Improve readability of some tests in strings.sql
c251336 has added some tests to check if a toast relation should be empty or not, hardcoding the toast relation name when calling pg_relation_size(). pg_class.reltoastrelid offers the same information, so simplify the tests to use that. Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/20190403065949.GH3298@paquier.xyz
This commit is contained in:
parent
b73c3a1196
commit
92c76021ae
@ -1190,9 +1190,10 @@ INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
-- expect >0 blocks
|
||||
select 0 = pg_relation_size('pg_toast.pg_toast_'||(select oid from pg_class where relname = 'toasttest'))/current_setting('block_size')::integer as blocks;
|
||||
blocks
|
||||
--------
|
||||
SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty
|
||||
FROM pg_class where relname = 'toasttest';
|
||||
is_empty
|
||||
----------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
@ -1203,9 +1204,10 @@ INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
-- expect 0 blocks
|
||||
select 0 = pg_relation_size('pg_toast.pg_toast_'||(select oid from pg_class where relname = 'toasttest'))/current_setting('block_size')::integer as blocks;
|
||||
blocks
|
||||
--------
|
||||
SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty
|
||||
FROM pg_class where relname = 'toasttest';
|
||||
is_empty
|
||||
----------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
|
@ -375,7 +375,8 @@ INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
-- expect >0 blocks
|
||||
select 0 = pg_relation_size('pg_toast.pg_toast_'||(select oid from pg_class where relname = 'toasttest'))/current_setting('block_size')::integer as blocks;
|
||||
SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty
|
||||
FROM pg_class where relname = 'toasttest';
|
||||
|
||||
TRUNCATE TABLE toasttest;
|
||||
ALTER TABLE toasttest set (toast_tuple_target = 4080);
|
||||
@ -384,7 +385,8 @@ INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
INSERT INTO toasttest values (repeat('1234567890',300));
|
||||
-- expect 0 blocks
|
||||
select 0 = pg_relation_size('pg_toast.pg_toast_'||(select oid from pg_class where relname = 'toasttest'))/current_setting('block_size')::integer as blocks;
|
||||
SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty
|
||||
FROM pg_class where relname = 'toasttest';
|
||||
|
||||
DROP TABLE toasttest;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user