From: Michael Paquier Date: Thu, 4 Apr 2019 01:24:56 +0000 (+0900) Subject: Improve readability of some tests in strings.sql X-Git-Tag: REL_12_BETA1~313 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92c76021aed47daa61afd5c7d6f8201382dee203;p=postgresql 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 --- diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out index 189bdffdca..2f5f58273a 100644 --- a/src/test/regress/expected/strings.out +++ b/src/test/regress/expected/strings.out @@ -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) diff --git a/src/test/regress/sql/strings.sql b/src/test/regress/sql/strings.sql index f2203ef1b1..1f4cd88a18 100644 --- a/src/test/regress/sql/strings.sql +++ b/src/test/regress/sql/strings.sql @@ -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;