1--TEST--
2mysqli_change_user(), MySQL 5.6+
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'connect.inc';
8
9if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
10    die(sprintf("SKIP Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
11        $host, $user, $db, $port, $socket));
12
13if (mysqli_get_server_version($link) < 50600)
14    die("SKIP For MySQL >= 5.6.0");
15
16if (mysqli_get_server_version($link) >= 10_00_00)
17    die("SKIP Not applicable for MariaDB");
18?>
19--FILE--
20<?php
21    require_once 'connect.inc';
22
23    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
24        printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
25            $host, $user, $db, $port, $socket);
26
27    /* Pre 5.6: link remains useable */
28    if (false !== ($tmp = @mysqli_change_user($link, $user . '_unknown_really', $passwd . 'non_empty', $db)))
29        printf("[002] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
30
31    if (!$res = mysqli_query($link, 'SELECT 1 AS _one'))
32        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
33    else
34        var_dump($res->fetch_assoc());
35
36    print "done!";
37?>
38--EXPECT--
39[003] [2006] MySQL server has gone away
40done!
41