Conversation
Both statements are accepted with -dialect postgresql, so that migration files that install pg_trgm and friends can be fed to sqlgg unchanged. sqlgg keeps no extension state, so there is nothing to track: the optional SCHEMA, VERSION and CASCADE clauses are parsed and discarded, an extension can be dropped without having been created, and the statements evaluate to Stmt.Other rather than getting a statement kind of their own. They are gated behind a new `extension` dialect feature, PostgreSQL only, like the existing `user_defined_type` gate on CREATE TYPE. `extension`, `schema` and `version` become keywords, so they are added to `ident` to keep them unreserved, the way `type` already is. Being unreserved, they also join the filter in lsp/completion.ml that already excluded `type`: the recovering parser accepts an unreserved keyword wherever an identifier fits, so without this they would be offered as keyword completions in every completion list. CREATE EXTENSION's trailing `[ WITH ] ...` clause is ambiguous with a following statement that starts with a WITH (a CTE), which LR(1) cannot resolve. Both statements therefore live in a new `top_statement` rule used only by `input`, where EOF bounds the clause. Extensions are database-global DDL that has no business in a routine body anyway. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Niols
force-pushed
the
psql-create-drop-extension
branch
from
September 15, 2026 18:09
bb82bcc to
ae8719e
Compare
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.
Both statements are accepted with -dialect postgresql, so that migration files that install pg_trgm and friends can be fed to sqlgg unchanged.
sqlgg keeps no extension state, so there is nothing to track: the optional SCHEMA, VERSION and CASCADE clauses are parsed and discarded, an extension can be dropped without having been created, and the statements evaluate to Stmt.Other rather than getting a statement kind of their own.
They are gated behind a new
extensiondialect feature, PostgreSQL only, like the existinguser_defined_typegate on CREATE TYPE.extension,schemaandversionbecome keywords, so they are added toidentto keep them unreserved, the waytypealready is.CREATE EXTENSION's trailing
[ WITH ] ...clause is ambiguous with a following statement that starts with a WITH (a CTE), which LR(1) cannot resolve. Both statements therefore live in a newtop_statementrule used only byinput, where EOF bounds the clause. Extensions are database-global DDL that has no business in a routine body anyway.