Skip to content

Commit 2856afc

Browse files
committed
Make "MySQL server has gone away" errors more consistent
Don't generate explicit warnings for these in two places, use usual error handling mechanism. Additionally suppress a number of warnings if the server has gone away.
1 parent cf9fd37 commit 2856afc

5 files changed

+7
-17
lines changed

ext/mysqli/tests/mysqli_change_user_new.phpt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ if (mysqli_get_server_version($link) < 50600)
3535

3636
print "done!";
3737
?>
38-
--EXPECTF--
39-
Warning: mysqli_query(): MySQL server has gone away in %s on line %d
40-
41-
Warning: mysqli_query(): Error reading result set's header in %s on line %d
38+
--EXPECT--
4239
[003] [2006] MySQL server has gone away
4340
done!

ext/mysqli/tests/mysqli_mysqlnd_read_timeout.phpt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ mysqlnd.net_read_timeout=1
2828

2929
print "done!";
3030
?>
31-
--EXPECTF--
32-
Warning: mysqli_query(): MySQL server has gone away in %s on line %d
33-
34-
Warning: mysqli_query(): Error reading result set's header in %s on line %d
35-
[002] [%d] %s
31+
--EXPECT--
32+
[002] [2006] MySQL server has gone away
3633
done!

ext/mysqli/tests/mysqli_pconn_max_links.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,6 @@ Before second pconnect:array(3) {
234234
["cached_plinks"]=>
235235
int(0)
236236
}
237-
238-
Warning: main(): MySQL server has gone away in %s on line %d
239-
240-
Warning: main(): Error reading result set's header in %s line %d
241237
After second pconnect:array(3) {
242238
["total"]=>
243239
int(1)

ext/mysqlnd/mysqlnd_result.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s)
391391
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
392392

393393
if (FAIL == (ret = PACKET_READ(conn, &rset_header))) {
394-
php_error_docref(NULL, E_WARNING, "Error reading result set's header");
394+
if (conn->error_info->error_no != CR_SERVER_GONE_ERROR) {
395+
php_error_docref(NULL, E_WARNING, "Error reading result set's header");
396+
}
395397
break;
396398
}
397399

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
296296
if (FAIL == mysqlnd_read_header(pfc, vio, packet_header, stats, error_info)) {
297297
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
298298
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
299-
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
300299
DBG_ERR_FMT("Can't read %s's header", packet_type_as_text);
301300
DBG_RETURN(FAIL);
302301
}
@@ -308,7 +307,6 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header,
308307
if (FAIL == pfc->data->m.receive(pfc, vio, buf, packet_header->size, stats, error_info)) {
309308
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
310309
SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone);
311-
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
312310
DBG_ERR_FMT("Empty '%s' packet body", packet_type_as_text);
313311
DBG_RETURN(FAIL);
314312
}
@@ -2532,7 +2530,7 @@ MYSQLND_METHOD(mysqlnd_protocol, send_command)(
25322530
MYSQLND_INC_CONN_STATISTIC(stats, STAT_COM_QUIT + command - 1 /* because of COM_SLEEP */ );
25332531

25342532
if (! PACKET_WRITE(payload_decoder_factory->conn, &cmd_packet)) {
2535-
if (!silent) {
2533+
if (!silent && error_info->error_no != CR_SERVER_GONE_ERROR) {
25362534
DBG_ERR_FMT("Error while sending %s packet", mysqlnd_command_to_text[command]);
25372535
php_error(E_WARNING, "Error while sending %s packet. PID=%d", mysqlnd_command_to_text[command], getpid());
25382536
}

0 commit comments

Comments
 (0)