Commit 6cc40856 authored by Alexander Barkov's avatar Alexander Barkov

A safety patch for MDEV-9217 Split Item::tmp_table_field_from_field_type()...

A safety patch for MDEV-9217 Split Item::tmp_table_field_from_field_type() into virtual methods in Type_handler

During refactoring in Type_handler, it's safer to use new_Field_xxx
in Type_handler_xxx2::make_table_field(), to avoid creations of wrong
fields for fields of the TIME(0), DATETIME(0) and TIMESTAMP(0) types.
This will be changed back to "new" when we finish refactoring and
reuse Type_handler::make_table_field() in make_field() in field.cc.
parent 5f1544fe
......@@ -1381,8 +1381,12 @@ Field *Type_handler_timestamp2::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_timestampf(addr.ptr, addr.null_ptr, addr.null_bit,
/*
Will be changed to "new Field_timestampf" when we reuse
make_table_field() for make_field() purposes in field.cc.
*/
return new_Field_timestamp(table->in_use->mem_root,
addr.ptr, addr.null_ptr, addr.null_bit,
Field::NONE, name, table->s, attr.decimals);
}
......@@ -1405,6 +1409,11 @@ Field *Type_handler_date::make_table_field(const LEX_CSTRING *name,
TABLE *table) const
{
/*
DBUG_ASSERT will be removed when we reuse make_table_field()
for make_field() in field.cc
*/
DBUG_ASSERT(0);
return new (table->in_use->mem_root)
Field_date(addr.ptr, addr.null_ptr, addr.null_bit,
Field::NONE, name);
......@@ -1430,8 +1439,12 @@ Field *Type_handler_time2::make_table_field(const LEX_CSTRING *name,
{
return new (table->in_use->mem_root)
Field_timef(addr.ptr, addr.null_ptr, addr.null_bit,
/*
Will be changed to "new Field_timef" when we reuse
make_table_field() for make_field() purposes in field.cc.
*/
return new_Field_time(table->in_use->mem_root,
addr.ptr, addr.null_ptr, addr.null_bit,
Field::NONE, name, attr.decimals);
}
......@@ -1453,8 +1466,12 @@ Field *Type_handler_datetime2::make_table_field(const LEX_CSTRING *name,
const Type_all_attributes &attr,
TABLE *table) const
{
return new (table->in_use->mem_root)
Field_datetimef(addr.ptr, addr.null_ptr, addr.null_bit,
/*
Will be changed to "new Field_datetimef" when we reuse
make_table_field() for make_field() purposes in field.cc.
*/
return new_Field_datetime(table->in_use->mem_root,
addr.ptr, addr.null_ptr, addr.null_bit,
Field::NONE, name, attr.decimals);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment