diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-05-09 22:41:12 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-05-09 22:41:12 -0400 |
commit | 3439f84475642fab029df0c06c81df94e6941dc0 (patch) | |
tree | 40343d84af3b2cef9075f853ed89df53c7d05b51 /src/backend/parser/parse_utilcmd.c | |
parent | 489b96e80b96c0eda02575347654e87968f2f5f4 (diff) | |
download | postgresql-3439f84475642fab029df0c06c81df94e6941dc0.tar.gz postgresql-3439f84475642fab029df0c06c81df94e6941dc0.zip |
Disallow finite partition bound following earlier UNBOUNDED column.
Amit Langote, per an observation by me.
Discussion: http://postgr.es/m/CA+TgmoYWnV2GMnYLG-Czsix-E1WGAbo4D+0tx7t9NdfYBDMFsA@mail.gmail.com
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r-- | src/backend/parser/parse_utilcmd.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index e187409f6f2..882955bb1c9 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -3358,6 +3358,7 @@ transformPartitionBound(ParseState *pstate, Relation parent, Node *bound) int i, j; char *colname; + bool seen_unbounded; if (spec->strategy != PARTITION_STRATEGY_RANGE) ereport(ERROR, @@ -3376,6 +3377,39 @@ transformPartitionBound(ParseState *pstate, Relation parent, Node *bound) (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("TO must specify exactly one value per partitioning column"))); + /* + * Check that no finite value follows a UNBOUNDED literal in either of + * lower and upper bound lists. + */ + seen_unbounded = false; + foreach(cell1, spec->lowerdatums) + { + PartitionRangeDatum *ldatum; + + ldatum = (PartitionRangeDatum *) lfirst(cell1); + if (ldatum->infinite) + seen_unbounded = true; + else if (seen_unbounded) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cannot specify finite value after UNBOUNDED"), + parser_errposition(pstate, exprLocation((Node *) ldatum)))); + } + seen_unbounded = false; + foreach(cell1, spec->upperdatums) + { + PartitionRangeDatum *rdatum; + + rdatum = (PartitionRangeDatum *) lfirst(cell1); + if (rdatum->infinite) + seen_unbounded = true; + else if (seen_unbounded) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cannot specify finite value after UNBOUNDED"), + parser_errposition(pstate, exprLocation((Node *) rdatum)))); + } + i = j = 0; result_spec->lowerdatums = result_spec->upperdatums = NIL; forboth(cell1, spec->lowerdatums, cell2, spec->upperdatums) |