fix(cli): do not split BEGIN...END script blocks on inner semicolons#786
Conversation
34e43ea to
2f45409
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e23f509851
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0b2b62a to
1985fa8
Compare
cf050c6 to
8caf8a3
Compare
45e71d4 to
f46489a
Compare
|
@codex review |
65bafc2 to
d39c263
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65bafc2627
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
da33a78 to
e04e55f
Compare
e04e55f to
523cfe6
Compare
dbee801 to
e583210
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e583210670
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
e583210 to
1c87e7b
Compare
1c87e7b to
899b036
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
899b036 to
a0d0387
Compare
The SQL statement splitter treated every semicolon as a statement
boundary, which broke multi-statement CREATE TASK blocks:
CREATE TASK t1 AS
BEGIN
select 1;
select 2;
END;
The splitter would send only 'CREATE TASK t1 AS BEGIN select 1' to the
server, causing a parse error.
Fix: track AS BEGIN...END block depth. Only a semicolon immediately
after a bare END token (not END IF, END FOR, etc.) closes the block.
Transaction BEGIN statements are unaffected because they are not
preceded by AS.
Closes databendlabs#785
a0d0387 to
3f351a1
Compare
Summary
Fix multi-statement
CREATE TASK ... AS BEGIN ... ENDblocks being incorrectly split on inner semicolons.Closes #785
Motivation
When a user runs a
CREATE TASKwith aBEGIN...ENDscript block in bendsql, the client-side statement splitter treats every;as a statement boundary. This causes only the fragment up to the first inner semicolon to be sent to the server, resulting in a parse error. The same SQL works fine in Databend Cloud worksheet.Changes
AS BEGIN...ENDblock depth inparse_statements(). Only enter block mode whenBEGINis immediately preceded byAS(distinguishing script blocks from transactionBEGIN).END(i.e.END;), which closes the block.END IF;,END FOR;, etc. do not close the block.test = true).Testing
Added 9 unit tests covering:
CREATE TASK ... AS BEGIN ... END;treated as single statement;BEGIN;(transaction) still splits correctlyBEGIN TRANSACTION;still splits correctlyEND IF;) does not close the blockCREATE PROCEDUREwith$$quoting works correctlyCREATE PROCEDUREfollowed by another statement splits correctlyAll 13 tests in
cargo test -p bendsqlpass.