| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | proposal: parentid and naturalid for plpgsql nodes |
| Date: | 2026-01-22 08:26:28 |
| Message-ID: | CAFj8pRDwT=5UV9cKzCGxpo9ksYghcTm_h+8t_cWebaJDrN0vww@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi
I propose two enhancing of PLpgSQL_stmt structure
1. parentid
This is the id (stmtid) of the near outer statement. Why do I need it?
Inside the plpgsql_check profiler I need to handle exceptions. Exceptions
are not supported by the plpgsql debug API, so I need to hold a stack of
executed statements. When any statements start, I need to check this stack
and sometimes (after a handled exception) I need to reduce this stack until
I find a statement that has the same parenid as the parentid of the current
statement.
Currently I hold an array with parentid outside, but it is not practical
and increases the complexity of plpgsql_check.
2. naturalid
stmtid is assigned by the plpgsql parser. It is unique, but has a little
bit of a messy order, and when something like a statement id is displayed
in some reports, then it is confusing for users. I propose extra id (that
is unique too), but with order based on searching statements tree
example
BEGIN --> stmtid = 3
PERFORM --> stmtid = 1
PERFORM --> stmtid = 2
BEGIN --> naturalid = 1
PERFORM --> naturalid = 2
PERFORM --> naturalid = 3
Maybe the ordering of stmtid can be changed, and then naturalid can be
useless.
Proposed change can reduce complexity of plpgsql_check, but I believe it
can help with other exceptions that use pl debug api.
Comments, notes?
Regards
Pavel
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonin Houska | 2026-01-22 08:37:40 | Re: Adding REPACK [concurrently] |
| Previous Message | Chao Li | 2026-01-22 08:22:24 | Re: Fix accidentally cast away qualifiers |