Failing backend on plpgsql function

From: Ondrej Palkovsky <xpalo03(at)vse(dot)cz>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Failing backend on plpgsql function
Date: 2001-05-19 11:11:47
Message-ID: Pine.LNX.4.20.0105191304100.4305-100000@ondra.debian.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I have the following function. When the function is executed and it gets
to the 'IF NOT FOUND', the backend gets restarted. I've read that the
exception handling is not perfect in Postgres but this seems to me
too hard behaviour for a badly written function.

CREATE FUNCTION attach_message(int8,int4,text[],date)
RETURNS int4
AS '
DECLARE
v_msgid ALIAS FOR $1;
v_folderid ALIAS FOR $2;
v_flags ALIAS FOR $3;
v_date ALIAS FOR $4;
v_newuid int4;
v_olduid int4;
BEGIN
SELECT into v_newuid nextuid FROM folder WHERE folderid=v_folderid FOR
UPDATE;
SELECT into v_olduid uid FROM msg_folder WHERE msgid=v_msgid AND
folderid=v_folderid;
IF NOT FOUND THEN
INSERT INTO msg_folder values
(v_msgid,v_folderid,v_newuid,v_internaldate,v_flags);
UPDATE folder SET nextuid=nextuid+1 WHERE folderid=v_folderid;
return v_newuid;
END IF;
return v_olduid;
end;
' LANGUAGE 'plpgsql';

--
As President I have to go vacuum my coin collection!

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-05-20 23:38:31 references fail over rows inserted via inherited tables
Previous Message Thomas Lockhart 2001-05-19 06:21:18 Re: Problems with avg on interval data type