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@postgresql.org
Subject: pgsql: Prevent multicolumn expansion of "foo.*" in an UPDATE source exp
Date: Sun, 20 Nov 2016 19:26:46 +0000
Message-ID: <E1c8XlG-0001vx-MH@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Prevent multicolumn expansion of "foo.*" in an UPDATE source expression.

Because we use transformTargetList() for UPDATE as well as SELECT
tlists, the code accidentally tried to expand a "*" reference into
several columns.  This is nonsensical, because the UPDATE syntax
provides exactly one target column to put the value into.  The
immediate result was that transformUpdateTargetList() got confused
and reported "UPDATE target count mismatch --- internal error".
It seems better to treat such a reference as a plain whole-row
variable, as it would be in other contexts.  (This could produce
useful results when the target column is of composite type.)

Fix by tweaking transformTargetList() to perform *-expansion only
conditionally, depending on its exprKind parameter.

Back-patch to 9.3.  The problem exists further back, but a fix would be
much more invasive before that, because transformTargetList() wasn't
told what kind of list it was working on.  Doesn't seem worth the
trouble given the lack of field reports.  (I only noticed it because
I was checking the code while trying to improve the documentation about
how we handle "foo.*".)

Discussion: <4308.1479595330@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c5f365f3ab21a345b7a109bc0411895536e9fa69

Modified Files
--------------
src/backend/parser/parse_target.c    | 53 ++++++++++++++++++++++--------------
src/test/regress/expected/update.out | 18 ++++++++++++
src/test/regress/sql/update.sql      |  9 ++++++
3 files changed, 59 insertions(+), 21 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (5+ messages)

Message-ID: <E1c8XlG-0001vx-MH@gemulon.postgresql.org>
Permalink:  ../E1c8XlG-0001vx-MH@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1c8XlG-0001vx-MH@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: Prevent multicolumn expansion of "foo.*" in an UPDATE source exp
  In-Reply-To: <E1c8XlG-0001vx-MH@gemulon.postgresql.org>
  References: <E1c8XlG-0001vx-MH@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