From: Ulf Wendel Date: Fri, 3 Jul 2009 12:14:39 +0000 (+0000) Subject: MFH. ... to play with large data sets. Currently its only 10MB in size to keep the... X-Git-Tag: php-5.3.1RC1~455 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b90a412302855f5d9eb8247dd77f3f8bfc063c52;p=php MFH. ... 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 --- 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