proposal 9.4 plpgsql: allows access to call stack from GET DIAGNOSTICS statement

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: proposal 9.4 plpgsql: allows access to call stack from GET DIAGNOSTICS statement
Date: 2013-02-02 09:23:21
Message-ID: CAFj8pRChsM1zshEFi0Sy6_VHQpWQ6gr0o6d3qvt9tGG9ovnNNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

I propose enhancing GET DIAGNOSTICS statement about new field
PG_CONTEXT. It is similar to GET STACKED DIAGNOSTICS'
PG_EXCEPTION_CONTEXT.

Motivation for this proposal is possibility to get call stack for
debugging without raising exception.

This code is based on cleaned code from Orafce, where is used four
years without any error reports.

CREATE OR REPLACE FUNCTION public."inner"(integer)
RETURNS integer
LANGUAGE plpgsql
AS $function$
declare _context text;
begin
get diagnostics _context = pg_context;
raise notice '***%***', _context;
return 2 * $1;
end;
$function$

postgres=# select outer_outer(10);
NOTICE: ***PL/pgSQL function "inner"(integer) line 4 at GET DIAGNOSTICS
PL/pgSQL function "outer"(integer) line 3 at RETURN
PL/pgSQL function outer_outer(integer) line 3 at RETURN***
CONTEXT: PL/pgSQL function "outer"(integer) line 3 at RETURN
PL/pgSQL function outer_outer(integer) line 3 at RETURN
outer_outer
─────────────
20
(1 row)

Ideas, comments?

Regards

Pavel Stehule

Attachment Content-Type Size
get_diagnostics_context_initial.patch application/octet-stream 8.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Norman 2013-02-02 10:05:40 Using indexes for partial index builds
Previous Message Jeff Janes 2013-02-02 04:48:48 Re: autovacuum not prioritising for-wraparound tables