pgsql: Prevent multicolumn expansion of "foo.*" in an UPDATE source exp

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Prevent multicolumn expansion of "foo.*" in an UPDATE source exp
Date: 2016-11-20 19:26:46
Message-ID: E1c8XlG-0001w3-MX@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-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(dot)1479595330(at)sss(dot)pgh(dot)pa(dot)us>

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/44c8b4fcdf4db4f50e4bfc0bf403d08b4cbfff72

Modified Files
--------------
src/backend/parser/parse_target.c | 59 +++++++++++++++++++++---------------
src/test/regress/expected/update.out | 7 +++++
src/test/regress/sql/update.sql | 4 +++
3 files changed, 46 insertions(+), 24 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-11-21 16:09:39 pgsql: Fix test for subplans in force-parallel mode.
Previous Message Tom Lane 2016-11-19 20:06:48 pgsql: Fix latent costing error in create_merge_append_path.