Subject: | do() method doesn't set $dbh->{Statement} |
do() method doesn't set $dbh->{Statement} which means that
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.
Subject: | DBD-mysql-4.001.do-statement.patch |
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