Skip to content

fix(snowflake): refuse a bare ALTER instead of panicking - #252

Merged
kvlonge merged 1 commit into
mainfrom
fix/bare-alter-panic
Nov 18, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/bare-alter-panic

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Why

The nightly fuzz run on main (#251) found a panic. A Snowflake ALTER with nothing after its optional ICEBERG, such as ALTER alone or the first statement of ALTER;TABLE ..., made the opaque-statement check read the object kind past the last token. parse_statements_with and parse_tolerant both panicked with "index out of bounds" instead of returning a parse error.

Changes

  • The opaque-statement check refuses an ALTER or CREATE that ends before its object kind with "Expected an object kind and a name", the error a bare CREATE already gives.
  • The kind's words are read with bounds checks.
  • Regression cases for ALTER, ALTER ICEBERG, ALTER; and ALTER;TABLE t1 ADD COLUMN c1 INT in the parser's incomplete-SQL test.

Closes #251.

Verification

  • The new cases panic on main at snowflake_opaque.rs:44 and pass with the fix. cargo test -p sqlquack-syntax-snowflake passes, including the ignored hostile-inputs termination test.
  • Cross-dialect probe: 101 statement verbs (ALTER, DROP, CREATE, CREATE OR REPLACE, UNDROP, TRUNCATE, COMMENT ON, GRANT, SHOW, INSERT, MERGE, COPY INTO and others) times 72 object kinds (none, TABLE, WAREHOUSE, ICEBERG, OPENFLOW CONNECTOR, NOTEBOOK PROJECT, MODEL MONITOR and others) times 9 tails (none, IF, IF EXISTS, IF NOT EXISTS, a name, ., =), each alone, before or after ; and around SELECT 1: 392,688 inputs. Run through all 8 parsers in strict and tolerant mode (Snowflake and DuckDB through the shared parser, plus BigQuery, ClickHouse, Databricks, DuckDB, PostgreSQL, SQLite and SQL Server), counting panics a parser catches itself.
    • main: 16 panics, all in the shared parser under Snowflake: ALTER and ALTER ICEBERG, 4 in strict mode and 12 in tolerant mode. Every other parser and mode: 0.
    • this branch: 0 panics in all 18 parser modes.
  • The nightly fuzz artifact gives a clean parse error in both modes.
  • make check-ci RECORDER=0 passes.

An ALTER with nothing after it, such as `ALTER` or the first statement of
`ALTER;TABLE ...` under tolerant parsing, reached the opaque statement
check with its object kind past the last token, and the check indexed
past the end of the token list. Every parse entry point that reads
Snowflake panicked on it, which the nightly fuzz run found.

The opaque check now refuses an ALTER or CREATE that ends before its
object kind with "Expected an object kind and a name", the error a
bare CREATE already gives, and reads the kind's words with bounds
checks.
@kvlonge
kvlonge enabled auto-merge November 18, 2026 13:25
@kvlonge
kvlonge added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 57e8722 Nov 18, 2026
9 checks passed
@kvlonge
kvlonge deleted the fix/bare-alter-panic branch November 18, 2026 14:41
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.

Nightly CI failed

1 participant