From 07af981aab1748dd230cf1def871e291a8f86c8b Mon Sep 17 00:00:00 2001 From: Jared Jetsel Date: Wed, 2 Mar 2022 12:12:53 -0700 Subject: [PATCH 1/2] Error handling if statement global id not found * Added error log output instead of assert failure if the global id for the statement is not found * Returns an error packet to the client --- lib/MySQL_Session.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 88c5505744..ee9364392f 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -3135,10 +3135,13 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C memcpy(&client_stmt_id,(char *)pkt.ptr+5,sizeof(uint32_t)); stmt_global_id=client_myds->myconn->local_stmts->find_global_stmt_id_from_client(client_stmt_id); if (stmt_global_id == 0) { - // FIXME: add error handling - // LCOV_EXCL_START - assert(0); - // LCOV_EXCL_STOP + proxy_error("Could not execute statement, global id not found. Client statement id is %d", client_stmt_id); + l_free(pkt.size,pkt.ptr); + client_myds->setDSS_STATE_QUERY_SENT_NET(); + client_myds->myprot.generate_pkt_ERR(true, nullptr, nullptr, 1, 1243, (char*)"28000", (char*)"Prepared statement not found", true); + client_myds->DSS=STATE_SLEEP; + status=WAITING_CLIENT_DATA; + return; } CurrentQuery.stmt_global_id=stmt_global_id; // now we get the statement information From 0d0817a0ad73451c0c9c5924dc6f63f65b022927 Mon Sep 17 00:00:00 2001 From: Jared Jetsel Date: Wed, 2 Mar 2022 15:52:47 -0700 Subject: [PATCH 2/2] Client disconnected if global statement id not found * Also updated the error message --- lib/MySQL_Session.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index ee9364392f..8d3e70b731 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -3135,12 +3135,13 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C memcpy(&client_stmt_id,(char *)pkt.ptr+5,sizeof(uint32_t)); stmt_global_id=client_myds->myconn->local_stmts->find_global_stmt_id_from_client(client_stmt_id); if (stmt_global_id == 0) { - proxy_error("Could not execute statement, global id not found. Client statement id is %d", client_stmt_id); + proxy_error("Could not execute statement, global id not found. Client statement id is %d. Client will be disconnected.", client_stmt_id); l_free(pkt.size,pkt.ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); client_myds->myprot.generate_pkt_ERR(true, nullptr, nullptr, 1, 1243, (char*)"28000", (char*)"Prepared statement not found", true); client_myds->DSS=STATE_SLEEP; status=WAITING_CLIENT_DATA; + client_myds->destroy_MySQL_Connection_From_Pool(true); return; } CurrentQuery.stmt_global_id=stmt_global_id;