r34291 - in /branches/upstream/libdbd-mysql-perl/current: ChangeLog INSTALL.html MANIFEST META.yml dbdimp.c eg/._bug14979.pl eg/._bug21028.pl lib/DBD/mysql.pm lib/DBD/mysql/GetInfo.pm t/40server_prepare.t t/51bind_type_guessing.t t/mysql.mtest

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Tue Apr 28 21:45:39 UTC 2009


Author: eloy
Date: Tue Apr 28 21:45:34 2009
New Revision: 34291

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=34291
Log:
[svn-upgrade] Integrating new upstream version, libdbd-mysql-perl (4.011)

Added:
    branches/upstream/libdbd-mysql-perl/current/t/51bind_type_guessing.t   (with props)
Removed:
    branches/upstream/libdbd-mysql-perl/current/eg/._bug14979.pl
    branches/upstream/libdbd-mysql-perl/current/eg/._bug21028.pl
Modified:
    branches/upstream/libdbd-mysql-perl/current/ChangeLog
    branches/upstream/libdbd-mysql-perl/current/INSTALL.html
    branches/upstream/libdbd-mysql-perl/current/MANIFEST
    branches/upstream/libdbd-mysql-perl/current/META.yml
    branches/upstream/libdbd-mysql-perl/current/dbdimp.c
    branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql.pm
    branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql/GetInfo.pm
    branches/upstream/libdbd-mysql-perl/current/t/40server_prepare.t
    branches/upstream/libdbd-mysql-perl/current/t/mysql.mtest

Modified: branches/upstream/libdbd-mysql-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/ChangeLog?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/ChangeLog (original)
+++ branches/upstream/libdbd-mysql-perl/current/ChangeLog Tue Apr 28 21:45:34 2009
@@ -1,3 +1,13 @@
+2009-04-13 Patrick Galbraith <patg at patg.net> (4.011)
+* Renamed unsafe_bind_type_guessing, fixed some of the logic. This
+can be used to deal with bug 43822 
+(https://rt.cpan.org/Ticket/Display.html?id=43822)
+* Patch from Daniel Frett (daniel Dot frett At ccci Dot org) to fix 
+issue of binding sever side integer parameters (server-side prepare
+statements) resulting in corrupt data, bug 42723 
+(https://rt.cpan.org/Ticket/Display.html?id=42723)
+* Updated documentation, cruft cleanup (as always)
+
 2008-10-24 Patrick Galbraith <patg at patg.net> (4.010)
 * Fix to dbd_bind_ph() for uninitialized value 'buffer_length'
 thanks for bug report and patch from Askniel.com (thanks!)
@@ -1092,7 +1102,7 @@
 	* lib/Msql/Statement.pm: Fixed use of Msql::TEXT_TYPE without
 	  checking whether we are running Msql 1.
 
-$Id: ChangeLog 11993 2008-10-22 00:49:10Z capttofu $
+$Id: ChangeLog 12696 2009-04-14 02:28:12Z capttofu $
 
 DBD::mysql for DBI - Written by Jochen Wiedmann <joe at ispsoft.de>
 

Modified: branches/upstream/libdbd-mysql-perl/current/INSTALL.html
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/INSTALL.html?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/INSTALL.html (original)
+++ branches/upstream/libdbd-mysql-perl/current/INSTALL.html Tue Apr 28 21:45:34 2009
@@ -4,7 +4,7 @@
 <head>
 <title>INSTALL - How to install and configure DBD::mysql</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
-<link rev="made" href="mailto:_www at b70.apple.com" />
+<link rev="made" href="mailto:root at localhost" />
 </head>
 
 <body style="background-color: white">

Modified: branches/upstream/libdbd-mysql-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/MANIFEST?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/MANIFEST (original)
+++ branches/upstream/libdbd-mysql-perl/current/MANIFEST Tue Apr 28 21:45:34 2009
@@ -41,6 +41,7 @@
 t/42bindparam.t
 t/50chopblanks.t
 t/50commit.t
+t/51bind_type_guessing.t
 t/55utf8.t
 t/60leaks.t
 t/65types.t

Modified: branches/upstream/libdbd-mysql-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/META.yml?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/META.yml (original)
+++ branches/upstream/libdbd-mysql-perl/current/META.yml Tue Apr 28 21:45:34 2009
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         DBD-mysql
-version:      4.010
+version:      4.011
 version_from: lib/DBD/mysql.pm
 installdirs:  site
 requires:

Modified: branches/upstream/libdbd-mysql-perl/current/dbdimp.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/dbdimp.c?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/dbdimp.c (original)
+++ branches/upstream/libdbd-mysql-perl/current/dbdimp.c Tue Apr 28 21:45:34 2009
@@ -1,14 +1,14 @@
 /*
  *  DBD::mysql - DBI driver for the mysql database
  *
- *  Copyright (c) 2005       Patrick Galbraith
- *  Copyright (c) 2003       Rudolf Lippan
+ *  Copyright (c) 2005-2009 Patrick Galbraith
+ *  Copyright (c) 2003-2005  Rudolf Lippan
  *  Copyright (c) 1997-2003  Jochen Wiedmann
  *
  *  You may distribute this under the terms of either the GNU General Public
  *  License or the Artistic License, as specified in the Perl README file.
  *
- *  $Id: dbdimp.c 11993 2008-10-22 00:49:10Z capttofu $
+ *  $Id: dbdimp.c 12689 2009-04-13 19:19:25Z capttofu $
  */
 
 
@@ -20,7 +20,6 @@
 #include "dbdimp.h"
 
 #if defined(WIN32)  &&  defined(WORD)
-    /*  Don't exactly know who's responsible for defining WORD ... :-(  */
 #undef WORD
 typedef short WORD;
 #endif
@@ -456,7 +455,7 @@
       /* of mysql.xs hardcodes all types to SQL_VARCHAR */
       if (!ph->type)
       {
-        if ( bind_type_guessing > 1 )
+        if (bind_type_guessing)
         {
           valbuf= SvPV(ph->value, vallen);
           ph->type= SQL_INTEGER;
@@ -466,8 +465,6 @@
               ph->type= SQL_VARCHAR;
           }
         }
-        else if (bind_type_guessing)
-          ph->type= SvNIOK(ph->value) ? SQL_INTEGER : SQL_VARCHAR;
         else
           ph->type= SQL_VARCHAR;
       }
@@ -2119,8 +2116,8 @@
   else if (kl == 20 && strEQ(key, "mysql_server_prepare"))
     imp_dbh->use_server_side_prepare=SvTRUE(valuesv);
 
-  else if (kl == 31 && strEQ(key,"mysql_unsafe_bind_type_guessing"))
-	imp_dbh->bind_type_guessing = SvIV(valuesv);
+  else if (kl == 24 && strEQ(key,"mysql_bind_type_guessing"))
+    imp_dbh->bind_type_guessing = SvIV(valuesv);
   /*HELMUT */
 #if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
   else if (kl == 17 && strEQ(key, "mysql_enable_utf8"))
@@ -2198,9 +2195,9 @@
     if (kl == strlen("auto_reconnect") && strEQ(key, "auto_reconnect"))
       result= sv_2mortal(newSViv(imp_dbh->auto_reconnect));
     break;
-  case 'u':
-    if (kl == strlen("unsafe_bind_type_guessing") &&
-        strEQ(key, "unsafe_bind_type_guessing"))
+  case 'b':
+    if (kl == strlen("bind_type_guessing") &&
+        strEQ(key, "bind_type_guessing"))
       result = sv_2mortal(newSViv(imp_dbh->bind_type_guessing));
     break;
   case 'e':
@@ -2807,7 +2804,7 @@
                                        int use_mysql_use_result
                                       )
 {
-  bool bind_type_guessing;
+  bool bind_type_guessing= 0;
   STRLEN slen;
   char *sbuf = SvPV(statement, slen);
   char *table;
@@ -2832,10 +2829,10 @@
   {
     D_imp_dbh(h);
     /* if imp_dbh is not available, it causes segfault (proper) on OpenBSD */
-    if (imp_dbh)
+    if (imp_dbh && imp_dbh->bind_type_guessing)
       bind_type_guessing= imp_dbh->bind_type_guessing;
     else
-      bind_type_guessing=0;
+      bind_type_guessing= 0;
   }
   /* h is a sth */
   else
@@ -4322,8 +4319,15 @@
           break;
       }
 
-      buffer= SvPV(imp_sth->params[idx].value, slen);
-      buffer_length= slen;
+      if (buffer_type == MYSQL_TYPE_STRING || buffer_type == MYSQL_TYPE_BLOB)
+      {
+        buffer= SvPV(imp_sth->params[idx].value, slen);
+        buffer_length= slen;
+        if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
+          PerlIO_printf(DBILOGFP,
+                        " SCALAR type %d ->length %d<- IS A STRING or BLOB\n",
+                        sql_type, buffer_length);
+      }
     }
     else
     {

Modified: branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql.pm?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql.pm (original)
+++ branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql.pm Tue Apr 28 21:45:34 2009
@@ -9,7 +9,7 @@
 use Carp ();
 @ISA = qw(DynaLoader);
 
-$VERSION = '4.010';
+$VERSION = '4.011';
 
 bootstrap DBD::mysql $VERSION;
 
@@ -1276,6 +1276,33 @@
 
 This option is experimental and may change in future versions.
 
+=item mysql_bind_type_guessing
+
+This attribute causes the driver (emulated prepare statements) 
+to attempt to guess if a value being bound is a numeric value,
+and if so, doesn't quote the value.  This was created by 
+Dragonchild and is one way to deal with the performance issue 
+of using quotes in a statement that is inserting or updating a
+large numeric value. This was previously called 
+C<unsafe_bind_type_guessing> because it is experimental. I have 
+successfully run the full test suite with this option turned on,
+the name can now be simply C<mysql_bind_type_guessing>. 
+
+See bug: https://rt.cpan.org/Ticket/Display.html?id=43822
+
+C<mysql_bind_type_guessing> can be turned on via 
+
+ - through DSN 
+
+  my $dbh= DBI->connect('DBI:mysql:test', 'username', 'pass',
+  { mysql_bind_type_guessing => 1})
+
+  - OR after handle creation
+
+  $dbh->{mysql_bind_type_guessing} = 1;
+
+
+
 =head1 STATEMENT HANDLES
 
 The statement handles of DBD::mysql support a number

Modified: branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql/GetInfo.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql/GetInfo.pm?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql/GetInfo.pm (original)
+++ branches/upstream/libdbd-mysql-perl/current/lib/DBD/mysql/GetInfo.pm Tue Apr 28 21:45:34 2009
@@ -4,9 +4,9 @@
 #
 #
 # Generated by DBI::DBD::Metadata
-# $Author: capttofu $  <-- the person to blame
-# $Revision: 8435 $
-# $Date: 2006-12-23 14:03:49 -0500 (Sat, 23 Dec 2006) $
+# $Author: rlippan $  <-- the person to blame
+# $Revision: 1108 $
+# $Date: 2003-03-31 20:17:27 -0500 (Mon, 31 Mar 2003) $
 
 use strict;
 use DBD::mysql;

Modified: branches/upstream/libdbd-mysql-perl/current/t/40server_prepare.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/t/40server_prepare.t?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/t/40server_prepare.t (original)
+++ branches/upstream/libdbd-mysql-perl/current/t/40server_prepare.t Tue Apr 28 21:45:34 2009
@@ -19,7 +19,7 @@
 if ($@) {
     plan skip_all => "ERROR: $@. Can't continue test";
 }
-plan tests => 10; 
+plan tests => 21; 
 
 ok(defined $dbh, "connecting");
 
@@ -30,9 +30,10 @@
 #
 ok($dbh->do(qq{CREATE TABLE t1 (id INT, num DOUBLE)}), "creating table");
 
-ok($dbh->do(qq{INSERT INTO t1 VALUES (1,3.0),(2,-4.5)}), "loading data");
+my $sth;
+ok($sth= $dbh->prepare(qq{INSERT INTO t1 VALUES (?,?),(?,?)}), "loading data");
+ok($sth->execute(1, 3.0, 2, -4.5));
 
-my $sth;
 ok ($sth= $dbh->prepare("SELECT num FROM t1 WHERE id = ? FOR UPDATE"));
 
 ok ($sth->bind_param(1, 1), "binding parameter");
@@ -45,4 +46,26 @@
 
 ok ($dbh->do(qq{DROP TABLE t1}), "cleaning up");
 
+#
+# Bug #42723: Binding server side integer parameters results in corrupt data
+#
+ok($dbh->do(qq{DROP TABLE IF EXISTS t2}), "making slate clean");
+
+ok($dbh->do(q{CREATE TABLE `t2` (`i` int,`si` smallint,`ti` tinyint,`bi` bigint)}), "creating test table");
+
+my $sth2;
+ok($sth2 = $dbh->prepare('INSERT INTO t2 VALUES (?,?,?,?)'));
+
+#bind test values
+ok($sth2->bind_param(1, 101, DBI::SQL_INTEGER), "binding int");
+ok($sth2->bind_param(2, 102, DBI::SQL_SMALLINT), "binding smallint");
+ok($sth2->bind_param(3, 103, DBI::SQL_TINYINT), "binding tinyint");
+ok($sth2->bind_param(4, 104, DBI::SQL_INTEGER), "binding bigint");
+
+ok($sth2->execute(), "inserting data");
+
+is_deeply($dbh->selectall_arrayref('SELECT * FROM t2'), [[101, 102, 103, 104]]);
+
+ok ($dbh->do(qq{DROP TABLE t2}), "cleaning up");
+
 $dbh->disconnect();

Added: branches/upstream/libdbd-mysql-perl/current/t/51bind_type_guessing.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/t/51bind_type_guessing.t?rev=34291&op=file
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/t/51bind_type_guessing.t (added)
+++ branches/upstream/libdbd-mysql-perl/current/t/51bind_type_guessing.t Tue Apr 28 21:45:34 2009
@@ -1,0 +1,65 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use DBI;
+use DBI::Const::GetInfoType;
+use Test::More;
+use lib 't', '.';
+require 'lib.pl';
+
+use vars qw($test_dsn $test_user $test_password $table);
+
+my $dbh;
+eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
+                      { RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
+if ($@) {
+    plan skip_all => 
+        "ERROR: $DBI::errstr. Can't continue test";
+}
+plan tests => 16; 
+
+ok $dbh->do("DROP TABLE IF EXISTS $table"), "drop table if exists $table";
+
+my $create= <<"EOTABLE";
+create table $table (
+    id bigint unsigned not null default 0
+    )
+EOTABLE
+
+
+ok $dbh->do($create), "creating table";
+
+my $statement= "insert into $table (id) values (?)";
+
+my $sth1;
+ok $sth1= $dbh->prepare($statement);
+
+my $rows;
+ok $rows= $sth1->execute('9999999999999999');
+cmp_ok $rows, '==',  1;
+
+$statement= "update $table set id = ?";
+my $sth2;
+ok $sth2= $dbh->prepare($statement);
+
+ok $rows= $sth2->execute('9999999999999998');
+cmp_ok $rows, '==',  1;
+
+$dbh->{mysql_bind_type_guessing}= 1;
+ok $rows= $sth1->execute('9999999999999997');
+cmp_ok $rows, '==',  1;
+
+$statement= "update $table set id = ? where id = ?";
+
+ok $sth2= $dbh->prepare($statement);
+ok $rows= $sth2->execute('9999999999999996', '9999999999999997');
+
+my $retref;
+ok $retref= $dbh->selectall_arrayref("select * from $table");
+
+cmp_ok $retref->[0][0], '==', 9999999999999998;
+cmp_ok $retref->[1][0], '==', 9999999999999996;
+
+ok $dbh->disconnect;

Propchange: branches/upstream/libdbd-mysql-perl/current/t/51bind_type_guessing.t
------------------------------------------------------------------------------
    svn:executable = *

Modified: branches/upstream/libdbd-mysql-perl/current/t/mysql.mtest
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdbd-mysql-perl/current/t/mysql.mtest?rev=34291&op=diff
==============================================================================
--- branches/upstream/libdbd-mysql-perl/current/t/mysql.mtest (original)
+++ branches/upstream/libdbd-mysql-perl/current/t/mysql.mtest Tue Apr 28 21:45:34 2009
@@ -3,13 +3,13 @@
          'embedded' => '',
          'ssl' => 0,
          'nocatchstderr' => 0,
-         'libs' => '-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm',
+         'libs' => '-rdynamic -L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm',
          'testhost' => '',
          'nofoundrows' => 0,
          'testdb' => 'test',
-         'cflags' => '-I/usr/local/mysql/include/mysql -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL',
+         'cflags' => '-I/usr/local/mysql/include/mysql -DUNIV_LINUX',
          'testuser' => 'root',
-         'testpassword' => '',
+         'testpassword' => 'root',
          'testsocket' => ''
        };
 $::test_host = $opt->{'testhost'};




More information about the Pkg-perl-cvs-commits mailing list