#include "mysql_priv.h"#include <m_ctype.h>#include "my_dir.h"#include "sp_rcontext.h"#include "sp_head.h"#include "sql_trigger.h"#include "sql_select.h"Include dependency graph for item.cc:

Go to the source code of this file.
Functions | |
| static void | mark_as_dependent (THD *thd, SELECT_LEX *last, SELECT_LEX *current, Item_ident *item) |
| void | item_init (void) |
| static void | my_coll_agg_error (DTCollation &c1, DTCollation &c2, const char *fname) |
| static void | my_coll_agg_error (DTCollation &c1, DTCollation &c2, DTCollation &c3, const char *fname) |
| static void | my_coll_agg_error (Item **args, uint count, const char *fname, int item_sep) |
| bool | agg_item_collations (DTCollation &c, const char *fname, Item **av, uint count, uint flags, int item_sep) |
| bool | agg_item_collations_for_comparison (DTCollation &c, const char *fname, Item **av, uint count, uint flags) |
| bool | agg_item_charsets (DTCollation &coll, const char *fname, Item **args, uint nargs, uint flags, int item_sep) |
| bool | check_if_only_end_space (CHARSET_INFO *cs, char *str, char *end) |
| static void | default_set_param_func (Item_param *param, uchar **pos __attribute__((unused)), ulong len __attribute__((unused))) |
| static void | mark_as_dependent (THD *thd, SELECT_LEX *last, SELECT_LEX *current, Item_ident *resolved_item, Item_ident *mark_item) |
| void | mark_select_range_as_dependent (THD *thd, SELECT_LEX *last_select, SELECT_LEX *current_sel, Field *found_field, Item *found_item, Item_ident *resolved_item) |
| static Item ** | find_field_in_group_list (Item *find_item, ORDER *group_list) |
| static Item ** | resolve_ref_in_select_and_group (THD *thd, Item_ident *ref, SELECT_LEX *select) |
| static uint | nr_of_decimals (const char *str, const char *end) |
| uint | char_val (char X) |
| Item_result | item_cmp_type (Item_result a, Item_result b) |
| void | resolve_const_item (THD *thd, Item **ref, Item *comp_item) |
| bool | field_is_equal_to_item (Field *field, Item *item) |
| void | dummy_error_processor (THD *thd, void *data) |
| void | view_error_processor (THD *thd, void *data) |
Variables | |
| const String | my_null_string ("NULL", 4, default_charset_info) |
| static const Hybrid_type_traits | real_traits_instance |
| static const Hybrid_type_traits_decimal | decimal_traits_instance |
| static const Hybrid_type_traits_integer | integer_traits_instance |
| bool agg_item_charsets | ( | DTCollation & | coll, | |
| const char * | fname, | |||
| Item ** | args, | |||
| uint | nargs, | |||
| uint | flags, | |||
| int | item_sep | |||
| ) |
Definition at line 1427 of file item.cc.
References agg_item_collations(), args, backup, DTCollation::collation, current_thd, FALSE, Item::FIELD_ITEM, Item_field::fix_fields(), LINT_INIT, my_coll_agg_error(), String::needs_conversion(), NULL, and TRUE.
Referenced by Item_func::agg_arg_charsets(), and Item_func_group_concat::fix_fields().
01429 { 01430 Item **arg, **last, *safe_args[2]; 01431 01432 LINT_INIT(safe_args[0]); 01433 LINT_INIT(safe_args[1]); 01434 01435 if (agg_item_collations(coll, fname, args, nargs, flags, item_sep)) 01436 return TRUE; 01437 01438 /* 01439 For better error reporting: save the first and the second argument. 01440 We need this only if the the number of args is 3 or 2: 01441 - for a longer argument list, "Illegal mix of collations" 01442 doesn't display each argument's characteristics. 01443 - if nargs is 1, then this error cannot happen. 01444 */ 01445 if (nargs >=2 && nargs <= 3) 01446 { 01447 safe_args[0]= args[0]; 01448 safe_args[1]= args[item_sep]; 01449 } 01450 01451 THD *thd= current_thd; 01452 Query_arena *arena, backup; 01453 bool res= FALSE; 01454 uint i; 01455 /* 01456 In case we're in statement prepare, create conversion item 01457 in its memory: it will be reused on each execute. 01458 */ 01459 arena= thd->is_stmt_prepare() ? thd->activate_stmt_arena_if_needed(&backup) 01460 : NULL; 01461 01462 for (i= 0, arg= args; i < nargs; i++, arg+= item_sep) 01463 { 01464 Item* conv; 01465 uint32 dummy_offset; 01466 if (!String::needs_conversion(0, coll.collation, 01467 (*arg)->collation.collation, 01468 &dummy_offset)) 01469 continue; 01470 01471 if (!(conv= (*arg)->safe_charset_converter(coll.collation))) 01472 { 01473 if (nargs >=2 && nargs <= 3) 01474 { 01475 /* restore the original arguments for better error message */ 01476 args[0]= safe_args[0]; 01477 args[item_sep]= safe_args[1]; 01478 } 01479 my_coll_agg_error(args, nargs, fname, item_sep); 01480 res= TRUE; 01481 break; // we cannot return here, we need to restore "arena". 01482 } 01483 if ((*arg)->type() == Item::FIELD_ITEM) 01484 ((Item_field *)(*arg))->no_const_subst= 1; 01485 /* 01486 If in statement prepare, then we create a converter for two 01487 constant items, do it once and then reuse it. 01488 If we're in execution of a prepared statement, arena is NULL, 01489 and the conv was created in runtime memory. This can be 01490 the case only if the argument is a parameter marker ('?'), 01491 because for all true constants the charset converter has already 01492 been created in prepare. In this case register the change for 01493 rollback. 01494 */ 01495 if (arena) 01496 *arg= conv; 01497 else 01498 thd->change_item_tree(arg, conv); 01499 /* 01500 We do not check conv->fixed, because Item_func_conv_charset which can 01501 be return by safe_charset_converter can't be fixed at creation 01502 */ 01503 conv->fix_fields(thd, arg); 01504 } 01505 if (arena) 01506 thd->restore_active_arena(arena, &backup); 01507 return res; 01508 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool agg_item_collations | ( | DTCollation & | c, | |
| const char * | fname, | |||
| Item ** | av, | |||
| uint | count, | |||
| uint | flags, | |||
| int | item_sep | |||
| ) |
Definition at line 1365 of file item.cc.
References DTCollation::aggregate(), DTCollation::derivation, DERIVATION_NONE, FALSE, my_coll_agg_error(), MY_COLL_DISALLOW_NONE, DTCollation::set(), and TRUE.
Referenced by Item_func::agg_arg_collations(), agg_item_charsets(), and agg_item_collations_for_comparison().
01367 { 01368 uint i; 01369 Item **arg; 01370 c.set(av[0]->collation); 01371 for (i= 1, arg= &av[item_sep]; i < count; i++, arg++) 01372 { 01373 if (c.aggregate((*arg)->collation, flags)) 01374 { 01375 my_coll_agg_error(av, count, fname, item_sep); 01376 return TRUE; 01377 } 01378 } 01379 if ((flags & MY_COLL_DISALLOW_NONE) && 01380 c.derivation == DERIVATION_NONE) 01381 { 01382 my_coll_agg_error(av, count, fname, item_sep); 01383 return TRUE; 01384 } 01385 return FALSE; 01386 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool agg_item_collations_for_comparison | ( | DTCollation & | c, | |
| const char * | fname, | |||
| Item ** | av, | |||
| uint | count, | |||
| uint | flags | |||
| ) |
Definition at line 1389 of file item.cc.
References agg_item_collations(), and MY_COLL_DISALLOW_NONE.
Referenced by Item_func::agg_arg_collations_for_comparison().
01391 { 01392 return (agg_item_collations(c, fname, av, count, 01393 flags | MY_COLL_DISALLOW_NONE, 1)); 01394 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint char_val | ( | char | X | ) | [inline] |
| bool check_if_only_end_space | ( | CHARSET_INFO * | cs, | |
| char * | str, | |||
| char * | end | |||
| ) | [inline] |
Definition at line 2096 of file item.cc.
References charset_info_st::cset, MY_SEQ_SPACES, and my_charset_handler_st::scan.
Referenced by Item_string::val_int(), and Item_string::val_real().
02097 { 02098 return str+ cs->cset->scan(cs, str, end, MY_SEQ_SPACES) == end; 02099 }
Here is the caller graph for this function:

| static void default_set_param_func | ( | Item_param * | param, | |
| uchar **pos | __attribute__((unused)), | |||
| ulong len | __attribute__((unused)) | |||
| ) | [static] |
Definition at line 2207 of file item.cc.
References Item_param::set_null().
02210 { 02211 param->set_null(); 02212 }
Here is the call graph for this function:

| void dummy_error_processor | ( | THD * | thd, | |
| void * | data | |||
| ) |
Definition at line 6395 of file item.cc.
Referenced by Name_resolution_context::init().
Here is the caller graph for this function:

Definition at line 5707 of file item.cc.
References DECIMAL_RESULT, INT_RESULT, item_cmp_type(), MAX_FIELD_WIDTH, my_charset_bin, my_decimal_cmp(), Item::null_value, Field::result_type(), Item::result_type(), STRING_RESULT, stringcmp(), Item::val_decimal(), Field::val_decimal(), Item::val_real(), Field::val_real(), Item::val_str(), and Field::val_str().
Referenced by get_mm_leaf().
05708 { 05709 05710 Item_result res_type=item_cmp_type(field->result_type(), 05711 item->result_type()); 05712 if (res_type == STRING_RESULT) 05713 { 05714 char item_buff[MAX_FIELD_WIDTH]; 05715 char field_buff[MAX_FIELD_WIDTH]; 05716 String item_tmp(item_buff,sizeof(item_buff),&my_charset_bin),*item_result; 05717 String field_tmp(field_buff,sizeof(field_buff),&my_charset_bin); 05718 item_result=item->val_str(&item_tmp); 05719 if (item->null_value) 05720 return 1; // This must be true 05721 field->val_str(&field_tmp); 05722 return !stringcmp(&field_tmp,item_result); 05723 } 05724 if (res_type == INT_RESULT) 05725 return 1; // Both where of type int 05726 if (res_type == DECIMAL_RESULT) 05727 { 05728 my_decimal item_buf, *item_val, 05729 field_buf, *field_val; 05730 item_val= item->val_decimal(&item_buf); 05731 if (item->null_value) 05732 return 1; // This must be true 05733 field_val= field->val_decimal(&field_buf); 05734 return !my_decimal_cmp(item_val, field_val); 05735 } 05736 double result= item->val_real(); 05737 if (item->null_value) 05738 return 1; 05739 return result == field->val_real(); 05740 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3107 of file item.cc.
References current_thd, Item_ident::db_name, DBUG_ASSERT, ER_NON_UNIQ_ERROR, Item::FIELD_ITEM, Item_ident::field_name, files_charset_info, Item::full_name(), st_order::item, lower_case_table_names, my_casedn_str, my_error(), my_strcasecmp, MYF, NAME_LEN, st_order::next, NULL, Item::REF_ITEM, strcmp(), strmake(), system_charset_info, Item_ident::table_name, and Item::type().
Referenced by resolve_ref_in_select_and_group().
03108 { 03109 const char *db_name; 03110 const char *table_name; 03111 const char *field_name; 03112 ORDER *found_group= NULL; 03113 int found_match_degree= 0; 03114 Item_ident *cur_field; 03115 int cur_match_degree= 0; 03116 char name_buff[NAME_LEN+1]; 03117 03118 if (find_item->type() == Item::FIELD_ITEM || 03119 find_item->type() == Item::REF_ITEM) 03120 { 03121 db_name= ((Item_ident*) find_item)->db_name; 03122 table_name= ((Item_ident*) find_item)->table_name; 03123 field_name= ((Item_ident*) find_item)->field_name; 03124 } 03125 else 03126 return NULL; 03127 03128 if (db_name && lower_case_table_names) 03129 { 03130 /* Convert database to lower case for comparison */ 03131 strmake(name_buff, db_name, sizeof(name_buff)-1); 03132 my_casedn_str(files_charset_info, name_buff); 03133 db_name= name_buff; 03134 } 03135 03136 DBUG_ASSERT(field_name != 0); 03137 03138 for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next) 03139 { 03140 if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM) 03141 { 03142 cur_field= (Item_ident*) *cur_group->item; 03143 cur_match_degree= 0; 03144 03145 DBUG_ASSERT(cur_field->field_name != 0); 03146 03147 if (!my_strcasecmp(system_charset_info, 03148 cur_field->field_name, field_name)) 03149 ++cur_match_degree; 03150 else 03151 continue; 03152 03153 if (cur_field->table_name && table_name) 03154 { 03155 /* If field_name is qualified by a table name. */ 03156 if (strcmp(cur_field->table_name, table_name)) 03157 /* Same field names, different tables. */ 03158 return NULL; 03159 03160 ++cur_match_degree; 03161 if (cur_field->db_name && db_name) 03162 { 03163 /* If field_name is also qualified by a database name. */ 03164 if (strcmp(cur_field->db_name, db_name)) 03165 /* Same field names, different databases. */ 03166 return NULL; 03167 ++cur_match_degree; 03168 } 03169 } 03170 03171 if (cur_match_degree > found_match_degree) 03172 { 03173 found_match_degree= cur_match_degree; 03174 found_group= cur_group; 03175 } 03176 else if (found_group && (cur_match_degree == found_match_degree) && 03177 ! (*(found_group->item))->eq(cur_field, 0)) 03178 { 03179 /* 03180 If the current resolve candidate matches equally well as the current 03181 best match, they must reference the same column, otherwise the field 03182 is ambiguous. 03183 */ 03184 my_error(ER_NON_UNIQ_ERROR, MYF(0), 03185 find_item->full_name(), current_thd->where); 03186 return NULL; 03187 } 03188 } 03189 } 03190 03191 if (found_group) 03192 return found_group->item; 03193 else 03194 return NULL; 03195 }
Here is the call graph for this function:

Here is the caller graph for this function:

| Item_result item_cmp_type | ( | Item_result | a, | |
| Item_result | b | |||
| ) |
Definition at line 5595 of file item.cc.
References DECIMAL_RESULT, INT_RESULT, REAL_RESULT, ROW_RESULT, and STRING_RESULT.
Referenced by agg_cmp_type(), field_is_equal_to_item(), Item_func_field::fix_length_and_dec(), Item_func_min_max::fix_length_and_dec(), resolve_const_item(), Arg_comparator::set_cmp_func(), and Arg_comparator::set_compare_func().
05596 { 05597 if (a == STRING_RESULT && b == STRING_RESULT) 05598 return STRING_RESULT; 05599 if (a == INT_RESULT && b == INT_RESULT) 05600 return INT_RESULT; 05601 else if (a == ROW_RESULT || b == ROW_RESULT) 05602 return ROW_RESULT; 05603 if ((a == INT_RESULT || a == DECIMAL_RESULT) && 05604 (b == INT_RESULT || b == DECIMAL_RESULT)) 05605 return DECIMAL_RESULT; 05606 return REAL_RESULT; 05607 }
Here is the caller graph for this function:

| void item_init | ( | void | ) |
Definition at line 166 of file item.cc.
References item_user_lock_init().
Referenced by init_common_variables().
00167 { 00168 item_user_lock_init(); 00169 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void mark_as_dependent | ( | THD * | thd, | |
| SELECT_LEX * | last, | |||
| SELECT_LEX * | current, | |||
| Item_ident * | resolved_item, | |||
| Item_ident * | mark_item | |||
| ) | [static] |
Definition at line 2997 of file item.cc.
References Item_ident::db_name, Item_ident::depended_from, DESCRIBE_EXTENDED, ER, ER_WARN_FIELD_RESOLVED, Item_ident::field_name, MYSQL_ERRMSG_SIZE, push_warning(), Item_ident::table_name, and MYSQL_ERROR::WARN_LEVEL_NOTE.
03000 { 03001 const char *db_name= (resolved_item->db_name ? 03002 resolved_item->db_name : ""); 03003 const char *table_name= (resolved_item->table_name ? 03004 resolved_item->table_name : ""); 03005 /* store pointer on SELECT_LEX from which item is dependent */ 03006 if (mark_item) 03007 mark_item->depended_from= last; 03008 current->mark_as_dependent(last); 03009 if (thd->lex->describe & DESCRIBE_EXTENDED) 03010 { 03011 char warn_buff[MYSQL_ERRMSG_SIZE]; 03012 sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED), 03013 db_name, (db_name[0] ? "." : ""), 03014 table_name, (table_name [0] ? "." : ""), 03015 resolved_item->field_name, 03016 current->select_number, last->select_number); 03017 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, 03018 ER_WARN_FIELD_RESOLVED, warn_buff); 03019 } 03020 }
Here is the call graph for this function:

| static void mark_as_dependent | ( | THD * | thd, | |
| SELECT_LEX * | last, | |||
| SELECT_LEX * | current, | |||
| Item_ident * | item | |||
| ) | [static] |
Referenced by Item_ref::fix_fields(), Item_field::fix_outer_field(), and mark_select_range_as_dependent().
Here is the caller graph for this function:

| void mark_select_range_as_dependent | ( | THD * | thd, | |
| SELECT_LEX * | last_select, | |||
| SELECT_LEX * | current_sel, | |||
| Field * | found_field, | |||
| Item * | found_item, | |||
| Item_ident * | resolved_item | |||
| ) |
Definition at line 3045 of file item.cc.
References Item_subselect::const_item_cache, Item::FIELD_ITEM, st_table::map, mark_as_dependent(), OUTER_REF_TABLE_BIT, Item::REF_ITEM, Field::table, Item::type(), Item::used_tables(), Item_subselect::used_tables_cache, and view_ref_found.
Referenced by find_field_in_tables().
03050 { 03051 /* 03052 Go from current SELECT to SELECT where field was resolved (it 03053 have to be reachable from current SELECT, because it was already 03054 done once when we resolved this field and cached result of 03055 resolving) 03056 */ 03057 SELECT_LEX *previous_select= current_sel; 03058 for (; previous_select->outer_select() != last_select; 03059 previous_select= previous_select->outer_select()) 03060 { 03061 Item_subselect *prev_subselect_item= 03062 previous_select->master_unit()->item; 03063 prev_subselect_item->used_tables_cache|= OUTER_REF_TABLE_BIT; 03064 prev_subselect_item->const_item_cache= 0; 03065 } 03066 { 03067 Item_subselect *prev_subselect_item= 03068 previous_select->master_unit()->item; 03069 Item_ident *dependent= resolved_item; 03070 if (found_field == view_ref_found) 03071 { 03072 Item::Type type= found_item->type(); 03073 prev_subselect_item->used_tables_cache|= 03074 found_item->used_tables(); 03075 dependent= ((type == Item::REF_ITEM || type == Item::FIELD_ITEM) ? 03076 (Item_ident*) found_item : 03077 0); 03078 } 03079 else 03080 prev_subselect_item->used_tables_cache|= 03081 found_field->table->map; 03082 prev_subselect_item->const_item_cache= 0; 03083 mark_as_dependent(thd, last_select, current_sel, resolved_item, 03084 dependent); 03085 } 03086 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void my_coll_agg_error | ( | Item ** | args, | |
| uint | count, | |||
| const char * | fname, | |||
| int | item_sep | |||
| ) | [static] |
Definition at line 1352 of file item.cc.
References args, ER_CANT_AGGREGATE_NCOLLATIONS, my_coll_agg_error(), my_error(), and MYF.
01354 { 01355 if (count == 2) 01356 my_coll_agg_error(args[0]->collation, args[item_sep]->collation, fname); 01357 else if (count == 3) 01358 my_coll_agg_error(args[0]->collation, args[item_sep]->collation, 01359 args[2*item_sep]->collation, fname); 01360 else 01361 my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname); 01362 }
Here is the call graph for this function:

| static void my_coll_agg_error | ( | DTCollation & | c1, | |
| DTCollation & | c2, | |||
| DTCollation & | c3, | |||
| const char * | fname | |||
| ) | [static] |
Definition at line 1340 of file item.cc.
References DTCollation::collation, DTCollation::derivation_name(), ER_CANT_AGGREGATE_3COLLATIONS, my_error(), MYF, and charset_info_st::name.
01342 { 01343 my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0), 01344 c1.collation->name,c1.derivation_name(), 01345 c2.collation->name,c2.derivation_name(), 01346 c3.collation->name,c3.derivation_name(), 01347 fname); 01348 }
Here is the call graph for this function:

| static void my_coll_agg_error | ( | DTCollation & | c1, | |
| DTCollation & | c2, | |||
| const char * | fname | |||
| ) | [static] |
Definition at line 1330 of file item.cc.
References DTCollation::collation, DTCollation::derivation_name(), ER_CANT_AGGREGATE_2COLLATIONS, my_error(), MYF, and charset_info_st::name.
Referenced by agg_item_charsets(), agg_item_collations(), my_coll_agg_error(), and Arg_comparator::set_compare_func().
01331 { 01332 my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), 01333 c1.collation->name,c1.derivation_name(), 01334 c2.collation->name,c2.derivation_name(), 01335 fname); 01336 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static uint nr_of_decimals | ( | const char * | str, | |
| const char * | end | |||
| ) | [static] |
Definition at line 4299 of file item.cc.
References my_isdigit, NOT_FIXED_DEC, and system_charset_info.
Referenced by Item_float::Item_float().
04300 { 04301 const char *decimal_point; 04302 04303 /* Find position for '.' */ 04304 for (;;) 04305 { 04306 if (str == end) 04307 return 0; 04308 if (*str == 'e' || *str == 'E') 04309 return NOT_FIXED_DEC; 04310 if (*str++ == '.') 04311 break; 04312 } 04313 decimal_point= str; 04314 for (; my_isdigit(system_charset_info, *str) ; str++) 04315 ; 04316 if (*str == 'e' || *str == 'E') 04317 return NOT_FIXED_DEC; 04318 return (uint) (str - decimal_point); 04319 }
Here is the caller graph for this function:

Definition at line 5610 of file item.cc.
References Item::basic_const_item(), String::charset(), Item_row::cols(), DBUG_ASSERT, DECIMAL_RESULT, Item::decimals, Item_row::el(), INT_RESULT, item_cmp_type(), String::length(), MAX_FIELD_WIDTH, Item::max_length, my_charset_bin, name, Item::name, NULL, Item::null_value, String::ptr(), REAL_RESULT, resolve_const_item(), Item::result_type(), Item::ROW_ITEM, ROW_RESULT, sql_strmake(), STRING_RESULT, Item::type(), Item::val_decimal(), Item::val_int(), Item::val_real(), and Item::val_str().
Referenced by propagate_cond_constants(), and resolve_const_item().
05611 { 05612 Item *item= *ref; 05613 Item *new_item= NULL; 05614 if (item->basic_const_item()) 05615 return; // Can't be better 05616 Item_result res_type=item_cmp_type(comp_item->result_type(), 05617 item->result_type()); 05618 char *name=item->name; // Alloced by sql_alloc 05619 05620 switch (res_type) { 05621 case STRING_RESULT: 05622 { 05623 char buff[MAX_FIELD_WIDTH]; 05624 String tmp(buff,sizeof(buff),&my_charset_bin),*result; 05625 result=item->val_str(&tmp); 05626 if (item->null_value) 05627 new_item= new Item_null(name); 05628 else 05629 { 05630 uint length= result->length(); 05631 char *tmp_str= sql_strmake(result->ptr(), length); 05632 new_item= new Item_string(name, tmp_str, length, result->charset()); 05633 } 05634 break; 05635 } 05636 case INT_RESULT: 05637 { 05638 longlong result=item->val_int(); 05639 uint length=item->max_length; 05640 bool null_value=item->null_value; 05641 new_item= (null_value ? (Item*) new Item_null(name) : 05642 (Item*) new Item_int(name, result, length)); 05643 break; 05644 } 05645 case ROW_RESULT: 05646 if (item->type() == Item::ROW_ITEM && comp_item->type() == Item::ROW_ITEM) 05647 { 05648 /* 05649 Substitute constants only in Item_rows. Don't affect other Items 05650 with ROW_RESULT (eg Item_singlerow_subselect). 05651 05652 For such Items more optimal is to detect if it is constant and replace 05653 it with Item_row. This would optimize queries like this: 05654 SELECT * FROM t1 WHERE (a,b) = (SELECT a,b FROM t2 LIMIT 1); 05655 */ 05656 Item_row *item_row= (Item_row*) item; 05657 Item_row *comp_item_row= (Item_row*) comp_item; 05658 uint col; 05659 new_item= 0; 05660 /* 05661 If item and comp_item are both Item_rows and have same number of cols 05662 then process items in Item_row one by one. 05663 We can't ignore NULL values here as this item may be used with <=>, in 05664 which case NULL's are significant. 05665 */ 05666 DBUG_ASSERT(item->result_type() == comp_item->result_type()); 05667 DBUG_ASSERT(item_row->cols() == comp_item_row->cols()); 05668 col= item_row->cols(); 05669 while (col-- > 0) 05670 resolve_const_item(thd, item_row->addr(col), comp_item_row->el(col)); 05671 break; 05672 } 05673 /* Fallthrough */ 05674 case REAL_RESULT: 05675 { // It must REAL_RESULT 05676 double result= item->val_real(); 05677 uint length=item->max_length,decimals=item->decimals; 05678 bool null_value=item->null_value; 05679 new_item= (null_value ? (Item*) new Item_null(name) : (Item*) 05680 new Item_float(name, result, decimals, length)); 05681 break; 05682 } 05683 case DECIMAL_RESULT: 05684 { 05685 my_decimal decimal_value; 05686 my_decimal *result= item->val_decimal(&decimal_value); 05687 uint length= item->max_length, decimals= item->decimals; 05688 bool null_value= item->null_value; 05689 new_item= (null_value ? 05690 (Item*) new Item_null(name) : 05691 (Item*) new Item_decimal(name, result, length, decimals)); 05692 break; 05693 } 05694 default: 05695 DBUG_ASSERT(0); 05696 } 05697 if (new_item) 05698 thd->change_item_tree(ref, new_item); 05699 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static Item** resolve_ref_in_select_and_group | ( | THD * | thd, | |
| Item_ident * | ref, | |||
| SELECT_LEX * | select | |||
| ) | [static] |
Definition at line 3238 of file item.cc.
References counter, current_thd, DBUG_ASSERT, ER, ER_ILLEGAL_REFERENCE, ER_NON_GROUPING_FIELD_USED, ER_NON_UNIQ_ERROR, FALSE, find_field_in_group_list(), find_item_in_list(), Item_ident::full_name(), MODE_ONLY_FULL_GROUP_BY, my_error(), MYF, Item::name, not_found_item, NULL, push_warning_printf(), TRUE, MYSQL_ERROR::WARN_LEVEL_WARN, and Item::with_sum_func.
Referenced by Item_ref::fix_fields(), and Item_field::fix_outer_field().
03239 { 03240 Item **group_by_ref= NULL; 03241 Item **select_ref= NULL; 03242 ORDER *group_list= (ORDER*) select->group_list.first; 03243 bool ambiguous_fields= FALSE; 03244 uint counter; 03245 bool not_used; 03246 03247 /* 03248 Search for a column or derived column named as 'ref' in the SELECT 03249 clause of the current select. 03250 */ 03251 if (!(select_ref= find_item_in_list(ref, *(select->get_item_list()), 03252 &counter, REPORT_EXCEPT_NOT_FOUND, 03253 ¬_used))) 03254 return NULL; /* Some error occurred. */ 03255 03256 /* If this is a non-aggregated field inside HAVING, search in GROUP BY. */ 03257 if (select->having_fix_field && !ref->with_sum_func && group_list) 03258 { 03259 group_by_ref= find_field_in_group_list(ref, group_list); 03260 03261 /* Check if the fields found in SELECT and GROUP BY are the same field. */ 03262 if (group_by_ref && (select_ref != not_found_item) && 03263 !((*group_by_ref)->eq(*select_ref, 0))) 03264 { 03265 ambiguous_fields= TRUE; 03266 push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR, 03267 ER(ER_NON_UNIQ_ERROR), ref->full_name(), 03268 current_thd->where); 03269 03270 } 03271 } 03272 03273 if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && 03274 select_ref != not_found_item && !group_by_ref) 03275 { 03276 /* 03277 Report the error if fields was found only in the SELECT item list and 03278 the strict mode is enabled. 03279 */ 03280 my_error(ER_NON_GROUPING_FIELD_USED, MYF(0), 03281 ref->name, "HAVING"); 03282 return NULL; 03283 } 03284 if (select_ref != not_found_item || group_by_ref) 03285 { 03286 if (select_ref != not_found_item && !ambiguous_fields) 03287 { 03288 DBUG_ASSERT(*select_ref != 0); 03289 if (!select->ref_pointer_array[counter]) 03290 { 03291 my_error(ER_ILLEGAL_REFERENCE, MYF(0), 03292 ref->name, "forward reference in item list"); 03293 return NULL; 03294 } 03295 DBUG_ASSERT((*select_ref)->fixed); 03296 return (select->ref_pointer_array + counter); 03297 } 03298 if (group_by_ref) 03299 return group_by_ref; 03300 DBUG_ASSERT(FALSE); 03301 return NULL; /* So there is no compiler warning. */ 03302 } 03303 03304 return (Item**) not_found_item; 03305 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void view_error_processor | ( | THD * | thd, | |
| void * | data | |||
| ) |
Definition at line 6408 of file item.cc.
Referenced by mysql_make_view(), and Item_default_value::save_in_field().
06409 { 06410 ((TABLE_LIST *)data)->hide_view_error(thd); 06411 }
Here is the caller graph for this function:

const Hybrid_type_traits_decimal decimal_traits_instance [static] |
const Hybrid_type_traits_integer integer_traits_instance [static] |
| const String my_null_string("NULL", 4, default_charset_info) |
Referenced by insert_params_from_vars_with_log(), and Item_param::query_val_str().
const Hybrid_type_traits real_traits_instance [static] |
1.4.7

