Re: recursive query crash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Postgres <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: recursive query crash
Date: 2008-10-11 23:03:48
Message-ID: 29499.1223766228@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> This crashes, apparently it tries to look up the result type on a NULL
> planstate:
> with recursive z(i) as (
> select *
> from t
> union all
> (with a(i) as (select * from z)
> select * from a)
> )
> select * from z;

Hmm ... I tried to fix this by changing the order in which the subplans
get initialized, but that just moves the crash to the other subplan.
The problem really is that what we have here is two mutually recursive
WITH entries, and neither one can be successfully initialized in the
executor before the other one is. I begin to see why the SQL spec
forbids this syntax altogether.

I'm inclined to prevent this case by forbidding recursive references
inside nested WITH clauses. Thoughts?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vladimir Sitnikov 2008-10-11 23:24:39 Buffer pool statistics in Explain Analyze
Previous Message Magnus Hagander 2008-10-11 21:42:18 Re: libpq ssl -> clear fallback looses error messages