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