diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ebb9c8098cf..303d9f3d655 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1533,7 +1533,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, { uint idx; double scan_time; - DBUG_ENTER("test_quick_select"); + DBUG_ENTER("SQL_SELECT::test_quick_select"); //printf("\nQUERY: %s\n", thd->query); DBUG_PRINT("enter",("keys_to_use: %lu prev_tables: %lu const_tables: %lu", keys_to_use.to_ulonglong(), (ulong) prev_tables, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7a908120774..8199c6fcdce 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 53b5e8f3a00..15022bdb8df 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1573,8 +1573,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (grant_option && check_grant(thd, SELECT_ACL, &table_list, 2, UINT_MAX, 0)) break; - /* switch on VIEW optimisation: do not fill temporary tables */ - thd->lex->sql_command= SQLCOM_SHOW_FIELDS; /* init structures for VIEW processing */ table_list.select_lex= &(thd->lex->select_lex); mysql_init_query(thd, (uchar*)"", 0); @@ -1582,6 +1580,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, select_lex.table_list.link_in_list((byte*) &table_list, (byte**) &table_list.next_local); + /* switch on VIEW optimisation: do not fill temporary tables */ + thd->lex->sql_command= SQLCOM_SHOW_FIELDS; mysqld_list_fields(thd,&table_list,fields); thd->lex->unit.cleanup(); thd->cleanup_after_query();