Add some new hooks so extensions can add details to EXPLAIN.
authorRobert Haas <rhaas@postgresql.org>
Tue, 18 Mar 2025 13:09:34 +0000 (09:09 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 18 Mar 2025 13:28:01 +0000 (09:28 -0400)
commit4fd02bf7cf94c3b6807dcf0b13e076de94f1e4ff
tree56c34e32e6b83c07fc41fa11cc3a08ca403f791e
parentf76892c9ff7e5f2dcb4073310d1a5273f47d1d9d
Add some new hooks so extensions can add details to EXPLAIN.

Specifically, add a per-node hook that is called after the per-node
information has been displayed but before we display children, and a
per-query hook that is called after existing query-level information
is printed. This assumes that extension-added information should
always go at the end rather than the beginning or the middle, but
that seems like an acceptable limitation for simplicity. It also
assumes that extensions will only want to add information, not remove
or reformat existing details; those also seem like acceptable
restrictions, at least for now.

If multiple EXPLAIN extensions are used, the order in which any
additional details are printed is likely to depend on the order in
which the modules are loaded. That seems OK, since the user may
have opinions about the order in which output should appear, and the
extension author can't really know whether their stuff is more or
less important to a particular user than some other extension.

Discussion: http://postgr.es/m/CA+TgmoYSzg58hPuBmei46o8D3SKX+SZoO4K_aGQGwiRzvRApLg@mail.gmail.com
Reviewed-by: Srinath Reddy <srinath2133@gmail.com>
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
src/backend/commands/explain.c
src/include/commands/explain.h