summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@laptop.sanja.is.com.ua>2003-08-23 13:29:38 +0300
committerunknown <bell@laptop.sanja.is.com.ua>2003-08-23 13:29:38 +0300
commit93afa26ea7c6206aca6d8dc3b25873f4d732b929 (patch)
tree53f4829d55971fc556fdf48ef0def5296d1b9f18
parentb4a45538dfc89868246bdb1bd6ec8a20eba666b1 (diff)
downloadmariadb-git-93afa26ea7c6206aca6d8dc3b25873f4d732b929.tar.gz
fixed bug of lack of fix_fields call (after merge bugfix (SCRUM))
fixed bug in Item_sum fixed bug in dependence remover after merge fix mysql-test/r/subselect.result: after merge fix mysql-test/r/union.result: new test mysql-test/t/subselect.test: after merge fix mysql-test/t/union.test: new test sql/item.cc: fixed returned value sql/item.h: fixed flag dropper (I was not able to find Item whicj need more to be fix_fielded twice) sql/item_subselect.h: fixed initialisation sql/item_sum.cc: fixed absence of walk method of Item_sum sql/item_sum.h: fixed absence of walk method of Item_sum sql/mysql_priv.h: setup_fields reverter sql/sql_base.cc: setup_fields reverter sql/sql_derived.cc: fixed bug of lack of fix_fields call sql/sql_union.cc: fixed bug of lack of fix_fields call
-rw-r--r--mysql-test/r/subselect.result2
-rw-r--r--mysql-test/r/union.result14
-rw-r--r--mysql-test/t/subselect.test2
-rw-r--r--mysql-test/t/union.test10
-rw-r--r--sql/item.cc2
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_subselect.h3
-rw-r--r--sql/item_sum.cc14
-rw-r--r--sql/item_sum.h2
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/sql_base.cc15
-rw-r--r--sql/sql_derived.cc3
-rw-r--r--sql/sql_union.cc3
13 files changed, 68 insertions, 4 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index deb6925cf6c..0eb89439fb0 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1347,7 +1347,7 @@ a
1
2
10
-drop table t1,t2;
+drop table t1,t2,t3;
create table t2 (a int, b int);
create table t3 (a int);
insert into t3 values (6),(7),(3);
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 396eba7197b..1f85e508067 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -384,3 +384,17 @@ is_in_group user_name group_name id
0 Tester Group A NULL
0 Tester Group B NULL
drop table t1, t2, t3;
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
+pla_id matintnum
+100 a
+101 a
+102 a
+103 b
+104 b
+105 c
+0 0
+drop table t1, t2;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index e4813326b14..74f789395fc 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -900,7 +900,7 @@ insert into t1 values (1),(2),(3),(4);
insert into t2 values (10),(20),(30),(40);
insert into t3 values (1),(2),(10),(50);
select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
-drop table t1,t2;
+drop table t1,t2,t3;
#
# correct ALL optimisation
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 3506c713907..8f49f56b991 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -236,3 +236,13 @@ insert into t2 (group_name) values ('Group B');
insert into t3 (user_id, group_id) values (1,1);
select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c;
drop table t1, t2, t3;
+
+#
+# fix_fields problem
+#
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
+drop table t1, t2;
diff --git a/sql/item.cc b/sql/item.cc
index 86fa2d82c41..1a071174210 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -99,7 +99,7 @@ bool Item_ident::remove_dependence_processor(byte * arg)
DBUG_ENTER("Item_ident::remove_dependence_processor");
if (depended_from == (st_select_lex *) arg)
depended_from= 0;
- DBUG_RETURN(1);
+ DBUG_RETURN(0);
}
diff --git a/sql/item.h b/sql/item.h
index 296ad18b1f1..4a1c6ac37b6 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -195,6 +195,7 @@ public:
}
virtual bool remove_dependence_processor(byte * arg) { return 0; }
+ virtual bool remove_fixed(byte * arg) { fixed= 0; return 0; }
// Row emulation
virtual uint cols() { return 1; }
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index d5c642fd337..194d75e3f30 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -206,7 +206,8 @@ public:
Item_in_subselect(THD *thd, Item * left_expr, st_select_lex *select_lex);
Item_in_subselect(Item_in_subselect *item);
- Item_in_subselect(): Item_exists_subselect(), abort_on_null(0) {}
+ Item_in_subselect()
+ :Item_exists_subselect(), abort_on_null(0), upper_not(0) {}
subs_type substype() { return IN_SUBS; }
void reset()
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 1d3e608c31c..b029bcf2b87 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -118,6 +118,20 @@ Item *Item_sum::get_tmp_table_item(THD *thd)
return sum_item;
}
+bool Item_sum::walk (Item_processor processor, byte *argument)
+{
+ if (arg_count)
+ {
+ Item **arg,**arg_end;
+ for (arg= args, arg_end= args+arg_count; arg != arg_end; arg++)
+ {
+ if ((*arg)->walk(processor, argument))
+ return 1;
+ }
+ }
+ return (this->*processor)(argument);
+}
+
String *
Item_sum_num::val_str(String *str)
{
diff --git a/sql/item_sum.h b/sql/item_sum.h
index ebb90c05215..651124e65f5 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -82,6 +82,8 @@ public:
virtual bool setup(THD *thd) {return 0;}
virtual void make_unique() {}
Item *get_tmp_table_item(THD *thd);
+
+ bool walk (Item_processor processor, byte *argument);
};
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index a5d9ce5bce3..a28d343ffd6 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -625,6 +625,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables,
List<Item> &item, bool set_query_id,
List<Item> *sum_func_list, bool allow_sum_func);
+void unfix_item_list(List<Item> item_list);
int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
int setup_ftfuncs(SELECT_LEX* select);
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index dc6e791c4be..2b23b622cc6 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2007,6 +2007,21 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
}
/*
+ Mark all items in list as not fixed (0 assigned to 'fixed' field)
+
+ SYNOPSYS
+ unfix_item_list()
+ item_list - list of items
+*/
+void unfix_item_list(List<Item> item_list)
+{
+ Item *item;
+ List_iterator_fast<Item> it(item_list);
+ while ((item= it++))
+ item->walk(&Item::remove_fixed, 0);
+}
+
+/*
Remap table numbers if INSERT ... SELECT
Check also that the 'used keys' and 'ignored keys' exists and set up the
table structure accordingly
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 771d68e8462..fcbb1bcfdeb 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -144,6 +144,9 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
res= -1;
goto exit;
}
+ // Item list should be fix_fielded yet another time in JOIN::prepare
+ unfix_item_list(item_list);
+
bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count= item_list.elements;
/*
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 5d815bb2ffa..e5fe5b13b02 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -156,6 +156,9 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
setup_fields(thd, select_cursor->ref_pointer_array, first_table,
item_list, 0, 0, 1))
goto err;
+ // Item list should be fix_fielded yet another time in JOIN::prepare
+ unfix_item_list(item_list);
+
t_and_f= 1;
while((item=it++))
{