$ERROR = $db->{error};
}
if (!$db->{ok} and !$arg->{failok}) {
+
+ ## Check if problem is due to backend being too old for this check
+ verify_version();
+
add_unknown;
## Remove it from the returned hash
pop @{$info->{db}};
## If we were provided with a regex, check and bail if it fails
elsif ($arg->{regex}) {
if ($db->{slurp} !~ $arg->{regex}) {
- my $oldslurp = $db->{slurp};
## Check if problem is due to backend being too old for this check
- verify_version($db->{slurp});
+ verify_version();
- $db->{slurp} = $oldslurp;
add_unknown qq{T-BAD-QUERY $db->{slurp}};
## Remove it from the returned hash
pop @{$info->{db}};
## We almost always need the version, so just grab it for any limitation
$SQL = q{SELECT setting FROM pg_settings WHERE name = 'server_version'};
+ my $oldslurp = $db->{slurp} || '';
my $info = run_command($SQL);
if (!defined $info->{db}[0] or $info->{db}[0]{slurp} !~ /((\d+)\.(\d+))/) {
die "Could not determine version while running $SQL\n";
}
}
+ $db->{slurp} = $oldslurp;
return;
} ## end of verify_version
## Figure out where the pg_xlog directory is
$SQL = q{SELECT count(*) FROM pg_ls_dir('pg_xlog') WHERE pg_ls_dir ~ E'^[0-9A-F]{24}$'}; ## no critic (RequireInterpolationOfMetachars)
- my $info = run_command($SQL);
+ my $info = run_command($SQL, {regex => qr[\d] });
my $found = 0;
for $db (@{$info->{db}}) {
}
}
- ## If no results, probably a version problem
- if (!$found and keys %unknown) {
- (my $first) = values %unknown;
- if ($first->[0][0] =~ /pg_ls_dir/) {
- ndie 'Target database must be version 8.1 or higher to run the check_wal_files action';
- }
- }
-
return;
} ## end of check_wal_files
}
}
- ## If no results, probably a version problem
- if (!$found and keys %unknown) {
- (my $first) = values %unknown;
- if ($first->[0][0] =~ /pg_relation_size/) {
- ndie "Target database must be version 8.1 or higher to run the ${relkind}_size action";
- }
- }
-
return;
} ## end of check_relations_size
return;
} ## end of check_last_vacuum_analyze
+
sub check_last_vacuum {
my $auto = shift || '';
return check_last_vacuum_analyze('vacuum', $auto);
}
}
- ## If no results, probably a version problem
- if (!$found and keys %unknown) {
- (my $first) = values %unknown;
- if ($first->[0][0] =~ /xact_start/) {
- ndie 'Target database must be version 8.3 or higher to run the txn_time action';
- }
- }
-
return;
} ## end of check_txn_time
## If no results, let's be paranoid and check their settings
if (!$found) {
- $SQL = q{SELECT setting FROM pg_settings WHERE name = 'stats_command_string'};
- $info = run_command($SQL);
- for my $db (@{$info->{db}}) {
- if ($db->{slurp} =~ /off/) {
- ndie q{Cannot run the txn_idle action unless stats_command_string is set to 'on'!};
- }
- }
+ verify_version();
}
return;