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: Mark built-in coercion functions as leakproof where possible.
Date: Sat, 25 Jul 2020 16:55:23 +0000
Message-ID: <E1jzNSF-0004dq-IP@gemulon.postgresql.org> (raw)

Mark built-in coercion functions as leakproof where possible.

Making these leakproof seems helpful since (for example) if you have a
function f(int8) that is leakproof, you don't want it to effectively
become non-leakproof when you apply it to an int4 or int2 column.
But that's what happens today, since the implicit up-coercion will
not be leakproof.

Most of the coercion functions that visibly can't throw errors are
functions that convert numeric datatypes to other, wider ones.
Notable is that float4_numeric and float8_numeric can be marked
leakproof; before commit a57d312a7 they could not have been.
I also marked the functions that coerce strings to "name" as leakproof;
that's okay today because they truncate silently, but if we ever
reconsidered that behavior then they could no longer be leakproof.

I desisted from marking rtrim1() as leakproof; it appears so right now,
but the code seems a little too complex and perhaps subject to change,
since it's shared with other SQL functions.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8a37951eebffd9bf528cb06d46127fb721d0e452

Modified Files
--------------
src/include/catalog/catversion.h         |   2 +-
src/include/catalog/pg_proc.dat          | 103 ++++++++++++++++---------------
src/test/regress/expected/opr_sanity.out |  25 ++++++++
3 files changed, 78 insertions(+), 52 deletions(-)



Message-ID: <E1jzNSF-0004dq-IP@gemulon.postgresql.org>
Permalink:  ../E1jzNSF-0004dq-IP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jzNSF-0004dq-IP@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: Mark built-in coercion functions as leakproof where possible.
  In-Reply-To: <E1jzNSF-0004dq-IP@gemulon.postgresql.org>
  References: <E1jzNSF-0004dq-IP@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