pgsql: Mark built-in btree comparison functions as leakproof whereit's - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Mark built-in btree comparison functions as leakproof whereit's
Date
Msg-id E1fdNtc-00031T-Ns@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Mark built-in btree comparison functions as leakproof where it's safe.

Generally, if the comparison operators for a datatype or pair of datatypes
are leakproof, the corresponding btree comparison support function can be
considered so as well.  But we had not originally worried about marking
support functions as leakproof, reasoning that they'd not likely be used in
queries so the marking wouldn't matter.  It turns out there's at least one
place where it does matter: calc_arraycontsel() finds the target datatype's
default btree comparison function and tries to use that to estimate
selectivity, but it will be blocked in some cases if the function isn't
leakproof.  This leads to unnecessarily poor selectivity estimates and bad
plans, as seen in bug #15251.

Hence, run around and apply proleakproof markings where the corresponding
btree comparison operators are leakproof.  (I did eyeball each function
to verify that it wasn't doing anything surprising, too.)

This isn't a full solution to bug #15251, and it's not back-patchable
because of the need for a catversion bump.  A more useful response probably
is to consider whether we can check permissions on the parent table instead
of the child.  However, this change will help in some cases where that
won't, and it's easy enough to do in HEAD, so let's do so.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/39a96512b3ed72de7b24b2667d9575d7e9fcb326

Modified Files
--------------
src/include/catalog/catversion.h         |   2 +-
src/include/catalog/pg_proc.dat          | 116 +++++++++++++++----------------
src/test/regress/expected/opr_sanity.out |  35 ++++++++++
3 files changed, 94 insertions(+), 59 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix create_scan_plan's handling of sortgrouprefs for physicaltl
Next
From: Michael Paquier
Date:
Subject: pgsql: Make logical WAL sender report streaming state appropriately