diff options
| author | Nathan Bossart <nathan@postgresql.org> | 2025-12-02 10:29:45 -0600 |
|---|---|---|
| committer | Nathan Bossart <nathan@postgresql.org> | 2025-12-02 10:29:45 -0600 |
| commit | f894acb24a12cf1f369a45af36c8f4049f9af571 (patch) | |
| tree | 74809e7b4b473e59fc68b6ced4a4157d658c37bd /src/test/modules | |
| parent | 758479213d574d6e2fbbdfee5328edef3d60da61 (diff) | |
Show size of DSAs and dshashes in pg_dsm_registry_allocations.
Presently, this view reports NULL for the size of DSAs and dshash
tables because 1) the current backend might not be attached to them
and 2) the registry doesn't save the pointers to the dsa_area or
dshash_table in local memory. Also, the view doesn't show
partially-initialized entries to avoid ambiguity, since those
entries would report a NULL size as well.
This commit introduces a function that looks up the size of a DSA
given its handle (transiently attaching to the control segment if
needed) and teaches pg_dsm_registry_allocations to use it to show
the size of successfully-initialized DSA and dshash entries.
Furthermore, the view now reports partially-initialized entries
with a NULL size.
Reviewed-by: Rahila Syed <rahilasyed90@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/aSeEDeznAsHR1_YF%40nathan
Diffstat (limited to 'src/test/modules')
| -rw-r--r-- | src/test/modules/test_dsm_registry/expected/test_dsm_registry.out | 12 | ||||
| -rw-r--r-- | src/test/modules/test_dsm_registry/sql/test_dsm_registry.sql | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/test/modules/test_dsm_registry/expected/test_dsm_registry.out b/src/test/modules/test_dsm_registry/expected/test_dsm_registry.out index ca8abbb377e..9128e171b1b 100644 --- a/src/test/modules/test_dsm_registry/expected/test_dsm_registry.out +++ b/src/test/modules/test_dsm_registry/expected/test_dsm_registry.out @@ -1,8 +1,8 @@ -SELECT name, type, size IS DISTINCT FROM 0 AS size +SELECT name, type, size > 0 AS size_ok FROM pg_dsm_registry_allocations WHERE name like 'test_dsm_registry%' ORDER BY name; - name | type | size -------+------+------ + name | type | size_ok +------+------+--------- (0 rows) CREATE EXTENSION test_dsm_registry; @@ -32,11 +32,11 @@ SELECT get_val_in_hash('test'); (1 row) \c -SELECT name, type, size IS DISTINCT FROM 0 AS size +SELECT name, type, size > 0 AS size_ok FROM pg_dsm_registry_allocations WHERE name like 'test_dsm_registry%' ORDER BY name; - name | type | size -------------------------+---------+------ + name | type | size_ok +------------------------+---------+--------- test_dsm_registry_dsa | area | t test_dsm_registry_dsm | segment | t test_dsm_registry_hash | hash | t diff --git a/src/test/modules/test_dsm_registry/sql/test_dsm_registry.sql b/src/test/modules/test_dsm_registry/sql/test_dsm_registry.sql index 965a3f1ebb6..a606e8872a1 100644 --- a/src/test/modules/test_dsm_registry/sql/test_dsm_registry.sql +++ b/src/test/modules/test_dsm_registry/sql/test_dsm_registry.sql @@ -1,4 +1,4 @@ -SELECT name, type, size IS DISTINCT FROM 0 AS size +SELECT name, type, size > 0 AS size_ok FROM pg_dsm_registry_allocations WHERE name like 'test_dsm_registry%' ORDER BY name; CREATE EXTENSION test_dsm_registry; @@ -8,6 +8,6 @@ SELECT set_val_in_hash('test', '1414'); SELECT get_val_in_shmem(); SELECT get_val_in_hash('test'); \c -SELECT name, type, size IS DISTINCT FROM 0 AS size +SELECT name, type, size > 0 AS size_ok FROM pg_dsm_registry_allocations WHERE name like 'test_dsm_registry%' ORDER BY name; |
