pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve predtest.c's handling of cases with NULL-constant inputs
Date: Wed, 21 Mar 2018 22:30:51 +0000
Message-ID: <E1eymFv-0000Sy-Gu@gemulon.postgresql.org> (raw)

Improve predtest.c's handling of cases with NULL-constant inputs.

Currently, if operator_predicate_proof() is given an operator clause like
"something op NULL", it just throws up its hands and reports it can't prove
anything.  But we can often do better than that, if the operator is strict,
because then we know that the clause returns NULL overall.  Depending on
whether we're trying to prove or refute something, and whether we need
weak or strong semantics for NULL, this may be enough to prove the
implication, especially when we rely on the standard rule that "false
implies anything".  In particular, this lets us do something useful with
questions like "does X IN (1,3,5,NULL) imply X <= 5?"  The null entry
in the IN list can effectively be ignored for this purpose, but the
proof rules were not previously smart enough to deduce that.

This patch is by me, but it owes something to previous work by
Amit Langote to try to solve problems of the form mentioned.
Thanks also to Emre Hasegeli and Ashutosh Bapat for review.

Discussion: https://postgr.es/m/3bad48fc-f257-c445-feeb-8a2b2fb622ba@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f0deb71948321efc89cf4e3e8cbd9750cc9e566

Modified Files
--------------
src/backend/optimizer/util/predtest.c              | 59 ++++++++++++++++------
.../test_predtest/expected/test_predtest.out       |  3 +-
.../modules/test_predtest/sql/test_predtest.sql    |  1 -
src/test/regress/expected/inherit.out              |  6 +--
4 files changed, 46 insertions(+), 23 deletions(-)



Message-ID: <E1eymFv-0000Sy-Gu@gemulon.postgresql.org>
Permalink:  ../E1eymFv-0000Sy-Gu@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1eymFv-0000Sy-Gu@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Improve predtest.c's handling of cases with NULL-constant inputs
  In-Reply-To: <E1eymFv-0000Sy-Gu@gemulon.postgresql.org>
  References: <E1eymFv-0000Sy-Gu@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox