From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Dominique Devienne <ddevienne(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: UPDATE-FROM and INNER-JOIN |
Date: | 2024-08-05 15:01:50 |
Message-ID: | 1073701.1722870110@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Dominique Devienne <ddevienne(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Dominique Devienne | 2024-08-05 15:09:20 | Re: UPDATE-FROM and INNER-JOIN |
Previous Message | David G. Johnston | 2024-08-05 14:57:08 | Re: UPDATE-FROM and INNER-JOIN |