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

Re: top-level DML under CTEs

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: top-level DML under CTEs
Date: 2010-09-14 22:49:29
Message-ID: AANLkTikA=XOsGmV+Bq-TDdMj-OpxPSpCVk0GV6_GNH5G@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-rrreviewers
On Tue, Sep 14, 2010 at 4:28 PM, Marko Tiikkaja
<marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> wrote:
> On 2010-09-14 10:51 PM, Tom Lane wrote:
>>
>> Hitoshi Harada<umi(dot)tanuki(at)gmail(dot)com>  writes:
>>>
>>> 2010/9/15 Marko Tiikkaja<marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>:
>>>>
>>>> In the email you referred to, Tom was concerned about the case where
>>>> these
>>>> WITH lists have different RECURSIVE declarations.  This patch makes both
>>>> RECURSIVE if either of them is.  I can think of cases where that might
>>>> lead
>>>> to surprising behaviour, but the chances of any of those happening in
>>>> real
>>>> life seem pretty slim.
>>
>>> Does that cause surprising behavior?
>>
>> My recollection is that whether a CTE is marked RECURSIVE or not affects
>> its scope of visibility, so that confusing the two cases can result in
>> flat-out incorrect parser behavior.
>
> The worst I can think of is:
>
> CREATE TABLE foo(a int);
>
> WITH t AS (SELECT * FROM foo)
> INSERT INTO bar
> WITH RECURSIVE foo (SELECT 1 AS a)
> SELECT * FROM t;
>
> t will actually be populated with the results of the CTE, not the table foo.

Unless I'm confused, that seems pretty clearly wrong.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2010-09-14 23:02:25
Subject: Re: top-level DML under CTEs
Previous:From: Bernd HelmleDate: 2010-09-14 22:41:19
Subject: Re: ALTER TABLE...ALTER COLUMN vs inheritance

pgsql-rrreviewers by date

Next:From: Tom LaneDate: 2010-09-14 23:02:25
Subject: Re: top-level DML under CTEs
Previous:From: Marko TiikkajaDate: 2010-09-14 20:28:33
Subject: Re: top-level DML under CTEs

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