1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-11337 Split Item::save_in_field() into virtual methods in Type_handler

Also fixes:
MDEV-11331 Wrong result for INSERT INTO t1 (datetime_field) VALUES (hybrid_function_of_TIME_data_type)
MDEV-11333 Expect "Impossible where condition" for WHERE timestamp_field>=DATE_ADD(TIMESTAMP'9999-01-01 00:00:00',INTERVAL 1000 YEAR)

This patch does the following:
1. Splits the function Item::save_in_field() into pieces:
- Item::save_str_in_field()
- Item::save_real_in_field()
- Item::save_decimal_in_field()
- Item::save_int_in_field()

2. Adds the missing "no_conversion" parameters to
   Item::save_time_in_field() and Item::save_date_in_field(),
   so this parameter is now correctly passed to
   set_field_to_null_with_conversions().
   This fixes the problem reported in 11333.

3. Introduces a new virtual method Type_handler::Item_save_in_field()
   and uses the methods Item::save_xxx_in_field() from the implementations
   of Type_handler_xxx::Item_save_in_field().

These changes additionally fix the problem reported in MDEV-11331,
as the old code erroneously handled expressions like
COALESE(datetime-expression) through the STRING_RESULT branch of
Item::save_in_field() and therefore they looked like string type expressions
for the target fields. Now such expressions are correctly handled by
Item::save_date_in_field().
This commit is contained in:
Alexander Barkov
2016-11-25 07:40:10 +04:00
parent 4b4efb0485
commit cb16d753b2
11 changed files with 242 additions and 76 deletions

View File

@ -272,6 +272,9 @@ public:
virtual void sortlength(THD *thd,
const Type_std_attributes *item,
SORT_FIELD_ATTR *attr) const= 0;
virtual int Item_save_in_field(Item *item, Field *field,
bool no_conversions) const= 0;
};
@ -288,6 +291,7 @@ public:
void sortlength(THD *thd,
const Type_std_attributes *item,
SORT_FIELD_ATTR *attr) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
};
@ -303,6 +307,7 @@ public:
void sortlength(THD *thd,
const Type_std_attributes *item,
SORT_FIELD_ATTR *attr) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
};
@ -318,6 +323,7 @@ public:
void sortlength(THD *thd,
const Type_std_attributes *item,
SORT_FIELD_ATTR *attr) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
};
@ -349,6 +355,7 @@ public:
void sortlength(THD *thd,
const Type_std_attributes *item,
SORT_FIELD_ATTR *attr) const;
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
};
@ -463,28 +470,43 @@ public:
};
class Type_handler_time: public Type_handler_temporal_result
class Type_handler_time_common: public Type_handler_temporal_result
{
public:
virtual ~Type_handler_time_common() { }
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
};
class Type_handler_time: public Type_handler_time_common
{
public:
virtual ~Type_handler_time() {}
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
};
class Type_handler_time2: public Type_handler_temporal_result
class Type_handler_time2: public Type_handler_time_common
{
public:
virtual ~Type_handler_time2() {}
enum_field_types field_type() const { return MYSQL_TYPE_TIME; }
enum_field_types real_field_type() const { return MYSQL_TYPE_TIME2; }
Field *make_conversion_table_field(TABLE *, uint metadata,
const Field *target) const;
};
class Type_handler_date: public Type_handler_temporal_result
class Type_handler_temporal_with_date: public Type_handler_temporal_result
{
public:
virtual ~Type_handler_temporal_with_date() {}
int Item_save_in_field(Item *item, Field *field, bool no_conversions) const;
};
class Type_handler_date: public Type_handler_temporal_with_date
{
public:
virtual ~Type_handler_date() {}
@ -494,7 +516,7 @@ public:
};
class Type_handler_newdate: public Type_handler_temporal_result
class Type_handler_newdate: public Type_handler_temporal_with_date
{
public:
virtual ~Type_handler_newdate() {}
@ -504,7 +526,7 @@ public:
};
class Type_handler_datetime: public Type_handler_temporal_result
class Type_handler_datetime: public Type_handler_temporal_with_date
{
public:
virtual ~Type_handler_datetime() {}
@ -514,7 +536,7 @@ public:
};
class Type_handler_datetime2: public Type_handler_temporal_result
class Type_handler_datetime2: public Type_handler_temporal_with_date
{
public:
virtual ~Type_handler_datetime2() {}
@ -525,7 +547,7 @@ public:
};
class Type_handler_timestamp: public Type_handler_temporal_result
class Type_handler_timestamp: public Type_handler_temporal_with_date
{
public:
virtual ~Type_handler_timestamp() {}
@ -535,7 +557,7 @@ public:
};
class Type_handler_timestamp2: public Type_handler_temporal_result
class Type_handler_timestamp2: public Type_handler_temporal_with_date
{
public:
virtual ~Type_handler_timestamp2() {}