pgsql: Add path column to pg_backend_memory_contexts view - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Add path column to pg_backend_memory_contexts view
Date
Msg-id E1sWolc-0015ev-Rn@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Add path column to pg_backend_memory_contexts view

"path" provides a reliable method of determining the parent/child
relationships between memory contexts.  Previously this could be done in
a non-reliable way by writing a recursive query and joining the "parent"
and "name" columns.  This wasn't reliable as the names were not unique,
which could result in joining to the wrong parent.

To make this reliable, "path" stores an array of numerical identifiers
starting with the identifier for TopLevelMemoryContext.  It contains an
element for each intermediate parent between that and the current context.

Incompatibility: Here we also adjust the "level" column to make it
1-based rather than 0-based.  A 1-based level provides a convenient way
to access elements in the "path" array. e.g. path[level] gives the
identifier for the current context.

Identifiers are not stable across multiple evaluations of the view.  In
an attempt to make these more stable for ad-hoc queries, the identifiers
are assigned breadth-first.  Contexts closer to TopLevelMemoryContext
are less likely to change between queries and during queries.

Author: Melih Mutlu <m.melihmutlu@gmail.com>
Discussion: https://postgr.es/m/CAGPVpCThLyOsj3e_gYEvLoHkr5w=tadDiN_=z2OwsK3VJppeBA@mail.gmail.com
Reviewed-by: Andres Freund, Stephen Frost, Atsushi Torikoshi,
Reviewed-by: Michael Paquier, Robert Haas, David Rowley

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/32d3ed8165f821f6994c95230a9a4b2ff0ce9f12

Modified Files
--------------
doc/src/sgml/system-views.sgml         |  40 +++++++-
src/backend/utils/adt/mcxtfuncs.c      | 180 +++++++++++++++++++++++++++------
src/include/catalog/catversion.h       |   2 +-
src/include/catalog/pg_proc.dat        |   6 +-
src/include/nodes/memnodes.h           |   4 +-
src/test/regress/expected/rules.out    |   3 +-
src/test/regress/expected/sysviews.out |  18 +++-
src/test/regress/sql/sysviews.sql      |  12 ++-
8 files changed, 225 insertions(+), 40 deletions(-)


pgsql-committers by date:

Previous
From: Thomas Munro
Date:
Subject: pgsql: ci: Pin MacPorts version to 2.9.3.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Add extern declarations for Bison global variables