patch: enhanced get diagnostics statement 2 - Mailing list pgsql-hackers

From Pavel Stehule
Subject patch: enhanced get diagnostics statement 2
Date
Msg-id BANLkTinyV_PAMBP7wpNJ_0KUP5S6OcP8WQ@mail.gmail.com
Whole thread Raw
Responses Re: patch: enhanced get diagnostics statement 2
List pgsql-hackers
Hello

This patch enhances a GET DIAGNOSTICS statement functionality. It adds
a possibility of access to exception's data. These data are stored on
stack when exception's handler is activated - and these data are
access-able everywhere inside handler. It has a different behave (the
content is immutable inside handler) and therefore it has modified
syntax (use keyword STACKED). This implementation is in conformance
with ANSI SQL and SQL/PSM  - implemented two standard fields -
RETURNED_SQLSTATE and MESSAGE_TEXT and three PostgreSQL specific
fields - PG_EXCEPTION_DETAIL, PG_EXCEPTION_HINT and
PG_EXCEPTION_CONTEXT.

The GET STACKED DIAGNOSTICS statement is allowed only inside
exception's handler. When it is used outside handler, then diagnostics
exception 0Z002 is raised.

This patch has no impact on performance. It is just interface to
existing stacked 'edata' structure. This patch doesn't change a
current behave of GET DIAGNOSTICS statement.

CREATE OR REPLACE FUNCTION public.stacked_diagnostics_test02()
 RETURNS void
 LANGUAGE plpgsql
AS $function$
declare _detail text; _hint text; _message text;
begin
  perform ...
exception when others then
  get stacked diagnostics
        _message = message_text,
        _detail = pg_exception_detail,
        _hint = pg_exception_hint;
  raise notice 'message: %, detail: %, hint: %', _message, _detail, _hint;
end;
$function$

All regress tests was passed.

Regards

Pavel Stehule

Attachment

pgsql-hackers by date:

Previous
From: Pavel Golub
Date:
Subject: Re: PQdeleteTuple function in libpq
Next
From: Pavel Golub
Date:
Subject: Re: PQdeleteTuple function in libpq