diff options
author | Tor Didriksen <tor.didriksen@oracle.com> | 2012-09-18 17:32:02 +0200 |
---|---|---|
committer | Tor Didriksen <tor.didriksen@oracle.com> | 2012-09-18 17:32:02 +0200 |
commit | b04427802069576e3ab7180c5565d50d9698d98a (patch) | |
tree | 2a6b26202a60f99e2c4316ffd53539df5cae2b3a /sql | |
parent | 9f11f46526956ebcb5c0883852233279a987b90a (diff) | |
download | mariadb-git-b04427802069576e3ab7180c5565d50d9698d98a.tar.gz |
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.
Diffstat (limited to 'sql')
-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 |
4 files changed, 21 insertions, 8 deletions
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)); |