diff --git a/docs/generated/sql/bnf/stmt_block.bnf b/docs/generated/sql/bnf/stmt_block.bnf index fa0b25303d35..46164fba7cb7 100644 --- a/docs/generated/sql/bnf/stmt_block.bnf +++ b/docs/generated/sql/bnf/stmt_block.bnf @@ -16,6 +16,7 @@ stmt ::= | release_stmt | nonpreparable_set_stmt | transaction_stmt + | close_cursor_stmt | preparable_stmt ::= @@ -90,6 +91,9 @@ transaction_stmt ::= | rollback_stmt | abort_stmt +close_cursor_stmt ::= + 'CLOSE' 'ALL' + alter_stmt ::= alter_ddl_stmt | alter_role_stmt @@ -631,6 +635,7 @@ unreserved_keyword ::= | 'CANCEL' | 'CASCADE' | 'CHANGEFEED' + | 'CLOSE' | 'CLUSTER' | 'COLUMNS' | 'COMMENT' @@ -656,6 +661,7 @@ unreserved_keyword ::= | 'DATE' | 'DAY' | 'DEALLOCATE' + | 'DECLARE' | 'DELETE' | 'DEFERRED' | 'DISCARD' diff --git a/pkg/sql/parser/sql.y b/pkg/sql/parser/sql.y index ccf9230a3ec6..d22d3205cfa6 100644 --- a/pkg/sql/parser/sql.y +++ b/pkg/sql/parser/sql.y @@ -527,7 +527,7 @@ func newNameFromStr(s string) *tree.Name { %token BLOB BOOL BOOLEAN BOTH BUNDLE BY BYTEA BYTES %token CACHE CANCEL CASCADE CASE CAST CHANGEFEED CHAR -%token CHARACTER CHARACTERISTICS CHECK +%token CHARACTER CHARACTERISTICS CHECK CLOSE %token CLUSTER COALESCE COLLATE COLLATION COLUMN COLUMNS COMMENT COMMIT %token COMMITTED COMPACT COMPLETE CONCAT CONFIGURATION CONFIGURATIONS CONFIGURE %token CONFLICT CONSTRAINT CONSTRAINTS CONTAINS CONVERSION COPY COVERING CREATE CREATEROLE @@ -536,7 +536,7 @@ func newNameFromStr(s string) *tree.Name { %token CURRENT_USER CYCLE %token DATA DATABASE DATABASES DATE DAY DEC DECIMAL DEFAULT -%token DEALLOCATE DEFERRABLE DEFERRED DELETE DESC +%token DEALLOCATE DECLARE DEFERRABLE DEFERRED DELETE DESC %token DISCARD DISTINCT DO DOMAIN DOUBLE DROP %token ELSE ENCODING END ENUM ESCAPE EXCEPT EXCLUDE @@ -800,6 +800,9 @@ func newNameFromStr(s string) *tree.Name { %type upsert_stmt %type use_stmt +%type close_cursor_stmt +%type declare_cursor_stmt + %type <[]string> opt_incremental %type kv_option %type <[]tree.KVOption> kv_option_list opt_with_options var_set_list @@ -842,7 +845,7 @@ func newNameFromStr(s string) *tree.Name { %type <*tree.UnresolvedName> func_name %type opt_collate -%type database_name index_name opt_index_name column_name insert_column_item statistics_name window_name +%type cursor_name database_name index_name opt_index_name column_name insert_column_item statistics_name window_name %type family_name opt_family_name table_alias_name constraint_name target_name zone_name partition_name collation_name %type db_object_name_component %type <*tree.UnresolvedObjectName> table_name standalone_index_name sequence_name type_name view_name db_object_name simple_db_object_name complex_db_object_name @@ -1136,6 +1139,8 @@ stmt: | release_stmt // EXTEND WITH HELP: RELEASE | nonpreparable_set_stmt // help texts in sub-rule | transaction_stmt // help texts in sub-rule +| close_cursor_stmt +| declare_cursor_stmt | /* EMPTY */ { $$.val = tree.Statement(nil) @@ -3393,6 +3398,15 @@ show_stmt: | show_zone_stmt | SHOW error // SHOW HELP: SHOW +// Cursors are not yet supported by CockroachDB. CLOSE ALL is safe to no-op +// since there will be no open cursors. +close_cursor_stmt: + CLOSE ALL { } +| CLOSE cursor_name { return unimplementedWithIssue(sqllex, 41412) } + +declare_cursor_stmt: + DECLARE { return unimplementedWithIssue(sqllex, 41412) } + // %Help: SHOW SESSION - display session variables // %Category: Cfg // %Text: SHOW [SESSION] { | ALL } @@ -9588,6 +9602,8 @@ standalone_index_name: db_object_name explain_option_name: non_reserved_word +cursor_name: name + // Names for column references. // Accepted patterns: // @@ -9790,6 +9806,7 @@ unreserved_keyword: | CANCEL | CASCADE | CHANGEFEED +| CLOSE | CLUSTER | COLUMNS | COMMENT @@ -9815,6 +9832,7 @@ unreserved_keyword: | DATE | DAY | DEALLOCATE +| DECLARE | DELETE | DEFERRED | DISCARD