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)
|
if ((newbuf = gwbuf_alloc(gwbuf_length(orig))) != NULL)
|
||||||
{
|
{
|
||||||
|
gwbuf_type_t buftype = orig->gwbuf_type;
|
||||||
ptr = GWBUF_DATA(newbuf);
|
ptr = GWBUF_DATA(newbuf);
|
||||||
|
|
||||||
while (orig)
|
while (orig)
|
||||||
{
|
{
|
||||||
len = GWBUF_LENGTH(orig);
|
len = GWBUF_LENGTH(orig);
|
||||||
@ -577,6 +579,7 @@ int len;
|
|||||||
ptr += len;
|
ptr += len;
|
||||||
orig = gwbuf_consume(orig, len);
|
orig = gwbuf_consume(orig, len);
|
||||||
}
|
}
|
||||||
|
newbuf->gwbuf_type = buftype;
|
||||||
}
|
}
|
||||||
return newbuf;
|
return newbuf;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ GWBUF *addition;
|
|||||||
*ptr++ = (newlength + 1) & 0xff;
|
*ptr++ = (newlength + 1) & 0xff;
|
||||||
*ptr++ = ((newlength + 1) >> 8) & 0xff;
|
*ptr++ = ((newlength + 1) >> 8) & 0xff;
|
||||||
*ptr++ = ((newlength + 1) >> 16) & 0xff;
|
*ptr++ = ((newlength + 1) >> 16) & 0xff;
|
||||||
|
addition->gwbuf_type = orig->gwbuf_type;
|
||||||
orig->next = addition;
|
orig->next = addition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1168,7 +1168,11 @@ routeQuery(FILTER *instance, void *session, GWBUF *queue)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queue->next != NULL)
|
||||||
|
{
|
||||||
|
queue = gwbuf_make_contiguous(queue);
|
||||||
|
}
|
||||||
|
|
||||||
if(modutil_extract_SQL(queue, &ptr, &length)){
|
if(modutil_extract_SQL(queue, &ptr, &length)){
|
||||||
|
|
||||||
my_session->was_query = true;
|
my_session->was_query = true;
|
||||||
|
@ -358,24 +358,30 @@ int length;
|
|||||||
struct tm t;
|
struct tm t;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
if (my_session->active && modutil_extract_SQL(queue, &ptr, &length))
|
if (my_session->active)
|
||||||
{
|
{
|
||||||
if ((my_instance->match == NULL ||
|
if (queue->next != NULL)
|
||||||
regexec(&my_instance->re, ptr, 0, NULL, 0) == 0) &&
|
|
||||||
(my_instance->nomatch == NULL ||
|
|
||||||
regexec(&my_instance->nore,ptr,0,NULL, 0) != 0))
|
|
||||||
{
|
{
|
||||||
gettimeofday(&tv, NULL);
|
queue = gwbuf_make_contiguous(queue);
|
||||||
localtime_r(&tv.tv_sec, &t);
|
}
|
||||||
fprintf(my_session->fp,
|
if (modutil_extract_SQL(queue, &ptr, &length) != 0)
|
||||||
"%02d:%02d:%02d.%-3d %d/%02d/%d, ",
|
{
|
||||||
t.tm_hour, t.tm_min, t.tm_sec, (int)(tv.tv_usec / 1000),
|
if ((my_instance->match == NULL ||
|
||||||
t.tm_mday, t.tm_mon + 1, 1900 + t.tm_year);
|
regexec(&my_instance->re, ptr, 0, NULL, 0) == 0) &&
|
||||||
fwrite(ptr, sizeof(char), length, my_session->fp);
|
(my_instance->nomatch == NULL ||
|
||||||
fwrite("\n", sizeof(char), 1, my_session->fp);
|
regexec(&my_instance->nore,ptr,0,NULL, 0) != 0))
|
||||||
|
{
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
localtime_r(&tv.tv_sec, &t);
|
||||||
|
fprintf(my_session->fp,
|
||||||
|
"%02d:%02d:%02d.%-3d %d/%02d/%d, ",
|
||||||
|
t.tm_hour, t.tm_min, t.tm_sec, (int)(tv.tv_usec / 1000),
|
||||||
|
t.tm_mday, t.tm_mon + 1, 1900 + t.tm_year);
|
||||||
|
fwrite(ptr, sizeof(char), length, my_session->fp);
|
||||||
|
fwrite("\n", sizeof(char), 1, my_session->fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass the query downstream */
|
/* Pass the query downstream */
|
||||||
return my_session->down.routeQuery(my_session->down.instance,
|
return my_session->down.routeQuery(my_session->down.instance,
|
||||||
my_session->down.session, queue);
|
my_session->down.session, queue);
|
||||||
|
@ -305,6 +305,10 @@ int length;
|
|||||||
|
|
||||||
if (modutil_is_SQL(queue))
|
if (modutil_is_SQL(queue))
|
||||||
{
|
{
|
||||||
|
if (queue->next != NULL)
|
||||||
|
{
|
||||||
|
queue = gwbuf_make_contiguous(queue);
|
||||||
|
}
|
||||||
modutil_extract_SQL(queue, &sql, &length);
|
modutil_extract_SQL(queue, &sql, &length);
|
||||||
newsql = regex_replace(sql, length, &my_instance->re,
|
newsql = regex_replace(sql, length, &my_instance->re,
|
||||||
my_instance->replace);
|
my_instance->replace);
|
||||||
|
@ -455,21 +455,27 @@ TOPN_SESSION *my_session = (TOPN_SESSION *)session;
|
|||||||
char *ptr;
|
char *ptr;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (my_session->active && modutil_extract_SQL(queue, &ptr, &length))
|
if (my_session->active)
|
||||||
{
|
{
|
||||||
if ((my_instance->match == NULL ||
|
if (queue->next != NULL)
|
||||||
regexec(&my_instance->re, ptr, 0, NULL, 0) == 0) &&
|
|
||||||
(my_instance->exclude == NULL ||
|
|
||||||
regexec(&my_instance->exre,ptr,0,NULL, 0) != 0))
|
|
||||||
{
|
{
|
||||||
my_session->n_statements++;
|
queue = gwbuf_make_contiguous(queue);
|
||||||
if (my_session->current)
|
}
|
||||||
free(my_session->current);
|
if (modutil_extract_SQL(queue, &ptr, &length) != 0)
|
||||||
gettimeofday(&my_session->start, NULL);
|
{
|
||||||
my_session->current = strndup(ptr, length);
|
if ((my_instance->match == NULL ||
|
||||||
|
regexec(&my_instance->re, ptr, 0, NULL, 0) == 0) &&
|
||||||
|
(my_instance->exclude == NULL ||
|
||||||
|
regexec(&my_instance->exre,ptr,0,NULL, 0) != 0))
|
||||||
|
{
|
||||||
|
my_session->n_statements++;
|
||||||
|
if (my_session->current)
|
||||||
|
free(my_session->current);
|
||||||
|
gettimeofday(&my_session->start, NULL);
|
||||||
|
my_session->current = strndup(ptr, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass the query downstream */
|
/* Pass the query downstream */
|
||||||
return my_session->down.routeQuery(my_session->down.instance,
|
return my_session->down.routeQuery(my_session->down.instance,
|
||||||
my_session->down.session, queue);
|
my_session->down.session, queue);
|
||||||
|
@ -1155,15 +1155,13 @@ static bool get_dcb(
|
|||||||
rses->router->available_slaves = false;
|
rses->router->available_slaves = false;
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Warning : No slaves available "
|
"Warning : No slaves available "
|
||||||
"for the service %s.",
|
"for the service %s.",
|
||||||
rses->router->service->name)));
|
rses->router->service->name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
btype = BE_MASTER;
|
btype = BE_MASTER;
|
||||||
|
|
||||||
|
|
||||||
if (BREF_IS_IN_USE(master_bref))
|
if (BREF_IS_IN_USE(master_bref))
|
||||||
{
|
{
|
||||||
*p_dcb = master_bref->bref_dcb;
|
*p_dcb = master_bref->bref_dcb;
|
||||||
@ -1199,7 +1197,7 @@ static bool get_dcb(
|
|||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"At least one slave has become available for "
|
"At least one slave has become available for "
|
||||||
"the service %s.",
|
"the service %s.",
|
||||||
rses->router->service->name)));
|
rses->router->service->name)));
|
||||||
}
|
}
|
||||||
ss_dassert(succp);
|
ss_dassert(succp);
|
||||||
}
|
}
|
||||||
@ -1920,8 +1918,8 @@ static int routeQuery(
|
|||||||
}
|
}
|
||||||
else if (hint->type == HINT_PARAMETER &&
|
else if (hint->type == HINT_PARAMETER &&
|
||||||
(strncasecmp((char *)hint->data,
|
(strncasecmp((char *)hint->data,
|
||||||
"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->value,
|
int val = (int) strtol((char *)hint->value,
|
||||||
(char **)NULL, 10);
|
(char **)NULL, 10);
|
||||||
@ -2047,8 +2045,7 @@ static int routeQuery(
|
|||||||
}
|
}
|
||||||
succp = false;
|
succp = false;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (succp) /*< Have DCB of the target backend */
|
if (succp) /*< Have DCB of the target backend */
|
||||||
|
Reference in New Issue
Block a user