diff --git a/docs/generated/sql/bnf/drop_sequence_stmt.bnf b/docs/generated/sql/bnf/drop_sequence_stmt.bnf index 1cd52bdfd48e..212345cf0981 100644 --- a/docs/generated/sql/bnf/drop_sequence_stmt.bnf +++ b/docs/generated/sql/bnf/drop_sequence_stmt.bnf @@ -1,7 +1,7 @@ drop_sequence_stmt ::= - 'DROP' 'SEQUENCE' table_name ( ( ',' table_name ) )* 'CASCADE' - | 'DROP' 'SEQUENCE' table_name ( ( ',' table_name ) )* 'RESTRICT' - | 'DROP' 'SEQUENCE' table_name ( ( ',' table_name ) )* - | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'CASCADE' - | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'RESTRICT' - | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* + 'DROP' 'SEQUENCE' sequence_name_list 'CASCADE' + | 'DROP' 'SEQUENCE' sequence_name_list 'RESTRICT' + | 'DROP' 'SEQUENCE' sequence_name_list + | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list 'CASCADE' + | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list 'RESTRICT' + | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list diff --git a/docs/generated/sql/bnf/drop_table.bnf b/docs/generated/sql/bnf/drop_table.bnf index dcaf2588e33c..5a713e065da8 100644 --- a/docs/generated/sql/bnf/drop_table.bnf +++ b/docs/generated/sql/bnf/drop_table.bnf @@ -1,7 +1,7 @@ drop_table_stmt ::= - 'DROP' 'TABLE' table_name ( ( ',' table_name ) )* 'CASCADE' - | 'DROP' 'TABLE' table_name ( ( ',' table_name ) )* 'RESTRICT' - | 'DROP' 'TABLE' table_name ( ( ',' table_name ) )* - | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'CASCADE' - | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* 'RESTRICT' - | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name ( ( ',' table_name ) )* + 'DROP' 'TABLE' table_name_list 'CASCADE' + | 'DROP' 'TABLE' table_name_list 'RESTRICT' + | 'DROP' 'TABLE' table_name_list + | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list 'CASCADE' + | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list 'RESTRICT' + | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list diff --git a/docs/generated/sql/bnf/drop_view.bnf b/docs/generated/sql/bnf/drop_view.bnf index 654b67e2b7a5..1abb9d84213d 100644 --- a/docs/generated/sql/bnf/drop_view.bnf +++ b/docs/generated/sql/bnf/drop_view.bnf @@ -1,5 +1,5 @@ drop_view_stmt ::= - 'DROP' 'VIEW' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) - | 'DROP' 'VIEW' 'IF' 'EXISTS' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) - | 'DROP' 'MATERIALIZED' 'VIEW' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) - | 'DROP' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' ( ( table_name ) ( ( ',' table_name ) )* ) ( 'CASCADE' | 'RESTRICT' | ) + 'DROP' 'VIEW' view_name_list ( 'CASCADE' | 'RESTRICT' | ) + | 'DROP' 'VIEW' 'IF' 'EXISTS' view_name_list ( 'CASCADE' | 'RESTRICT' | ) + | 'DROP' 'MATERIALIZED' 'VIEW' view_name_list ( 'CASCADE' | 'RESTRICT' | ) + | 'DROP' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' view_name_list ( 'CASCADE' | 'RESTRICT' | ) diff --git a/docs/generated/sql/bnf/for_locking.bnf b/docs/generated/sql/bnf/for_locking.bnf index 08dc976cfcc3..4e6e557f294a 100644 --- a/docs/generated/sql/bnf/for_locking.bnf +++ b/docs/generated/sql/bnf/for_locking.bnf @@ -1,9 +1,9 @@ for_locking_item ::= - 'FOR' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' - | 'FOR' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' - | 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' - | 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' - | 'FOR' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' - | 'FOR' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' - | 'FOR' 'KEY' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'SKIP' 'LOCKED' - | 'FOR' 'KEY' 'SHARE' 'OF' table_name ( ( ',' table_name ) )* 'NOWAIT' + 'FOR' 'UPDATE' 'OF' table_name_list 'SKIP' 'LOCKED' + | 'FOR' 'UPDATE' 'OF' table_name_list 'NOWAIT' + | 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name_list 'SKIP' 'LOCKED' + | 'FOR' 'NO' 'KEY' 'UPDATE' 'OF' table_name_list 'NOWAIT' + | 'FOR' 'SHARE' 'OF' table_name_list 'SKIP' 'LOCKED' + | 'FOR' 'SHARE' 'OF' table_name_list 'NOWAIT' + | 'FOR' 'KEY' 'SHARE' 'OF' table_name_list 'SKIP' 'LOCKED' + | 'FOR' 'KEY' 'SHARE' 'OF' table_name_list 'NOWAIT' diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index b77cd4e5e164..a4f2fb8bd048 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -1764,14 +1764,14 @@ drop_table_stmt ::= | 'DROP' 'TABLE' 'IF' 'EXISTS' table_name_list opt_drop_behavior drop_view_stmt ::= - 'DROP' 'VIEW' table_name_list opt_drop_behavior - | 'DROP' 'VIEW' 'IF' 'EXISTS' table_name_list opt_drop_behavior - | 'DROP' 'MATERIALIZED' 'VIEW' table_name_list opt_drop_behavior - | 'DROP' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' table_name_list opt_drop_behavior + 'DROP' 'VIEW' view_name_list opt_drop_behavior + | 'DROP' 'VIEW' 'IF' 'EXISTS' view_name_list opt_drop_behavior + | 'DROP' 'MATERIALIZED' 'VIEW' view_name_list opt_drop_behavior + | 'DROP' 'MATERIALIZED' 'VIEW' 'IF' 'EXISTS' view_name_list opt_drop_behavior drop_sequence_stmt ::= - 'DROP' 'SEQUENCE' table_name_list opt_drop_behavior - | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' table_name_list opt_drop_behavior + 'DROP' 'SEQUENCE' sequence_name_list opt_drop_behavior + | 'DROP' 'SEQUENCE' 'IF' 'EXISTS' sequence_name_list opt_drop_behavior drop_schema_stmt ::= 'DROP' 'SCHEMA' schema_name_list opt_drop_behavior @@ -2479,7 +2479,13 @@ table_index_name_list ::= ( table_index_name ) ( ( ',' table_index_name ) )* table_name_list ::= - ( table_name ) ( ( ',' table_name ) )* + db_object_name_list + +view_name_list ::= + db_object_name_list + +sequence_name_list ::= + db_object_name_list non_reserved_word ::= 'identifier' @@ -3034,6 +3040,9 @@ only_signed_fconst ::= '+' 'FCONST' | '-' 'FCONST' +db_object_name_list ::= + ( db_object_name ) ( ( ',' db_object_name ) )* + scrub_option ::= 'INDEX' 'ALL' | 'INDEX' '(' name_list ')' diff --git a/pkg/cmd/docgen/diagrams.go b/pkg/cmd/docgen/diagrams.go index 0422d3e02fd5..c30238bc116f 100644 --- a/pkg/cmd/docgen/diagrams.go +++ b/pkg/cmd/docgen/diagrams.go @@ -611,7 +611,7 @@ var specs = []stmtSpec{ { name: "for_locking", stmt: "for_locking_item", - inline: []string{"for_locking_strength", "opt_locked_rels", "opt_nowait_or_skip", "table_name_list"}, + inline: []string{"for_locking_strength", "opt_locked_rels", "opt_nowait_or_skip"}, }, { name: "col_qualification", @@ -844,7 +844,7 @@ var specs = []stmtSpec{ }, { name: "drop_sequence_stmt", - inline: []string{"table_name_list", "opt_drop_behavior"}, + inline: []string{"opt_drop_behavior"}, unlink: []string{"sequence_name"}, }, { @@ -855,24 +855,23 @@ var specs = []stmtSpec{ }, { name: "drop_stmt", - inline: []string{"table_name_list", "drop_ddl_stmt"}, + inline: []string{"drop_ddl_stmt"}, }, { name: "drop_table", stmt: "drop_table_stmt", - inline: []string{"opt_drop_behavior", "table_name_list"}, + inline: []string{"opt_drop_behavior"}, match: []*regexp.Regexp{regexp.MustCompile("'DROP' 'TABLE'")}, }, { name: "drop_type", stmt: "drop_type_stmt", - inline: []string{"table_name_list"}, replace: map[string]string{"opt_drop_behavior": ""}, }, { name: "drop_view", stmt: "drop_view_stmt", - inline: []string{"opt_drop_behavior", "table_name_list"}, + inline: []string{"opt_drop_behavior"}, nosplit: true, }, { diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index a66d9e440473..4da5f50adbbf 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -1351,7 +1351,7 @@ func (u *sqlSymUnion) functionObjs() tree.FuncObjs { %type from_clause %type from_list rowsfrom_list opt_from_list %type table_pattern_list -%type table_name_list opt_locked_rels +%type db_object_name_list table_name_list view_name_list sequence_name_list opt_locked_rels %type expr_list opt_expr_list tuple1_ambiguous_values tuple1_unambiguous_values %type <*tree.Tuple> expr_tuple1_ambiguous expr_tuple_unambiguous %type attrs @@ -4824,15 +4824,15 @@ drop_ddl_stmt: // %Text: DROP [MATERIALIZED] VIEW [IF EXISTS] [, ...] [CASCADE | RESTRICT] // %SeeAlso: WEBDOCS/drop-index.html drop_view_stmt: - DROP VIEW table_name_list opt_drop_behavior + DROP VIEW view_name_list opt_drop_behavior { $$.val = &tree.DropView{Names: $3.tableNames(), IfExists: false, DropBehavior: $4.dropBehavior()} } -| DROP VIEW IF EXISTS table_name_list opt_drop_behavior +| DROP VIEW IF EXISTS view_name_list opt_drop_behavior { $$.val = &tree.DropView{Names: $5.tableNames(), IfExists: true, DropBehavior: $6.dropBehavior()} } -| DROP MATERIALIZED VIEW table_name_list opt_drop_behavior +| DROP MATERIALIZED VIEW view_name_list opt_drop_behavior { $$.val = &tree.DropView{ Names: $4.tableNames(), @@ -4841,7 +4841,7 @@ drop_view_stmt: IsMaterialized: true, } } -| DROP MATERIALIZED VIEW IF EXISTS table_name_list opt_drop_behavior +| DROP MATERIALIZED VIEW IF EXISTS view_name_list opt_drop_behavior { $$.val = &tree.DropView{ Names: $6.tableNames(), @@ -4857,11 +4857,11 @@ drop_view_stmt: // %Text: DROP SEQUENCE [IF EXISTS] [, ...] [CASCADE | RESTRICT] // %SeeAlso: DROP drop_sequence_stmt: - DROP SEQUENCE table_name_list opt_drop_behavior + DROP SEQUENCE sequence_name_list opt_drop_behavior { $$.val = &tree.DropSequence{Names: $3.tableNames(), IfExists: false, DropBehavior: $4.dropBehavior()} } -| DROP SEQUENCE IF EXISTS table_name_list opt_drop_behavior +| DROP SEQUENCE IF EXISTS sequence_name_list opt_drop_behavior { $$.val = &tree.DropSequence{Names: $5.tableNames(), IfExists: true, DropBehavior: $6.dropBehavior()} } @@ -5005,18 +5005,27 @@ drop_role_stmt: } | DROP role_or_group_or_user error // SHOW HELP: DROP ROLE -table_name_list: - table_name +db_object_name_list: + db_object_name { name := $1.unresolvedObjectName().ToTableName() $$.val = tree.TableNames{name} } -| table_name_list ',' table_name +| db_object_name_list ',' db_object_name { name := $3.unresolvedObjectName().ToTableName() $$.val = append($1.tableNames(), name) } +table_name_list: + db_object_name_list + +sequence_name_list: + db_object_name_list + +view_name_list: + db_object_name_list + // %Help: ANALYZE - collect table statistics // %Category: Misc // %Text: @@ -7225,7 +7234,7 @@ show_create_stmt: /* SKIP DOC */ $$.val = &tree.ShowCreate{Mode: tree.ShowCreateModeView, Name: $4.unresolvedObjectName()} } -| SHOW CREATE SEQUENCE table_name +| SHOW CREATE SEQUENCE sequence_name { /* SKIP DOC */ $$.val = &tree.ShowCreate{Mode: tree.ShowCreateModeSequence, Name: $4.unresolvedObjectName()}