Bug#14542543 FIX BUG #12694872 IN 5.5
Bug#14530242 CRASH / MEMORY CORRUPTION IN FILESORT_BUFFER::GET_RECORD_BUFFER WITH MYISAM This is a backport of Bug#12694872 - VALGRIND: 18,816 BYTES IN 196 BLOCKS ARE DEFINITELY LOST Bug#13340270: assertion table->sort.record_pointers == __null Bug#14536113 CRASH IN CLOSEFRM (TABLE.CC) OR UNPACK (FIELD.H) ON SUBQUERY WITH MYISAM TABLES Also: removed and re-added test files with file-ids from trunk.
This commit is contained in:
parent
9f11f46526
commit
b044278020
@ -1179,7 +1179,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
|
||||
pthread_mutex_lock(&THR_LOCK_dbug);
|
||||
DoPrefix(cs, _line_);
|
||||
Indent(cs, cs->level);
|
||||
(void) fprintf(cs->stack->out_file, "<%s\n", cs->func);
|
||||
(void) fprintf(cs->stack->out_file, "<%s %u\n", cs->func, _line_);
|
||||
DbugFlush(cs);
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
*/
|
||||
memcpy(&table_sort, &table->sort, sizeof(FILESORT_INFO));
|
||||
table->sort.io_cache= NULL;
|
||||
DBUG_ASSERT(table_sort.record_pointers == NULL);
|
||||
|
||||
outfile= table_sort.io_cache;
|
||||
my_b_clear(&tempfile);
|
||||
@ -366,6 +367,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
||||
|
||||
void filesort_free_buffers(TABLE *table, bool full)
|
||||
{
|
||||
DBUG_ENTER("filesort_free_buffers");
|
||||
my_free(table->sort.record_pointers);
|
||||
table->sort.record_pointers= NULL;
|
||||
|
||||
@ -383,6 +385,7 @@ void filesort_free_buffers(TABLE *table, bool full)
|
||||
my_free(table->sort.addon_field);
|
||||
table->sort.addon_buf= NULL;
|
||||
table->sort.addon_field= NULL;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/** Make a array of string pointers. */
|
||||
|
@ -74,6 +74,7 @@
|
||||
#include "records.h" // init_read_record, end_read_record
|
||||
#include <m_ctype.h>
|
||||
#include "sql_select.h"
|
||||
#include "filesort.h" // filesort_free_buffers
|
||||
|
||||
#ifndef EXTRA_DEBUG
|
||||
#define test_rb_tree(A,B) {}
|
||||
@ -1246,7 +1247,8 @@ int QUICK_INDEX_MERGE_SELECT::init()
|
||||
int QUICK_INDEX_MERGE_SELECT::reset()
|
||||
{
|
||||
DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::reset");
|
||||
DBUG_RETURN(read_keys_and_merge());
|
||||
const int retval= read_keys_and_merge();
|
||||
DBUG_RETURN(retval);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -8295,7 +8297,10 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
|
||||
thd->variables.sortbuff_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
unique->reset();
|
||||
filesort_free_buffers(head, false);
|
||||
}
|
||||
|
||||
DBUG_ASSERT(file->ref_length == unique->get_size());
|
||||
DBUG_ASSERT(thd->variables.sortbuff_size == unique->get_max_in_memory_size());
|
||||
|
@ -7173,14 +7173,14 @@ void JOIN::cleanup(bool full)
|
||||
{
|
||||
JOIN_TAB *tab,*end;
|
||||
/*
|
||||
Only a sorted table may be cached. This sorted table is always the
|
||||
first non const table in join->all_tables
|
||||
Free resources allocated by filesort() and Unique::get()
|
||||
*/
|
||||
if (tables > const_tables) // Test for not-const tables
|
||||
{
|
||||
free_io_cache(all_tables[const_tables]);
|
||||
filesort_free_buffers(all_tables[const_tables],full);
|
||||
}
|
||||
for (uint ix= const_tables; ix < tables; ++ix)
|
||||
{
|
||||
free_io_cache(all_tables[ix]);
|
||||
filesort_free_buffers(all_tables[ix], full);
|
||||
}
|
||||
|
||||
if (full)
|
||||
{
|
||||
|
@ -57,7 +57,10 @@ int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique)
|
||||
|
||||
Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
|
||||
uint size_arg, ulonglong max_in_memory_size_arg)
|
||||
:max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0)
|
||||
:max_in_memory_size(max_in_memory_size_arg),
|
||||
record_pointers(NULL),
|
||||
size(size_arg),
|
||||
elements(0)
|
||||
{
|
||||
my_b_clear(&file);
|
||||
init_tree(&tree, (ulong) (max_in_memory_size / 16), 0, size, comp_func, 0,
|
||||
@ -583,6 +586,7 @@ bool Unique::get(TABLE *table)
|
||||
if (my_b_tell(&file) == 0)
|
||||
{
|
||||
/* Whole tree is in memory; Don't use disk if you don't need to */
|
||||
DBUG_ASSERT(table->sort.record_pointers == NULL);
|
||||
if ((record_pointers=table->sort.record_pointers= (uchar*)
|
||||
my_malloc(size * tree.elements_in_tree, MYF(0))))
|
||||
{
|
||||
@ -603,6 +607,7 @@ bool Unique::get(TABLE *table)
|
||||
bool error=1;
|
||||
|
||||
/* Open cached file if it isn't open */
|
||||
DBUG_ASSERT(table->sort.io_cache == NULL);
|
||||
outfile=table->sort.io_cache=(IO_CACHE*) my_malloc(sizeof(IO_CACHE),
|
||||
MYF(MY_ZEROFILL));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user