Skip to content

sql: print comments in SHOW CREATE TABLE#43152

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
hueypark:print-comment
Jan 20, 2020
Merged

sql: print comments in SHOW CREATE TABLE#43152
craig[bot] merged 1 commit intocockroachdb:masterfrom
hueypark:print-comment

Conversation

@hueypark
Copy link
Copy Markdown
Contributor

Fixes #42875

Release note (sql change): SHOW CREATE TABLE now prints comments.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@namibj
Copy link
Copy Markdown

namibj commented Jan 20, 2020

Will this get into v.19.2.3? I'd quite like to deploy this, so that I can start writing comments without them getting lost.

@hueypark
Copy link
Copy Markdown
Contributor Author

@jordanlewis Would you review this?

Copy link
Copy Markdown
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.

@namibj no this will not get in 19.2.x. We do not add or changes features in release branches unless they are security-critical. The earliest this will be released will be v20.1.

@hueypark Jordan is away and he asked me to review.

As usual, your work here is very good. I have just one suggestion to improve the interface and some stylistics edits on code comments.

A request on the commit message: can you expand the release note to explain what is happening, for example:

Release note (sql change): SHOW CREATE TABLE now also emits the COMMENT statements sufficient to populate the table's user-defined comments, if any, alongside the CREATE statement proper.

Finally, could you please file an issue for supporting COMMENT ON VIEW and COMMENT ON SEQUENCE for completeness, and mention in the issue description that the code for SHOW CREATE must be adapted accordingly. Thank you.

Reviewed 8 of 8 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @hueypark)


pkg/sql/show_create.go, line 48 at r1 (raw file):

// the prefix when the given table references other tables in the
// current database.
func ShowCreateTable(

I would make this function a method on *planner, then add its in terface to the PlanHookState interface.


pkg/sql/show_create_clauses.go, line 26 at r1 (raw file):

)

// tableComment has comment data for table.
  1. tableConmment -> tableComments

  2. // tableComments stores the comment data for a table.


pkg/sql/show_create_clauses.go, line 38 at r1 (raw file):

}

// selectComment returns table comment.

Detail what is being done here:

// selectComment retrieves all the comments pertaining to a table (comments on the table
// itself but also column and index comments.)

pkg/sql/show_create_clauses.go, line 94 at r1 (raw file):

}

// showComment writes a valid SQL representation of a COMMENT clause.
  1. showComment -> showComments

  2. // showComments prints out the COMMENT statement sufficient to populate a table's comments, including its index and column comments.

@knz
Copy link
Copy Markdown
Contributor

knz commented Jan 20, 2020

sorry regarding my last comment of course the word should be plural:

// showComments prints out the COMMENT statements sufficient to populate a 
// table's comments, including its index and column comments.

Fixes cockroachdb#42875

Release note (sql change): SHOW CREATE TABLE now also emits the COMMENT statements sufficient to populate the table's user-defined comments, if any, alongside the CREATE statement proper.
Copy link
Copy Markdown
Contributor Author

@hueypark hueypark 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)


pkg/sql/show_create.go, line 48 at r1 (raw file):

Previously, knz (kena) wrote…

I would make this function a method on *planner, then add its in terface to the PlanHookState interface.

Done.


pkg/sql/show_create_clauses.go, line 26 at r1 (raw file):

Previously, knz (kena) wrote…
  1. tableConmment -> tableComments

  2. // tableComments stores the comment data for a table.

Done.


pkg/sql/show_create_clauses.go, line 38 at r1 (raw file):

Previously, knz (kena) wrote…

Detail what is being done here:

// selectComment retrieves all the comments pertaining to a table (comments on the table
// itself but also column and index comments.)

Done.


pkg/sql/show_create_clauses.go, line 94 at r1 (raw file):

Previously, knz (kena) wrote…
  1. showComment -> showComments

  2. // showComments prints out the COMMENT statement sufficient to populate a table's comments, including its index and column comments.

Done.

Copy link
Copy Markdown
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.

Very nice. Thank you!

Reviewed 4 of 4 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

Copy link
Copy Markdown
Contributor Author

@hueypark hueypark left a comment

Choose a reason for hiding this comment

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

I added an issue for VIEW and SEQUENCE(#44135).

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

@knz
Copy link
Copy Markdown
Contributor

knz commented Jan 20, 2020

Thank you again for your contribution.

bors r+

craig bot pushed a commit that referenced this pull request Jan 20, 2020
43152: sql: print comments in SHOW CREATE TABLE r=knz a=hueypark

Fixes #42875

Release note (sql change): SHOW CREATE TABLE now prints comments.

Co-authored-by: Jaewan Park <jaewan.huey.park@gmail.com>
@hueypark
Copy link
Copy Markdown
Contributor Author

Thank you for the review!

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 20, 2020

Build succeeded

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.

cli/dump: COMMENT ON missing

4 participants