Tim,
Again, Thanks, and I'll be doing a release tomorrow or this weekend at
latest.
Kind regareds,
Patrick
Tim Bunce wrote:
The DBD::mysql do() method doesn't set $dbh->{Statement} attribute.
This means:
a) using DBI::Profile doesn't give correct profile results for calls to do()
b) using ShowErrorStatement may report the wrong statement in the error message.
I've attached a patch, including a test.
Tim.
p.s. Until DBD::mysql gets patched here's a workaround for profiling:
if ($ENV{DBI_PROFILE}) {
# workaround bug in DBD::mysql where its own do() method doesn't set
$dbh->{Statement}
# if we're profiling the fallback to the DBI's own do metgod
require DBD::mysql;
no strict 'refs';
delete ${"DBD::mysql::db::"}{do};
}
------------------------------------------------------------------------
Only in DBD-mysql-4.001.timbunce1: Makefile
Only in DBD-mysql-4.001.timbunce1: blib
Only in DBD-mysql-4.001.timbunce1: dbdimp.o
Only in DBD-mysql-4.001.timbunce1: mysql.bs
Only in DBD-mysql-4.001.timbunce1: mysql.c
Only in DBD-mysql-4.001.timbunce1: mysql.o
diff -ur DBD-mysql-4.001/mysql.xs DBD-mysql-4.001.timbunce1/mysql.xs
--- DBD-mysql-4.001/mysql.xs 2007-01-08 00:39:05.000000000 +0000
+++ DBD-mysql-4.001.timbunce1/mysql.xs 2007-02-15 16:59:46.000000000 +0000
@@ -300,6 +300,8 @@
"mysql.xs do() use_server_side_prepare %d\n",
use_server_side_prepare);
+ hv_store((HV*)SvRV(dbh), "Statement", 9, SvREFCNT_inc(statement), 0);
+
if (use_server_side_prepare)
{
str_ptr= SvPV(statement, slen);
Only in DBD-mysql-4.001.timbunce1: mysql.xsi
Only in DBD-mysql-4.001.timbunce1: pm_to_blib
diff -ur DBD-mysql-4.001/t/20createdrop.t
DBD-mysql-4.001.timbunce1/t/20createdrop.t
--- DBD-mysql-4.001/t/20createdrop.t 2006-12-23 18:03:30.000000000 +0000
+++ DBD-mysql-4.001.timbunce1/t/20createdrop.t 2007-02-15 16:58:27.000000000
+0000
@@ -73,6 +73,12 @@
or DbiError($dbh->err, $dbh->errstr);
#
+ # ... check do() sets $dbh->{Statement}
+ #
+ Test($state or $dbh->{Statement} eq "DROP TABLE $table")
+ or DbiError(1, "do() didn't set Statement attribute");
+
+ #
# Finally disconnect.
#
Test($state or $dbh->disconnect())
Only in DBD-mysql-4.001.timbunce1/t: mysql.mtest
--
Patrick Galbraith, Senior Programmer
Grazr - Easy feed grazing and sharing
http://www.grazr.com
Satyam Eva Jayate - Truth Alone Triumphs
Mundaka Upanishad