xref: /php-src/ext/mysqli/tests/bug48909.phpt (revision a21edc52)
1--TEST--
2Bug #48909 (Segmentation fault in mysqli_stmt_execute)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    require_once 'connect.inc';
12
13    if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)))
14        printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
15            $host, $user, $db, $port, $socket);
16
17    if (!$link->query("DROP TABLE IF EXISTS test") ||
18        !$link->query(sprintf("CREATE TABLE test(id INT, label varchar(255)) ENGINE = %s", $engine)))
19        printf("[002] [%d] %s\n", $link->errno, $link->error);
20
21    if (!$stmt = $link->prepare("INSERT INTO test(id, label) VALUES  (?, ?)"))
22        printf("[003] [%d] %s\n", $link->errno, $link->error);
23
24    if (!$stmt->bind_param("bb",$bvar, $bvar))
25        printf("[004] [%d] %s\n", $stmt->errno, $stmt->error);
26
27    if (!$stmt->execute()) {
28        if ($stmt->errno != 1366) {
29            /*
30                $bvar is null, b is for BLOB - any error like this should be OK:
31                1366 -  Incorrect integer value: '' for column 'id' at row 1
32            */
33            printf("[005] [%d] %s\n", $stmt->errno, $stmt->error);
34        }
35    }
36
37    $stmt->close();
38    $link->close();
39
40    echo "done";
41?>
42--CLEAN--
43<?php
44    require_once 'clean_table.inc';
45?>
46--EXPECT--
47done
48