Repository navigation
refactor(catalog): return resolved references from resolve - #867
Merged
Merged
Conversation
Generalise the function call recording of the resolver into opt-in references on Resolution: function calls, columns and relations that resolve to exactly one object. Replaces resolve::function_calls; inlay hints read the function references instead.
Collaborator
Author
|
Folded into #861 (now one PR for inlay hints, resolved references and hover). GitHub shows this as merged into |
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.
resolvecan now also return what the names of a statement resolve to, not just the errors. This replaces the narrowresolve::function_calls/ResolvedCallAPI from #861, so hover (#868) can use the resolver instead of name-only snapshot lookups.API
ResolveParams::collect_references: bool. The linter passesfalse. When it'sfalse, nothing is collected and nothing extra is allocated: FROM items only get a column source when collecting.Resolution::references: Vec<Reference>, which is empty unless requested. Every variant has alocationand aspan(the possibly qualified name) relative to the statement:Function { function, arguments }: whatResolvedCallheld before.Column { source, column }:sourceis a catalogRelation { schema, name }, aCte { name }(the CTE's own name, not the alias it is referenced by) or aSubquery { alias }.columnis the column as its source defines it: under its own name even if an alias renames it (users u(uid)→id). CTE and subquery columns carry their inferred type. Only the FROM item a column resolves to is followed, not where a CTE's columns come from in turn, so hover can say "column of CTE c".Relation { relation }: catalog relations in FROM and the targets of INSERT/UPDATE/DELETE/COPY. CTEs referenced by name are not relations.USING, output-column names inORDER BY, levels with FROM items whose columns aren't known, and unknown objects are all skipped.resolve(.. collect_references: true ..)and keep only theFunctionreferences. Their behaviour and tests are unchanged.Risk
The recording hooks sit in the column-ref and range-var resolution paths, next to the findings logic. A test checks that findings and
database_onlyare identical with and without collection. All catalog and analyser tests pass, including the Postgres regression test (crates/pgls_analyser/tests/postgres_regress.rs), so typecheck findings are unchanged.Not covered
INSERT target column lists,
UPDATE SETtargets,excluded/old/new, columns of functions in FROM and of aliased joins, and columns behindNATURALjoins get no column references.