From 62513bb1bca33902fa909ca13b25c550046ee3ae Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Tue, 15 Jul 2008 18:13:21 +0400 Subject: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique, tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted and b) it might be that the the data is used by filesort(), which will need record rowids (which rr_from_cache() cannot provide). - Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next(). This fixes BUG#35477. (bk trigger: file as fix for BUG#35478). sql/filesort.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - make find_all_keys() use quick->get_next() instead of init_read_record(r)/r.read_record() calls - added dbug printout sql/mysql_priv.h: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/opt_range.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - In QUICK_INDEX_MERGE_SELECT::read_keys_and_merge: when we got table->sort from Unique, tell init_read_record() not to use rr_from_cache() because a) rowids are already sorted and b) it might be that the the data is used by filesort(), which will need record rowids (which rr_from_cache() cannot provide). - Fully de-initialize the table->sort read in QUICK_INDEX_MERGE_SELECT::get_next(). sql/records.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added disable_rr_cache parameter to init_read_record - Added comment sql/sql_acl.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/sql_delete.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/sql_help.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/sql_select.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/sql_table.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/sql_udf.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record sql/sql_update.cc: BUG#35478: sort_union() returns bad data when sort_buffer_size is hit - Added parameter to init_read_record --- sql/records.cc | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'sql/records.cc') diff --git a/sql/records.cc b/sql/records.cc index f61efc13034..d5c3a421cd9 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -72,11 +72,47 @@ void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, } -/* init struct for read with info->read_record */ +/* + init struct for read with info->read_record + + SYNOPSIS + init_read_record() + info OUT read structure + thd Thread handle + table Table the data [originally] comes from. + select SQL_SELECT structure. We may select->quick or + select->file as data source + use_record_cache Call file->extra_opt(HA_EXTRA_CACHE,...) + if we're going to do sequential read and some + additional conditions are satisfied. + print_error Copy this to info->print_error + disable_rr_cache Don't use rr_from_cache (used by sort-union + index-merge which produces rowid sequences that + are already ordered) + + DESCRIPTION + This function sets up reading data via one of the methods: + + rr_unpack_from_tempfile Unpack full records from sequential file + rr_unpack_from_buffer ... or from buffer + + rr_from_tempfile Read rowids from tempfile and get full records + with handler->rnd_pos() calls. + rr_from_pointers ... or get rowids from buffer + + rr_from_cache Read a bunch of rowids from file, sort them, + get records in rowid order, return, repeat. + + rr_quick Get data from QUICK_*_SELECT + + rr_sequential Sequentially scan the table using + handler->rnd_next() calls +*/ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, SQL_SELECT *select, - int use_record_cache, bool print_error) + int use_record_cache, bool print_error, + bool disable_rr_cache) { IO_CACHE *tempfile; DBUG_ENTER("init_read_record"); @@ -121,7 +157,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, it doesn't make sense to use cache - we don't read from the table and table->sort.io_cache is read sequentially */ - if (!table->sort.addon_field && + if (!disable_rr_cache && + !table->sort.addon_field && ! (specialflag & SPECIAL_SAFE_MODE) && thd->variables.read_rnd_buff_size && !(table->file->table_flags() & HA_FAST_KEY_READ) && -- cgit v1.2.1