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