Commit 92c76021 authored by Michael Paquier's avatar Michael Paquier

Improve readability of some tests in strings.sql

c2513365 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
parent b73c3a11
...@@ -1190,9 +1190,10 @@ INSERT INTO toasttest values (repeat('1234567890',300)); ...@@ -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));
INSERT INTO toasttest values (repeat('1234567890',300)); INSERT INTO toasttest values (repeat('1234567890',300));
-- expect >0 blocks -- 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
blocks FROM pg_class where relname = 'toasttest';
-------- is_empty
----------
f f
(1 row) (1 row)
...@@ -1203,9 +1204,10 @@ INSERT INTO toasttest values (repeat('1234567890',300)); ...@@ -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));
INSERT INTO toasttest values (repeat('1234567890',300)); INSERT INTO toasttest values (repeat('1234567890',300));
-- expect 0 blocks -- 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
blocks FROM pg_class where relname = 'toasttest';
-------- is_empty
----------
t t
(1 row) (1 row)
......
...@@ -375,7 +375,8 @@ INSERT INTO toasttest values (repeat('1234567890',300)); ...@@ -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));
INSERT INTO toasttest values (repeat('1234567890',300)); INSERT INTO toasttest values (repeat('1234567890',300));
-- expect >0 blocks -- 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; TRUNCATE TABLE toasttest;
ALTER TABLE toasttest set (toast_tuple_target = 4080); ALTER TABLE toasttest set (toast_tuple_target = 4080);
...@@ -384,7 +385,8 @@ INSERT INTO toasttest values (repeat('1234567890',300)); ...@@ -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));
INSERT INTO toasttest values (repeat('1234567890',300)); INSERT INTO toasttest values (repeat('1234567890',300));
-- expect 0 blocks -- 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; DROP TABLE toasttest;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment