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@postgresql.org
Subject: pgsql: Improve predtest.c's internal docs, and enhance its functionalit
Date: Fri, 09 Mar 2018 21:58:35 +0000
Message-ID: <E1euQ27-0005T0-PX@gemulon.postgresql.org> (raw)

Improve predtest.c's internal docs, and enhance its functionality a bit.

Commit b08df9cab left things rather poorly documented as far as the
exact semantics of "clause_is_check" mode went.  Also, that mode did
not really work correctly for predicate_refuted_by; although given the
lack of specification as to what it should do, as well as the lack
of any actual use-case, that's perhaps not surprising.

Rename "clause_is_check" to "weak" proof mode, and provide specifications
for what it should do.  I defined weak refutation as meaning "truth of A
implies non-truth of B", which makes it possible to use the mode in the
part of relation_excluded_by_constraints that checks for mutually
contradictory WHERE clauses.  Fix up several places that did things wrong
for that definition.  (As far as I can see, these errors would only lead
to failure-to-prove, not incorrect claims of proof, making them not
serious bugs even aside from the fact that v10 contains no use of this
mode.  So there seems no need for back-patching.)

In addition, teach predicate_refuted_by_recurse that it can use
predicate_implied_by_recurse after all when processing a strong NOT-clause,
so long as it asks for the correct proof strength.  This is an optimization
that could have been included in commit b08df9cab, but wasn't.

Also, simplify and generalize the logic that checks for whether nullness of
the argument of IS [NOT] NULL would force overall nullness of the predicate
or clause.  (This results in a change in the partition_prune test's output,
as it is now able to prune an all-nulls partition that it did not recognize
before.)

In passing, in PartConstraintImpliedByRelConstraint, remove bogus
conversion of the constraint list to explicit-AND form and then right back
again; that accomplished nothing except forcing a useless extra level of
recursion inside predicate_implied_by.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5748f3a0aa7cf78ac6979010273bd9d50869bb8e

Modified Files
--------------
src/backend/commands/tablecmds.c                   |  20 +-
src/backend/optimizer/util/plancat.c               |   9 +-
src/backend/optimizer/util/predtest.c              | 363 +++++++++++++--------
src/include/optimizer/predtest.h                   |   4 +-
.../test_predtest/expected/test_predtest.out       |  89 ++++-
.../modules/test_predtest/sql/test_predtest.sql    |  34 +-
src/test/regress/expected/partition_prune.out      |   6 +-
src/test/regress/sql/partition_prune.sql           |   2 +-
8 files changed, 364 insertions(+), 163 deletions(-)



Message-ID: <E1euQ27-0005T0-PX@gemulon.postgresql.org>
Permalink:  ../E1euQ27-0005T0-PX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1euQ27-0005T0-PX@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 internal docs, and enhance its functionalit
  In-Reply-To: <E1euQ27-0005T0-PX@gemulon.postgresql.org>
  References: <E1euQ27-0005T0-PX@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