Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] WITH RECURSIVE patches 0818

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: david(at)fetter(dot)org
Cc: pgsql-patches(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] WITH RECURSIVE patches 0818
Date: 2008-08-23 02:33:13
Message-ID: 20080823.113313.35505109.t-ishii@sraoss.co.jp (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
> I think I may have found another bug:
> 
> WITH RECURSIVE t(i,j) AS (
>     VALUES (1,2)
> UNION ALL
>     SELECT t2.i, t.j
>     FROM (
>         SELECT 2 AS i
>     UNION ALL               /* Wrongly getting detected, I think */
>         SELECT 3 AS i
>     ) AS t2
>     JOIN
>         t
>         ON (t2.i = t.i)
> )
> SELECT * FROM t;
> ERROR:  attribute number 2 exceeds number of columns 1
> 
> Is there some way to ensure that in the case of WITH RECURSIVE, the
> query to the right of UNION ALL follows only the SQL:2008 rules about
> not having outer JOINs, etc. in it, but otherwise make it opaque to
> the error-checking code?
> 
> I know I didn't explain that well, but the above SQL should work and
> the error appears to stem from the parser's looking at the innermost
> UNION ALL instead of the outermost.

Here is new patches fixing the bug you pointed out (patches was
created by Yoshiyuki). Also I added your SQL to the regression test,
and now the patches is against CVS HEAD. For your convenience I also
include patches against the previous version.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

Attachment: recursive_query.patch.gz
Description: application/octet-stream (31.5 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2008-08-23 03:19:53
Subject: Re: Extending grant insert on tables to sequences
Previous:From: D'Arcy J.M. CainDate: 2008-08-22 20:46:19
Subject: Re: Feeding results back into select (was: proposal sql: labeled function params)

pgsql-patches by date

Next:From: Bruce MomjianDate: 2008-08-23 03:19:53
Subject: Re: Extending grant insert on tables to sequences
Previous:From: Bruce MomjianDate: 2008-08-22 18:47:14
Subject: Re: [HACKERS] Userset logging

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group