[MDEV-18992] Crash when using “insert into on duplicate update” if session charset different from table charset Created: 2019-03-21  Updated: 2019-05-07  Resolved: 2019-04-30

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Spider
Affects Version/s: None
Fix Version/s: 10.4.5

Type: Bug Priority: Major
Reporter: willhan Assignee: Kentoku Shiba (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-18991 Constrain column charset same as tabl... Closed
relates to MDEV-19003 ignore send <cache> to remote Closed

 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='中国';



 Comments   
Comment by Kentoku Shiba (Inactive) [ 2019-04-26 ]

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

Comment by willhan [ 2019-04-29 ]

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".

Comment by Kentoku Shiba (Inactive) [ 2019-04-29 ]

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

Comment by willhan [ 2019-04-30 ]

It's ok

Comment by Kentoku Shiba (Inactive) [ 2019-04-30 ]

Merged and pushed

Comment by willhan [ 2019-05-07 ]

good

Generated at Thu Feb 08 08:48:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.