As far as now transformer called after setup_wild() it is impossible to have '*'

parent 75812927
...@@ -722,59 +722,6 @@ bool Item::fix_fields(THD *thd, ...@@ -722,59 +722,6 @@ bool Item::fix_fields(THD *thd,
return 0; return 0;
} }
bool Item_asterisk_remover::fix_fields(THD *thd,
struct st_table_list *list,
Item ** ref)
{
DBUG_ENTER("Item_asterisk_remover::fix_fields");
bool res= 1;
if (item)
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field_name[0] == '*')
{
Item_field *fitem= (Item_field*) item;
if (list)
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)
{
TABLE * tb= table->table;
if (find_table_in_list(table->next, fitem->db_name,
fitem->table_name) != 0 ||
tb->fields == 1)
{
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(); // can't create Item => out of memory
}
else
my_error(ER_CARDINALITY_COL, MYF(0), 1);
}
else
my_error(ER_BAD_TABLE_ERROR, MYF(0), fitem->table_name);
}
else
my_error(ER_CARDINALITY_COL, MYF(0), 1);
else
my_error(ER_NO_TABLES_USED, MYF(0));
}
else
res= item->fix_fields(thd, list, &item);
else
thd->fatal_error(); // no item given => out of memory
DBUG_RETURN(res);
}
bool Item_ref_on_list_position::fix_fields(THD *thd, bool Item_ref_on_list_position::fix_fields(THD *thd,
struct st_table_list *tables, struct st_table_list *tables,
Item ** reference) Item ** reference)
......
...@@ -626,6 +626,16 @@ public: ...@@ -626,6 +626,16 @@ public:
} }
}; };
class Item_null_helper :public Item_ref_null_helper
{
Item *store;
public:
Item_null_helper(Item_in_subselect* master, Item *item,
const char *table_name_par, const char *field_name_par)
:Item_ref_null_helper(master, &store, table_name_par, field_name_par),
store(item)
{}
};
/* /*
Used to find item in list of select items after '*' items processing. Used to find item in list of select items after '*' items processing.
...@@ -654,32 +664,6 @@ public: ...@@ -654,32 +664,6 @@ public:
bool fix_fields(THD *, struct st_table_list *, Item ** ref); bool fix_fields(THD *, struct st_table_list *, Item ** ref);
}; };
/*
To resolve '*' field moved to condition
and register NULL values
*/
class Item_asterisk_remover :public Item_ref_null_helper
{
Item *item;
public:
Item_asterisk_remover(Item_in_subselect *master, Item *it,
char *table, char *field):
Item_ref_null_helper(master, &item, table, field),
item(it)
{}
bool fix_fields(THD *, struct st_table_list *, Item ** ref);
Item **storage() {return &item;}
void print(String *str)
{
str->append("ref_null_helper('");
if (item)
item->print(str);
else
str->append('?');
str->append(')');
}
};
/* /*
The following class is used to optimize comparing of date columns The following class is used to optimize comparing of date columns
We need to save the original item, to be able to set the field to the We need to save the original item, to be able to set the field to the
......
...@@ -559,27 +559,6 @@ Item_in_subselect::single_value_transformer(JOIN *join, ...@@ -559,27 +559,6 @@ Item_in_subselect::single_value_transformer(JOIN *join,
if (select_lex->table_list.elements) if (select_lex->table_list.elements)
{ {
Item *having= item, *isnull= item; Item *having= item, *isnull= item;
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field_name[0] == '*')
{
Item_asterisk_remover *remover;
item= remover= new Item_asterisk_remover(this, item,
(char *)"<no matter>",
(char *)"<result>");
if (!abort_on_null)
{
having=
new Item_is_not_null_test(this,
new Item_ref(remover->storage(),
(char *)"<no matter>",
(char *)"<null test>"));
isnull=
new Item_is_not_null_test(this,
new Item_ref(remover->storage(),
(char *)"<no matter>",
(char *)"<null test>"));
}
}
item= (*func)(expr, item); item= (*func)(expr, item);
if (!abort_on_null) if (!abort_on_null)
{ {
...@@ -603,20 +582,10 @@ Item_in_subselect::single_value_transformer(JOIN *join, ...@@ -603,20 +582,10 @@ Item_in_subselect::single_value_transformer(JOIN *join,
} }
else else
{ {
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field_name[0] == '*')
{
my_error(ER_NO_TABLES_USED, MYF(0));
DBUG_RETURN(ERROR);
}
if (select_lex->master_unit()->first_select()->next_select()) if (select_lex->master_unit()->first_select()->next_select())
{ {
/*
It is in union => we should perform it.
Item_asterisk_remover used only as wrapper to receine NULL value
*/
join->having= (*func)(expr, join->having= (*func)(expr,
new Item_asterisk_remover(this, item, new Item_null_helper(this, item,
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<result>")); (char *)"<result>"));
select_lex->having_fix_field= 1; select_lex->having_fix_field= 1;
......
...@@ -225,7 +225,6 @@ public: ...@@ -225,7 +225,6 @@ public:
void top_level_item() { abort_on_null=1; } void top_level_item() { abort_on_null=1; }
bool test_limit(st_select_lex_unit *unit); bool test_limit(st_select_lex_unit *unit);
friend class Item_asterisk_remover;
friend class Item_ref_null_helper; friend class Item_ref_null_helper;
friend class Item_is_not_null_test; friend class Item_is_not_null_test;
friend class subselect_indexin_engine; friend class subselect_indexin_engine;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment