Skip to content

[CBRD-27101] Fix CALL statement prepare rejecting leading comments and whitespace - #7972

Draft
mhoh3963 wants to merge 1 commit into
CUBRID:developfrom
mhoh3963:cbrd-27101
Draft

mhoh3963 wants to merge 1 commit into
CUBRID:developfrom
mhoh3963:cbrd-27101

Conversation

@mhoh3963

Copy link
Copy Markdown
Contributor

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

CCI_PREPARE_CALL classified the statement with get_stmt_type(), which compares the head of the raw string, so a valid CALL preceded by a comment or whitespace was rejected with CAS_ER_INVALID_CALL_STMT. Add a non-destructive skip helper to the broker and to cubmethod, and apply it before out-parameter detection, while scanning for '=', and before classification. The '=' scan advances one position at a time and skips only comments, so existing forms such as "?:1 = CALL f()" keep working. The original SQL is preserved, so the execute-time recompile path is unaffected and the destructive ut_trim() call is no longer needed.

Base the unprepared fallback decision on the node type the parser produced rather than on the leading keyword, so REPLACE (PT_INSERT) and WITH ... UPDATE are deferred as intended instead of being rejected.

Behavior change: UPDATE STATISTICS with a semantic error now fails at prepare instead of at execute. get_stmt_type() matched only the first six characters and reported it as CUBRID_STMT_UPDATE; its grammar accepts only a class list, so no host variable can appear and the deferred recompile could never have succeeded.

Also pass the SQL to cubmethod::consume_tokens() by const reference. calculate_num_markers() called it once per comment or quoted token and copied the whole statement each time.

…d whitespace

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

CCI_PREPARE_CALL classified the statement with get_stmt_type(), which compares
the head of the raw string, so a valid CALL preceded by a comment or whitespace
was rejected with CAS_ER_INVALID_CALL_STMT. Add a non-destructive skip helper to
the broker and to cubmethod, and apply it before out-parameter detection, while
scanning for '=', and before classification. The '=' scan advances one position
at a time and skips only comments, so existing forms such as "?:1 = CALL f()"
keep working. The original SQL is preserved, so the execute-time recompile path
is unaffected and the destructive ut_trim() call is no longer needed.

Base the unprepared fallback decision on the node type the parser produced
rather than on the leading keyword, so REPLACE (PT_INSERT) and WITH ... UPDATE
are deferred as intended instead of being rejected.

Behavior change: UPDATE STATISTICS with a semantic error now fails at prepare
instead of at execute. get_stmt_type() matched only the first six characters and
reported it as CUBRID_STMT_UPDATE; its grammar accepts only a class list, so no
host variable can appear and the deferred recompile could never have succeeded.

Also pass the SQL to cubmethod::consume_tokens() by const reference.
calculate_num_markers() called it once per comment or quoted token and copied
the whole statement each time.
@github-actions

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)

@mhoh3963

Copy link
Copy Markdown
Contributor Author

@greptile 리뷰해주세요.

@github-actions

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 Sep 17, 2026

Copy link
Copy Markdown
Contributor

Retrigger

확인된 동작상 차단 결함은 없어 병합 가능한 상태로 보이지만, 수정된 CALL prepare 문법의 자동화 회귀 테스트를 추가하는 것이 바람직합니다.

Reviews (1) · Last reviewed commit: "[CBRD-27101] Fix CALL statement prepare ..."

Comment thread src/broker/cas_execute.c
Comment on lines 689 to +718
@@ -708,7 +714,8 @@ ux_prepare (char *sql_stmt, int flag, char auto_commit_mode, T_NET_BUF * net_buf
tmp++;
}

ut_trim (tmp);
/* skip again after removing "? =" before classifying the statement */
tmp = skip_leading_whitespace_and_comment (tmp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 CALL 회귀 테스트 누락

이번 수정의 핵심 경로인 CALL, ? = CALL, ?:1 = CALL 앞뒤의 공백과 연속 주석 처리를 검증하는 회귀 테스트가 추가되지 않았습니다. 특히 broker와 cubmethod가 동일한 스캔 동작을 별도로 구현하므로, 일반 CALL과 OUT 파라미터 형식에 --, //, /* ... */ 주석을 조합한 테스트를 두 경로 모두에 추가해야 향후 구현 간 동작 불일치를 방지할 수 있습니다.

@mhoh3963 mhoh3963 self-assigned this Sep 17, 2026
@mhoh3963 mhoh3963 added this to the guava milestone Sep 17, 2026
@mhoh3963

Copy link
Copy Markdown
Contributor Author

/run all

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.

1 participant