DebugInfo: Expand queries table with params & details
Apart from the ugly implementation, this is pretty neat.
This commit is contained in:
parent
76f55f277b
commit
cbccf045b7
2 changed files with 153 additions and 59 deletions
23
FU.pm
23
FU.pm
|
|
@ -121,11 +121,24 @@ sub query_trace($st,@) {
|
|||
$REQ->{trace_nsqldirect}++ if !defined $st->prepare_time;
|
||||
$REQ->{trace_sqlexec} += $st->exec_time;
|
||||
$REQ->{trace_sqlprep} += $st->prepare_time if $st->prepare_time;
|
||||
push $REQ->{trace_sql}->@*, {
|
||||
query => $st->query, nrows => $st->nrows,
|
||||
param_types => $st->param_types, param_values => $st->param_values,
|
||||
exec_time => $st->exec_time, prepare_time => $st->prepare_time,
|
||||
} if FU::debug;
|
||||
if (FU::debug) {
|
||||
my $t = $st->param_types;
|
||||
my $v = $st->param_values;
|
||||
my $txt = $st->get_text_params;
|
||||
push $REQ->{trace_sql}->@*, {
|
||||
query => $st->query, nrows => $st->nrows,
|
||||
exec_time => $st->exec_time, prepare_time => $st->prepare_time,
|
||||
# Store the binary value when we're in binary params mode, that way
|
||||
# we don't have to keep a reference to the original perl value and
|
||||
# we can defer & batch the conversion to text.
|
||||
params => [ map +{
|
||||
type => $t->[$_],
|
||||
!defined $v->[$_] ? (text => undef) :
|
||||
$txt ? (text => "$v->[$_]")
|
||||
: (bin => $DB->perl2bin($t->[$_], $v->[$_]))
|
||||
}, 0..$#$v ],
|
||||
};
|
||||
}
|
||||
}
|
||||
sub _connect_db {
|
||||
$DB = ref $INIT_DB eq 'CODE' ? $INIT_DB->() : FU::Pg->connect($INIT_DB);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue