pgsql: Disallow LATERAL references to the target table of an UPDATE/DEL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Disallow LATERAL references to the target table of an UPDATE/DEL
Date: 2014-01-12 00:03:40
Message-ID: E1W28Wi-0001f8-Ew@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Disallow LATERAL references to the target table of an UPDATE/DELETE.

On second thought, commit 0c051c90082da0b7e5bcaf9aabcbd4f361137cdc was
over-hasty: rather than allowing this case, we ought to reject it for now.
That leaves the field clear for a future feature that allows the target
table to be re-specified in the FROM (or USING) clause, which will enable
left-joining the target table to something else. We can then also allow
LATERAL references to such an explicitly re-specified target table.
But allowing them right now will create ambiguities or worse for such a
feature, and it isn't something we documented 9.3 as supporting.

While at it, add a convenience subroutine to avoid having several copies
of the ereport for disalllowed-LATERAL-reference cases.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/158b7fa6a34006bdc70b515e14e120d3e896589b

Modified Files
--------------
src/backend/parser/analyze.c | 12 ++++---
src/backend/parser/parse_relation.c | 62 +++++++++++++++++++++--------------
src/include/parser/parse_node.h | 3 +-
src/test/regress/expected/join.out | 48 +++++++++++----------------
src/test/regress/sql/join.sql | 13 ++++----
5 files changed, 72 insertions(+), 66 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2014-01-13 03:26:23 pgsql: Fix pg_dumpall on pre-8.1 servers
Previous Message Tom Lane 2014-01-11 22:07:39 Re: pgsql: Revert fd2ace802811c333b0b4e1a28b138fd4774745f3