Prev: [HACKERS] PGCon 2010 - registered yet?
Next: [HACKERS] psql: Add setting to make '+' on \d implicit
From: Tom Lane on 23 Apr 2010 11:57 Piyush Newe <piyush.newe(a)enterprisedb.com> writes: > Please consider the following test case > CREATE OR REPLACE FUNCTION raisetest() returns void AS $$ > BEGIN > BEGIN > RAISE syntax_error; > EXCEPTION > WHEN syntax_error THEN > BEGIN > raise notice 'exception thrown in inner block, reraising'; > RAISE; > EXCEPTION > WHEN OTHERS THEN > raise notice 'RIGHT - exception caught in innermost > block'; > END; > END; > EXCEPTION > WHEN OTHERS THEN > raise notice 'WRONG - exception caught in outer block'; > END; > $$ LANGUAGE plpgsql; > select raisetest(); > NOTICE: exception thrown in inner block, reraising > NOTICE: WRONG - exception caught in outer block RAISE without parameters is only allowed inside an exception handler, and what it throws is that handler's exception. In this example, it is within an exception handler ---- of the outer block. So it's allowed, but it re-throws from that handler. We could possibly make the above case throw an "improperly placed RAISE" error instead of doing what it does now, but I don't think there is a good argument for having it do what you propose. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
From: Heikki Linnakangas on 23 Apr 2010 12:06 Tom Lane wrote: > Piyush Newe <piyush.newe(a)enterprisedb.com> writes: >> Please consider the following test case > >> CREATE OR REPLACE FUNCTION raisetest() returns void AS $$ >> BEGIN >> BEGIN >> RAISE syntax_error; >> EXCEPTION >> WHEN syntax_error THEN >> BEGIN >> raise notice 'exception thrown in inner block, reraising'; >> RAISE; >> EXCEPTION >> WHEN OTHERS THEN >> raise notice 'RIGHT - exception caught in innermost >> block'; >> END; >> END; >> EXCEPTION >> WHEN OTHERS THEN >> raise notice 'WRONG - exception caught in outer block'; >> END; >> $$ LANGUAGE plpgsql; > >> select raisetest(); >> NOTICE: exception thrown in inner block, reraising >> NOTICE: WRONG - exception caught in outer block > > RAISE without parameters is only allowed inside an exception handler, > and what it throws is that handler's exception. In this example, it is > within an exception handler ---- of the outer block. So it's allowed, > but it re-throws from that handler. > > We could possibly make the above case throw an "improperly placed RAISE" > error instead of doing what it does now, but I don't think there is a > good argument for having it do what you propose. It's worth noting that RAISE without parameters was added to mimic the corresponding RAISE command on Oracle, and on Oracle Piyush's test case works as he says. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
|
Pages: 1 Prev: [HACKERS] PGCon 2010 - registered yet? Next: [HACKERS] psql: Add setting to make '+' on \d implicit |