This action requires Postgres 8.3 or better.
+Superuser privileges are required to see the queries of all users in the system;
+UNKNOWN is returned if queries cannot be checked. To only include queries by
+the connecting user, use I<--includeuser>.
+
Example 1: Give a warning if any connection has been idle in transaction for more than 15 seconds:
check_postgres_txn_idle --port=5432 --warning='15 seconds'
use strict;
use warnings;
use Data::Dumper;
-use Test::More tests => 15;
+use Test::More tests => 16;
use lib 't','.';
use CP_Testing;
$t = qq{$S returns an unknown if running as a non-superuser};
my $olduser = $cp->{testuser};
$cp->{testuser} = 'powerless_pete';
-like ($cp->run('-w 0'), qr{^$label UNKNOWN: .+superuser}, $t);
+like ($cp->run('-w 1'), qr{^$label UNKNOWN: .+superuser}, $t);
$idle_dbh->commit;
+my $idle_dbh2 = $cp->test_database_handle({ testuser => 'powerless_pete' });
+$idle_dbh2->do('SELECT 1');
+sleep(1);
+$t = qq{$S identifies own queries even when running as a non-superuser};
+like ($cp->run('-w 1 --includeuser powerless_pete'), qr{longest idle in txn: \d+s}, $t);
+
exit;