BUG #3596: "insert ... returning *" not usable as last statement in a function... - Mailing list pgsql-bugs

From Ciprian Dorin Craciun
Subject BUG #3596: "insert ... returning *" not usable as last statement in a function...
Date
Msg-id 200709031713.l83HDekd055443@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3596
Logged by:          Ciprian Dorin Craciun
Email address:      ciprian.craciun@gmail.com
PostgreSQL version: 8.2.4
Operating system:   Debian Etch (4.0)
Description:        "insert ... returning *" not usable as last statement in
a function...
Details:

I think the best explanation is the example just above...

The idea is that in 8.2 insert statement was modified by adding an returning
option, that modifies insert to behave also as a select statement by
returning all the rows inserted. But unfortunately this option can not be
used inside functions that return something as a last statement...

create table table1 ( field int );

create function function1 ( int ) returns table1 as $$
    insert into table1 values ($1) returning *;
$$ language sql;

pgsql-bugs by date:

Previous
From: "Heikki Linnakangas"
Date:
Subject: Re: BUG #3595: Segmentation fault with a simple select query
Next
From: Ben Kim
Date:
Subject: Re: BUG #3591: autovacuum crash