1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-25403 ALTER TABLE wrongly checks for field's default value if AFTER is used

When a column is added to an non-empty table, existing rows will have
a column's default value for existing rows. Or a "zero value" if the
column has no default.

But this check should be skipped when an existing column is altered.
This commit is contained in:
Sergei Golubchik
2021-04-13 19:52:40 +02:00
parent 3ebd6cd3ad
commit 499e617182
3 changed files with 30 additions and 1 deletions

View File

@ -7906,7 +7906,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
def->sql_type == MYSQL_TYPE_NEWDATE ||
def->sql_type == MYSQL_TYPE_DATETIME ||
def->sql_type == MYSQL_TYPE_DATETIME2) &&
!alter_ctx->datetime_field &&
!alter_ctx->datetime_field && !def->field &&
!(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) &&
thd->variables.sql_mode & MODE_NO_ZERO_DATE)
{