BUG #4710: Bug with sql functions, when using INSERT.. RETURNING .. statment

Started by Oleg Serovabout 17 years ago2 messagesbugs
Jump to latest
#1Oleg Serov
serovov@gmail.com

The following bug has been logged online:

Bug reference: 4710
Logged by: Oleg
Email address: serovOv@gmail.com
PostgreSQL version: last stable
Operating system: CentOS
Description: Bug with sql functions, when using INSERT.. RETURNING ..
statment
Details:

Example:

CREATE TABLE test (id BIGINT);
CREATE OR REPLACE FUNCTION test(in_row test) RETURNS bigint AS
$body$
INSERT INTO test (SELECT $1.*) RETURNING id;
$body$
LANGUAGE 'sql';

WILL THROW:

ERROR: return type mismatch in function declared to return bigint
DETAIL: Function's final statement must be a SELECT.
CONTEXT: SQL function "test"

It is okey ?

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Oleg Serov (#1)
Re: BUG #4710: Bug with sql functions, when using INSERT.. RETURNING .. statment

"Oleg" <serovOv@gmail.com> writes:

CREATE TABLE test (id BIGINT);
CREATE OR REPLACE FUNCTION test(in_row test) RETURNS bigint AS
$body$
INSERT INTO test (SELECT $1.*) RETURNING id;
$body$
LANGUAGE 'sql';

WILL THROW:

ERROR: return type mismatch in function declared to return bigint

This is improved for 8.4.

http://archives.postgresql.org/pgsql-committers/2008-10/msg00295.php

regards, tom lane