Hi Patrick,

Patrick Galbraith wrote:

>Dear DBI/DBD::mysql developers,
>
>DBD::mysql 2.9007 and 2.9015_3 are now available via CPAN!
>
Thanks for the new releases!

Please find attached two patches, one for each release.

patch-stable.txt patches 2.9007 to remove all reference to mysql_config 
on Win32 where (AFAICT) mysql_config doesn't exist.  If this patch looks 
good then it would need applying to 2.9015_3 too, of course.  (The patch 
isn't quite as scary as diff makes it look -- it basically just moves 
the two big mysql_config chunks into "if (not Win32) { ... }" blocks.)

patch-dev.txt patches 2.9015_3 so that it builds on Win32.  This is 
largely what I sent you before, but incorporates a couple of further 
suggestions that were made at the time, namely: use "longlong" in 
my_global.h instead of "long long", and use Perl_ibcmp() instead of 
"strncasecmp".  This is by no means perfect (pulling in my_global.h 
causes a bunch of warnings about macro redefinition clashes with Perl 
header files, and there are issues with where Perl_ibcmp() gets the THX 
from in threaded perls), but it at least gets things building on Win32 
with non-threaded perl, which is all that DBI really supports anyway.

One last thing:  Dare I mention UTF-8 again?  Are there any plans to 
have DBD-mysql access MySQL's new character set functionality, or at 
least an option to have Perl's utf8 flag set on UTF-8 data?  Rudy did 
produce a simplistic patch along the latter lines once, but it never got 
released.  It would be an extermely useful feature to have.

Cheers,
- Steve


------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender 
immediately.  The unauthorized use, disclosure, copying or alteration of this 
message is strictly forbidden.  Note that any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of Radan Computational Ltd.  The recipient(s) of this message should 
check it and any attached files for viruses: Radan Computational will accept no 
liability for any damage caused by any virus transmitted by this email.
diff -ruN DBD-mysql-2.9015_3.orig/dbdimp.c DBD-mysql-2.9015_3/dbdimp.c
--- DBD-mysql-2.9015_3.orig/dbdimp.c    2005-04-22 05:14:08.000000000 +0100
+++ DBD-mysql-2.9015_3/dbdimp.c 2005-04-28 11:37:13.551556400 +0100
@@ -491,7 +491,7 @@
     if (! limit_flag)
     {
       if ((*statement_ptr == 'l' || *statement_ptr == 'L') &&
-         !strncasecmp(statement_ptr+1, "imit", 4))
+         !Perl_ibcmp(pTHX_ statement_ptr+1, "imit", 4))
         limit_flag = 1;
     }
     switch (*statement_ptr)
@@ -2103,10 +2103,10 @@
     for ( i = 0; i < statement_length - 1; i++) {
       searchptr= &statement[i];
       /* prepared statements for SHOW commands are not supported */
-      if (!strncasecmp(searchptr, "SHOW ", 5))
+      if (!Perl_ibcmp(pTHX_ searchptr, "SHOW ", 5))
         imp_sth->use_server_side_prepare = 0;
       /* if there is a 'limit' in the statement... */
-      if (!limit_flag && !strncasecmp(searchptr, "limit ", 6))
+      if (!limit_flag && !Perl_ibcmp(pTHX_ searchptr, "limit ", 6))
       {
         limit_flag = 1;
         i += 6;
@@ -2152,7 +2152,7 @@
   */
 
     /* this is a better way to do this */
-  if ( !strncasecmp(statement, "listfields ", 11) && 
imp_sth->use_server_side_prepare )
+  if ( !Perl_ibcmp(pTHX_ statement, "listfields ", 11) && 
imp_sth->use_server_side_prepare )
   {
     if (dbis->debug >= 2)
       PerlIO_printf(DBILOGFP, "\"listfields\" Statement: %s\n setting 
use_server_side_prepare to 0\n", statement);
@@ -2295,7 +2295,7 @@
     *result= NULL;
   }
 
-  if (slen >= 11 && !strncasecmp(sbuf, "listfields ", 11))
+  if (slen >= 11 && !Perl_ibcmp(pTHX_ sbuf, "listfields ", 11))
   {
     /* remove pre-space */
     slen -= 10;
@@ -2703,6 +2703,9 @@
   AV *av;
   MYSQL_ROW cols;
   unsigned long* lengths;
+  int rc;
+  imp_sth_fbh_t * fbh;   
+  MYSQL_BIND *bind;
 
 #if MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
   if (imp_sth->use_server_side_prepare)
@@ -2745,9 +2748,6 @@
   }
 
 #if MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
-  int rc;
-  imp_sth_fbh_t * fbh;   
-  MYSQL_BIND *bind;
   if (imp_sth->use_server_side_prepare)
   {
     if (dbis->debug >= 2)
diff -ruN DBD-mysql-2.9015_3.orig/dbdimp.h DBD-mysql-2.9015_3/dbdimp.h
--- DBD-mysql-2.9015_3.orig/dbdimp.h    2005-04-22 23:27:32.000000000 +0100
+++ DBD-mysql-2.9015_3/dbdimp.h 2005-04-28 11:17:19.393763900 +0100
@@ -19,7 +19,8 @@
  */
 #include <DBIXS.h>  /* installed by the DBI module                        */
 #include <mysql.h>  /* Comes with MySQL-devel */
-#include <mysqld_error.h>  /* Comes MySQL */
+#include <mysqld_error.h>  /* Comes with MySQL */
+#include <my_global.h>  /* Comes with MySQL */
 #include <errmsg.h> /* Comes with MySQL-devel */
 
 /*
@@ -173,7 +174,7 @@
     char           * data;
     double        ddata;
     long          ldata;
-    long long     lldata;
+    longlong      lldata;
 
 } imp_sth_fbh_t;
 
diff -ruN DBD-mysql-2.9007.orig/Makefile.PL DBD-mysql-2.9007/Makefile.PL
--- DBD-mysql-2.9007.orig/Makefile.PL   2005-04-05 00:07:36.000000000 +0100
+++ DBD-mysql-2.9007/Makefile.PL        2005-04-28 11:52:14.603454700 +0100
@@ -49,36 +49,39 @@
 
 my $source = {};
 
-#Check for mysql_config first
-$source->{'mysql_config'}="guessed";
-if ($opt->{'mysql_config'})
-{  
-  if (-f $opt->{'mysql_config'})
-  {
-    $source->{'mysql_config'} = "Users choice";
-  }
-  else
-  {
-    print <<"MSG";
-
-Specified mysql configuration script '$opt->{'mysql_config'}' doesn't exist. 
-Please check path/permissions. Will try to use default mysql_config 
-script found through PATH.
+if ($^O !~ /mswin32/i)
+{
+  #Check for mysql_config first
+  $source->{'mysql_config'}="guessed";
+  if ($opt->{'mysql_config'})
+  {  
+    if (-f $opt->{'mysql_config'})
+    {
+      $source->{'mysql_config'} = "Users choice";
+    }
+    else
+    {
+      print <<"MSG";
+  
+  Specified mysql configuration script '$opt->{'mysql_config'}' doesn't exist. 
+  Please check path/permissions. Will try to use default mysql_config 
+  script found through PATH.
 MSG
-    $opt->{'mysql_config'}= "mysql_config";
+      $opt->{'mysql_config'}= "mysql_config";
+    }
   }
-}
-else
-{
-  if (! `mysql_config`)
+  else
   {
-    print <<MSG;
-
-Cannot find the file 'mysql_config'! Your execution PATH doesn't seem 
-not contain the path to mysql_config. Resorting to guessed values!
+    if (! `mysql_config`)
+    {
+      print <<MSG;
+  
+  Cannot find the file 'mysql_config'! Your execution PATH doesn't seem 
+  not contain the path to mysql_config. Resorting to guessed values!
 MSG
+    }
+    $opt->{'mysql_config'} = "mysql_config";
   }
-  $opt->{'mysql_config'} = "mysql_config";
 }
 
 foreach my $key (qw/testdb testhost testuser testpassword testsocket 
@@ -183,9 +186,11 @@
 Possible options are:
 
   --cflags=<flags>       Use <flags> for running the C compiler; defaults
-                         to the value of "mysql_config --cflags"
+                         to the value of "mysql_config --cflags" or a guessed
+                         value
   --libs=<libs>          Use <libs> for running the linker; defaults
-                         to the value of "mysql_config --libs"
+                         to the value of "mysql_config --libs" or a guessed
+                         value
   --testdb=<db>          Use the database <db> for running the test suite;
                          defaults to $TESTDB
   --testuser=<user>      Use the username <user> for running the test suite;
@@ -198,6 +203,7 @@
                          by default the port number is choosen from the
                          mysqlclient library
   --mysql_config=<path>  Specify <path> for mysql_config script
+                         (Not supported on Win32)
   --nocatchstderr        Supress using the "myld" script that redirects
                          STDERR while running the linker.
   --nofoundrows          Change the behavoiur of \$sth->rows() so that it
@@ -207,7 +213,8 @@
   --help                 Print this message and exit
 
 All options may be configured on the command line. If they are
-not present on the command line, then mysql_config is called:
+not present on the command line, then mysql_config is called (if
+it can be found):
 
   mysql_config --cflags
   mysql_config --libs
@@ -241,40 +248,43 @@
     return;
   }
 
-  # First try to get options values from mysql_config
-  my $command = $opt->{'mysql_config'} . " --$param";
-  eval 
-  {
-    open(PIPE, "$command |") or die "Can't find mysql_config.";
-  };
-
-  if (!$@)
+  if ($^O !~ /mswin32/i)
   {
-    my $str = "";
-    while (defined(my $line = <PIPE>)) 
+    # First try to get options values from mysql_config
+    my $command = $opt->{'mysql_config'} . " --$param";
+    eval 
     {
-      $str .= $line;
+      open(PIPE, "$command |") or die "Can't find mysql_config.";
+    };
+  
+    if (!$@)
+    {
+      my $str = "";
+      while (defined(my $line = <PIPE>)) 
+      {
+        $str .= $line;
+      }
+      if ($str ne ""  &&  $str !~ /Options:/) 
+      {
+        $str =~ s/\s+$//s;
+        $str =~ s/^\s+//s;
+  
+        # Unfortunately ExtUtils::MakeMaker doesn't deal very well
+        # with -L'...'
+        $str =~ s/\-L\'(.*?)\'/-L$1/sg;
+        $str =~ s/\-L\"(.*?)\"/-L$1/sg;
+  
+        $opt->{$param} = $str;
+        $source->{$param} = "mysql_config";
+        return;
+      }
     }
-    if ($str ne ""  &&  $str !~ /Options:/) 
+    else
     {
-      $str =~ s/\s+$//s;
-      $str =~ s/^\s+//s;
-
-      # Unfortunately ExtUtils::MakeMaker doesn't deal very well
-      # with -L'...'
-      $str =~ s/\-L\'(.*?)\'/-L$1/sg;
-      $str =~ s/\-L\"(.*?)\"/-L$1/sg;
-
-      $opt->{$param} = $str;
-      $source->{$param} = "mysql_config";
-      return;
+      # need to do something here...
+      #print "Can't find mysql_config. Use --mysql_config option to specify 
where mysql_config is located\n";
     }
   }
-  else
-  {
-    # need to do something here...
-    #print "Can't find mysql_config. Use --mysql_config option to specify 
where mysql_config is located\n";
-  }
 
   # Ok, mysql_config doesn't work. We need to do our best
   if ($param eq "nocatchstderr" || $param eq "nofoundrows")

Reply via email to