1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

fixed using VIEW fields (BUG#4617)

mysql-test/r/view.result:
  using VIEW fields several times in query resolved via temporary tables
mysql-test/t/view.test:
  using VIEW fields several times in query resolved via temporary tables
sql/item.h:
  fixed using of result_field by Item_ref
sql/sql_base.cc:
  Create Item_ref as reference on VIEW fields expression reference
sql/sql_insert.cc:
  privent creating Item_ref in insert list (where Item_fields should be)
sql/sql_lex.cc:
  Item_ref creation control
sql/sql_lex.h:
  Item_ref creation control
sql/sql_update.cc:
  privent creating Item_ref in insert list (where Item_fields should be) and creation Item_fields for UPDATE list
sql/table.cc:
  Do not create Item_ref for internal view of view processing
This commit is contained in:
unknown
2004-07-23 09:20:58 +03:00
parent dc4de8d562
commit 1b98202be7
9 changed files with 100 additions and 16 deletions

View File

@ -1955,7 +1955,6 @@ Field *find_field_in_table(THD *thd, TABLE_LIST *table_list,
{
if (strcmp(trans[i]->name, name) == 0)
{
*ref= trans[i];
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (check_grants_view &&
check_grant_column(thd, &table_list->grant,
@ -1964,6 +1963,21 @@ Field *find_field_in_table(THD *thd, TABLE_LIST *table_list,
name, length))
return WRONG_GRANT;
#endif
if (thd->lex->current_select->no_wrap_view_item)
*ref= trans[i];
else
{
Item_arena *arena= thd->current_arena, backup;
if (arena)
thd->set_n_backup_item_arena(arena, &backup);
*ref= new Item_ref(trans + i, 0, table_list->view_name.str,
name);
if (arena)
thd->restore_backup_item_arena(arena, &backup);
/* as far as Item_ref have defined refernce it do not need tables */
if (*ref)
(*ref)->fix_fields(thd, 0, ref);
}
return (Field*) view_ref_found;
}
}
@ -2441,6 +2455,7 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
{
reg2 Item *item;
List_iterator<Item> it(fields);
SELECT_LEX *select_lex= thd->lex->current_select;
DBUG_ENTER("setup_fields");
thd->set_query_id=set_query_id;
@ -2452,7 +2467,10 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
{
if (!item->fixed && item->fix_fields(thd, tables, it.ref()) ||
(item= *(it.ref()))->check_cols(1))
{
select_lex->no_wrap_view_item= 0;
DBUG_RETURN(-1); /* purecov: inspected */
}
if (ref)
*(ref++)= item;
if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM &&