232
232
Item **args, uint32_t nargs, uint32_t flags,
235
Item **arg, *safe_args[2];
237
memset(safe_args, 0, sizeof(safe_args));
239
235
if (agg_item_collations(coll, fname, args, nargs, flags, item_sep))
243
For better error reporting: save the first and the second argument.
244
We need this only if the the number of args is 3 or 2:
245
- for a longer argument list, "Illegal mix of collations"
246
doesn't display each argument's characteristics.
247
- if nargs is 1, then this error cannot happen.
249
if (nargs >=2 && nargs <= 3)
251
safe_args[0]= args[0];
252
safe_args[1]= args[item_sep];
255
Session *session= current_session;
259
for (i= 0, arg= args; i < nargs; i++, arg+= item_sep)
262
uint32_t dummy_offset;
263
if (!String::needs_conversion(0, (*arg)->collation.collation,
268
if (!(conv= (*arg)->safe_charset_converter(coll.collation)))
270
if (nargs >=2 && nargs <= 3)
272
/* restore the original arguments for better error message */
273
args[0]= safe_args[0];
274
args[item_sep]= safe_args[1];
276
my_coll_agg_error(args, nargs, fname, item_sep);
278
break; // we cannot return here, we need to restore "arena".
280
if ((*arg)->type() == Item::FIELD_ITEM)
281
((Item_field *)(*arg))->no_const_subst= 1;
283
If in statement prepare, then we create a converter for two
284
constant items, do it once and then reuse it.
285
If we're in execution of a prepared statement, arena is NULL,
286
and the conv was created in runtime memory. This can be
287
the case only if the argument is a parameter marker ('?'),
288
because for all true constants the charset converter has already
289
been created in prepare. In this case register the change for
292
session->change_item_tree(arg, conv);
294
We do not check conv->fixed, because Item_func_conv_charset which can
295
be return by safe_charset_converter can't be fixed at creation
297
conv->fix_fields(session, arg);