-
Notifications
You must be signed in to change notification settings - Fork 134
[CBRD-26006] Scale Range Expansion and Floating-Point NUMERIC Type Support #6486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jongmin-won
wants to merge
7
commits into
develop
Choose a base branch
from
feature/scale_range_fp_numeric
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
http://jira.cubrid.org/browse/CBRD-26243 Purpose 1. Extension of the maximum NUMERIC range - Exponential form: 1.0 * 10^-252 <= |Value| < 1.0 * 10^254 - Precision: 1 <= prec <= 43 - Scale: -211 <= scale <= 252 2. Extension of the maximum range and scale for Fixed NUMERIC - Exponential form: 1.0 * 10^-127 <= |Value| < 1.0 * 10^122 - Precision: 1 <= prec <= 38 - Scale: -84 <= scale <= 127 3. Modification of NUMERIC literal parsing logic - Parse integer and fractional parts separately - Interpret precision and scale consistently, following Oracle’s approach - Apply rounding when the maximum number of significant digits is exceeded - Do not remove trailing zeros; behavior remains the same as before Remarks 1. In Numeric parsing, DB_MAX_NUMERIC_PRECISION(43) is temporarily replaced with phase_1_tmp_max_prec(38). - Currently (Phase-1), only the maximum range extension of NUMERIC has been applied. Using DB_MAX_NUMERIC_PRECISION(43) as is would not work correctly. - Therefore, the full NUMERIC range (43, -211) is not yet supported. Only values within 1 <= prec <= 38 and -84 <= scale <= 127 are guaranteed to work properly.
…' into feature/scale_range_fp_numeric
…odified for extended scale range (2/2) (#6520) http://jira.cubrid.org/browse/CBRD-26317 Arithmetic Operations and Built-in Function Updates Following Scale (Fixed Numeric) and NUMERIC Range Expansion 1. Arithmetic Operations 1-1. Added - New arithmetic functions are used for DB_TYPE_NUMERIC. - Functions: fp_numeric_db_value_(add, sub, mul, div) 1-2. Modified - Existing arithmetic functions are used for Serial, DB_TYPE_SHORT, DB_TYPE_INTEGER, and DB_TYPE_BIGINT. - Functions: numeric_db_value_(add, sub, mul, div) 2. NUMERIC Mapping Table Expansion - Fixed Numeric: Used to check precision overflow. - FP Numeric: Used to calculate precision (significant digits) directly from db_value data. 3. Comparison Operations - Added fp_numeric_compare() to support comparison up to the expanded scale range. 4. Built-in Functions 4-1. Added 1) MOD() - Previous: Calculated using double precision and returned as a double value. - Changed: Uses fp_numeric and returns a Numeric value (Improved precision, available only for DB_TYPE_NUMERIC). 4-2. Modified 1) abs(), round(), trunc() - Buffer expanded for base-256 -> decimal string conversion. 2) typeof() - Negative scale output supported. - When precision = DB_MAX_NUMERIC_PRECISION, omit precision/scale and display only NUMERIC (to be verified in Phase-3). 3) floor(), ceil() - Fixed overflow when scale > 38 during conversion from decimal string to base-256. 4) WIDTH_BUCKET() - Core dump for values >= 39 digits -> replaced sub/div operations with fp_sub/fp_div. 5) MIN(), MAX() - Fixed scale overgrowth in PT_TYPE_NUMERIC domain calculation. 6) TO_NUMBER() - Extended format range. - The previous scale limit (0–15) had no clear reason. - Although extension beyond 15 was considered, the upper bound remains 15 to avoid potential side effects.
http://jira.cubrid.org/browse/CBRD-26367 In the previous (develop) version, Fixed Numeric values were always stored using a fixed 16-byte layout. With this update, they are now stored using a variable-length format depending on their precision. For Floating Numeric values, the precision at input time cannot be determined in advance, so they are always stored using the maximum size: 20 bytes (2-byte header + 18-byte data for precision 43). - Header: 2 bytes - Data area for precision 43: 18 bytes - Total size: 20 bytes 1. DB_MAX_NUMERIC_PRECISION Increased - The maximum precision has been expanded from 38 digits to 43 digits. 2. Numeric Rounding Rule Updated - Until phase-1, values exceeding 38 digits were rounded at the 39th digit. - Starting from phase-2, rounding is performed at the 44th digit when exceeding 43 digits. 3. Fixed Numeric Storage Changed from Fixed to Variable Length - Previously, Fixed Numeric values were always stored in a 16-byte fixed format. - They are now stored using a variable-length format based on the precision value. - Length calculation: - log10(256) = 2.40824 - byte = ceil(precision / log10(256))
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-26006
Purpose
기존 Fixed NUMERIC 타입에는 다음과 같은 제약이 있습니다.
이러한 제약을 개선하기 위해 Scale 범위 확장과 Precision/Scale 미지정 시 Floating-Point NUMERIC 타입 지원을 단계적으로 구현합니다.
Phase-1. Fixed NUMERIC의 최대 범위 및 scale 범위 확장 (1/2) : #6385
1) Fixed NUMERIC의 최대 범위 및 scale 범위 확장
2) 리터럴 값 NUMERIC Parsing 로직 수정
3) NUMERIC 최대 범위 확장 (Phase-1 에서 범위만 확장 했으며, 해당 구현은 Phase-3 에서 정상 동작 예정)
Phase-1. Scale 범위 확장에 따른 산술 연산 및 내장 함수 수정 (2/2) : #6520
1) 산술 연산
1-1) 추가
1-2) 수정
2) 비교 연산
2-1) 추가
3) NUMERIC 매핑(lookup) 테이블 확장
powers_of_10[10^n][10^n 값을 base-256으로 변환한 바이트 값]_gv_powers_of_10_significant_bytes[POW10_BUF_SIZE]4) 내장 함수
4-1) 추가
4-2) 수정
Phase-2. NUMERIC 저장 방식 개선 : #6623
Implementation
N/A
Remarks
N/A