MXS-2432 Recognize RESET
RESET QUERY CACHE is reported to be a session command, which will cause it to be sent to all servers. RESET [MASTER|SLAVE] are classified as write, which will cause them to be sent to the master. It could be argued that RESET [MASTER|SLAVE] should cause an error to be sent to the client.
This commit is contained in:
@ -999,6 +999,17 @@ static uint32_t resolve_query_type(parsing_info_t* pi, THD* thd)
|
|||||||
goto return_qtype;
|
goto return_qtype;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SQLCOM_RESET:
|
||||||
|
if (lex->type & REFRESH_QUERY_CACHE)
|
||||||
|
{
|
||||||
|
type |= QUERY_TYPE_SESSION_WRITE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type |= QUERY_TYPE_WRITE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
type |= QUERY_TYPE_WRITE;
|
type |= QUERY_TYPE_WRITE;
|
||||||
break;
|
break;
|
||||||
|
@ -2602,6 +2602,11 @@ public:
|
|||||||
m_operation = QUERY_OP_REVOKE;
|
m_operation = QUERY_OP_REVOKE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TK_RESET:
|
||||||
|
m_status = QC_QUERY_TOKENIZED;
|
||||||
|
m_type_mask = (QUERY_TYPE_WRITE | QUERY_TYPE_COMMIT);
|
||||||
|
break;
|
||||||
|
|
||||||
case TK_SELECT:
|
case TK_SELECT:
|
||||||
m_status = QC_QUERY_TOKENIZED;
|
m_status = QC_QUERY_TOKENIZED;
|
||||||
m_type_mask = QUERY_TYPE_READ;
|
m_type_mask = QUERY_TYPE_READ;
|
||||||
@ -2838,6 +2843,23 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void maxscaleReset(Parse* pParse, int what)
|
||||||
|
{
|
||||||
|
mxb_assert(this_thread.initialized);
|
||||||
|
|
||||||
|
m_status = QC_QUERY_PARSED;
|
||||||
|
|
||||||
|
switch (what)
|
||||||
|
{
|
||||||
|
case MXS_RESET_QUERY_CACHE:
|
||||||
|
m_type_mask = (QUERY_TYPE_SESSION_WRITE | QUERY_TYPE_COMMIT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
mxb_assert(!true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void maxscaleSet(Parse* pParse, int scope, mxs_set_t kind, ExprList* pList)
|
void maxscaleSet(Parse* pParse, int scope, mxs_set_t kind, ExprList* pList)
|
||||||
{
|
{
|
||||||
mxb_assert(this_thread.initialized);
|
mxb_assert(this_thread.initialized);
|
||||||
@ -3448,6 +3470,7 @@ extern "C"
|
|||||||
extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt);
|
extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt);
|
||||||
extern void maxscalePrivileges(Parse*, int kind);
|
extern void maxscalePrivileges(Parse*, int kind);
|
||||||
extern void maxscaleRenameTable(Parse*, SrcList* pTables);
|
extern void maxscaleRenameTable(Parse*, SrcList* pTables);
|
||||||
|
extern void maxscaleReset(Parse*, int what);
|
||||||
extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*);
|
extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*);
|
||||||
extern void maxscaleShow(Parse*, MxsShow* pShow);
|
extern void maxscaleShow(Parse*, MxsShow* pShow);
|
||||||
extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName);
|
extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName);
|
||||||
@ -4488,6 +4511,16 @@ void maxscalePrivileges(Parse* pParse, int kind)
|
|||||||
QC_EXCEPTION_GUARD(pInfo->maxscalePrivileges(pParse, kind));
|
QC_EXCEPTION_GUARD(pInfo->maxscalePrivileges(pParse, kind));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void maxscaleReset(Parse* pParse, int what)
|
||||||
|
{
|
||||||
|
QC_TRACE();
|
||||||
|
|
||||||
|
QcSqliteInfo* pInfo = this_thread.pInfo;
|
||||||
|
mxb_assert(pInfo);
|
||||||
|
|
||||||
|
QC_EXCEPTION_GUARD(pInfo->maxscaleReset(pParse, what));
|
||||||
|
}
|
||||||
|
|
||||||
void maxscaleSet(Parse* pParse, int scope, mxs_set_t kind, ExprList* pList)
|
void maxscaleSet(Parse* pParse, int scope, mxs_set_t kind, ExprList* pList)
|
||||||
{
|
{
|
||||||
QC_TRACE();
|
QC_TRACE();
|
||||||
|
@ -125,6 +125,7 @@ extern void maxscaleLock(Parse*, mxs_lock_t, SrcList*);
|
|||||||
extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt);
|
extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt);
|
||||||
extern void maxscalePrivileges(Parse*, int kind);
|
extern void maxscalePrivileges(Parse*, int kind);
|
||||||
extern void maxscaleRenameTable(Parse*, SrcList* pTables);
|
extern void maxscaleRenameTable(Parse*, SrcList* pTables);
|
||||||
|
extern void maxscaleReset(Parse*, int what);
|
||||||
extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*);
|
extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*);
|
||||||
extern void maxscaleShow(Parse*, MxsShow* pShow);
|
extern void maxscaleShow(Parse*, MxsShow* pShow);
|
||||||
extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName);
|
extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName);
|
||||||
@ -614,7 +615,7 @@ columnid(A) ::= nm(X). {
|
|||||||
// TODO: BINARY is a reserved word and should not automatically convert into an identifer.
|
// TODO: BINARY is a reserved word and should not automatically convert into an identifer.
|
||||||
// TODO: However, if not here then rules such as CAST need to be modified.
|
// TODO: However, if not here then rules such as CAST need to be modified.
|
||||||
BINARY
|
BINARY
|
||||||
/*CASCADE*/ CAST CLOSE COLUMNKW COLUMNS COMMENT CONCURRENT /*CONFLICT*/
|
CACHE /*CASCADE*/ CAST CLOSE COLUMNKW COLUMNS COMMENT CONCURRENT /*CONFLICT*/
|
||||||
DATA DATABASE DEALLOCATE DEFERRED /*DESC*/ /*DETACH*/ DUMPFILE
|
DATA DATABASE DEALLOCATE DEFERRED /*DESC*/ /*DETACH*/ DUMPFILE
|
||||||
/*EACH*/ END ENGINE ENUM EXCLUSIVE /*EXPLAIN*/
|
/*EACH*/ END ENGINE ENUM EXCLUSIVE /*EXPLAIN*/
|
||||||
FIRST FLUSH /*FOR*/ FORMAT
|
FIRST FLUSH /*FOR*/ FORMAT
|
||||||
@ -628,8 +629,8 @@ columnid(A) ::= nm(X). {
|
|||||||
NO
|
NO
|
||||||
OF OFFSET OPEN
|
OF OFFSET OPEN
|
||||||
PREVIOUS
|
PREVIOUS
|
||||||
QUICK
|
QUERY QUICK
|
||||||
RAISE RECURSIVE /*REINDEX*/ RELEASE /*RENAME*/ /*REPLACE*/ RESTRICT ROLLBACK ROLLUP ROW
|
RAISE RECURSIVE /*REINDEX*/ RELEASE /*RENAME*/ /*REPLACE*/ RESET RESTRICT ROLLBACK ROLLUP ROW
|
||||||
SAVEPOINT SELECT_OPTIONS_KW /*SEQUENCE*/ SLAVE /*START*/ STATEMENT STATUS
|
SAVEPOINT SELECT_OPTIONS_KW /*SEQUENCE*/ SLAVE /*START*/ STATEMENT STATUS
|
||||||
TABLES TEMP TEMPTABLE /*TRIGGER*/
|
TABLES TEMP TEMPTABLE /*TRIGGER*/
|
||||||
/*TRUNCATE*/
|
/*TRUNCATE*/
|
||||||
@ -3079,6 +3080,12 @@ rename ::= RENAME TABLE tables_to_rename(X). {
|
|||||||
maxscaleRenameTable(pParse, X);
|
maxscaleRenameTable(pParse, X);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////// The RESET statement ////////////////////////////////////
|
||||||
|
//
|
||||||
|
cmd ::= RESET QUERY CACHE. {
|
||||||
|
maxscaleReset(pParse, MXS_RESET_QUERY_CACHE);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////// The SET statement ////////////////////////////////////
|
//////////////////////// The SET statement ////////////////////////////////////
|
||||||
//
|
//
|
||||||
%type set_scope {int}
|
%type set_scope {int}
|
||||||
|
@ -4099,6 +4099,11 @@ typedef enum mxs_drop
|
|||||||
MXS_DROP_SEQUENCE,
|
MXS_DROP_SEQUENCE,
|
||||||
} mxs_drop_t;
|
} mxs_drop_t;
|
||||||
|
|
||||||
|
typedef enum mxs_reset
|
||||||
|
{
|
||||||
|
MXS_RESET_QUERY_CACHE
|
||||||
|
} mxs_reset_t;
|
||||||
|
|
||||||
typedef enum mxs_set
|
typedef enum mxs_set
|
||||||
{
|
{
|
||||||
MXS_SET_VARIABLES,
|
MXS_SET_VARIABLES,
|
||||||
|
@ -180,6 +180,7 @@ static Keyword aKeywordTable[] = {
|
|||||||
{ "BY", "TK_BY", ALWAYS },
|
{ "BY", "TK_BY", ALWAYS },
|
||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
{ "CALL", "TK_CALL", ALWAYS },
|
{ "CALL", "TK_CALL", ALWAYS },
|
||||||
|
{ "CACHE", "TK_CACHE", ALWAYS },
|
||||||
#endif
|
#endif
|
||||||
{ "CASCADE", "TK_CASCADE", FKEY },
|
{ "CASCADE", "TK_CASCADE", FKEY },
|
||||||
{ "CASE", "TK_CASE", ALWAYS },
|
{ "CASE", "TK_CASE", ALWAYS },
|
||||||
@ -391,7 +392,9 @@ static Keyword aKeywordTable[] = {
|
|||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
{ "PROCEDURE", "TK_FUNCTION_KW", ALWAYS },
|
{ "PROCEDURE", "TK_FUNCTION_KW", ALWAYS },
|
||||||
#endif
|
#endif
|
||||||
#ifndef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
|
{ "QUERY", "TK_QUERY", ALWAYS },
|
||||||
|
#else
|
||||||
{ "QUERY", "TK_QUERY", EXPLAIN },
|
{ "QUERY", "TK_QUERY", EXPLAIN },
|
||||||
#endif
|
#endif
|
||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
@ -409,6 +412,9 @@ static Keyword aKeywordTable[] = {
|
|||||||
{ "RELEASE", "TK_RELEASE", ALWAYS },
|
{ "RELEASE", "TK_RELEASE", ALWAYS },
|
||||||
{ "RENAME", "TK_RENAME", ALTER },
|
{ "RENAME", "TK_RENAME", ALTER },
|
||||||
{ "REPLACE", "TK_REPLACE", CONFLICT },
|
{ "REPLACE", "TK_REPLACE", CONFLICT },
|
||||||
|
#ifdef MAXSCALE
|
||||||
|
{ "RESET", "TK_RESET", ALWAYS },
|
||||||
|
#endif
|
||||||
{ "RESTRICT", "TK_RESTRICT", FKEY },
|
{ "RESTRICT", "TK_RESTRICT", FKEY },
|
||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
{ "REVOKE", "TK_REVOKE", ALWAYS },
|
{ "REVOKE", "TK_REVOKE", ALWAYS },
|
||||||
|
Reference in New Issue
Block a user