Add some tests to check the SQL functions of control file
authorMichael Paquier <[email protected]>
Thu, 27 Oct 2022 00:58:44 +0000 (09:58 +0900)
committerMichael Paquier <[email protected]>
Thu, 27 Oct 2022 00:58:44 +0000 (09:58 +0900)
As the recent commit 05d4cbf (reverted after as a448e49) has proved,
there is zero coverage for the four SQL functions that can scan the
control file data:
- pg_control_checkpoint()
- pg_control_init()
- pg_control_recovery()
- pg_control_system()

This commit adds a minimal coverage for these functions, checking that
their execution is able to complete.  This would have been enough to
catch the problems introduced in the commit mentioned above.  More
checks could be done for each individual fields, but it is unclear
whether this would be better than the other checks in place in the
backend code.

Per discussion with Bharath Rupireddy.

Discussion: https://postgr.es/m/[email protected]

src/test/regress/expected/misc_functions.out
src/test/regress/sql/misc_functions.sql

index 9f106c2a108e680e6df46714e27fb489db3ac904..88bb696ded813a2209716e315e3ab28694ec3bd6 100644 (file)
@@ -594,3 +594,28 @@ SELECT * FROM tenk1 a JOIN my_gen_series(1,10) g ON a.unique1 = g;
          Index Cond: (unique1 = g.g)
 (4 rows)
 
+-- Test functions for control data
+SELECT count(*) > 0 AS ok FROM pg_control_checkpoint();
+ ok 
+----
+ t
+(1 row)
+
+SELECT count(*) > 0 AS ok FROM pg_control_init();
+ ok 
+----
+ t
+(1 row)
+
+SELECT count(*) > 0 AS ok FROM pg_control_recovery();
+ ok 
+----
+ t
+(1 row)
+
+SELECT count(*) > 0 AS ok FROM pg_control_system();
+ ok 
+----
+ t
+(1 row)
+
index 639e9b352cfa3169cc44cfe989e8ea256ef4d0d4..b07e9e8dbb3c5d943fc5996f28f8436213139dbf 100644 (file)
@@ -223,3 +223,9 @@ SELECT * FROM tenk1 a JOIN my_gen_series(1,1000) g ON a.unique1 = g;
 
 EXPLAIN (COSTS OFF)
 SELECT * FROM tenk1 a JOIN my_gen_series(1,10) g ON a.unique1 = g;
+
+-- Test functions for control data
+SELECT count(*) > 0 AS ok FROM pg_control_checkpoint();
+SELECT count(*) > 0 AS ok FROM pg_control_init();
+SELECT count(*) > 0 AS ok FROM pg_control_recovery();
+SELECT count(*) > 0 AS ok FROM pg_control_system();