Re: top-level DML under CTEs - Mailing list pgsql-hackers

From Hitoshi Harada
Subject Re: top-level DML under CTEs
Date
Msg-id AANLkTim-z+sd8Q3oxBg1COq7EpPi582hg=xeE_hnrKGC@mail.gmail.com
Whole thread Raw
In response to Re: top-level DML under CTEs  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: top-level DML under CTEs
List pgsql-hackers
2010/9/15 Tom Lane <tgl@sss.pgh.pa.us>:
> Hitoshi Harada <umi.tanuki@gmail.com> writes:
>> 2010/9/15 Tom Lane <tgl@sss.pgh.pa.us>:
>>> Why is it so difficult to do this correctly?
>
>> Because INSERT INTO ... (SELECT|VALUES) is already a collection of
>> kludge (as comments say). It was possible to parse the two WITHs
>> separately, but it results in ambiguous naming issue;
>> parseWithClause() asserts there's only one WITH clause in the Stmt and
>> detects duplicated CTE name in it.
>
> Well, I would think that the no-duplication rule applies to each WITH
> list separately, not both together.  If you do something like
>
> with t1 as (select * from foo)
>  select * from
>    (with t2 as (select * from foo)
>       select * from t1, t2) ss;
>

Well, I didn't know it is allowed. That would look like the way to go.

Regards,



--
Hitoshi Harada


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: top-level DML under CTEs
Next
From: SAKAMOTO Masahiko
Date:
Subject: patch: SQL/MED(FDW) DDL