Re: DELETE ... USING LATERAL - Mailing list pgsql-general

From Tom Lane
Subject Re: DELETE ... USING LATERAL
Date
Msg-id 3998065.1633369719@sss.pgh.pa.us
Whole thread Raw
In response to DELETE ... USING LATERAL  (Nikhil Benesch <nikhil.benesch@gmail.com>)
Responses Re: DELETE ... USING LATERAL
List pgsql-general
Nikhil Benesch <nikhil.benesch@gmail.com> writes:
> Is it intentional that LATERAL elements in a USING clause of a DELETE
> statement can't reference the table declared in the FROM clause?

Hmm ... doesn't work for UPDATE, either.

My mental model of these things is that the target table is cross-joined
to the additional tables as though by a comma in FROM, so that what
you have here ought to work much like

select * from int_arrays, jsonb_array_each(int_array) _ (val)
where val::integer > 1;

Clearly it's not doing so as far as the LATERAL scoping is concerned.
Maybe we are adding the target table to the query after the additional
tables, not before them?

Not sure I'd call this a bug exactly, but maybe there's room for
improvement.  Or maybe there is an actual semantic issue that
I'm not seeing right away.

            regards, tom lane



pgsql-general by date:

Previous
From: Israel Brewster
Date:
Subject: Re: Growth planning
Next
From: Nikhil Benesch
Date:
Subject: Re: DELETE ... USING LATERAL