115 enum_parsing_place place= NO_MATTER;
117 Select_Lex *current_sel= session->lex().current_select;
119 if (!ref || ref == not_found_item)
124 if (ref == not_found_item)
134 my_error(ER_BAD_FIELD_ERROR,MYF(0), full_name(), session->where());
147 from_field= (
Field*) not_found_field;
151 Select_Lex *select= outer_context->
select_lex;
153 last_checked_context->
select_lex->master_unit()->item;
154 last_checked_context= outer_context;
161 if (ref != not_found_item)
163 assert(*ref && (*ref)->fixed);
164 prev_subselect_item->used_tables_cache|= (*ref)->used_tables();
165 prev_subselect_item->const_item_cache&= (*ref)->const_item();
176 place= prev_subselect_item->parsing_place;
189 if ((place != IN_HAVING ||
190 (!select->with_sum_func &&
191 select->group_list.elements == 0)))
198 from_field= find_field_in_tables(session,
this,
200 first_name_resolution_table,
202 last_name_resolution_table,
204 IGNORE_EXCEPT_NON_UNIQUE,
true);
207 if (from_field == view_ref_found)
209 Item::Type refer_type= (*reference)->type();
210 prev_subselect_item->used_tables_cache|=
211 (*reference)->used_tables();
212 prev_subselect_item->const_item_cache&=
213 (*reference)->const_item();
214 assert((*reference)->type() == REF_ITEM);
216 context->select_lex,
this,
217 ((refer_type == REF_ITEM ||
218 refer_type == FIELD_ITEM) ?
219 (Item_ident*) (*reference) :
227 if (from_field != not_found_field)
229 if (cached_table && cached_table->select_lex &&
231 cached_table->select_lex != outer_context->
select_lex)
243 last_checked_context->
select_lex->master_unit()->item;
244 last_checked_context= outer_context;
245 }
while (outer_context && outer_context->
select_lex &&
246 cached_table->select_lex != outer_context->
select_lex);
248 prev_subselect_item->used_tables_cache|= from_field->getTable()->
map;
249 prev_subselect_item->const_item_cache=
false;
253 assert(from_field == not_found_field);
256 prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT;
257 prev_subselect_item->const_item_cache=
false;
260 }
while (outer_context);
262 assert(from_field != 0 && from_field != view_ref_found);
263 if (from_field != not_found_field)
269 session->lex().current_select,
this, fld);
275 if (session->lex().in_sum_func &&
276 session->lex().in_sum_func->nest_level >=
278 set_if_bigger(session->lex().in_sum_func->max_arg_level,
279 last_checked_context->
select_lex->nest_level);
285 my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where());
289 assert(*ref && (*ref)->fixed);
291 context->select_lex,
this,
this);
297 if (session->lex().in_sum_func &&
298 session->lex().in_sum_func->nest_level >=
300 set_if_bigger(session->lex().in_sum_func->max_arg_level,
301 last_checked_context->
select_lex->nest_level);
312 if (!((*ref)->type() == REF_ITEM &&
313 ((Item_ref *)(*ref))->ref_type() == OUTER_REF) &&
314 (((*ref)->with_sum_func &&
name &&
315 !(current_sel->linkage != GLOBAL_OPTIONS_TYPE &&
316 current_sel->having_fix_field)) ||
319 my_error(ER_ILLEGAL_REFERENCE, MYF(0),
name, ((*ref)->with_sum_func ?
"reference to group function" :
"forward reference in item list"));
325 if ((*ref)->check_cols(1))