bug35103.phpt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. --TEST--
  2. Bug #35103 (Bad handling of unsigned bigint)
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. $drop = <<<EOSQL
  12. DROP TABLE test_bint;
  13. DROP TABLE test_buint;
  14. EOSQL;
  15. require_once("connect.inc");
  16. $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
  17. $mysql->query("DROP TABLE IF EXISTS test_bint");
  18. $mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM");
  19. $mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");
  20. $mysql->query("DROP TABLE IF EXISTS test_buint");
  21. $mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)");
  22. $mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)");
  23. $stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a");
  24. $stmt->bind_result($v);
  25. $stmt->execute();
  26. $i=0;
  27. echo "BIG INT SIGNED, TEST\n";
  28. while ($i++ < 8) {
  29. $stmt->fetch();
  30. echo $v, "\n";
  31. }
  32. $stmt->close();
  33. echo str_repeat("-", 20), "\n";
  34. $stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a");
  35. $stmt->bind_result($v2);
  36. $stmt->execute();
  37. $j=0;
  38. echo "BIG INT UNSIGNED TEST\n";
  39. while ($j++ < 6) {
  40. $stmt->fetch();
  41. echo $v2, "\n";
  42. }
  43. $stmt->close();
  44. $mysql->multi_query($drop);
  45. $mysql->close();
  46. ?>
  47. --CLEAN--
  48. <?php
  49. require_once("connect.inc");
  50. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  51. printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  52. if (!mysqli_query($link, "DROP TABLE IF EXISTS test_bint") || !mysqli_query($link, "DROP TABLE IF EXISTS test_buint"))
  53. printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  54. mysqli_close($link);
  55. ?>
  56. --EXPECT--
  57. BIG INT SIGNED, TEST
  58. -9223372036854775808
  59. -2147483649
  60. -2147483648
  61. -2147483647
  62. 2147483647
  63. 2147483648
  64. 2147483649
  65. 9223372036854775807
  66. --------------------
  67. BIG INT UNSIGNED TEST
  68. 2147483647
  69. 2147483649
  70. 4294967295
  71. 9223372036854775807
  72. 9223372036854775808
  73. 18446744073709551615