bug53649.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --TEST--
  2. Bug #53649 (mysql_query with "load data" unable to save result set)
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
  8. die(sprintf("skip Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error()));
  9. }
  10. if (!mysql_query("DROP TABLE IF EXISTS test", $link) ||
  11. !mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link))
  12. die(sprintf("skip [%d] %s\n", mysql_errno($link), mysql_error($link)));
  13. if (false === file_put_contents('bug53649.data', "1\n2\n3\n"))
  14. die(sprintf("skip Failed to create data file\n"));
  15. if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link) &&
  16. 1148 == mysql_errno($link))
  17. die("skip LOAD DATA LOAD INFILE not allowed\n");
  18. ?>
  19. --FILE--
  20. <?php
  21. require_once("connect.inc");
  22. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
  23. printf("[001] Connect failed, [%d] %s\n", mysqlerrno(), mysqli_error());
  24. }
  25. if (!mysql_query("DROP TABLE IF EXISTS test", $link)) {
  26. printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
  27. }
  28. if (!mysql_query("CREATE TABLE test (dump1 INT UNSIGNED NOT NULL PRIMARY KEY) ENGINE=" . $engine, $link)) {
  29. printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
  30. }
  31. if (false === file_put_contents('bug53649.data', "1\n2\n3\n"))
  32. printf("[004] Failed to create data file\n");
  33. if (!mysql_query("SELECT 1 FROM DUAL", $link))
  34. printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
  35. if (!mysql_query("LOAD DATA LOCAL INFILE 'bug53649.data' INTO TABLE test", $link)) {
  36. printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
  37. echo "bug";
  38. } else {
  39. echo "done";
  40. }
  41. mysql_close($link);
  42. ?>
  43. --CLEAN--
  44. <?php
  45. require_once('connect.inc');
  46. if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
  47. printf("[clean] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  48. $host, $user, $db, $port, $socket);
  49. }
  50. if (!mysql_query($link, 'DROP TABLE IF EXISTS test', $link)) {
  51. printf("[clean] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  52. }
  53. mysql_close($link);
  54. unlink('bug53649.data');
  55. ?>
  56. --EXPECTF--
  57. Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  58. done