~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/timestamp.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include "config.h"
 
22
#include <drizzled/server_includes.h>
23
23
#include <drizzled/field/timestamp.h>
24
24
#include <drizzled/error.h>
25
25
#include <drizzled/tztime.h>
26
26
#include <drizzled/table.h>
27
27
#include <drizzled/session.h>
28
28
 
29
 
#include <math.h>
30
 
 
31
 
#include <sstream>
32
 
 
33
29
#include "drizzled/temporal.h"
34
30
 
35
 
namespace drizzled
36
 
{
37
31
 
38
32
/**
39
33
  TIMESTAMP type holds datetime values in range from 1970-01-01 00:00:01 UTC to
79
73
  exception is different behavior of old/new timestamps during ALTER TABLE.
80
74
 */
81
75
Field_timestamp::Field_timestamp(unsigned char *ptr_arg,
82
 
                                 uint32_t,
83
 
                                 unsigned char *null_ptr_arg,
84
 
                                 unsigned char null_bit_arg,
 
76
                                 uint32_t ,
 
77
                                 unsigned char *null_ptr_arg, unsigned char null_bit_arg,
85
78
                                 enum utype unireg_check_arg,
86
79
                                 const char *field_name_arg,
87
80
                                 TableShare *share,
88
81
                                 const CHARSET_INFO * const cs)
89
82
  :Field_str(ptr_arg,
90
 
             DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
91
 
             null_ptr_arg,
92
 
             null_bit_arg,
93
 
             field_name_arg,
94
 
             cs)
 
83
             drizzled::DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
 
84
             null_ptr_arg, null_bit_arg,
 
85
             unireg_check_arg, field_name_arg, cs)
95
86
{
96
87
  /* For 4.0 MYD and 4.0 InnoDB compatibility */
97
88
  flags|= UNSIGNED_FLAG;
98
 
  unireg_check= unireg_check_arg;
99
 
  if (! share->timestamp_field && unireg_check != NONE)
 
89
  if (!share->timestamp_field && unireg_check != NONE)
100
90
  {
101
91
    /* This timestamp has auto-update */
102
92
    share->timestamp_field= this;
109
99
Field_timestamp::Field_timestamp(bool maybe_null_arg,
110
100
                                 const char *field_name_arg,
111
101
                                 const CHARSET_INFO * const cs)
112
 
  :Field_str((unsigned char*) NULL,
113
 
             DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
114
 
             maybe_null_arg ? (unsigned char*) "": 0,
115
 
             0,
116
 
             field_name_arg,
117
 
             cs)
 
102
  :Field_str((unsigned char*) 0,
 
103
             drizzled::DateTime::MAX_STRING_LENGTH - 1 /* no \0 */,
 
104
             maybe_null_arg ? (unsigned char*) "": 0, 0,
 
105
             NONE, field_name_arg, cs)
118
106
{
119
107
  /* For 4.0 MYD and 4.0 InnoDB compatibility */
120
108
  flags|= UNSIGNED_FLAG;
121
 
  if (unireg_check != TIMESTAMP_DN_FIELD)
122
 
    flags|= ON_UPDATE_NOW_FLAG;
 
109
    if (unireg_check != TIMESTAMP_DN_FIELD)
 
110
      flags|= ON_UPDATE_NOW_FLAG;
123
111
}
124
112
 
125
113
/**
160
148
                           uint32_t len,
161
149
                           const CHARSET_INFO * const )
162
150
{
163
 
  Timestamp temporal;
 
151
  drizzled::Timestamp temporal;
164
152
 
165
153
  ASSERT_COLUMN_MARKED_FOR_WRITE;
166
154
 
203
191
   * Try to create a DateTime from the supplied integer.  Throw an error
204
192
   * if unable to create a valid DateTime.  
205
193
   */
206
 
  Timestamp temporal;
 
194
  drizzled::Timestamp temporal;
207
195
  if (! temporal.from_int64_t(from))
208
196
  {
209
197
    /* Convert the integer to a string using stringstream */
240
228
#endif
241
229
    longget(temp, ptr);
242
230
 
243
 
  Timestamp temporal;
 
231
  drizzled::Timestamp temporal;
244
232
  (void) temporal.from_time_t((time_t) temp);
245
233
 
246
234
  /* We must convert into a "timestamp-formatted integer" ... */
267
255
 
268
256
  val_buffer->set_charset(&my_charset_bin);     /* Safety */
269
257
 
270
 
  Timestamp temporal;
 
258
  drizzled::Timestamp temporal;
271
259
  (void) temporal.from_time_t((time_t) temp);
272
260
 
273
261
  int rlen;
291
279
  
292
280
  memset(ltime, 0, sizeof(*ltime));
293
281
 
294
 
  Timestamp temporal;
 
282
  drizzled::Timestamp temporal;
295
283
  (void) temporal.from_time_t((time_t) temp);
296
284
 
297
285
  /* @TODO Goodbye the below code when DRIZZLE_TIME is finally gone.. */
397
385
#endif
398
386
    longstore(ptr,(uint32_t) timestamp);
399
387
}
400
 
 
401
 
} /* namespace drizzled */