1--TEST--
2mysqli_thread_id()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    require_once 'connect.inc';
12    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
13        printf("Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
14            $host, $user, $db, $port, $socket);
15        exit(1);
16    }
17
18    if (!is_int($tmp = mysqli_thread_id($link)) || (0 === $tmp))
19        printf("[003] Expecting int/any but zero, got %s/%s. [%d] %s\n",
20            gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
21
22    // should work if the thread id is correct
23    $link->real_query('KILL '.mysqli_thread_id($link));
24    // We kill our own connection so we should get "Query execution was interrupted"
25	if ($link->errno !== 1317)
26		printf("[042] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
27
28    mysqli_close($link);
29
30    try {
31        mysqli_thread_id($link);
32    } catch (Error $exception) {
33        echo $exception->getMessage() . "\n";
34    }
35
36    print "done!";
37?>
38--EXPECT--
39mysqli object is already closed
40done!
41