The world's most popular open source database
#include "mysql_priv.h"#include <m_ctype.h>#include "sql_select.h"Include dependency graph for item_cmpfunc.cc:

Go to the source code of this file.
Defines | |
| #define | likeconv(cs, A) (uchar) (cs)->sort_order[(uchar) (A)] |
Functions | |
| static bool | convert_constant_item (THD *thd, Field *field, Item **item) |
| static Item_result | item_store_type (Item_result a, Item_result b) |
| static void | agg_result_type (Item_result *type, Item **items, uint nitems) |
| static void | agg_cmp_type (THD *thd, Item_result *type, Item **items, uint nitems) |
| static void | my_coll_agg_error (DTCollation &c1, DTCollation &c2, const char *fname) |
| static int | cmp_longlong (void *cmp_arg, longlong *a, longlong *b) |
| static int | cmp_double (void *cmp_arg, double *a, double *b) |
| static int | cmp_row (void *cmp_arg, cmp_item_row *a, cmp_item_row *b) |
| static int | cmp_decimal (void *cmp_arg, my_decimal *a, my_decimal *b) |
| static int | srtcmp_in (CHARSET_INFO *cs, const String *x, const String *y) |
| Item * | and_expressions (Item *a, Item *b, Item **org_item) |
| #define likeconv | ( | cs, | |||
| A | ) | (uchar) (cs)->sort_order[(uchar) (A)] |
Definition at line 3344 of file item_cmpfunc.cc.
| static void agg_cmp_type | ( | THD * | thd, | |
| Item_result * | type, | |||
| Item ** | items, | |||
| uint | nitems | |||
| ) | [static] |
Definition at line 119 of file item_cmpfunc.cc.
References convert_constant_item(), Item::FIELD_ITEM, Item::FUNC_ITEM, INT_RESULT, item_cmp_type(), Field::move_field(), NULL, Item::result_type(), and STRING_RESULT.
Referenced by Item_func_in::fix_length_and_dec(), Item_func_case::fix_length_and_dec(), and Item_func_between::fix_length_and_dec().
00120 { 00121 uint i; 00122 Item::Type res= (Item::Type)0; 00123 /* Used only for date/time fields, max_length = 19 */ 00124 char buff[20]; 00125 uchar null_byte; 00126 Field *field= NULL; 00127 00128 /* Search for date/time fields/functions */ 00129 for (i= 0; i < nitems; i++) 00130 { 00131 if (!items[i]->result_as_longlong()) 00132 { 00133 /* Do not convert anything if a string field/function is present */ 00134 if (!items[i]->const_item() && items[i]->result_type() == STRING_RESULT) 00135 { 00136 i= nitems; 00137 break; 00138 } 00139 continue; 00140 } 00141 if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM && 00142 items[i]->result_type() != INT_RESULT) 00143 { 00144 field= ((Item_field *)items[i]->real_item())->field; 00145 break; 00146 } 00147 else if (res == Item::FUNC_ITEM) 00148 { 00149 field= items[i]->tmp_table_field_from_field_type(0, 0); 00150 if (field) 00151 field->move_field(buff, &null_byte, 0); 00152 break; 00153 } 00154 } 00155 if (field) 00156 { 00157 /* Check the rest of the list for presence of a string field/function. */ 00158 for (i++ ; i < nitems; i++) 00159 { 00160 if (!items[i]->const_item() && items[i]->result_type() == STRING_RESULT && 00161 !items[i]->result_as_longlong()) 00162 { 00163 if (res == Item::FUNC_ITEM) 00164 delete field; 00165 field= 0; 00166 break; 00167 } 00168 } 00169 } 00170 /* 00171 If the first item is a date/time function then its result should be 00172 compared as int 00173 */ 00174 if (field) 00175 /* Suppose we are comparing dates */ 00176 type[0]= INT_RESULT; 00177 else 00178 type[0]= items[0]->result_type(); 00179 00180 for (i= 0; i < nitems ; i++) 00181 { 00182 Item_result result= items[i]->result_type(); 00183 /* 00184 Use INT_RESULT as result type for DATE/TIME fields/functions and 00185 for constants successfully converted to DATE/TIME 00186 */ 00187 if (field && 00188 ((!items[i]->const_item() && items[i]->result_as_longlong()) || 00189 (items[i]->const_item() && convert_constant_item(thd, field, 00190 &items[i])))) 00191 result= INT_RESULT; 00192 type[0]= item_cmp_type(type[0], result); 00193 } 00194 00195 if (res == Item::FUNC_ITEM && field) 00196 delete field; 00197 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void agg_result_type | ( | Item_result * | type, | |
| Item ** | items, | |||
| uint | nitems | |||
| ) | [static] |
Definition at line 42 of file item_cmpfunc.cc.
References item_store_type(), Item::NULL_ITEM, and STRING_RESULT.
Referenced by Item_func_coalesce::fix_length_and_dec(), Item_func_case::fix_length_and_dec(), Item_func_if::fix_length_and_dec(), and Item_func_ifnull::fix_length_and_dec().
00043 { 00044 Item **item, **item_end; 00045 00046 *type= STRING_RESULT; 00047 /* Skip beginning NULL items */ 00048 for (item= items, item_end= item + nitems; item < item_end; item++) 00049 { 00050 if ((*item)->type() != Item::NULL_ITEM) 00051 { 00052 *type= (*item)->result_type(); 00053 item++; 00054 break; 00055 } 00056 } 00057 /* Combine result types. Note: NULL items don't affect the result */ 00058 for (; item < item_end; item++) 00059 { 00060 if ((*item)->type() != Item::NULL_ITEM) 00061 *type= item_store_type(type[0], (*item)->result_type()); 00062 } 00063 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2971 of file item_cmpfunc.cc.
References Item::not_null_tables(), Item_func::not_null_tables_cache, Item::used_tables(), and Item_func::used_tables_cache.
02972 { 02973 if (!a) 02974 return (*org_item= (Item*) b); 02975 if (a == *org_item) 02976 { 02977 Item_cond *res; 02978 if ((res= new Item_cond_and(a, (Item*) b))) 02979 { 02980 res->used_tables_cache= a->used_tables() | b->used_tables(); 02981 res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables(); 02982 } 02983 return res; 02984 } 02985 if (((Item_cond_and*) a)->add((Item*) b)) 02986 return 0; 02987 ((Item_cond_and*) a)->used_tables_cache|= b->used_tables(); 02988 ((Item_cond_and*) a)->not_null_tables_cache|= b->not_null_tables(); 02989 return a; 02990 }
Here is the call graph for this function:

| static int cmp_decimal | ( | void * | cmp_arg, | |
| my_decimal * | a, | |||
| my_decimal * | b | |||
| ) | [static] |
Definition at line 2078 of file item_cmpfunc.cc.
References my_decimal::fix_buffer_pointer(), and my_decimal_cmp().
02079 { 02080 /* 02081 We need call of fixing buffer pointer, because fast sort just copy 02082 decimal buffers in memory and pointers left pointing on old buffer place 02083 */ 02084 a->fix_buffer_pointer(); 02085 b->fix_buffer_pointer(); 02086 return my_decimal_cmp(a, b); 02087 }
Here is the call graph for this function:

| static int cmp_double | ( | void * | cmp_arg, | |
| double * | a, | |||
| double * | b | |||
| ) | [static] |
Definition at line 2067 of file item_cmpfunc.cc.
Referenced by test_bug3035(), and test_prepare().
Here is the caller graph for this function:

| static int cmp_row | ( | void * | cmp_arg, | |
| cmp_item_row * | a, | |||
| cmp_item_row * | b | |||
| ) | [static] |
Definition at line 2072 of file item_cmpfunc.cc.
References cmp_item_row::compare().
Referenced by in_row::in_row().
02073 { 02074 return a->compare(b); 02075 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 347 of file item_cmpfunc.cc.
References dbug_tmp_restore_column_map(), dbug_tmp_use_all_columns(), Field::flags, MODE_INVALID_DATES, Field::table, test, UNSIGNED_FLAG, and Field::val_int().
Referenced by agg_cmp_type(), and Item_bool_func2::fix_length_and_dec().
00348 { 00349 int result= 0; 00350 00351 if (!(*item)->with_subselect && (*item)->const_item()) 00352 { 00353 TABLE *table= field->table; 00354 ulong orig_sql_mode= thd->variables.sql_mode; 00355 my_bitmap_map *old_write_map; 00356 my_bitmap_map *old_read_map; 00357 00358 if (table) 00359 { 00360 old_write_map= dbug_tmp_use_all_columns(table, table->write_set); 00361 old_read_map= dbug_tmp_use_all_columns(table, table->read_set); 00362 } 00363 /* For comparison purposes allow invalid dates like 2000-01-32 */ 00364 thd->variables.sql_mode|= MODE_INVALID_DATES; 00365 if (!(*item)->save_in_field(field, 1) && !((*item)->null_value)) 00366 { 00367 Item *tmp= new Item_int_with_ref(field->val_int(), *item, 00368 test(field->flags & UNSIGNED_FLAG)); 00369 if (tmp) 00370 thd->change_item_tree(item, tmp); 00371 result= 1; // Item was replaced 00372 } 00373 thd->variables.sql_mode= orig_sql_mode; 00374 if (table) 00375 { 00376 dbug_tmp_restore_column_map(table->write_set, old_write_map); 00377 dbug_tmp_restore_column_map(table->read_set, old_read_map); 00378 } 00379 } 00380 return result; 00381 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static Item_result item_store_type | ( | Item_result | a, | |
| Item_result | b | |||
| ) | [static] |
Definition at line 30 of file item_cmpfunc.cc.
References DECIMAL_RESULT, INT_RESULT, REAL_RESULT, and STRING_RESULT.
Referenced by agg_result_type().
00031 { 00032 if (a == STRING_RESULT || b == STRING_RESULT) 00033 return STRING_RESULT; 00034 else if (a == REAL_RESULT || b == REAL_RESULT) 00035 return REAL_RESULT; 00036 else if (a == DECIMAL_RESULT || b == DECIMAL_RESULT) 00037 return DECIMAL_RESULT; 00038 else 00039 return INT_RESULT; 00040 }
Here is the caller graph for this function:

| static void my_coll_agg_error | ( | DTCollation & | c1, | |
| DTCollation & | c2, | |||
| const char * | fname | |||
| ) | [static] |
Definition at line 200 of file item_cmpfunc.cc.
References DTCollation::collation, DTCollation::derivation_name(), ER_CANT_AGGREGATE_2COLLATIONS, my_error(), MYF, and charset_info_st::name.
00202 { 00203 my_error(ER_CANT_AGGREGATE_2COLLATIONS, MYF(0), 00204 c1.collation->name,c1.derivation_name(), 00205 c2.collation->name,c2.derivation_name(), 00206 fname); 00207 }
Here is the call graph for this function:

| static int srtcmp_in | ( | CHARSET_INFO * | cs, | |
| const String * | x, | |||
| const String * | y | |||
| ) | [static] |
Definition at line 2487 of file item_cmpfunc.cc.
References charset_info_st::coll, String::length(), String::ptr(), my_collation_handler_st::strnncollsp, and x.
Referenced by Item_func_in::fix_length_and_dec().
02488 { 02489 return cs->coll->strnncollsp(cs, 02490 (uchar *) x->ptr(),x->length(), 02491 (uchar *) y->ptr(),y->length(), 0); 02492 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

