Re: [GENERAL] Using results from DELETE ... RETURNING

From: David Fetter <david(at)fetter(dot)org>
To: Petr Jelinek <pjmodos(at)pjmodos(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] Using results from DELETE ... RETURNING
Date: 2009-06-14 22:24:19
Message-ID: 20090614222419.GG15314@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sun, Jun 14, 2009 at 05:59:58PM +0200, Petr Jelinek wrote:
> David Fetter wrote:
>> I was discussing this with Andrew Gierth in IRC, who thought that
>> putting RETURNING inside the WITH clause would be relatively easy, at
>> least for the parser and planner. For the executor, he suggested that
>> one approach might be to make INSERT, UPDATE and DELETE into their own
>> nodes.
>
> David asked me to post his (and mine) experimental work in progress
> patch for this here. The patch in the current state does not work. It
> dies in executor on:
> ERROR: attribute 1 has wrong type
> DETAIL: Table has type tid, but query expects integer.
> Since I know nothing about postgres' executor I am only guessing it
> thinks the query is SELECT instead of DELETE RETURNING.
> Also I think those query->commandType == CMD_SELECT ? query->targetList
> : query->returningList in several places might not be the right way to
> go.

I went another way in the attached patch, and thanks :)

> Anyway it's beginning and maybe somebody who knows what he is doing
> could help or continue the work.

This patch fails regression tests and hangs or crashes when attempting
to do a writeable CTE.

Any help getting it into better shape would be greatly appreciated :)

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment Content-Type Size
cte_delete_returning.diff text/plain 8.6 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-06-14 22:36:33 Re: running pg_dump from python
Previous Message Garry Saddington 2009-06-14 21:50:32 Re: running pg_dump from python

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-06-15 01:11:41 Re: machine-readable explain output
Previous Message Erik Rijkers 2009-06-14 20:31:48 8.4 release notes "Recursive Joins"