Fixing tests to run with SQL_MODE=ANSI_QUOTES as well.

This commit is contained in:
Ulf Wendel 2009-07-07 11:31:45 +00:00
parent b4dac2a738
commit 8f617842f3
8 changed files with 21 additions and 21 deletions

View File

@ -62,4 +62,4 @@ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1)))
false;
$IS_MYSQLND = stristr(mysql_get_client_info(), "mysqlnd");
?>
?>

View File

@ -35,18 +35,18 @@ if (!mysql_query('DROP TABLE IF EXISTS test', $link))
if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine, $link))
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link))
if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a')", $link))
printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (1 !== ($tmp = mysql_affected_rows($link)))
printf("[010] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
// ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented
@mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link);
@mysql_query("INSERT INTO test(id, label) VALUES (1, 'a')", $link);
if (-1 !== ($tmp = mysql_affected_rows($link)))
printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp);
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4', $link))
if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4", $link))
printf("[012] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (2 !== ($tmp = mysql_affected_rows($link)))

View File

@ -53,11 +53,11 @@ $tables = array(
'label' => array(($version < 500) ? 'multiple_key' : 'unique_key')
),
'labela INT, label2 CHAR(1), KEY keyname (labela, label2)' => array(
array('labela, label2', '1, "a"'),
array('labela, label2', "1, 'a'"),
'labela' => array('multiple_key'),
),
'label1 BLOB' => array(
array('label1', '"blob"'),
array('label1', "'blob'"),
'label1' => array('blob', 'binary'),
),
'label1 INT UNSIGNED' => array(
@ -70,15 +70,15 @@ $tables = array(
'unsigned'),
),
'label1 ENUM("a", "b")' => array(
array('label1', '"a"'),
array('label1', "'a'"),
'label1' => array('enum'),
),
'label1 SET("a", "b")' => array(
array('label1', '"a"'),
array('label1', "'a'"),
'label1' => array('set'),
),
'label1 TIMESTAMP' => array(
array('label1', sprintf('"%s"', @date("Y-m-d H:i:s"))),
array('label1', sprintf("'%s'", @date("Y-m-d H:i:s"))),
'label1' => array(
'timestamp',
'unsigned',

View File

@ -16,13 +16,13 @@ if (NULL !== ($tmp = @mysql_info(NULL)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
require "table.inc";
if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (100, "a")', $link))
if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (100, 'a')", $link))
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (false !== ($tmp = mysql_info($link)))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (101, "a"), (102, "b")', $link))
if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')", $link))
printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
@ -40,7 +40,7 @@ if (!$res = mysql_query('ALTER TABLE test MODIFY label CHAR(2)', $link))
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysql_query('UPDATE test SET label = "b" WHERE id >= 100', $link))
if (!$res = mysql_query("UPDATE test SET label = 'b' WHERE id >= 100", $link))
printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))

View File

@ -26,26 +26,26 @@ if (NULL !== ($tmp = @mysql_query("SELECT 1 AS a", $link, "foo")))
if (false !== ($tmp = mysql_query('THIS IS NOT SQL', $link)))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = mysql_query('SELECT "this is sql but with backslash g"\g', $link)))
if (false !== ($tmp = mysql_query("SELECT 'this is sql but with backslash g'\g", $link)))
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if ((0 === mysql_errno($link)) || ('' == mysql_error($link)))
printf("[006] mysql_errno()/mysql_error should return some error\n");
if (!$res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; ', $link))
if (!$res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link))
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
var_dump(mysql_fetch_assoc($res));
mysql_free_result($res);
if (!$res = mysql_query('SELECT "a" AS ""', $link))
if (!$res = mysql_query("SELECT 'a' AS ''", $link))
printf("[007a] [%d] %s\n", mysql_errno($link), mysql_error($link));
var_dump($tmp = mysql_fetch_assoc($res));
var_dump($tmp[""]);
mysql_free_result($res);
if (false !== ($res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link)))
if (false !== ($res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link)))
printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) {

View File

@ -23,19 +23,19 @@ if (NULL !== ($tmp = @mysql_unbuffered_query("SELECT 1 AS a", $link, "foo")))
if (false !== ($tmp = mysql_unbuffered_query('THIS IS NOT SQL', $link)))
printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = mysql_unbuffered_query('SELECT "this is sql but with backslash g"\g', $link)))
if (false !== ($tmp = mysql_unbuffered_query("SELECT 'this is sql but with backslash g'\g", $link)))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if ((0 === mysql_errno($link)) || ('' == mysql_error($link)))
printf("[005] mysql_errno()/mysql_error should return some error\n");
if (!$res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; ', $link))
if (!$res = mysql_unbuffered_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link))
printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
var_dump(mysql_fetch_assoc($res));
mysql_free_result($res);
if (false !== ($res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link)))
if (false !== ($res = mysql_unbuffered_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link)))
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (mysql_unbuffered_query('DROP PROCEDURE IF EXISTS p', $link)) {

View File

@ -1,6 +1,6 @@
<?php
require_once('connect.inc');
if (!extension_loaded("mysql")) {
die('skip mysql extension not available');
}
require_once('connect.inc');
?>

View File

@ -18,7 +18,7 @@ if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGI
exit(1);
}
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")', $link)) {
if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')", $link)) {
printf("[%d] %s\n", mysql_errno($link), mysql_error($link));
}
?>