Tom Lane 5c0f7cc544 Fix ancient memory leak in contrib/auto_explain.
The ExecutorEnd hook is invoked in a context that could be quite
long-lived, not the executor's own per-query context as I think
we were sort of assuming.  Thus, any cruft generated while producing
the EXPLAIN output could accumulate over multiple queries.  This can
result in spectacular leakage if log_nested_statements is on, and
even without that I'm surprised nobody complained before.

To fix, just switch into the executor's context so that anything we
allocate will be released when standard_ExecutorEnd frees the executor
state.  We might as well nuke the code's retail pfree of the explain
output string, too; that's laughably inadequate to the need.

Japin Li, per report from Jeff Janes.  This bug is old, so
back-patch to all supported branches.

Discussion: https://postgr.es/m/CAMkU=1wCVtbeRn0s9gt12KwQ7PLXovbpM8eg25SYocKW3BT4hg@mail.gmail.com
2021-02-02 13:49:08 -05:00
..
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00
2021-01-02 13:06:25 -05:00

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.