Fix to bug #585, http://bugs.mariadb.com/show_bug.cgi?id=585
buffer.c:gwbuf_make_contiguous: when new buffer is created, copy original buffer's type to new buffer modutil.c:modutil_replace_SQL: when new bugger is added to GWBUF, copy original buffer's type to new buffer In all filters, merge all buffers of GWBUF to one before calling modutil:extract_SQL
This commit is contained in:
@ -569,7 +569,9 @@ int len;
|
||||
|
||||
if ((newbuf = gwbuf_alloc(gwbuf_length(orig))) != NULL)
|
||||
{
|
||||
gwbuf_type_t buftype = orig->gwbuf_type;
|
||||
ptr = GWBUF_DATA(newbuf);
|
||||
|
||||
while (orig)
|
||||
{
|
||||
len = GWBUF_LENGTH(orig);
|
||||
@ -577,6 +579,7 @@ int len;
|
||||
ptr += len;
|
||||
orig = gwbuf_consume(orig, len);
|
||||
}
|
||||
newbuf->gwbuf_type = buftype;
|
||||
}
|
||||
return newbuf;
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ GWBUF *addition;
|
||||
*ptr++ = (newlength + 1) & 0xff;
|
||||
*ptr++ = ((newlength + 1) >> 8) & 0xff;
|
||||
*ptr++ = ((newlength + 1) >> 16) & 0xff;
|
||||
addition->gwbuf_type = orig->gwbuf_type;
|
||||
orig->next = addition;
|
||||
}
|
||||
|
||||
|
@ -1168,6 +1168,10 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
||||
|
||||
}
|
||||
|
||||
if (queue->next != NULL)
|
||||
{
|
||||
queue = gwbuf_make_contiguous(queue);
|
||||
}
|
||||
|
||||
if(modutil_extract_SQL(queue, &ptr, &length)){
|
||||
|
||||
|
@ -358,7 +358,13 @@ int length;
|
||||
struct tm t;
|
||||
struct timeval tv;
|
||||
|
||||
if (my_session->active && modutil_extract_SQL(queue, &ptr, &length))
|
||||
if (my_session->active)
|
||||
{
|
||||
if (queue->next != NULL)
|
||||
{
|
||||
queue = gwbuf_make_contiguous(queue);
|
||||
}
|
||||
if (modutil_extract_SQL(queue, &ptr, &length) != 0)
|
||||
{
|
||||
if ((my_instance->match == NULL ||
|
||||
regexec(&my_instance->re, ptr, 0, NULL, 0) == 0) &&
|
||||
@ -375,7 +381,7 @@ struct timeval tv;
|
||||
fwrite("\n", sizeof(char), 1, my_session->fp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* Pass the query downstream */
|
||||
return my_session->down.routeQuery(my_session->down.instance,
|
||||
my_session->down.session, queue);
|
||||
|
@ -305,6 +305,10 @@ int length;
|
||||
|
||||
if (modutil_is_SQL(queue))
|
||||
{
|
||||
if (queue->next != NULL)
|
||||
{
|
||||
queue = gwbuf_make_contiguous(queue);
|
||||
}
|
||||
modutil_extract_SQL(queue, &sql, &length);
|
||||
newsql = regex_replace(sql, length, &my_instance->re,
|
||||
my_instance->replace);
|
||||
|
@ -455,7 +455,13 @@ TOPN_SESSION *my_session = (TOPN_SESSION *)session;
|
||||
char *ptr;
|
||||
int length;
|
||||
|
||||
if (my_session->active && modutil_extract_SQL(queue, &ptr, &length))
|
||||
if (my_session->active)
|
||||
{
|
||||
if (queue->next != NULL)
|
||||
{
|
||||
queue = gwbuf_make_contiguous(queue);
|
||||
}
|
||||
if (modutil_extract_SQL(queue, &ptr, &length) != 0)
|
||||
{
|
||||
if ((my_instance->match == NULL ||
|
||||
regexec(&my_instance->re, ptr, 0, NULL, 0) == 0) &&
|
||||
@ -469,7 +475,7 @@ int length;
|
||||
my_session->current = strndup(ptr, length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* Pass the query downstream */
|
||||
return my_session->down.routeQuery(my_session->down.instance,
|
||||
my_session->down.session, queue);
|
||||
|
@ -1160,10 +1160,8 @@ static bool get_dcb(
|
||||
rses->router->service->name)));
|
||||
}
|
||||
|
||||
|
||||
btype = BE_MASTER;
|
||||
|
||||
|
||||
if (BREF_IS_IN_USE(master_bref))
|
||||
{
|
||||
*p_dcb = master_bref->bref_dcb;
|
||||
@ -2048,7 +2046,6 @@ static int routeQuery(
|
||||
succp = false;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (succp) /*< Have DCB of the target backend */
|
||||
|
Reference in New Issue
Block a user