Add a way to get the current function's OID in pl/pgsql.
Tom Lane <tgl@sss.pgh.pa.us>
Add a way to get the current function's OID in pl/pgsql. Invent "GET DIAGNOSTICS oid_variable = PG_ROUTINE_OID". This is useful for avoiding the maintenance nuisances that come with embedding a function's name in its body, as one might do for logging purposes for example. Typically users would cast the result to regproc or regprocedure to get something human-readable, but we won't pre-judge whether that's appropriate. Pavel Stehule, reviewed by Kirk Wolak and myself Discussion: https://postgr.es/m/CAFj8pRA4zMd5pY-B89Gm64bDLRt-L+akOd34aD1j4PEstHHSVQ@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/plpgsql.sgml | modified | +5 −0 |
| src/pl/plpgsql/src/pl_exec.c | modified | +6 −0 |
| src/pl/plpgsql/src/pl_funcs.c | modified | +2 −0 |
| src/pl/plpgsql/src/pl_gram.y | modified | +6 −0 |
| src/pl/plpgsql/src/plpgsql.h | modified | +1 −0 |
| src/pl/plpgsql/src/pl_unreserved_kwlist.h | modified | +1 −0 |
| src/test/regress/expected/plpgsql.out | modified | +29 −2 |
| src/test/regress/sql/plpgsql.sql | modified | +27 −2 |
Documentation touched
Discussion
- possible proposal plpgsql GET DIAGNOSTICS oid = PG_ROUTINE_OID 14 messages · 2023-02-07 → 2023-04-04