error in simple sql function breaks connection

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: error in simple sql function breaks connection
Date: 2004-09-06 16:14:27
Message-ID: Pine.LNX.4.61.0409061806480.2431@sablons.cri.ensmp.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Dear bug-hunters,

With a nearly current cvs head version I have the following:

psql> SELECT VERSION();
...
PostgreSQL 8.0.0beta2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
3.3.4 (Debian 1:3.3.4-6sarge1)

psql> CREATE TABLE foo(id SERIAL PRIMARY KEY, data TEXT);

psql> CREATE FUNCTION add_data(TEXT) RETURNS boolean LANGUAGE SQL AS
'BEGIN; INSERT INTO foo(data) VALUES($1); COMMIT; SELECT TRUE;';

psql> SELECT add_data('hello');
FATAL: EndTransactionBlock: unexpected state BEGIN
CONTEXT: SQL function "add_data" statement 3
server closed the connection unexpectedly

in log:
Sep 6 18:09:23 sablons postgres[21271]: [4-1] FATAL: EndTransactionBlock: unexpected state BEGIN
Sep 6 18:09:23 sablons postgres[21271]: [4-2] CONTEXT: SQL function "add_data" statement 3
Sep 6 18:09:23 sablons postgres[21271]: [5-1] LOG: disconnection: session time: 0:02:49.02 user=coelho database=coelho host=[local] port=
Sep 6 18:09:23 sablons postgres[21271]: [5-2] CONTEXT: SQL function "add_data" statement 3

Although the "BEGIN" might not be welcome (well, it was ok, possibly
ignored, with version 7.4), shuting down the connection does not seem to
be the appropriate action anyway.

Have a nice day,

--
Fabien.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-09-06 16:29:10 Re: BUG #1239: Stale postmaster.pid prevents server start
Previous Message Roland Walter 2004-09-06 16:09:39 Re: BUG #1240: memory leak in JDBC driver build 215