diff options
author | Greg Sabino Mullane | 2008-10-10 01:38:14 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2008-10-10 01:38:14 +0000 |
commit | ff2c783e01ae07ff7368be63ecb48eb692e835b4 (patch) | |
tree | cee06f652567940e39caeeed485a7f290a9c8374 | |
parent | 99caa69931a4a8f9d4a7f0f712fe462f84989090 (diff) |
Better error handling.
-rwxr-xr-x | check_postgres.pl | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index df24226d7..617bdd1ad 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -971,11 +971,15 @@ sub run_command { ndie "$db->{error}"; } - if (!$db->{ok} and !$arg->{failok}) { + if (!$db->{ok} and !$arg->{failok} and !$arg->{noverify}) { ## Check if problem is due to backend being too old for this check verify_version(); + if (exists $db->{error}) { + ndie $db->{error}; + } + add_unknown; ## Remove it from the returned hash pop @{$info->{db}}; @@ -1058,7 +1062,14 @@ sub verify_version { ## 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); + my $info = run_command($SQL, {noverify => 1}); + if (defined $info->{db}[0] + and exists $info->{db}[0]{error} + and defined $info->{db}[0]{error} + ) { + ndie $info->{db}[0]{error}; + } + if (!defined $info->{db}[0] or $info->{db}[0]{slurp} !~ /((\d+)\.(\d+))/) { die "Could not determine version while running $SQL\n"; } @@ -4695,6 +4706,7 @@ Items not specifically attributed are by Greg Sabino Mullane. =item B<Version 2.3.5> Change option 'checktype' to 'valtype' to prevent collisions with -c[ritical] + Better handling of errors. =item B<Version 2.3.4> |