I want to modify the queries of a running application so that what's passed to the database includes a comment that tells where in the Perl code the request originated. SQL::Library (or Data::Phrasebook) is a nice idea, but it solves a completely different problem.
Likewise, I don't want to step through my code in the debugger and modify queries by hand. Rather, this is a tedious task that I think the computer should do for me. More to the point, I can't sit at the debugger in production.
| [reply] |
Curently the DBI only defines two trace flags:
ALL - turn on all DBI and driver flags (not recommended)
SQL - trace SQL statements executed (not yet implemented)
Update: actually, I bet that turning on trace level 1 is pretty close to what you're asking for. It will echo your prepare statements (including the SQL), and label them with line number and file of your code:
$dbh->trace(1, $trace_log_file);
| [reply] [d/l] [select] |
| [reply] |
We're not planning to write everything to a log, but there's a "slow queries" log for when something takes too long, and I'd like those entries to have a little more information in them. Unfortunately, I can't always tell ahead of time which queries those will be, so I need to add my special bonus info to everything.
| [reply] |