Check before clearing statements stored in the session

If the session has no stored statements, there's no need to clear them.
This commit is contained in:
Markus Mäkelä 2017-10-06 15:28:44 +03:00
parent b00964dc54
commit 9d6c2010b3
2 changed files with 17 additions and 2 deletions

View File

@ -407,6 +407,18 @@ bool session_store_stmt(MXS_SESSION *session, GWBUF *buf, const struct server *s
*/
bool session_take_stmt(MXS_SESSION *session, GWBUF **buffer, const struct server **target);
/**
* @brief Check if the session has a stored statement
*
* @param session Session to check
*
* @return True if the session has a stored statement
*/
static inline bool session_have_stmt(MXS_SESSION *session)
{
return session->stmt.buffer;
}
/**
* Clear the stored statement
*

View File

@ -1196,8 +1196,11 @@ static void clientReply(MXS_ROUTER *instance,
return;
}
/** Statement was successfully executed, free the stored statement */
session_clear_stmt(backend_dcb->session);
if (session_have_stmt(backend_dcb->session))
{
/** Statement was successfully executed, free the stored statement */
session_clear_stmt(backend_dcb->session);
}
if (reply_is_complete(backend, writebuf))
{