As far as now transformer called after setup_wild() it is impossible to have '*'
This commit is contained in:
parent
758129279f
commit
55094f903f
53
sql/item.cc
53
sql/item.cc
@ -722,59 +722,6 @@ bool Item::fix_fields(THD *thd,
|
||||
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,
|
||||
struct st_table_list *tables,
|
||||
Item ** reference)
|
||||
|
36
sql/item.h
36
sql/item.h
@ -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.
|
||||
@ -654,32 +664,6 @@ public:
|
||||
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
|
||||
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,
|
||||
if (select_lex->table_list.elements)
|
||||
{
|
||||
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);
|
||||
if (!abort_on_null)
|
||||
{
|
||||
@ -603,22 +582,12 @@ Item_in_subselect::single_value_transformer(JOIN *join,
|
||||
}
|
||||
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())
|
||||
{
|
||||
/*
|
||||
It is in union => we should perform it.
|
||||
Item_asterisk_remover used only as wrapper to receine NULL value
|
||||
*/
|
||||
join->having= (*func)(expr,
|
||||
new Item_asterisk_remover(this, item,
|
||||
(char *)"<no matter>",
|
||||
(char *)"<result>"));
|
||||
new Item_null_helper(this, item,
|
||||
(char *)"<no matter>",
|
||||
(char *)"<result>"));
|
||||
select_lex->having_fix_field= 1;
|
||||
if (join->having->fix_fields(thd, join->tables_list, &join->having))
|
||||
{
|
||||
|
@ -225,7 +225,6 @@ public:
|
||||
void top_level_item() { abort_on_null=1; }
|
||||
bool test_limit(st_select_lex_unit *unit);
|
||||
|
||||
friend class Item_asterisk_remover;
|
||||
friend class Item_ref_null_helper;
|
||||
friend class Item_is_not_null_test;
|
||||
friend class subselect_indexin_engine;
|
||||
|
Loading…
x
Reference in New Issue
Block a user