Subject: | Binding server side integer parameters results in corrupt data |
Date: | Fri, 23 Jan 2009 15:55:01 +0100 |
To: | bug-DBD-mysql [...] rt.cpan.org |
From: | Andreas Stahlbauer <andreas.stahlbauer [...] tngtech.com> |
Hi,
Server side prepared statements do not work in version 4.010 of
DBD::mysql correctly. Binded integer-parameters are not passed correctly
to the database if mysql_server_prepare is enabled (see below). Version
4.007 of the module works fine. Version 4.008 and 4.009 have not been
tested.
Thanks
Show quoted text
---------- Environment infos -----------
DBD::mysql, version 4.010
DBI, version 1.607
perl, v5.10.0 built for i486-linux-gnu-thread-multi
Linux myhost 2.6.27-7-generic #1 SMP Tue Nov 4 19:33:20 UTC 2008 i686
GNU/Linux
---------- Steps to reproduce ----------
Create the following table (used for testing):
CREATE TABLE `inttest` (
`fld_integer` int(11) DEFAULT NULL,
`fld_smallint` smallint(6) DEFAULT NULL,
`fld_tinyint` tinyint(4) DEFAULT NULL,
`fld_bigint` bigint(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Script that results in wrong data:
use strict;
use DBI;
use DBI qw(:sql_types);
# Using mysql_server_prepare!!!
my $dbh =
DBI->connect("DBI:mysql:dbname=testdb;host=127.0.0.1;port=3306;mysql_server_prepare=1",
"root", "") or die $!;
my $sth = $dbh->prepare("INSERT INTO inttest VALUES (?,?,?,?)");
$sth->bind_param(1, 101, SQL_INTEGER);
$sth->bind_param(2, 102, SQL_SMALLINT);
$sth->bind_param(3, 103, SQL_TINYINT);
$sth->bind_param(4, 104, SQL_BIGINT);
# This execute works fine, but does not insert the desired values!
# (using version 4.010 of the DBD::mysql; version 4.007 works fine in
this case!!!!)
#
# 3223601 is inserted instead of 101 (sql type INTEGER)
# 32767 is inserted instead of 102 (sql type SMALLINT)
# 127 is inserted instead of 103 (sql type TINYINT)
# 3420209 is inserted instead of 104 (sql type BIGINT)
#
$sth->execute() or die $!;