andrey                                   Thu, 29 Apr 2010 12:07:02 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=298768

Log:
Try blob columns instead of int, and insert a lot of data at once

Changed paths:
    U   
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt
    U   
php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt

Modified: 
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt
===================================================================
--- 
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt
      2010-04-29 11:49:08 UTC (rev 298767)
+++ 
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt
      2010-04-29 12:07:02 UTC (rev 298768)
@@ -6,6 +6,8 @@
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
+--INI--
+memory_limit=256M
 --FILE--
 <?php
        /*
@@ -25,6 +27,19 @@
                exit(1);
        }

+       list($old_max_allowed_packet) = $link->query("SELECT 
@@max_allowed_packet")->fetch_row();
+       if (!$link->query("SET GLOBAL max_allowed_packet=(2<<29)")) {
+               printf("Failed to set max_allowed_packet the test table: [%d] 
%s\n", mysqli_errno($link), mysqli_error($link));
+       }
+       mysqli_close($link);
+
+
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, 
$socket)) {
+               printf("Cannot connect to the server using host=%s, user=%s, 
passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+               exit(1);
+       }
+
        if (!mysqli_query($link, 'DROP TABLE IF EXISTS ps_test')) {
                printf("Failed to drop old test table: [%d] %s\n", 
mysqli_errno($link), mysqli_error($link));
                exit(1);
@@ -33,27 +48,38 @@
        $cols = 2500;
        $str = array();
        for ($i = 1; $i <= $cols; $i++) {
-               $str[] ="a$i INT";
+               $str[] ="a$i BLOB";
        }
-       $link->query("CREATE TABLE ps_test(" . implode(" , ", $str) . ")");
+       $link->query("CREATE TABLE ps_test(" . implode(" , ", $str) . ") 
ENGINE=MyISAM");
        if (mysqli_errno($link)) {
                printf("Failed to create the test table: [%d] %s\n", 
mysqli_errno($link), mysqli_error($link));
                die("");
        }
        $stmt = $link->prepare("INSERT INTO ps_test VALUES(".str_repeat("?, ", 
$cols-1) . "?)");
        var_dump($stmt->id);
-       $eval_str="\$stmt->bind_param(\"".str_repeat("i",$cols)."\", ";
+       $s = str_repeat("a", 2 << 12);
+       $eval_str="\$stmt->bind_param(\"".str_repeat("s",$cols)."\", ";
        for ($i = 1; $i < $cols; $i++) {
-               $eval_str.="\$i,";
+               $eval_str.="\$s,";
        }
-       $eval_str.="\$i";
+       $eval_str.="\$s";
        $eval_str.=");";
        eval($eval_str);
-       var_dump($stmt->execute());
+       printf("executing\n");
+       if (!$stmt->execute()) {
+               printf("failed");
+               printf("Failed to execute: [%d] %s\n", 
mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+       } else {
+               var_dump(true);
+       }

        mysqli_stmt_close($stmt);


+       if (!$link->query("SET GLOBAL 
max_allowed_packet=$old_max_allowed_packet")) {
+               printf("Failed to set max_allowed_packet the test table: [%d] 
%s\n", mysqli_errno($link), mysqli_error($link));
+       }
+
        mysqli_close($link);

        print "done!";
@@ -72,5 +98,6 @@
 ?>
 --EXPECTF--
 int(1)
+executing
 bool(true)
 done!

Modified: 
php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt 
2010-04-29 11:49:08 UTC (rev 298767)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_bind_param_many_columns.phpt 
2010-04-29 12:07:02 UTC (rev 298768)
@@ -6,6 +6,8 @@
 require_once('skipifemb.inc');
 require_once('skipifconnectfailure.inc');
 ?>
+--INI--
+memory_limit=256M
 --FILE--
 <?php
        /*
@@ -25,6 +27,19 @@
                exit(1);
        }

+       list($old_max_allowed_packet) = $link->query("SELECT 
@@max_allowed_packet")->fetch_row();
+       if (!$link->query("SET GLOBAL max_allowed_packet=(2<<29)")) {
+               printf("Failed to set max_allowed_packet the test table: [%d] 
%s\n", mysqli_errno($link), mysqli_error($link));
+       }
+       mysqli_close($link);
+
+
+       if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, 
$socket)) {
+               printf("Cannot connect to the server using host=%s, user=%s, 
passwd=***, dbname=%s, port=%s, socket=%s\n",
+                       $host, $user, $db, $port, $socket);
+               exit(1);
+       }
+
        if (!mysqli_query($link, 'DROP TABLE IF EXISTS ps_test')) {
                printf("Failed to drop old test table: [%d] %s\n", 
mysqli_errno($link), mysqli_error($link));
                exit(1);
@@ -33,27 +48,38 @@
        $cols = 2500;
        $str = array();
        for ($i = 1; $i <= $cols; $i++) {
-               $str[] ="a$i INT";
+               $str[] ="a$i BLOB";
        }
-       $link->query("CREATE TABLE ps_test(" . implode(" , ", $str) . ")");
+       $link->query("CREATE TABLE ps_test(" . implode(" , ", $str) . ") 
ENGINE=MyISAM");
        if (mysqli_errno($link)) {
                printf("Failed to create the test table: [%d] %s\n", 
mysqli_errno($link), mysqli_error($link));
                die("");
        }
        $stmt = $link->prepare("INSERT INTO ps_test VALUES(".str_repeat("?, ", 
$cols-1) . "?)");
        var_dump($stmt->id);
-       $eval_str="\$stmt->bind_param(\"".str_repeat("i",$cols)."\", ";
+       $s = str_repeat("a", 2 << 12);
+       $eval_str="\$stmt->bind_param(\"".str_repeat("s",$cols)."\", ";
        for ($i = 1; $i < $cols; $i++) {
-               $eval_str.="\$i,";
+               $eval_str.="\$s,";
        }
-       $eval_str.="\$i";
+       $eval_str.="\$s";
        $eval_str.=");";
        eval($eval_str);
-       var_dump($stmt->execute());
+       printf("executing\n");
+       if (!$stmt->execute()) {
+               printf("failed");
+               printf("Failed to execute: [%d] %s\n", 
mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
+       } else {
+               var_dump(true);
+       }

        mysqli_stmt_close($stmt);


+       if (!$link->query("SET GLOBAL 
max_allowed_packet=$old_max_allowed_packet")) {
+               printf("Failed to set max_allowed_packet the test table: [%d] 
%s\n", mysqli_errno($link), mysqli_error($link));
+       }
+
        mysqli_close($link);

        print "done!";
@@ -72,5 +98,6 @@
 ?>
 --EXPECTF--
 int(1)
+executing
 bool(true)
 done!

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to