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

Re: Issue with ReRaise in PG

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Piyush Newe <piyush(dot)newe(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Issue with ReRaise in PG
Date: 2010-04-23 15:57:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Piyush Newe <piyush(dot)newe(at)enterprisedb(dot)com> writes:
> Please consider the following test case

> CREATE OR REPLACE FUNCTION raisetest() returns void AS $$
>    BEGIN
>        RAISE syntax_error;
>        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;
>        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

In response to


pgsql-hackers by date

Next:From: Terry BrownDate: 2010-04-23 15:58:40
Subject: psql: Add setting to make '+' on \d implicit
Previous:From: Tom LaneDate: 2010-04-23 15:49:24
Subject: Re: BETA

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