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:
		@ -126,20 +126,21 @@ typedef struct mxs_upstream
 | 
			
		||||
typedef struct session
 | 
			
		||||
{
 | 
			
		||||
    skygw_chk_t             ses_chk_top;
 | 
			
		||||
    mxs_session_state_t     state;            /*< Current descriptor state */
 | 
			
		||||
    size_t                  ses_id;           /*< Unique session identifier */
 | 
			
		||||
    struct dcb              *client_dcb;      /*< The client connection */
 | 
			
		||||
    void                    *router_session;  /*< The router instance data */
 | 
			
		||||
    MXS_SESSION_STATS       stats;            /*< Session statistics */
 | 
			
		||||
    struct service          *service;         /*< The service this session is using */
 | 
			
		||||
    int                     n_filters;        /*< Number of filter sessions */
 | 
			
		||||
    SESSION_FILTER          *filters;         /*< The filters in use within this session */
 | 
			
		||||
    MXS_DOWNSTREAM          head;             /*< Head of the filter chain */
 | 
			
		||||
    MXS_UPSTREAM            tail;             /*< The tail of the filter chain */
 | 
			
		||||
    int                     refcount;         /*< Reference count on the session */
 | 
			
		||||
    bool                    ses_is_child;     /*< this is a child session */
 | 
			
		||||
    mxs_session_trx_state_t trx_state;        /*< The current transaction state. */
 | 
			
		||||
    bool                    autocommit;       /*< Whether autocommit is on. */
 | 
			
		||||
    mxs_session_state_t     state;                /*< Current descriptor state */
 | 
			
		||||
    size_t                  ses_id;               /*< Unique session identifier */
 | 
			
		||||
    struct dcb              *client_dcb;          /*< The client connection */
 | 
			
		||||
    void                    *router_session;      /*< The router instance data */
 | 
			
		||||
    MXS_SESSION_STATS       stats;                /*< Session statistics */
 | 
			
		||||
    struct service          *service;             /*< The service this session is using */
 | 
			
		||||
    int                     n_filters;            /*< Number of filter sessions */
 | 
			
		||||
    SESSION_FILTER          *filters;             /*< The filters in use within this session */
 | 
			
		||||
    MXS_DOWNSTREAM          head;                 /*< Head of the filter chain */
 | 
			
		||||
    MXS_UPSTREAM            tail;                 /*< The tail of the filter chain */
 | 
			
		||||
    int                     refcount;             /*< Reference count on the session */
 | 
			
		||||
    bool                    ses_is_child;         /*< this is a child session */
 | 
			
		||||
    mxs_session_trx_state_t trx_state;            /*< The current transaction state. */
 | 
			
		||||
    bool                    autocommit;           /*< Whether autocommit is on. */
 | 
			
		||||
    intptr_t                client_protocol_data; /*< Owned and managed by the client protocol. */
 | 
			
		||||
    struct
 | 
			
		||||
    {
 | 
			
		||||
        GWBUF *buffer; /**< Buffer containing the statement */
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ MXS_BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
#define SESSION_INIT {.ses_chk_top = CHK_NUM_SESSION, \
 | 
			
		||||
    .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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user