Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge 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@stripped, 2007-03-09 13:56:48+02:00, gkodinov@stripped +10 -0
Merge gkodinov@stripped:/home/bk/mysql-5.0-opt
into magare.gmz:/home/kgeorge/mysql/autopush/B24484-5.0
MERGE: 1.2377.47.1
mysql-test/r/subselect3.result@stripped, 2007-03-09 13:56:44+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.4.1.1
sql/item.h@stripped, 2007-03-09 13:56:44+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.213.7.1
sql/item_sum.cc@stripped, 2007-03-09 13:56:44+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.192.3.1
sql/mysql_priv.h@stripped, 2007-03-09 13:56:44+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.429.12.1
sql/sql_base.cc@stripped, 2007-03-09 13:56:44+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.365.3.1
sql/sql_delete.cc@stripped, 2007-03-09 13:56:45+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.191.2.1
sql/sql_insert.cc@stripped, 2007-03-09 13:56:45+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.211.7.1
sql/sql_load.cc@stripped, 2007-03-09 13:56:45+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.102.4.1
sql/sql_select.cc@stripped, 2007-03-09 13:56:45+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.488.4.1
sql/sql_update.cc@stripped, 2007-03-09 13:56:45+02:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.205.5.1
# 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: gkodinov
# Host: magare.gmz
# Root: /home/kgeorge/mysql/autopush/B24484-5.0/RESYNC
--- 1.220/sql/item.h 2007-03-05 05:54:30 +02:00
+++ 1.221/sql/item.h 2007-03-09 13:56:44 +02:00
@@ -1893,6 +1893,11 @@ public:
{
return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
}
+ void update_used_tables()
+ {
+ if (!depended_from)
+ (*ref)->update_used_tables();
+ }
table_map not_null_tables() const { return (*ref)->not_null_tables(); }
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }
--- 1.196/sql/item_sum.cc 2007-02-21 13:05:00 +02:00
+++ 1.197/sql/item_sum.cc 2007-03-09 13:56:44 +02:00
@@ -61,6 +61,7 @@ bool Item_sum::init_sum_func_check(THD *
/* Save a pointer to object to be used in items for nested set functions */
thd->lex->in_sum_func= this;
nest_level= thd->lex->current_select->nest_level;
+ nest_level_tables_count= thd->lex->current_select->join->tables;
ref_by= 0;
aggr_level= -1;
max_arg_level= -1;
@@ -176,6 +177,7 @@ bool Item_sum::check_sum_func(THD *thd,
*/
set_if_bigger(in_sum_func->max_sum_func_level, aggr_level);
}
+ update_used_tables();
thd->lex->in_sum_func= in_sum_func;
return FALSE;
}
@@ -271,8 +273,8 @@ bool Item_sum::register_sum_func(THD *th
}
-Item_sum::Item_sum(List<Item> &list)
- :arg_count(list.elements)
+Item_sum::Item_sum(List<Item> &list) :arg_count(list.elements),
+ forced_const(FALSE)
{
if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
{
@@ -296,7 +298,10 @@ Item_sum::Item_sum(List<Item> &list)
Item_sum::Item_sum(THD *thd, Item_sum *item):
Item_result_field(thd, item), arg_count(item->arg_count),
- quick_group(item->quick_group)
+ nest_level(item->nest_level), aggr_level(item->aggr_level),
+ quick_group(item->quick_group), used_tables_cache(item->used_tables_cache),
+ forced_const(item->forced_const),
+ nest_level_tables_count(item->nest_level_tables_count)
{
if (arg_count <= 2)
args=tmp_args;
@@ -426,6 +431,26 @@ case DECIMAL_RESULT:
}
+void Item_sum::update_used_tables ()
+{
+ if (!forced_const)
+ {
+ used_tables_cache= 0;
+ for (uint i=0 ; i < arg_count ; i++)
+ {
+ args[i]->update_used_tables();
+ used_tables_cache|= args[i]->used_tables();
+ }
+
+ used_tables_cache&= PSEUDO_TABLE_BITS;
+
+ /* the aggregate function is aggregated into its local context */
+ if (aggr_level == nest_level)
+ used_tables_cache |= (1 << nest_level_tables_count) - 1;
+ }
+}
+
+
String *
Item_sum_num::val_str(String *str)
{
@@ -485,7 +510,7 @@ Item_sum_num::fix_fields(THD *thd, Item
Item_sum_hybrid::Item_sum_hybrid(THD *thd, Item_sum_hybrid *item)
:Item_sum(thd, item), value(item->value), hybrid_type(item->hybrid_type),
hybrid_field_type(item->hybrid_field_type), cmp_sign(item->cmp_sign),
- used_table_cache(item->used_table_cache), was_values(item->was_values)
+ was_values(item->was_values)
{
/* copy results from old value */
switch (hybrid_type) {
@@ -1073,7 +1098,6 @@ void Item_sum_count::cleanup()
DBUG_ENTER("Item_sum_count::cleanup");
count= 0;
Item_sum_int::cleanup();
- used_table_cache= ~(table_map) 0;
DBUG_VOID_RETURN;
}
@@ -1554,7 +1578,7 @@ void Item_sum_hybrid::cleanup()
{
DBUG_ENTER("Item_sum_hybrid::cleanup");
Item_sum::cleanup();
- used_table_cache= ~(table_map) 0;
+ forced_const= FALSE;
/*
by default it is TRUE to avoid TRUE reporting by
--- 1.437/sql/mysql_priv.h 2007-03-08 19:29:58 +02:00
+++ 1.438/sql/mysql_priv.h 2007-03-09 13:56:44 +02:00
@@ -1055,7 +1055,7 @@ bool setup_tables_and_check_access (THD
Name_resolution_context *context,
List<TABLE_LIST> *from_clause,
TABLE_LIST *tables, Item **conds,
- TABLE_LIST **leaves,
+ TABLE_LIST **leaves, uint *leaf_count,
bool select_insert,
ulong want_access_first,
ulong want_access);
--- 1.370/sql/sql_base.cc 2007-03-08 19:29:58 +02:00
+++ 1.371/sql/sql_base.cc 2007-03-09 13:56:44 +02:00
@@ -4840,6 +4840,7 @@ bool setup_tables(THD *thd, Name_resolut
tables Table list (select_lex->table_list)
conds Condition of current SELECT (can be changed by VIEW)
leaves List of join table leaves list (select_lex->leaf_tables)
+ leaf_count Optional. Pointer to an plase to accumulate the count.
refresh It is onle refresh for subquery
select_insert It is SELECT ... INSERT command
want_access what access is needed
@@ -4857,12 +4858,14 @@ bool setup_tables_and_check_access(THD *
List<TABLE_LIST> *from_clause,
TABLE_LIST *tables,
Item **conds, TABLE_LIST **leaves,
+ uint *leaf_count,
bool select_insert,
ulong want_access_first,
ulong want_access)
{
TABLE_LIST *leaves_tmp = NULL;
bool first_table= true;
+ uint leaf_count_tmp= 0;
if (setup_tables (thd, context, from_clause, tables, conds,
&leaves_tmp, select_insert))
@@ -4881,7 +4884,10 @@ bool setup_tables_and_check_access(THD *
return TRUE;
}
first_table= false;
+ leaf_count_tmp++;
}
+ if (leaf_count)
+ *leaf_count= leaf_count_tmp;
return FALSE;
}
--- 1.193/sql/sql_delete.cc 2007-03-01 23:10:23 +02:00
+++ 1.194/sql/sql_delete.cc 2007-03-09 13:56:45 +02:00
@@ -359,7 +359,7 @@ bool mysql_prepare_delete(THD *thd, TABL
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list, conds,
- &select_lex->leaf_tables, FALSE,
+ &select_lex->leaf_tables, NULL, FALSE,
DELETE_ACL, SELECT_ACL) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
setup_ftfuncs(select_lex))
@@ -427,7 +427,7 @@ bool mysql_multi_delete_prepare(THD *thd
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
lex->query_tables, &lex->select_lex.where,
- &lex->select_lex.leaf_tables, FALSE,
+ &lex->select_lex.leaf_tables, NULL, FALSE,
DELETE_ACL, SELECT_ACL))
DBUG_RETURN(TRUE);
--- 1.221/sql/sql_insert.cc 2007-03-08 19:29:58 +02:00
+++ 1.222/sql/sql_insert.cc 2007-03-09 13:56:45 +02:00
@@ -932,7 +932,7 @@ static bool mysql_prepare_insert_check_t
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list, where,
- &thd->lex->select_lex.leaf_tables,
+ &thd->lex->select_lex.leaf_tables, NULL,
select_insert, INSERT_ACL, SELECT_ACL))
DBUG_RETURN(TRUE);
--- 1.109/sql/sql_load.cc 2007-03-08 19:29:58 +02:00
+++ 1.110/sql/sql_load.cc 2007-03-09 13:56:45 +02:00
@@ -152,7 +152,8 @@ bool mysql_load(THD *thd,sql_exchange *e
if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context,
&thd->lex->select_lex.top_join_list,
table_list, &unused_conds,
- &thd->lex->select_lex.leaf_tables, FALSE,
+ &thd->lex->select_lex.leaf_tables, NULL,
+ FALSE,
INSERT_ACL | UPDATE_ACL,
INSERT_ACL | UPDATE_ACL))
DBUG_RETURN(-1);
--- 1.498/sql/sql_select.cc 2007-03-09 11:44:40 +02:00
+++ 1.499/sql/sql_select.cc 2007-03-09 13:56:45 +02:00
@@ -409,9 +409,17 @@ JOIN::prepare(Item ***rref_pointer_array
if ((!(select_options & OPTION_SETUP_TABLES_DONE) &&
setup_tables_and_check_access(thd, &select_lex->context, join_list,
tables_list, &conds,
- &select_lex->leaf_tables, FALSE,
- SELECT_ACL, SELECT_ACL)) ||
- setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) ||
+ &select_lex->leaf_tables, &tables,
+ FALSE,
+ SELECT_ACL, SELECT_ACL)))
+ DBUG_RETURN(-1);
+
+ TABLE_LIST *table_ptr;
+ for (table_ptr= select_lex->leaf_tables, tables=0; table_ptr;
+ table_ptr= table_ptr->next_leaf)
+ tables++;
+
+ if (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), fields_list, 1,
&all_fields, 1) ||
@@ -516,11 +524,6 @@ JOIN::prepare(Item ***rref_pointer_array
DBUG_RETURN(-1);
}
}
- TABLE_LIST *table_ptr;
- for (table_ptr= select_lex->leaf_tables;
- table_ptr;
- table_ptr= table_ptr->next_leaf)
- tables++;
}
{
/* Caclulate the number of groups */
@@ -6461,7 +6464,8 @@ static void update_depend_map(JOIN *join
order->item[0]->update_used_tables();
order->depend_map=depend_map=order->item[0]->used_tables();
// Not item_sum(), RAND() and no reference to table outside of sub select
- if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT)))
+ if (!(order->depend_map & (OUTER_REF_TABLE_BIT | RAND_TABLE_BIT))
+ && !order->item[0]->with_sum_func)
{
for (JOIN_TAB **tab=join->map2table;
depend_map ;
--- 1.212/sql/sql_update.cc 2007-03-08 19:29:59 +02:00
+++ 1.213/sql/sql_update.cc 2007-03-09 13:56:45 +02:00
@@ -628,7 +628,7 @@ bool mysql_prepare_update(THD *thd, TABL
if (setup_tables_and_check_access(thd, &select_lex->context,
&select_lex->top_join_list,
table_list, conds,
- &select_lex->leaf_tables,
+ &select_lex->leaf_tables, NULL,
FALSE, UPDATE_ACL, SELECT_ACL) ||
setup_conds(thd, table_list, select_lex->leaf_tables, conds) ||
select_lex->setup_ref_array(thd, order_num) ||
@@ -723,7 +723,7 @@ reopen_tables:
if (setup_tables_and_check_access(thd, &lex->select_lex.context,
&lex->select_lex.top_join_list,
table_list, &lex->select_lex.where,
- &lex->select_lex.leaf_tables, FALSE,
+ &lex->select_lex.leaf_tables, NULL, FALSE,
UPDATE_ACL, SELECT_ACL))
DBUG_RETURN(TRUE);
--- 1.5/mysql-test/r/subselect3.result 2007-02-21 21:59:51 +02:00
+++ 1.6/mysql-test/r/subselect3.result 2007-03-09 13:56:44 +02:00
@@ -645,3 +645,26 @@ a b Z
2 2 0
3 3 1
drop table t1,t2;
+CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
+INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'),
+(2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'),
+(1,9,'m');
+CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b));
+INSERT INTO t2 SELECT * FROM t1;
+SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b))
+as test FROM t1 GROUP BY a;
+a MAX(b) test
+1 9 m
+2 3 h
+3 4 i
+SELECT * FROM t1 GROUP by t1.a
+HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c
+HAVING MAX(t2.b+t1.a) < 10));
+a b c
+SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b))
+AS test FROM t1 GROUP BY a;
+a AVG(b) test
+1 4.0000 NULL
+2 2.0000 k
+3 2.5000 NULL
+DROP TABLE t1, t2;
| Thread |
|---|
| • bk commit into 5.0 tree (gkodinov:1.2471) | kgeorge | 9 Mar |