Keep using pg_relation_size on 8.4 and earlier
authorChristoph Berg <[email protected]>
Tue, 31 May 2016 19:33:01 +0000 (21:33 +0200)
committerChristoph Berg <[email protected]>
Tue, 31 May 2016 19:49:43 +0000 (21:49 +0200)
pg_indexes_size doesn't exist either on 8.4, but that action is new, so
let's not care for now.

Also fix t/05_docs.t for the newly added actions.

check_postgres.pl
t/05_docs.t

index 01fcdfcf8351393e5eece6c485b59633052a2636..77aa39ae7e37e04ac3f43a7cef4c2e9ce83e9866 100755 (executable)
@@ -6321,7 +6321,10 @@ WHERE relkind IN (%2$s)
         $SQL .= $USERWHERECLAUSE;
     }
 
-    my $info = run_command($SQL, {emptyok => 1});
+    my $SQL8 = $SQL;
+    $SQL8 =~ s/pg_table_size/pg_relation_size/g; # 8.4 and earlier
+
+    my $info = run_command($SQL, {emptyok => 1, version => [ "<9.0 $SQL8" ] });
 
     my $found = 0;
     for $db (@{$info->{db}}) {
@@ -10157,8 +10160,8 @@ Items not specifically attributed are by GSM (Greg Sabino Mullane).
 
 =item B<Version 2.22.1> Released ????
 
-  Change table_size to use pg_table_size(), i.e. to include the TOAST table
-  size in the numbers reported. Add new actions indexes_size and
+  Change table_size to use pg_table_size() on 9.0+, i.e. include the TOAST
+  table size in the numbers reported. Add new actions indexes_size and
   total_relation_size, using the respective pg_indexes_size() and
   pg_total_relation_size() functions. All size checks will now also check
   materialized views where applicable.
index 7c7541a3fdc3545e5d88912804ac637167a5e906..7ef94999dfc8b8c5f8fcbacd6af6d2eaa18f8f24 100644 (file)
@@ -38,6 +38,7 @@ for my $action (@actions) {
   next if $action =~ /last_auto/;
 
   my $match = $action;
+  $match = 'relation_size' if $match =~ /^(index|table|indexes|total_relation)_size/;
   $match = 'pgb_pool' if $match =~ /pgb_pool/;
 
   if ($slurp !~ /\n\s*sub check_$match/) {