bug45019.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. Bug #45019 (Segmentation fault with SELECT ? and UNION)
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. require_once("table.inc");
  13. // Regular (non-prepared) queries
  14. print "Using CAST('somestring' AS CHAR)...\n";
  15. if (!($res = $link->query("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
  16. printf("[001] [%d] %s\n", $link->errno, $link->error);
  17. $data = array();
  18. while ($row = $res->fetch_assoc()) {
  19. $data[] = $row['column1'];
  20. var_dump($row['column1']);
  21. }
  22. $res->free();
  23. // Prepared Statements
  24. if (!($stmt = $link->prepare("SELECT CAST('one' AS CHAR) AS column1 UNION SELECT CAST('three' AS CHAR) UNION SELECT CAST('two' AS CHAR)")))
  25. printf("[002] [%d] %s\n", $link->errno, $link->error);
  26. $column1 = null;
  27. if (!$stmt->bind_result($column1) || !$stmt->execute())
  28. printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
  29. $index = 0;
  30. while ($stmt->fetch()) {
  31. /* NOTE: libmysql - http://bugs.mysql.com/bug.php?id=47483 */
  32. if ($data[$index] != $column1) {
  33. if ($IS_MYSQLND || $index != 1) {
  34. printf("[004] Row %d, expecting %s/%s got %s/%s\n",
  35. $index + 1, gettype($data[$index]), $data[$index], gettype($column1), $column1);
  36. } else {
  37. if ($column1 != "thre")
  38. printf("[005] Got '%s'. Please check if http://bugs.mysql.com/bug.php?id=47483 has been fixed and adapt tests bug45019.phpt/mysqli_ps_select_union.phpt", $column1);
  39. }
  40. }
  41. $index++;
  42. }
  43. $stmt->close();
  44. $link->close();
  45. print "done!";
  46. ?>
  47. --EXPECT--
  48. Using CAST('somestring' AS CHAR)...
  49. string(3) "one"
  50. string(5) "three"
  51. string(3) "two"
  52. done!