Patrick Galbraith wrote:

>On Apr 5, 2005, at 3:01 PM, Tim Bunce wrote:
>
>  
>
>>On Tue, Apr 05, 2005 at 11:46:21AM -0700, Patrick Galbraith wrote:
>>    
>>
>>>Steve,
>>>
>>>There is a version of DBD::mysql (2.9015) that does support
>>>placeholders in the server, via CVS (or I can package it  and send it
>>>to you). I would be glad to give you a version of it to try out, and I
>>>think it may deal with your problem better than the current driver
>>>(which emulates it) the new driver uses the database to handle
>>>placeholders. I have tested this code on numerous SQL statements with
>>>placeholders, and it works great.
>>>      
>>>
>>That's great. But the behavior when placeholders are emulated[1]
>>still could be easily improved with a one-line code change.
>>
>>    
>>
>
>Tim,
>
>I'll fix this ;)
>
>  
>
>>Tim.
>>
>>[1] I'm presuming that the latest version still lets you use
>>emulated placeholders either optionally or when talking to old
>>servers. Is that right?
>>    
>>
>
>Yes, if the version of mysql is less than 4.1.3, it doesn't even 
>compile in server-side-prepare. With a server > 4.1.3,  one sets  
>'mysql_server_prepare=1'  in the DSN to enable it, and without it, it 
>defaults to old behaviour.
>
Is the looks_like_number() issue solved already in the dev version?

I just checked out the Dev-2_9 branch.  It took a bit of hacking around 
to get it to build on Win32, and even then a load of tests failed, but 
when I re-tried the sample program that I posted previously it worked 
fine even without "mysql_server_prepare=1" in the DSN.  trace() shows 
that the SQL statement now contains 1 rather than 1.#INF or '1.#INF':

UPDATE foo SET str = 'one', num = 1 WHERE id = 1

Is this what you expected?

Trying again with "mysql_server_prepare=1" in the DSN, the program now 
says "UPDATE affected 25388176 rows" (!), but actually didn't change any 
rows.  This is presumably not what you expected, but may very well be 
due to the crude hacking that I did to make it build.

Do you have a Win32 environment that you could try this out on?

If not, here are the issues that I encountered:

- long long and uint are unknown; I used LONGLONG and UINT instead;
- strncasecmp is unknown; I used strncmp instead;
- dbdimp.h line 257 has a syntax error;
- dbdimp.c contains declarations after code at line 2823.

Attached is a patch of the changes that I made.

The test failures were as follows:

C:\Temp\modules\DBD-mysql>nmake test

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

        C:\perl5\bin\perl.exe "-MExtUtils::Command::MM" "-e" 
"test_harness(0, 'b
lib\lib', 'blib\arch')" t/*.t
t/00base...........ok
t/10dsnlist........ok
t/20createdrop.....ok
t/30insertfetch....ok
t/35limit..........DBD::mysql::st execute failed: You have an error in 
your SQL
syntax; check the manual that corresponds to your MySQL server version 
for the r
ight syntax to use near ''20', '50'' at line 1 at t/35limit.t line 106.
DBD::mysql::st fetchall_arrayref failed: fetch() without execute() at 
t/35limit.
t line 110.
t/35limit..........FAILED tests 107-109
        Failed 3/113 tests, 97.35% okay
t/35prepare........ok
t/40bindparam......ok
t/40blobs..........ok
t/40listfields.....Use of uninitialized value in numeric eq (==) at 
t/40listfiel
ds.t line 132.
t/40listfields.....ok
t/40nulls..........ok
t/40numrows........ok
t/50chopblanks.....ok
t/50commit.........ok
t/60leaks..........skipped
        all skipped: $ENV{SLOW_TESTS} is not set or Proc::ProcessTable 
not insta
lled
t/ak-dbd...........ok 12/90DBD::mysql::st execute failed: You have an 
error in y
our SQL syntax; check the manual that corresponds to your MySQL server 
version f
or the right syntax to use near 'LISTFIELDS testae' at line 1 at 
t/ak-dbd.t line
 143.
t/ak-dbd...........FAILED test 13
        Failed 1/90 tests, 98.89% okay
t/akmisc...........ok 56/351DBD::mysql::st execute failed: You have an 
error in
your SQL syntax; check the manual that corresponds to your MySQL server 
version
for the right syntax to use near 'LISTFIELDS testae' at line 1 at 
C:\Temp\module
s\DBD-mysql\blib\lib/Mysql.pm line 175.
Can't call method "name" on an undefined value at t/akmisc.t line 660.
t/akmisc...........dubious
        Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 73-351
        Failed 279/351 tests, 20.51% okay
t/dbdadmin.........ok
t/insertid.........ok
t/mysql............DBD::mysql::st execute failed: Table 'table01' 
already exists
 at C:\Temp\modules\DBD-mysql\blib\lib/Mysql.pm line 175.
DBD::mysql::st execute failed: You have an error in your SQL syntax; 
check the m
anual that corresponds to your MySQL server version for the right syntax 
to use
near 'LISTFIELDS TABLE02' at line 1 at 
C:\Temp\modules\DBD-mysql\blib\lib/Mysql.
pm line 175.
Can't call method "name" on an undefined value at t/mysql.t line 502.
t/mysql............dubious
        Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 43-68
        Failed 26/68 tests, 61.76% okay
t/mysql2...........ok
Failed Test Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/35limit.t              113    3   2.65%  107-109
t/ak-dbd.t                90    1   1.11%  13
t/akmisc.t     2   512   351  557 158.69%  73-351
t/mysql.t      2   512    68   52  76.47%  43-68
1 test skipped.
Failed 4/20 test scripts, 80.00% okay. 309/909 subtests failed, 66.01% okay.
NMAKE : fatal error U1077: 'C:\perl5\bin\perl.exe' : return code '0xff'
Stop.

If you're able to address any of these issues and would like me to 
re-test, I would be very happy to do so.

- 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.
--- dbdimp.h.orig       2005-04-05 00:53:46.000000000 +0100
+++ dbdimp.h    2005-04-06 10:16:27.435430200 +0100
@@ -173,7 +173,7 @@
     char           * data;
     double        ddata;
     long          ldata;
-    long long     lldata;
+    LONGLONG      lldata;
 
 } imp_sth_fbh_t;
 
@@ -254,7 +254,7 @@
 #define do_error               mysql_dr_error
 #define dbd_db_type_info_all    mysql_db_type_info_all
 #define dbd_db_quote            mysql_db_quote
-#ifdef DBD_MYSQL_INSERT_ID_IS_GOOD /* prototype was broken in some versions of 
dbi */j
+#ifdef DBD_MYSQL_INSERT_ID_IS_GOOD /* prototype was broken in some versions of 
dbi */
 #define dbd_db_last_insert_id   mysql_db_last_insert_id
 #endif
 
--- dbdimp.c.orig       2005-04-05 00:53:46.000000000 +0100
+++ dbdimp.c    2005-04-06 10:21:53.498475800 +0100
@@ -538,7 +538,7 @@
     if (! limit_flag)
     {
       if ((*statement_ptr == 'l' || *statement_ptr == 'L') &&
-         !strncasecmp(statement_ptr+1, "imit", 4))
+         !strncmp(statement_ptr+1, "imit", 4))
         limit_flag = 1;
     }
     switch (*statement_ptr)
@@ -1481,7 +1481,7 @@
 
 safe_hv_fetch
 */
-static char *safe_hv_fetch(HV *hv, const char *name, uint name_length)
+static char *safe_hv_fetch(HV *hv, const char *name, UINT name_length)
 {
   SV** svp;
   STRLEN len;
@@ -2162,10 +2162,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 (!strncmp(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 && !strncmp(searchptr, "limit ", 6))
       {
         limit_flag = 1;
         i += 6;
@@ -2211,7 +2211,7 @@
   */
 
     /* this is a better way to do this */
-  if ( !strncasecmp(statement, "listfields ", 11) && 
imp_sth->use_server_side_prepare )
+  if ( !strncmp(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);
@@ -2356,7 +2356,7 @@
     *result= NULL;
   }
 
-  if (slen >= 11 && !strncasecmp(sbuf, "listfields ", 11))
+  if (slen >= 11 && !strncmp(sbuf, "listfields ", 11))
   {
     /* remove pre-space */
     slen -= 10;
@@ -2418,7 +2418,7 @@
   else
     rows= mysql_num_rows(*result);
 
-  if ((long long)rows == -1)
+  if ((LONGLONG)rows == -1)
     return(-1);
 
   return(rows);
@@ -2527,7 +2527,7 @@
          rows= mysql_stmt_num_rows(stmt);
       }
   }
-  if ((long long)rows == -1)
+  if ((LONGLONG)rows == -1)
     return(-1);
   return(rows);
 
@@ -2641,7 +2641,7 @@
                   imp_sth->row_num);
   }
 
-  if ((long long) imp_sth->row_num == -1)
+  if ((LONGLONG) imp_sth->row_num == -1)
     return -1;
   else
     return (int) imp_sth->row_num;
@@ -2778,6 +2778,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)
@@ -2820,9 +2823,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)
--- mysql.xs.orig       2005-04-05 00:53:46.000000000 +0100
+++ mysql.xs    2005-04-06 10:21:20.859104200 +0100
@@ -564,7 +564,7 @@
     D_imp_sth(sth);
     char buf[64];
 
-  if ((long long)imp_sth->row_num ==  -1)
+  if ((LONGLONG)imp_sth->row_num ==  -1)
     sprintf(buf, "%d", -1);
   else
     sprintf(buf, "%llu", imp_sth->row_num);

Reply via email to