diff options
author | dlenev@brandersnatch.localdomain <> | 2004-10-01 18:54:06 +0400 |
---|---|---|
committer | dlenev@brandersnatch.localdomain <> | 2004-10-01 18:54:06 +0400 |
commit | 2511990c978137fe0bc81657e160a6d537bc957f (patch) | |
tree | ef52125fb61cc2cbe211c25d6ef541c0ca4cb188 /sql/sql_show.cc | |
parent | d03f447f84936ccd8687d460f23ae020df41b95e (diff) | |
download | mariadb-git-2511990c978137fe0bc81657e160a6d537bc957f.tar.gz |
Support for TIMESTAMP columns holding NULL values. Unlike all other
column types TIMESTAMP is NOT NULL by default, so in order to have
TIMESTAMP column holding NULL valaues you have to specify NULL as
one of its attributes (this needed for backward compatibility).
Main changes:
Replaced TABLE::timestamp_default_now/on_update_now members with
TABLE::timestamp_auto_set_type flag which is used everywhere
for determining if we should auto-set value of TIMESTAMP field
during this operation or not. We are also use Field_timestamp::set_time()
instead of handler::update_timestamp() in handlers.
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fbb45ce2484..7bef2106f11 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -710,10 +710,11 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, protocol->store(field->has_charset() ? field->charset()->name : "NULL", system_charset_info); /* - Altough TIMESTAMP fields can't contain NULL as its value they + Even if TIMESTAMP field can't contain NULL as its value it will accept NULL if you will try to insert such value and will - convert it to current TIMESTAMP. So YES here means that NULL - is allowed for assignment but can't be returned. + convert NULL value to current TIMESTAMP. So YES here means + that NULL is allowed for assignment (but may be won't be + returned). */ pos=(byte*) ((flags & NOT_NULL_FLAG) && field->type() != FIELD_TYPE_TIMESTAMP ? @@ -1291,7 +1292,14 @@ store_create_info(THD *thd, TABLE *table, String *packet) if (flags & NOT_NULL_FLAG) packet->append(" NOT NULL", 9); - + else if (field->type() == FIELD_TYPE_TIMESTAMP) + { + /* + TIMESTAMP field require explicit NULL flag, because unlike + all other fields they are treated as NOT NULL by default. + */ + packet->append(" NULL", 5); + } /* Again we are using CURRENT_TIMESTAMP instead of NOW because it is |