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

prevent substituting Item_ref as VIEW fields in WHERE conditions (BUG#5969)

prevent filling temporary tables of views on list fields command
This commit is contained in:
bell@sanja.is.com.ua
2004-10-10 11:01:05 +03:00
parent 183036ea9a
commit 41ddca4d68
3 changed files with 13 additions and 8 deletions

View File

@ -2973,6 +2973,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
SELECT_LEX *select_lex= thd->lex->current_select;
Item_arena *arena= thd->current_arena;
Item_arena backup;
bool save_wrapper= thd->lex->current_select->no_wrap_view_item;
DBUG_ENTER("setup_conds");
if (select_lex->conds_processed_with_permanent_arena ||
@ -2981,13 +2982,14 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
thd->set_query_id=1;
thd->lex->current_select->no_wrap_view_item= 1;
select_lex->cond_count= 0;
if (*conds)
{
thd->where="where clause";
if (!(*conds)->fixed && (*conds)->fix_fields(thd, tables, conds) ||
(*conds)->check_cols(1))
DBUG_RETURN(1);
goto err_no_arena;
}
/* Check if we are using outer joins */
@ -3005,7 +3007,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
if (!embedded->on_expr->fixed &&
embedded->on_expr->fix_fields(thd, tables, &embedded->on_expr) ||
embedded->on_expr->check_cols(1))
DBUG_RETURN(1);
goto err_no_arena;
select_lex->cond_count++;
}
if (embedded->natural_join)
@ -3059,7 +3061,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
Item_cond_and *cond_and=new Item_cond_and();
if (!cond_and) // If not out of memory
DBUG_RETURN(1);
goto err_no_arena;
cond_and->top_level_item();
if (table->field_translation)
@ -3123,7 +3125,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
if (*conds && !(*conds)->fixed)
{
if ((*conds)->fix_fields(thd, tables, conds))
DBUG_RETURN(1);
goto err_no_arena;
}
}
else
@ -3135,7 +3137,7 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
if (embedded->on_expr && !embedded->on_expr->fixed)
{
if (embedded->on_expr->fix_fields(thd, tables, &table->on_expr))
DBUG_RETURN(1);
goto err_no_arena;
}
}
}
@ -3157,11 +3159,14 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
select_lex->where= *conds;
select_lex->conds_processed_with_permanent_arena= 1;
}
thd->lex->current_select->no_wrap_view_item= save_wrapper;
DBUG_RETURN(test(thd->net.report_error));
err:
if (arena)
thd->restore_backup_item_arena(arena, &backup);
err_no_arena:
thd->lex->current_select->no_wrap_view_item= save_wrapper;
DBUG_RETURN(1);
}