forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
49335: sql: parse partial indexes r=mgartner a=mgartner This commit adds support for parsing partial indexes. The parser can now parse statements like: CREATE TABLE t (a INT, INDEX (a) WHERE a > 3) CREATE TABLE t (a INT, UNIQUE INDEX (a) WHERE a > 3) CREATE INDEX i ON t (a) WHERE a > 3 Note that these `WHERE` clauses have no effect as of this commit. Until further work is done, the `WHERE` clauses are ignored and full indexes are created. This commit also adds the ability to format the `Predicate` expression of `tree.CreateIndex` and `tree.IndexTableDef` expressions. A temporary session setting has been added called `partial_indexes`. When set to true, it enables the user to create partial indexes. By default, it is false because partial indexes are not fully supported. Once partial indexes are fully functional, this setting will be removed. Release note: None Co-authored-by: Marcus Gartner <[email protected]>
- Loading branch information
Showing
18 changed files
with
156 additions
and
62 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
create_index_stmt ::= | ||
'CREATE' 'UNIQUE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'UNIQUE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'UNIQUE' 'INVERTED' 'INDEX' opt_concurrently '...' 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'UNIQUE' 'INVERTED' 'INDEX' opt_concurrently '...' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'INVERTED' 'INDEX' opt_concurrently '...' 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
| 'CREATE' 'INVERTED' 'INDEX' opt_concurrently '...' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' | ||
'CREATE' 'UNIQUE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'UNIQUE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'INDEX' opt_concurrently '...' opt_hash_sharded 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'UNIQUE' 'INVERTED' 'INDEX' opt_concurrently '...' 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'UNIQUE' 'INVERTED' 'INDEX' opt_concurrently '...' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'INVERTED' 'INDEX' opt_concurrently '...' 'STORING' '(' stored_columns ')' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause | ||
| 'CREATE' 'INVERTED' 'INDEX' opt_concurrently '...' 'INTERLEAVE' 'IN' 'PARENT' parent_table '(' interleave_prefix ')' opt_where_clause |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
create_index_stmt ::= | ||
'CREATE' ( 'UNIQUE' | ) 'INDEX' opt_concurrently opt_index_name 'ON' table_name ( 'USING' name | ) '(' ( ( ( column_name ( 'ASC' | 'DESC' | ) ) ) ( ( ',' ( column_name ( 'ASC' | 'DESC' | ) ) ) )* ) ')' opt_hash_sharded ( ( 'COVERING' | 'STORING' | 'INCLUDE' ) '(' name_list ')' | ) opt_interleave opt_partition_by | ||
| 'CREATE' ( 'UNIQUE' | ) 'INDEX' opt_concurrently 'IF' 'NOT' 'EXISTS' index_name 'ON' table_name ( 'USING' name | ) '(' ( ( ( column_name ( 'ASC' | 'DESC' | ) ) ) ( ( ',' ( column_name ( 'ASC' | 'DESC' | ) ) ) )* ) ')' opt_hash_sharded ( ( 'COVERING' | 'STORING' | 'INCLUDE' ) '(' name_list ')' | ) opt_interleave opt_partition_by | ||
'CREATE' ( 'UNIQUE' | ) 'INDEX' opt_concurrently opt_index_name 'ON' table_name ( 'USING' name | ) '(' ( ( ( column_name ( 'ASC' | 'DESC' | ) ) ) ( ( ',' ( column_name ( 'ASC' | 'DESC' | ) ) ) )* ) ')' opt_hash_sharded ( ( 'COVERING' | 'STORING' | 'INCLUDE' ) '(' name_list ')' | ) opt_interleave opt_partition_by opt_where_clause | ||
| 'CREATE' ( 'UNIQUE' | ) 'INDEX' opt_concurrently 'IF' 'NOT' 'EXISTS' index_name 'ON' table_name ( 'USING' name | ) '(' ( ( ( column_name ( 'ASC' | 'DESC' | ) ) ) ( ( ',' ( column_name ( 'ASC' | 'DESC' | ) ) ) )* ) ')' opt_hash_sharded ( ( 'COVERING' | 'STORING' | 'INCLUDE' ) '(' name_list ')' | ) opt_interleave opt_partition_by opt_where_clause | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
index_def ::= | ||
'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'COVERING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'STORING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded opt_interleave opt_partition_by | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'COVERING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'STORING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded opt_interleave opt_partition_by | ||
| 'INVERTED' 'INDEX' name '(' index_elem ( ( ',' index_elem ) )* ')' | ||
| 'INVERTED' 'INDEX' '(' index_elem ( ( ',' index_elem ) )* ')' | ||
'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'COVERING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'STORING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'COVERING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'STORING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' 'INDEX' opt_index_name '(' index_elem ( ( ',' index_elem ) )* ')' opt_hash_sharded opt_interleave opt_partition_by opt_where_clause | ||
| 'INVERTED' 'INDEX' name '(' index_elem ( ( ',' index_elem ) )* ')' opt_where_clause | ||
| 'INVERTED' 'INDEX' '(' index_elem ( ( ',' index_elem ) )* ')' opt_where_clause |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
table_constraint ::= | ||
'CONSTRAINT' constraint_name 'CHECK' '(' a_expr ')' | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' 'COVERING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' 'STORING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' opt_interleave opt_partition_by | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' 'COVERING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' 'STORING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'CONSTRAINT' constraint_name 'UNIQUE' '(' index_params ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'CONSTRAINT' constraint_name 'PRIMARY' 'KEY' '(' index_params ')' opt_hash_sharded opt_interleave | ||
| 'CONSTRAINT' constraint_name 'FOREIGN' 'KEY' '(' name_list ')' 'REFERENCES' table_name opt_column_list key_match reference_actions | ||
| 'CHECK' '(' a_expr ')' | ||
| 'UNIQUE' '(' index_params ')' 'COVERING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' '(' index_params ')' 'STORING' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' '(' index_params ')' 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' '(' index_params ')' opt_interleave opt_partition_by | ||
| 'UNIQUE' '(' index_params ')' 'COVERING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' '(' index_params ')' 'STORING' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' '(' index_params ')' 'INCLUDE' '(' name_list ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'UNIQUE' '(' index_params ')' opt_interleave opt_partition_by opt_where_clause | ||
| 'PRIMARY' 'KEY' '(' index_params ')' opt_hash_sharded opt_interleave | ||
| 'FOREIGN' 'KEY' '(' name_list ')' 'REFERENCES' table_name opt_column_list key_match reference_actions |
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 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 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 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 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 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
Oops, something went wrong.