mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Introduce pg_dsm_registry_allocations view.
This commit adds a new system view that provides information about entries in the dynamic shared memory (DSM) registry. Specifically, it returns the name, type, and size of each entry. Note that since we cannot discover the size of dynamic shared memory areas (DSAs) and hash tables backed by DSAs (dshashes) without first attaching to them, the size column is left as NULL for those. Bumps catversion. Author: Florents Tselai <florents.tselai@gmail.com> Reviewed-by: Sungwoo Chang <swchangdev@gmail.com> Discussion: https://postgr.es/m/4D445D3E-81C5-4135-95BB-D414204A0AB4%40gmail.com
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
SELECT name, type, size IS DISTINCT FROM 0 AS size
|
||||
FROM pg_dsm_registry_allocations
|
||||
WHERE name like 'test_dsm_registry%' ORDER BY name;
|
||||
name | type | size
|
||||
------+------+------
|
||||
(0 rows)
|
||||
|
||||
CREATE EXTENSION test_dsm_registry;
|
||||
SELECT set_val_in_shmem(1236);
|
||||
set_val_in_shmem
|
||||
@@ -24,3 +31,14 @@ SELECT get_val_in_hash('test');
|
||||
1414
|
||||
(1 row)
|
||||
|
||||
\c
|
||||
SELECT name, type, size IS DISTINCT FROM 0 AS size
|
||||
FROM pg_dsm_registry_allocations
|
||||
WHERE name like 'test_dsm_registry%' ORDER BY name;
|
||||
name | type | size
|
||||
------------------------+---------+------
|
||||
test_dsm_registry_dsa | area | t
|
||||
test_dsm_registry_dsm | segment | t
|
||||
test_dsm_registry_hash | hash | t
|
||||
(3 rows)
|
||||
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
SELECT name, type, size IS DISTINCT FROM 0 AS size
|
||||
FROM pg_dsm_registry_allocations
|
||||
WHERE name like 'test_dsm_registry%' ORDER BY name;
|
||||
CREATE EXTENSION test_dsm_registry;
|
||||
SELECT set_val_in_shmem(1236);
|
||||
SELECT set_val_in_hash('test', '1414');
|
||||
\c
|
||||
SELECT get_val_in_shmem();
|
||||
SELECT get_val_in_hash('test');
|
||||
\c
|
||||
SELECT name, type, size IS DISTINCT FROM 0 AS size
|
||||
FROM pg_dsm_registry_allocations
|
||||
WHERE name like 'test_dsm_registry%' ORDER BY name;
|
||||
|
||||
@@ -3220,7 +3220,8 @@ REVOKE MAINTAIN ON lock_table FROM regress_locktable_user;
|
||||
DROP TABLE lock_table;
|
||||
DROP USER regress_locktable_user;
|
||||
-- test to check privileges of system views pg_shmem_allocations,
|
||||
-- pg_shmem_allocations_numa and pg_backend_memory_contexts.
|
||||
-- pg_shmem_allocations_numa, pg_dsm_registry_allocations, and
|
||||
-- pg_backend_memory_contexts.
|
||||
-- switch to superuser
|
||||
\c -
|
||||
CREATE ROLE regress_readallstats;
|
||||
@@ -3248,6 +3249,12 @@ SELECT has_table_privilege('regress_readallstats','pg_shmem_allocations_numa','S
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT has_table_privilege('regress_readallstats','pg_dsm_registry_allocations','SELECT'); -- no
|
||||
has_table_privilege
|
||||
---------------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
GRANT pg_read_all_stats TO regress_readallstats;
|
||||
SELECT has_table_privilege('regress_readallstats','pg_aios','SELECT'); -- yes
|
||||
has_table_privilege
|
||||
@@ -3273,6 +3280,12 @@ SELECT has_table_privilege('regress_readallstats','pg_shmem_allocations_numa','S
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT has_table_privilege('regress_readallstats','pg_dsm_registry_allocations','SELECT'); -- yes
|
||||
has_table_privilege
|
||||
---------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
-- run query to ensure that functions within views can be executed
|
||||
SET ROLE regress_readallstats;
|
||||
SELECT COUNT(*) >= 0 AS ok FROM pg_aios;
|
||||
|
||||
@@ -1340,6 +1340,10 @@ pg_cursors| SELECT name,
|
||||
is_scrollable,
|
||||
creation_time
|
||||
FROM pg_cursor() c(name, statement, is_holdable, is_binary, is_scrollable, creation_time);
|
||||
pg_dsm_registry_allocations| SELECT name,
|
||||
type,
|
||||
size
|
||||
FROM pg_get_dsm_registry_allocations() pg_get_dsm_registry_allocations(name, type, size);
|
||||
pg_file_settings| SELECT sourcefile,
|
||||
sourceline,
|
||||
seqno,
|
||||
|
||||
@@ -1948,7 +1948,8 @@ DROP TABLE lock_table;
|
||||
DROP USER regress_locktable_user;
|
||||
|
||||
-- test to check privileges of system views pg_shmem_allocations,
|
||||
-- pg_shmem_allocations_numa and pg_backend_memory_contexts.
|
||||
-- pg_shmem_allocations_numa, pg_dsm_registry_allocations, and
|
||||
-- pg_backend_memory_contexts.
|
||||
|
||||
-- switch to superuser
|
||||
\c -
|
||||
@@ -1959,6 +1960,7 @@ SELECT has_table_privilege('regress_readallstats','pg_aios','SELECT'); -- no
|
||||
SELECT has_table_privilege('regress_readallstats','pg_backend_memory_contexts','SELECT'); -- no
|
||||
SELECT has_table_privilege('regress_readallstats','pg_shmem_allocations','SELECT'); -- no
|
||||
SELECT has_table_privilege('regress_readallstats','pg_shmem_allocations_numa','SELECT'); -- no
|
||||
SELECT has_table_privilege('regress_readallstats','pg_dsm_registry_allocations','SELECT'); -- no
|
||||
|
||||
GRANT pg_read_all_stats TO regress_readallstats;
|
||||
|
||||
@@ -1966,6 +1968,7 @@ SELECT has_table_privilege('regress_readallstats','pg_aios','SELECT'); -- yes
|
||||
SELECT has_table_privilege('regress_readallstats','pg_backend_memory_contexts','SELECT'); -- yes
|
||||
SELECT has_table_privilege('regress_readallstats','pg_shmem_allocations','SELECT'); -- yes
|
||||
SELECT has_table_privilege('regress_readallstats','pg_shmem_allocations_numa','SELECT'); -- yes
|
||||
SELECT has_table_privilege('regress_readallstats','pg_dsm_registry_allocations','SELECT'); -- yes
|
||||
|
||||
-- run query to ensure that functions within views can be executed
|
||||
SET ROLE regress_readallstats;
|
||||
|
||||
Reference in New Issue
Block a user