X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A1383A4AC7 for ; Fri, 19 Nov 2004 11:52:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68310-05 for ; Fri, 19 Nov 2004 11:52:32 +0000 (GMT) Received: from web13924.mail.yahoo.com (web13924.mail.yahoo.com [66.163.176.49]) by svr1.postgresql.org (Postfix) with SMTP id 03E2F3A4AC5 for ; Fri, 19 Nov 2004 11:52:31 +0000 (GMT) Received: (qmail 27650 invoked by uid 60001); 19 Nov 2004 11:52:31 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=4Bf9XoMZ2XbZ06WUonBF+FKWZTBI9rAYzvPjUDBPHfI3v3DnMssurQFYZD8GmZEDU3mLWnl64iQwKcz5Yu7BCmJh5dTlJ3RmTW49bS8G4kRNsMQ0bqcJzwy/dIfNlopYLAC4Xnid3FHq6ZvM++EWbgaQ6oCY6PYNzzKLxw6Txhw= ; Message-ID: <20041119115231.27648.qmail@web13924.mail.yahoo.com> Received: from [80.67.100.162] by web13924.mail.yahoo.com via HTTP; Fri, 19 Nov 2004 03:52:31 PST Date: Fri, 19 Nov 2004 03:52:31 -0800 (PST) From: "Riccardo G. Facchini" Reply-To: abief_ag_-postgresql@yahoo.com Subject: transactions in functions, possible bug or what I'm doing wrong? To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/191 X-Sequence-Number: 19510 Hi All, PostgreSQL 7.4.5 assume this script: --- create table test_table ( id serial, test_value text ) without oids; insert into test_table (test_value) values ('A'); insert into test_table (test_value) values ('B'); insert into test_table (test_value) values ('C'); insert into test_table (test_value) values ('D'); CREATE OR REPLACE FUNCTION test_with_transaction() RETURNS text AS 'declare my_test_record record; declare my_return_value text; begin my_return_value := ''''; start transaction; for my_test_record in select * from test_table loop my_return_value := my_return_value || my_test_record.test_value; end loop; return my_return_value; commit; end;' LANGUAGE 'plpgsql' VOLATILE; CREATE OR REPLACE FUNCTION test_without_transaction() RETURNS text AS 'declare my_test_record record; declare my_return_value text; begin my_return_value := ''''; for my_test_record in select * from test_table loop my_return_value := my_return_value || my_test_record.test_value; end loop; return my_return_value; end;' LANGUAGE 'plpgsql' VOLATILE; --- Why does select test_without_transaction(); return this info: "ABCD" (as should be) and select test_with_transaction(); returns this error? ERROR: SPI_prepare() failed on "start transaction" CONTEXT: PL/pgSQL function "test_with_transaction" line 6 at SQL statement I've been investigating the matter in the doc I have, but to no avail. google was not helpful either. any suggestion? is this a bug? or the bug resides in my head? regards, Riccardo