Skip to content

[CBRD-26935] Fix debug-only abort when serial next_value/current_value is used in UNION/CTE#7302

Open
jongmin-won wants to merge 8 commits into
CUBRID:developfrom
jongmin-won:CBRD-26935
Open

[CBRD-26935] Fix debug-only abort when serial next_value/current_value is used in UNION/CTE#7302
jongmin-won wants to merge 8 commits into
CUBRID:developfrom
jongmin-won:CBRD-26935

Conversation

@jongmin-won

Copy link
Copy Markdown
Contributor

http://jira.cubrid.org//browse/CBRD-26935

Purpose

serial 의 next_value / current_value 를 UNION·집합연산·재귀 CTE·뷰 정의에서 사용할 때, debug 빌드에서 assertion 으로 abort 하는 문제를 수정합니다.

  • 재현 쿼리 (debug 빌드에서 abort):
    create serial s start with 1;
    
    select s.next_value union all select s.next_value;
    select s.current_value union all select s.current_value;
  • release 빌드에서는 assert_release 가 abort 하지 않고 notification 만 남기므로 crash 가 발생하지 않습니다.
  • 즉 특정 버전에서 생긴 회귀가 아니라, 모든 버전에 존재해 온 debug 전용 잠재 버그입니다.

Implementation

원인

  • next_value / current_value 는 결과 타입이 PT_TYPE_NUMERIC 이지만, semantic check 단계에서 data_type(precision/scale)이 설정되지 않아 NULL 로 남습니다. (도메인은 xasl_generation.cpt_make_prim_data_type 단계에서야 부여됨)
  • type_checking.cpt_upd_domain_info() switch (op)PT_NEXT_VALUE / PT_CURRENT_VALUE case 가 없어 default 로 빠지고, node->data_type 이 설정되지 않습니다.
  • UNION/CTE 컬럼 호환성 검사(pt_union_compatiblept_to_compatible_cast / pt_is_compatible_without_cast)는 "NUMERIC 이면 data_type 이 있다"고 가정하므로, data_type 이 NULL 인 next_value 가 들어오면 assertion 에서 abort 합니다.

수정

  • pt_upd_domain_info() 에서 PT_NEXT_VALUE / PT_CURRENT_VALUEfixed NUMERIC(38,0) data_type 을 부여합니다.
    • precision = DB_MAX_FIXED_NUMERIC_PRECISION(38), scale = DB_DEFAULT_NUMERIC_SCALE(0)
  • serial 저장값(db_serial.current_val)이 모든 버전에서 NUMERIC(38,0) (fixed) 이므로 next_value / current_value 도 fixed(38,0) 으로 수정 합니다.
    • float numeric(40,0) 으로 가면 serial 의 유일성/정밀도 의미가 깨질 수 있어 fixed 여야 합니다.
  • 결과적으로 UNION 양쪽 next_value 가 동일한 (38,0) 도메인이 되어 PT_UNION_COMP 로 판정 → cast 불필요 → 정상 동작.

관련 파일

  • src/parser/type_checking.cpt_upd_domain_info (수정 지점)
  • src/parser/semantic_check.cpt_union_compatible, pt_to_compatible_cast, pt_is_compatible_without_cast (assertion 위치)
  • src/parser/xasl_generation.c — next_value 도메인 생성(pt_make_prim_data_type)
  • src/object/schema_system_catalog_install.cppdb_serial.current_val = NUMERIC(38,0)

Remarks

발생 조건 (두 조건의 교집합)

  • (1) NUMERIC 이면서 data_type 이 NULL 인 노드 → 실질적으로 serial 의 next_value / current_value 뿐 (TO_NUMBER, LAST_INSERT_ID 는 도메인이 부여되므로 해당 없음)
  • (2) 집합연산/CTE 컬럼 호환성 검사가 도는 위치 → UNION / UNION ALL / INTERSECT / DIFFERENCE(EXCEPT) / 재귀 CTE / union 을 사용하는 VIEW 정의
  • (1) × (2) 가 만날 때만 발생. 단일 SELECT s.next_value 는 호환성 cast 가 없어 발생하지 않음.

영향 빌드

  • 11.5 dev / 11.4 (최신) — debug 빌드 (release 는 crash 미발생)

@jongmin-won jongmin-won self-assigned this Jun 16, 2026
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

✅ TC Merge Gate — Merge Allowed

All TC PRs are merged, closed, or not present.

TC Repositories & Branches:

  • cubrid-testcases: No open TC PR (merged, closed, or not created)
  • cubrid-testcases-private-ex: No open TC PR (merged, closed, or not created)

@jongmin-won

Copy link
Copy Markdown
Contributor Author

@greptile

수정 된 내용에 대해 리뷰 해줘

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

🧪 TC Test Environment Ready

CircleCI Testing:

  • CircleCI will automatically test using the branches below.

TC Repositories & Branches:

Next Steps:

  1. Wait for CircleCI tests to complete
  2. If CircleCI tests failed, please check the test results and fix the issues.
  3. When ready to merge this PR, please merge the TC PR first, then merge this PR.

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "[CBRD-26935] Fix debug-only abort when s..." | Re-trigger Greptile

Comment thread src/parser/type_checking.c
Comment thread src/parser/type_checking.c
…(debug abort + ER_QPROC_INCOMPATIBLE_TYPES)

next_value/current_value 는 결과가 PT_TYPE_NUMERIC 이지만 pt_upd_domain_info() 에
해당 op case 가 없어 semantic 단계에서 data_type 이 NULL 로 남았다. UNION/집합연산/재귀
CTE 의 컬럼 호환성 검사가 NUMERIC 에 data_type 이 있다고 가정하므로 debug 빌드에서
assertion 으로 abort 했다 (release 미발생).

또한 XASL 생성(pt_to_regu_variable)이 serial 의 regu 도메인을 float NUMERIC(40,0) 으로
만들어 semantic 도메인(38,0)과 어긋났다. 이 때문에 파생 서브쿼리로 NUMERIC(38,0) 으로
해석된 serial 컬럼과 bare serial 값을 UNION 하면 list-file 병합(qfile_unify_types)에서
ER_QPROC_INCOMPATIBLE_TYPES 가 발생했다.

- type_checking.c (pt_upd_domain_info): NEXT_VALUE/CURRENT_VALUE 에 fixed NUMERIC(38,0) data_type 부여
- xasl_generation.c (pt_to_regu_variable): serial regu 도메인도 fixed NUMERIC(38,0) 으로 정합

serial 저장값(db_serial.current_val)이 NUMERIC(38,0) 이고 값이 정수 <=38자리라 무손실.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jongmin-won jongmin-won marked this pull request as ready for review June 16, 2026 06:31
@jongmin-won jongmin-won requested a review from beyondykk9 as a code owner June 16, 2026 06:31
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "[CBRD-26935] Fix serial next_value/curre..." | Re-trigger Greptile

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

Comment thread src/parser/xasl_generation.c
@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@jongmin-won jongmin-won reopened this Jun 22, 2026
@github-actions

Copy link
Copy Markdown

🗑️ TC Branch Finalized for cubrid-testcases-private-ex

Engine PR was closed (not merged).

Cleanup Results:

TC base branch is ready for the next PR.

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Reviews (6): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (7): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won

Copy link
Copy Markdown
Contributor Author

#7288 PR merge를 기다리는 중 (merge 이후 test_shell(cbrd_26911.sh) 통과 가능).

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (8): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (9): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won jongmin-won reopened this Jun 29, 2026
@github-actions

Copy link
Copy Markdown

🗑️ TC Branch Finalized for cubrid-testcases-private-ex

Engine PR was closed (not merged).

Cleanup Results:

TC base branch is ready for the next PR.

@github-actions

Copy link
Copy Markdown

🗑️ TC Branch Finalized for cubrid-testcases

Engine PR was closed (not merged).

Cleanup Results:

TC base branch is ready for the next PR.

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Reviews (10): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won

Copy link
Copy Markdown
Contributor Author

/run all

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Reviews (11): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

@jongmin-won jongmin-won reopened this Jun 30, 2026
@github-actions

Copy link
Copy Markdown

🗑️ TC Branch Finalized for cubrid-testcases

Engine PR was closed (not merged).

Cleanup Results:

TC base branch is ready for the next PR.

@github-actions

Copy link
Copy Markdown

🗑️ TC Branch Finalized for cubrid-testcases-private-ex

Engine PR was closed (not merged).

Cleanup Results:

TC base branch is ready for the next PR.

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Reviews (12): Last reviewed commit: "Merge remote-tracking branch 'upstream/d..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants