summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-08-28 15:05:46 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2017-08-28 15:05:46 +0300
commit11352d52cd35f89b1d573405fca92932e112cba9 (patch)
tree77e2880d62fca5c7aa93d4a6bcfa299606e7f831 /sql/sql_table.cc
parent61096ff214dec68a66efb811aa3a70ef49f06a11 (diff)
parent582545a38421ea0e43f326db84550773411c3261 (diff)
downloadmariadb-git-11352d52cd35f89b1d573405fca92932e112cba9.tar.gz
Merge 10.0 into 10.1
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc45
1 files changed, 42 insertions, 3 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 29c382f57d6..a3a7fa2cb44 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7544,9 +7544,25 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
{
if (def->change && ! def->field)
{
- my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change,
- table->s->table_name.str);
- goto err;
+ /*
+ Check if there is modify for newly added field.
+ */
+ Create_field *find;
+ find_it.rewind();
+ while((find=find_it++))
+ {
+ if (!my_strcasecmp(system_charset_info,find->field_name, def->field_name))
+ break;
+ }
+
+ if (find && !find->field)
+ find_it.remove();
+ else
+ {
+ my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change,
+ table->s->table_name.str);
+ goto err;
+ }
}
/*
Check that the DATE/DATETIME not null field we are going to add is
@@ -7612,6 +7628,29 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
find_it.after(def); // Put column after this
}
}
+ /*
+ Check if there is alter for newly added field.
+ */
+ alter_it.rewind();
+ Alter_column *alter;
+ while ((alter=alter_it++))
+ {
+ if (!my_strcasecmp(system_charset_info,def->field_name, alter->name))
+ break;
+ }
+ if (alter)
+ {
+ if (def->sql_type == MYSQL_TYPE_BLOB)
+ {
+ my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), def->change);
+ goto err;
+ }
+ if ((def->def=alter->def)) // Use new default
+ def->flags&= ~NO_DEFAULT_VALUE_FLAG;
+ else
+ def->flags|= NO_DEFAULT_VALUE_FLAG;
+ alter_it.remove();
+ }
}
if (alter_info->alter_list.elements)
{