From 5392726e3c4f924745412500a7d1e030226a68d1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 14 Oct 2019 08:21:08 +0400 Subject: MDEV-20818 ER_CRASHED_ON_USAGE or Assertion `length <= column->length' failed in write_block_record on temporary table The patch for `MDEV-20795 CAST(inet6 AS BINARY) returns wrong result` unintentionally changed what Item_char_typecast::type_handler() returns. This broke UNIONs with the BINARY() function, as the Aria engine started to get columns of unexpected data types. Restoring previous behaviour, to return Type_handler::string_type_handler(max_length). The prototype for Item_handed_func::return_type_handler() has changed from: const Type_handler *return_type_handler() const to: const Type_handler *return_type_handler(const Item_handled_func *) const --- sql/item_timefunc.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/item_timefunc.cc') diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 631829eee1d..8639edf2944 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2420,14 +2420,14 @@ String *Item_char_typecast::val_str_binary_from_native(String *str) class Item_char_typecast_func_handler: public Item_handled_func::Handler_str { public: - const Type_handler *return_type_handler() const + const Type_handler *return_type_handler(const Item_handled_func *item) const { - return &type_handler_varchar; + return Type_handler::string_type_handler(item->max_length); } const Type_handler * type_handler_for_create_select(const Item_handled_func *item) const { - return return_type_handler()->type_handler_for_tmp_table(item); + return return_type_handler(item)->type_handler_for_tmp_table(item); } bool fix_length_and_dec(Item_handled_func *item) const -- cgit v1.2.1