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 planner's understanding of strictness of type coercions.
Date: Wed, 20 Feb 2019 19:39:17 +0000
Message-ID: <E1gwXi9-00076a-Bg@gemulon.postgresql.org> (raw)

Improve planner's understanding of strictness of type coercions.

PG type coercions are generally strict, ie a NULL input must produce
a NULL output (or, in domain cases, possibly an error).  The planner's
understanding of that was a bit incomplete though, so improve it:

* Teach contain_nonstrict_functions() that CoerceViaIO can always be
considered strict.  Previously it believed that only if the underlying
I/O functions were marked strict, which is often but not always true.

* Teach clause_is_strict_for() that CoerceViaIO, ArrayCoerceExpr,
ConvertRowtypeExpr, CoerceToDomain can all be considered strict.
Previously it knew nothing about any of them.

The main user-visible impact of this is that IS NOT NULL predicates
can be proven to hold from expressions involving casts in more cases
than before, allowing partial indexes with such predicates to be used
without extra pushups.  This reduces the surprise factor for users,
who may well be used to ordinary (function-call-based) casts being
known to be strict.

Per a gripe from Samuel Williams.  This doesn't rise to the level of
a bug, IMO, so no back-patch.

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

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/util/clauses.c  | 10 ++++++++++
src/backend/optimizer/util/predtest.c | 21 +++++++++++++++++++++
2 files changed, 31 insertions(+)



Message-ID: <E1gwXi9-00076a-Bg@gemulon.postgresql.org>
Permalink:  ../E1gwXi9-00076a-Bg@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gwXi9-00076a-Bg@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 planner's understanding of strictness of type coercions.
  In-Reply-To: <E1gwXi9-00076a-Bg@gemulon.postgresql.org>
  References: <E1gwXi9-00076a-Bg@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