| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Add custom extension states to QueryDesc |
| Date: | 2026-10-27 06:09:45 |
| Message-ID: | E1xLaNV-00000000wHN-0muS@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Add custom extension states to QueryDesc
Extensions sometimes need to carry private data from one executor hook
to another for a given query. ExecutorEnd() can run in a different
context than ExecutorStart(), so backend-wide variables cannot be used
for that.
This commit adds a way for loadable modules to attach private state to a
QueryDesc, modeled in the same fashion as what is already done for
PlannerGlobal, PlannerInfo, RelOptInfo and ExplainState.
GetQueryDescExtensionId() maps an extension name to a backend-local ID.
SetQueryDescExtensionState() and GetQueryDescExtensionState() store and
fetch an opaque pointer for that ID. The array of pointers is allocated
in the memory context of the QueryDesc, and is freed by FreeQueryDesc().
What the pointers refer to is owned by the extensions.
There are no users of this facility yet. A follow-up commit will make
use of it. Some potential use cases have been identified for
pg_stat_statements and auto_explain, where both need to be able to
co-exist in peace. Extensions living outside of core may also find a
use for it.
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAEcQ1bZrgwKsauC=03otebkLk77Zc_hYNjhTP3OUdpXs++u+BA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/e5d5d1ad1e3aa495609e19fa716dcea6a39db1bb
Modified Files
--------------
src/backend/tcop/pquery.c | 107 +++++++++++++++++++++++++++++++++++++++-
src/include/executor/execdesc.h | 9 ++++
2 files changed, 114 insertions(+), 2 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-10-27 06:27:58 | pgsql: pg_stat_statements: Fix toplevel tracking across nesting levels |
| Previous Message | Michael Paquier | 2026-10-27 04:56:38 | pgsql: Avoid truncated or zero-padded copies of replaced files in backu |