query_classifier.cc:skygw_get_canonical: Fixed bug in how strings were passed to replace_literal function. Changed to use item->str_ptr which stores all strings in the same way unlike item->name in which some string values have double quotation.
skygw_utils.cc:Fixed regexp so that it detects literals at the end of line too.
This commit is contained in:
@ -892,6 +892,7 @@ char* skygw_get_canonical(
|
|||||||
}
|
}
|
||||||
pi = (parsing_info_t *)gwbuf_get_buffer_object_data(querybuf,
|
pi = (parsing_info_t *)gwbuf_get_buffer_object_data(querybuf,
|
||||||
GWBUF_PARSING_INFO);
|
GWBUF_PARSING_INFO);
|
||||||
|
CHK_PARSING_INFO(pi);
|
||||||
|
|
||||||
if (pi == NULL)
|
if (pi == NULL)
|
||||||
{
|
{
|
||||||
@ -911,7 +912,6 @@ char* skygw_get_canonical(
|
|||||||
querystr = NULL;
|
querystr = NULL;
|
||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
querystr = strdup(pi->pi_query_plain_str);
|
querystr = strdup(pi->pi_query_plain_str);
|
||||||
|
|
||||||
for (item=thd->free_list; item != NULL; item=item->next)
|
for (item=thd->free_list; item != NULL; item=item->next)
|
||||||
@ -928,11 +928,21 @@ char* skygw_get_canonical(
|
|||||||
itype == Item::VARBIN_ITEM ||
|
itype == Item::VARBIN_ITEM ||
|
||||||
itype == Item::NULL_ITEM))
|
itype == Item::NULL_ITEM))
|
||||||
{
|
{
|
||||||
if (itype == Item::STRING_ITEM && strlen(item->name) == 0)
|
if (itype == Item::STRING_ITEM)
|
||||||
|
{
|
||||||
|
String tokenstr;
|
||||||
|
String* res = item->val_str_ascii(&tokenstr);
|
||||||
|
|
||||||
|
if (res->is_empty()) /*< empty string */
|
||||||
{
|
{
|
||||||
querystr = replace_literal(querystr, "\"\"", "\"?\"");
|
querystr = replace_literal(querystr, "\"\"", "\"?\"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
querystr = replace_literal(querystr, res->ptr(), "?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
querystr = replace_literal(querystr, item->name, "?");
|
querystr = replace_literal(querystr, item->name, "?");
|
||||||
}
|
}
|
||||||
|
@ -1883,7 +1883,7 @@ char* replace_literal(
|
|||||||
const char* replacement)
|
const char* replacement)
|
||||||
{
|
{
|
||||||
const char* prefix = "[ ='\",\\(]"; /*< ' ','=','(',''',''"',',' are allowed before needle */
|
const char* prefix = "[ ='\",\\(]"; /*< ' ','=','(',''',''"',',' are allowed before needle */
|
||||||
const char* suffix = "[^[:alnum:]]"; /*< alpha-num chars aren't allowed after the needle */
|
const char* suffix = "([^[:alnum:]]|$)"; /*< alpha-num chars aren't allowed after the needle */
|
||||||
char* search_re;
|
char* search_re;
|
||||||
char* newstr;
|
char* newstr;
|
||||||
regex_t re;
|
regex_t re;
|
||||||
|
Reference in New Issue
Block a user