~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/datetime.cc

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 MySQL
33
33
****************************************************************************/
34
34
 
35
35
int Field_datetime::store(const char *from,
36
 
                          uint len,
 
36
                          uint32_t len,
37
37
                          const CHARSET_INFO * const cs __attribute__((unused)))
38
38
{
39
39
  DRIZZLE_TIME time_tmp;
98
98
                                          (MODE_NO_ZERO_DATE |
99
99
                                           MODE_INVALID_DATES))), &error);
100
100
 
101
 
  if (nr == -1LL)
 
101
  if (nr == INT64_C(-1))
102
102
  {
103
103
    nr= 0;
104
104
    error= 2;
122
122
}
123
123
 
124
124
 
125
 
int Field_datetime::store_time(DRIZZLE_TIME *ltime,timestamp_type time_type)
 
125
int Field_datetime::store_time(DRIZZLE_TIME *ltime,
 
126
                               enum enum_drizzle_timestamp_type time_type)
126
127
{
127
128
  int64_t tmp;
128
129
  int error= 0;
133
134
  if (time_type == DRIZZLE_TIMESTAMP_DATE ||
134
135
      time_type == DRIZZLE_TIMESTAMP_DATETIME)
135
136
  {
136
 
    tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*1000000LL+
 
137
    tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*INT64_C(1000000)+
137
138
         (ltime->hour*10000L+ltime->minute*100+ltime->second));
138
139
    if (check_date(ltime, tmp != 0,
139
140
                   (TIME_FUZZY_DATE |
211
212
    Avoid problem with slow int64_t arithmetic and sprintf
212
213
  */
213
214
 
214
 
  part1=(long) (tmp/1000000LL);
215
 
  part2=(long) (tmp - (uint64_t) part1*1000000LL);
 
215
  part1=(long) (tmp/INT64_C(1000000));
 
216
  part2=(long) (tmp - (uint64_t) part1*INT64_C(1000000));
216
217
 
217
218
  pos=(char*) val_buffer->ptr() + MAX_DATETIME_WIDTH;
218
219
  *pos--=0;
238
239
  return val_buffer;
239
240
}
240
241
 
241
 
bool Field_datetime::get_date(DRIZZLE_TIME *ltime, uint fuzzydate)
 
242
bool Field_datetime::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
242
243
{
243
244
  int64_t tmp=Field_datetime::val_int();
244
245
  uint32_t part1,part2;
245
 
  part1=(uint32_t) (tmp/1000000LL);
246
 
  part2=(uint32_t) (tmp - (uint64_t) part1*1000000LL);
 
246
  part1=(uint32_t) (tmp/INT64_C(1000000));
 
247
  part2=(uint32_t) (tmp - (uint64_t) part1*INT64_C(1000000));
247
248
 
248
249
  ltime->time_type=     DRIZZLE_TIMESTAMP_DATETIME;
249
250
  ltime->neg=           0;
262
263
  return Field_datetime::get_date(ltime,0);
263
264
}
264
265
 
265
 
int Field_datetime::cmp(const uchar *a_ptr, const uchar *b_ptr)
 
266
int Field_datetime::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
266
267
{
267
268
  int64_t a,b;
268
269
#ifdef WORDS_BIGENDIAN
281
282
    ((uint64_t) a > (uint64_t) b) ? 1 : 0;
282
283
}
283
284
 
284
 
void Field_datetime::sort_string(uchar *to,uint length __attribute__((unused)))
 
285
void Field_datetime::sort_string(unsigned char *to,uint32_t length __attribute__((unused)))
285
286
{
286
287
#ifdef WORDS_BIGENDIAN
287
288
  if (!table || !table->s->db_low_byte_first)