Repository navigation
fix(snowflake): refuse a bare ALTER instead of panicking - #252
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The nightly fuzz run on main (#251) found a panic. A Snowflake
ALTERwith nothing after its optionalICEBERG, such asALTERalone or the first statement ofALTER;TABLE ..., made the opaque-statement check read the object kind past the last token.parse_statements_withandparse_tolerantboth panicked with "index out of bounds" instead of returning a parse error.Changes
ALTER,ALTER ICEBERG,ALTER;andALTER;TABLE t1 ADD COLUMN c1 INTin the parser's incomplete-SQL test.Closes #251.
Verification
cargo test -p sqlquack-syntax-snowflakepasses, including the ignored hostile-inputs termination test..,=), each alone, before or after;and aroundSELECT 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.ALTERandALTER ICEBERG, 4 in strict mode and 12 in tolerant mode. Every other parser and mode: 0.make check-ci RECORDER=0passes.