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

Crash when using “insert into on duplicate update” if session charset different from table charset

Details

    Description

      Crash when using “insert into on duplicate update” if session charset different from table charset
      set names latin1;
      insert into table_utf8 values('abd') on duplicate key update acct_name='中国';

      Attachments

        Issue Links

          Activity

            willhan
            I fixed this issue. Please check the following commit.
            3eee025

            Kentoku Kentoku Shiba (Inactive) added a comment - willhan I fixed this issue. Please check the following commit. 3eee025
            willhan willhan added a comment -

            int spider_mysql_handler::init()
            {
            uint roop_count;
            THD *thd = spider->trx->thd;
            st_spider_share *share = spider->share;
            int init_sql_alloc_size =
            spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
            TABLE *table = spider->get_table();
            DBUG_ENTER("spider_mysql_handler::init");
            DBUG_PRINT("info",("spider this=%p", this));
            sql.init_calc_mem(59);
            sql_part.init_calc_mem(60);
            sql_part2.init_calc_mem(61);
            ha_sql.init_calc_mem(62);
            insert_sql.init_calc_mem(64);
            update_sql.init_calc_mem(65);
            tmp_sql.init_calc_mem(66);
            dup_update_sql.init_calc_mem(166);
            if (
            (sql.real_alloc(init_sql_alloc_size)) ||
            (insert_sql.real_alloc(init_sql_alloc_size)) ||
            (update_sql.real_alloc(init_sql_alloc_size)) ||
            (tmp_sql.real_alloc(init_sql_alloc_size))
            )

            { DBUG_RETURN(HA_ERR_OUT_OF_MEM); }

            sql.set_charset(share->access_charset);
            sql_part.set_charset(share->access_charset);
            ha_sql.set_charset(share->access_charset);
            insert_sql.set_charset(share->access_charset);
            update_sql.set_charset(share->access_charset);
            tmp_sql.set_charset(share->access_charset);
            dup_update_sql.set_charset(share->access_charset);
            sql_part2.set_charset(share->access_charset);

            In our environment, we add this charset init for "dup_update_sql".

            willhan willhan added a comment - int spider_mysql_handler::init() { uint roop_count; THD *thd = spider->trx->thd; st_spider_share *share = spider->share; int init_sql_alloc_size = spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size); TABLE *table = spider->get_table(); DBUG_ENTER("spider_mysql_handler::init"); DBUG_PRINT("info",("spider this=%p", this)); sql.init_calc_mem(59); sql_part.init_calc_mem(60); sql_part2.init_calc_mem(61); ha_sql.init_calc_mem(62); insert_sql.init_calc_mem(64); update_sql.init_calc_mem(65); tmp_sql.init_calc_mem(66); dup_update_sql.init_calc_mem(166); if ( (sql.real_alloc(init_sql_alloc_size)) || (insert_sql.real_alloc(init_sql_alloc_size)) || (update_sql.real_alloc(init_sql_alloc_size)) || (tmp_sql.real_alloc(init_sql_alloc_size)) ) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } sql.set_charset(share->access_charset); sql_part.set_charset(share->access_charset); ha_sql.set_charset(share->access_charset); insert_sql.set_charset(share->access_charset); update_sql.set_charset(share->access_charset); tmp_sql.set_charset(share->access_charset); dup_update_sql.set_charset(share->access_charset); sql_part2.set_charset(share->access_charset); In our environment, we add this charset init for "dup_update_sql".

            willhan
            Thank you for reviewing! I fixed these forgotten initializing and pushed it. Please check again the following commit.
            1b24078

            Kentoku Kentoku Shiba (Inactive) added a comment - willhan Thank you for reviewing! I fixed these forgotten initializing and pushed it. Please check again the following commit. 1b24078
            willhan willhan added a comment -

            It's ok

            willhan willhan added a comment - It's ok

            Merged and pushed

            Kentoku Kentoku Shiba (Inactive) added a comment - Merged and pushed
            willhan willhan added a comment -

            good

            willhan willhan added a comment - good

            People

              Kentoku Kentoku Shiba (Inactive)
              willhan willhan
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.