do() converts undef bound params to 0 for server side prepared statements
am 15.04.2008 05:30:12 von Rob MuellerThis is in DBD::mysql 4.006 and debian mysql client lib 5.0.32-7~bpo.1
---
#!/usr/bin/perl
use DBI;
use Data::Dumper;
my $dbh =
DBI->connect('dbi:mysql:fastmail:127.0.0.1;mysql_server_prep are=1', 'root',
'testpw');
$dbh->do('DROP TABLE IF EXISTS tmp_testnull');
$dbh->do('CREATE TABLE tmp_testnull (C1 int(11)) ENGINE=INNODB');
$dbh->do("INSERT INTO tmp_testnull values (?)", {}, 1);
$dbh->do("INSERT INTO tmp_testnull values (?)", {}, 2);
$dbh->do("INSERT INTO tmp_testnull values (?)", {}, undef);
print Dumper $dbh->selectcol_arrayref("SELECT c1 FROM tmp_testnull");
---
Output:
---
$VAR1 = [
1,
2,
0
];
---
Expected output:
---
$VAR1 = [
1,
2,
undef
];
---
Replacing do() with a prepare() + excute() call fixed the problem, or
changing the connect string to mysql_server_prepare=0.
I'm surprised no one else ran into this bug yet...
Rob
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org