Re: BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction. - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction.
Date
Msg-id CAFj8pRDHHcLFhaw+3-sdpg5g4tAe1726ghVV6Vfm+RkNm6=+LA@mail.gmail.com
Whole thread Raw
In response to BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction.  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction.
List pgsql-bugs
Hi

It is not a bug. GET DIAGNOSTICS PG_CONTEXT returns error context

Error context is generated by the function plpgsql_exec_error_callback. This function uses estate->func->fn_signature string
and this string is generated by function format_procedure. This function hides schema when function is visible from current search_path

(2025-01-06 17:01:05) postgres=# create schema test;
CREATE SCHEMA
(2025-01-06 17:01:26) postgres=# create function public.fx(a int) returns void as $$ begin end $$ language plpgsql;
CREATE FUNCTION
(2025-01-06 17:01:47) postgres=# create function test.fx(a int) returns void as $$ begin end $$ language plpgsql;
CREATE FUNCTION

(2025-01-06 17:02:16) postgres=# select 'test.fx'::regproc;
┌─────────┐
│ regproc │
╞═════════╡
│ test.fx │
└─────────┘
(1 row)

(2025-01-06 17:02:22) postgres=# select 'test.fx'::regproc::regprocedure;
┌──────────────────┐
│   regprocedure   │
╞══════════════════╡
│ test.fx(integer) │
└──────────────────┘
(1 row)

(2025-01-06 17:02:27) postgres=# select 'public.fx'::regproc::regprocedure;
┌──────────────┐
│ regprocedure │
╞══════════════╡
│ fx(integer)  │
└──────────────┘
(1 row)

This is mostly used for displaying functions in error messages.

Unfortunately it is not possible to change it without a compatibility break. This was designed more than 20 years ago.

If you want to track function calls exactly you need own extension based on pl debug api like https://github.com/EnterpriseDB/pldebugger

Regards

Pavel




pgsql-bugs by date:

Previous
From: Richard Guo
Date:
Subject: Re: BUG #18764: server closed the connection unexpectedly
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #18765: Inconsistent behaviour and errors with LIKE