summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Sabino Mullane2012-02-20 20:54:08 +0000
committerGreg Sabino Mullane2012-02-20 20:54:08 +0000
commita2be20a6967df2b860bbe34f7ef4b6826a958058 (patch)
tree857780210becfdc0a4afd52157ac161d8012f84b
parent1499a6818c77ec968210b248e89811b693caf875 (diff)
Allow txn_idle to work again for < 8.3 servers by switching to query_time.
-rwxr-xr-xcheck_postgres.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/check_postgres.pl b/check_postgres.pl
index 6f0b2c3d2..0e2f3a44d 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -7474,12 +7474,16 @@ sub check_txn_idle {
## We don't GROUP BY because we want details on every connection
## Someday we may even break things down by database
+ my $SQL2;
if ($type ne 'qtime') {
$SQL = q{SELECT datname, datid, procpid, usename, client_addr, xact_start, current_query, }.
q{CASE WHEN client_port < 0 THEN 0 ELSE client_port END AS client_port, }.
qq{COALESCE(ROUND(EXTRACT(epoch FROM now()-$start)),0) AS seconds }.
qq{FROM pg_stat_activity WHERE $clause$USERWHERECLAUSE }.
q{ORDER BY xact_start, query_start, procpid DESC};
+ ## Craft an alternate version for old servers that do not have the xact_start column:
+ ($SQL2 = $SQL) =~ s/xact_start/query_start AS xact_start/;
+ $SQL2 =~ s/BY xact_start,/BY/;
}
else {
$SQL = q{SELECT datname, datid, procpid, usename, client_addr, current_query, }.
@@ -7489,8 +7493,7 @@ sub check_txn_idle {
q{ORDER BY query_start, procpid DESC};
}
- my $info = run_command($SQL, { emptyok => 1 } );
-
+ my $info = run_command($SQL, { emptyok => 1 , version => [ "<8.3 $SQL2" ] } );
## Extract the first entry
$db = $info->{db}[0];
@@ -9673,6 +9676,8 @@ Items not specifically attributed are by GSM (Greg Sabino Mullane).
Allow for spaces in item lists when doing same_schema.
+ Allow txn_idle to work again for < 8.3 servers by switching to query_time.
+
=item B<Version 2.19.0> January 17, 2012
Add the --assume-prod option (Cédric Villemain)