Repository navigation
[CBRD-27826] [Backport-11.0.17] Coerce an empty or whitespace-only string to NUMERIC 0, the same as the other numeric types - #8331
Merged
Conversation
…the same as the other numeric types http://jira.cubrid.org/browse/CBRD-27826 CBRD-26749 made an empty string ('') and a whitespace-only string (' ') an error when coerced to NUMERIC, while the other numeric types coerce them to 0 and NUMERIC itself stored NULL before CBRD-26749 (SUPPORT-1206). - Coerce them to NUMERIC 0 in numeric_coerce_string_to_num (). - Add hidden parameter numeric_empty_string_as_null (default no, applied on restart); yes coerces them to NULL as before CBRD-26749. A zero-padded string ('000') stays 0, and the other strings without a digit ('+', '-', '.') stay an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…added NUMERIC string http://jira.cubrid.org/browse/CBRD-27826 When no digit is found, fill num_string with a single '0' and let it take the common terminator and conversion, instead of building 0 in two branches. No change in behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ull parameter http://jira.cubrid.org/browse/CBRD-27826 - Drop PRM_FORCE_SERVER. The server sends every FORCE_SERVER parameter to a connecting client by id, and a client without this parameter would index past its parameter table. Client and server now read their own cubrid.conf, and PRM_FOR_QRY_STRING keeps clients with different values from sharing a cached plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jongmin-won
marked this pull request as ready for review
October 29, 2026 11:37
Contributor
|
[Medium impact] The change reaches shared string-to-numeric conversion paths. C API에서도 새 NULL 변환 설정이 동작하도록 수정한 뒤 병합해야 합니다. Reviews (1) · Last reviewed commit: "[CBRD-27826] Drop PRM_FORCE_SERVER from ..." · Reviewed by Greptile |
…he coercion http://jira.cubrid.org/browse/CBRD-27826 With numeric_empty_string_as_null=yes, '' and a whitespace-only string are NULL as NUMERIC only after the coercion, after the checks that assume a non-NULL value stays non-NULL. Handle that NULL where the coercion happens. - heap_attrinfo_set (): a non-NULL value that is NULL after the coercion to a NOT NULL attribute is a NOT NULL violation. INSERT ... SELECT, UPDATE with a subquery, ON DUPLICATE KEY UPDATE and REPLACE checked the constraint before the coercion and stored NULL, also into a primary key. - scan_dbvals_to_midxkey (): a key value that is NULL after the coercion matches no row, the same as a NULL key value. A multi-column index scan with such a value hit an assertion. - heap_object_upgrade_domain (): allow this NULL in the assertion when ALTER changes a string attribute to NUMERIC. ALTER to NOT NULL is rejected by the existing check after the upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n attribute already NOT NULL in ALTER http://jira.cubrid.org/browse/CBRD-27826 - heap_object_upgrade_domain (): ALTER checks existing NULL values only when NOT NULL is newly added, so an attribute already NOT NULL stored NULL when '' became NULL as NUMERIC with numeric_empty_string_as_null. Treat it as a conversion failure: an error with alter_table_change_type_strict, and the default value of the domain otherwise. - heap_attrinfo_set (): drop the always-true !DB_IS_NULL (attr_val), and note that a failed coercion with return_null_on_function_errors is also NULL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kangmin5505
approved these changes
Oct 30, 2026
jongmin-won
added a commit
that referenced
this pull request
Nov 19, 2026
…ing to NUMERIC 0, the same as the other numeric types (#8421) http://jira.cubrid.org/browse/CBRD-27826 Backport of #8326 (11.4) to 11.3.7, the same change as #8331 (11.0). 11.3 has no PL/CSQL, so only the engine C code is changed. CBRD-26749 made an empty string ('') and a whitespace-only string (' ') an error when coerced to NUMERIC, while the other numeric types coerce them to 0 and NUMERIC itself stored NULL before CBRD-26749 (SUPPORT-1206). - Coerce them to NUMERIC 0 in numeric_coerce_string_to_num (). A zero-padded string ('000') stays 0, and a string without a digit ('+', '-', '.') stays an error. - Add the hidden parameter numeric_empty_string_as_null (default no, applied on restart). With yes, they are NULL as before CBRD-26749. - With the parameter, the NULL appears only after the coercion. Handle it where the coercion happens: - heap_attrinfo_set (): a NULL into a NOT NULL attribute is a NOT NULL violation. INSERT ... SELECT, UPDATE with a subquery, ON DUPLICATE KEY UPDATE and REPLACE stored NULL, also into a primary key. A failed coercion with return_null_on_function_errors is caught as well. - scan_dbvals_to_midxkey (): a NULL key value matches no row, instead of an assertion on a multi-column index scan. - heap_object_upgrade_domain (): ALTER to NUMERIC keeps the NULL. For an attribute already NOT NULL, it is a conversion failure: an error with alter_table_change_type_strict, and the default value otherwise.
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-27826
Backport of #8326 to 11.0.17. (엔진 C 코드만 해당, 11.0에는 PL/CSQL이 없어 Java 변경 없음)
Purpose
'')과 공백만 있는 문자열(' ')도 에러로 바뀌었습니다.Implementation
numeric_coerce_string_to_num ()'',' ')를 나머지와 분리했습니다.numeric_empty_string_as_null = yes이면 NULL입니다.'0','000')은 파라미터와 관계없이 지금처럼 0입니다.'+','-','.','+.')은 지금처럼 에러입니다.히든 파라미터
numeric_empty_string_as_null추가 (bool, 기본값 no)PRM_FOR_SERVER | PRM_FOR_CLIENT | PRM_FOR_QRY_STRING | PRM_HIDDENPRM_FOR_QRY_STRING: 값이 기본값과 다르면 XASL 캐시 키에 들어가, 값이 다른 클라이언트끼리 캐시된 플랜(상수 계산 결과 포함)을 공유하지 않습니다. (oracle_style_empty_string과 같음)SET SYSTEM PARAMETERS로 변경 불가)PRM_FORCE_SERVER(접속 시 서버 값을 클라이언트에 전달)는 쓰지 않습니다.Result
Before
''' '''' 'c_num 변환이 실패한 행은 INSERT 전체가 실패해서 저장되지 않습니다.
After
''' '''' '''' '''' '리터럴, 바인드,
CAST,UPDATE,NUMERIC(p,s), 정밀도 없는NUMERIC모두 같은 결과입니다. (11.0 release 빌드, SA로 확인)Remarks
numeric_empty_string_as_null = yes로 설정할 때''와 공백 문자열만 26749 이전처럼 NULL이 됩니다.'+','-','.'은 계속 에러입니다.''·공백 문자열은 변환 후에야 NULL이 되므로, 변환 전 값으로 NULL을 판단하던 아래 경우를 함께 처리했습니다. (26749 이전부터 있던 결함)INSERT ... SELECT,UPDATE ... SET n = (SELECT ...),ON DUPLICATE KEY UPDATE,REPLACE로 NOT NULL·PK 컬럼에 넣으면 NULL이 저장되던 것을 NOT NULL 위반 에러로 막습니다. (heap_attrinfo_set ())return_null_on_function_errors=yes에서 변환에 실패해 NULL이 된 값도 같은 경로라 함께 막힙니다. (타입 무관)scan_dbvals_to_midxkey ())ALTER TABLE ... MODIFY로 문자열 컬럼을 NUMERIC으로 바꾸면 debug 빌드가 assert로 종료되던 것을 막습니다. (heap_object_upgrade_domain ())''·공백 행은 26749 이전처럼 NULL이 됩니다. NOT NULL 컬럼이면 변환 실패와 같이alter_table_change_type_strict=yes에서는 에러, no에서는 타입 기본값(0)입니다. (원래 NOT NULL인 컬럼 포함)DEFAULT ''(DDL 시점에 변환되어 저장)바뀌지 않는 것
oracle_style_empty_string = yes이면''는 변환 전에 NULL이 되므로 모든 숫자 타입이 NULL입니다.TO_NUMBER(''),TO_NUMBER(' ')는 자체 형식 해석을 거쳐 지금처럼 에러입니다. (9.3부터 같음)'',' '를 0으로 바꾸지 않고 에러를 냅니다. 11.0의 기존 동작이며 이번 범위가 아닙니다. (11.4는 0)