summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-11-04 13:16:46 +0200
committerunknown <bell@sanja.is.com.ua>2005-11-04 13:16:46 +0200
commit234bf9a70cc22f788ae655de1bb140e984918409 (patch)
tree941bd8ee7fed13c66d2a2579fd836c0369f4f5c9 /sql
parent71898b3e2406897197df654f0ebf1b89e70b65b5 (diff)
downloadmariadb-git-234bf9a70cc22f788ae655de1bb140e984918409.tar.gz
avoiding of calling Item::val_* methods family with opt_range mem_root, because its life time is too short. (BUG#14342)
mysql-test/r/subselect_innodb.result: BUG#14342 test case mysql-test/t/subselect_innodb.test: BUG#14342 test case sql/opt_range.cc: avoiding of calling Item::val_* methods family with opt_range mem_root, because its life time is too short.
Diffstat (limited to 'sql')
-rw-r--r--sql/opt_range.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 63a49a46110..de52811c12f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -5759,10 +5759,17 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
MEM_ROOT *old_root= thd->mem_root;
/* The following call may change thd->mem_root */
QUICK_RANGE_SELECT *quick= new QUICK_RANGE_SELECT(thd, table, ref->key, 0);
+ /* save mem_root set by QUICK_RANGE_SELECT constructor */
+ MEM_ROOT *alloc= thd->mem_root;
KEY *key_info = &table->key_info[ref->key];
KEY_PART *key_part;
QUICK_RANGE *range;
uint part;
+ /*
+ return back default mem_root (thd->mem_root) changed by
+ QUICK_RANGE_SELECT constructor
+ */
+ thd->mem_root= old_root;
if (!quick)
return 0; /* no ranges found */
@@ -5774,7 +5781,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
quick->records= records;
if (cp_buffer_from_ref(thd,ref) && thd->is_fatal_error ||
- !(range= new QUICK_RANGE()))
+ !(range= new(alloc) QUICK_RANGE()))
goto err; // out of memory
range->min_key=range->max_key=(char*) ref->key_buff;
@@ -5809,20 +5816,20 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
QUICK_RANGE *null_range;
*ref->null_ref_key= 1; // Set null byte then create a range
- if (!(null_range= new QUICK_RANGE((char*)ref->key_buff, ref->key_length,
- (char*)ref->key_buff, ref->key_length,
- EQ_RANGE)))
+ if (!(null_range= new (alloc) QUICK_RANGE((char*)ref->key_buff,
+ ref->key_length,
+ (char*)ref->key_buff,
+ ref->key_length,
+ EQ_RANGE)))
goto err;
*ref->null_ref_key= 0; // Clear null byte
if (insert_dynamic(&quick->ranges,(gptr)&null_range))
goto err;
}
- thd->mem_root= old_root;
return quick;
err:
- thd->mem_root= old_root;
delete quick;
return 0;
}