#include <item_func.h>
Inheritance diagram for Item_func_min_max:


Public Member Functions | |
| Item_func_min_max (List< Item > &list, int cmp_sign_arg) | |
| double | val_real () |
| longlong | val_int () |
| String * | val_str (String *) |
| my_decimal * | val_decimal (my_decimal *) |
| void | fix_length_and_dec () |
| enum Item_result | result_type () const |
| bool | check_partition_func_processor (byte *bool_arg) |
Private Attributes | |
| Item_result | cmp_type |
| String | tmp_value |
| int | cmp_sign |
Definition at line 708 of file item_func.h.
Definition at line 714 of file item_func.h.
00714 :Item_func(list), 00715 cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg) {}
| void Item_func_min_max::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Definition at line 2050 of file item_func.cc.
References Item_func::agg_arg_charsets(), Item_func::arg_count, Item_func::args, cmp_type, Item::collation, Item::decimal_int_part(), DECIMAL_RESULT, Item::decimals, INT_RESULT, item_cmp_type(), Item::max_length, Item::maybe_null, MY_COLL_CMP_CONV, my_decimal_precision_to_length(), result_type(), Item::result_type(), set_if_bigger, STRING_RESULT, and Item::unsigned_flag.
02051 { 02052 int max_int_part=0; 02053 decimals=0; 02054 max_length=0; 02055 maybe_null=0; 02056 cmp_type=args[0]->result_type(); 02057 02058 for (uint i=0 ; i < arg_count ; i++) 02059 { 02060 set_if_bigger(max_length, args[i]->max_length); 02061 set_if_bigger(decimals, args[i]->decimals); 02062 set_if_bigger(max_int_part, args[i]->decimal_int_part()); 02063 if (args[i]->maybe_null) 02064 maybe_null=1; 02065 cmp_type=item_cmp_type(cmp_type,args[i]->result_type()); 02066 } 02067 if (cmp_type == STRING_RESULT) 02068 agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV, 1); 02069 else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT)) 02070 max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals, 02071 unsigned_flag); 02072 }
Here is the call graph for this function:

| enum Item_result Item_func_min_max::result_type | ( | ) | const [inline, virtual] |
Reimplemented from Item.
Definition at line 721 of file item_func.h.
References cmp_type.
Referenced by fix_length_and_dec().
00721 { return cmp_type; }
Here is the caller graph for this function:

| my_decimal * Item_func_min_max::val_decimal | ( | my_decimal * | ) | [virtual] |
Reimplemented from Item_func.
Definition at line 2180 of file item_func.cc.
References Item_func::arg_count, Item_func::args, cmp_sign, DBUG_ASSERT, Item::fixed, LINT_INIT, my_decimal2decimal(), my_decimal_cmp(), Item::null_value, and Item::val_decimal().
Referenced by val_str().
02181 { 02182 DBUG_ASSERT(fixed == 1); 02183 my_decimal tmp_buf, *tmp, *res; 02184 LINT_INIT(res); 02185 02186 for (uint i=0; i < arg_count ; i++) 02187 { 02188 if (i == 0) 02189 res= args[i]->val_decimal(dec); 02190 else 02191 { 02192 tmp= args[i]->val_decimal(&tmp_buf); // Zero if NULL 02193 if (tmp && (my_decimal_cmp(tmp, res) * cmp_sign) < 0) 02194 { 02195 if (tmp == &tmp_buf) 02196 { 02197 /* Move value out of tmp_buf as this will be reused on next loop */ 02198 my_decimal2decimal(tmp, dec); 02199 res= dec; 02200 } 02201 else 02202 res= tmp; 02203 } 02204 } 02205 if ((null_value= args[i]->null_value)) 02206 { 02207 res= 0; 02208 break; 02209 } 02210 } 02211 return res; 02212 }
Here is the call graph for this function:

Here is the caller graph for this function:

| longlong Item_func_min_max::val_int | ( | ) | [virtual] |
Implements Item.
Definition at line 2159 of file item_func.cc.
References Item_func::arg_count, Item_func::args, cmp_sign, DBUG_ASSERT, Item::fixed, Item::null_value, Item::val_int(), and value.
Referenced by val_str().
02160 { 02161 DBUG_ASSERT(fixed == 1); 02162 longlong value=0; 02163 for (uint i=0; i < arg_count ; i++) 02164 { 02165 if (i == 0) 02166 value=args[i]->val_int(); 02167 else 02168 { 02169 longlong tmp=args[i]->val_int(); 02170 if (!args[i]->null_value && (tmp < value ? cmp_sign : -cmp_sign) > 0) 02171 value=tmp; 02172 } 02173 if ((null_value= args[i]->null_value)) 02174 break; 02175 } 02176 return value; 02177 }
Here is the call graph for this function:

Here is the caller graph for this function:

| double Item_func_min_max::val_real | ( | ) | [virtual] |
Implements Item.
Definition at line 2138 of file item_func.cc.
References Item_func::arg_count, Item_func::args, cmp_sign, DBUG_ASSERT, Item::fixed, Item::null_value, Item::val_real(), and value.
Referenced by val_str().
02139 { 02140 DBUG_ASSERT(fixed == 1); 02141 double value=0.0; 02142 for (uint i=0; i < arg_count ; i++) 02143 { 02144 if (i == 0) 02145 value= args[i]->val_real(); 02146 else 02147 { 02148 double tmp= args[i]->val_real(); 02149 if (!args[i]->null_value && (tmp < value ? cmp_sign : -cmp_sign) > 0) 02150 value=tmp; 02151 } 02152 if ((null_value= args[i]->null_value)) 02153 break; 02154 } 02155 return value; 02156 }
Here is the call graph for this function:

Here is the caller graph for this function:

Implements Item.
Definition at line 2075 of file item_func.cc.
References Item_func::arg_count, Item_func::args, cmp, cmp_sign, cmp_type, DTCollation::collation, Item::collation, DBUG_ASSERT, DECIMAL_RESULT, Item::decimals, E_DEC_FATAL_ERROR, Item::fixed, INT_RESULT, LINT_INIT, my_charset_bin, my_decimal2string(), Item::null_value, REAL_RESULT, ROW_RESULT, String::set_charset(), String::set_int(), String::set_real(), sortcmp(), STRING_RESULT, tmp_value, Item::unsigned_flag, val_decimal(), val_int(), val_real(), and Item::val_str().
02076 { 02077 DBUG_ASSERT(fixed == 1); 02078 switch (cmp_type) { 02079 case INT_RESULT: 02080 { 02081 longlong nr=val_int(); 02082 if (null_value) 02083 return 0; 02084 str->set_int(nr, unsigned_flag, &my_charset_bin); 02085 return str; 02086 } 02087 case DECIMAL_RESULT: 02088 { 02089 my_decimal dec_buf, *dec_val= val_decimal(&dec_buf); 02090 if (null_value) 02091 return 0; 02092 my_decimal2string(E_DEC_FATAL_ERROR, dec_val, 0, 0, 0, str); 02093 return str; 02094 } 02095 case REAL_RESULT: 02096 { 02097 double nr= val_real(); 02098 if (null_value) 02099 return 0; /* purecov: inspected */ 02100 str->set_real(nr,decimals,&my_charset_bin); 02101 return str; 02102 } 02103 case STRING_RESULT: 02104 { 02105 String *res; 02106 LINT_INIT(res); 02107 for (uint i=0; i < arg_count ; i++) 02108 { 02109 if (i == 0) 02110 res=args[i]->val_str(str); 02111 else 02112 { 02113 String *res2; 02114 res2= args[i]->val_str(res == str ? &tmp_value : str); 02115 if (res2) 02116 { 02117 int cmp= sortcmp(res,res2,collation.collation); 02118 if ((cmp_sign < 0 ? cmp : -cmp) < 0) 02119 res=res2; 02120 } 02121 } 02122 if ((null_value= args[i]->null_value)) 02123 return 0; 02124 } 02125 res->set_charset(collation.collation); 02126 return res; 02127 } 02128 case ROW_RESULT: 02129 default: 02130 // This case should never be chosen 02131 DBUG_ASSERT(0); 02132 return 0; 02133 } 02134 return 0; // Keep compiler happy 02135 }
Here is the call graph for this function:

int Item_func_min_max::cmp_sign [private] |
Definition at line 712 of file item_func.h.
Referenced by val_decimal(), val_int(), val_real(), and val_str().
Item_result Item_func_min_max::cmp_type [private] |
Definition at line 710 of file item_func.h.
Referenced by fix_length_and_dec(), result_type(), and val_str().
String Item_func_min_max::tmp_value [private] |
1.4.7

