1--TEST--
2mysqli_release_savepoint()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8
9require_once('connect.inc');
10if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
11    die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
12
13if (!have_innodb($link))
14    die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
15?>
16--FILE--
17<?php
18    require_once("connect.inc");
19    $tmp    = NULL;
20    $link   = NULL;
21
22    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
23        printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
24            $host, $user, $db, $port, $socket);
25
26    try {
27        mysqli_release_savepoint($link, '');
28    } catch (\ValueError $e) {
29        echo $e->getMessage() . \PHP_EOL;
30    }
31
32    if (!mysqli_query($link, 'DROP TABLE IF EXISTS test'))
33        printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
34
35    if (!mysqli_query($link, 'CREATE TABLE test(id INT) ENGINE = InnoDB'))
36        printf("[008] Cannot create test table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
37
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
41    /* note that there is no savepoint my... */
42    if (false !== ($tmp = mysqli_release_savepoint($link, 'my')))
43        printf("[010] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
44
45    if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
46        printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
47
48    $tmp = mysqli_commit($link);
49    if ($tmp !== true)
50        printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
51
52    if (true !== ($tmp = mysqli_savepoint($link, 'my')))
53        printf("[013] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
54
55    $res = mysqli_query($link, "SELECT * FROM test");
56    var_dump($res->fetch_assoc());
57
58    if (true !== ($tmp = mysqli_release_savepoint($link, 'my')))
59        printf("[014] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
60
61    print "done!";
62?>
63--CLEAN--
64<?php
65    require_once("clean_table.inc");
66?>
67--EXPECT--
68mysqli_release_savepoint(): Argument #2 ($name) cannot be empty
69array(1) {
70  ["id"]=>
71  string(1) "1"
72}
73done!
74