From 09f5ea9393b34ba3df821e0545ef2e224afd6546 Mon Sep 17 00:00:00 2001 From: amit Date: Wed, 12 Apr 2017 15:16:56 +0900 Subject: [PATCH 2/4] Allow partition columns to optionally include WITH OPTIONS keywords --- src/backend/parser/gram.y | 20 ++++++++++++++++++++ src/test/regress/expected/create_table.out | 3 ++- src/test/regress/sql/create_table.sql | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 89d2836c49..4f674cda70 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -3282,6 +3282,26 @@ PartitionElement: n->location = @1; $$ = (Node *) n; } + + /* Optionally, allow WITH OPTIONS keywords */ + | ColId WITH OPTIONS 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($4, &n->constraints, &n->collClause, + yyscanner); + n->location = @1; + $$ = (Node *) n; + } ; columnDef: ColId Typename create_generic_options ColQualList diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out index 1828f49f06..21173f7563 100644 --- a/src/test/regress/expected/create_table.out +++ b/src/test/regress/expected/create_table.out @@ -610,6 +610,7 @@ SELECT attname, attislocal, attinhcount FROM pg_attribute -- able to specify column default, column constraint, and table constraint CREATE TABLE part_b PARTITION OF parted ( + a WITH OPTIONS NOT NULL, b NOT NULL DEFAULT 1, CONSTRAINT check_a CHECK (length(a) > 0), CONSTRAINT check_b CHECK (b >= 0) @@ -658,7 +659,7 @@ CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10); Table "public.part_b" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- - a | text | | | + a | text | | not null | b | integer | | not null | 1 Partition of: parted FOR VALUES IN ('b') diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql index ff2c7d571d..d1c2926ad3 100644 --- a/src/test/regress/sql/create_table.sql +++ b/src/test/regress/sql/create_table.sql @@ -570,6 +570,7 @@ SELECT attname, attislocal, attinhcount FROM pg_attribute -- able to specify column default, column constraint, and table constraint CREATE TABLE part_b PARTITION OF parted ( + a WITH OPTIONS NOT NULL, b NOT NULL DEFAULT 1, CONSTRAINT check_a CHECK (length(a) > 0), CONSTRAINT check_b CHECK (b >= 0) -- 2.11.0