From fa2a66719554d13a00db5c81c5c9ffd5b3a2ce14 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 29 Sep 2016 23:48:21 +0300 Subject: [PATCH] qc_sqlite: Handle a name like ```a`. --- query_classifier/qc_sqlite/qc_sqlite.c | 1 + query_classifier/qc_sqlite/sqlite-src-3110100/src/util.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/query_classifier/qc_sqlite/qc_sqlite.c b/query_classifier/qc_sqlite/qc_sqlite.c index 9c7b086ce..6253b2a33 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.c +++ b/query_classifier/qc_sqlite/qc_sqlite.c @@ -919,6 +919,7 @@ static void update_database_names(QC_SQLITE_INFO* info, const char* zDatabase) static void update_names(QC_SQLITE_INFO* info, const char* zDatabase, const char* zTable) { char* zCopy = mxs_strdup(zTable); + // TODO: Is this call really needed. Check also sqlite3Dequote. exposed_sqlite3Dequote(zCopy); enlarge_string_array(1, info->table_names_len, &info->table_names, &info->table_names_capacity); diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/src/util.c b/query_classifier/qc_sqlite/sqlite-src-3110100/src/util.c index 94b10b481..2030e0e0c 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/util.c +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/util.c @@ -220,7 +220,13 @@ int sqlite3Dequote(char *z){ for(i=1, j=0;; i++){ assert( z[i] ); #ifdef MAXSCALE - if ( z[i]=='\\' ){ + if ( z[i]==0 ){ + // TODO: This is needed only because exposed_sqlite3Dequote() is called + // TODO: in qc_sqlite.c:update_names(). That call probably is not needed + // TODO: and should be removed, in which case this check could also be + // TODO: removed. + break; + }else if ( z[i]=='\\' ){ z[j++] = '\\'; if ( z[i+1]==quote || z[i+1]=='\\' ){ z[j++] = quote;