-
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: support COMMENT ON SCHEMA #68606
Conversation
Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. Before a member of our team reviews your PR, I have some potential action items for you:
I have added a few people who may be able to assist in reviewing:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
f0fe1da
to
b7e22d1
Compare
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
b7e22d1
to
bca0d80
Compare
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
bca0d80
to
dd7d105
Compare
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
dd7d105
to
f78a4b6
Compare
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
f78a4b6
to
9008f08
Compare
Thank you for updating your pull request. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
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 PR is missing the necessary changes to sql/pg_catalog.go
to generate the values in pg_catalog.pg_description
. This will also need a test about how to retrieve the schema comment via pg_catalog.obj_description()
.
You'll probably need input from someone in the SQL schema team about how to populate pg_description properly.
Reviewed 14 of 14 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ekalinin)
pkg/sql/drop_schema.go, line 185 at r1 (raw file):
} if err := p.removeSchemaComment(params.ctx, sc.GetID()); err != nil {
This needs to go to dropSchemaImpl
otherwise the comment is not dropped upon DROP DATABASE CASCADE
fa378dd
to
c02b849
Compare
Thanks. Added.
Done. |
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 6 of 6 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ekalinin)
pkg/sql/pg_catalog.go, line 1398 at r2 (raw file):
case keys.SchemaCommentType: objID = tree.NewDOid(tree.MustBeDInt(objID)) classOid = tree.NewDOid(catconstants.PgCatalogSchemaID)
We'll need a review from SQL Schema for this change.
(@ajwerner?)
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5085 at r2 (raw file):
---- objoid classoid objsubid description 94 4294967022 0 testing schema
I think we need to test this via pg_catalog.obj_description()
because I don't think we wish to assert particular object IDs inside unit tests.
Someone from SQL experience would know better.
(@rafiss?)
pkg/sql/sem/builtins/pg_builtins.go
Outdated
@@ -1942,6 +1942,8 @@ func getCatalogOidForComments(catalogName string) (id int, ok bool) { | |||
return catconstants.PgCatalogClassTableID, true | |||
case "pg_database": | |||
return catconstants.PgCatalogDatabaseTableID, true | |||
case "pg_schema": | |||
return catconstants.PgCatalogSchemaID, true |
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.
I checked the postgres documentation and I couldn't find any mention of pg_schema
in there. Strictly speaking the table for schemas in the pg catalog is pg_namespace
. As far as comments are concerned, it seems they might actually belong in pg_shdescription
or pg_description
. Perhaps @rafiss can enlighten us?
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.
a quick test inside psql
tells me that schema comments get stored inside pg_description
.
c02b849
to
84b4e6f
Compare
Fixed.
Fixed. |
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 13 of 14 files at r1, 2 of 6 files at r2, 3 of 4 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ekalinin, @knz, and @rafiss)
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5085 at r2 (raw file):
Previously, knz (kena) wrote…
I think we need to test this via
pg_catalog.obj_description()
because I don't think we wish to assert particular object IDs inside unit tests.Someone from SQL experience would know better.
(@rafiss?)
i'd probably omit the oids / subids simply because they are potentially unstable.
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5082 at r3 (raw file):
SELECT obj_description(objoid) FROM pg_catalog.pg_description WHERE description = 'testing schema';
nit: drop the trailing ;
here and above
pkg/sql/logictest/testdata/logic_test/schema, line 881 at r3 (raw file):
statement ok; USE comment_db;
nit: drop the trailing ;
here
pkg/sql/sem/builtins/pg_builtins.go, line 1946 at r2 (raw file):
Previously, knz (kena) wrote…
a quick test inside
psql
tells me that schema comments get stored insidepg_description
.
pg_description
is correct
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ekalinin, @knz, and @rafiss)
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5085 at r2 (raw file):
Previously, otan (Oliver Tan) wrote…
i'd probably omit the oids / subids simply because they are potentially unstable.
Should I remove test via obj_description
?
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5085 at r2 (raw file): Previously, ekalinin (Eugene Kalinin) wrote…
Is there a test for it? We should keep it for sure if there is and add it if it isn't. |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ekalinin, @knz, @otan, and @rafiss)
pkg/sql/drop_schema.go, line 185 at r1 (raw file):
Previously, knz (kena) wrote…
This needs to go to
dropSchemaImpl
otherwise the comment is not dropped upon DROP DATABASE CASCADE
Fixed.
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5085 at r2 (raw file):
Previously, otan (Oliver Tan) wrote…
Is there a test for it? We should keep it for sure if there is and add it if it isn't.
Yes, there's. Please, see the latest version of the PR.
pkg/sql/logictest/testdata/logic_test/pg_catalog, line 5082 at r3 (raw file):
Previously, otan (Oliver Tan) wrote…
nit: drop the trailing
;
here and above
Fixed.
pkg/sql/logictest/testdata/logic_test/schema, line 881 at r3 (raw file):
Previously, otan (Oliver Tan) wrote…
nit: drop the trailing
;
here
Fixed.
84b4e6f
to
882e08e
Compare
This change adds support for SCHEMA commenting. Release note (sql change): This change adds associating comment to SQL schema using PostgreSQL's COMMENT ON SCHEMA syntax.
882e08e
to
edc8951
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ekalinin, @knz, @otan, and @rafiss)
pkg/sql/sem/builtins/pg_builtins.go, line 1946 at r2 (raw file):
Previously, otan (Oliver Tan) wrote…
pg_description
is correct
Fixed
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.
looks good to me! thanks
bors r+
Build succeeded: |
Fixes #67689
This change adds support for SCHEMA comment.
Release note (sql change): This change adds associating
comment to SQL schema using PostgreSQL's
COMMENT ON SCHEMA
syntax.