~posulliv/drizzle/memcached_applier

« back to all changes in this revision

Viewing changes to drizzled/item/cmpfunc.cc

Merged trunk and resolved conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
4392
4393
}
4393
4394
 
4394
4395
 
4430
4431
 
4431
4432
  if (escape_item->const_item())
4432
4433
  {
 
4434
    
4433
4435
    /* If we are on execution stage */
4434
4436
    String *escape_str= escape_item->val_str(&tmp_value1);
4435
4437
    if (escape_str)
4436
4438
    {
4437
 
      if (escape_used_in_parsing && escape_str->numchars() > 1)
4438
 
      {
4439
 
        my_error(ER_WRONG_ARGUMENTS,MYF(0),"ESCAPE");
4440
 
        return true;
4441
 
      }
4442
 
 
4443
 
      if (use_mb(cmp.cmp_collation.collation))
4444
 
      {
4445
 
        const CHARSET_INFO * const cs= escape_str->charset();
4446
 
        my_wc_t wc;
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 : '\\');
4452
 
      }
4453
 
      else
4454
 
      {
4455
 
        /*
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.
4459
 
        */
4460
 
        const CHARSET_INFO * const cs= cmp.cmp_collation.collation;
4461
 
        uint32_t unused;
4462
 
        if (escape_str->needs_conversion(escape_str->length(),
4463
 
                                         escape_str->charset(), cs, &unused))
4464
 
        {
4465
 
          char ch;
4466
 
          uint32_t errors;
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 : '\\';
4471
 
        }
4472
 
        else
4473
 
          escape= *(escape_str->ptr());
4474
 
      }
 
4439
      escape= (char *)sql_alloc(escape_str->length());
 
4440
      strcpy(escape, escape_str->ptr()); 
4475
4441
    }
4476
4442
    else
4477
 
      escape= '\\';
4478
 
 
 
4443
    {
 
4444
      escape= (char *)sql_alloc(1);
 
4445
      strcpy(escape, "\\");
 
4446
    } 
 
4447
   
4479
4448
    /*
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)
4500
4469
      {
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++)
 
4472
        {
 
4473
          if (escape == tmp)
 
4474
            break;
 
4475
        }
 
4476
  
4503
4477
        canDoTurboBM = (tmp == last) && !use_mb(args[0]->collation.collation);
4504
4478
      }
4505
4479
      if (canDoTurboBM)