aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-07-19 15:41:46 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-07-19 15:41:46 -0400
commit24097167558bafbc1ea32f67ea5840e5650ad4e7 (patch)
tree757367ffd4e568bca76a04d493a648c90d01a5fa /src
parent90371a24a5367c357d7b046383dad8ee352b938b (diff)
downloadpostgresql-24097167558bafbc1ea32f67ea5840e5650ad4e7.tar.gz
postgresql-24097167558bafbc1ea32f67ea5840e5650ad4e7.zip
Remove undocumented restriction against duplicate partition key columns.
transformPartitionSpec rejected duplicate simple partition columns (e.g., "PARTITION BY RANGE (x,x)") but paid no attention to expression columns, resulting in inconsistent behavior. Worse, cases like "PARTITION BY RANGE (x,(x))") were accepted but would then result in dump/reload failures, since the expression (x) would get simplified to a plain column later. There seems no better reason for this restriction than there was for the one against duplicate included index columns (cf commit 701fd0bbc), so let's just remove it. Back-patch to v10 where this code was added. Report and patch by Yugo Nagata. Discussion: https://postgr.es/m/20180712165939.36b12aff.nagata@sraoss.co.jp
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/tablecmds.c15
-rw-r--r--src/test/regress/expected/create_table.out5
-rw-r--r--src/test/regress/sql/create_table.sql5
3 files changed, 0 insertions, 25 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 4d3fc3098c9..eb2d33dd86d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -13628,21 +13628,6 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
foreach(l, partspec->partParams)
{
PartitionElem *pelem = castNode(PartitionElem, lfirst(l));
- ListCell *lc;
-
- /* Check for PARTITION BY ... (foo, foo) */
- foreach(lc, newspec->partParams)
- {
- PartitionElem *pparam = castNode(PartitionElem, lfirst(lc));
-
- if (pelem->name && pparam->name &&
- strcmp(pelem->name, pparam->name) == 0)
- ereport(ERROR,
- (errcode(ERRCODE_DUPLICATE_COLUMN),
- errmsg("column \"%s\" appears more than once in partition key",
- pelem->name),
- parser_errposition(pstate, pelem->location)));
- }
if (pelem->expr)
{
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 8fdbca13458..8927b21ba2c 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -288,11 +288,6 @@ CREATE TABLE partitioned (
ERROR: exclusion constraints are not supported on partitioned tables
LINE 3: EXCLUDE USING gist (a WITH &&)
^
--- prevent column from being used twice in the partition key
-CREATE TABLE partitioned (
- a int
-) PARTITION BY RANGE (a, a);
-ERROR: column "a" appears more than once in partition key
-- prevent using prohibited expressions in the key
CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
CREATE TABLE partitioned (
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index 78944950fef..81fa7658b0d 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -303,11 +303,6 @@ CREATE TABLE partitioned (
EXCLUDE USING gist (a WITH &&)
) PARTITION BY RANGE (a);
--- prevent column from being used twice in the partition key
-CREATE TABLE partitioned (
- a int
-) PARTITION BY RANGE (a, a);
-
-- prevent using prohibited expressions in the key
CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
CREATE TABLE partitioned (