mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.2'
* PHP-8.2: Fix MySQL Statement has a empty query result when the response field has changed, also Segmentation fault
This commit is contained in:
commit
82934746b7
3 changed files with 157 additions and 1 deletions
70
ext/mysqli/tests/gh11550.phpt
Normal file
70
ext/mysqli/tests/gh11550.phpt
Normal file
|
@ -0,0 +1,70 @@
|
|||
--TEST--
|
||||
Bug GH-11550 (MySQL Statement has a empty query result when the response field has changed, also Segmentation fault)
|
||||
--EXTENSIONS--
|
||||
mysqli
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once 'skipifconnectfailure.inc';
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once 'connect.inc';
|
||||
|
||||
$link = new \mysqli($host, $user, $passwd, $db, $port, $socket);
|
||||
|
||||
$link->query(<<<'SQL'
|
||||
CREATE TABLE `test_gh11550` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `name`(`name`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||
SQL);
|
||||
$link->query(<<<'SQL'
|
||||
INSERT INTO `test_gh11550` (`name`) VALUES ('test1');
|
||||
SQL);
|
||||
|
||||
$stmt = $link->prepare('select * from test_gh11550');
|
||||
var_dump('mysqli-1:', $stmt->execute(), $stmt->get_result()->fetch_all());
|
||||
|
||||
$link->query(<<<'SQL'
|
||||
ALTER TABLE `test_gh11550`
|
||||
ADD COLUMN `a` varchar(255) NOT NULL DEFAULT '';
|
||||
SQL);
|
||||
|
||||
var_dump('mysqli-2:', $stmt->execute(), $stmt->get_result()->fetch_all());
|
||||
echo 'Done';
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once 'connect.inc';
|
||||
|
||||
$link = new \mysqli($host, $user, $passwd, $db, $port, $socket);
|
||||
$link->query('DROP TABLE IF EXISTS test_gh11550');
|
||||
?>
|
||||
--EXPECT--
|
||||
string(9) "mysqli-1:"
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
string(5) "test1"
|
||||
}
|
||||
}
|
||||
string(9) "mysqli-2:"
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
string(5) "test1"
|
||||
[2]=>
|
||||
string(0) ""
|
||||
}
|
||||
}
|
||||
Done
|
|
@ -286,9 +286,13 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s)
|
|||
COM_STMT_EXECUTE (even if it is not necessary), so either this or
|
||||
previous branch always works.
|
||||
*/
|
||||
if (rset_header.field_count != stmt->result->field_count) {
|
||||
stmt->result->m.free_result(stmt->result, TRUE);
|
||||
stmt->result = conn->m->result_init(rset_header.field_count);
|
||||
}
|
||||
result = stmt->result;
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
SET_OOM_ERROR(conn->error_info);
|
||||
ret = FAIL;
|
||||
|
|
82
ext/pdo_mysql/tests/gh11550.phpt
Normal file
82
ext/pdo_mysql/tests/gh11550.phpt
Normal file
|
@ -0,0 +1,82 @@
|
|||
--TEST--
|
||||
Bug GH-11550 (MySQL Statement has a empty query result when the response field has changed, also Segmentation fault)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$pdo->exec(<<<'SQL'
|
||||
CREATE TABLE `test_gh11550` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `name`(`name`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||
SQL);
|
||||
$pdo->exec(<<<'SQL'
|
||||
INSERT INTO `test_gh11550` (`name`) VALUES ('test1');
|
||||
SQL);
|
||||
|
||||
$stmt = $pdo->prepare('select * from test_gh11550');
|
||||
var_dump('PDO-1:', $stmt->execute(), $stmt->fetchAll());
|
||||
|
||||
$stmt->closeCursor(); // Optional. Segmentation fault (core dumped)
|
||||
|
||||
$pdo->exec(<<<'SQL'
|
||||
ALTER TABLE `test_gh11550`
|
||||
ADD COLUMN `a` varchar(255) NOT NULL DEFAULT '';
|
||||
SQL);
|
||||
|
||||
var_dump('PDO-2:', $stmt->execute(), $stmt->fetchAll());
|
||||
echo 'Done';
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->query('DROP TABLE IF EXISTS test_gh11550');
|
||||
?>
|
||||
--EXPECT--
|
||||
string(6) "PDO-1:"
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(4) {
|
||||
["id"]=>
|
||||
int(1)
|
||||
[0]=>
|
||||
int(1)
|
||||
["name"]=>
|
||||
string(5) "test1"
|
||||
[1]=>
|
||||
string(5) "test1"
|
||||
}
|
||||
}
|
||||
string(6) "PDO-2:"
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(6) {
|
||||
["id"]=>
|
||||
int(1)
|
||||
[0]=>
|
||||
int(1)
|
||||
["name"]=>
|
||||
string(5) "test1"
|
||||
[1]=>
|
||||
string(5) "test1"
|
||||
["a"]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
}
|
||||
}
|
||||
Done
|
Loading…
Add table
Add a link
Reference in a new issue