summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-11-28 19:29:26 +0200
committerunknown <bell@sanja.is.com.ua>2002-11-28 19:29:26 +0200
commit6f80b711692d99d5d197cece8fe978eab6f1f3ec (patch)
tree00a9de3df37ec79df37b41b63cb2971efe86b0a1 /sql
parent5a1b9e1d05ec4c52e89df1adf40312a55f8b7d3f (diff)
downloadmariadb-git-6f80b711692d99d5d197cece8fe978eab6f1f3ec.tar.gz
fixed * without tables in IN bug
fixed sunction-test select in IN bug fixed unions in subselect bug include/mysqld_error.h: new warning mysql-test/r/subselect.result: test of * without tables in IN test of sunction-test select in IN test of unions in subselect mysql-test/t/subselect.test: test of * without tables in IN test of sunction-test select in IN test of unions in subselect sql/item.cc: fixed * substitution without tables sql/item_subselect.cc: fixed subselect rewriting with function-test subselect sql/item_subselect.h: mechanism for subselect removing sql/share/czech/errmsg.txt: new warning sql/share/danish/errmsg.txt: new warning sql/share/dutch/errmsg.txt: new warning sql/share/english/errmsg.txt: new warning sql/share/estonian/errmsg.txt: new warning sql/share/french/errmsg.txt: new warning sql/share/german/errmsg.txt: new warning sql/share/greek/errmsg.txt: new warning sql/share/hungarian/errmsg.txt: new warning sql/share/italian/errmsg.txt: new warning sql/share/japanese/errmsg.txt: new warning sql/share/korean/errmsg.txt: new warning sql/share/norwegian-ny/errmsg.txt: new warning sql/share/norwegian/errmsg.txt: new warning sql/share/polish/errmsg.txt: new warning sql/share/portuguese/errmsg.txt: new warning sql/share/romanian/errmsg.txt: new warning sql/share/russian/errmsg.txt: new warning sql/share/serbian/errmsg.txt: new warning sql/share/slovak/errmsg.txt: new warning sql/share/spanish/errmsg.txt: new warning sql/share/swedish/errmsg.txt: new warning sql/share/ukrainian/errmsg.txt: new warning sql/sql_base.cc: fixed case on no name field in UNION subselect sql/sql_lex.cc: mechanisp of removing single subselect for optimisation purposes sql/sql_lex.h: mechanisp of removing single subselect for optimisation purposes sql/sql_parse.cc: error handling sql/sql_union.cc: fixed unions in subselect sql/sql_yacc.yy: fixed Lex->describe flag appearence
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc50
-rw-r--r--sql/item_subselect.cc66
-rw-r--r--sql/item_subselect.h6
-rw-r--r--sql/share/czech/errmsg.txt1
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt1
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/serbian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt1
-rw-r--r--sql/share/ukrainian/errmsg.txt1
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_lex.cc25
-rw-r--r--sql/sql_lex.h3
-rw-r--r--sql/sql_parse.cc12
-rw-r--r--sql/sql_union.cc4
-rw-r--r--sql/sql_yacc.yy3
32 files changed, 156 insertions, 38 deletions
diff --git a/sql/item.cc b/sql/item.cc
index ece627f9fe3..a81b4f2394b 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -463,41 +463,41 @@ bool Item_asterisk_remover::fix_fields(THD *thd,
((Item_field*) item)->field_name[0] == '*')
{
Item_field *fitem= (Item_field*) item;
- if (!list->next || fitem->db_name || fitem->table_name)
- {
- TABLE_LIST *table= find_table_in_list(list,
- fitem->db_name,
- fitem->table_name);
- if (table)
+ if (list)
+ if (!list->next || fitem->db_name || fitem->table_name)
{
- TABLE * tb= table->table;
- if (find_table_in_list(table->next, fitem->db_name,
- fitem->table_name) != 0 ||
- tb->fields == 1)
+ TABLE_LIST *table= find_table_in_list(list,
+ fitem->db_name,
+ fitem->table_name);
+ if (table)
{
- if ((item= new Item_field(tb->field[0])))
+ TABLE * tb= table->table;
+ if (find_table_in_list(table->next, fitem->db_name,
+ fitem->table_name) != 0 ||
+ tb->fields == 1)
{
- res= 0;
- tb->field[0]->query_id= thd->query_id;
- tb->used_keys&= tb->field[0]->part_of_key;
- tb->used_fields= tb->fields;
+ if ((item= new Item_field(tb->field[0])))
+ {
+ res= 0;
+ tb->field[0]->query_id= thd->query_id;
+ tb->used_keys&= tb->field[0]->part_of_key;
+ tb->used_fields= tb->fields;
+ }
+ else
+ thd->fatal_error= 1; // can't create Item => out of memory
}
else
- thd->fatal_error= 1; // can't create Item => out of memory
+ my_message(ER_SUBSELECT_NO_1_COL, ER(ER_SUBSELECT_NO_1_COL),
+ MYF(0));
}
else
- my_message(ER_SUBSELECT_NO_1_COL, ER(ER_SUBSELECT_NO_1_COL),
- MYF(0));
+ my_error(ER_BAD_TABLE_ERROR, MYF(0), fitem->table_name);
}
else
- if (!fitem->table_name)
- my_error(ER_NO_TABLES_USED, MYF(0));
- else
- my_error(ER_BAD_TABLE_ERROR, MYF(0), fitem->table_name);
- }
+ my_message(ER_SUBSELECT_NO_1_COL, ER(ER_SUBSELECT_NO_1_COL),
+ MYF(0));
else
- my_message(ER_SUBSELECT_NO_1_COL, ER(ER_SUBSELECT_NO_1_COL),
- MYF(0));
+ my_error(ER_NO_TABLES_USED, MYF(0));
}
else
res= item->fix_fields(thd, list, &item);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 555b7ae45c3..e0bfbe01c9b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -33,7 +33,7 @@ SUBSELECT TODO:
#include "sql_select.h"
Item_subselect::Item_subselect():
- Item_result_field(), engine_owner(1), value_assigned(0)
+ Item_result_field(), engine_owner(1), value_assigned(0), substitution(0)
{
assign_null();
/*
@@ -89,6 +89,13 @@ void Item_subselect::make_field (Send_field *tmp_field)
bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{
+ if (substitution)
+ {
+ (*ref)= substitution;
+ engine->exclude();
+ return substitution->fix_fields(thd, tables, ref);
+ }
+
char const *save_where= thd->where;
int res= engine->prepare();
if (!res)
@@ -291,12 +298,12 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex,
else
item= (Item*) sl->item_list.pop();
- left_expr= new Item_outer_select_context_saver(left_expr);
+ Item *expr= new Item_outer_select_context_saver(left_expr);
if (sl->having || sl->with_sum_func || sl->group_list.first)
{
sl->item_list.push_back(item);
- item= (*func)(left_expr, new Item_ref(sl->item_list.head_ref(),
+ item= (*func)(expr, new Item_ref(sl->item_list.head_ref(),
0, "<result>"));
if (sl->having)
sl->having= new Item_cond_and(sl->having, item);
@@ -307,11 +314,42 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex,
{
sl->item_list.empty();
sl->item_list.push_back(new Item_int(1));
- item= (*func)(left_expr, new Item_asterisk_remover(item));
- if (sl->where)
- sl->where= new Item_cond_and(sl->where, item);
+ if (sl->table_list.elements)
+ {
+ item= (*func)(expr, new Item_asterisk_remover(item));
+ if (sl->where)
+ sl->where= new Item_cond_and(sl->where, item);
+ else
+ sl->where= item;
+ }
else
- sl->where= item;
+ {
+ if (item->type() == Item::FIELD_ITEM &&
+ ((Item_field*) item)->field_name[0] == '*')
+ {
+ my_error(ER_NO_TABLES_USED, MYF(0));
+ DBUG_VOID_RETURN;
+ }
+ if (select_lex->next_select())
+ {
+ // it is in union => we should perform it
+ sl->having= (*func)(expr, item);
+ }
+ else
+ {
+ // it is single select without tables => possible optimization
+ item= (*func)(left_expr, item);
+ substitution= item;
+ THD *thd= current_thd;
+ if (thd->lex.describe)
+ {
+ char warn_buff[MYSQL_ERRMSG_SIZE];
+ sprintf(warn_buff, ER(ER_SELECT_REDUCED), sl->select_number);
+ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_SELECT_REDUCED, warn_buff);
+ }
+ }
+ }
}
}
DBUG_VOID_RETURN;
@@ -502,3 +540,17 @@ bool subselect_union_engine::check_loop(uint id)
DBUG_RETURN(1);
DBUG_RETURN(0);
}
+
+void subselect_single_select_engine::exclude()
+{
+ select_lex->master_unit()->exclude_level();
+ //if (current_thd->lex->describe)
+}
+
+void subselect_union_engine::exclude()
+{
+ unit->exclude_level();
+ // for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
+ // if (sl->join && sl->join->check_loop(id))
+ // DBUG_RETURN(1);
+}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 3a635ace8ba..d323dab51f1 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -36,6 +36,8 @@ class Item_subselect :public Item_result_field
my_bool engine_owner; /* Is this item owner of engine */
my_bool value_assigned; /* value already assigned to subselect */
protected:
+ /* substitution instead of subselect in case of optimization */
+ Item *substitution;
/* engine that perform execution of subselect (single select or union) */
subselect_engine *engine;
/* allowed number of columns (1 for single value subqueries) */
@@ -45,6 +47,7 @@ public:
Item_subselect();
Item_subselect(Item_subselect *item)
{
+ substitution= item->substitution;
null_value= item->null_value;
decimals= item->decimals;
max_columns= item->max_columns;
@@ -213,6 +216,7 @@ public:
virtual bool depended()= 0; /* depended from outer select */
enum Item_result type() { return res_type; }
virtual bool check_loop(uint id)= 0;
+ virtual void exclude()= 0;
};
class subselect_single_select_engine: public subselect_engine
@@ -232,6 +236,7 @@ public:
uint cols();
bool depended();
bool check_loop(uint id);
+ void exclude();
};
class subselect_union_engine: public subselect_engine
@@ -248,4 +253,5 @@ public:
uint cols();
bool depended();
bool check_loop(uint id);
+ void exclude();
};
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 4838de12ed6..ff73914199f 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -256,3 +256,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index 91fa06f184f..f0c78032814 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -250,3 +250,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index 50c70ce0d2c..cf8d7ecc6b3 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -258,3 +258,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 1c5564b9ad5..963ba7a29bf 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -247,3 +247,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 8a49cc7fb69..759f569e396 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -252,3 +252,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index a8b602ee295..de2d7ee6854 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -247,3 +247,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index cb449738d61..166d604e013 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -250,3 +250,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index f6c650468b1..9533c25a30d 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -247,3 +247,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index fe47d79a101..07597be6214 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -249,3 +249,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index 0d951857392..772f7ba9532 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -247,3 +247,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index df78901a6e9..42b77e56f6b 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -249,3 +249,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index c20110e1aa5..b6a8a403213 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -247,3 +247,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index c75c3ed6140..54cb3bb77e3 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -249,3 +249,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index b5a660773ab..9a6a5f5e427 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -249,3 +249,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index c65a16bf1e4..6488ca27782 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -251,3 +251,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 355ae90c157..1e50e8bff5e 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -247,3 +247,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index c7a5b41deac..d999661a40b 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -251,3 +251,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s"
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index 35134e6d9d5..fb4278c2ae9 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -250,3 +250,4 @@
"Циклическая ссылка на подзапрос",
"Преобразование поля '%s' из %s в %s",
"Ссылка '%-.64s' не поддерживается (%s)",
+"Select %u был упразднен в процессе оптимизации",
diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt
index 354c0bdfac4..526f5834094 100644
--- a/sql/share/serbian/errmsg.txt
+++ b/sql/share/serbian/errmsg.txt
@@ -243,3 +243,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index 4f49aeb2f6e..db06c0f4881 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -255,3 +255,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index 1bd4aed6897..40d36a571f2 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -248,3 +248,4 @@
"Cyclic reference on subqueries",
"Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index af3f7ca33dd..817d8acbfef 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -247,3 +247,4 @@
"Syklisk referens i subselect",
"Konvertar kolumn '%s' frЕn %s till %s",
"Reference '%-.64s' not supported (%s)",
+"Select %u was reduced during optimisation",
diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt
index c5bfff130fd..a95043f9fcd 100644
--- a/sql/share/ukrainian/errmsg.txt
+++ b/sql/share/ukrainian/errmsg.txt
@@ -252,3 +252,4 @@
"Циклiчне посилання на пiдзапит",
"Перетворення стовбца '%s' з %s у %s",
"Посилання '%-.64s' не пiдтримуется (%s)",
+"Select %u was скасовано при оптимiзацii",
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 8aa33a65ce3..b052fb066e0 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2082,7 +2082,7 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
while ((item=it++))
{
- if (item->type() == Item::FIELD_ITEM &&
+ if (item->type() == Item::FIELD_ITEM && ((Item_field*) item)->field_name &&
((Item_field*) item)->field_name[0] == '*')
{
uint elem= fields.elements;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 5104487c700..041e9c1d892 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1058,6 +1058,31 @@ void st_select_lex_node::exclude()
*/
}
+void st_select_lex_unit::exclude_level()
+{
+ SELECT_LEX_UNIT *units= 0, **units_last= &units;
+ for(SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
+ {
+ if (sl->link_prev && (*sl->link_prev= sl->link_next))
+ sl->link_next->link_prev= sl->link_prev;
+ SELECT_LEX_UNIT **last= 0;
+ for (SELECT_LEX_UNIT *u= sl->first_inner_unit(); u; u= u->next_unit())
+ last= (SELECT_LEX_UNIT**)&(u->next);
+ if (last)
+ {
+ (*units_last)= sl->first_inner_unit();
+ units_last= last;
+ }
+ }
+ if (units)
+ {
+ (*prev)= units;
+ (*units_last)= (SELECT_LEX_UNIT*)next;
+ }
+ else
+ (*prev)= next;
+}
+
st_select_lex* st_select_lex_node::select_lex()
{
DBUG_ENTER("st_select_lex_node::select_lex (never should be called)");
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index b9691bb1059..4c5ca88b7b0 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -242,6 +242,8 @@ public:
List<String> *ignore_index= 0);
virtual void set_lock_for_tables(thr_lock_type lock_type) {}
void mark_as_dependent(st_select_lex *last);
+
+ friend class st_select_lex_unit;
private:
void fast_exclude();
};
@@ -288,6 +290,7 @@ public:
st_select_lex* outer_select();
st_select_lex* first_select() { return (st_select_lex*) slave; }
st_select_lex_unit* next_unit() { return (st_select_lex_unit*) next; }
+ void st_select_lex_unit::exclude_level();
/* UNION methods */
int prepare(THD *thd, select_result *result);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a410a9f2d7e..26817bc30ac 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1329,7 +1329,6 @@ mysql_execute_command(THD *thd)
*/
thd->old_total_warn_count= thd->total_warn_count;
- thd->net.report_error= 0;
if (thd->slave_thread)
{
/*
@@ -2957,6 +2956,8 @@ mysql_parse(THD *thd, char *inBuf, uint length)
mysql_init_query(thd);
thd->query_length = length;
+ thd->net.report_error= 0;
+
if (query_cache_send_result_to_client(thd, inBuf, length) <= 0)
{
LEX *lex=lex_start(thd, (uchar*) inBuf, length);
@@ -2969,8 +2970,13 @@ mysql_parse(THD *thd, char *inBuf, uint length)
}
else
{
- mysql_execute_command(thd);
- query_cache_end_of_result(&thd->net);
+ if (thd->net.report_error)
+ send_error(thd, 0, NullS);
+ else
+ {
+ mysql_execute_command(thd);
+ query_cache_end_of_result(&thd->net);
+ }
}
}
else
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 0e6de306c0d..d448a5204e2 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -214,7 +214,11 @@ int st_select_lex_unit::exec()
if (dependent || !item || !item->assigned())
{
if (optimized && item && item->assigned())
+ {
item->assigned(0); // We will reinit & rexecute unit
+ item->assign_null();
+ table->file->delete_all_rows();
+ }
for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
{
thd->lex.current_select= sl;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index cb1c7fed838..c4b3c31d91b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3323,11 +3323,10 @@ describe:
YYABORT;
}
opt_describe_column
- | describe_command select
+ | describe_command { Lex->describe=1; } select
{
LEX *lex=Lex;
lex->select_lex.options|= SELECT_DESCRIBE;
- lex->describe=1;
};