MXS-2431 Recognize the XA keyword

Recognize the XA keyword and classify the statement as write.
Needs to be dealt with explicitly as sqlite3 assumes there are
no keywords starting with the letter X.
This commit is contained in:
Johan Wikman
2019-04-12 10:33:53 +03:00
parent 62f2a86a5f
commit 4131f09c16
4 changed files with 33 additions and 12 deletions

View File

@ -1575,18 +1575,16 @@ public:
} }
} }
void mxs_sqlite3BeginTrigger(Parse* pParse, /* The parse context of the CREATE TRIGGER statement void mxs_sqlite3BeginTrigger(Parse* pParse, /* The parse context of the CREATE TRIGGER statement */
* */ Token* pName1, /* The name of the trigger */
Token* pName1, /* The name of the trigger */ Token* pName2, /* The name of the trigger */
Token* pName2, /* The name of the trigger */ int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ IdList* pColumns, /* column list if this is an UPDATE OF trigger */
IdList* pColumns, /* column list if this is an UPDATE OF trigger */ SrcList* pTableName, /* The name of the table/view the trigger applies to */
SrcList* pTableName, /* The name of the table/view the trigger applies to Expr* pWhen, /* WHEN clause */
* */ int isTemp, /* True if the TEMPORARY keyword is present */
Expr* pWhen, /* WHEN clause */ int noErr) /* Suppress errors if the trigger already exists */
int isTemp, /* True if the TEMPORARY keyword is present */
int noErr) /* Suppress errors if the trigger already exists */
{ {
mxb_assert(this_thread.initialized); mxb_assert(this_thread.initialized);
@ -2632,6 +2630,11 @@ public:
m_type_mask = (QUERY_TYPE_WRITE | QUERY_TYPE_COMMIT); m_type_mask = (QUERY_TYPE_WRITE | QUERY_TYPE_COMMIT);
break; break;
case TK_XA:
m_status = QC_QUERY_TOKENIZED;
m_type_mask = QUERY_TYPE_WRITE;
break;
default: default:
; ;
} }

View File

@ -639,6 +639,7 @@ columnid(A) ::= nm(X). {
VALUE VIEW /*VIRTUAL*/ VALUE VIEW /*VIRTUAL*/
/*WITH*/ /*WITH*/
WORK WORK
XA
%endif %endif
. .
%wildcard ANY. %wildcard ANY.

View File

@ -626,6 +626,22 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
/* If it is not a BLOB literal, then it must be an ID, since no /* If it is not a BLOB literal, then it must be an ID, since no
** SQL keywords start with the letter 'x'. Fall through */ ** SQL keywords start with the letter 'x'. Fall through */
} }
#endif
#ifdef MAXSCALE
// It may be the "XA" keyword.
// If the next character is 'a' or 'A', followed by whitespace or a
// comment, then we are indeed dealing with the "XA" keyword.
if (( z[1]=='a' || z[1]=='A' ) &&
(sqlite3Isspace(z[2]) || // Whitespace
(z[2]=='/' && z[3]=='*') || // Beginning of /* comment
(z[2]=='#') || // # eol comment
(z[2]=='-' && z[3]=='-' && sqlite3Isspace(z[4])))) { // -- eol comment
extern int maxscaleKeyword(int);
*tokenType = TK_XA;
maxscaleKeyword(*tokenType);
return 2;
}
#endif #endif
case CC_ID: { case CC_ID: {
i = 1; i = 1;

View File

@ -500,6 +500,7 @@ static Keyword aKeywordTable[] = {
#ifdef MAXSCALE #ifdef MAXSCALE
{ "WORK", "TK_WORK", ALWAYS }, { "WORK", "TK_WORK", ALWAYS },
{ "WRITE", "TK_WRITE", ALWAYS }, { "WRITE", "TK_WRITE", ALWAYS },
{ "XA", "TK_XA", ALWAYS },
#endif #endif
{ "ZEROFILL", "TK_ZEROFILL", ALWAYS }, { "ZEROFILL", "TK_ZEROFILL", ALWAYS },
}; };