From: Ole John Aske Date: March 23 2011 2:08pm Subject: bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (ole.john.aske:3451 to 3452) List-Archive: http://lists.mysql.com/commits/133650 Message-Id: <20110323140821.B694E218@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3452 Ole John Aske 2011-03-23 [merge] Merge from mainline telco -> SPJ (Mainly of the MCP_BUG-stuff as the 'overly eager sort' fix itself already was present in the SPJ branch ) modified: sql/ha_ndbcluster.cc sql/opt_range.cc sql/opt_range.h sql/sql_select.cc 3451 Ole John Aske 2011-03-23 [merge] SPJ merge from telco mainline > SPJ branch removed: mysql-test/suite/rpl_ndb/have_one_ndb.inc modified: mysql-test/suite/ndb/r/ndb_multi.result mysql-test/suite/ndb/t/ndb_multi.test mysql-test/suite/rpl_ndb/ndb_master-slave.inc sql/ha_ndbcluster_binlog.cc storage/ndb/src/common/portlib/NdbCondition.c === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2011-03-17 13:20:46 +0000 +++ b/sql/ha_ndbcluster.cc 2011-03-23 14:07:43 +0000 @@ -6773,7 +6773,11 @@ int ha_ndbcluster::index_first(uchar *bu // Start the ordered index scan and fetch the first row // Only HA_READ_ORDER indexes get called by index_first +#ifdef MCP_BUG11764737 + const int error= ordered_index_scan(0, 0, TRUE, FALSE, buf, NULL); +#else const int error= ordered_index_scan(0, 0, m_sorted, FALSE, buf, NULL); +#endif table->status=error ? STATUS_NOT_FOUND: 0; DBUG_RETURN(error); } @@ -6783,7 +6787,11 @@ int ha_ndbcluster::index_last(uchar *buf { DBUG_ENTER("ha_ndbcluster::index_last"); ha_statistic_increment(&SSV::ha_read_last_count); +#ifdef MCP_BUG11764737 + const int error= ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL); +#else const int error= ordered_index_scan(0, 0, m_sorted, TRUE, buf, NULL); +#endif table->status=error ? STATUS_NOT_FOUND: 0; DBUG_RETURN(error); } === modified file 'sql/opt_range.cc' --- a/sql/opt_range.cc 2010-11-11 13:07:41 +0000 +++ b/sql/opt_range.cc 2011-03-23 14:07:43 +0000 @@ -1097,8 +1097,12 @@ SQL_SELECT::~SQL_SELECT() #undef index // Fix for Unixware 7 QUICK_SELECT_I::QUICK_SELECT_I() +#ifdef MCP_BUG11764737 + :max_used_key_length(0), +#else :sorted(false), max_used_key_length(0), +#endif used_key_parts(0) {} @@ -1110,6 +1114,9 @@ QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(T DBUG_ENTER("QUICK_RANGE_SELECT::QUICK_RANGE_SELECT"); in_ror_merged_scan= 0; +#ifdef MCP_BUG11764737 + sorted= 0; +#endif index= key_nr; head= table; key_part_info= head->key_info[index].key_part; @@ -4983,7 +4990,11 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_ { if (!(quick= get_quick_select(param, (*first_scan)->idx, (*first_scan)->sel_arg, alloc)) || +#ifdef MCP_BUG11764737 + quick_intrsect->push_quick_back(quick)) +#else (quick->sorted= 1, quick_intrsect->push_quick_back(quick))) +#endif { delete quick_intrsect; DBUG_RETURN(NULL); @@ -4998,7 +5009,9 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_ DBUG_RETURN(NULL); } quick->file= NULL; +#ifndef MCP_BUG11764737 quick->sorted= 1; +#endif quick_intrsect->cpk_quick= quick; } quick_intrsect->records= records; @@ -5025,7 +5038,11 @@ QUICK_SELECT_I *TRP_ROR_UNION::make_quic for (scan= first_ror; scan != last_ror; scan++) { if (!(quick= (*scan)->make_quick(param, FALSE, &quick_roru->alloc)) || +#ifdef MCP_BUG11764737 + quick_roru->push_quick_back(quick)) +#else (quick->sorted= 1, quick_roru->push_quick_back(quick))) +#endif DBUG_RETURN(NULL); } quick_roru->records= records; @@ -8455,7 +8472,11 @@ int QUICK_RANGE_SELECT::reset() in_range= FALSE; cur_range= (QUICK_RANGE**) ranges.buffer; +#ifdef MCP_BUG11764737 + if (file->inited == handler::NONE && (error= file->ha_index_init(index,1))) +#else if (file->inited == handler::NONE && (error= file->ha_index_init(index,sorted))) +#endif DBUG_RETURN(error); /* Do not allocate the buffers twice. */ @@ -8672,7 +8693,11 @@ int QUICK_RANGE_SELECT::get_next_prefix( result= file->read_range_first(last_range->min_keypart_map ? &start_key : 0, last_range->max_keypart_map ? &end_key : 0, test(last_range->flag & EQ_RANGE), +#ifdef MCP_BUG11764737 + TRUE); +#else sorted); +#endif if (last_range->flag == (UNIQUE_RANGE | EQ_RANGE)) last_range= 0; // Stop searching @@ -8785,6 +8810,10 @@ QUICK_SELECT_DESC::QUICK_SELECT_DESC(QUI multi_range= NULL; multi_range_buff= NULL; +#ifndef MCP_BUG11764737 + sorted= 1; // 'sorted' as internals use index_last/_prev +#endif + QUICK_RANGE **pr= (QUICK_RANGE**)ranges.buffer; QUICK_RANGE **end_range= pr + ranges.elements; for (; pr!=end_range; pr++) @@ -8798,18 +8827,19 @@ QUICK_SELECT_DESC::QUICK_SELECT_DESC(QUI r->flag&= ~EQ_RANGE; } rev_it.rewind(); - sorted= 1; q->dont_free=1; // Don't free shared mem delete q; } +#ifndef MCP_BUG11764737 int QUICK_SELECT_DESC::reset(void) { sorted= 1; // 'sorted' index access is required by internals rev_it.rewind(); return QUICK_RANGE_SELECT::reset(); } +#endif int QUICK_SELECT_DESC::get_next() @@ -10223,12 +10253,14 @@ TRP_GROUP_MIN_MAX::make_quick(PARAM *par quick->quick_prefix_select= get_quick_select(param, param_idx, index_tree, &quick->alloc); +#ifndef MCP_BUG11764737 if (!quick->quick_prefix_select) { delete quick; DBUG_RETURN(NULL); } quick->quick_prefix_select->sorted= 1; +#endif } /* Extract the SEL_ARG subtree that contains only ranges for the MIN/MAX @@ -10620,9 +10652,10 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(vo DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset"); head->set_keyread(TRUE); /* We need only the key attributes */ - - // Request ordered index access as usage of ::index_last(), ::index_first() - // within GROUP_MIN_MAX depends on it. + /* + Request ordered index access as usage of ::index_last(), + ::index_first() within QUICK_GROUP_MIN_MAX_SELECT depends on it. + */ if ((result= file->ha_index_init(index,1))) DBUG_RETURN(result); if (quick_prefix_select && quick_prefix_select->reset()) === modified file 'sql/opt_range.h' --- a/sql/opt_range.h 2010-11-11 13:07:41 +0000 +++ b/sql/opt_range.h 2011-03-23 14:07:43 +0000 @@ -762,7 +762,11 @@ public: int get_type() { return QS_TYPE_RANGE_DESC; } private: bool range_reads_after_key(QUICK_RANGE *range); +#ifdef MCP_BUG11764737 + int reset(void) { rev_it.rewind(); return QUICK_RANGE_SELECT::reset(); } +#else int reset(void); +#endif List rev_ranges; List_iterator rev_it; uint used_key_parts; === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2011-03-17 13:54:30 +0000 +++ b/sql/sql_select.cc 2011-03-23 14:07:43 +0000 @@ -1813,6 +1813,7 @@ JOIN::save_join_tab() } +#ifndef MCP_BUG11764737 static void disable_sorted_access(JOIN_TAB* join_tab) { @@ -1822,6 +1823,7 @@ disable_sorted_access(JOIN_TAB* join_tab join_tab->select->quick->sorted= 0; } } +#endif /** @@ -1993,7 +1995,11 @@ JOIN::exec() DBUG_PRINT("info", ("%s", thd->proc_info)); if (!curr_join->sort_and_group && curr_join->const_tables != curr_join->tables) +#ifdef MCP_BUG11764737 + curr_join->join_tab[curr_join->const_tables].sorted= 0; +#else disable_sorted_access(&curr_join->join_tab[curr_join->const_tables]); +#endif if ((tmp_error= do_select(curr_join, (List *) 0, curr_tmp_table, 0))) { error= tmp_error; @@ -2157,7 +2163,11 @@ JOIN::exec() curr_join->group_list= 0; if (!curr_join->sort_and_group && curr_join->const_tables != curr_join->tables) +#ifdef MCP_BUG11764737 + curr_join->join_tab[curr_join->const_tables].sorted= 0; +#else disable_sorted_access(&curr_join->join_tab[curr_join->const_tables]); +#endif if (setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) || (tmp_error= do_select(curr_join, (List *) 0, curr_tmp_table, 0))) @@ -6928,7 +6938,12 @@ make_join_readinfo(JOIN *join, ulonglong uint i; bool statistics= test(!(join->select_options & SELECT_DESCRIBE)); bool ordered_set= 0; +#ifdef MCP_BUG11764737 + bool sorted= 1; +#else + /* First table sorted if ORDER or GROUP BY was specified */ bool sorted= (join->order || join->group_list); +#endif DBUG_ENTER("make_join_readinfo"); for (i=join->const_tables ; i < join->tables ; i++) @@ -12280,7 +12295,12 @@ join_read_key(JOIN_TAB *tab) if (!table->file->inited) { +#ifdef MCP_BUG11764737 table->file->ha_index_init(tab->ref.key, 0); +#else + DBUG_ASSERT(!tab->sorted); // Don't expect sort req. for single row. + table->file->ha_index_init(tab->ref.key, tab->sorted); +#endif } if (cmp_buffer_with_ref(tab) || (table->status & (STATUS_GARBAGE | STATUS_NO_PARENT | STATUS_NULL_ROW))) @@ -12639,7 +12659,11 @@ join_read_last(JOIN_TAB *tab) tab->read_record.index=tab->index; tab->read_record.record=table->record[0]; if (!table->file->inited) +#ifdef MCP_BUG11764737 + table->file->ha_index_init(tab->index, 1); +#else table->file->ha_index_init(tab->index, tab->sorted); +#endif if ((error= tab->table->file->index_last(tab->table->record[0]))) return report_error(table, error); return 0; @@ -12663,7 +12687,11 @@ join_ft_read_first(JOIN_TAB *tab) TABLE *table= tab->table; if (!table->file->inited) +#ifdef MCP_BUG11764737 + table->file->ha_index_init(tab->ref.key, 1); +#else table->file->ha_index_init(tab->ref.key, tab->sorted); +#endif #if NOT_USED_YET /* as ft-key doesn't use store_key's, see also FT_SELECT::init() */ if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref)) No bundle (reason: useless for push emails).