-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: fix has_column_privilege builtin #39785
Conversation
Here is an excerpt from the PostgreSQL docs for the function:
|
Thanks for the quick fix @yuzefovich! What you have here works, but I think it's actually a misdiagnosis of the problem. In #39703, we see that the In Postgres:
In CockroachDB:
I think the correct fix here is to maintain stable |
I think the fix here is actually to stop using information_schema stuff to answer a question that's fundamentally about postgres, pg_catalog concepts :) I think if you rephrased the inner query to use pg_catalog everywhere instead of information_schema you'd have an easier time. |
Have you looked into what that entails? Also, I don't think it's accurate to say that |
d5b44cd
to
21413cf
Compare
I briefly looked into Nathan's suggestion in keeping I've just rewritten the query in question using |
Previously, has_column_privilege would treat its second argument (when it is an integer) that specifies the column to check the privileges on as an ordinal index of the column, but when a column is dropped from the table, ordinal indices are adjusted, so ordinal_position of information_schema.columns would contain a different from attnum of pg_catalog.pg_attribute number. Now this is fixed. Release note: None
21413cf
to
1e2b25b
Compare
I don't think we'd have to go this far. We'd just need to use the |
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.
This approach does LGTM as-is though! We're still mixing information_schema
and pg_catalog
, but for this initial attname
question, that seems fine. I think I misinterpreted the discussion above as the more general topic of using information_schema.table_privileges
to implement these pg acl builtins.
Before merging though, could you open an issue about the ordinal position semantic mismatch between the two tables?
#39787 is filed. Thanks for the review! bors r+ |
39785: sql: fix has_column_privilege builtin r=yuzefovich a=yuzefovich Previously, has_column_privilege would treat its second argument (when it is an integer) that specifies the column to check the privileges on as an ordinal index of the column, but when a column is dropped from the table, ordinal indices are adjusted, so ordinal_position of information_schema.columns would contain a different from attnum of pg_catalog.pg_attribute number. Now this is fixed. Fixes: #39703. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
Build succeeded |
Previously, has_column_privilege would treat its second argument
(when it is an integer) that specifies the column to check the
privileges on as an ordinal index of the column, but when a column
is dropped from the table, ordinal indices are adjusted, so
ordinal_position of information_schema.columns would contain a
different from attnum of pg_catalog.pg_attribute number. Now
this is fixed.
Fixes: #39703.
Release note: None