Re: top-level DML under CTEs

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-14 19:51:56
Message-ID: 11301.1284493916@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-rrreviewers

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.

It would probably be all right to combine the cases internally, at the
rewriter or planner stage. It's not okay to do it in the parser, not
even after doing parse analysis of the individual CTEs, because then it
would be impossible for ruleutils.c to reverse-list the query correctly.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2010-09-14 20:28:33 Re: top-level DML under CTEs
Previous Message Heikki Linnakangas 2010-09-14 19:48:50 Re: Serializable Snapshot Isolation

Browse pgsql-rrreviewers by date

  From Date Subject
Next Message Marko Tiikkaja 2010-09-14 20:28:33 Re: top-level DML under CTEs
Previous Message Hitoshi Harada 2010-09-14 18:59:43 Re: top-level DML under CTEs