pgsql: Fix run-time partition pruning code to handle NULL values proper

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix run-time partition pruning code to handle NULL values proper
Date: 2018-06-11 16:08:29
Message-ID: E1fSPMr-0006yb-Ps@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix run-time partition pruning code to handle NULL values properly.

The previous coding just ignored pruning constraints that compare a
partition key to a null-valued expression. This is silly, since really
what we can do there is conclude that all partitions are rejected: the
pruning operator is known strict so the comparison must always fail.

This also fixes the logic to not ignore constisnull for a Const comparison
value. That's probably an unreachable case, since the planner would
normally have simplified away a strict operator with a constant-null input.
But this code has no business assuming that.

David Rowley, per a gripe from me

Discussion: https://postgr.es/m/26279.1528670981@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/partitioning/partprune.c | 48 +++++++++++++++++++--------
src/test/regress/expected/partition_prune.out | 14 ++++++++
src/test/regress/sql/partition_prune.sql | 4 +++
3 files changed, 53 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2018-06-11 16:49:52 Re: pgsql: Fix and document lock handling for in-memory replication slot da
Previous Message Peter Eisentraut 2018-06-11 15:26:34 pgsql: Make new error code name match SQL standard more closely