Re: Adding support for a fully qualified column-name in UPDATE ... SET - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Adding support for a fully qualified column-name in UPDATE ... SET
Date
Msg-id 14868.1544203383@sss.pgh.pa.us
Whole thread Raw
In response to Adding support for a fully qualified column-name in UPDATE ... SET  (Jim Finnerty <jfinnert@amazon.com>)
Responses Re: Adding support for a fully qualified column-name in UPDATE ...SET
List pgsql-hackers
Jim Finnerty <jfinnert@amazon.com> writes:
> The accepted syntax for UPDATE ... SET does not currently permit the column
> name to be qualified by schema.table or table or correlation-name, as is
> permitted in other systems.  This is apparently due to the syntax that
> PostgreSQL accepts for composite columns, which would create an ambiguity in
> the grammar if both SET t.c [ opt_indirection ] = value, or SET c.f [
> opt_indirection ] = value, were both allowed.

> As a result, databases migrated from several other commercial database
> servers to PostgreSQL must be "cleaned up" to reconcile these differences. 
> This can be time consuming and unnecessary.

> This can be disambiguated during semantic analysis in all but the most
> contrived cases.

I don't think it'd really be a good idea to allow "SET x.y = ..." to mean
two (or more?) completely different things depending on context.  That's
just a recipe for shooting yourself in the foot.  Your claim that
ambiguity would arise only in contrived cases seems way over-optimistic.

The case for doing something would be stronger if the SQL spec allowed
qualified column names here.  But AFAICS it does not, for pretty much
the same reason we don't: it thinks "x.y" is an assignment to subcolumn
y of composite column x --- or at least I think that's what the
impenetrable verbiage around "mutated set clause" means.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: additional foreign key test coverage
Next
From: Andres Freund
Date:
Subject: Re: make install getting slower