@@ -334,6 +334,11 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
334334 simple_select values_clause
335335 PLpgSQL_Expr PLAssignStmt
336336
337+ %type <str> opt_single_name
338+ %type <list> opt_qualified_name
339+ %type <boolean> opt_concurrently
340+ %type <dbehavior> opt_drop_behavior
341+
337342%type <node> alter_column_default opclass_item opclass_drop alter_using
338343%type <ival> add_drop opt_asc_desc opt_nulls_order
339344
@@ -343,8 +348,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
343348%type <list> alter_identity_column_option_list
344349%type <defelt> alter_identity_column_option
345350
346- %type <dbehavior> opt_drop_behavior
347-
348351%type <list> createdb_opt_list createdb_opt_items copy_opt_list
349352 transaction_mode_list
350353 create_extension_opt_list alter_extension_opt_list
@@ -371,7 +374,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
371374%type <str> foreign_server_version opt_foreign_server_version
372375%type <str> opt_in_database
373376
374- %type <str> OptSchemaName parameter_name
377+ %type <str> parameter_name
375378%type <list> OptSchemaEltList parameter_name_list
376379
377380%type <chr> am_type
@@ -392,10 +395,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
392395%type <str> copy_file_name
393396 access_method_clause attr_name
394397 table_access_method_clause name cursor_name file_name
395- opt_index_name cluster_index_specification
398+ cluster_index_specification
396399
397400%type <list> func_name handler_name qual_Op qual_all_Op subquery_Op
398- opt_class opt_inline_handler opt_validator validator_clause
401+ opt_inline_handler opt_validator validator_clause
399402 opt_collate
400403
401404%type <range> qualified_name insert_target OptConstrFromTable
@@ -435,7 +438,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
435438 oper_argtypes RuleActionList RuleActionMulti
436439 opt_column_list columnList opt_name_list
437440 sort_clause opt_sort_clause sortby_list index_params
438- opt_stats_name stats_params
441+ stats_params
439442 opt_include opt_c_include index_including_params
440443 name_list role_list from_clause from_list opt_array_bounds
441444 qualified_name_list any_name any_name_list type_name_list
@@ -495,7 +498,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
495498%type <str> unicode_normal_form
496499
497500%type <boolean> opt_instead
498- %type <boolean> opt_unique opt_concurrently opt_verbose opt_full
501+ %type <boolean> opt_unique opt_verbose opt_full
499502%type <boolean> opt_freeze opt_analyze opt_default opt_recheck
500503%type <defelt> opt_binary copy_delimiter
501504
@@ -1180,6 +1183,30 @@ stmt:
11801183 { $$ = NULL ; }
11811184 ;
11821185
1186+ /*
1187+ * Generic supporting productions for DDL
1188+ */
1189+ opt_single_name :
1190+ ColId { $$ = $1 ; }
1191+ | /* EMPTY */ { $$ = NULL ; }
1192+ ;
1193+
1194+ opt_qualified_name :
1195+ any_name { $$ = $1 ; }
1196+ | /* EMPTY*/ { $$ = NIL; }
1197+ ;
1198+
1199+ opt_concurrently :
1200+ CONCURRENTLY { $$ = true ; }
1201+ | /* EMPTY*/ { $$ = false ; }
1202+ ;
1203+
1204+ opt_drop_behavior :
1205+ CASCADE { $$ = DROP_CASCADE; }
1206+ | RESTRICT { $$ = DROP_RESTRICT; }
1207+ | /* EMPTY */ { $$ = DROP_RESTRICT; /* default */ }
1208+ ;
1209+
11831210/* ****************************************************************************
11841211 *
11851212 * CALL statement
@@ -1554,7 +1581,7 @@ add_drop: ADD_P { $$ = +1; }
15541581 *****************************************************************************/
15551582
15561583CreateSchemaStmt :
1557- CREATE SCHEMA OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
1584+ CREATE SCHEMA opt_single_name AUTHORIZATION RoleSpec OptSchemaEltList
15581585 {
15591586 CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
15601587
@@ -1576,7 +1603,7 @@ CreateSchemaStmt:
15761603 n->if_not_exists = false ;
15771604 $$ = (Node *) n;
15781605 }
1579- | CREATE SCHEMA IF_P NOT EXISTS OptSchemaName AUTHORIZATION RoleSpec OptSchemaEltList
1606+ | CREATE SCHEMA IF_P NOT EXISTS opt_single_name AUTHORIZATION RoleSpec OptSchemaEltList
15801607 {
15811608 CreateSchemaStmt *n = makeNode(CreateSchemaStmt);
15821609
@@ -1610,11 +1637,6 @@ CreateSchemaStmt:
16101637 }
16111638 ;
16121639
1613- OptSchemaName :
1614- ColId { $$ = $1 ; }
1615- | /* EMPTY */ { $$ = NULL ; }
1616- ;
1617-
16181640OptSchemaEltList :
16191641 OptSchemaEltList schema_stmt
16201642 {
@@ -2995,12 +3017,6 @@ alter_column_default:
29953017 | DROP DEFAULT { $$ = NULL ; }
29963018 ;
29973019
2998- opt_drop_behavior :
2999- CASCADE { $$ = DROP_CASCADE; }
3000- | RESTRICT { $$ = DROP_RESTRICT; }
3001- | /* EMPTY */ { $$ = DROP_RESTRICT; /* default */ }
3002- ;
3003-
30043020opt_collate_clause :
30053021 COLLATE any_name
30063022 {
@@ -4467,7 +4483,7 @@ part_params: part_elem { $$ = list_make1($1); }
44674483 | part_params ' ,' part_elem { $$ = lappend($1 , $3 ); }
44684484 ;
44694485
4470- part_elem : ColId opt_collate opt_class
4486+ part_elem : ColId opt_collate opt_qualified_name
44714487 {
44724488 PartitionElem *n = makeNode(PartitionElem);
44734489
@@ -4478,7 +4494,7 @@ part_elem: ColId opt_collate opt_class
44784494 n->location = @1 ;
44794495 $$ = n;
44804496 }
4481- | func_expr_windowless opt_collate opt_class
4497+ | func_expr_windowless opt_collate opt_qualified_name
44824498 {
44834499 PartitionElem *n = makeNode(PartitionElem);
44844500
@@ -4489,7 +4505,7 @@ part_elem: ColId opt_collate opt_class
44894505 n->location = @1 ;
44904506 $$ = n;
44914507 }
4492- | ' (' a_expr ' )' opt_collate opt_class
4508+ | ' (' a_expr ' )' opt_collate opt_qualified_name
44934509 {
44944510 PartitionElem *n = makeNode(PartitionElem);
44954511
@@ -4543,10 +4559,12 @@ ExistingIndex: USING INDEX name { $$ = $3; }
45434559 * but the grammar accepts it and then we'll throw FEATURE_NOT_SUPPORTED
45444560 * errors as necessary at execution.
45454561 *
4562+ * Statistics name is optional unless IF NOT EXISTS is specified.
4563+ *
45464564 *****************************************************************************/
45474565
45484566CreateStatsStmt :
4549- CREATE STATISTICS opt_stats_name
4567+ CREATE STATISTICS opt_qualified_name
45504568 opt_name_list ON stats_params FROM from_list
45514569 {
45524570 CreateStatsStmt *n = makeNode(CreateStatsStmt);
@@ -4574,12 +4592,6 @@ CreateStatsStmt:
45744592 }
45754593 ;
45764594
4577- /* Statistics name is optional unless IF NOT EXISTS is specified */
4578- opt_stats_name :
4579- any_name { $$ = $1 ; }
4580- | /* EMPTY*/ { $$ = NULL ; }
4581- ;
4582-
45834595/*
45844596 * Statistics attributes can be either simple column references, or arbitrary
45854597 * expressions in parens. For compatibility with index attributes permitted
@@ -7987,7 +7999,7 @@ defacl_privilege_target:
79877999 * willing to make TABLESPACE a fully reserved word.
79888000 *****************************************************************************/
79898001
7990- IndexStmt : CREATE opt_unique INDEX opt_concurrently opt_index_name
8002+ IndexStmt : CREATE opt_unique INDEX opt_concurrently opt_single_name
79918003 ON relation_expr access_method_clause ' (' index_params ' )'
79928004 opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
79938005 {
@@ -8058,16 +8070,6 @@ opt_unique:
80588070 | /* EMPTY*/ { $$ = false ; }
80598071 ;
80608072
8061- opt_concurrently :
8062- CONCURRENTLY { $$ = true ; }
8063- | /* EMPTY*/ { $$ = false ; }
8064- ;
8065-
8066- opt_index_name :
8067- name { $$ = $1 ; }
8068- | /* EMPTY*/ { $$ = NULL ; }
8069- ;
8070-
80718073access_method_clause :
80728074 USING name { $$ = $2 ; }
80738075 | /* EMPTY*/ { $$ = DEFAULT_INDEX_TYPE; }
@@ -8079,7 +8081,7 @@ index_params: index_elem { $$ = list_make1($1); }
80798081
80808082
80818083index_elem_options :
8082- opt_collate opt_class opt_asc_desc opt_nulls_order
8084+ opt_collate opt_qualified_name opt_asc_desc opt_nulls_order
80838085 {
80848086 $$ = makeNode(IndexElem);
80858087 $$ ->name = NULL ;
@@ -8139,9 +8141,6 @@ opt_collate: COLLATE any_name { $$ = $2; }
81398141 | /* EMPTY*/ { $$ = NIL; }
81408142 ;
81418143
8142- opt_class : any_name { $$ = $1 ; }
8143- | /* EMPTY*/ { $$ = NIL; }
8144- ;
81458144
81468145opt_asc_desc : ASC { $$ = SORTBY_ASC; }
81478146 | DESC { $$ = SORTBY_DESC; }
0 commit comments