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

spider_mbase_share::convert_key_hint_str() seems to be wrong

Details

    Description

      Probably affects other versions too. It iterates the access to spider_share->key_hint in the else branch, but not the if branch:

      int spider_mbase_share::convert_key_hint_str()
      {
        spider_string *tmp_key_hint;
        int roop_count;
        TABLE_SHARE *table_share = spider_share->table_share;
        DBUG_ENTER("spider_mbase_share::convert_key_hint_str");
        if (spider_share->access_charset->cset != system_charset_info->cset)
        {
          /* need conversion */
          for (roop_count = 0, tmp_key_hint = key_hint;
            roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++)
          {
            tmp_key_hint->length(0);
            if (tmp_key_hint->append(spider_share->key_hint->ptr(),
              spider_share->key_hint->length(), system_charset_info))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
          }
        } else {
          for (roop_count = 0, tmp_key_hint = key_hint;
            roop_count < (int) table_share->keys; roop_count++, tmp_key_hint++)
          {
            if (tmp_key_hint->copy(spider_share->key_hint[roop_count]))
              DBUG_RETURN(HA_ERR_OUT_OF_MEM);
          }
        }
        DBUG_RETURN(0);
      }
      

      So something like the following would not use the key hint

      --echo #
      --echo # tmp
      --echo #
      --disable_query_log
      --disable_result_log
      --source ../../t/test_init.inc
      --enable_result_log
      --enable_query_log
       
      evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
      OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
       
      create table t2 (c int, d int, key (c), key (d));
      show create table t2;
      create table t1 (c int, d int, key (c), key (d)) ENGINE=Spider
      COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2", idx001 "f d"';
      show create table t1;
      /* 13 */ insert into t1 values (42, 23), (37, 93);
      select max(d) from t1;
       
      drop table t1, t2;
       
      drop server srv;
       
      --disable_query_log
      --disable_result_log
      --source ../../t/test_deinit.inc
      --enable_result_log
      --enable_query_log
      --echo #
      --echo # end of test tmp
      --echo #
      

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

              ycp Yuchen Pei
              ycp Yuchen Pei
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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