[prev in list] [next in list] [prev in thread] [next in thread]
List: msql-mysql-modules
Subject: do() converts undef bound params to 0 for server side prepared statements
From: "Rob Mueller" <robm () fastmail ! fm>
Date: 2008-04-15 3:30:12
Message-ID: 112801c89ea9$05e7ad30$8900a8c0 () robmhp
[Download RAW message or body]
This 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_prepare=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=msql-mysql-modules@progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic