mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4)
Optionally do table->update_default_fields() even for INSERT that supposedly provides values for all column. Because these "values" might be DEFAULT, which would need table->update_default_fields() at the end. Also set Item_default_value::used_tables() from the default expression. Non-zero used_field() means that mysql_insert() will initialize all fields to their default values (with restore_record()) even if all columns are later provided with values. Because default expressions may refer to other columns and they must be initialized.
This commit is contained in:
11
sql/field.cc
11
sql/field.cc
@ -5264,6 +5264,7 @@ int Field_timestamp::set_time()
|
||||
Mark the field as having an explicit default value.
|
||||
|
||||
@param value if available, the value that the field is being set to
|
||||
@returns whether the explicit default bit was set
|
||||
|
||||
@note
|
||||
Fields that have an explicit default value should not be updated
|
||||
@ -5279,13 +5280,14 @@ int Field_timestamp::set_time()
|
||||
This is how MySQL has worked since it's start.
|
||||
*/
|
||||
|
||||
void Field_timestamp::set_explicit_default(Item *value)
|
||||
bool Field_timestamp::set_explicit_default(Item *value)
|
||||
{
|
||||
if (((value->type() == Item::DEFAULT_VALUE_ITEM &&
|
||||
!((Item_default_value*)value)->arg) ||
|
||||
(!maybe_null() && value->null_value)))
|
||||
return;
|
||||
return false;
|
||||
set_has_explicit_value();
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
@ -10790,12 +10792,13 @@ key_map Field::get_possible_keys()
|
||||
analyzed to check if it really should count as a value.
|
||||
*/
|
||||
|
||||
void Field::set_explicit_default(Item *value)
|
||||
bool Field::set_explicit_default(Item *value)
|
||||
{
|
||||
if (value->type() == Item::DEFAULT_VALUE_ITEM &&
|
||||
!((Item_default_value*)value)->arg)
|
||||
return;
|
||||
return false;
|
||||
set_has_explicit_value();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user