diff options
-rw-r--r-- | dbug/dbug.c | 2 | ||||
-rw-r--r-- | sql/filesort.cc | 3 | ||||
-rw-r--r-- | sql/opt_range.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.cc | 12 | ||||
-rw-r--r-- | sql/uniques.cc | 7 |
5 files changed, 22 insertions, 9 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index 2dadf7bb2d5..d55195255d4 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -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); } } diff --git a/sql/filesort.cc b/sql/filesort.cc index dba09c969e3..a11be501991 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -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. */ diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 8d221af392b..ce48a8da958 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -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()); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fd6d0e44597..3bde5aa8f6a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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) { diff --git a/sql/uniques.cc b/sql/uniques.cc index e7ce2197147..71e680682cd 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -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)); |