postgresql/src/test/modules/test_slru/sql/test_slru.sql
Michael Paquier 006b69fd91 Add test module for SLRUs
This commit introduces a basic facility to test SLRUs, in terms of
initialization, page reads, writes, flushes, truncation and deletions,
using SQL wrappers around the APIs of slru.c.  This should be easily
extensible at will, and it can be used as a starting point for someone
willing to implement an external module that makes use of SLRUs (LWLock
tranche registering and SLRU initialization particularly).

As this requires a loaded library, the tests use a custom configuration
file and are disabled under installcheck.

Author: Aleksander Alekseev, Michael Paquier
Reviewed-by: Pavel Borisov, Daniel Gustafsson, Noah Misch, Maxim Orlov
Discussion: https://postgr.es/m/CAJ7c6TOFoWcHOW4BVe3BG_uikCrO9B91ayx9d6rh5JZr_tPESg@mail.gmail.com
2022-11-16 09:52:21 +09:00

38 lines
1.1 KiB
SQL

CREATE EXTENSION test_slru;
SELECT test_slru_page_exists(12345);
SELECT test_slru_page_write(12345, 'Test SLRU');
SELECT test_slru_page_read(12345);
SELECT test_slru_page_exists(12345);
-- 48 extra pages
SELECT count(test_slru_page_write(a, 'Test SLRU'))
FROM generate_series(12346, 12393, 1) as a;
-- Reading page in buffer for read and write
SELECT test_slru_page_read(12377, true);
-- Reading page in buffer for read-only
SELECT test_slru_page_readonly(12377);
-- Reading page not in buffer with read-only
SELECT test_slru_page_readonly(12346);
-- Write all the pages in buffers
SELECT test_slru_page_writeall();
-- Flush the last page written out.
SELECT test_slru_page_sync(12393);
SELECT test_slru_page_exists(12393);
-- Segment deletion
SELECT test_slru_page_delete(12393);
SELECT test_slru_page_exists(12393);
-- Page truncation
SELECT test_slru_page_exists(12377);
SELECT test_slru_page_truncate(12377);
SELECT test_slru_page_exists(12377);
-- Full deletion
SELECT test_slru_delete_all();
SELECT test_slru_page_exists(12345);
SELECT test_slru_page_exists(12377);
SELECT test_slru_page_exists(12393);
DROP EXTENSION test_slru;