1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +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:
Sergei Golubchik
2016-12-30 13:03:47 +01:00
parent 588eca31e3
commit cd4dd2b62d
8 changed files with 63 additions and 26 deletions

View File

@@ -954,7 +954,7 @@ public:
{
return bitmap_is_set(&table->has_value_set, field_index);
}
virtual void set_explicit_default(Item *value);
virtual bool set_explicit_default(Item *value);
/**
Evaluates the @c UPDATE default function, if one exists, and stores the
@@ -2379,9 +2379,9 @@ public:
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
bool zero_pack() const { return 0; }
virtual int set_time();
virtual void set_explicit_default(Item *value);
virtual int evaluate_update_default_function()
int set_time();
bool set_explicit_default(Item *value);
int evaluate_update_default_function()
{
int res= 0;
if (has_update_default_function())
@@ -2813,8 +2813,8 @@ public:
void sql_type(String &str) const;
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ return Field_datetime::get_TIME(ltime, ptr, fuzzydate); }
virtual int set_time();
virtual int evaluate_update_default_function()
int set_time();
int evaluate_update_default_function()
{
int res= 0;
if (has_update_default_function())