Re: [sqlsmith] Failed to generate plan on lateral subqueries

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
Cc: David Fetter <david(at)fetter(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [sqlsmith] Failed to generate plan on lateral subqueries
Date: 2015-12-10 18:37:34
Message-ID: 1463.1449772654@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andreas Seltenreich <seltenreich(at)gmx(dot)de> writes:
> Tom Lane writes:
>> [2. transitive-lateral-fixes-1.patch]

> I was about to write that sqlsmith likes the patch, but after more than
> 10^8 ok queries the attached ones were generated.

Ah-hah --- the new check I added in join_is_legal understood about
chains of LATERAL references, but it forgot that we could also have chains
of outer-join ordering constraints. When we're looking to see if joining
on the basis of a LATERAL reference would break some later outer join, we
have to look at outer joins to the outer joins' inner relations, too.

Fixed in the attached. I also stuck all of join_is_legal's
lateral-related checks inside an "if (root->hasLateralRTEs)" block,
which will save some time in typical queries with no LATERAL. That
makes that section of the patch a bit bigger than before, but it's
mostly just reindentation.

Many thanks for the work you've done with this tool! Who knows how
long it would've taken us to find these problems otherwise ...

regards, tom lane

Attachment Content-Type Size
transitive-lateral-fixes-2.patch text/x-diff 42.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2015-12-10 18:45:15 Re: proposal: PL/Pythonu - function ereport
Previous Message Pavel Stehule 2015-12-10 18:29:52 Re: [patch] Proposal for \rotate in psql