mysqli_release_savepoint.phpt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. --TEST--
  2. mysqli_release_savepoint()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. require_once('connect.inc');
  9. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  10. die(sprintf("Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
  11. if (!have_innodb($link))
  12. die(sprintf("Needs InnoDB support, [%d] %s", $link->errno, $link->error));
  13. ?>
  14. --FILE--
  15. <?php
  16. require_once("connect.inc");
  17. /* {{{ proto bool mysqli_release_savepoint(object link, string name) */
  18. $tmp = NULL;
  19. $link = NULL;
  20. if (!is_null($tmp = @mysqli_release_savepoint()))
  21. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  22. if (!is_null($tmp = @mysqli_release_savepoint($link)))
  23. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  24. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  25. printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  26. $host, $user, $db, $port, $socket);
  27. $name = array();
  28. if (!is_null($tmp = @mysqli_release_savepoint($link, $name)))
  29. printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  30. if (!is_null($tmp = @mysqli_release_savepoint($link, 'foo', $link)))
  31. printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  32. if (false !== ($tmp = mysqli_release_savepoint($link, '')))
  33. printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
  34. if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
  35. printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  36. if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB'))
  37. printf("[008] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  38. if (true !== ($tmp = mysqli_autocommit($link, false)))
  39. printf("[009] Cannot turn off autocommit, expecting true, got %s/%s\n", gettype($tmp), $tmp);
  40. /* note that there is no savepoint my... */
  41. if (true !== ($tmp = mysqli_release_savepoint($link, 'my')))
  42. printf("[010] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
  43. if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
  44. printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  45. $tmp = mysqli_commit($link);
  46. if ($tmp !== true)
  47. printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  48. if (true !== ($tmp = mysqli_savepoint($link, 'my')))
  49. printf("[013] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
  50. $res = mysqli_query($link, "SELECT * FROM test");
  51. var_dump($res->fetch_assoc());
  52. if (true !== ($tmp = mysqli_release_savepoint($link, 'my')))
  53. printf("[014] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
  54. print "done!";
  55. ?>
  56. --CLEAN--
  57. <?php
  58. require_once("clean_table.inc");
  59. ?>
  60. --EXPECTF--
  61. Warning: mysqli_release_savepoint(): Savepoint name cannot be empty in %s on line %d
  62. array(1) {
  63. ["id"]=>
  64. string(1) "1"
  65. }
  66. done!