Обсуждение: BUG #2946: server crashes when trying to catch exception in function

Поиск
Список
Период
Сортировка

BUG #2946: server crashes when trying to catch exception in function

От
""
Дата:
The following bug has been logged online:

Bug reference:      2946
Logged by:
Email address:      chris@icp.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.

Re: BUG #2946: server crashes when trying to catch exception in function

От
Tom Lane
Дата:
"" <chris@icp.pl> writes:
> PostgreSQL version: 8.2.0
> Operating system:   Red Hat Enterprise Linux ES release 4
> Description:        server crashes when trying to catch exception in
> function

I can't reproduce this using 8.2 branch tip.  I suspect it is at bottom
the same problem as bug #2817, in which case it's fixed in 8.2.1.

            regards, tom lane