Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1910 05/05/30 20:54:37 konstantin@stripped +17 -0
Preparatory (and the most problematic) patch for Bug#7306
"the server side preparedStatement error for LIMIT placeholder",
which moves all uses of LIMIT clause from PREPARE to OPTIMIZE
and later steps.
After-review fixes.
sql/sql_update.cc
1.159 05/05/30 20:54:31 konstantin@stripped +3 -4
- setup_tables signature changed
sql/sql_union.cc
1.116 05/05/30 20:54:31 konstantin@stripped +8 -28
Class st_select_lex_unit was changed to avoid calls to
st_select_lex_unit::set_limit from places where it may be unknown.
Now unit->select_limit_cnt is set at ::exec().
st_select_lex_unit::init_prepare_fake_select_lex():
- move out set_limit functionality
- remove a few lines of dead code.
st_select_lex_unit::prepare():
- now we don't call set_limit at the time of prepare, so the value
of unit->select_limit_cnt may be unknown here. Use sl->select_limit
instead.
st_select_lex_unit::exec():
- cleanup
- call set_limit explicitly as it has been moved out of
init_prepare_fake_select_lex.
sql/sql_select.cc
1.325 05/05/30 20:54:30 konstantin@stripped +11 -21
Move setting of JOIN::select_limit from JOIN::prepare
to JOIN::optimize. At prepare, limit is unknown yet.
Remove excessive cleanups from JOIN::reinit which were overwriting
join->join_tab[i]->table->used_keys. This fixes the bug which was triggered
by the change in item_subselect.cc.
sql/sql_parse.cc
1.435 05/05/30 20:54:30 konstantin@stripped +2 -2
- st_select_lex_unit::set_limit() signature changed
sql/sql_olap.cc
1.16 05/05/30 20:54:30 konstantin@stripped +1 -2
- setup_tables signature changed
sql/sql_load.cc
1.80 05/05/30 20:54:30 konstantin@stripped +1 -1
- setup_tables signature changed
sql/sql_lex.h
1.179 05/05/30 20:54:30 konstantin@stripped +2 -2
Cleanup signature of st_select_lex_unit::init_prepare_fake_select_lex().
sql/sql_lex.cc
1.145 05/05/30 20:54:30 konstantin@stripped +2 -6
Consolidate setting of internal LIMIT for IN/ALL/ANY/EXISTS subqeries
in one place, and hence remove it from st_select_lex::test_limit().
sql/sql_insert.cc
1.153 05/05/30 20:54:30 konstantin@stripped +1 -1
- setup_tables signature changed
sql/sql_help.cc
1.45 05/05/30 20:54:30 konstantin@stripped +1 -1
- setup_tables signature changed
sql/sql_delete.cc
1.149 05/05/30 20:54:30 konstantin@stripped +2 -3
- setup_tables signature changed
sql/sql_base.cc
1.246 05/05/30 20:54:30 konstantin@stripped +8 -11
- setup_tables no longer needs a special mode for subqueries.
Unused checks were removed.
sql/sp.cc
1.76 05/05/30 20:54:30 konstantin@stripped +1 -1
- setup_tables signature changed.
sql/opt_range.cc
1.162 05/05/30 20:54:29 konstantin@stripped +10 -1
Fix a glitch in GROUP_MIN_MAX access plan: we should use table metadata,
not field data, to evaluate max_used_key_length, which is then
used for explain.
sql/mysql_priv.h
1.300 05/05/30 20:54:29 konstantin@stripped +1 -2
setup_tables no longer needs a special flag for the case when
it's called from JOIN::reinit() (we don't need to call setup_tables
between two executions of a correlated subquery).
sql/item_subselect.cc
1.100 05/05/30 20:54:29 konstantin@stripped +9 -12
Move setting of the internal LIMIT used for IN/ALL/ANY/EXISTS
subqueries to one place: Item_exists_subselect::fix_length_and_dec().
This implies that unit->select_limit_cnt is not set until the item is
fixed. This is OK, as now LIMIT values are not used until JOIN::optimize.
mysql-test/r/group_min_max.result
1.13 05/05/30 20:54:29 konstantin@stripped +6 -6
Test results fixed for EXPLAINs when using GROUP_MIN_MAX access plan.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: konstantin
# Host: dragonfly.local
# Root: /opt/local/work/mysql-5.0-7306-new
--- 1.299/sql/mysql_priv.h 2005-05-24 22:25:44 +04:00
+++ 1.300/sql/mysql_priv.h 2005-05-30 20:54:29 +04:00
@@ -884,8 +884,7 @@
List_iterator<Item> *it, bool any_privileges,
bool allocate_view_names);
bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds,
- TABLE_LIST **leaves, bool refresh_only,
- bool select_insert);
+ TABLE_LIST **leaves, bool select_insert);
int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
List<Item> *sum_func_list, uint wild_num);
bool setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables,
--- 1.161/sql/opt_range.cc 2005-05-21 18:02:22 +04:00
+++ 1.162/sql/opt_range.cc 2005-05-30 20:54:29 +04:00
@@ -7982,8 +7982,17 @@
}
}
}
- else if (have_min && min_max_arg_part &&
min_max_arg_part->field->is_null())
+ else if (have_min && min_max_arg_part &&
+ min_max_arg_part->field->real_maybe_null())
{
+ /*
+ If a MIN/MAX argument value is NULL, we can quickly determine
+ that we're in the beginning of the next group, because NULLs
+ are always < any other value. This allows us to quickly
+ determine the end of the current group and jump to the next
+ group (see next_min()) and thus effectively increases the
+ usable key length.
+ */
max_used_key_length+= min_max_arg_len;
++used_key_parts;
}
--- 1.245/sql/sql_base.cc 2005-05-24 22:25:44 +04:00
+++ 1.246/sql/sql_base.cc 2005-05-30 20:54:30 +04:00
@@ -3208,7 +3208,7 @@
*/
bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds,
- TABLE_LIST **leaves, bool refresh, bool select_insert)
+ TABLE_LIST **leaves, bool select_insert)
{
uint tablenr= 0;
DBUG_ENTER("setup_tables");
@@ -3261,17 +3261,14 @@
my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
DBUG_RETURN(1);
}
- if (!refresh)
+ for (TABLE_LIST *table_list= tables;
+ table_list;
+ table_list= table_list->next_local)
{
- for (TABLE_LIST *table_list= tables;
- table_list;
- table_list= table_list->next_local)
- {
- if (table_list->ancestor &&
- table_list->setup_ancestor(thd, conds,
- table_list->effective_with_check))
- DBUG_RETURN(1);
- }
+ if (table_list->ancestor &&
+ table_list->setup_ancestor(thd, conds,
+ table_list->effective_with_check))
+ DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
--- 1.148/sql/sql_delete.cc 2005-05-24 22:25:44 +04:00
+++ 1.149/sql/sql_delete.cc 2005-05-30 20:54:30 +04:00
@@ -300,8 +300,7 @@
SELECT_LEX *select_lex= &thd->lex->select_lex;
DBUG_ENTER("mysql_prepare_delete");
- if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables,
- FALSE, FALSE) ||
+ if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
setup_ftfuncs(select_lex))
DBUG_RETURN(TRUE);
@@ -358,7 +357,7 @@
lex->query_tables also point on local list of DELETE SELECT_LEX
*/
if (setup_tables(thd, lex->query_tables, &lex->select_lex.where,
- &lex->select_lex.leaf_tables, FALSE, FALSE))
+ &lex->select_lex.leaf_tables, FALSE))
DBUG_RETURN(TRUE);
--- 1.152/sql/sql_insert.cc 2005-05-24 22:35:38 +04:00
+++ 1.153/sql/sql_insert.cc 2005-05-30 20:54:30 +04:00
@@ -699,7 +699,7 @@
DBUG_ENTER("mysql_prepare_insert_check_table");
if (setup_tables(thd, table_list, where, &thd->lex->select_lex.leaf_tables,
- FALSE, select_insert))
+ select_insert))
DBUG_RETURN(TRUE);
if (insert_into_view && !fields.elements)
--- 1.144/sql/sql_lex.cc 2005-05-19 05:48:17 +04:00
+++ 1.145/sql/sql_lex.cc 2005-05-30 20:54:30 +04:00
@@ -1369,8 +1369,6 @@
"LIMIT & IN/ALL/ANY/SOME subquery");
return(1);
}
- // We need only 1 row to determinate existence
- select_limit= 1;
// no sense in ORDER BY without LIMIT
order_list.empty();
return(0);
@@ -1553,7 +1551,7 @@
item->substype() == Item_subselect::IN_SUBS ||
item->substype() == Item_subselect::ALL_SUBS))
{
- DBUG_ASSERT(select_limit == 1L && offset_limit == 0L);
+ DBUG_ASSERT(!item->fixed || select_limit == 1L && offset_limit == 0L);
return;
}
@@ -1756,11 +1754,9 @@
SYNOPSIS
st_select_lex_unit::set_limit()
values - SELECT_LEX with initial values for counters
- sl - SELECT_LEX for options set
*/
-void st_select_lex_unit::set_limit(SELECT_LEX *values,
- SELECT_LEX *sl)
+void st_select_lex_unit::set_limit(SELECT_LEX *values)
{
offset_limit_cnt= values->offset_limit;
select_limit_cnt= values->select_limit+values->offset_limit;
--- 1.178/sql/sql_lex.h 2005-05-23 22:38:07 +04:00
+++ 1.179/sql/sql_lex.h 2005-05-30 20:54:30 +04:00
@@ -445,10 +445,10 @@
void print(String *str);
- ulong init_prepare_fake_select_lex(THD *thd);
+ void init_prepare_fake_select_lex(THD *thd);
inline bool is_prepared() { return prepared; }
bool change_result(select_subselect *result, select_subselect *old_result);
- void set_limit(st_select_lex *values, st_select_lex *sl);
+ void set_limit(st_select_lex *values);
friend void lex_start(THD *thd, uchar *buf, uint length);
friend int subselect_union_engine::exec();
--- 1.79/sql/sql_load.cc 2005-05-24 22:19:28 +04:00
+++ 1.80/sql/sql_load.cc 2005-05-30 20:54:30 +04:00
@@ -150,7 +150,7 @@
if (open_and_lock_tables(thd, table_list))
DBUG_RETURN(TRUE);
if (setup_tables(thd, table_list, &unused_conds,
- &thd->lex->select_lex.leaf_tables, FALSE, FALSE))
+ &thd->lex->select_lex.leaf_tables, FALSE))
DBUG_RETURN(-1);
if (!table_list->table || // do not suport join view
!table_list->updatable || // and derived tables
--- 1.434/sql/sql_parse.cc 2005-05-24 18:51:58 +04:00
+++ 1.435/sql/sql_parse.cc 2005-05-30 20:54:30 +04:00
@@ -2777,7 +2777,7 @@
select_result *result;
select_lex->options|= SELECT_NO_UNLOCK;
- unit->set_limit(select_lex, select_lex);
+ unit->set_limit(select_lex);
if (!(res= open_and_lock_tables(thd, select_tables)))
{
@@ -3175,7 +3175,7 @@
select_lex->options|= SELECT_NO_UNLOCK;
select_result *result;
- unit->set_limit(select_lex, select_lex);
+ unit->set_limit(select_lex);
if (!(res= open_and_lock_tables(thd, all_tables)))
{
--- 1.324/sql/sql_select.cc 2005-05-23 21:01:14 +04:00
+++ 1.325/sql/sql_select.cc 2005-05-30 20:54:30 +04:00
@@ -233,7 +233,7 @@
else
{
SELECT_LEX_UNIT *unit= &lex->unit;
- unit->set_limit(unit->global_parameters, select_lex);
+ unit->set_limit(unit->global_parameters);
/*
'options' of mysql_select will be set in JOIN, as far as JOIN for
every PS/SP execution new, we will not need reset this flag if
@@ -342,7 +342,7 @@
if ((!(select_options & OPTION_SETUP_TABLES_DONE) &&
setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables,
- FALSE, FALSE)) ||
+ FALSE)) ||
setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) ||
select_lex->setup_ref_array(thd, og_num) ||
setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1,
@@ -465,13 +465,6 @@
count_field_types(&tmp_table_param, all_fields, 0);
ref_pointer_array_size= all_fields.elements*sizeof(Item*);
this->group= group_list != 0;
- row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
- unit_arg->select_limit_cnt);
- /* select_limit is used to decide if we are likely to scan the whole table */
- select_limit= unit_arg->select_limit_cnt;
- if (having || (select_options & OPTION_FOUND_ROWS))
- select_limit= HA_POS_ERROR;
- do_send_rows = (unit_arg->select_limit_cnt) ? 1 : 0;
unit= unit_arg;
#ifdef RESTRICTED_GROUP
@@ -550,6 +543,13 @@
DBUG_RETURN(0);
optimized= 1;
+ row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR :
+ unit->select_limit_cnt);
+ /* select_limit is used to decide if we are likely to scan the whole table */
+ select_limit= unit->select_limit_cnt;
+ if (having || (select_options & OPTION_FOUND_ROWS))
+ select_limit= HA_POS_ERROR;
+ do_send_rows = (unit->select_limit_cnt) ? 1 : 0;
// Ignore errors of execution if option IGNORE present
if (thd->lex->ignore)
thd->lex->current_select->no_error= 1;
@@ -1110,18 +1110,7 @@
JOIN::reinit()
{
DBUG_ENTER("JOIN::reinit");
- /* TODO move to unit reinit */
- unit->set_limit(select_lex, select_lex);
- /* conds should not be used here, it is added just for safety */
- if (tables_list)
- {
- if (setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables,
- TRUE, FALSE))
- DBUG_RETURN(1);
- }
-
- /* Reset of sum functions */
first_record= 0;
if (exec_tmp_table1)
@@ -1147,6 +1136,7 @@
if (tmp_join)
restore_tmp();
+ /* Reset of sum functions */
if (sum_funcs)
{
Item_sum *func, **func_ptr= sum_funcs;
@@ -13485,7 +13475,7 @@
else
{
thd->lex->current_select= first;
- unit->set_limit(unit->global_parameters, first);
+ unit->set_limit(unit->global_parameters);
res= mysql_select(thd, &first->ref_pointer_array,
(TABLE_LIST*) first->table_list.first,
first->with_wild, first->item_list,
--- 1.158/sql/sql_update.cc 2005-05-24 22:35:38 +04:00
+++ 1.159/sql/sql_update.cc 2005-05-30 20:54:31 +04:00
@@ -557,8 +557,7 @@
tables.table= table;
tables.alias= table_list->alias;
- if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables,
- FALSE, FALSE) ||
+ if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
select_lex->setup_ref_array(thd, order_num) ||
setup_order(thd, select_lex->ref_pointer_array,
@@ -644,7 +643,7 @@
*/
if (setup_tables(thd, table_list, &lex->select_lex.where,
- &lex->select_lex.leaf_tables, FALSE, FALSE))
+ &lex->select_lex.leaf_tables, FALSE))
DBUG_RETURN(TRUE);
leaves= lex->select_lex.leaf_tables;
@@ -764,7 +763,7 @@
tbl->cleanup_items();
if (setup_tables(thd, table_list, &lex->select_lex.where,
- &lex->select_lex.leaf_tables, FALSE, FALSE) ||
+ &lex->select_lex.leaf_tables, FALSE) ||
(lex->select_lex.no_wrap_view_item= 1,
res= setup_fields(thd, 0, table_list, *fields, 1, 0, 0),
lex->select_lex.no_wrap_view_item= 0,
--- 1.15/sql/sql_olap.cc 2004-11-25 03:23:08 +03:00
+++ 1.16/sql/sql_olap.cc 2005-05-30 20:54:30 +04:00
@@ -153,8 +153,7 @@
if (setup_tables(lex->thd, (TABLE_LIST *)select_lex->table_list.first
- &select_lex->where, &select_lex->leaf_tables,
- FALSE, FALSE) ||
+ &select_lex->where, &select_lex->leaf_tables, FALSE) ||
setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first,
select_lex->item_list, 1, &all_fields,1) ||
setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first,
--- 1.115/sql/sql_union.cc 2005-03-31 11:39:43 +04:00
+++ 1.116/sql/sql_union.cc 2005-05-30 20:54:31 +04:00
@@ -115,27 +115,15 @@
options of SELECT
*/
-ulong
+void
st_select_lex_unit::init_prepare_fake_select_lex(THD *thd)
{
- ulong options_tmp= thd->options | fake_select_lex->options;
thd->lex->current_select= fake_select_lex;
- offset_limit_cnt= global_parameters->offset_limit;
- select_limit_cnt= global_parameters->select_limit +
- global_parameters->offset_limit;
-
- if (select_limit_cnt < global_parameters->select_limit)
- select_limit_cnt= HA_POS_ERROR; // no limit
- if (select_limit_cnt == HA_POS_ERROR)
- options_tmp&= ~OPTION_FOUND_ROWS;
- else if (found_rows_for_union && !thd->lex->describe)
- options_tmp|= OPTION_FOUND_ROWS;
fake_select_lex->ftfunc_list_alloc.empty();
fake_select_lex->ftfunc_list= &fake_select_lex->ftfunc_list_alloc;
fake_select_lex->table_list.link_in_list((byte *)&result_table_list,
(byte **)
&result_table_list.next_local);
- return options_tmp;
}
@@ -217,10 +205,9 @@
goto err;
thd_arg->lex->current_select= sl;
- set_limit(sl, sl);
can_skip_order_by= is_union &&
- (!sl->braces || select_limit_cnt == HA_POS_ERROR);
+ (!sl->braces || sl->select_limit == HA_POS_ERROR);
res= join->prepare(&sl->ref_pointer_array,
(TABLE_LIST*) sl->table_list.first, sl->with_wild,
@@ -340,7 +327,7 @@
if (arena->is_stmt_prepare())
{
/* prepare fake select to initialize it correctly */
- (void) init_prepare_fake_select_lex(thd);
+ init_prepare_fake_select_lex(thd);
/*
Should be done only once (the only item_list per statement).
*/
@@ -429,12 +416,8 @@
res= sl->join->reinit();
else
{
- if (sl != global_parameters && !describe)
- {
- offset_limit_cnt= sl->offset_limit;
- select_limit_cnt= sl->select_limit+sl->offset_limit;
- }
- else
+ set_limit(sl);
+ if (sl == global_parameters || describe)
{
offset_limit_cnt= 0;
/*
@@ -443,11 +426,7 @@
*/
if (sl->order_list.first || describe)
select_limit_cnt= HA_POS_ERROR;
- else
- select_limit_cnt= sl->select_limit+sl->offset_limit;
- }
- if (select_limit_cnt < sl->select_limit)
- select_limit_cnt= HA_POS_ERROR; // no limit
+ }
/*
When using braces, SQL_CALC_FOUND_ROWS affects the whole query:
@@ -512,7 +491,8 @@
if (!thd->is_fatal_error) // Check if EOM
{
- ulong options_tmp= init_prepare_fake_select_lex(thd);
+ set_limit(global_parameters);
+ init_prepare_fake_select_lex(thd);
JOIN *join= fake_select_lex->join;
if (!join)
{
--- 1.99/sql/item_subselect.cc 2005-04-01 03:13:23 +04:00
+++ 1.100/sql/item_subselect.cc 2005-05-30 20:54:29 +04:00
@@ -537,8 +537,6 @@
null_value= 0; //can't be NULL
maybe_null= 0; //can't be NULL
value= 0;
- // We need only 1 row to determinate existence
- select_lex->master_unit()->global_parameters->select_limit= 1;
DBUG_VOID_RETURN;
}
@@ -605,6 +603,8 @@
decimals= 0;
max_length= 1;
max_columns= engine->cols();
+ /* We need only 1 row to determinate existence */
+ unit->global_parameters->select_limit= 1;
}
double Item_exists_subselect::val_real()
@@ -854,9 +854,6 @@
else
{
Item_maxmin_subselect *item;
- // remove LIMIT placed by ALL/ANY subquery
- select_lex->master_unit()->global_parameters->select_limit=
- HA_POS_ERROR;
subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op());
if (upper_item)
upper_item->set_sub_test(item);
@@ -1286,13 +1283,10 @@
select_subselect *result,
Item_subselect *item)
:subselect_engine(item, result),
- prepared(0), optimized(0), executed(0), join(0)
+ prepared(0), optimized(0), executed(0),
+ select_lex(select), join(0)
{
- select_lex= select;
- SELECT_LEX_UNIT *unit= select_lex->master_unit();
- unit->set_limit(unit->global_parameters, select_lex);
- unit->item= item;
- this->select_lex= select_lex;
+ select_lex->master_unit()->item= item;
}
@@ -1440,7 +1434,10 @@
thd->lex->current_select= select_lex;
if (!optimized)
{
- optimized=1;
+ SELECT_LEX_UNIT *unit= select_lex->master_unit();
+
+ optimized= 1;
+ unit->set_limit(unit->global_parameters);
if (join->optimize())
{
thd->where= save_where;
--- 1.75/sql/sp.cc 2005-05-19 05:48:17 +04:00
+++ 1.76/sql/sp.cc 2005-05-30 20:54:30 +04:00
@@ -667,7 +667,7 @@
tables is not VIEW for sure => we can pass 0 as condition
*/
- setup_tables(thd, &tables, 0, &leaves, FALSE, FALSE);
+ setup_tables(thd, &tables, 0, &leaves, FALSE);
for (used_field= &used_fields[0];
used_field->field_name;
used_field++)
--- 1.12/mysql-test/r/group_min_max.result 2005-05-19 06:54:28 +04:00
+++ 1.13/mysql-test/r/group_min_max.result 2005-05-30 20:54:29 +04:00
@@ -133,13 +133,13 @@
test.t3 analyze status Table is already up to date
explain select a1, min(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a1, max(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
explain select a1, min(a2), max(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
@@ -151,13 +151,13 @@
1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by
explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2,
b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
explain select min(a2) from t1 group by a1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by
explain select a2, min(c), max(c) from t1 group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by
@@ -1404,7 +1404,7 @@
1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index
for group-by
explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c')
group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index
for group-by
+1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index
for group-by
select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a')
group by a1,a2,b;
a1 a2 b min(c) max(c)
a a b e112 h112
@@ -1838,7 +1838,7 @@
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using
index for group-by
explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx_t1_1 130 NULL 9 Using index for group-by
+1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by
select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b;
a1 a2 b concat(min(c), max(c))
a a a a111d111
--- 1.44/sql/sql_help.cc 2005-03-19 03:12:22 +03:00
+++ 1.45/sql/sql_help.cc 2005-05-30 20:54:30 +04:00
@@ -651,7 +651,7 @@
tables do not contain VIEWs => we can pass 0 as conds
*/
- setup_tables(thd, tables, 0, &leaves, FALSE, FALSE);
+ setup_tables(thd, tables, 0, &leaves, FALSE);
memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields));
if (init_fields(thd, tables, used_fields, array_elements(used_fields)))
goto error;
| Thread |
|---|
| • bk commit into 5.0 tree (konstantin:1.1910) BUG#7306 | konstantin | 31 May |