diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/stats.out | 46 | ||||
| -rw-r--r-- | src/test/regress/sql/stats.sql | 30 |
2 files changed, 76 insertions, 0 deletions
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out index 319164a5e9e..94187e59cfb 100644 --- a/src/test/regress/expected/stats.out +++ b/src/test/regress/expected/stats.out @@ -765,6 +765,52 @@ FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass; (1 row) ----- +-- Test reset of some stats for shared table +----- +-- This updates the comment of the database currently in use in +-- pg_shdescription with a fake value, then sets it back to its +-- original value. +SELECT shobj_description(d.oid, 'pg_database') as description_before + FROM pg_database d WHERE datname = current_database() \gset +-- force some stats in pg_shdescription. +BEGIN; +SELECT current_database() as datname \gset +COMMENT ON DATABASE :"datname" IS 'This is a test comment'; +SELECT pg_stat_force_next_flush(); + pg_stat_force_next_flush +-------------------------- + +(1 row) + +COMMIT; +-- check that the stats are reset. +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass; + has_data +---------- + t +(1 row) + +SELECT pg_stat_reset_single_table_counters('pg_shdescription'::regclass); + pg_stat_reset_single_table_counters +------------------------------------- + +(1 row) + +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass; + has_data +---------- + f +(1 row) + +-- set back comment +\if :{?description_before} + COMMENT ON DATABASE :"datname" IS :'description_before'; +\else + COMMENT ON DATABASE :"datname" IS NULL; +\endif +----- -- Test that various stats views are being properly populated ----- -- Test that sessions is incremented when a new session is started in pg_stat_database diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql index 9a16df1c498..1e21e55c6d9 100644 --- a/src/test/regress/sql/stats.sql +++ b/src/test/regress/sql/stats.sql @@ -376,6 +376,36 @@ COMMIT; SELECT seq_scan, :'test_last_seq' = last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' < last_idx_scan AS idx_ok FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass; +----- +-- Test reset of some stats for shared table +----- + +-- This updates the comment of the database currently in use in +-- pg_shdescription with a fake value, then sets it back to its +-- original value. +SELECT shobj_description(d.oid, 'pg_database') as description_before + FROM pg_database d WHERE datname = current_database() \gset + +-- force some stats in pg_shdescription. +BEGIN; +SELECT current_database() as datname \gset +COMMENT ON DATABASE :"datname" IS 'This is a test comment'; +SELECT pg_stat_force_next_flush(); +COMMIT; + +-- check that the stats are reset. +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass; +SELECT pg_stat_reset_single_table_counters('pg_shdescription'::regclass); +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass; + +-- set back comment +\if :{?description_before} + COMMENT ON DATABASE :"datname" IS :'description_before'; +\else + COMMENT ON DATABASE :"datname" IS NULL; +\endif ----- -- Test that various stats views are being properly populated |
