#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:jonas@stripped
3320 Ole John Aske 2010-10-21 [merge]
merge from telco-spj branch
modified:
mysql-test/suite/ndb/r/ndb_join_pushdown.result
mysql-test/t/partition.test
sql/opt_range.cc
sql/opt_range.h
sql/sql_select.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result'
--- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2010-10-16 15:05:21 +0000
+++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2010-10-21 07:50:44 +0000
@@ -3168,7 +3168,7 @@ scan_count
pruned_scan_count
1
sorted_scan_count
-2
+1
pushed_queries_defined
3
pushed_queries_dropped
=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test 2010-03-22 12:30:27 +0000
+++ b/mysql-test/t/partition.test 2010-10-21 07:23:57 +0000
@@ -1556,9 +1556,11 @@ partitions 10;
show create table t1;
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE),
(18446744073709551613), (18446744073709551612);
+--sorted_result
select * from t1;
select * from t1 where a = 18446744073709551615;
delete from t1 where a = 18446744073709551615;
+--sorted_result
select * from t1;
drop table t1;
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2010-10-06 10:06:47 +0000
+++ b/sql/opt_range.cc 2010-10-20 13:53:02 +0000
@@ -4983,7 +4983,7 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_
{
if (!(quick= get_quick_select(param, (*first_scan)->idx,
(*first_scan)->sel_arg, alloc)) ||
- quick_intrsect->push_quick_back(quick))
+ (quick->sorted= 1, quick_intrsect->push_quick_back(quick)))
{
delete quick_intrsect;
DBUG_RETURN(NULL);
@@ -4998,6 +4998,7 @@ QUICK_SELECT_I *TRP_ROR_INTERSECT::make_
DBUG_RETURN(NULL);
}
quick->file= NULL;
+ quick->sorted= 1;
quick_intrsect->cpk_quick= quick;
}
quick_intrsect->records= records;
@@ -5024,7 +5025,7 @@ 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)) ||
- quick_roru->push_quick_back(quick))
+ (quick->sorted= 1, quick_roru->push_quick_back(quick)))
DBUG_RETURN(NULL);
}
quick_roru->records= records;
@@ -8454,7 +8455,7 @@ int QUICK_RANGE_SELECT::reset()
in_range= FALSE;
cur_range= (QUICK_RANGE**) ranges.buffer;
- if (file->inited == handler::NONE && (error= file->ha_index_init(index,1)))
+ if (file->inited == handler::NONE && (error= file->ha_index_init(index,sorted)))
DBUG_RETURN(error);
/* Do not allocate the buffers twice. */
@@ -8671,7 +8672,7 @@ 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),
- TRUE);
+ sorted);
if (last_range->flag == (UNIQUE_RANGE | EQ_RANGE))
last_range= 0; // Stop searching
@@ -8797,6 +8798,7 @@ 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;
}
@@ -10208,11 +10210,18 @@ TRP_GROUP_MIN_MAX::make_quick(PARAM *par
if (quick_prefix_records == HA_POS_ERROR)
quick->quick_prefix_select= NULL; /* Can't construct a quick select. */
else
+ {
/* Make a QUICK_RANGE_SELECT to be used for group prefix retrieval. */
quick->quick_prefix_select= get_quick_select(param, param_idx,
index_tree,
&quick->alloc);
-
+ if (!quick->quick_prefix_select)
+ {
+ delete quick;
+ DBUG_RETURN(NULL);
+ }
+ quick->quick_prefix_select->sorted= 1;
+ }
/*
Extract the SEL_ARG subtree that contains only ranges for the MIN/MAX
attribute, and create an array of QUICK_RANGES to be used by the
@@ -10603,6 +10612,9 @@ 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.
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-10-06 10:06:47 +0000
+++ b/sql/opt_range.h 2010-10-20 13:53:02 +0000
@@ -350,7 +350,7 @@ class SEL_ARG;
/*
Quick select that does a range scan on a single key. The records are
- returned in key order.
+ returned in key order if 'QUICK_SELECT_I::sorted==true'.
*/
class QUICK_RANGE_SELECT : public QUICK_SELECT_I
{
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-10-16 09:22:02 +0000
+++ b/sql/sql_select.cc 2010-10-21 07:50:44 +0000
@@ -1822,6 +1822,17 @@ JOIN::save_join_tab()
}
+static void
+disable_sorted_access(JOIN_TAB* join_tab)
+{
+ join_tab->sorted= 0;
+ if (join_tab->select && join_tab->select->quick)
+ {
+ join_tab->select->quick->sorted= 0;
+ }
+}
+
+
/**
Exec select.
@@ -1991,7 +2002,7 @@ JOIN::exec()
DBUG_PRINT("info", ("%s", thd->proc_info));
if (!curr_join->sort_and_group &&
curr_join->const_tables != curr_join->tables)
- curr_join->join_tab[curr_join->const_tables].sorted= 0;
+ disable_sorted_access(&curr_join->join_tab[curr_join->const_tables]);
if ((tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table, 0)))
{
error= tmp_error;
@@ -2155,7 +2166,7 @@ JOIN::exec()
curr_join->group_list= 0;
if (!curr_join->sort_and_group &&
curr_join->const_tables != curr_join->tables)
- curr_join->join_tab[curr_join->const_tables].sorted= 0;
+ disable_sorted_access(&curr_join->join_tab[curr_join->const_tables]);
if (setup_sum_funcs(curr_join->thd, curr_join->sum_funcs) ||
(tmp_error= do_select(curr_join, (List<Item> *) 0, curr_tmp_table,
0)))
@@ -6739,7 +6750,7 @@ make_join_readinfo(JOIN *join, ulonglong
uint i;
bool statistics= test(!(join->select_options & SELECT_DESCRIBE));
bool ordered_set= 0;
- bool sorted= 1;
+ bool sorted= (join->order || join->group_list);
DBUG_ENTER("make_join_readinfo");
for (i=join->const_tables ; i < join->tables ; i++)
@@ -12037,7 +12048,7 @@ join_read_key(JOIN_TAB *tab)
if (!table->file->inited)
{
- table->file->ha_index_init(tab->ref.key, tab->sorted);
+ table->file->ha_index_init(tab->ref.key, 0);
}
if (cmp_buffer_with_ref(tab) ||
(table->status & (STATUS_GARBAGE | STATUS_NO_PARENT | STATUS_NULL_ROW)))
@@ -12395,7 +12406,7 @@ join_read_last(JOIN_TAB *tab)
tab->read_record.index=tab->index;
tab->read_record.record=table->record[0];
if (!table->file->inited)
- table->file->ha_index_init(tab->index, 1);
+ table->file->ha_index_init(tab->index, tab->sorted);
if ((error= tab->table->file->index_last(tab->table->record[0])))
return report_error(table, error);
return 0;
@@ -12419,7 +12430,7 @@ join_ft_read_first(JOIN_TAB *tab)
TABLE *table= tab->table;
if (!table->file->inited)
- table->file->ha_index_init(tab->ref.key, 1);
+ table->file->ha_index_init(tab->ref.key, tab->sorted);
#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: revision is a merge).
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3320) | Ole John Aske | 21 Oct |