From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | emre(at)hasegeli(dot)com, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Failed assertion root->hasLateralRTEs on initsplan.c |
Date: | 2014-01-09 15:33:18 |
Message-ID: | 26448.1389281598@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Tue, Jan 7, 2014 at 1:15 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> The next question is if we should allow it with LATERAL. That would
>> essentially be treating "subscriber" as having implicitly appeared at the
>> start of the FROM list, which I guess is all right ... but does anyone
>> want to argue against it? I seem to recall some old discussions about
>> allowing the update target to be explicitly shown in FROM, in case you
>> wanted say to left join it against something else. Allowing this implicit
>> appearance might limit our options if we ever get around to trying to do
>> that. On the other hand, those discussions were a long time back, so
>> maybe it'll never happen anyway.
> I still think that would be a good thing to do, but I don't see a
> problem. The way I imagine it would work is: if the alias used for
> the update target also appears in the FROM clause, then we treat them
> as the same thing (after checking that they refer to the same table in
> both cases). Otherwise, we add the update target as an additional
> from-list item.
Um, well, no; this does make it harder. Consider
update t1 ... from lateral (select...) ss join (t1 left join ...)
You propose that we identify t1 in the sub-JOIN clause with the target
table. What if we have already resolved some outer references in
subselect ss as belonging to t1? Now we have an illegal reference
structure in the FROM clause, which is likely to lead to all sorts
of grief.
I'm sure we could forbid this combination of features, with some klugy
parse-time check or other, but it feels like we started from wrong
premises somewhere.
It might be better if we simply didn't allow lateral references to the
target table for now. We could introduce them in combination with the
other feature, in which case we could say that the lateral reference has
to be to an explicit reference to the target table in FROM, ie, if you
want a lateral reference to t1 in ss you must write
update t1 ... from t1 join lateral (select...) ss;
The fly in the ointment is that we've already shipped a couple of
9.3.x releases that allowed lateral references to the target table.
Even though this wasn't suggested or documented anywhere, somebody
might be relying on it already.
I'm inclined though to pull it back anyway, now that I've thought
about it some more.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Hannu Krosing | 2014-01-09 15:55:22 | Re: Standalone synchronous master |
Previous Message | Amit Langote | 2014-01-09 15:24:33 | Re: [BUG] Archive recovery failure on 9.3+. |