Re: DELETE ... USING LATERAL

2021-10-07 Thread Nikhil Benesch
On Mon, Oct 4, 2021 at 3:21 PM Tom Lane wrote: > Not sure what to tell you about the state of the idea that the > target table could be re-specified in FROM/USING. I'm hesitant > to close the door on it permanently, because people do periodically > wish to be able to left-join the target to somet

Re: DELETE ... USING LATERAL

2021-10-04 Thread Tom Lane
Michael Lewis writes: > On Mon, Oct 4, 2021, 10:30 AM Nikhil Benesch > wrote: >> # delete from int_arrays using int_arrays; >> ERROR: table name "int_arrays" specified more than once >> Don't you need to use an alias for the table in the using clause? You could, but then you'd be creating a se

Re: DELETE ... USING LATERAL

2021-10-04 Thread Tom Lane
Nikhil Benesch writes: > On Mon, Oct 4, 2021 at 1:48 PM Tom Lane wrote: >> 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 [...] > Mine as well. > I just managed to dredge up some history here though. Turns out yo

Re: DELETE ... USING LATERAL

2021-10-04 Thread Michael Lewis
On Mon, Oct 4, 2021, 10:30 AM Nikhil Benesch wrote: > you can't reuse the FROM table name in the USING clause: > > # delete from int_arrays using int_arrays; > ERROR: table name "int_arrays" specified more than once > Don't you need to use an alias for the table in the using clause?

Re: DELETE ... USING LATERAL

2021-10-04 Thread Nikhil Benesch
On Mon, Oct 4, 2021 at 1:48 PM Tom Lane wrote: > 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 [...] Mine as well. I just managed to dredge up some history here though. Turns out you explicitly disabled this featu

Re: DELETE ... USING LATERAL

2021-10-04 Thread Tom Lane
Nikhil Benesch 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 ta