mirror of
https://github.com/MariaDB/server.git
synced 2025-08-31 22:22:30 +03:00
Support for TIMESTAMP columns holding NULL values. Unlike all other
column types TIMESTAMP is NOT NULL by default, so in order to have TIMESTAMP column holding NULL valaues you have to specify NULL as one of its attributes (this needed for backward compatibility). Main changes: Replaced TABLE::timestamp_default_now/on_update_now members with TABLE::timestamp_auto_set_type flag which is used everywhere for determining if we should auto-set value of TIMESTAMP field during this operation or not. We are also use Field_timestamp::set_time() instead of handler::update_timestamp() in handlers.
This commit is contained in:
@@ -4142,7 +4142,12 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
|
||||
}
|
||||
else if (default_value->type() == Item::NULL_ITEM)
|
||||
{
|
||||
default_value=0;
|
||||
/*
|
||||
TIMESTAMP type should be able to distingush non-specified default
|
||||
value and default value NULL later.
|
||||
*/
|
||||
if (type != FIELD_TYPE_TIMESTAMP)
|
||||
default_value= 0;
|
||||
if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) ==
|
||||
NOT_NULL_FLAG)
|
||||
{
|
||||
@@ -4334,7 +4339,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
|
||||
new_field->length=((new_field->length+1)/2)*2; /* purecov: inspected */
|
||||
new_field->length= min(new_field->length,14); /* purecov: inspected */
|
||||
}
|
||||
new_field->flags|= ZEROFILL_FLAG | UNSIGNED_FLAG | NOT_NULL_FLAG;
|
||||
new_field->flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
|
||||
if (default_value)
|
||||
{
|
||||
/* Grammar allows only NOW() value for ON UPDATE clause */
|
||||
@@ -4352,6 +4357,9 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type,
|
||||
else
|
||||
new_field->unireg_check= (on_update_value?Field::TIMESTAMP_UN_FIELD:
|
||||
Field::NONE);
|
||||
|
||||
if (default_value->type() == Item::NULL_ITEM)
|
||||
new_field->def= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user