xref: /PHP-8.4/ext/mysqli/tests/gh11550.phpt (revision ca5d4821)
1--TEST--
2Bug GH-11550 (MySQL Statement has a empty query result when the response field has changed, also Segmentation fault)
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11require_once 'connect.inc';
12
13$link = new \mysqli($host, $user, $passwd, $db, $port, $socket);
14
15$link->query(<<<'SQL'
16CREATE TABLE `test_gh11550`  (
17    `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
18    `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
19    PRIMARY KEY (`id`) USING BTREE,
20    INDEX `name`(`name`) USING BTREE
21) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
22SQL);
23$link->query(<<<'SQL'
24INSERT INTO `test_gh11550` (`name`) VALUES ('test1');
25SQL);
26
27$stmt = $link->prepare('select * from test_gh11550');
28var_dump('mysqli-1:', $stmt->execute(), $stmt->get_result()->fetch_all());
29
30$link->query(<<<'SQL'
31ALTER TABLE `test_gh11550`
32ADD COLUMN `a` varchar(255) NOT NULL DEFAULT '';
33SQL);
34
35var_dump('mysqli-2:', $stmt->execute(), $stmt->get_result()->fetch_all());
36echo 'Done';
37?>
38--CLEAN--
39<?php
40require_once 'connect.inc';
41
42$link = new \mysqli($host, $user, $passwd, $db, $port, $socket);
43$link->query('DROP TABLE IF EXISTS test_gh11550');
44?>
45--EXPECT--
46string(9) "mysqli-1:"
47bool(true)
48array(1) {
49  [0]=>
50  array(2) {
51    [0]=>
52    int(1)
53    [1]=>
54    string(5) "test1"
55  }
56}
57string(9) "mysqli-2:"
58bool(true)
59array(1) {
60  [0]=>
61  array(3) {
62    [0]=>
63    int(1)
64    [1]=>
65    string(5) "test1"
66    [2]=>
67    string(0) ""
68  }
69}
70Done
71