bug35759.phpt 1.5 KB

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