Below is the list of changes that have just been committed into a local
4.1 repository of bell. When bell 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://www.mysql.com/doc/I/n/Installing_source_tree.html
ChangeSet
1.1378 02/10/31 02:11:59 bell@xxxxxxxxxxxxxxx +8 -0
IN subselect with ORDER BY, HAVING & sum functions
sql/sql_lex.h
1.95 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +1 -0
IN subselect with ORDER BY, HAVING & sum functions
sql/sql_lex.cc
1.52 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +2 -1
IN subselect with ORDER BY, HAVING & sum functions
sql/item_sum.h
1.19 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +8 -3
IN subselect with ORDER BY, HAVING & sum functions
sql/item_sum.cc
1.37 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +5 -2
IN subselect with ORDER BY, HAVING & sum functions
sql/item_subselect.cc
1.23 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +22 -7
IN subselect with ORDER BY, HAVING & sum functions
sql/item.h
1.36 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +4 -6
removed field, because parent class has same field
mysql-test/t/subselect.test
1.23 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +5 -0
IN subselect with ORDER BY, HAVING & sum functions test
mysql-test/r/subselect.result
1.24 02/10/31 02:11:57 bell@xxxxxxxxxxxxxxx +11 -0
IN subselect with ORDER BY, HAVING & sum functions test
# 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: bell
# Host: sanja.is.com.ua
# Root: /home/bell/mysql/work-in-4.1
--- 1.35/sql/item.h Sun Oct 27 23:26:55 2002
+++ 1.36/sql/item.h Thu Oct 31 02:11:57 2002
@@ -116,11 +116,10 @@
*/
class Item_outer_select_context_saver :public Item_wrapper
{
- Item *item;
public:
- Item_outer_select_context_saver(Item *i):
- item(i)
+ Item_outer_select_context_saver(Item *i)
{
+ item= i;
}
bool fix_fields(THD *, struct st_table_list *, Item ** ref);
};
@@ -130,11 +129,10 @@
*/
class Item_asterisk_remover :public Item_wrapper
{
- Item *item;
public:
- Item_asterisk_remover(Item *i):
- item(i)
+ Item_asterisk_remover(Item *i)
{
+ item= i;
}
bool fix_fields(THD *, struct st_table_list *, Item ** ref);
};
--- 1.36/sql/item_sum.cc Wed Oct 30 14:19:42 2002
+++ 1.37/sql/item_sum.cc Thu Oct 31 02:11:57 2002
@@ -23,7 +23,6 @@
#include "mysql_priv.h"
-
Item_sum::Item_sum(List<Item> &list)
{
arg_count=list.elements;
@@ -38,10 +37,14 @@
args[i++]= item;
}
}
- with_sum_func=1;
+ mark_as_sum_func();
list.empty(); // Fields are used
}
+void Item_sum::mark_as_sum_func()
+{
+ current_thd->lex.select->with_sum_func= with_sum_func= 1;
+}
void Item_sum::make_field(Send_field *tmp_field)
{
--- 1.18/sql/item_sum.h Wed Oct 2 13:32:53 2002
+++ 1.19/sql/item_sum.h Thu Oct 31 02:11:57 2002
@@ -34,23 +34,28 @@
uint arg_count;
bool quick_group; /* If incremental update of fields */
- Item_sum() : arg_count(0),quick_group(1) { with_sum_func=1; }
+ Item_sum() : arg_count(0),quick_group(1)
+ {
+ mark_as_sum_func();
+ }
Item_sum(Item *a) :quick_group(1)
{
arg_count=1;
args=tmp_args;
args[0]=a;
- with_sum_func = 1;
+ mark_as_sum_func();
}
Item_sum( Item *a, Item *b ) :quick_group(1)
{
arg_count=2;
args=tmp_args;
args[0]=a; args[1]=b;
- with_sum_func=1;
+ mark_as_sum_func();
}
Item_sum(List<Item> &list);
~Item_sum() { result_field=0; }
+ inline void mark_as_sum_func();
+
enum Type type() const { return SUM_FUNC_ITEM; }
virtual enum Sumfunctype sum_func () const=0;
virtual void reset()=0;
--- 1.51/sql/sql_lex.cc Sun Oct 27 21:29:38 2002
+++ 1.52/sql/sql_lex.cc Thu Oct 31 02:11:57 2002
@@ -934,7 +934,8 @@
order_list.first= 0;
order_list.next= (byte**) &order_list.first;
select_limit= HA_POS_ERROR;
- offset_limit= 0;
+ offset_limit= 0;
+ with_sum_func= 0;
}
void st_select_lex_unit::init_query()
--- 1.94/sql/sql_lex.h Tue Oct 29 10:52:29 2002
+++ 1.95/sql/sql_lex.h Thu Oct 31 02:11:57 2002
@@ -196,6 +196,7 @@
enum sub_select_type linkage;
SQL_LIST order_list; /* ORDER clause */
ha_rows select_limit, offset_limit; /* LIMIT clause parameters */
+ bool with_sum_func;
void init_query();
void init_select();
void include_down(st_select_lex_node *upper);
--- 1.23/mysql-test/r/subselect.result Sun Oct 27 23:27:56 2002
+++ 1.24/mysql-test/r/subselect.result Thu Oct 31 02:11:57 2002
@@ -230,4 +230,15 @@
1 PRIMARY searchconthardwarefr3 index NULL topic 3 NULL
2 Using index
2 SUBSELECT
No tables used
3 UNION No
tables used
+SELECT 1 IN (SELECT 1 FROM searchconthardwarefr3 HAVING a);
+Unknown column 'a' in 'having clause'
+SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM
searchconthardwarefr3 GROUP BY date);
+topic date pseudo
+40143 2002-08-03 joce
+43506 2002-10-02 joce
+SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM
searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
+topic date pseudo
+43506 2002-10-02 joce
+SELECT * from searchconthardwarefr3 where topic IN (SELECT SUM(topic) FROM
searchconthardwarefr3);
+topic date pseudo
drop table searchconthardwarefr3;
--- 1.22/mysql-test/t/subselect.test Sun Oct 27 23:27:56 2002
+++ 1.23/mysql-test/t/subselect.test Thu Oct 31 02:11:57 2002
@@ -120,4 +120,9 @@
-- error 1240
SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION ALL SELECT 1)
UNION SELECT 1;
EXPLAIN SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1);
+-- error 1054
+SELECT 1 IN (SELECT 1 FROM searchconthardwarefr3 HAVING a);
+SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM
searchconthardwarefr3 GROUP BY date);
+SELECT * from searchconthardwarefr3 where topic IN (SELECT topic FROM
searchconthardwarefr3 GROUP BY date HAVING topic < 4100);
+SELECT * from searchconthardwarefr3 where topic IN (SELECT SUM(topic) FROM
searchconthardwarefr3);
drop table searchconthardwarefr3;
--- 1.22/sql/item_subselect.cc Wed Oct 30 16:09:04 2002
+++ 1.23/sql/item_subselect.cc Thu Oct 31 02:11:57 2002
@@ -254,15 +254,30 @@
}
else
item= (Item*) sl->item_list.pop();
- sl->item_list.empty();
- sl->item_list.push_back(new Item_int(1));
+
left_expr= new Item_outer_select_context_saver(left_expr);
- item= new Item_asterisk_remover(item);
- if (sl->where)
- sl->where= new Item_cond_and(sl->where,
- new Item_func_eq(item, left_expr));
+
+ if (sl->having || sl->with_sum_func || sl->group_list.first)
+ {
+ sl->item_list.push_back(item);
+ item= new Item_ref(sl->item_list.head_ref(), 0, "<result>");
+ if (sl->having)
+ sl->having= new Item_cond_and(sl->having,
+ new Item_func_eq(item, left_expr));
+ else
+ sl->having= new Item_func_eq(item, left_expr);
+ }
else
- sl->where= new Item_func_eq(item, left_expr);
+ {
+ sl->item_list.empty();
+ sl->item_list.push_back(new Item_int(1));
+ item= new Item_asterisk_remover(item);
+ if (sl->where)
+ sl->where= new Item_cond_and(sl->where,
+ new Item_func_eq(item, left_expr));
+ else
+ sl->where= new Item_func_eq(item, left_expr);
+ }
}
DBUG_VOID_RETURN;
}
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail internals-thread5210@xxxxxxxxxxxxxxx
To unsubscribe, e-mail <internals-unsubscribe@xxxxxxxxxxxxxxx>
|