diff --git a/CMakeLists.txt b/CMakeLists.txt index d2bc816d8..bf0c1ecac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif() # Set default values for cache entries and set the MaxScale version include(cmake/defaults.cmake) -include(VERSION.cmake) +include(VERSION22.cmake) include(ExternalProject) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") diff --git a/VERSION.cmake b/VERSION20.cmake similarity index 100% rename from VERSION.cmake rename to VERSION20.cmake diff --git a/VERSION21.cmake b/VERSION21.cmake new file mode 100644 index 000000000..c79617932 --- /dev/null +++ b/VERSION21.cmake @@ -0,0 +1,14 @@ +# MaxScale version for CMake +# +# This file contains cache values for CMake which control MaxScale's version +# number. + +set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version") +set(MAXSCALE_VERSION_MINOR "1" CACHE STRING "Minor version") +set(MAXSCALE_VERSION_PATCH "3" CACHE STRING "Patch version") + +# This should only be incremented if a package is rebuilt +set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number") + +set(MAXSCALE_VERSION_NUMERIC "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") +set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") diff --git a/VERSION22.cmake b/VERSION22.cmake new file mode 100644 index 000000000..c79617932 --- /dev/null +++ b/VERSION22.cmake @@ -0,0 +1,14 @@ +# MaxScale version for CMake +# +# This file contains cache values for CMake which control MaxScale's version +# number. + +set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version") +set(MAXSCALE_VERSION_MINOR "1" CACHE STRING "Minor version") +set(MAXSCALE_VERSION_PATCH "3" CACHE STRING "Patch version") + +# This should only be incremented if a package is rebuilt +set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number") + +set(MAXSCALE_VERSION_NUMERIC "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") +set(MAXSCALE_VERSION "${MAXSCALE_VERSION_MAJOR}.${MAXSCALE_VERSION_MINOR}.${MAXSCALE_VERSION_PATCH}") diff --git a/server/modules/filter/ccrfilter/ccrfilter.c b/server/modules/filter/ccrfilter/ccrfilter.c index d85b66e3b..8dee80ade 100644 --- a/server/modules/filter/ccrfilter/ccrfilter.c +++ b/server/modules/filter/ccrfilter/ccrfilter.c @@ -296,6 +296,7 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue) CCR_INSTANCE *my_instance = (CCR_INSTANCE *)instance; CCR_SESSION *my_session = (CCR_SESSION *)session; char *sql; + regmatch_t limits[] = {{0, 0}}; time_t now = time(NULL); if (modutil_is_SQL(queue)) @@ -306,7 +307,7 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue) */ if (qc_query_is_type(qc_get_type_mask(queue), QUERY_TYPE_WRITE)) { - if ((sql = modutil_get_SQL(queue)) != NULL) + if (modutil_extract_SQL(queue, &sql, &limits[0].rm_eo)) { bool trigger_ccr = true; bool decided = false; // Set by hints to take precedence. @@ -323,13 +324,13 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue) if (!decided) { if (my_instance->nomatch && - regexec(&my_instance->nore, sql, 0, NULL, 0) == 0) + regexec(&my_instance->nore, sql, 0, limits, 0) == 0) { // Nomatch was present and sql matched it. trigger_ccr = false; } else if (my_instance->match && - (regexec(&my_instance->re, sql, 0, NULL, 0) != 0)) + (regexec(&my_instance->re, sql, 0, limits, 0) != 0)) { // Match was present but sql did *not* match it. trigger_ccr = false; @@ -351,7 +352,6 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue) my_instance->stats.n_modified++; } - MXS_FREE(sql); } } else if (my_session->hints_left > 0) diff --git a/server/modules/filter/hintfilter/hintparser.c b/server/modules/filter/hintfilter/hintparser.c index 3881df8bb..f0dd24712 100644 --- a/server/modules/filter/hintfilter/hintparser.c +++ b/server/modules/filter/hintfilter/hintparser.c @@ -96,7 +96,11 @@ static const char* token_get_keyword( { switch (token->token) { - case TOK_EOL: + case TOK_END: + return "End of hint"; + break; + + case TOK_LINEBRK: return "End of line"; break; @@ -107,14 +111,14 @@ static const char* token_get_keyword( default: { int i = 0; - while (i < TOK_EOL && keywords[i].token != token->token) + while (i < TOK_LINEBRK && keywords[i].token != token->token) { i++; } - ss_dassert(i != TOK_EOL); + ss_dassert(i != TOK_LINEBRK); - if (i == TOK_EOL) + if (i == TOK_LINEBRK) { return "Unknown token"; } @@ -147,7 +151,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request) GWBUF *buf; HINT_TOKEN *tok; HINT_MODE mode = HM_EXECUTE; - + bool multiline_comment = false; /* First look for any comment in the SQL */ modutil_MySQL_Query(request, &ptr, &len, &residual); buf = request; @@ -180,7 +184,9 @@ hint_parser(HINT_SESSION *session, GWBUF *request) squoted = 0; } else if (quoted || squoted) + { ; + } else if (escape) { escape = 0; @@ -197,6 +203,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request) else if (*ptr == '*' && lastch == '/') { found = 1; + multiline_comment = true; break; } else if (*ptr == '-' && lastch == '-') @@ -271,9 +278,24 @@ hint_parser(HINT_SESSION *session, GWBUF *request) state = HS_INIT; - while ((tok = hint_next_token(&buf, &ptr)) != NULL - && tok->token != TOK_EOL) + while (((tok = hint_next_token(&buf, &ptr)) != NULL) && + (tok->token != TOK_END)) { + if (tok->token == TOK_LINEBRK) + { + if (multiline_comment) + { + // Skip token + token_free(tok); + continue; + } + else + { + // Treat as TOK_END + tok->token = TOK_END; + break; + } + } switch (state) { case HS_INIT: @@ -365,6 +387,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request) { case TOK_EQUAL: pname = lvalue; + lvalue = NULL; state = HS_PVALUE; break; case TOK_PREPARE: @@ -390,6 +413,8 @@ hint_parser(HINT_SESSION *session, GWBUF *request) case HS_PVALUE: /* Action: pname = tok->value */ rval = hint_create_parameter(rval, pname, tok->value); + MXS_FREE(pname); + pname = NULL; state = HS_INIT; break; case HS_PREPARE: @@ -418,7 +443,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request) token_free(tok); } /*< while */ - if (tok && tok->token == TOK_EOL) + if (tok && tok->token == TOK_END) { token_free(tok); } @@ -536,8 +561,8 @@ hint_next_token(GWBUF **buf, char **ptr) inword = 0; break; } - /** found '=', move ptr and return with '=' */ - else if (!inword && inquote == '\0' && **ptr == '=') + /** found '=' or '\n', move ptr and return with the char */ + else if (!inword && inquote == '\0' && ((**ptr == '=') || (**ptr == '\n'))) { *dest = **ptr; dest++; @@ -590,7 +615,12 @@ hint_next_token(GWBUF **buf, char **ptr) */ if (word[0] == '\0' || (word[0] == '*' && word[1] == '/')) { - tok->token = TOK_EOL; + tok->token = TOK_END; + return tok; + } + if (word[0] == '\n') + { + tok->token = TOK_LINEBRK; return tok; } found = 0; diff --git a/server/modules/filter/hintfilter/mysqlhint.h b/server/modules/filter/hintfilter/mysqlhint.h index 38004e6ef..7c0321510 100644 --- a/server/modules/filter/hintfilter/mysqlhint.h +++ b/server/modules/filter/hintfilter/mysqlhint.h @@ -40,7 +40,8 @@ typedef enum TOK_MASTER, TOK_SLAVE, TOK_SERVER, - TOK_EOL + TOK_LINEBRK, + TOK_END } TOKEN_VALUE; /* The tokenising return type */ diff --git a/server/modules/monitor/mysqlmon/mysql_mon.c b/server/modules/monitor/mysqlmon/mysql_mon.c index c8c00e498..8a0547c51 100644 --- a/server/modules/monitor/mysqlmon/mysql_mon.c +++ b/server/modules/monitor/mysqlmon/mysql_mon.c @@ -640,7 +640,7 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon) (database->server->master_id <= 0 || database->server->master_id != handle->master->server->node_id)) { - monitor_clear_pending_status(database, SERVER_SLAVE); + monitor_set_pending_status(database, SERVER_SLAVE); monitor_set_pending_status(database, SERVER_SLAVE_OF_EXTERNAL_MASTER); } database = database->next; @@ -1853,7 +1853,7 @@ static MXS_MONITOR_SERVERS *get_replication_tree(MXS_MONITOR *mon, int num_serve /* this server is slave of another server not in MaxScale configuration * we cannot use it as a real slave. */ - monitor_clear_pending_status(ptr, SERVER_SLAVE); + monitor_set_pending_status(ptr, SERVER_SLAVE); monitor_set_pending_status(ptr, SERVER_SLAVE_OF_EXTERNAL_MASTER); } } diff --git a/server/modules/protocol/examples/cdc_kafka_producer.py b/server/modules/protocol/examples/cdc_kafka_producer.py index 8e78a1c42..f660ea781 100755 --- a/server/modules/protocol/examples/cdc_kafka_producer.py +++ b/server/modules/protocol/examples/cdc_kafka_producer.py @@ -38,7 +38,7 @@ while True: if len(buf) == 0: break - data = buf.encode().strip() + data = buf[:-1] producer.send(topic=opts.kafka_topic, value=data) producer.flush()