Skip to content
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 INDEX` #41555

Merged
merged 1 commit into from Oct 18, 2019

Conversation

@hueypark
Copy link
Contributor

hueypark commented Oct 13, 2019

Informs #41316.

This patch introduces support for index comments.

The syntax to set or delete a comment is the same as postgres:
COMMENT ON INDEX ... IS .... See:
https://www.postgresql.org/docs/10/static/sql-comment.html

Release note (sql change): CockroachDB now supports associating
comments to SQL index using PostgreSQL's COMMENT ON INDEX.
This comment can be checked with the SHOW INDEXES FROM ... WITH COMMENT command.

@cockroach-teamcity

This comment has been minimized.

Copy link
Member

cockroach-teamcity commented Oct 13, 2019

This change is Reviewable

Copy link
Member

jordanlewis left a comment

Very nice! Can you add a test case to parse_test.go analogous to the other ones you added before?

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @hueypark)


pkg/sql/comment_on_index.go, line 28 at r1 (raw file):

}

// CommentOnIndex add comment on a index.

Grammar: CommentOnIndex adds a comment on an index.


pkg/sql/pg_catalog.go, line 1166 at r1 (raw file):

			case keys.IndexCommentType:
				objID = makeOidHasher().IndexOid(
					sqlbase.ID(tree.MustBeDInt(comment[0])),

Seems like you should reuse your variables from above rather than comment[n] - it will be more clear.


pkg/sql/truncate.go, line 487 at r1 (raw file):

}

// reassignIndexComment reassign comment on index.

reassignIndexComment reassigns a comment on an index


pkg/sql/sem/tree/comment_on_index.go, line 15 at r1 (raw file):

import "github.com/cockroachdb/cockroach/pkg/sql/lex"

// CommentOnIndex represents an COMMENT ON INDEX statement.

represents a COMMENT ON INDEX statement

This patch introduces support for index comments.

The syntax to set or delete a comment is the same as postgres:
`COMMENT ON INDEX ... IS ...`. See:
https://www.postgresql.org/docs/10/static/sql-comment.html

Release note (sql change): CockroachDB now supports associating
comments to SQL index using PostgreSQL's `COMMENT ON INDEX`.
This comment can be checked with the `SHOW INDEXES FROM ... WITH COMMENT` command.
@hueypark hueypark force-pushed the hueypark:comment-on-index branch from 03fcc30 to 81dc2f3 Oct 17, 2019
Copy link
Contributor Author

hueypark left a comment

TFTR!
I added test cases to parse_test.go.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis)


pkg/sql/comment_on_index.go, line 28 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

Grammar: CommentOnIndex adds a comment on an index.

Done.


pkg/sql/pg_catalog.go, line 1166 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

Seems like you should reuse your variables from above rather than comment[n] - it will be more clear.

Done.


pkg/sql/truncate.go, line 487 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

reassignIndexComment reassigns a comment on an index

Done.


pkg/sql/sem/tree/comment_on_index.go, line 15 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

represents a COMMENT ON INDEX statement

Done.

Copy link
Member

jordanlewis left a comment

Looks good! Thank you.

bors r+

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

craig bot pushed a commit that referenced this pull request Oct 18, 2019
41555: sql: support `COMMENT ON INDEX` r=jordanlewis a=hueypark

Informs #41316.

This patch introduces support for index comments.

The syntax to set or delete a comment is the same as postgres:
`COMMENT ON INDEX ... IS ...`. See:
https://www.postgresql.org/docs/10/static/sql-comment.html

Release note (sql change): CockroachDB now supports associating
comments to SQL index using PostgreSQL's `COMMENT ON INDEX`.
This comment can be checked with the `SHOW INDEXES FROM ... WITH COMMENT` command.

Co-authored-by: Jaewan Park <jaewan.huey.park@gmail.com>
@craig

This comment has been minimized.

Copy link

craig bot commented Oct 18, 2019

Build succeeded

@craig craig bot merged commit 81dc2f3 into cockroachdb:master Oct 18, 2019
3 checks passed
3 checks passed
GitHub CI (Cockroach) TeamCity build finished
Details
bors Build succeeded
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.