diff options
author | Monty <monty@mariadb.org> | 2015-08-18 00:42:08 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2015-08-18 11:18:57 +0300 |
commit | 6b20342651bb5207b6c125d2d11b664a1bebcc41 (patch) | |
tree | 2f2e6ca60f3e45239224909eed19b907614f5054 /sql/sql_table.cc | |
parent | 92fd65832727162a003647b4c48344dc9567ce84 (diff) | |
download | mariadb-git-6b20342651bb5207b6c125d2d11b664a1bebcc41.tar.gz |
Ensure that fields declared with NOT NULL doesn't have DEFAULT values if not specified and if not timestamp or auto_increment
In original code, sometimes one got an automatic DEFAULT value in some cases, in other cases not.
For example:
create table t1 (a int primary key) - No default
create table t2 (a int, primary key(a)) - DEFAULT 0
create table t1 SELECT .... - Default for all fields, even if they where defined as NOT NULL
ALTER TABLE ... MODIFY could sometimes add an unexpected DEFAULT value.
The patch is quite big because we had some many test cases that used
CREATE ... SELECT or CREATE ... (...PRIMARY KEY(xxx)) which doesn't have an automatic DEFAULT anymore.
Other things:
- Removed warnings from InnoDB when waiting from semaphore (got this when testing things with --big)
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 512c5a355c5..a2cab82de4e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4092,6 +4092,20 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, { Field::utype type= (Field::utype) MTYP_TYPENR(sql_field->unireg_check); + /* + Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and + it is NOT NULL, not an AUTO_INCREMENT field, not a TIMESTAMP and not + updated trough a NOW() function. + */ + if (!sql_field->def && + !sql_field->has_default_function() && + (sql_field->flags & NOT_NULL_FLAG) && + !is_timestamp_type(sql_field->sql_type)) + { + sql_field->flags|= NO_DEFAULT_VALUE_FLAG; + sql_field->pack_flag|= FIELDFLAG_NO_DEFAULT; + } + if (thd->variables.sql_mode & MODE_NO_ZERO_DATE && !sql_field->def && is_timestamp_type(sql_field->sql_type) && |