From 559b786533b0fb6c691ef8d28c8397488ca3b1ae Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 21 Mar 2019 10:06:15 +0200 Subject: [PATCH] MXS-2398 Handle MariaDB specific comments Same approach as with regular comments: - /*M! STMT */ are always parsed. - /*M!###### STMT */ are never parsed. --- .../sqlite-src-3110100/src/tokenize.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/src/tokenize.c b/query_classifier/qc_sqlite/sqlite-src-3110100/src/tokenize.c index 11360dc56..84e4a4538 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/tokenize.c +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/tokenize.c @@ -255,21 +255,27 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){ return 1; } #ifdef MAXSCALE - if ( z[2] == '!' ){ + if ( z[2]=='!' || (z[2]=='M' && z[3]=='!')){ + int j = (z[2]=='M' ? 4 : 3); // MySQL-specific code - for (i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} + for (i=j, c=z[j-1]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} if (c=='*' && z[i]=='/'){ - if (sqlite3Isdigit(z[3])) { - // A version specific executable comment, e.g. "/*!99999 ..." => never parsed. + if (sqlite3Isdigit(z[j])) { + // A version specific executable comment, + // e.g. "/*!99999 ..." or "/*M!99999 ..." => never parsed. extern void maxscaleSetStatusCap(int); maxscaleSetStatusCap(2); // QC_QUERY_PARTIALLY_PARSED, see query_classifier.h:qc_parse_result ++i; // Next after the trailing '/' } else { - // A non-version specific executable comment, e.g. "/*! select 1 */ => always parsed. + // A non-version specific executable comment, + // e.g."/*! select 1 */ or "/*M! select 1 */ => always parsed. char* znc = (char*) z; znc[0]=znc[1]=znc[2]=znc[i-1]=znc[i]=' '; // Remove comment chars, i.e. "/*!" and "*/". - for (i=3; sqlite3Isspace(z[i]); ++i){} // Jump over any space. + if (j==4){ + znc[3]=0; // It wasn't "/*!" but "/*M!". + } + for (i=j; sqlite3Isspace(z[i]); ++i){} // Jump over any space. } } } else {