diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2016-07-29 18:21:08 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2016-07-30 20:13:03 +0200 |
commit | 5fdb3cfcd432b85dc305a1a61c2d018a798a6ac3 (patch) | |
tree | f13bb287d1db1aed667ed48a226f74c97462e3d5 /sql | |
parent | c6aaa2adbefa04463bb9b67264c09a04b9c4bfcd (diff) | |
download | mariadb-git-5fdb3cfcd432b85dc305a1a61c2d018a798a6ac3.tar.gz |
MDEV-10419: crash in mariadb 10.1.16-MariaDB-1~trusty
Fixed initialization and usage of THD reference in subselect engines.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_subselect.cc | 8 | ||||
-rw-r--r-- | sql/item_subselect.h | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 690318c610a..3727711a395 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -3308,7 +3308,7 @@ int subselect_uniquesubquery_engine::scan_table() } table->file->extra_opt(HA_EXTRA_CACHE, - current_thd->variables.read_buff_size); + get_thd()->variables.read_buff_size); table->null_row= 0; for (;;) { @@ -3746,7 +3746,7 @@ table_map subselect_union_engine::upper_select_const_tables() void subselect_single_select_engine::print(String *str, enum_query_type query_type) { - select_lex->print(thd, str, query_type); + select_lex->print(get_thd(), str, query_type); } @@ -4276,6 +4276,7 @@ bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root) bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id) { + THD *thd= get_thd(); select_union *result_sink; /* Options to create_tmp_table. */ ulonglong tmp_create_options= thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS; @@ -5500,6 +5501,7 @@ bool subselect_rowid_merge_engine::init(MY_BITMAP *non_null_key_parts, MY_BITMAP *partial_match_key_parts) { + THD *thd= get_thd(); /* The length in bytes of the rowids (positions) of tmp_table. */ uint rowid_length= tmp_table->file->ref_length; ha_rows row_count= tmp_table->file->stats.records; @@ -6038,7 +6040,7 @@ bool subselect_table_scan_engine::partial_match() } tmp_table->file->extra_opt(HA_EXTRA_CACHE, - current_thd->variables.read_buff_size); + get_thd()->variables.read_buff_size); for (;;) { error= tmp_table->file->ha_rnd_next(tmp_table->record[0]); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 0abfe0d5abc..a44503b4471 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -716,7 +716,8 @@ public: ROWID_MERGE_ENGINE, TABLE_SCAN_ENGINE}; subselect_engine(Item_subselect *si, - select_result_interceptor *res) + select_result_interceptor *res): + thd(NULL) { result= res; item= si; @@ -732,7 +733,7 @@ public: Should be called before prepare(). */ void set_thd(THD *thd_arg); - THD * get_thd() { return thd; } + THD * get_thd() { return thd ? thd : current_thd; } virtual int prepare(THD *)= 0; virtual void fix_length_and_dec(Item_cache** row)= 0; /* |