Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group