]> granicus.if.org Git - php/commitdiff
Make the tests pass with sql strict mode enabled
authorUlf Wendel <uw@php.net>
Tue, 8 Jun 2010 15:47:51 +0000 (15:47 +0000)
committerUlf Wendel <uw@php.net>
Tue, 8 Jun 2010 15:47:51 +0000 (15:47 +0000)
ext/mysql/tests/mysql_fetch_array.phpt
ext/mysql/tests/mysql_fetch_field.phpt

index 635e6d1097f8387a4f23609f172e2aeb63e292f3..362cf99ddc6727cb7e40dd449466555b6c28f728 100644 (file)
@@ -50,7 +50,7 @@ mysql_free_result($res);
 if (!$res = mysql_query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C", $link)) {
        printf("[012] Cannot run query, [%d] %s\n",
                mysql_errno($link), $mysql_error($link));
-exit(1);
+       exit(1);
 }
 
 do {
@@ -76,7 +76,6 @@ function func_mysql_fetch_array($link, $engine, $sql_type, $sql_value, $php_valu
        }
 
        if (!mysql_query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine), $link)) {
-               print $sql;
                // don't bail, engine might not support the datatype
                return false;
        }
@@ -225,11 +224,11 @@ func_mysql_fetch_array($link, $engine, "CHAR(255)", $string255,  $string255, 550
 func_mysql_fetch_array($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
 func_mysql_fetch_array($link, $engine, "CHAR(1)", NULL, NULL, 570);
 
-$string65k = func_mysql_fetch_array_make_string(65535);
+$string65k = func_mysql_fetch_array_make_string(65400);
 
 func_mysql_fetch_array($link, $engine, "VARCHAR(1)", "a", "a", 580);
 func_mysql_fetch_array($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
-func_mysql_fetch_array($link, $engine, "VARCHAR(65635)", $string65k, $string65k, 600);
+func_mysql_fetch_array($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
 func_mysql_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
 func_mysql_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
 
index 65c44edc5e1a93509eb94b3fbc4dfc413c08cca3..ef03279087154a71473c2cb87fddac32d474c66d 100644 (file)
@@ -51,6 +51,7 @@ require_once('skipifconnectfailure.inc');
                'BIT'               => array(1, 'int'),
                'TINYINT'           => array(1, 'int'),
                'BOOL'              => array('true', 'int'),
+               'BOOL'              => array(1, 'int'),
                'SMALLINT'          => array(32767, 'int'),
                'MEDIUMINT'         => array(8388607, 'int'),
                'INT'               => array(100, 'int'),
@@ -86,7 +87,17 @@ require_once('skipifconnectfailure.inc');
                        // server and/or engine might not support the data type
                        continue;
                }
-               if (!mysql_query(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $type_desc[0]), $link)) {
+
+               if (is_string($type_desc[0]))
+                       $insert = sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $type_desc[0]);
+               else
+                       $insert = sprintf("INSERT INTO test(id, label) VALUES (1, %s)", $type_desc[0]);
+
+               if (!mysql_query($insert, $link)) {
+                       if (1366 == mysql_errno($link)) {
+                               /* Strict SQL mode - 1366, Incorrect integer value: 'true' for column 'label' at row 1 */
+                               continue;
+                       }
                        printf("[009/%s] [%d] %s\n", $type_name, mysql_errno($link), mysql_error($link));
                        continue;
                }