return;
}
- # Look at bind parameters if any
+ # Look at bind/execute parameters if any
if ($cur_info{$t_pid}{query}) {
# Remove obsolete connection storage
$cur_info{$t_pid}{parameters} = "$1";
# go look at other params
return;
+ # replace the execute statements with the prepared query and set the parameters
+ } elsif (($prefix_vars{'t_loglevel'} eq 'DETAIL') && ($prefix_vars{'t_query'} =~ s/prepare: PREPARE[\s\t]+([^\s\t]+)[\s\t]+AS[\s\t]+(.*)//is)) {
+ my $q_name = $1;
+ my $real_query = $2;
+ if ($cur_info{$t_pid}{query} =~ /\b$q_name\b/) {
+ $cur_info{$t_pid}{query} =~ s/EXECUTE[\s\t]+$q_name([\s\t]+)\(//is;
+ $cur_info{$t_pid}{parameters} = $cur_info{$t_pid}{query};
+ $cur_info{$t_pid}{parameters} =~ s/\)$//;
+ $cur_info{$t_pid}{query} = $real_query;
+ $cur_info{$t_pid}{'bind'} = 1;
+ }
+ # go look at other params
+ return;
}
}
}
$cur_info{$t_pid}{query} =~ s/[\t\s\r\n;]+$//s;
# Replace bind parameters values in the query if any
- if (exists $cur_info{$t_pid}{parameters}) {
+ if (exists $cur_info{$t_pid}{parameters} && ($cur_info{$t_pid}{parameters} =~ /[,\s]*\$(\d+)\s=\s/)) {
my @t_res = split(/[,\s]*\$(\d+)\s=\s/, $cur_info{$t_pid}{parameters});
shift(@t_res);
for (my $i = 0 ; $i < $#t_res ; $i += 2) {
$cur_info{$t_pid}{query} =~ s/\$$t_res[$i]\b/$t_res[$i+1]/s;
}
+ } else {
+ # parameters from EXECUTE statements
+ my @t_res = split(/[\s]*,[\s]*/, $cur_info{$t_pid}{parameters});
+ for (my $i = 0 ; $i <= $#t_res ; $i++) {
+ my $num = $i + 1;
+ $cur_info{$t_pid}{query} =~ s/\$$num\b/$t_res[$i]/s;
+ }
}
# We only process stored object with query here