mysqli_kill.phpt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. --TEST--
  2. mysqli_kill()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. $tmp = NULL;
  13. $link = NULL;
  14. if (!is_null($tmp = @mysqli_kill()))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (!is_null($tmp = @mysqli_kill($link)))
  17. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. require('table.inc');
  19. // Zend will cast the NULL to 0
  20. if (!is_bool($tmp = mysqli_kill($link, null)))
  21. printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp);
  22. if (!$thread_id = mysqli_thread_id($link))
  23. printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  24. $tmp = mysqli_kill($link, $thread_id);
  25. if (!is_bool($tmp))
  26. printf("[005] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp);
  27. if ($res = mysqli_query($link, "SELECT id FROM test LIMIT 1"))
  28. pintf("[006] Expecting boolean/false, got %s/%s\n", gettype($res), $res);
  29. var_dump($error = mysqli_error($link));
  30. if (!is_string($error) || ('' === $error))
  31. printf("[007] Expecting string/any non empty, got %s/%s\n", gettype($error), $error);
  32. var_dump($res);
  33. var_dump($link);
  34. if ($IS_MYSQLND) {
  35. if ($link->info != 'Records: 6 Duplicates: 0 Warnings: 0') {
  36. printf("[008] mysqlnd used to be more verbose and used to support SELECT\n");
  37. }
  38. if ($link->stat != NULL) {
  39. printf("[009] NULL expected because of error.\n");
  40. }
  41. } else {
  42. if ($link->info != NULL) {
  43. printf("[008] Time for wonders - libmysql has started to support SELECT, change test\n");
  44. }
  45. }
  46. mysqli_close($link);
  47. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  48. printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  49. mysqli_kill($link, -1);
  50. if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) ||
  51. (!$tmp = mysqli_fetch_assoc($res))) {
  52. printf("[011] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  53. }
  54. var_dump($tmp);
  55. mysqli_free_result($res);
  56. mysqli_close($link);
  57. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  58. printf("[012] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  59. mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1);
  60. mysqli_close($link);
  61. print "done!";
  62. ?>
  63. --CLEAN--
  64. <?php
  65. require_once("clean_table.inc");
  66. ?>
  67. --EXPECTF--
  68. Warning: mysqli_kill(): processid should have positive value in %s on line %d
  69. %unicode|string%(%d) "%s"
  70. bool(false)
  71. object(mysqli)#%d (%d) {
  72. [%u|b%"affected_rows"]=>
  73. int(-1)
  74. [%u|b%"client_info"]=>
  75. %unicode|string%(%d) "%s"
  76. [%u|b%"client_version"]=>
  77. int(%d)
  78. [%u|b%"connect_errno"]=>
  79. int(0)
  80. [%u|b%"connect_error"]=>
  81. NULL
  82. [%u|b%"errno"]=>
  83. int(2006)
  84. [%u|b%"error"]=>
  85. %unicode|string%(%d) "%s"
  86. [%u|b%"error_list"]=>
  87. array(1) {
  88. [0]=>
  89. array(3) {
  90. [%u|b%"errno"]=>
  91. int(2006)
  92. [%u|b%"sqlstate"]=>
  93. %unicode|string%(5) "%s"
  94. [%u|b%"error"]=>
  95. %unicode|string%(%d) "%s"
  96. }
  97. }
  98. [%u|b%"field_count"]=>
  99. int(0)
  100. [%u|b%"host_info"]=>
  101. %unicode|string%(%d) "%s"
  102. [%u|b%"info"]=>
  103. %s
  104. [%u|b%"insert_id"]=>
  105. int(0)
  106. [%u|b%"server_info"]=>
  107. %unicode|string%(%d) "%s"
  108. [%u|b%"server_version"]=>
  109. int(%d)
  110. [%u|b%"stat"]=>
  111. %s
  112. [%u|b%"sqlstate"]=>
  113. %unicode|string%(5) "HY000"
  114. [%u|b%"protocol_version"]=>
  115. int(10)
  116. [%u|b%"thread_id"]=>
  117. int(%d)
  118. [%u|b%"warning_count"]=>
  119. int(0)
  120. }
  121. Warning: mysqli_kill(): processid should have positive value in %s on line %d
  122. array(1) {
  123. [%u|b%"id"]=>
  124. %unicode|string%(1) "1"
  125. }
  126. Warning: mysqli_kill(): processid should have positive value in %s on line %d
  127. done!