aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2017-04-27 20:14:39 -0400
committerStephen Frost <sfrost@snowman.net>2017-04-27 20:14:39 -0400
commitb9a3ef55b253d885081c2d0e9dc45802cab71c7b (patch)
tree7ac94e2b90d2b8269a3b826300e8d5d51d7ff7d3 /src/backend/parser
parentab9c43381ef7a7333086107847413e0b593854d0 (diff)
downloadpostgresql-b9a3ef55b253d885081c2d0e9dc45802cab71c7b.tar.gz
postgresql-b9a3ef55b253d885081c2d0e9dc45802cab71c7b.zip
Remove unnecessairly duplicated gram.y productions
Declarative partitioning duplicated the TypedTableElement productions, evidently to remove the need to specify WITH OPTIONS when creating partitions. Instead, simply make WITH OPTIONS optional in the TypedTableElement production and remove all of the duplicate PartitionElement-related productions. This change simplifies the syntax and makes WITH OPTIONS optional when adding defaults, constraints or storage parameters to columns when creating either typed tables or partitions. Also update pg_dump to no longer include WITH OPTIONS, since it's not necessary, and update the documentation to reflect that WITH OPTIONS is now optional.
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/gram.y68
1 files changed, 23 insertions, 45 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 89d2836c49a..21cdc7c7da4 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -576,8 +576,6 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <str> part_strategy
%type <partelem> part_elem
%type <list> part_params
-%type <list> OptPartitionElementList PartitionElementList
-%type <node> PartitionElement
%type <node> ForValues
%type <node> partbound_datum
%type <list> partbound_datum_list
@@ -3131,7 +3129,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$$ = (Node *)n;
}
| CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name
- OptPartitionElementList ForValues OptPartitionSpec OptWith
+ OptTypedTableElementList ForValues OptPartitionSpec OptWith
OnCommitOption OptTableSpace
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3150,7 +3148,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$$ = (Node *)n;
}
| CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF
- qualified_name OptPartitionElementList ForValues OptPartitionSpec
+ qualified_name OptTypedTableElementList ForValues OptPartitionSpec
OptWith OnCommitOption OptTableSpace
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3213,11 +3211,6 @@ OptTypedTableElementList:
| /*EMPTY*/ { $$ = NIL; }
;
-OptPartitionElementList:
- '(' PartitionElementList ')' { $$ = $2; }
- | /*EMPTY*/ { $$ = NIL; }
- ;
-
TableElementList:
TableElement
{
@@ -3240,17 +3233,6 @@ TypedTableElementList:
}
;
-PartitionElementList:
- PartitionElement
- {
- $$ = list_make1($1);
- }
- | PartitionElementList ',' PartitionElement
- {
- $$ = lappend($1, $3);
- }
- ;
-
TableElement:
columnDef { $$ = $1; }
| TableLikeClause { $$ = $1; }
@@ -3262,28 +3244,6 @@ TypedTableElement:
| TableConstraint { $$ = $1; }
;
-PartitionElement:
- TableConstraint { $$ = $1; }
- | ColId ColQualList
- {
- ColumnDef *n = makeNode(ColumnDef);
- n->colname = $1;
- n->typeName = NULL;
- n->inhcount = 0;
- n->is_local = true;
- n->is_not_null = false;
- n->is_from_type = false;
- n->storage = 0;
- n->raw_default = NULL;
- n->cooked_default = NULL;
- n->collOid = InvalidOid;
- SplitColQualList($2, &n->constraints, &n->collClause,
- yyscanner);
- n->location = @1;
- $$ = (Node *) n;
- }
- ;
-
columnDef: ColId Typename create_generic_options ColQualList
{
ColumnDef *n = makeNode(ColumnDef);
@@ -3305,7 +3265,25 @@ columnDef: ColId Typename create_generic_options ColQualList
}
;
-columnOptions: ColId WITH OPTIONS ColQualList
+columnOptions: ColId ColQualList
+ {
+ ColumnDef *n = makeNode(ColumnDef);
+ n->colname = $1;
+ n->typeName = NULL;
+ n->inhcount = 0;
+ n->is_local = true;
+ n->is_not_null = false;
+ n->is_from_type = false;
+ n->storage = 0;
+ n->raw_default = NULL;
+ n->cooked_default = NULL;
+ n->collOid = InvalidOid;
+ SplitColQualList($2, &n->constraints, &n->collClause,
+ yyscanner);
+ n->location = @1;
+ $$ = (Node *)n;
+ }
+ | ColId WITH OPTIONS ColQualList
{
ColumnDef *n = makeNode(ColumnDef);
n->colname = $1;
@@ -4872,7 +4850,7 @@ CreateForeignTableStmt:
$$ = (Node *) n;
}
| CREATE FOREIGN TABLE qualified_name
- PARTITION OF qualified_name OptPartitionElementList ForValues
+ PARTITION OF qualified_name OptTypedTableElementList ForValues
SERVER name create_generic_options
{
CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);
@@ -4893,7 +4871,7 @@ CreateForeignTableStmt:
$$ = (Node *) n;
}
| CREATE FOREIGN TABLE IF_P NOT EXISTS qualified_name
- PARTITION OF qualified_name OptPartitionElementList ForValues
+ PARTITION OF qualified_name OptTypedTableElementList ForValues
SERVER name create_generic_options
{
CreateForeignTableStmt *n = makeNode(CreateForeignTableStmt);