| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> | 
| 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 03:22:44 | 
| Message-ID: | 24626.1284520964@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers pgsql-rrreviewers | 
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;
there's no expectation that the WITH clauses can't both define the same
name.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2010-09-15 03:22:58 | Re: knngist - 0.8 | 
| Previous Message | Tom Lane | 2010-09-15 02:47:10 | Re: elog during holding a spinlock is safe? | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hitoshi Harada | 2010-09-15 04:38:17 | Re: top-level DML under CTEs | 
| Previous Message | Hitoshi Harada | 2010-09-15 01:15:12 | Re: top-level DML under CTEs |