-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: name resolution/expansion is performed in-place in the AST #22847
Comments
This change adds infrastructure for annotating AST nodes. Only certain nodes can be annotated (currently `UnresolvedObjectName`). The parser sets up annotation indices for these nodes, and the annotations are stored in a separate Annotation container. The annotations will allow us to stop modifying the AST during type and semantic checking. The annotation for an `UnresolvedObjectName` will contain the resolved `*TableName`. See cockroachdb#34240 and cockroachdb#22847 for more context. Release note: None
This change adds infrastructure for annotating AST nodes. Only certain nodes can be annotated (currently `UnresolvedObjectName`). The parser sets up annotation indices for these nodes, and the annotations are stored in a separate Annotation container. The annotations will allow us to stop modifying the AST during type and semantic checking. The annotation for an `UnresolvedObjectName` will contain the resolved `*TableName`. See cockroachdb#34240 and cockroachdb#22847 for more context. Release note: None
37484: sql: add AST annotations r=RaduBerinde a=RaduBerinde #### sql: add AST annotations This change adds infrastructure for annotating AST nodes. Only certain nodes can be annotated (currently `UnresolvedObjectName`). The parser sets up annotation indices for these nodes, and the annotations are stored in a separate Annotation container. The annotations will allow us to stop modifying the AST during type and semantic checking. The annotation for an `UnresolvedObjectName` will contain the resolved `*TableName`. See #34240 and #22847 for more context. Release note: None #### sql: use UnresolvedObjectName in AlterTable Change AlterTable to contain an `UnresolvedObjectName`. Release note: None Co-authored-by: Radu Berinde <[email protected]>
We have marked this issue as stale because it has been inactive for |
Removing the erroneous-edge-case label because there are no known correctness issues - we don't reuse the AST because of these modifications. Leaving the issue open because we would like to stop making these modifications and reuse ASTs. |
The facilities
ResolveExistingName
/ResolveTargetName
/ColumnItemResolver
(previously:QualifyWithDatabaseName
,findColumn
) edit the AST node in-place (TableName
orColumnItem
).The result of this name resolution however are context-dependent on session variables and the current schema in KV: the current database, the search path, and the descriptors currently visible.
Therefore it is unsafe + incorrect to reuse the modified AST across multiple executes.
The fix for this must either avoid modifying the AST in-place, or ensure the modified AST is not reused.
cc @jordanlewis
Jira issue: CRDB-5841
The text was updated successfully, but these errors were encountered: