-
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 ...' for tables, columns and other objects #19472
Comments
Huh, interesting. Thanks for isolating the issue and including an example of it used in the wild! Indeed, cockroach doesn't currently support that syntax, or indeed store any sort of table or column comments or plain-text descriptions. @knz it seems like it this shouldn't be too hard to add and may improve some off-the-shelf ORM/app compatibility (based on that example). Seems like a decent SQL starter project? |
Yep! |
Going to try and look at this if nobody else is. PG lets you comment on nearly everything. Would we want to adopt that approach here, or should I focus only on tables? It also looks like PG stores this in two new tables by oid. It seems a little more complicated than I initially would have thought but I'll give it my best shot. Do ya'll see any obvious gotchas with that approach? |
Hi @ZacharyThomas ! |
It looks like this is actually not supported yet so I'm reopening it |
Let's not forget that there are a ton of objects that can have comments on them: Let's make sure that any work towards this is extensible. Also, we should populate this and any other internal tables: https://www.postgresql.org/docs/9.6/catalog-pg-description.html |
See cockroachdb#19472 Release note (sql change): support COMMENT ON TABLE syntax
@hueypark are you going to work on the |
See cockroachdb#19472 Release note (sql change): support COMMENT ON TABLE syntax
Create system.comments table for comment. Each column description: - type: type of object, to distinguish between db, table, column and others(https://www.postgresql.org/docs/9.1/sql-comment.html) - object_id: object ID, this will be usually db/table desc ID - sub_id: sub ID for columns inside table, 0 for pure table - comment: the comment And system.comments has public priviliege because this table used in SHOW TABLES. See cockroachdb#19472 Release note (sql change): support COMMENT ON TABLE syntax
Create system.comments table for comment. Each column description: - type: type of object, to distinguish between db, table, column and others(https://www.postgresql.org/docs/9.1/sql-comment.html) - object_id: object ID, this will be usually db/table desc ID - sub_id: sub ID for columns inside table, 0 for pure table - comment: the comment And system.comments has public priviliege because this table used in SHOW TABLES. See cockroachdb#19472 Release note (sql change): support COMMENT ON TABLE syntax
Create system.comments table for comment. Each column description: - type: type of object, to distinguish between db, table, column and others(https://www.postgresql.org/docs/9.1/sql-comment.html) - object_id: object ID, this will be usually db/table desc ID - sub_id: sub ID for columns inside table, 0 for pure table - comment: the comment And system.comments has public privilege because this table used in SHOW TABLES. See cockroachdb#19472 Release note (sql change): support `COMMENT ON TABLE` syntax, support `WITH COMMENT` option for `SHOW TABLE`
32442: sql: implement `COMMENT ON TABLE` r=knz a=hueypark Informs #19472. This patch introduces support for table comments. The syntax to set or delete a comment is the same as postgres: `COMMENT ON TABLE ... IS ...`. See: postgresql.org/docs/9.1/sql-comment.html This also makes `pg_catalog.pg_description` and `obj_description()` do the right thing for compatibility with 3rd party clients. This is supported by a new system table `system.comments`, which is extensible to support comments on other database objects than tables: - its `type` column indicates the type of object, to distinguish between db, table, column and others. For now just one type is defined. - `object_id`: table or database ID, relative to the `type`. - `sub_id`: when a comment is placed on an object "inside" another, eg a column inside a table. - `comment`: the comment proper. This design of `system.comments` mimics pg's own `pg_description` which uses the same schema. Release note (sql change): CockroachDB now supports associating comments to SQL tables using PostgreSQL's `COMMENT ON TABLE` syntax. This also provides proper support for pg's `pg_catalog.pg_description` and built-in function `obj_description()`. Release note (sql change): The `SHOW TABLES` statement now supports printing out table comments using the optional phrase `WITH COMMENT`, e.g `SHOW TABLES FROM mydb WITH COMMENT`. Co-authored-by: Jaewan Park <jaewan.huey.park@gmail.com>
32442: sql: implement `COMMENT ON TABLE` r=knz a=hueypark Informs #19472. This patch introduces support for table comments. The syntax to set or delete a comment is the same as postgres: `COMMENT ON TABLE ... IS ...`. See: https://postgresql.org/docs/9.1/sql-comment.html This also makes `pg_catalog.pg_description` and `obj_description()` do the right thing for compatibility with 3rd party clients. This is supported by a new system table `system.comments`, which is extensible to support comments on other database objects than tables: - its `type` column indicates the type of object, to distinguish between db, table, column and others. For now just one type is defined. - `object_id`: table or database ID, relative to the `type`. - `sub_id`: when a comment is placed on an object "inside" another, eg a column inside a table. - `comment`: the comment proper. This design of `system.comments` mimics pg's own `pg_description` which uses the same schema. Release note (sql change): CockroachDB now supports associating comments to SQL tables using PostgreSQL's `COMMENT ON TABLE` syntax. This also provides proper support for pg's `pg_catalog.pg_description` and built-in function `obj_description()`. Release note (sql change): The `SHOW TABLES` statement now supports printing out table comments using the optional phrase `WITH COMMENT`, e.g `SHOW TABLES FROM mydb WITH COMMENT`. Co-authored-by: Jaewan Park <jaewan.huey.park@gmail.com>
33057: sql: support `COMMENT ON DATABASE` r=knz a=hueypark Informs #19472. This patch introduces support for database comments. The syntax to set or delete a comment is the same as postgres: `COMMENT ON DATABASE ... IS ...`. See: https://www.postgresql.org/docs/9.1/sql-comment.html Release note (sql change): CockroachDB now supports associating comments to SQL databases using PostgreSQL's `COMMENT ON DATABASE` syntax. This also provides proper support for pg's `pg_catalog.pg_description` and built-in function `obj_description()`. Co-authored-by: Jaewan Park <jaewan.huey.park@gmail.com>
33355: sql: support `COMMENT ON COLUMN` r=knz a=hueypark Informs #19472. This patch introduces support for table column comments. The syntax to set or delete a comment is the same as postgres: `COMMENT ON COLUMN ... IS ...`. See: https://www.postgresql.org/docs/9.1/sql-comment.html Release note (sql change): CockroachDB now supports associating comments to SQL table column using PostgreSQL's `COMMENT ON COLIMN` syntax. This also provides proper support for pg's `pg_catalog.pg_description` and built-in function `col_description()`. Co-authored-by: Jaewan Park <jaewan.huey.park@gmail.com>
This is done but for schemas which we don't support anyway - closing. Thanks again @hueypark. |
Any syntax error while using the COMMENT ON statement returns an error referencing cockroachdb#19472. With cockroachdb#19472 closed, we should no longer reference it when the syntax is wrong. Fixes cockroachdb#40713 Release note: None Release Justification: Very minor change
40943: sql: remove unimplemented error message from COMMENT ON statement r=arulajmani a=arulajmani Any syntax error while using the COMMENT ON statement returns an error referencing #19472. With #19472 closed, we should no longer reference it when the syntax is wrong. Fixes #40713 Release note: None Release Justification: Very minor change 40944: roachtest: tpcc-max had too low of a timeout r=jordanlewis a=jordanlewis It's supposed to run for 6 days, but used the default timeout of 10 hours. Closes #38558. Release note: None Release justification: test-only change Co-authored-by: Arul Ajmani <arula@cockroachlabs.com> Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Postgres docs on
COMMENT ON
: https://www.postgresql.org/docs/current/static/sql-comment.htmlCOMMENT ON TABLE
sql: implementCOMMENT ON TABLE
#32442COMMENT ON
for table columns sql: support COMMENT ON for table columns #32965COMMENT ON DATABASE
sql: supportCOMMENT ON DATABASE
#33057COMMENT ON
schemasThe text was updated successfully, but these errors were encountered: