79
79
stored to the value pointer, if latter is provided.
82
0 If one of arguments is NULL or there was a execution error
82
0 If one of arguments is NULL
83
83
# index of the least/greatest argument
94
94
bool is_null_unused;
95
95
uint64_t res= get_datetime_value(session, &arg, 0, datetime_item,
98
/* Check if we need to stop (because of error or KILL) and stop the loop */
99
if (session->is_error())
105
97
if ((null_value= args[i]->null_value))
107
99
if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
132
124
str_res= args[min_max_idx]->val_str(str);
133
if (args[min_max_idx]->null_value)
135
// check if the call to val_str() above returns a NULL value
139
125
str_res->set_charset(collation.collation);
142
128
switch (cmp_type) {
145
int64_t nr=val_int();
148
str->set_int(nr, unsigned_flag, &my_charset_bin);
131
int64_t nr=val_int();
134
str->set_int(nr, unsigned_flag, &my_charset_bin);
152
137
case DECIMAL_RESULT:
154
my_decimal dec_buf, *dec_val= val_decimal(&dec_buf);
157
my_decimal2string(E_DEC_FATAL_ERROR, dec_val, 0, 0, 0, str);
139
my_decimal dec_buf, *dec_val= val_decimal(&dec_buf);
142
my_decimal2string(E_DEC_FATAL_ERROR, dec_val, 0, 0, 0, str);
161
145
case REAL_RESULT:
163
double nr= val_real();
166
str->set_real(nr,decimals,&my_charset_bin);
147
double nr= val_real();
150
str->set_real(nr,decimals,&my_charset_bin);
170
153
case STRING_RESULT:
157
for (uint32_t i=0; i < arg_count ; i++)
174
for (uint32_t i=0; i < arg_count ; i++)
160
res=args[i]->val_str(str);
177
res=args[i]->val_str(str);
181
res2= args[i]->val_str(res == str ? &tmp_value : str);
184
int cmp= sortcmp(res,res2,collation.collation);
185
if ((cmp_sign < 0 ? cmp : -cmp) < 0)
189
if ((null_value= args[i]->null_value))
164
res2= args[i]->val_str(res == str ? &tmp_value : str);
167
int cmp= sortcmp(res,res2,collation.collation);
168
if ((cmp_sign < 0 ? cmp : -cmp) < 0)
192
res->set_charset(collation.collation);
172
if ((null_value= args[i]->null_value))
175
res->set_charset(collation.collation);
197
180
// This case should never be chosen
202
184
return 0; // Keep compiler happy