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: Consider syntactic form when disambiguating function vs column r
Date: Mon, 18 Jun 2018 15:39:47 +0000
Message-ID: <E1fUwFv-0001d3-1L@gemulon.postgresql.org> (raw)

Consider syntactic form when disambiguating function vs column reference.

Postgres has traditionally considered the syntactic forms f(x) and x.f
to be equivalent, allowing tricks such as writing a function and then
using it as though it were a computed-on-demand column.  However, our
behavior when both interpretations are feasible left something to be
desired: we always chose the column interpretation.  This could lead
to very surprising results, as in a recent bug report from Neil Conway.
It also created a dump-and-reload hazard, since what was a function
call in a dumped view could get interpreted as a column reference
at reload, if a matching column name had been added to the underlying
table since the view was created.

What seems better, in ambiguous situations, is to prefer the choice
matching the syntactic form of the reference.  This seems much less
astonishing in general, and it fixes the dump/reload hazard.

Although this could be called a bug fix, there have been few complaints
and there's some small risk of breaking applications that depend on the
old behavior, so no back-patch.  It does seem reasonable to slip it
into v11, though.

Discussion: https://postgr.es/m/CAOW5sYa3Wp7KozCuzjOdw6PiOYPi6D=VvRybtH2S=2C0SVmRmA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/rowtypes.sgml             |   9 ++-
src/backend/parser/parse_func.c        | 125 ++++++++++++++++++++-------------
src/test/regress/expected/rowtypes.out |  44 ++++++++++++
src/test/regress/sql/rowtypes.sql      |  20 ++++++
4 files changed, 148 insertions(+), 50 deletions(-)



Message-ID: <E1fUwFv-0001d3-1L@gemulon.postgresql.org>
Permalink:  ../E1fUwFv-0001d3-1L@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fUwFv-0001d3-1L@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: Consider syntactic form when disambiguating function vs column r
  In-Reply-To: <E1fUwFv-0001d3-1L@gemulon.postgresql.org>
  References: <E1fUwFv-0001d3-1L@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