1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
Sergey Petrunya
2013-09-26 14:42:30 +04:00
parent 7d60030c02
commit 0b69c44e94
6 changed files with 65 additions and 50 deletions

View File

@ -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);
}
}