Skip to content

fix(syntax): parse Snowflake ALTER APPLICATION ROLE and DATABASE ROLE by their grammar - #48

Merged
kvlonge merged 3 commits into
mainfrom
fix/alter-role-routing
Nov 4, 2026
Merged

kvlonge merged 3 commits into
mainfrom
fix/alter-role-routing

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Fixes a regression from #45: ALTER APPLICATION ROLE and ALTER DATABASE ROLE were routed into the new ALTER APPLICATION / ALTER DATABASE parsers, which refused role actions such as RENAME TO and SET COMMENT. Before #45 these fell to the raw fallback, which accepted everything.

The fix parses both kinds by their grammar: [ IF EXISTS ] <name> then RENAME TO <name>, SET <properties> or UNSET <properties>. When RENAME, SET or UNSET follows the kind, ROLE is read as the application or database name, as Snowflake does (those cases are recorded with errno 2003).

Checked against every receipted case for both kinds (109): the 58 that Snowflake parsed are accepted and the 51 it refused with a syntax error are refused. The test table in test_fixes.rs carries six of them.

Gate: make check-merge RECORDER=0 exited 0 on head 2f0c38a (main 3d11e66 merged in).

… to the role parser

The ALTER APPLICATION and ALTER DATABASE matchers took the kind word before
checking for a following ROLE, so role actions such as RENAME TO and SET
COMMENT were refused.
… by their grammar

Both kinds take RENAME TO, SET or UNSET; when one of those follows the kind,
Snowflake reads ROLE as the application or database name. All 109 receipted
role cases agree: 58 parse and 51 are refused.
@kvlonge
kvlonge merged commit 2f0c38a into main Nov 4, 2026

kvlonge commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Gate: make check-merge RECORDER=0 exited 0 on 2f0c38a (main 3d11e66 merged in). Landed as a fast-forward with git push origin 2f0c38a7:main (D122d), so the merge tree is the gated tree. Receipt check: all 109 receipted ALTER APPLICATION ROLE / DATABASE ROLE cases agree (58 parse, 51 refused).

kvlonge added a commit that referenced this pull request Nov 4, 2026
…ified)

Basis: main 2f0c38a (PR #46, #48), catalogue b7d45d5, evidence e68cfb2,
parser tree 4b9e8db.

- 86 forms approved (functions 34, ddl 20, scripting 13, expressions 6,
  transaction_session 6, utility 5, query 2): newly eligible forms, forms
  whose earlier findings or withholds are fixed (DROP SEQUENCE RESTRICT
  included), and re-reads of reviews made stale by re-rendered cases.
- Not approved: 12 catalogue findings and 6 parser withholds (INSERT
  VALUES DEFAULT, SELECT ALL, APPROX_COUNT_DISTINCT DISTINCT, TIMESTAMP
  WITHOUT TIME ZONE, START TRANSACTION NAME, USE SECONDARY ROLES list).

Checker at 2f0c38a: valid, 3476 forms, 0 problems; 1468 of 3348 verified.
kvlonge added a commit that referenced this pull request Nov 5, 2026
…on names and role lists

From the omission audit after #46 and #48:
- SELECT ALL sets select.all; it was consumed and dropped.
- An aggregate of several arguments, such as APPROX_COUNT_DISTINCT
  ( DISTINCT a , b ), keeps distinct; the generic call dropped it.
- TIMESTAMP [ ( p ) ] WITHOUT TIME ZONE is TIMESTAMP_NTZ, as its synonyms
  are, not bare TIMESTAMP (whose meaning follows TIMESTAMP_TYPE_MAPPING).
- START TRANSACTION NAME n keeps n as the name, quoting kept, apart from NAME.
- USE SECONDARY ROLES lists each role with its quoting in use.roles.
@kvlonge
kvlonge deleted the fix/alter-role-routing branch November 9, 2026 21:31
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