summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/POE/Component/Pg.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/POE/Component/Pg.pm b/lib/POE/Component/Pg.pm
index 076d4b7..a68966b 100644
--- a/lib/POE/Component/Pg.pm
+++ b/lib/POE/Component/Pg.pm
@@ -74,6 +74,7 @@ package POE::Component::Pg::STATES;
use POE;
use DBI;
use DBD::Pg ':async';
+use Time::HiRes 'time';
sub QACT { 0 }
sub QSESID { 1 }
@@ -270,12 +271,13 @@ sub dbi_canread {
$res = $_[HEAP]{q}->fetchall_arrayref({}) if $item->[QACT] eq 'query';
};
$_[HEAP]{q} = undef;
+ my $time = time - $_[HEAP]{querystart};
# send event
if($@) {
sendevent \@_, 'error', $item->[QACT], $@, $item->[QQUERY], $item->[QPARAM], $item->[QSESID], $item->[QARG];
} elsif($item->[QEVENT]) {
- $_[KERNEL]->post($item->[QSESID], $item->[QEVENT], $num, $res, exists $item->[QARG] ? $item->[QARG] : ());
+ $_[KERNEL]->post($item->[QSESID], $item->[QEVENT], $num, $res, $item->[QARG], $time);
}
$_[KERNEL]->refcount_decrement($item->[QSESID], 'P:C:PG') if defined $item->[QSESID];
@@ -288,6 +290,7 @@ sub dbi_canread {
sub dbi_canwrite {
# execute topmost query in the queue
my $item = $_[HEAP]{queue}[0];
+ $_[HEAP]{querystart} = time;
eval {
$_[HEAP]{q} = $_[HEAP]{dbi}->prepare($item->[QQUERY], { pg_async => PG_ASYNC });
$_[HEAP]{q}->execute($item->[QPARAM] && ref($item->[QPARAM]) eq 'ARRAY' ? @{$item->[QPARAM]} : ());