diff --git a/query_classifier/qc_sqlite/CMakeLists.txt b/query_classifier/qc_sqlite/CMakeLists.txt index d0092d981..59c82a1ac 100644 --- a/query_classifier/qc_sqlite/CMakeLists.txt +++ b/query_classifier/qc_sqlite/CMakeLists.txt @@ -21,7 +21,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=array-bounds") add_library(qc_sqlite SHARED qc_sqlite.cc qc_sqlite3.c builtin_functions.c) add_dependencies(qc_sqlite maxscale_sqlite) -add_definitions(-DMAXSCALE -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_OMIT_ATTACH -DSQLITE_OMIT_REINDEX -DSQLITE_OMIT_AUTOVACUUM -DSQLITE_OMIT_PRAGMA) +# If you feel a need to add something here, check also the handling of 'enable_maxscale' +# in sqlite-src-3110100/configure. +# In configure we have defined SQLITE_OMIT_VIRTUALTABLE, but it cannot be defined here, +# although conceptually is should, as one needed static function in case will be missing. +add_definitions(-DMAXSCALE -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_OMIT_ATTACH -DSQLITE_OMIT_REINDEX -DSQLITE_OMIT_AUTOVACUUM -DSQLITE_OMIT_PRAGMA ) set_target_properties(qc_sqlite PROPERTIES VERSION "1.0.0") set_target_properties(qc_sqlite PROPERTIES LINK_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/qc_sqlite.map) diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/configure b/query_classifier/qc_sqlite/sqlite-src-3110100/configure index 224f6d368..69a2d50d3 100755 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/configure +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/configure @@ -11506,7 +11506,9 @@ else fi if test "${enable_maxscale}" = "yes" ; then - OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS -DMAXSCALE -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_OMIT_ATTACH -DSQLITE_OMIT_REINDEX -DSQLITE_OMIT_AUTOVACUUM -DSQLITE_OMIT_PRAGMA" + # If something is added here, check the obvious 'add_definitions' + # in ../CMakeLists.txt + OPT_FEATURE_FLAGS="$OPT_FEATURE_FLAGS -DMAXSCALE -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_OMIT_ATTACH -DSQLITE_OMIT_REINDEX -DSQLITE_OMIT_AUTOVACUUM -DSQLITE_OMIT_PRAGMA -DSQLITE_OMIT_VIRTUALTABLE" fi ######### diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y index fc76fc231..e5e9de952 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y @@ -384,10 +384,21 @@ create_table ::= createkw temp(T) TABLE ifnotexists(E) nm(Y) dbnm(Z). { sqlite3StartTable(pParse,&Y,&Z,T,0,0,E); #endif } +%ifdef MAXSCALE +or_replace_opt ::= . +or_replace_opt ::= OR REPLACE. + +createkw(A) ::= CREATE(X) or_replace_opt. { + disableLookaside(pParse); + A = X; +} +%endif +%ifndef MAXSCALE createkw(A) ::= CREATE(X). { disableLookaside(pParse); A = X; } +%endif %type ifnotexists {int} ifnotexists(A) ::= . {A = 0;} ifnotexists(A) ::= IF NOT EXISTS. {A = 1;} @@ -904,9 +915,6 @@ ifexists(A) ::= . {A = 0;} // %ifndef SQLITE_OMIT_VIEW %ifdef MAXSCALE -or_replace_opt ::= . -or_replace_opt ::= OR REPLACE. - %type algorithm {int} algorithm(A) ::= UNDEFINED. {A=0;} algorithm(A) ::= MERGE. {A=0;} @@ -916,7 +924,7 @@ algorithm(A) ::= TEMPTABLE. {A=1;} algorithm_opt(A) ::= . {A=0;} algorithm_opt(A) ::= ALGORITHM EQ algorithm(X). {A=X;} -cmd ::= createkw(X) or_replace_opt algorithm_opt(T) VIEW ifnotexists(E) nm(Y) dbnm(Z) eidlist_opt(C) +cmd ::= createkw(X) algorithm_opt(T) VIEW ifnotexists(E) nm(Y) dbnm(Z) eidlist_opt(C) AS select(S). { mxs_sqlite3CreateView(pParse, &X, &Y, &Z, C, S, T, E); sqlite3SelectDelete(pParse->db, S); diff --git a/query_classifier/test/classify.c b/query_classifier/test/classify.c index 39ac87aa9..cb2cd2080 100644 --- a/query_classifier/test/classify.c +++ b/query_classifier/test/classify.c @@ -313,7 +313,9 @@ int main(int argc, char** argv) if (mxs_log_init(NULL, ".", MXS_LOG_TARGET_DEFAULT)) { - if (qc_setup(lib, QC_SQL_MODE_DEFAULT, NULL) && qc_process_init(QC_INIT_BOTH)) + if (qc_setup(lib, QC_SQL_MODE_DEFAULT, NULL) && + qc_process_init(QC_INIT_BOTH) && + qc_thread_init(QC_INIT_BOTH)) { rc = run(input_name, expected_name); qc_process_end(QC_INIT_BOTH); diff --git a/query_classifier/test/crash_qc_sqlite.c b/query_classifier/test/crash_qc_sqlite.c index 23930f66c..c3d4fda8c 100644 --- a/query_classifier/test/crash_qc_sqlite.c +++ b/query_classifier/test/crash_qc_sqlite.c @@ -41,7 +41,9 @@ int main() set_libdir(strdup("../qc_sqlite")); - if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL) && qc_process_init(QC_INIT_BOTH)) + if (qc_setup("qc_sqlite", QC_SQL_MODE_DEFAULT, NULL) && + qc_process_init(QC_INIT_BOTH) && + qc_thread_init(QC_INIT_BOTH)) { const char s[] = "SELECT @@global.max_allowed_packet"; diff --git a/query_classifier/test/maxscale.test b/query_classifier/test/maxscale.test index 6b9b59449..92db02501 100644 --- a/query_classifier/test/maxscale.test +++ b/query_classifier/test/maxscale.test @@ -86,4 +86,6 @@ select * from db1.t1 union select * from db2.t2; select names from t; call p1(); -call p1(@var); \ No newline at end of file +call p1(@var); + +create or replace table t (a int); diff --git a/query_classifier/test/version_sensitivity.cc b/query_classifier/test/version_sensitivity.cc index 9831b166b..6655f1355 100644 --- a/query_classifier/test/version_sensitivity.cc +++ b/query_classifier/test/version_sensitivity.cc @@ -133,13 +133,13 @@ int main(int argc, char* argv[]) if (qc_setup(QC_LIB, QC_SQL_MODE_DEFAULT, NULL)) { - if (qc_process_init(QC_INIT_BOTH)) + if (qc_process_init(QC_INIT_BOTH) && qc_thread_init(QC_INIT_BOTH)) { rc = test(); } else { - cerr << "error: Could not perform process initialization for " << QC_LIB << "." << endl; + cerr << "error: Could not perform process/thread initialization for " << QC_LIB << "." << endl; } } else