-
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: use crdb_internal for pg_proc.pronamespace when needed #95029
Conversation
140c0dc
to
8113484
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz)
@knz could you PTAL at the changes in the
So it looks like it's suggesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where should I make the change?
Very good question!
You'd need to modify the completion rule for functions, at pkg/sql/comprules/rules.go line 160.
We want to use a query that enumerate the functions visible from the current search_path.
So I believe this willb e something like replacing
SELECT DISTINCT proname FROM pg_catalog.pg_proc
to
SELECT DISTINCT proname FROM pg_catalog.pg_proc p,
JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
WHERE n.nspname = ANY pg_catalog.current_schemas(TRUE)
You'll also see that function says something about built-in function comments not being available through pg_objdescription yet. Should we file an issue about that?
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh wait my previous explanation is wrong. That completion rule is a bit more intelligent, and is able to recognize a namespace prefix earlier in the SQL syntax. This should be used instead of current_schemas
if available.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
If you'd like we can do some pair programming later this week to iterate on this! |
since we don't have |
1cdbb29
to
9941ce1
Compare
@knz thanks for the pointer. I added a new commit to fix the completion rules. Can you review it when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got this! I'm so glad you found the simplification. This architecture works.
There's a few nits we need to take care of: #95029
LGTM modulo something like that + necessary test adjustments.
Reviewed 1 of 5 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @e-mbrown and @rafiss)
pkg/sql/comprules/rules.go
line 150 at r2 (raw file):
// built-in functions through pg_catalog. const query = ` WITH p AS (SELECT DISTINCT proname, nspname FROM pg_catalog.pg_proc JOIN pg_catalog.pg_namespace n ON n.oid = pronamespace)
👏 👏 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant to link to this: rafiss#1
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @e-mbrown and @rafiss)
9941ce1
to
e6303fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 5 files at r2, 4 of 4 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)
f46e8b6
to
78feb8e
Compare
Release note (bug fix): The pronamespace column of the pg_proc table now correctly reports the crdb_internal schema for built-in functions that have the "crdb_internal" prefix.
The syntax completion engine now generates suggestion for user-defined functions. It restricts the suggestions to only functions in the schema name if one was provided, or else to the schemas in the search_path. No release note since this functionality is new in v23.1. Release note: None
78feb8e
to
83fca32
Compare
The remaining flake in CI here is not yours. Let's file an issue for it (and perhaps skip it), you can merge your PR. |
i'll file it for you |
thank you for the help! bors r=knz |
Build failed: |
flake was #94956 which is also on me to fix (unrelated to this PR) bors r=knz |
Build failed (retrying...): |
Build succeeded: |
Epic: CRDB-23454
fixes #94952
Release note (bug fix): The pronamespace column of the pg_proc table now correctly reports the crdb_internal schema for built-in functions that have the "crdb_internal" prefix.
comprules: support completion for qualified functions
The syntax completion engine now generates suggestion for user-defined
functions. It restricts the suggestions to only functions in the schema
name if one was provided, or else to the schemas in the search_path.
No release note since this functionality is new in v23.1.