~drizzle-trunk/drizzle/development

173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 MySQL
5
 *
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.
10
 *
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.
15
 *
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
19
 */
20
21
#ifndef DRIZZLE_SERVER_FIELD_TIMESTAMP
22
#define DRIZZLE_SERVER_FIELD_TIMESTAMP
23
24
class Field_timestamp :public Field_str {
25
public:
205 by Brian Aker
uint32 -> uin32_t
26
  Field_timestamp(uchar *ptr_arg, uint32_t len_arg,
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
27
                  uchar *null_ptr_arg, uchar null_bit_arg,
28
		  enum utype unireg_check_arg, const char *field_name_arg,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
29
		  TABLE_SHARE *share, const CHARSET_INFO * const cs);
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
30
  Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
31
		  const CHARSET_INFO * const cs);
212.2.2 by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE
32
  enum_field_types type() const { return DRIZZLE_TYPE_TIMESTAMP;}
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
33
  enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
34
  enum Item_result cmp_type () const { return INT_RESULT; }
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
35
  int  store(const char *to,uint length, const CHARSET_INFO * const charset);
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
36
  int  store(double nr);
37
  int  store(int64_t nr, bool unsigned_val);
38
  int  reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
39
  double val_real(void);
40
  int64_t val_int(void);
41
  String *val_str(String*,String *);
42
  bool send_binary(Protocol *protocol);
43
  int cmp(const uchar *,const uchar *);
44
  void sort_string(uchar *buff,uint length);
205 by Brian Aker
uint32 -> uin32_t
45
  uint32_t pack_length() const { return 4; }
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
46
  void sql_type(String &str) const;
47
  bool can_be_compared_as_int64_t() const { return true; }
48
  bool zero_pack() const { return 0; }
49
  void set_time();
50
  virtual void set_default()
51
  {
52
    if (table->timestamp_field == this &&
53
        unireg_check != TIMESTAMP_UN_FIELD)
54
      set_time();
55
    else
56
      Field::set_default();
57
  }
58
  /* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
275 by Brian Aker
Full removal of my_bool from central server.
59
  inline long get_timestamp(bool *null_value)
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
60
  {
61
    if ((*null_value= is_null()))
62
      return 0;
63
#ifdef WORDS_BIGENDIAN
64
    if (table && table->s->db_low_byte_first)
65
      return sint4korr(ptr);
66
#endif
67
    long tmp;
68
    longget(tmp,ptr);
69
    return tmp;
70
  }
71
  inline void store_timestamp(my_time_t timestamp)
72
  {
73
#ifdef WORDS_BIGENDIAN
74
    if (table && table->s->db_low_byte_first)
75
    {
76
      int4store(ptr,timestamp);
77
    }
78
    else
79
#endif
205 by Brian Aker
uint32 -> uin32_t
80
      longstore(ptr,(uint32_t) timestamp);
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
81
  }
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
82
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
83
  bool get_time(DRIZZLE_TIME *ltime);
173.1.6 by Toru Maesaka
ripped out TIMESTAMP and move to field/
84
  timestamp_auto_set_type get_auto_set_type() const;
85
};
86
87
#endif
88