From 17eab779a3a61eeab4d18783ad31cf22486ae09d Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Fri, 3 Jul 2009 12:13:57 +0000 Subject: [PATCH] ... to play with large data sets. Currently its only 10MB in size to keep the test runtime short. However, its easy to increase, if you want to test large data sets --- .../mysqli_query_local_infile_large.phpt | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 ext/mysqli/tests/mysqli_query_local_infile_large.phpt diff --git a/ext/mysqli/tests/mysqli_query_local_infile_large.phpt b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt new file mode 100644 index 0000000000..e141d3e230 --- /dev/null +++ b/ext/mysqli/tests/mysqli_query_local_infile_large.phpt @@ -0,0 +1,87 @@ +--TEST-- +mysql_query(LOAD DATA LOCAL INFILE) with large data set (10MB) +--SKIPIF-- + +--FILE-- +') == 1)) + $bytes += fwrite($fp, (binary)(++$rowno . ";" . $data)); + else + $bytes += fwrite($fp, ++$rowno . ";" . $data); + } + fclose($fp); + printf("Filesize in bytes: %d\nRows: %d\n", $bytes, $rowno); + + include "connect.inc"; + if (!($link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))) + printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, "CREATE TABLE test(id INT, col1 VARCHAR(255), col2 VARCHAR(255)) ENGINE = " . $engine)) + printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';'", mysqli_real_escape_string($link, $file)))) + printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + if (!($res = mysqli_query($link, "SELECT COUNT(*) AS _num FROM test"))) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $row = mysqli_fetch_assoc($res); + if (($row["_num"] != $rowno)) + printf("[006] Expecting %d rows, found %d\n", $rowno, $row["_num"]); + + mysqli_free_result($res); + + $random = mt_rand(1, $rowno); + if (!$res = mysqli_query($link, "SELECT id, col1, col2 FROM test WHERE id = " . $random)) + printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + + $row = mysqli_fetch_assoc($res); + var_dump($row); + mysqli_free_result($res); + + mysqli_close($link); + print "done!"; +?> +--CLEAN-- + +--EXPECTF-- +Filesize in bytes: %d +Rows: %d +array(3) { + [%u|b%"id"]=> + %unicode|string%(%d) "%d" + [%u|b%"col1"]=> + %unicode|string%(127) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + [%u|b%"col2"]=> + %unicode|string%(127) "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +} +done! \ No newline at end of file -- 2.40.0