Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-8222

"string_field LIKE int_const" returns a wrong result in case of UCS2

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL)
    • 10.1.5
    • Character Sets
    • None

    Description

      This script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARCHAR(10) CHARSET utf8);
      INSERT INTO t1 VALUES ('1');
      SELECT * FROM t1 WHERE a LIKE 1;

      correctly returns one row:

      +------+
      | a    |
      +------+
      | 1    |
      +------+

      If I change character set from utf8 to ucs2, it returns empty set:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARCHAR(10) CHARSET ucs2);
      INSERT INTO t1 VALUES ('1');
      SELECT * FROM t1 WHERE a LIKE 1;

      The problem happens in this piece of the code:

      bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp)
      {
        DBUG_ASSERT(arg_count == 2);
       
        if (args[0]->cmp_type() == STRING_RESULT &&
            args[1]->cmp_type() == STRING_RESULT &&
            agg_arg_charsets_for_comparison(cmp->cmp_collation, args, 2))
            return true;

      In case of LIKE it should unconditionally call arg_arg_charsets_for_comparison(), no matter that cmp_type() of the arguments are.

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.