Re: Better error message for a small problem with WITH RECURSIVE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Better error message for a small problem with WITH RECURSIVE
Date: 2008-10-08 12:50:40
Message-ID: 27619.1223470240@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> Yes, please. At least DB2 allows recursive queries without the
> "RECURSIVE" keyword, just "WITH" is enough. Without a hint, anyone
> migrating from such a system will spend hours looking at the query,
> seeing nothing wrong.

Huh, interesting ... so they're violating the letter of the spec
as to WITH name scope.

Anyway, here's what we do as of last night:

regression=# with q(x) as (select 1 union all select x+1 from q where x<10)
select * from q;
ERROR: relation "q" does not exist
LINE 1: with q(x) as (select 1 union all select x+1 from q where x<1...
^
DETAIL: There is a WITH item named "q", but it cannot be referenced from this part of the query.
HINT: Use WITH RECURSIVE, or re-order the WITH items to remove forward references.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Emmanuel Cecchet 2008-10-08 12:51:48 Building Postgres in Eclipse
Previous Message Tom Lane 2008-10-08 12:46:01 Re: Better error message for a small problem with WITH RECURSIVE