Re: subselect bug (was Re: [GENERAL] DBLink: interesting issue) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: subselect bug (was Re: [GENERAL] DBLink: interesting issue)
Date
Msg-id 2202.1032884231@sss.pgh.pa.us
Whole thread Raw
In response to subselect bug (was Re: [GENERAL] DBLink: interesting issue)  (Joe Conway <mail@joeconway.com>)
List pgsql-hackers
Joe Conway <mail@joeconway.com> writes:
> replica=# create table foo(f1 int);
> CREATE TABLE
> replica=# SELECT * FROM foo t WHERE NOT EXISTS (SELECT remoteid FROM (SELECT
> f1 as remoteid FROM foo WHERE f1 = t.f1) AS t1);
> server closed the connection unexpectedly

Ick.

> I'm just starting to dig in to this, but was hoping for any thoughts or
> guidance I can get.

I can look at this, unless you really want to solve it yourself ...

> p.s. Below is a backtrace:

The debug output:

TRAP: FailedAssertion("!(var->varlevelsup > 0 && var->varlevelsup < PlannerQueryLevel)", File: "subselect.c", Line:
81)

suggests that the problem is with variable depth --- I'm guessing that
we're not adjusting varlevelsup correctly at some step of the planning
process.  Offhand I'd expect the innermost "select" to be pulled up into
the parent select (the argument of EXISTS) and probably something is
going wrong with that.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Ross J. Reedstrom"
Date:
Subject: Re: Web site
Next
From: Roberto Fichera
Date:
Subject: Re: Problem on PG7.2.2