Re: UPDATE-FROM and INNER-JOIN - Mailing list pgsql-general

From Tom Lane
Subject Re: UPDATE-FROM and INNER-JOIN
Date
Msg-id 1073701.1722870110@sss.pgh.pa.us
Whole thread Raw
In response to Re: UPDATE-FROM and INNER-JOIN  (Dominique Devienne <ddevienne@gmail.com>)
Responses Re: UPDATE-FROM and INNER-JOIN
List pgsql-general
Dominique Devienne <ddevienne@gmail.com> writes:
> The reason I find the restriction damaging is that `FROM t1, t2 WHERE
> t1.c1 = t2.c2`
> is the "old" way to write joins, versus the "newer" `FROM t1 JOIN t2
> ON t1.c1 = t2.c2`
> which IMHO better separates "filtering" from "joining" columns. FWIW.

But the whole point of that syntax is to be explicit about which
tables the ON clause(s) can draw from.  If we had a more complex
FROM clause, with say three or four JOINs involved, which part of
that would you argue the UPDATE target table should be implicitly
inserted into?  The only thing that would be non-ambiguous would
be to require the target table to be explicitly named in FROM
(and not treat that as a self-join, but as the sole scan of the
target table).  Some other RDBMSes do it like that, but it seems
like too much of a compatibility break for us.

Sadly, the SQL spec doesn't provide for a FROM clause in UPDATE,
so they offer no guidance.  But I doubt we are going to change
this unless the standard defines it and does so in a way that
doesn't match what we're doing.

            regards, tom lane



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: UPDATE-FROM and INNER-JOIN
Next
From: Dominique Devienne
Date:
Subject: Re: UPDATE-FROM and INNER-JOIN