mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Allow users to opt out of returning FPI data and block data from pg_get_wal_block_info as an optimization. Testing has shown that this can make function execution over twice as fast in some cases. When pg_get_wal_block_info is called with "show_data := false", it always returns NULL values for its block_data and block_fpi_data bytea output parameters. Nothing else changes. In particular, the function will still return the usual per-block summary of block data/FPI space overhead. Use of "show_data := false" is therefore feasible with all queries that don't specifically require these raw binary strings. Follow-up to recent work in commit 122376f0. There still hasn't been a stable release with the pg_get_wal_block_info function, so no bump in the pg_walinspect extension version. Per suggestion from Melanie Plageman. Author: Peter Geoghegan <pg@bowt.ie> Discussion: https://postgr.es/m/CAAKRu_bJvbcYBRj2cN6G2xV7B7-Ja+pjTO1nEnEhRR8OXYiABA@mail.gmail.com Discussion: https://postgr.es/m/CAH2-Wzm9shOkEDM10_+qOZkRSQhKVxwBFiehH6EHWQQRd_rDPw@mail.gmail.com
70 lines
2.4 KiB
Plaintext
70 lines
2.4 KiB
Plaintext
-- Test old extension version entry points.
|
|
CREATE EXTENSION pg_walinspect WITH VERSION '1.0';
|
|
-- Mask DETAIL messages as these could refer to current LSN positions.
|
|
\set VERBOSITY terse
|
|
-- List what version 1.0 contains, using a locale-independent sorting.
|
|
SELECT pg_describe_object(classid, objid, 0) AS obj
|
|
FROM pg_depend
|
|
WHERE refclassid = 'pg_extension'::regclass AND
|
|
refobjid = (SELECT oid FROM pg_extension
|
|
WHERE extname = 'pg_walinspect') AND deptype = 'e'
|
|
ORDER BY pg_describe_object(classid, objid, 0) COLLATE "C";
|
|
obj
|
|
-----------------------------------------------------------
|
|
function pg_get_wal_record_info(pg_lsn)
|
|
function pg_get_wal_records_info(pg_lsn,pg_lsn)
|
|
function pg_get_wal_records_info_till_end_of_wal(pg_lsn)
|
|
function pg_get_wal_stats(pg_lsn,pg_lsn,boolean)
|
|
function pg_get_wal_stats_till_end_of_wal(pg_lsn,boolean)
|
|
(5 rows)
|
|
|
|
-- Make sure checkpoints don't interfere with the test.
|
|
SELECT 'init' FROM pg_create_physical_replication_slot('regress_pg_walinspect_slot', true, false);
|
|
?column?
|
|
----------
|
|
init
|
|
(1 row)
|
|
|
|
CREATE TABLE sample_tbl(col1 int, col2 int);
|
|
SELECT pg_current_wal_lsn() AS wal_lsn1 \gset
|
|
INSERT INTO sample_tbl SELECT * FROM generate_series(1, 2);
|
|
-- Tests for the past functions.
|
|
SELECT COUNT(*) >= 1 AS ok FROM pg_get_wal_records_info_till_end_of_wal(:'wal_lsn1');
|
|
ok
|
|
----
|
|
t
|
|
(1 row)
|
|
|
|
SELECT COUNT(*) >= 1 AS ok FROM pg_get_wal_stats_till_end_of_wal(:'wal_lsn1');
|
|
ok
|
|
----
|
|
t
|
|
(1 row)
|
|
|
|
-- Failures with start LSNs.
|
|
SELECT * FROM pg_get_wal_records_info_till_end_of_wal('FFFFFFFF/FFFFFFFF');
|
|
ERROR: WAL start LSN must be less than current LSN
|
|
SELECT * FROM pg_get_wal_stats_till_end_of_wal('FFFFFFFF/FFFFFFFF');
|
|
ERROR: WAL start LSN must be less than current LSN
|
|
-- Move to new version 1.1.
|
|
ALTER EXTENSION pg_walinspect UPDATE TO '1.1';
|
|
-- List what version 1.1 contains.
|
|
\dx+ pg_walinspect
|
|
Objects in extension "pg_walinspect"
|
|
Object description
|
|
-------------------------------------------------------
|
|
function pg_get_wal_block_info(pg_lsn,pg_lsn,boolean)
|
|
function pg_get_wal_record_info(pg_lsn)
|
|
function pg_get_wal_records_info(pg_lsn,pg_lsn)
|
|
function pg_get_wal_stats(pg_lsn,pg_lsn,boolean)
|
|
(4 rows)
|
|
|
|
SELECT pg_drop_replication_slot('regress_pg_walinspect_slot');
|
|
pg_drop_replication_slot
|
|
--------------------------
|
|
|
|
(1 row)
|
|
|
|
DROP TABLE sample_tbl;
|
|
DROP EXTENSION pg_walinspect;
|