Fix bloat check to use correct SQL depending on the server version.
authorChristoph Berg <[email protected]>
Mon, 8 Sep 2014 15:05:35 +0000 (17:05 +0200)
committerChristoph Berg <[email protected]>
Mon, 8 Sep 2014 15:05:35 +0000 (17:05 +0200)
Previously it used the psql version which might differ when multiple
versions are installed locally, or when querying remote servers.

The hot_standby_delay check is also affected, but more involved to fix,
so leave that for later.

Adrian Vondendriesch

check_postgres.pl

index 60e86c3b37eff7f8e6fcbda3e6dcb081a27752b2..2e6eb7a4e568fe2c0ec063ed748b035b64a2336e 100755 (executable)
@@ -3623,14 +3623,10 @@ FROM (
 
     ## Alternate versions for old versions
     my $SQL2 = $SQL;
-    if ($psql_version <= 8.4) {
-        $SQL2 =~ s/AND s.inherited=false//;
-    }
+    $SQL2 =~ s/AND s.inherited=false//; # 8.4 and earlier
 
     my $SQL3 = $SQL2;
-    if ($psql_version <= 7.4) {
-        $SQL3 =~ s/SELECT current_setting.+?AS bs/(SELECT 8192) AS bs/;
-    }
+    $SQL3 =~ s/SELECT current_setting.+?AS bs/(SELECT 8192) AS bs/; # 7.4 and earlier
 
     my $info = run_command($SQL, { version => [  "<8.0 $SQL3", "<9.0 $SQL2" ] } );
 
@@ -4759,7 +4755,7 @@ sub check_hot_standby_delay {
     ## --warning='1048576 and 2min' --critical='16777216 and 10min'
 
     my ($warning, $wtime, $critical, $ctime) = validate_integer_for_time({default_to_int => 1});
-    if ($psql_version < 9.1 and (length $wtime or length $ctime)) {
+    if ($psql_version < 9.1 and (length $wtime or length $ctime)) { # FIXME: check server version instead
         add_unknown msg('hs-time-version');
         return;
     }
@@ -9821,6 +9817,9 @@ Items not specifically attributed are by GSM (Greg Sabino Mullane).
 
 =item B<Version 2.21.1>
 
+  Fix bloat check to use correct SQL depending on the server version.
+    (Adrian Vondendriesch)
+
   Add explicit ORDER BY to the slony_status check to get the most lagged server.
     (Jeff Frost)