in reply to Re^2: Intercepting critical SQL inside DBI.pm
in thread Intercepting critical SQL inside DBI.pm
Writing a proxy object for DBI is not enough as you have to write proxies for the database handle and database statement as well.
A very simple approach is to enable the tracing in DBI, by calling DBI->trace('2|SQL|2', 'c:/Temp/DBI-Trace.txt') or setting $ENV{DBI_TRACE}='2|SQL|2'. This still has the drawback of writing to the filehandle. YOu could then use a tied filehandle maybe to analyze the lines written to it and use caller() repeatedly to identify the place where the statement was created from (by looking for the first non-DBD, non-DBI package in the calltree).
The DBI documentation claims that this is only implemented by some DBDs, but maybe MySQL/MariaDB have that feature...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Intercepting critical SQL inside DBI.pm
by LanX (Saint) on Sep 16, 2022 at 16:18 UTC |