Re: top-level DML under CTEs

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: top-level DML under CTEs
Date: 2010-09-15 04:38:17
Message-ID: AANLkTim-z+sd8Q3oxBg1COq7EpPi582hg=xeE_hnrKGC@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-rrreviewers

2010/9/15 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
>> 2010/9/15 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message SAKAMOTO Masahiko 2010-09-15 05:46:24 patch: SQL/MED(FDW) DDL
Previous Message Robert Haas 2010-09-15 03:22:58 Re: knngist - 0.8

Browse pgsql-rrreviewers by date

  From Date Subject
Next Message David Fetter 2010-09-16 06:07:09 Day 01/31
Previous Message Tom Lane 2010-09-15 03:22:44 Re: top-level DML under CTEs