Fix for Bug #466, http://bugs.skysql.com/show_bug.cgi?id=466
hintparser.c:hint_parser:when string token is found, create a copy of the token value instead of copying the its address because token will be freed before the value is used. hint_next_token:didn't recognize '=' as TOK_EQUAL, fixed that. Read the code. hint.c:hint_create_parameter: copy the pointer to parameter name instead of creating copy of it - pname is already copied from token before the call readwritesplit.c:routeQuery:Hint name was copied when hint value was supposed to be copied, thus resulting invalid value for hinted parameter. Also fixed server type in trace log command. skygw_debug.h:Added string for Relay server to macro STRSRVSTATUS.
This commit is contained in:
@ -115,7 +115,7 @@ HINT *hint;
|
|||||||
return head;
|
return head;
|
||||||
hint->next = head;
|
hint->next = head;
|
||||||
hint->type = HINT_PARAMETER;
|
hint->type = HINT_PARAMETER;
|
||||||
hint->data = strdup(pname);
|
hint->data = pname;
|
||||||
hint->value = strdup(value);
|
hint->value = strdup(value);
|
||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ HINT_MODE mode = HM_EXECUTE;
|
|||||||
break;
|
break;
|
||||||
case TOK_STRING:
|
case TOK_STRING:
|
||||||
state = HS_NAME;
|
state = HS_NAME;
|
||||||
lvalue = tok->value;
|
lvalue = strdup(tok->value);
|
||||||
break;
|
break;
|
||||||
case TOK_STOP:
|
case TOK_STOP:
|
||||||
/* Action: pop active hint */
|
/* Action: pop active hint */
|
||||||
@ -451,31 +451,42 @@ HINT_TOKEN *tok;
|
|||||||
dest = word;
|
dest = word;
|
||||||
while (*ptr < (char *)((*buf)->end) || (*buf)->next)
|
while (*ptr < (char *)((*buf)->end) || (*buf)->next)
|
||||||
{
|
{
|
||||||
|
/** word ends, don't move ptr but return with read word */
|
||||||
if (inword && inquote == '\0' &&
|
if (inword && inquote == '\0' &&
|
||||||
(**ptr == '=' || isspace(**ptr)))
|
(isspace(**ptr) || **ptr == '='))
|
||||||
{
|
{
|
||||||
inword = 0;
|
inword = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/** found '=', move ptr and return with '=' */
|
||||||
|
else if (!inword && inquote == '\0' && **ptr == '=')
|
||||||
|
{
|
||||||
|
*dest = **ptr;
|
||||||
|
*dest++;
|
||||||
|
(*ptr)++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
else if (**ptr == '\'' && inquote == '\'')
|
else if (**ptr == '\'' && inquote == '\'')
|
||||||
inquote = '\0';
|
inquote = '\0';
|
||||||
else if (**ptr == '\'')
|
else if (**ptr == '\'')
|
||||||
inquote = **ptr;
|
inquote = **ptr;
|
||||||
|
/** Any other character which belongs to the word, move ahead */
|
||||||
else if (inword || (isspace(**ptr) == 0))
|
else if (inword || (isspace(**ptr) == 0))
|
||||||
{
|
{
|
||||||
*dest++ = **ptr;
|
*dest++ = **ptr;
|
||||||
inword = 1;
|
inword = 1;
|
||||||
}
|
}
|
||||||
(*ptr)++;
|
(*ptr)++;
|
||||||
|
|
||||||
if (*ptr > (char *)((*buf)->end) && (*buf)->next)
|
if (*ptr > (char *)((*buf)->end) && (*buf)->next)
|
||||||
{
|
{
|
||||||
*buf = (*buf)->next;
|
*buf = (*buf)->next;
|
||||||
*ptr = (*buf)->start;
|
*ptr = (*buf)->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest - word > 98)
|
if (dest - word > 98)
|
||||||
break;
|
break;
|
||||||
|
} /*< while */
|
||||||
}
|
|
||||||
*dest = 0;
|
*dest = 0;
|
||||||
|
|
||||||
/* We now have a word in the local word, check to see if it is a
|
/* We now have a word in the local word, check to see if it is a
|
||||||
|
@ -1417,7 +1417,7 @@ static int routeQuery(
|
|||||||
"max_slave_replication_lag",
|
"max_slave_replication_lag",
|
||||||
strlen("max_slave_replication_lag")) == 0))
|
strlen("max_slave_replication_lag")) == 0))
|
||||||
{
|
{
|
||||||
int val = (int) strtol((char *)hint->data,
|
int val = (int) strtol((char *)hint->value,
|
||||||
(char **)NULL, 10);
|
(char **)NULL, 10);
|
||||||
|
|
||||||
if (val != 0 || errno == 0)
|
if (val != 0 || errno == 0)
|
||||||
@ -2308,9 +2308,7 @@ static bool select_connect_backend_servers(
|
|||||||
LOGIF(LT, (skygw_log_write(
|
LOGIF(LT, (skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_TRACE,
|
||||||
"Selected %s in \t%s:%d",
|
"Selected %s in \t%s:%d",
|
||||||
(btype == BE_MASTER ? "master" :
|
STRSRVSTATUS(b->backend_server),
|
||||||
(btype == BE_SLAVE ? "slave" :
|
|
||||||
"unknown node type")),
|
|
||||||
b->backend_server->name,
|
b->backend_server->name,
|
||||||
b->backend_server->port)));
|
b->backend_server->port)));
|
||||||
}
|
}
|
||||||
|
@ -232,12 +232,13 @@ typedef enum skygw_chk_t {
|
|||||||
((c) == LEAST_BEHIND_MASTER ? "LEAST_BEHIND_MASTER" : \
|
((c) == LEAST_BEHIND_MASTER ? "LEAST_BEHIND_MASTER" : \
|
||||||
((c) == LEAST_CURRENT_OPERATIONS ? "LEAST_CURRENT_OPERATIONS" : "Unknown criteria")))))
|
((c) == LEAST_CURRENT_OPERATIONS ? "LEAST_CURRENT_OPERATIONS" : "Unknown criteria")))))
|
||||||
|
|
||||||
#define STRSRVSTATUS(s) ((SERVER_IS_RUNNING(s) && SERVER_IS_MASTER(s)) ? "RUNNING MASTER" : \
|
#define STRSRVSTATUS(s) (SERVER_IS_MASTER(s) ? "RUNNING MASTER" : \
|
||||||
((SERVER_IS_RUNNING(s) && SERVER_IS_SLAVE(s)) ? "RUNNING SLAVE" : \
|
(SERVER_IS_SLAVE(s) ? "RUNNING SLAVE" : \
|
||||||
((SERVER_IS_RUNNING(s) && SERVER_IS_JOINED(s)) ? "RUNNING JOINED" : \
|
(SERVER_IS_JOINED(s) ? "RUNNING JOINED" : \
|
||||||
((SERVER_IS_RUNNING(s) && SERVER_IS_NDB(s)) ? "RUNNING NDB" : \
|
(SERVER_IS_NDB(s) ? "RUNNING NDB" : \
|
||||||
((SERVER_IS_RUNNING(s) && SERVER_IN_MAINT(s)) ? "RUNNING MAINTENANCE" : \
|
((SERVER_IS_RUNNING(s) && SERVER_IN_MAINT(s)) ? "RUNNING MAINTENANCE" : \
|
||||||
(SERVER_IS_RUNNING(s) ? "RUNNING (only)" : "NO STATUS"))))))
|
(SERVER_IS_RELAY_SERVER(s) ? "RUNNING RELAY" : \
|
||||||
|
(SERVER_IS_RUNNING(s) ? "RUNNING (only)" : "NO STATUS")))))))
|
||||||
|
|
||||||
#define CHK_MLIST(l) { \
|
#define CHK_MLIST(l) { \
|
||||||
ss_info_dassert((l->mlist_chk_top == CHK_NUM_MLIST && \
|
ss_info_dassert((l->mlist_chk_top == CHK_NUM_MLIST && \
|
||||||
|
Reference in New Issue
Block a user