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: Straighten out leakproofness markings on text comparison functio
Date: Sat, 21 Sep 2019 20:56:39 +0000
Message-ID: <E1iBmQp-00043P-7W@gemulon.postgresql.org> (raw)

Straighten out leakproofness markings on text comparison functions.

Since we introduced the idea of leakproof functions, texteq and textne
were marked leakproof but their sibling text comparison functions were
not.  This inconsistency seemed justified because texteq/textne just
relied on memcmp() and so could easily be seen to be leakproof, while
the other comparison functions are far more complex and indeed can
throw input-dependent errors.

However, that argument crashed and burned with the addition of
nondeterministic collations, because now texteq/textne may invoke
the exact same varstr_cmp() infrastructure as the rest.  It makes no
sense whatever to give them different leakproofness markings.

After a certain amount of angst we've concluded that it's all right
to consider varstr_cmp() to be leakproof, mostly because the other
choice would be disastrous for performance of many queries where
leakproofness matters.  The input-dependent errors should only be
reachable for corrupt input data, or so we hope anyway; certainly,
if they are reachable in practice, we've got problems with requirements
as basic as maintaining a btree index on a text column.

Hence, run around to all the SQL functions that derive from varstr_cmp()
and mark them leakproof.  This should result in a useful gain in
flexibility/performance for queries in which non-leakproofness degrades
the efficiency of the query plan.

Back-patch to v12 where nondeterministic collations were added.
While this isn't an essential bug fix given the determination
that varstr_cmp() is leakproof, we might as well apply it now that
we've been forced into a post-beta4 catversion bump.

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

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/varlena.c          |   6 ++
src/include/catalog/catversion.h         |   2 +-
src/include/catalog/pg_proc.dat          | 132 +++++++++++++++----------------
src/test/regress/expected/opr_sanity.out |  54 ++++++++++---
src/test/regress/sql/opr_sanity.sql      |   2 -
5 files changed, 115 insertions(+), 81 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1iBmQp-00043P-7W@gemulon.postgresql.org>
Permalink:  ../E1iBmQp-00043P-7W@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iBmQp-00043P-7W@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: Straighten out leakproofness markings on text comparison functio
  In-Reply-To: <E1iBmQp-00043P-7W@gemulon.postgresql.org>
  References: <E1iBmQp-00043P-7W@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