mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Fix test of pg_stat_io for wal_level=minimal.
Back-patch to v16, which introduced the test.
This commit is contained in:
@ -76,11 +76,15 @@ INSERT INTO heaptest (a, b)
|
|||||||
--
|
--
|
||||||
-- Create an alternative tablespace and move the heaptest table to it, causing
|
-- Create an alternative tablespace and move the heaptest table to it, causing
|
||||||
-- it to be rewritten and all the blocks to reliably evicted from shared
|
-- it to be rewritten and all the blocks to reliably evicted from shared
|
||||||
-- buffers -- guaranteeing actual reads when we next select from it.
|
-- buffers -- guaranteeing actual reads when we next select from it in the
|
||||||
|
-- same transaction. The heaptest table is smaller than the default
|
||||||
|
-- wal_skip_threshold, so a wal_level=minimal commit reads the table into
|
||||||
|
-- shared_buffers. A transaction delays that and excludes any autovacuum.
|
||||||
SET allow_in_place_tablespaces = true;
|
SET allow_in_place_tablespaces = true;
|
||||||
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
||||||
SELECT sum(reads) AS stats_bulkreads_before
|
SELECT sum(reads) AS stats_bulkreads_before
|
||||||
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
||||||
|
BEGIN;
|
||||||
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
||||||
-- Check that valid options are not rejected nor corruption reported
|
-- Check that valid options are not rejected nor corruption reported
|
||||||
-- for a non-empty table
|
-- for a non-empty table
|
||||||
@ -104,6 +108,7 @@ SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock :=
|
|||||||
-------+--------+--------+-----
|
-------+--------+--------+-----
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
-- verify_heapam should have read in the page written out by
|
-- verify_heapam should have read in the page written out by
|
||||||
-- ALTER TABLE ... SET TABLESPACE ...
|
-- ALTER TABLE ... SET TABLESPACE ...
|
||||||
-- causing an additional bulkread, which should be reflected in pg_stat_io.
|
-- causing an additional bulkread, which should be reflected in pg_stat_io.
|
||||||
|
@ -36,19 +36,23 @@ INSERT INTO heaptest (a, b)
|
|||||||
--
|
--
|
||||||
-- Create an alternative tablespace and move the heaptest table to it, causing
|
-- Create an alternative tablespace and move the heaptest table to it, causing
|
||||||
-- it to be rewritten and all the blocks to reliably evicted from shared
|
-- it to be rewritten and all the blocks to reliably evicted from shared
|
||||||
-- buffers -- guaranteeing actual reads when we next select from it.
|
-- buffers -- guaranteeing actual reads when we next select from it in the
|
||||||
|
-- same transaction. The heaptest table is smaller than the default
|
||||||
|
-- wal_skip_threshold, so a wal_level=minimal commit reads the table into
|
||||||
|
-- shared_buffers. A transaction delays that and excludes any autovacuum.
|
||||||
SET allow_in_place_tablespaces = true;
|
SET allow_in_place_tablespaces = true;
|
||||||
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
||||||
SELECT sum(reads) AS stats_bulkreads_before
|
SELECT sum(reads) AS stats_bulkreads_before
|
||||||
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
||||||
|
BEGIN;
|
||||||
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
||||||
|
|
||||||
-- Check that valid options are not rejected nor corruption reported
|
-- Check that valid options are not rejected nor corruption reported
|
||||||
-- for a non-empty table
|
-- for a non-empty table
|
||||||
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'none');
|
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'none');
|
||||||
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-frozen');
|
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-frozen');
|
||||||
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-visible');
|
SELECT * FROM verify_heapam(relation := 'heaptest', skip := 'all-visible');
|
||||||
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock := 0);
|
SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock := 0);
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
-- verify_heapam should have read in the page written out by
|
-- verify_heapam should have read in the page written out by
|
||||||
-- ALTER TABLE ... SET TABLESPACE ...
|
-- ALTER TABLE ... SET TABLESPACE ...
|
||||||
|
Reference in New Issue
Block a user