| 3061 | */ |
| 3062 | |
| 3063 | void reinit_stmt_before_use(THD *thd, LEX *lex) |
| 3064 | { |
| 3065 | SELECT_LEX *sl= lex->all_selects_list; |
| 3066 | DBUG_ENTER("reinit_stmt_before_use"); |
| 3067 | Window_spec *win_spec; |
| 3068 | |
| 3069 | /* |
| 3070 | We have to update "thd" pointer in LEX, all its units and in LEX::result, |
| 3071 | since statements which belong to trigger body are associated with TABLE |
| 3072 | object and because of this can be used in different threads. |
| 3073 | */ |
| 3074 | lex->thd= thd; |
| 3075 | DBUG_ASSERT(!lex->explain); |
| 3076 | |
| 3077 | if (lex->empty_field_list_on_rset) |
| 3078 | { |
| 3079 | lex->empty_field_list_on_rset= 0; |
| 3080 | lex->field_list.empty(); |
| 3081 | } |
| 3082 | for (; sl; sl= sl->next_select_in_list()) |
| 3083 | { |
| 3084 | if (sl->changed_elements & TOUCHED_SEL_COND) |
| 3085 | { |
| 3086 | /* remove option which was put by mysql_explain_union() */ |
| 3087 | sl->options&= ~SELECT_DESCRIBE; |
| 3088 | |
| 3089 | /* see unique_table() */ |
| 3090 | sl->exclude_from_table_unique_test= FALSE; |
| 3091 | |
| 3092 | /* |
| 3093 | Copy WHERE, HAVING clause pointers to avoid damaging them |
| 3094 | by optimisation |
| 3095 | */ |
| 3096 | if (sl->prep_where) |
| 3097 | { |
| 3098 | /* |
| 3099 | We need this rollback because memory allocated in |
| 3100 | copy_andor_structure() will be freed |
| 3101 | */ |
| 3102 | thd->change_item_tree((Item**)&sl->where, |
| 3103 | sl->prep_where->copy_andor_structure(thd)); |
| 3104 | sl->where->cleanup(); |
| 3105 | } |
| 3106 | else |
| 3107 | sl->where= NULL; |
| 3108 | if (sl->prep_having) |
| 3109 | { |
| 3110 | /* |
| 3111 | We need this rollback because memory allocated in |
| 3112 | copy_andor_structure() will be freed |
| 3113 | */ |
| 3114 | thd->change_item_tree((Item**)&sl->having, |
| 3115 | sl->prep_having->copy_andor_structure(thd)); |
| 3116 | sl->having->cleanup(); |
| 3117 | } |
| 3118 | else |
| 3119 | sl->having= NULL; |
| 3120 | DBUG_ASSERT(sl->join == 0); |
no test coverage detected