From: | Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | [PATCH] GET DIAGNOSTICS FUNCTION_NAME |
Date: | 2017-12-28 09:04:22 |
Message-ID: | 20171228180422.444845d7.nagata@sraoss.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
Attached is a patch to implement a feature to get the current function
name by GET DIAGNOSTICS in PL/pgSQL function.
Currentyly, we can get call stack by GET DIAGNOSTICS PG_CONTEXT, but
we cannot get the function name directly. One of our clients wanted
this feature for debugging, and this was realized by creating a
function that extracts the function name string from call stack.
However, the overhead of function calls was not small, and it
caused performance regression.
I found that there are other needs for this feature[1], so I have
implemented this.
Example:
postgres=# CREATE FUNCTION test() RETURNS void
LANGUAGE plpgsql AS $$
DECLARE t text;
BEGIN
GET DIAGNOSTICS t = FUNCTION_NAME;
RAISE INFO 'function name: %', t;
END;
$$;
CREATE FUNCTION
postgres=# select test();
INFO: function name: test()
test
------
(1 row)
Regards,
--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Attachment | Content-Type | Size |
---|---|---|
getdiag_function.patch | text/x-diff | 4.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2017-12-28 11:26:23 | Re: WIP: a way forward on bootstrap data |
Previous Message | Kyotaro HORIGUCHI | 2017-12-28 08:31:47 | TAP test module - PostgresClient |