pgsql: Clarify the contract of partition_rbound_cmp().

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Clarify the contract of partition_rbound_cmp().
Date: 2017-07-06 11:49:23
Message-ID: E1dT5Hf-0002oT-FN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Clarify the contract of partition_rbound_cmp().

partition_rbound_cmp() is intended to compare range partition bounds
in a way such that if all the bound values are equal but one is an
upper bound and one is a lower bound, the upper bound is treated as
smaller than the lower bound. This particular ordering is required by
RelationBuildPartitionDesc() when building the PartitionBoundInfoData,
so that it can consistently keep only the upper bounds when upper and
lower bounds coincide.

Update the function comment to make that clearer.

Also, fix a (currently unreachable) corner-case bug -- if the bound
values coincide and they contain unbounded values, fall through to the
lower-vs-upper comparison code, rather than immediately returning
0. Currently it is not possible to define coincident upper and lower
bounds containing unbounded columns, but that may change in the
future, so code defensively.

Discussion: https://postgr.es/m/CAAJ_b947mowpLdxL3jo3YLKngRjrq9+Ej4ymduQTfYR+8=YAYQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f1dae097f2945ffcb59a9f236843e0e0bbf0920d

Modified Files
--------------
src/backend/catalog/partition.c | 44 ++++++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Teodor Sigaev 2017-07-06 14:19:24 pgsql: Fix potential data corruption during freeze
Previous Message Dean Rasheed 2017-07-06 09:03:15 pgsql: Simplify the logic checking new range partition bounds.