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:
VilhoRaatikka
2014-09-01 13:23:04 +03:00
parent 40f85f9cad
commit 20abbbdf57
2 changed files with 19 additions and 9 deletions

View File

@ -892,7 +892,8 @@ char* skygw_get_canonical(
}
pi = (parsing_info_t *)gwbuf_get_buffer_object_data(querybuf,
GWBUF_PARSING_INFO);
CHK_PARSING_INFO(pi);
if (pi == NULL)
{
querystr = NULL;
@ -911,10 +912,9 @@ char* skygw_get_canonical(
querystr = NULL;
goto retblock;
}
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)
{
Item::Type itype;
@ -928,10 +928,20 @@ char* skygw_get_canonical(
itype == Item::VARBIN_ITEM ||
itype == Item::NULL_ITEM))
{
if (itype == Item::STRING_ITEM && strlen(item->name) == 0)
{
querystr = replace_literal(querystr, "\"\"", "\"?\"");
}
if (itype == Item::STRING_ITEM)
{
String tokenstr;
String* res = item->val_str_ascii(&tokenstr);
if (res->is_empty()) /*< empty string */
{
querystr = replace_literal(querystr, "\"\"", "\"?\"");
}
else
{
querystr = replace_literal(querystr, res->ptr(), "?");
}
}
else
{
querystr = replace_literal(querystr, item->name, "?");