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/field.h | |
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/field.h')
-rw-r--r-- | sql/field.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/field.h b/sql/field.h index e12dd60c13b..8432ce02e5e 100644 --- a/sql/field.h +++ b/sql/field.h @@ -676,6 +676,7 @@ public: class Field_timestamp :public Field_str { public: Field_timestamp(char *ptr_arg, uint32 len_arg, + uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, struct st_table *table_arg, CHARSET_INFO *cs); @@ -705,8 +706,11 @@ public: else Field::set_default(); } - inline long get_timestamp() + /* Get TIMESTAMP field value as seconds since begging of Unix Epoch */ + inline long get_timestamp(my_bool *null_value) { + if ((*null_value= is_null())) + return 0; #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) return sint4korr(ptr); @@ -718,7 +722,7 @@ public: bool get_date(TIME *ltime,uint fuzzydate); bool get_time(TIME *ltime); field_cast_enum field_cast_type() { return FIELD_CAST_TIMESTAMP; } - void set_timestamp_offsets(); + timestamp_auto_set_type get_auto_set_type() const; }; |