summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2013-09-26 14:42:30 +0400
committerSergey Petrunya <psergey@askmonty.org>2013-09-26 14:42:30 +0400
commit0b69c44e945658e82b4c5d532694795136018f12 (patch)
tree37e11ffbdff3a6aa55340cb7b789d529cea61387 /sql/opt_range.cc
parent7d60030c0200b982c13a4c6a9023cf7190b2510a (diff)
downloadmariadb-git-0b69c44e945658e82b4c5d532694795136018f12.tar.gz
MDEV-5067: Valgrind warnings (Invalid read) in QPF_table_access::print_explain
- Query plan footprint (in new terms, "EXPLAIN structure") should always keep a copy of key_name. This is because the table might be a temporary table which may be already freed by the time we use query plan footprint.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc32
1 files changed, 15 insertions, 17 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index c216a035794..97cbe73dcb4 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -11940,23 +11940,21 @@ void QUICK_SELECT_I::add_key_name(String *str, bool *first)
}
-void QUICK_RANGE_SELECT::save_info(QPF_quick_select *qpf)
+void QUICK_RANGE_SELECT::save_info(MEM_ROOT *alloc, QPF_quick_select *qpf)
{
qpf->quick_type= QS_TYPE_RANGE;
- qpf->range.key_name= head->key_info[index].name;
- qpf->range.key_len= max_used_key_length;
+ qpf->range.set(alloc, head->key_info[index].name, max_used_key_length);
}
-void QUICK_GROUP_MIN_MAX_SELECT::save_info(QPF_quick_select *qpf)
+void QUICK_GROUP_MIN_MAX_SELECT::save_info(MEM_ROOT *alloc, QPF_quick_select *qpf)
{
qpf->quick_type= QS_TYPE_GROUP_MIN_MAX;
- qpf->range.key_name= head->key_info[index].name;
- qpf->range.key_len= max_used_key_length;
+ qpf->range.set(alloc, head->key_info[index].name, max_used_key_length);
}
-void QUICK_INDEX_SORT_SELECT::save_info(QPF_quick_select *qpf)
+void QUICK_INDEX_SORT_SELECT::save_info(MEM_ROOT *alloc, QPF_quick_select *qpf)
{
qpf->quick_type= get_type();
@@ -11967,14 +11965,14 @@ void QUICK_INDEX_SORT_SELECT::save_info(QPF_quick_select *qpf)
{
child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- quick->save_info(child_qpf);
+ quick->save_info(alloc, child_qpf);
}
if (pk_quick_select)
{
child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- pk_quick_select->save_info(child_qpf);
+ pk_quick_select->save_info(alloc, child_qpf);
}
}
@@ -11982,7 +11980,7 @@ void QUICK_INDEX_SORT_SELECT::save_info(QPF_quick_select *qpf)
Same as QUICK_INDEX_SORT_SELECT::save_info(), but primary key is printed
first
*/
-void QUICK_INDEX_INTERSECT_SELECT::save_info(QPF_quick_select *qpf)
+void QUICK_INDEX_INTERSECT_SELECT::save_info(MEM_ROOT *alloc, QPF_quick_select *qpf)
{
qpf->quick_type= get_type();
QPF_quick_select *child_qpf;
@@ -11991,7 +11989,7 @@ void QUICK_INDEX_INTERSECT_SELECT::save_info(QPF_quick_select *qpf)
{
child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- pk_quick_select->save_info(child_qpf);
+ pk_quick_select->save_info(alloc, child_qpf);
}
QUICK_RANGE_SELECT *quick;
@@ -12000,13 +11998,13 @@ void QUICK_INDEX_INTERSECT_SELECT::save_info(QPF_quick_select *qpf)
{
child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- quick->save_info(child_qpf);
+ quick->save_info(alloc, child_qpf);
}
}
-void QUICK_ROR_INTERSECT_SELECT::save_info(QPF_quick_select *qpf)
+void QUICK_ROR_INTERSECT_SELECT::save_info(MEM_ROOT *alloc, QPF_quick_select *qpf)
{
qpf->quick_type= get_type();
@@ -12016,19 +12014,19 @@ void QUICK_ROR_INTERSECT_SELECT::save_info(QPF_quick_select *qpf)
{
QPF_quick_select *child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- qr->quick->save_info(child_qpf);
+ qr->quick->save_info(alloc, child_qpf);
}
if (cpk_quick)
{
QPF_quick_select *child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- cpk_quick->save_info(child_qpf);
+ cpk_quick->save_info(alloc, child_qpf);
}
}
-void QUICK_ROR_UNION_SELECT::save_info(QPF_quick_select *qpf)
+void QUICK_ROR_UNION_SELECT::save_info(MEM_ROOT *alloc, QPF_quick_select *qpf)
{
qpf->quick_type= get_type();
@@ -12038,7 +12036,7 @@ void QUICK_ROR_UNION_SELECT::save_info(QPF_quick_select *qpf)
{
QPF_quick_select *child_qpf= new QPF_quick_select;
qpf->children.push_back(child_qpf);
- quick->save_info(child_qpf);
+ quick->save_info(alloc, child_qpf);
}
}