List:Commits« Previous MessageNext Message »
From:uwendel Date:June 26 2007 9:29am
Subject:PHP mysqlnd svn commit: r487 - trunk/tests/ext/mysqli
View as plain text  
Author: uwendel
Date: 2007-06-26 11:29:44 +0200 (Tue, 26 Jun 2007)
New Revision: 487

Modified:
   trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_bad_character.phpt
Log:
Well done, Andrey! Works now.


Modified: trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_bad_character.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_bad_character.phpt	2007-06-26
08:07:26 UTC (rev 486)
+++ trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_bad_character.phpt	2007-06-26
09:29:44 UTC (rev 487)
@@ -20,16 +20,30 @@
     
     function callback_bad_character($fp, &$buffer, $buflen, &$error) {
         static $invocation = 0;
-		// Uncomment the following to crash the server
-//        mysqli_close($GLOBALS['link']);
-        printf("Callback: %d\n", $invocation);
+
+        printf("Callback: %d\n", $invocation++);
+
+        $num_chars = (ini_get('unicode.semantics')) ? (floor($buflen / 2) - 10) :
($buflen - 5);
+        $part1 = floor($num_chars / 2);
+        $part2 = $num_chars - $part1;
+        
         $buffer = '';
-        for ($i = 0; $i < $buflen/2; $i++)
+        for ($i = 0; $i < $part1; $i++)
             $buffer .= chr(mt_rand(0, 255));
-        return $invocation++ < 10? $buflen:0;
+
+        $buffer .= ';"';
+        
+        for ($i = 0; $i < $part2; $i++)
+            $buffer .= chr(mt_rand(0, 255));
+            
+        $buffer .= '";';        
+        if ($invocation > 10)
+            return 0;
+               
+        return strlen($buffer);
     }
     
-    function try_handler($offset, $link, $file, $handler, $expected) {
+    function try_handler($offset, $link, $file, $handler) {
         
         if (!mysqli_set_local_infile_handler($link, $handler)) {
             printf("[%03d] Cannot set infile handler to '%s'\n", $offset, $handler);
@@ -51,62 +65,30 @@
             printf("[%03d] LOAD DATA failed, [%d] %s\n", 
                     $offset + 2,
                     mysqli_errno($link), mysqli_error($link));
-        }
+        }       
         
-        if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id")) {
-            printf("[%03d] [%d] %s\n", $offset + 3, mysqli_errno($link),
mysqli_error($link));
-            return false;
-        }
-/*
-        foreach ($expected as $k => $values) {
-            if (!$tmp = mysqli_fetch_assoc($res)) {
-                printf("[%03d/%d] [%d] %s\n", $offset + 4, $k, mysqli_errno($link),
mysqli_error($link));
-                return false;
-            }
-            if ($values['id'] != $tmp['id']) {
-                printf("[%03d/%d] Expecting %s got %s\n", 
-                    $offset + 5, $k, 
-                    $values['id'], $tmp['id']);
-                return false;
-            }
-            if ($values['label'] != $tmp['label']) {
-                printf("[%03d/%d] Expecting %s got %s\n", 
-                    $offset + 6, $k,
-                    $values['label'], $tmp['label']);
-                return false;
-            }
-        }
-        
-        if ($res && $tmp = mysqli_fetch_assoc($res))
-           printf("More results than expected!\n");
-*/        
-        if ($res)
-            mysqli_free_result($res);
-        
         return true;
     }    
     
     // create a CVS file
     $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
-    if (!$fp = fopen($file, 'w'))
+    if (!$fp = fopen($file, 'wb'))
         printf("[005] Cannot create CVS file '%s'\n", $file);
 	else
         register_shutdown_function("shutdown_clean", $file);
 
-    if (!fwrite($fp, "97;'x';\n") ||
-        !fwrite($fp, "98;'y';\n") ||
-        !fwrite($fp, "99;'z';\n"))
+    if (!fwrite($fp, (binary)"97;'x';\n") ||
+        !fwrite($fp, (binary)"98;'y';\n") ||
+        !fwrite($fp, (binary)"99;'z';\n"))
         printf("[006] Cannot write CVS file '%s'\n", $file);
         
     fclose($fp);    
     
     if (!chmod($file, 0644))
         printf("[007] Cannot change the file perms of '%s' from 0600 to 0644, MySQL might
not be able to read it\n",
-            $file);
-
+            $file);               
     
-    $expected = array();
-    try_handler(20, $link, $file, 'callback_bad_character', $expected);    
+    try_handler(20, $link, $file, 'callback_bad_character');
     
     mysqli_close($link);    
     print "done!";
@@ -124,4 +106,4 @@
 Callback: 8
 Callback: 9
 Callback: 10
-done!
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r487 - trunk/tests/ext/mysqliuwendel26 Jun