Skip to content

Conversation

lnhsingh
Copy link
Contributor

@lnhsingh lnhsingh commented Apr 1, 2019

  • Add COMMENT ON statement
  • Update SHOW TABLES ... WITH COMMENT

Closes #4261, #4182, #4262.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor Author

@lnhsingh lnhsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


v19.1/comment-on.md, line 45 at r1 (raw file):

~~~

To view all comments:

Is there a way to view a specific database's comments?


v19.1/comment-on.md, line 93 at r1 (raw file):

~~~

To view column comments:

How do you view column comments? I tried SELECT col_description(dogs.name); but it didn't work

@lnhsingh lnhsingh requested review from knz and rmloveland April 1, 2019 21:56
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below: I am not comfortable showing SQL examples for database and column comments until we have proper support in SHOW. (This is an oversight in my part - please create issues).

In the meantime, I think it would be good to more prominently explain that this new feature is best used using database GUI navigation tools. These will be able to set and view comments "naturally" because we use the same API as PostgreSQL. Maybe it would be useful to include a screenshot taken with dbeaver.

Reviewed 5 of 5 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @lhirata and @rmloveland)


v19.1/comment-on.md, line 42 at r1 (raw file):

~~~ sql
> SELECT * FROM system.comments;

I recommend against using any system table anywhere in documentation.


v19.1/comment-on.md, line 45 at r1 (raw file):

Previously, lhirata wrote…

Is there a way to view a specific database's comments?

It's an oversight on my part that we do not have a way to view comments with SHOW DATABASES.
Please file an issue in the cockroach repo and cc me on it.

There's a way that is usable by UI tools, but which we are not yet ready to document (see my comment at top).

The query (for your personal enlightnment, although I don't recommend documenting it here) is this:

select pg_catalog.obj_description((select oid from pg_database where datname='customers'));

In the meantime, I would recommend to not document a SQL example here. Instead, highlight that the comment can be viewed with a GUI tool.


v19.1/comment-on.md, line 93 at r1 (raw file):

Previously, lhirata wrote…

How do you view column comments? I tried SELECT col_description(dogs.name); but it didn't work

Same as above.

It's an oversight on my part that we do not have a way to view comments with SHOW COLUMNS.
Please file an issue in the cockroach repo and cc me on it.

There's a way that is usable by UI tools, but which we are not yet ready to document (see my comment at top).

The query (for your personal enlightnment, although I don't recommend documenting it here) is this:

select pg_catalog.col_description(t.oid, a.attnum) from pg_class t, pg_attribute a where t.oid = a.attrelid and t.relname = 'dogs' and a.attname='name';

In the meantime, I would recommend to not document a SQL example here. Instead, highlight that the comment can be viewed with a GUI tool.

Copy link
Contributor Author

@lnhsingh lnhsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the info. Opened an issue to add SHOW ... WITH COMMENTS here.

Added a callout to suggest using this feature with a GUI. Will hold off on screenshots for now.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz and @rmloveland)


v19.1/comment-on.md, line 42 at r1 (raw file):

Previously, knz (kena) wrote…

I recommend against using any system table anywhere in documentation.

Done.

COMMENT ON TABLE
~~~

[To view table comments](show-tables.html):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest changing this to something like

To view table comments, use SHOW TABLES.

@@ -113,10 +116,28 @@ This uses the [current schema](sql-name-resolution.html#current-schema) `public`
(3 rows)
~~~

### Show tables with comments

<span class="version-tag">New in v19.1:</span> To view a table's comments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest editing slightly to something like:

New in v19.1: You can add and view comments on a table. To view a table's comments:

## See also

- [`SHOW DATABASES`](show-databases.html)
- [`SHOW SCHEMAS`](show-schemas.html)
- [`CREATE TABLE`](create-table.html)
- [`CREATE VIEW`](create-view.html)
- [`COMMENT ON`](comment-on.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOICE

Copy link
Contributor

@rmloveland rmloveland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple of small but non-critical wording suggestions.

Copy link
Contributor Author

@lnhsingh lnhsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz and @rmloveland)


v19.1/comment-on.md, line 60 at r2 (raw file):

Previously, rmloveland (Rich Loveland) wrote…

Suggest changing this to something like

To view table comments, use SHOW TABLES.

Done.


v19.1/show-tables.md, line 121 at r2 (raw file):

Previously, rmloveland (Rich Loveland) wrote…

Suggest editing slightly to something like:

New in v19.1: You can add and view comments on a table. To view a table's comments:

Done.


v19.1/show-tables.md, line 142 at r2 (raw file):

Previously, rmloveland (Rich Loveland) wrote…

NOICE

👍

@lnhsingh lnhsingh requested a review from jseldess April 3, 2019 16:38
Copy link
Contributor

@jseldess jseldess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but I have a few nits and questions.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jseldess, @knz, @lhirata, and @rmloveland)


v19.1/comment-on.md, line 45 at r3 (raw file):

~~~

To view column comments, use a database GUI navigation tool (e.g., [dBeaver](dBeaver.html)).

column comments > database comments


v19.1/comment-on.md, line 62 at r3 (raw file):

To view table comments, use [`SHOW TABLES`](show-tables.html):

~~~ sql

Add copy to clipboard.


v19.1/comment-on.md, line 75 at r3 (raw file):

### Add a comment to a column

To add a comment to a column:

This command looks identical to the comment for adding a comment to a table. How is this column-specific?


v19.1/show-tables.md, line 121 at r3 (raw file):

### Show tables with comments

<span class="version-tag">New in v19.1:</span>You can add and view comments on a table. To view a table's comments:

Should we link to COMMENT ON somehow?

Copy link
Contributor Author

@lnhsingh lnhsingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jseldess, @knz, and @rmloveland)


v19.1/comment-on.md, line 45 at r3 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

column comments > database comments

Done.


v19.1/comment-on.md, line 62 at r3 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

Add copy to clipboard.

Done.


v19.1/comment-on.md, line 75 at r3 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

This command looks identical to the comment for adding a comment to a table. How is this column-specific?

This was copy/paste messiness. Updated to be COMMENT ON COLUMN dogs.name


v19.1/show-tables.md, line 121 at r3 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

Should we link to COMMENT ON somehow?

Done.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r3, 2 of 2 files at r5.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jseldess, @lhirata, and @rmloveland)


v19.1/comment-on.md, line 10 at r5 (raw file):

{{site.data.alerts.callout_success}}
`COMMENT ON` is best suited for use with database GUI navigation tools (e.g., [dBeaver](dbeaver.html)).

is currently best suited ...

Copy link
Contributor

@jseldess jseldess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @lhirata and @rmloveland)

Edits based on feedback

Edits based on feedback

Edit based on feedback + add to SQL Statements page

Fix broken links

Edits based on feedback

Edit based on feedback
@cockroach-teamcity
Copy link
Member

@lnhsingh lnhsingh merged commit aa4a718 into master Apr 4, 2019
@lnhsingh lnhsingh deleted the comment-on branch April 4, 2019 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants