Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysqlnd: error message is inappropriate in some cases #11950

Closed
SakiTakamachi opened this issue Aug 12, 2023 · 1 comment
Closed

mysqlnd: error message is inappropriate in some cases #11950

SakiTakamachi opened this issue Aug 12, 2023 · 1 comment

Comments

@SakiTakamachi
Copy link
Member

SakiTakamachi commented Aug 12, 2023

Description

This is an issue I noticed while working on this fix.
#11912

This line sets the CR_MALFORMED_PACKET error.

SET_CLIENT_ERROR(error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "Malformed packet");

However, the CR_SERVER_GONE_ERROR error may already be set at this point.

SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);

Therefore, a CR_MALFORMED_PACKET error is output when an CR_SERVER_GONE_ERROR error should be output.

Fatal error: Uncaught mysqli_sql_exception: Malformed packet in /var/www/html/test/test.php:11

I get the following error message in the same situation when building with libmysqlclient :

Fatal error: Uncaught mysqli_sql_exception: Lost connection to MySQL server during query in /var/www/html/test/test.php:11

The code to reproduce:

<?php

$driver = new mysqli_driver();
$driver->report_mode = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;

$mysqli = new mysqli("mysql", "root", "", "test"); // my env 

fgets(STDIN);
// Restarted mysql, then press enter

var_dump($mysqli->select_db("test2"));

PHP Version

PHP 8.0+

Operating System

No response

@nielsdos
Copy link
Member

Fixed in 199e48b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants