Commit 4b6f5f53 authored by Georgi Kodinov's avatar Georgi Kodinov

Bug #45962: memory leak after 'sort aborted' errors

When the function exits with an error it was not
freeing the local Unique class instance.
Fixed my making sure all the places where the function
returns from are freeing the Unique instance 
parent 6e6bdb55
...@@ -8065,21 +8065,28 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() ...@@ -8065,21 +8065,28 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
if (cur_quick->file->inited != handler::NONE) if (cur_quick->file->inited != handler::NONE)
cur_quick->file->ha_index_end(); cur_quick->file->ha_index_end();
if (cur_quick->init() || cur_quick->reset()) if (cur_quick->init() || cur_quick->reset())
{
delete unique;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
}
if (result) if (result)
{ {
if (result != HA_ERR_END_OF_FILE) if (result != HA_ERR_END_OF_FILE)
{ {
cur_quick->range_end(); cur_quick->range_end();
delete unique;
DBUG_RETURN(result); DBUG_RETURN(result);
} }
break; break;
} }
if (thd->killed) if (thd->killed)
{
delete unique;
DBUG_RETURN(1); DBUG_RETURN(1);
}
/* skip row if it will be retrieved by clustered PK scan */ /* skip row if it will be retrieved by clustered PK scan */
if (pk_quick_select && pk_quick_select->row_in_ranges()) if (pk_quick_select && pk_quick_select->row_in_ranges())
...@@ -8088,8 +8095,10 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge() ...@@ -8088,8 +8095,10 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
cur_quick->file->position(cur_quick->record); cur_quick->file->position(cur_quick->record);
result= unique->unique_add((char*)cur_quick->file->ref); result= unique->unique_add((char*)cur_quick->file->ref);
if (result) if (result)
{
delete unique;
DBUG_RETURN(1); DBUG_RETURN(1);
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment