1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 MySQL
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLE_SERVER_FIELD_TIMESTAMP
22
#define DRIZZLE_SERVER_FIELD_TIMESTAMP
24
#include "mysql_priv.h"
26
class Field_timestamp :public Field_str {
28
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
29
uchar *null_ptr_arg, uchar null_bit_arg,
30
enum utype unireg_check_arg, const char *field_name_arg,
31
TABLE_SHARE *share, CHARSET_INFO *cs);
32
Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
34
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
35
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
36
enum Item_result cmp_type () const { return INT_RESULT; }
37
int store(const char *to,uint length,CHARSET_INFO *charset);
39
int store(int64_t nr, bool unsigned_val);
40
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
41
double val_real(void);
42
int64_t val_int(void);
43
String *val_str(String*,String *);
44
bool send_binary(Protocol *protocol);
45
int cmp(const uchar *,const uchar *);
46
void sort_string(uchar *buff,uint length);
47
uint32 pack_length() const { return 4; }
48
void sql_type(String &str) const;
49
bool can_be_compared_as_int64_t() const { return true; }
50
bool zero_pack() const { return 0; }
52
virtual void set_default()
54
if (table->timestamp_field == this &&
55
unireg_check != TIMESTAMP_UN_FIELD)
60
/* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
61
inline long get_timestamp(my_bool *null_value)
63
if ((*null_value= is_null()))
65
#ifdef WORDS_BIGENDIAN
66
if (table && table->s->db_low_byte_first)
67
return sint4korr(ptr);
73
inline void store_timestamp(my_time_t timestamp)
75
#ifdef WORDS_BIGENDIAN
76
if (table && table->s->db_low_byte_first)
78
int4store(ptr,timestamp);
82
longstore(ptr,(uint32) timestamp);
84
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
85
bool get_time(MYSQL_TIME *ltime);
86
timestamp_auto_set_type get_auto_set_type() const;