Conversation
heap_attrinfo_set runs the full generic pipeline for every value of every row -- attrvalue locate, type table lookup, domain re-init, tp_domain_check, setval dispatch -- although the verdict is the same for every row of a multi-row INSERT. A value that already fits the column domain is now handed over by struct copy after the per-row guards (NULL, string length, codeset, collation); anything else keeps the generic path, so coercion and error semantics are unchanged. The slow path passes strings by reference as well (setval with copy == false), so the shallow copy does not change ownership, and the copy carries the column's precision the way the coercion would. Precision counts characters, so byte size alone would exclude a multi-byte value that fills the column; the character count is asked for only when byte size does not already settle it, which is the case the generic path would count as well. Marginal cost per value drops from 0.77us to 0.40us (1-column vs 9-column INSERT..SELECT scaling, 400k rows). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CHAR was left out of the shortcut because the column keeps trailing-space padding, and a struct copy does not pad. But the padding does not happen when the value is placed -- it happens on the way out, in mr_lengthval_char_internal and mr_writeval_char_internal, and it is keyed off the precision the value carries. So the shortcut only has to stamp the column precision, which it already does for VARCHAR. Without the stamp the precision stays floating, which is how both a literal and a bound value arrive, and the padding block is skipped entirely -- for CHAR that stamp is data correctness, not display consistency. Nothing reads the value between heap_attrinfo_set and heap_attrinfo_transform_to_disk: index keys are read back from the built record, and REPLACE builds its own record first. So handing the value over still unpadded is not observable. heap_attrinfo_set drops from 0.78% to 0.22% of server samples on a bound CHAR(120) + CHAR(60) insert, matching what VARCHAR already cost, and the coercion symbols leave the profile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
✅ TC Merge Gate — Merge AllowedAll TC PRs are merged, closed, or not present. TC Repositories & Branches:
|
🧪 TC Test Environment ReadyCircleCI Testing:
TC Repositories & Branches:
Next Steps:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
http://jira.cubrid.org/browse/CBRD-27246
Purpose
heap_attrinfo_set이 값마다 범용 절차를 전부 거친다. 표 조회, 대상 초기화, 도메인 대조, 함수 포인터 호출이 값이 이미 컬럼과 맞는 흔한 경우에도 그대로 난다. 타입이 맞는 값은 구조체 복사로 넘긴다.Implementation
HEAP_WRITTEN_ATTRVALUE로 표시하고 돌아간다. 어긋나면 기존 절차로 간다.CHAR·VARCHAR다. 문자셋·정렬 규칙이 같고is_max_string이 아니어야 한다. NULL, 집합, LOB, 타입이 다른 값은 기존 절차를 그대로 거친다.Remarks
need_clear를false로 명시해 해제 책임을 원본에 남긴다. 기존 절차도 비집합 타입은setval을copy == false로 부르므로 소유 관계가 달라지지 않는다.CHAR의 공백 채우기는 값을 앉히는 시점이 아니라mr_lengthval_char_internal과mr_writeval_char_internal이 쓰는 시점에 한다. 그 채우기가 값이 든 정밀도를 기준으로 하므로 위의 정밀도 도장이CHAR에서는 데이터 정합성 문제다. 없으면 정밀도가-1로 남아 채우기가 통째로 건너뛰어진다.REPLACE는 자기 레코드를 먼저 굽는다.TP_EXACT_MATCH가 통과했을 조건과 같은 항목을 직접 비교하고, 하나라도 어긋나면 원래 코드가 그대로 실행된다. 다른 점은 정밀도를 더 넓게 본다는 것뿐이고, 그 차이는 컬럼 정밀도를 찍어 메운다.