New test for dbd::mysql demonstrating that once an execute failsall other executes on same statement
am 30.03.2006 01:10:06 von Martin.EvansPatch against dbd::mysql 3.0002_4 which demonstrates that if you prepare
a statement and execute multiple times then as soon as one execute fails
all subsequent executes fail. This obviously effects execute_array in
particular as all the tuple_status values from the failed execute
onwards show an error.
I wasn't completely sure how to avoid tests which are supposed to fail
producing an error and failing the test. It appears turning PrintError
off for that test does what is required.
I have as yet, no solution to the problem.
Martin
--- Makefile.PL Thu Mar 30 00:03:18 2006
+++ Makefile.PL.mine Thu Mar 30 00:02:46 2006
@@ -305,6 +305,9 @@
't/insertid.t' => { filename =>
'mysqlEmb/t/insertid.t',
makedir => 'mysqlEmb/t'
},
+ 't/pexecute.t' => { filename =>
'mysqlEmb/t/pexecute.t',
+
makedir => 'mysqlEmb/t'
+ },
't/mysql.t' => { filename => 'mysqlEmb/t/mysql.t',
makedir => 'mysqlEmb/t'
},
--- /dev/null Tue Sep 11 15:18:33 2001
+++ t/pexecute.t Thu Mar 30 00:01:25 2006
@@ -0,0 +1,50 @@
+# -*- cperl -*-
+
+use strict;
+use DBI ();
+
+use vars qw($test_dsn $test_user $test_password $state);
+require "t/lib.pl";
+
+while (Testing()) {
+ my ($dbh, $sth);
+ #
+ # Connect to the database
+ Test($state or
+ ($dbh = DBI->connect($test_dsn, $test_user, $test_password,
+ {RaiseError => 0})));
+
+ #
+ # Find a possible new table name
+ #
+ my $table = "";
+ Test($state or
+ ($table = FindNewTable($dbh)));
+ #
+ # Create a new table
+ #
+ my $q = <<"QUERY";
+CREATE TABLE $table (id INTEGER PRIMARY KEY NOT NULL,
+ name VARCHAR(64))
+QUERY
+ Test($state or $dbh->do($q));
+
+ #
+ # Insert a row
+ #
+ $q = "INSERT INTO $table (id, name) VALUES (?,?)";
+ Test($state or ($sth = $dbh->prepare($q)));
+ Test($state or $sth->execute(1, "Jocken"));
+ $sth->{PrintError} = 0;
+ Test($state or !($sth->execute(1, "Jochen")));
+ $sth->{PrintError} = 1;
+ Test($state or $sth->execute(2, "Jochen"));
+
+ #
+ # Drop the table
+ Test($state or $dbh->do("DROP TABLE $table"));
+
+ #
+ # Close the database connection
+ Test($state or ($dbh->disconnect() or 1));
+}