From 63103cdbc6323bd3820fe11b4fc9989c14357fed Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Wed, 10 Oct 2007 10:54:02 +0000 Subject: [PATCH] Should be the last commit for HEAD. Now HEAD and 5_3 should have the latest set of ext/mysqli tests. On Linux 32bit we've about 10 tests failing. Before the commit we had about 20 tests failing with HEAD. --- ext/mysqli/tests/bug42378.phpt | 193 ++++++++++++++++++ .../tests/mysqli_real_connect_pconn.phpt | 152 ++++++++++++++ 2 files changed, 345 insertions(+) create mode 100644 ext/mysqli/tests/bug42378.phpt create mode 100644 ext/mysqli/tests/mysqli_real_connect_pconn.phpt diff --git a/ext/mysqli/tests/bug42378.phpt b/ext/mysqli/tests/bug42378.phpt new file mode 100644 index 0000000000..4489751a90 --- /dev/null +++ b/ext/mysqli/tests/bug42378.phpt @@ -0,0 +1,193 @@ +--TEST-- +SELECT column, FORMAT(...) AS _format +--SKIPIF-- + +--INI-- +memory_limit=83886080 +--FILE-- + $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'FORMAT(col1, 0)', 'test', NULL, array(), 100); + + $expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 110); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 120); + + $expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 130); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 140); + + $expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 150); + foreach ($expected as $k => $v) + $expected[$k] = number_format(round($v), 0, '.', ','); + test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 160); + + mysqli_close($link); + print "done!"; +?> +--EXPECTF-- +FLOAT +FORMAT(col1, 0) +FLOAT +id AS order_by_col, FORMAT(col1, 0) +FLOAT UNSIGNED +id AS order_by_col, FORMAT(col1, 0) +DECIMAL(5,0) +id AS order_by_col, FORMAT(col1, 0) +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_real_connect_pconn.phpt b/ext/mysqli/tests/mysqli_real_connect_pconn.phpt new file mode 100644 index 0000000000..ff7f4eff95 --- /dev/null +++ b/ext/mysqli/tests/mysqli_real_connect_pconn.phpt @@ -0,0 +1,152 @@ +--TEST-- +mysqli_real_connect() - persistent connections +--SKIPIF-- + +--INI-- +mysqli.allow_persistent=1 +mysqli.max_persistent=10 +--FILE-- +num_rows); + mysqli_next_result($link); + $res = mysqli_store_result($link); + var_dump($res->num_rows); + } + + + mysqli_close($link); + if (!$link = mysqli_init()) + printf("[018] mysqli_init() failed\n"); + + if (ini_get('open_basedir')) { + // CLIENT_LOCAL_FILES should be blocked - but how to test it ?! + + if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 128)) + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mysqli_real_connect_phpt'; + if (!$fp = fopen($filename, 'w')) + printf("[020] Cannot open temporary file %s\n", $filename); + + fwrite($fp, '100;z'); + fclose($fp); + + // how do we test if gets forbidden because of a missing right or the flag, this test is partly bogus ? + if (mysqli_query($link, "LOAD DATA LOCAL INFILE '$filename' INTO TABLE test FIELDS TERMINATED BY ';'")) + printf("[021] LOAD DATA INFILE should have been forbidden!\n"); + + unlink($filename); + } + + mysqli_close($link); + + if ($IS_MYSQLND) { + ini_set('mysqli.default_host', 'p:' . $host); + $link = mysqli_init(); + if (!@mysqli_real_connect($link)) { + printf("[022] Usage of mysqli.default_host=p:%s (persistent) failed\n", $host) ; + } else { + if (!$res = mysqli_query($link, "SELECT 'mysqli.default_host (persistent)' AS 'testing'")) + printf("[023] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $tmp = mysqli_fetch_assoc($res); + if ($tmp['testing'] !== 'mysqli.default_host (persistent)') { + printf("[024] Result looks strange - check manually, [%d] %s\n", + mysqli_errno($link), mysqli_error($link)); + var_dump($tmp); + } + mysqli_free_result($res); + mysqli_close($link); + } + + ini_set('mysqli.default_host', 'p:'); + $link = mysqli_init(); + if (@mysqli_real_sconnect($link)) { + printf("[025] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); + } + } + + if (NULL !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))) + printf("[026] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + + print "done!"; +?> +--EXPECTF-- +Warning: mysqli_real_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d +done! \ No newline at end of file -- 2.50.1