4386
4386
if (canDoTurboBM)
4387
4387
return turboBM_matches(res->ptr(), res->length()) ? 1 : 0;
4388
4388
return my_wildcmp(cmp.cmp_collation.collation,
4389
res->ptr(),res->ptr()+res->length(),
4389
res->ptr(),res->ptr()+res->length(),
4390
4390
res2->ptr(),res2->ptr()+res2->length(),
4391
escape,wild_one,wild_many) ? 0 : 1;
4391
make_escape_code(cmp.cmp_collation.collation, escape),
4392
wild_one,wild_many) ? 0 : 1;
4431
4432
if (escape_item->const_item())
4433
4435
/* If we are on execution stage */
4434
4436
String *escape_str= escape_item->val_str(&tmp_value1);
4435
4437
if (escape_str)
4437
if (escape_used_in_parsing && escape_str->numchars() > 1)
4439
my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE");
4443
if (use_mb(cmp.cmp_collation.collation))
4445
const CHARSET_INFO * const cs= escape_str->charset();
4447
int rc= cs->cset->mb_wc(cs, &wc,
4448
(const unsigned char*) escape_str->ptr(),
4449
(const unsigned char*) escape_str->ptr() +
4450
escape_str->length());
4451
escape= (int) (rc > 0 ? wc : '\\');
4456
In the case of 8bit character set, we pass native
4457
code instead of Unicode code as "escape" argument.
4458
Convert to "cs" if charset of escape differs.
4460
const CHARSET_INFO * const cs= cmp.cmp_collation.collation;
4462
if (escape_str->needs_conversion(escape_str->length(),
4463
escape_str->charset(), cs, &unused))
4467
uint32_t cnvlen= copy_and_convert(&ch, 1, cs, escape_str->ptr(),
4468
escape_str->length(),
4469
escape_str->charset(), &errors);
4470
escape= cnvlen ? ch : '\\';
4473
escape= *(escape_str->ptr());
4439
escape= (char *)sql_alloc(escape_str->length());
4440
strcpy(escape, escape_str->ptr());
4444
escape= (char *)sql_alloc(1);
4445
strcpy(escape, "\\");
4480
4449
We could also do boyer-more for non-const items, but as we would have to
4481
4450
recompute the tables for each row it's not worth it.
4499
4468
*last == wild_many)
4501
4470
const char* tmp = first + 1;
4502
for (; *tmp != wild_many && *tmp != wild_one && *tmp != escape; tmp++) ;
4471
for (; *tmp != wild_many && *tmp != wild_one; tmp++)
4503
4477
canDoTurboBM = (tmp == last) && !use_mb(args[0]->collation.collation);
4505
4479
if (canDoTurboBM)