pgsql: Simplify the logic checking new range partition bounds.

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Simplify the logic checking new range partition bounds.
Date: 2017-07-06 09:03:15
Message-ID: E1dT2gt-000843-2H@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Simplify the logic checking new range partition bounds.

The previous logic, whilst not actually wrong, was overly complex and
involved doing two binary searches, where only one was really
necessary. This simplifies that logic and improves the comments.

One visible change is that if the new partition overlaps multiple
existing partitions, the error message now always reports the overlap
with the first existing partition (the one with the lowest
bounds). The old code would sometimes report the clash with the first
partition and sometimes with the last one.

Original patch idea from Amit Langote, substantially rewritten by me.

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

Branch
------
master

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

Modified Files
--------------
src/backend/catalog/partition.c | 92 +++++++++++++-----------------
src/test/regress/expected/create_table.out | 2 +-
2 files changed, 40 insertions(+), 54 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Dean Rasheed 2017-07-06 11:49:23 pgsql: Clarify the contract of partition_rbound_cmp().
Previous Message Tom Lane 2017-07-06 03:59:25 pgsql: Fix another race-condition-ish issue in recovery/t/001_stream_re