diff options
author | unknown <dlenev@mysql.com> | 2004-10-04 17:16:49 +0400 |
---|---|---|
committer | unknown <dlenev@mysql.com> | 2004-10-04 17:16:49 +0400 |
commit | 6ef00f96b1a0840e9cd79b2dab9ea64be0f8e568 (patch) | |
tree | 94cc80e384efd56f1a5c0ea3f44d8bbc3ac52d4a /sql | |
parent | 78d27d3e1bc819be002a77a1f16b751e78f6c8b6 (diff) | |
parent | 2cb2efc261936a2c24db28eb4597fbcb5078d698 (diff) | |
download | mariadb-git-6ef00f96b1a0840e9cd79b2dab9ea64be0f8e568.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/dlenev/src/mysql-4.1-ryan
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_parse.cc | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e8441c05609..34cad1b062d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4142,12 +4142,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, } else if (default_value->type() == Item::NULL_ITEM) { - /* - TIMESTAMP type should be able to distingush non-specified default - value and default value NULL later. - */ - if (type != FIELD_TYPE_TIMESTAMP) - default_value= 0; + default_value= 0; if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG) { @@ -4357,19 +4352,27 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, else new_field->unireg_check= (on_update_value?Field::TIMESTAMP_UN_FIELD: Field::NONE); - - if (default_value->type() == Item::NULL_ITEM) - new_field->def= 0; } else { - /* - We are setting TIMESTAMP_OLD_FIELD here only temporary, we will - replace this value by TIMESTAMP_DNUN_FIELD or NONE later when + /* + If we have default TIMESTAMP NOT NULL column without explicit DEFAULT + or ON UPDATE values then for the sake of compatiblity we should treat + this column as having DEFAULT NOW() ON UPDATE NOW() (when we don't + have another TIMESTAMP column with auto-set option before this one) + or DEFAULT 0 (in other cases). + So here we are setting TIMESTAMP_OLD_FIELD only temporary, and will + replace this value by TIMESTAMP_DNUN_FIELD or NONE later when information about all TIMESTAMP fields in table will be availiable. + + If we have TIMESTAMP NULL column without explicit DEFAULT value + we treat it as having DEFAULT NULL attribute. */ - new_field->unireg_check= on_update_value?Field::TIMESTAMP_UN_FIELD: - Field::TIMESTAMP_OLD_FIELD; + new_field->unireg_check= on_update_value ? + Field::TIMESTAMP_UN_FIELD : + (new_field->flags & NOT_NULL_FLAG ? + Field::TIMESTAMP_OLD_FIELD: + Field::NONE); } break; case FIELD_TYPE_DATE: // Old date type |