Re: Access Error Details from PL/pgSQL

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: aasat <satriani(at)veranet(dot)pl>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Access Error Details from PL/pgSQL
Date: 2012-02-21 10:48:15
Message-ID: CAFj8pRDKGJ_Cp85Auh_rTdEL3SAi74URmXC7Mw4rkm6W4VGGkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

2012/2/21 aasat <satriani(at)veranet(dot)pl>:
> I have question. GET STACKED DIAGNOSTICS work only in exception block? is it
> posible to use it in separate function called in exception block?
>

Stacked diagnostick will be in 9.2 and it is allowed only in exception block.

Regards

Pavel Stehule

>
> EXCEPTION
>  WHEN others THEN
>    peform log_error();
> END;
>
> CREATE OR REPLACE FUNCTION log_error()
>  RETURNS boolean AS
> $BODY$
> declare
>    v_state   TEXT;
>    v_msg     TEXT;
>    v_detail  TEXT;
>    v_hint    TEXT;
>    v_context TEXT;
> begin
>
>  GET STACKED DIAGNOSTICS
>            v_state   = RETURNED_SQLSTATE,
>            v_msg     = MESSAGE_TEXT,
>            v_detail  = PG_EXCEPTION_DETAIL,
>            v_hint    = PG_EXCEPTION_HINT,
>            v_context = PG_EXCEPTION_CONTEXT;
>        raise notice E'Got exception:
>            state  : %
>            message: %
>            detail : %
>            hint   : %
>            context: %', v_state, v_msg, v_detail, v_hint, v_context;
> end;
> $BODY$
> LANGUAGE plpgsql VOLATILE;
>
>
>
> --
> View this message in context: http://postgresql.1045698.n5.nabble.com/Access-Error-Details-from-PL-pgSQL-tp5479926p5501584.html
> Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2012-02-21 11:15:07 Re: Speed dblink using alternate libpq tuple storage
Previous Message Marko Kreen 2012-02-21 10:44:35 Re: Speed dblink using alternate libpq tuple storage