[PATCH] GET DIAGNOSTICS FUNCTION_NAME

Поиск
Список
Период
Сортировка
От Yugo Nagata
Тема [PATCH] GET DIAGNOSTICS FUNCTION_NAME
Дата
Msg-id 20171228180422.444845d7.nagata@sraoss.co.jp
обсуждение исходный текст
Ответы Re: [PATCH] GET DIAGNOSTICS FUNCTION_NAME  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: [PATCH] GET DIAGNOSTICS FUNCTION_NAME  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: [PATCH] GET DIAGNOSTICS FUNCTION_NAME  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.

[1]
https://stackoverflow.com/questions/12611596/getting-name-of-the-current-function-inside-of-the-function-with-plpgsql

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@sraoss.co.jp>

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro HORIGUCHI
Дата:
Сообщение: TAP test module - PostgresClient
Следующее
От: John Naylor
Дата:
Сообщение: Re: WIP: a way forward on bootstrap data