From 8ed85453b751a26c0f71ee8739e8bda6f2ad2d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 14 Jul 2017 02:09:51 +0200 Subject: [PATCH] Reset insert_id on connection sent to pool #1093 Automatically reset mysql->insert_id when a connection is sent to connection pool. If is not reset to 0 , when a backend connections is assigned to a client, this one can potentially read the last inserted id from the previous client. --- lib/MySQL_Session.cpp | 1 + lib/MySQL_Thread.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index d90dfcdc6..1dd473a61 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -275,6 +275,7 @@ MySQL_Session::MySQL_Session() { init(); // we moved this out to allow CHANGE_USER + last_insert_id=0; // #1093 } void MySQL_Session::init() { diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index e544f5f26..43ca81b2f 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -4215,6 +4215,8 @@ MySQL_Connection * MySQL_Thread::get_MyConn_local(unsigned int _hid) { void MySQL_Thread::push_MyConn_local(MySQL_Connection *c) { MySrvC *mysrvc=NULL; mysrvc=(MySrvC *)c->parent; + // reset insert_id #1093 + c->mysql->insert_id = 0; if (mysrvc->status==MYSQL_SERVER_STATUS_ONLINE) { if (c->async_state_machine==ASYNC_IDLE) { cached_connections->add(c);