~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/datetime.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:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
 
21
#include "drizzled/server_includes.h"
22
22
#include "drizzled/field/datetime.h"
23
23
#include "drizzled/error.h"
24
24
#include "drizzled/table.h"
25
25
#include "drizzled/temporal.h"
26
26
#include "drizzled/session.h"
27
27
 
28
 
#include <math.h>
29
 
 
30
28
#include <sstream>
31
29
#include <string>
32
30
 
33
31
 
34
 
namespace drizzled
35
 
{
36
 
 
37
32
/****************************************************************************
38
33
** datetime type
39
34
** In string context: YYYY-MM-DD HH:MM:DD
50
45
   * Try to create a DateTime from the supplied string.  Throw an error
51
46
   * if unable to create a valid DateTime.  
52
47
   */
53
 
  DateTime temporal;
 
48
  drizzled::DateTime temporal;
54
49
  if (! temporal.from_string(from, (size_t) len))
55
50
  {
56
51
    my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), from);
95
90
   * Try to create a DateTime from the supplied integer.  Throw an error
96
91
   * if unable to create a valid DateTime.  
97
92
   */
98
 
  DateTime temporal;
 
93
  drizzled::DateTime temporal;
99
94
  if (! temporal.from_int64_t(from))
100
95
  {
101
96
    /* Convert the integer to a string using stringstream */
128
123
 
129
124
int Field_datetime::store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type)
130
125
{
131
 
  DateTime temporal;
 
126
  drizzled::DateTime temporal;
132
127
 
133
128
  temporal.set_years(ltime->year);
134
129
  temporal.set_months(ltime->month);
186
181
String *Field_datetime::val_str(String *val_buffer,
187
182
                                String *)
188
183
{
189
 
  val_buffer->alloc(DateTime::MAX_STRING_LENGTH);
190
 
  val_buffer->length(DateTime::MAX_STRING_LENGTH);
 
184
  val_buffer->alloc(drizzled::DateTime::MAX_STRING_LENGTH);
 
185
  val_buffer->length(drizzled::DateTime::MAX_STRING_LENGTH);
191
186
  int64_t tmp;
192
187
 
193
188
  ASSERT_COLUMN_MARKED_FOR_READ;
199
194
#endif
200
195
    int64_tget(tmp,ptr);
201
196
 
202
 
  DateTime dt;
 
197
  drizzled::DateTime dt;
203
198
 
204
199
  /* TODO: add an assert that this succeeds
205
200
   * currently fails due to bug in allowing
213
208
                               */
214
209
 
215
210
  int rlen;
216
 
  rlen= dt.to_string((char*)val_buffer->ptr(), DateTime::MAX_STRING_LENGTH);
217
 
  assert((rlen+1) <  DateTime::MAX_STRING_LENGTH);
 
211
  rlen= dt.to_string((char*)val_buffer->ptr(), drizzled::DateTime::MAX_STRING_LENGTH);
 
212
  assert((rlen+1) <  drizzled::DateTime::MAX_STRING_LENGTH);
218
213
 
219
214
  val_buffer->length(rlen);
220
215
 
298
293
  res.set_ascii(STRING_WITH_LEN("datetime"));
299
294
}
300
295
 
301
 
} /* namespace drizzled */