Merge branch '2.1' into develop

This commit is contained in:
Markus Mäkelä
2017-06-20 11:01:08 +03:00
9 changed files with 79 additions and 20 deletions

View File

@ -16,7 +16,7 @@ endif()
# Set default values for cache entries and set the MaxScale version # Set default values for cache entries and set the MaxScale version
include(cmake/defaults.cmake) include(cmake/defaults.cmake)
include(VERSION.cmake) include(VERSION22.cmake)
include(ExternalProject) 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.") 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.")

14
VERSION21.cmake Normal file
View File

@ -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}")

14
VERSION22.cmake Normal file
View File

@ -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}")

View File

@ -296,6 +296,7 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
CCR_INSTANCE *my_instance = (CCR_INSTANCE *)instance; CCR_INSTANCE *my_instance = (CCR_INSTANCE *)instance;
CCR_SESSION *my_session = (CCR_SESSION *)session; CCR_SESSION *my_session = (CCR_SESSION *)session;
char *sql; char *sql;
regmatch_t limits[] = {{0, 0}};
time_t now = time(NULL); time_t now = time(NULL);
if (modutil_is_SQL(queue)) 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 (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 trigger_ccr = true;
bool decided = false; // Set by hints to take precedence. 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 (!decided)
{ {
if (my_instance->nomatch && 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. // Nomatch was present and sql matched it.
trigger_ccr = false; trigger_ccr = false;
} }
else if (my_instance->match && 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. // Match was present but sql did *not* match it.
trigger_ccr = false; trigger_ccr = false;
@ -351,7 +352,6 @@ routeQuery(MXS_FILTER *instance, MXS_FILTER_SESSION *session, GWBUF *queue)
my_instance->stats.n_modified++; my_instance->stats.n_modified++;
} }
MXS_FREE(sql);
} }
} }
else if (my_session->hints_left > 0) else if (my_session->hints_left > 0)

View File

@ -96,7 +96,11 @@ static const char* token_get_keyword(
{ {
switch (token->token) switch (token->token)
{ {
case TOK_EOL: case TOK_END:
return "End of hint";
break;
case TOK_LINEBRK:
return "End of line"; return "End of line";
break; break;
@ -107,14 +111,14 @@ static const char* token_get_keyword(
default: default:
{ {
int i = 0; int i = 0;
while (i < TOK_EOL && keywords[i].token != token->token) while (i < TOK_LINEBRK && keywords[i].token != token->token)
{ {
i++; i++;
} }
ss_dassert(i != TOK_EOL); ss_dassert(i != TOK_LINEBRK);
if (i == TOK_EOL) if (i == TOK_LINEBRK)
{ {
return "Unknown token"; return "Unknown token";
} }
@ -147,7 +151,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
GWBUF *buf; GWBUF *buf;
HINT_TOKEN *tok; HINT_TOKEN *tok;
HINT_MODE mode = HM_EXECUTE; HINT_MODE mode = HM_EXECUTE;
bool multiline_comment = false;
/* First look for any comment in the SQL */ /* First look for any comment in the SQL */
modutil_MySQL_Query(request, &ptr, &len, &residual); modutil_MySQL_Query(request, &ptr, &len, &residual);
buf = request; buf = request;
@ -180,7 +184,9 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
squoted = 0; squoted = 0;
} }
else if (quoted || squoted) else if (quoted || squoted)
{
; ;
}
else if (escape) else if (escape)
{ {
escape = 0; escape = 0;
@ -197,6 +203,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
else if (*ptr == '*' && lastch == '/') else if (*ptr == '*' && lastch == '/')
{ {
found = 1; found = 1;
multiline_comment = true;
break; break;
} }
else if (*ptr == '-' && lastch == '-') else if (*ptr == '-' && lastch == '-')
@ -271,9 +278,24 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
state = HS_INIT; state = HS_INIT;
while ((tok = hint_next_token(&buf, &ptr)) != NULL while (((tok = hint_next_token(&buf, &ptr)) != NULL) &&
&& tok->token != TOK_EOL) (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) switch (state)
{ {
case HS_INIT: case HS_INIT:
@ -365,6 +387,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
{ {
case TOK_EQUAL: case TOK_EQUAL:
pname = lvalue; pname = lvalue;
lvalue = NULL;
state = HS_PVALUE; state = HS_PVALUE;
break; break;
case TOK_PREPARE: case TOK_PREPARE:
@ -390,6 +413,8 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
case HS_PVALUE: case HS_PVALUE:
/* Action: pname = tok->value */ /* Action: pname = tok->value */
rval = hint_create_parameter(rval, pname, tok->value); rval = hint_create_parameter(rval, pname, tok->value);
MXS_FREE(pname);
pname = NULL;
state = HS_INIT; state = HS_INIT;
break; break;
case HS_PREPARE: case HS_PREPARE:
@ -418,7 +443,7 @@ hint_parser(HINT_SESSION *session, GWBUF *request)
token_free(tok); token_free(tok);
} /*< while */ } /*< while */
if (tok && tok->token == TOK_EOL) if (tok && tok->token == TOK_END)
{ {
token_free(tok); token_free(tok);
} }
@ -536,8 +561,8 @@ hint_next_token(GWBUF **buf, char **ptr)
inword = 0; inword = 0;
break; break;
} }
/** found '=', move ptr and return with '=' */ /** found '=' or '\n', move ptr and return with the char */
else if (!inword && inquote == '\0' && **ptr == '=') else if (!inword && inquote == '\0' && ((**ptr == '=') || (**ptr == '\n')))
{ {
*dest = **ptr; *dest = **ptr;
dest++; dest++;
@ -590,7 +615,12 @@ hint_next_token(GWBUF **buf, char **ptr)
*/ */
if (word[0] == '\0' || (word[0] == '*' && word[1] == '/')) 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; return tok;
} }
found = 0; found = 0;

View File

@ -40,7 +40,8 @@ typedef enum
TOK_MASTER, TOK_MASTER,
TOK_SLAVE, TOK_SLAVE,
TOK_SERVER, TOK_SERVER,
TOK_EOL TOK_LINEBRK,
TOK_END
} TOKEN_VALUE; } TOKEN_VALUE;
/* The tokenising return type */ /* The tokenising return type */

View File

@ -640,7 +640,7 @@ static MXS_MONITOR_SERVERS *build_mysql51_replication_tree(MXS_MONITOR *mon)
(database->server->master_id <= 0 || (database->server->master_id <= 0 ||
database->server->master_id != handle->master->server->node_id)) 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); monitor_set_pending_status(database, SERVER_SLAVE_OF_EXTERNAL_MASTER);
} }
database = database->next; 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 /* this server is slave of another server not in MaxScale configuration
* we cannot use it as a real slave. * 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); monitor_set_pending_status(ptr, SERVER_SLAVE_OF_EXTERNAL_MASTER);
} }
} }

View File

@ -38,7 +38,7 @@ while True:
if len(buf) == 0: if len(buf) == 0:
break break
data = buf.encode().strip() data = buf[:-1]
producer.send(topic=opts.kafka_topic, value=data) producer.send(topic=opts.kafka_topic, value=data)
producer.flush() producer.flush()