The following bug has been logged online:
Bug reference: 2946
Logged by:
Email address: chris(at)icp(dot)pl
PostgreSQL version: 8.2.0
Operating system: Red Hat Enterprise Linux ES release 4
Description: server crashes when trying to catch exception in
function
Details:
I have a function named test()
CREATE OR REPLACE FUNCTION test()
RETURNS integer AS
$BODY$
DECLARE
r INTEGER;
y INTEGER;
x INTEGER;
BEGIN
BEGIN
select into r 1;
y := r / 0;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
RETURN y;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
select * from test() causes a server crash
when I change
select into r 1; to r:=1;
all works fine.
there can be a
select into r id FROM some_table LIMIT 1;
or
WHEN division_by_zero THEN
and the server srashes too.
Chris.