Add SLRU tests for 64-bit page case

4ed8f0913b added 64-bit page numbering for SLRU.  This commit adds tests for
page numbers higher than 2^32.

Author: Maxim Orlov
Reviewed-by: Aleksander Alekseev, Alexander Korotkov
Discussion: https://postgr.es/m/CACG%3DezZe1NQSCnfHOr78AtAZxJZeCvxrts0ygrxYwe%3DpyyjVWA%40mail.gmail.com
Discussion: https://postgr.es/m/CAJ7c6TPDOYBYrnCAeyndkBktO0WG2xSdYduTF0nxq%2BvfkmTF5Q%40mail.gmail.com
This commit is contained in:
Alexander Korotkov 2023-11-29 01:44:01 +02:00
parent 5a1dfde833
commit a60b8a58f4
2 changed files with 173 additions and 0 deletions

View File

@ -132,4 +132,139 @@ SELECT test_slru_page_exists(12393);
f
(1 row)
--
-- Test 64-bit pages
--
SELECT test_slru_page_exists(0x1234500000000);
test_slru_page_exists
-----------------------
f
(1 row)
SELECT test_slru_page_write(0x1234500000000, 'Test SLRU 64-bit');
test_slru_page_write
----------------------
(1 row)
SELECT test_slru_page_read(0x1234500000000);
test_slru_page_read
---------------------
Test SLRU 64-bit
(1 row)
SELECT test_slru_page_exists(0x1234500000000);
test_slru_page_exists
-----------------------
t
(1 row)
-- 48 extra pages
SELECT count(test_slru_page_write(a, 'Test SLRU 64-bit'))
FROM generate_series(0x1234500000001, 0x1234500000030, 1) as a;
count
-------
48
(1 row)
-- Reading page in buffer for read and write
SELECT test_slru_page_read(0x1234500000020, true);
test_slru_page_read
---------------------
Test SLRU 64-bit
(1 row)
-- Reading page in buffer for read-only
SELECT test_slru_page_readonly(0x1234500000020);
test_slru_page_readonly
-------------------------
Test SLRU 64-bit
(1 row)
-- Reading page not in buffer with read-only
SELECT test_slru_page_readonly(0x1234500000001);
test_slru_page_readonly
-------------------------
Test SLRU 64-bit
(1 row)
-- Write all the pages in buffers
SELECT test_slru_page_writeall();
test_slru_page_writeall
-------------------------
(1 row)
-- Flush the last page written out.
SELECT test_slru_page_sync(0x1234500000030);
NOTICE: Called SlruSyncFileTag() for segment 10007944888321 on path pg_test_slru/000091A28000001
test_slru_page_sync
---------------------
(1 row)
SELECT test_slru_page_exists(0x1234500000030);
test_slru_page_exists
-----------------------
t
(1 row)
-- Segment deletion
SELECT test_slru_page_delete(0x1234500000030);
NOTICE: Called SlruDeleteSegment() for segment 10007944888321
test_slru_page_delete
-----------------------
(1 row)
SELECT test_slru_page_exists(0x1234500000030);
test_slru_page_exists
-----------------------
f
(1 row)
-- Page truncation
SELECT test_slru_page_exists(0x1234500000020);
test_slru_page_exists
-----------------------
f
(1 row)
SELECT test_slru_page_truncate(0x1234500000020);
test_slru_page_truncate
-------------------------
(1 row)
SELECT test_slru_page_exists(0x1234500000020);
test_slru_page_exists
-----------------------
f
(1 row)
-- Full deletion
SELECT test_slru_delete_all();
test_slru_delete_all
----------------------
(1 row)
SELECT test_slru_page_exists(0x1234500000000);
test_slru_page_exists
-----------------------
f
(1 row)
SELECT test_slru_page_exists(0x1234500000020);
test_slru_page_exists
-----------------------
f
(1 row)
SELECT test_slru_page_exists(0x1234500000030);
test_slru_page_exists
-----------------------
f
(1 row)
DROP EXTENSION test_slru;

View File

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