Skip to content

Fixed transaction handling for snowflake#2263

Open
romanoff wants to merge 2 commits intoapache:mainfrom
romanoff:fix_begin_transaction_for_snowflake
Open

Fixed transaction handling for snowflake#2263
romanoff wants to merge 2 commits intoapache:mainfrom
romanoff:fix_begin_transaction_for_snowflake

Conversation

@romanoff
Copy link
Contributor

@romanoff romanoff commented Mar 4, 2026

Sample query:

BEGIN TRANSACTION;
  DROP TABLE IF EXISTS bla;
COMMIT;

Spec: https://docs.snowflake.com/en/sql-reference/sql/begin

|| parser.peek_keyword(Keyword::WORK)
|| parser.peek_keyword(Keyword::NAME)
|| parser.peek_token().token == Token::SemiColon
|| parser.peek_token().token == Token::EOF
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a test case with only a begin keyword (for the EOF case)?

// Snowflake supports both `BEGIN TRANSACTION` and `BEGIN ... END` blocks.
// If the next keyword indicates a transaction statement, let the
// standard parse_begin() handle it.
if parser.peek_keyword(Keyword::TRANSACTION)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use parser.peek_one_of_keywords() and parser.peek_token_ref() for the two cases to simplify or make the op less expensive?

@romanoff
Copy link
Contributor Author

romanoff commented Mar 5, 2026

@iffyio Updated. Thank you

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.

2 participants