From d363d42bb9a4399a0207bd3b371c966e22e06bd3 Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Fri, 21 Jul 2017 09:20:47 +0100 Subject: Use MINVALUE/MAXVALUE instead of UNBOUNDED for range partition bounds. Previously, UNBOUNDED meant no lower bound when used in the FROM list, and no upper bound when used in the TO list, which was OK for single-column range partitioning, but problematic with multiple columns. For example, an upper bound of (10.0, UNBOUNDED) would not be collocated with a lower bound of (10.0, UNBOUNDED), thus making it difficult or impossible to define contiguous multi-column range partitions in some cases. Fix this by using MINVALUE and MAXVALUE instead of UNBOUNDED to represent a partition column that is unbounded below or above respectively. This syntax removes any ambiguity, and ensures that if one partition's lower bound equals another partition's upper bound, then the partitions are contiguous. Also drop the constraint prohibiting finite values after an unbounded column, and just document the fact that any values after MINVALUE or MAXVALUE are ignored. Previously it was necessary to repeat UNBOUNDED multiple times, which was needlessly verbose. Note: Forces a post-PG 10 beta2 initdb. Report by Amul Sul, original patch by Amit Langote with some additional hacking by me. Discussion: https://postgr.es/m/CAAJ_b947mowpLdxL3jo3YLKngRjrq9+Ej4ymduQTfYR+8=YAYQ@mail.gmail.com --- src/backend/parser/parse_utilcmd.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'src/backend/parser/parse_utilcmd.c') diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index ee5f3a3a52c..9f37f1b9206 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -3365,7 +3365,6 @@ transformPartitionBound(ParseState *pstate, Relation parent, *cell2; int i, j; - bool seen_unbounded; if (spec->strategy != PARTITION_STRATEGY_RANGE) ereport(ERROR, @@ -3382,39 +3381,6 @@ transformPartitionBound(ParseState *pstate, Relation parent, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("TO must specify exactly one value per partitioning column"))); - /* - * Check that no finite value follows an UNBOUNDED item in either of - * lower and upper bound lists. - */ - seen_unbounded = false; - foreach(cell1, spec->lowerdatums) - { - PartitionRangeDatum *ldatum = castNode(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 = castNode(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)))); - } - /* Transform all the constants */ i = j = 0; result_spec->lowerdatums = result_spec->upperdatums = NIL; -- cgit v1.2.3