1--TEST--
2mysqli_stmt_execute() - OUT
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'connect.inc';
8if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
9    die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
10}
11if (mysqli_get_server_version($link) < 50503) {
12    die(sprintf('skip Needs MySQL 5.5.3+, found version %d.', mysqli_get_server_version($link)));
13}
14?>
15--FILE--
16<?php
17    require_once 'connect.inc';
18
19    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
20        printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
21          $host, $user, $db, $port, $socket);
22    }
23
24    if (!mysqli_query($link, 'DROP PROCEDURE IF EXISTS p'))
25        printf("[003] [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
26
27    if (mysqli_real_query($link, 'CREATE PROCEDURE p(IN ver_in VARCHAR(25), OUT ver_out VARCHAR(25)) BEGIN SELECT ver_in INTO ver_out; END;')) {
28        if (!$stmt = mysqli_prepare($link, 'CALL p(?, ?)'))
29            printf("[005] Cannot prepare CALL, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
30
31        $ver_in = 'myversion';
32        $ver_out = '';
33        if (!mysqli_stmt_bind_param($stmt, 'ss', $ver_in, $ver_out))
34            printf("[006] Cannot bind parameter, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
35
36        if (!mysqli_stmt_execute($stmt))
37            printf("[007] Cannot execute CALL, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
38
39        printf("[008] More results: %s\n", (mysqli_more_results($link) ? "yes" : "no"));
40        printf("[009] Next results: %s\n", (mysqli_next_result($link) ? "yes" : "no"));
41
42        try {
43            if (!mysqli_stmt_bind_result($stmt, $ver_out) || !mysqli_stmt_fetch($stmt))
44                printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
45        } catch (\ArgumentCountError $e) {
46            echo $e->getMessage() . \PHP_EOL;
47        }
48
49        if ("myversion" !== $ver_out)
50            printf("[011] Results seem wrong got '%s'\n", $ver_out);
51
52        if (!mysqli_stmt_close($stmt))
53            printf("[012] Cannot close statement, [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
54
55        if (!$res = $link->query("SELECT 1"))
56            printf("[013] [%d] %s\n", $link->errno, $link->error);
57
58    } else {
59        printf("[004] Cannot create SP, [%d] %s.\n", mysqli_errno($link), mysqli_error($link));
60    }
61
62    mysqli_close($link);
63    print "done!";
64?>
65--CLEAN--
66<?php
67require_once 'connect.inc';
68if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
69   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
70
71@mysqli_query($link, 'DROP PROCEDURE IF EXISTS p');
72
73mysqli_close($link);
74?>
75--XFAIL--
76Unsupported and undefined, under development
77--EXPECTF--
78[008] More results: %s
79[009] Next results: %s
80done!
81