MXS-1275: Add client protocol data to MXS_SESSION

The current sql mode will be tracked in that variable. Since one
thread will handle multiple sessions, we need to track the sql mode
of a session, so that the sql mode of the query classifier can be
set whenever we handle a request of a particular session.

As the sql-mode will be managed by the client protocol, the data
can be private to it as well.
This commit is contained in:
Johan Wikman
2017-06-02 15:53:48 +03:00
parent 51452ecb3b
commit 25314b6662
2 changed files with 16 additions and 15 deletions

View File

@ -140,6 +140,7 @@ typedef struct session
bool ses_is_child; /*< this is a child session */ bool ses_is_child; /*< this is a child session */
mxs_session_trx_state_t trx_state; /*< The current transaction state. */ mxs_session_trx_state_t trx_state; /*< The current transaction state. */
bool autocommit; /*< Whether autocommit is on. */ bool autocommit; /*< Whether autocommit is on. */
intptr_t client_protocol_data; /*< Owned and managed by the client protocol. */
struct struct
{ {
GWBUF *buffer; /**< Buffer containing the statement */ GWBUF *buffer; /**< Buffer containing the statement */

View File

@ -27,7 +27,7 @@ MXS_BEGIN_DECLS
#define SESSION_INIT {.ses_chk_top = CHK_NUM_SESSION, \ #define SESSION_INIT {.ses_chk_top = CHK_NUM_SESSION, \
.stats = SESSION_STATS_INIT, .head = MXS_DOWNSTREAM_INIT, .tail = MXS_UPSTREAM_INIT, \ .stats = SESSION_STATS_INIT, .head = MXS_DOWNSTREAM_INIT, .tail = MXS_UPSTREAM_INIT, \
.state = SESSION_STATE_ALLOC, .ses_chk_tail = CHK_NUM_SESSION} .state = SESSION_STATE_ALLOC, .client_protocol_data = 0, .ses_chk_tail = CHK_NUM_SESSION}
#define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client_dcb, type) #define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client_dcb, type)