diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index 49a4c1c920d..fb2889aad87 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1796,6 +1796,24 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname, &dummy_offset)) continue; + /* + No needs to add converter if an "arg" is NUMERIC or DATETIME + value (which is pure ASCII) and at the same time target DTCollation + is ASCII-compatible. For example, no needs to rewrite: + SELECT * FROM t1 WHERE datetime_field = '2010-01-01'; + to + SELECT * FROM t1 WHERE CONVERT(datetime_field USING cs) = '2010-01-01'; + + TODO: avoid conversion of any values with + repertoire ASCII and 7bit-ASCII-compatible, + not only numeric/datetime origin. + */ + if ((*arg)->collation.derivation == DERIVATION_NUMERIC && + (*arg)->collation.repertoire == MY_REPERTOIRE_ASCII && + !((*arg)->collation.collation->state & MY_CS_NONASCII) && + !(coll.collation->state & MY_CS_NONASCII)) + continue; + if (!(conv= (*arg)->safe_charset_converter(coll.collation)) && ((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII)) { @@ -5422,7 +5440,7 @@ int Item::save_in_field(Field *field, bool no_conversions) { double nr= val_real(); if (null_value) - return set_field_to_null(field); + return set_field_to_null_with_conversions(field, no_conversions); field->set_notnull(); error=field->store(nr); } |