338
338
MYSQL_TIME ltime;
339
339
if (get_date(<ime, TIME_FUZZY_DATE))
340
return set_field_to_null(field);
340
return set_field_to_null_with_conversions(field, 0);
341
341
field->set_notnull();
342
342
return field->store_time(<ime, MYSQL_TIMESTAMP_DATETIME);
1274
1274
valid_args guarantees value_item->basic_const_item(); if type is
1275
1275
FUNC_ITEM, then we have a fudged item_func_neg() on our hands
1276
1276
and return the underlying type.
1277
For Item_func_set_collation()
1278
e.g. NAME_CONST('name', 'value' COLLATE collation) we return its
1279
'value' argument type.
1279
(((value_item->type() == FUNC_ITEM) &&
1280
(((Item_func *) value_item)->functype() == Item_func::NEG_FUNC)) ?
1281
((Item_func *) value_item)->key_item()->type() :
1282
value_item->type()) :
1283
Item::Type value_type= value_item->type();
1284
if (value_type == FUNC_ITEM)
1287
The second argument of NAME_CONST('name', 'value') must be
1288
a simple constant item or a NEG_FUNC/COLLATE_FUNC.
1290
DBUG_ASSERT(((Item_func *) value_item)->functype() ==
1291
Item_func::NEG_FUNC ||
1292
((Item_func *) value_item)->functype() ==
1293
Item_func::COLLATE_FUNC);
1294
return ((Item_func *) value_item)->key_item()->type();
1520
1533
// Cannot apply conversion
1521
set(0, DERIVATION_NONE, 0);
1534
set(&my_charset_bin, DERIVATION_NONE,
1535
(dt.repertoire|repertoire));
1604
1620
c.set(av[0]->collation);
1605
1621
for (i= 1, arg= &av[item_sep]; i < count; i++, arg++)
1607
1623
if (c.aggregate((*arg)->collation, flags))
1625
if (c.derivation == DERIVATION_NONE &&
1626
c.collation == &my_charset_bin)
1609
1631
my_coll_agg_error(av, count, fname, item_sep);
1637
c.derivation != DERIVATION_EXPLICIT)
1639
my_coll_agg_error(av, count, fname, item_sep);
1613
1643
if ((flags & MY_COLL_DISALLOW_NONE) &&
1614
1644
c.derivation == DERIVATION_NONE)
1632
Collect arguments' character sets together.
1634
We allow to apply automatic character set conversion in some cases.
1635
The conditions when conversion is possible are:
1636
- arguments A and B have different charsets
1637
- A wins according to coercibility rules
1638
(i.e. a column is stronger than a string constant,
1639
an explicit COLLATE clause is stronger than a column)
1640
- character set of A is either superset for character set of B,
1641
or B is a string constant which can be converted into the
1642
character set of A without data loss.
1644
If all of the above is true, then it's possible to convert
1645
B into the character set of A, and then compare according
1646
to the collation of A.
1648
For functions with more than two arguments:
1650
collect(A,B,C) ::= collect(collect(A,B),C)
1652
Since this function calls THD::change_item_tree() on the passed Item **
1653
pointers, it is necessary to pass the original Item **'s, not copies.
1654
Otherwise their values will not be properly restored (see BUG#20769).
1655
If the items are not consecutive (eg. args[2] and args[5]), use the
1656
item_sep argument, ie.
1658
agg_item_charsets(coll, fname, &args[2], 2, flags, 3)
1662
bool agg_item_charsets(DTCollation &coll, const char *fname,
1663
Item **args, uint nargs, uint flags, int item_sep)
1661
bool agg_item_set_converter(DTCollation &coll, const char *fname,
1662
Item **args, uint nargs, uint flags, int item_sep)
1665
1664
Item **arg, *safe_args[2];
1667
LINT_INIT(safe_args[0]);
1668
LINT_INIT(safe_args[1]);
1670
if (agg_item_collations(coll, fname, args, nargs, flags, item_sep))
1674
1667
For better error reporting: save the first and the second argument.
1675
1668
We need this only if the the number of args is 3 or 2:
1746
Collect arguments' character sets together.
1747
We allow to apply automatic character set conversion in some cases.
1748
The conditions when conversion is possible are:
1749
- arguments A and B have different charsets
1750
- A wins according to coercibility rules
1751
(i.e. a column is stronger than a string constant,
1752
an explicit COLLATE clause is stronger than a column)
1753
- character set of A is either superset for character set of B,
1754
or B is a string constant which can be converted into the
1755
character set of A without data loss.
1757
If all of the above is true, then it's possible to convert
1758
B into the character set of A, and then compare according
1759
to the collation of A.
1761
For functions with more than two arguments:
1763
collect(A,B,C) ::= collect(collect(A,B),C)
1765
Since this function calls THD::change_item_tree() on the passed Item **
1766
pointers, it is necessary to pass the original Item **'s, not copies.
1767
Otherwise their values will not be properly restored (see BUG#20769).
1768
If the items are not consecutive (eg. args[2] and args[5]), use the
1769
item_sep argument, ie.
1771
agg_item_charsets(coll, fname, &args[2], 2, flags, 3)
1775
bool agg_item_charsets(DTCollation &coll, const char *fname,
1776
Item **args, uint nargs, uint flags, int item_sep)
1778
if (agg_item_collations(coll, fname, args, nargs, flags, item_sep))
1781
return agg_item_set_converter(coll, fname, args, nargs, flags, item_sep);
1752
1785
void Item_ident_for_show::make_field(Send_field *tmp_field)
1754
1787
tmp_field->table_name= tmp_field->org_table_name= table_name;
3082
3121
str_value.set_charset(value.cs_info.final_character_set_of_str_value);
3083
3122
/* Here str_value is guaranteed to be in final_character_set_of_str_value */
3085
max_length= str_value.length();
3124
max_length= str_value.numchars() * str_value.charset()->mbmaxlen;
3088
3127
str_value_ptr is returned from val_str(). It must be not alloced