From: stormbyte@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6686: plpgsql Can't assign a variable with the output of a SQL Sentence which is not a SELECT
Date: Sun, 10 Jun 2012 16:58:31 +0000
Message-ID: <E1SdlTD-0005ck-M6@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 6686
Logged by: David Carlos Manuelda
Email address: stormbyte@gmail.com
PostgreSQL version: 9.1.4
Operating system: Gentoo Linux
Description:
I will provide a really simple example:
Suppose we have a table
CREATE TABLE test(i INTEGER);
Let's have a value:
INSERT INTO test(i) VALUES (1);
And a function
CREATE OR REPLACE FUNCTION foo() RETURNS INTEGER AS $$
DECLARE
dummy INTEGER;
BEGIN
dummy=(SELECT MAX(id) FROM test); -- VALID
dummy=(UPDATE test SET i=i+10 RETURNING i); -- NOT VALID.. WHY?
dummy=(INSERT INTO test(i) VALUES (10) RETURNING i); -- NOT VALID..
WHY?
RETURN dummy;
END;
$$
Language 'plpgsql' VOLATILE;
I get syntax error in both commented as not valid
I think that since all queries actually returns a expected value, and since
the function is not marked as stable, there is no reason for me to block
that from happen.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: stormbyte@gmail.com
Subject: Re: BUG #6686: plpgsql Can't assign a variable with the output of a SQL Sentence which is not a SELECT
In-Reply-To: <E1SdlTD-0005ck-M6@wrigleys.postgresql.org>
References: <E1SdlTD-0005ck-M6@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox