Re: top-level DML under CTEs

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

On 2010-09-17 4:48 AM, Hitoshi Harada wrote:
> 2010/9/15 Hitoshi Harada<umi(dot)tanuki(at)gmail(dot)com>:
>> Well, I didn't know it is allowed. That would look like the way to go.
>
> I made changes to the previous version, so that it avoids to resolve
> CTE name duplication.

This patch still doesn't address the issue Tom raised here:
http://archives.postgresql.org/pgsql-hackers/2010-09/msg00753.php

For WITH .. INSERT .. WITH .. SELECT ..; this patch works OK, but not so
much for VALUES:

=# CREATE RULE barrule AS ON UPDATE TO bar DO INSTEAD
-# WITH RECURSIVE t AS (SELECT -1)
-# INSERT INTO bar
-# WITH t AS (SELECT 1)
-# VALUES((SELECT * FROM t));
CREATE RULE

=# \d bar
Table "public.bar"
Column | Type | Modifiers
--------+---------+-----------
a | integer |
Rules:
barrule AS
ON UPDATE TO bar DO INSTEAD WITH RECURSIVE t AS (
SELECT 1
), t AS (
SELECT (-1)
)
INSERT INTO bar (a) WITH RECURSIVE t AS (
SELECT 1
), t AS (
SELECT (-1)
)

VALUES (( SELECT t."?column?"
FROM t))

Regards,
Marko Tiikkaja

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2010-09-23 00:32:41 Re: Standby registration
Previous Message Bruce Momjian 2010-09-22 23:47:12 Re: Git conversion status

Browse pgsql-rrreviewers by date

  From Date Subject
Next Message Hitoshi Harada 2010-09-23 06:12:51 Re: top-level DML under CTEs
Previous Message Pavel Stehule 2010-09-22 04:44:58 Re: wip: functions median and percentile