-
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: added ALTER INDEX ... NOT VISIBLE #84295
Closed
wenyihu6
wants to merge
5
commits into
cockroachdb:master
from
wenyihu6:3-new-add-ALTER-INVISIBLE(wenyihu6)
Closed
sql: added ALTER INDEX ... NOT VISIBLE #84295
wenyihu6
wants to merge
5
commits into
cockroachdb:master
from
wenyihu6:3-new-add-ALTER-INVISIBLE(wenyihu6)
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR takes the first step for the invisible index feature. The first commit added a boolean field `Hidden` to the struct `IndexDescriptor`. Since primary indexes cannot be invisible, this commit also added a check in `pkg/sql/catalog/tabledesc/validate.go` for that. The second commit added a new column `is_hidden` to `crdb_internal.table_indexes` and also to the output of following SQL statements: ``` SHOW INDEX FROM (table_name) SHOW INDEXES FROM(table_name) SHOW KEYS FROM (table_name) SHOW INDEX FROM DATABASE(database_name) SHOW INDEXES FROM DATABASE (database_name) SHOW KEYS FROM DATABASE (database_name) ``` Since the invisible index feature has not been introduced yet, all indexes created should be visible. It is expected for all test cases to output `false` for all `is_hidden` columns. See also: There will be more PR coming up to add the SQL statements `CREATE INDEX … NOT VISIBLE`, `CREATE TABLE … (INDEX NOT VISIBLE)`, `ALTER INDEX … NOT VISIBLE`. Next PR for invisible index feature: cockroachdb#83471 TODO (wenyihu6): link more related pr later on Fixes: cockroachdb#72576 Note that this issue has not been resolved yet, and this pr only takes the first step. Release note (sql change): A new column `is_hidden` has been added to the table `crdb_internal.table_indexes` and to the output of SQL statements related to `SHOW INDEX`, `SHOW INDEXES`, and `SHOW KEYS`. Since the invisible index feature has not been introduced yet, the output for this column will always be false for now. This will be changed soon.
This PR added CREATE INDEX … INVISIBLE, CREATE TABLE (INDEX … INVISIBLE) to the parser and added invisible index feature to optimizer Invisible indexes are ignored by the optimizer unless they are specifically selected with index hinting (force index). This is not supported for unique Indexes or primary indexes.
This commit added UNIQUE INDEX ... NOT VISIBLE to parser and added panic error for if user tries to create an invisible unique index. Note that syntax for invisible unique constraint is not supported.
This commit added ALTER index NOT VISIBLE. Not done yet # Conflicts: # pkg/sql/walk.go covered unique and primary check
ghost
reviewed
Aug 12, 2022
if err := checkSchemaChangeEnabled( | ||
ctx, | ||
p.ExecCfg(), | ||
"ALTER INDEX VISBILITY", |
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 should probably be ALTER INDEX VISIBILITY
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.
You are right! Thank you : )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR added ALTER INDEX ... NOT VISIBLE to parser. Users
can now alter a secondary index to become invisible
or become visible. This PR also added panic error for if user tries
to alter a unique index or a primary index to become invisible.
Note that syntax for invisible unique constraint is not supported.
The first three commits of this PR come from #83388, #83471, and #84293.
They should be merged first.
Release note (sql): unique invisible index feature is currently not supported.