bug35759.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Bug #35759 (mysqli_stmt_bind_result() makes huge allocation when column empty)
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. require_once("connect.inc");
  11. $col_num= 1000;
  12. $mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
  13. $mysql->query("DROP TABLE IF EXISTS test");
  14. $create = "CREATE TABLE test (a0 MEDIUMBLOB NOT NULL DEFAULT ''";
  15. $i= 0;
  16. while (++$i < $col_num) {
  17. $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''";
  18. }
  19. $create .= ") ENGINE=MyISAM"; // doesn't work with InnoDB, which is default in 5.5
  20. if (!$mysql->query($create)) {
  21. if (1101 == $mysql->errno) {
  22. /* SQL strict mode - [1101] BLOB/TEXT column 'a0' can't have a default value */
  23. print "done!";
  24. exit(0);
  25. }
  26. printf("[001] [%d] %s\n", $mysql->errno, $mysql->error);
  27. }
  28. if (!$mysql->query("INSERT INTO test (a0) VALUES ('')"))
  29. printf("[002] [%d] %s\n", $mysql->errno, $mysql->error);
  30. $stmt = $mysql->prepare("SELECT * FROM test");
  31. if ($stmt) {
  32. $stmt->execute();
  33. $stmt->store_result();
  34. for ($i = 0; $i < $col_num; $i++) {
  35. $params[] = &$col_num;
  36. }
  37. call_user_func_array(array($stmt, "bind_result"), $params);
  38. $stmt->fetch();
  39. $stmt->close();
  40. } else {
  41. printf("[003] [%d] %s\n", $mysql->errno, $mysql->error);
  42. }
  43. $mysql->close();
  44. echo "done!";
  45. ?>
  46. --CLEAN--
  47. <?php require("clean_table.inc"); ?>
  48. --EXPECT--
  49. done!