~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/temporal_interval.cc

  • Committer: Andrew Hutchings
  • Date: 2011-01-21 11:23:19 UTC
  • mto: (2100.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2101.
  • Revision ID: andrew@linuxjedi.co.uk-20110121112319-nj1cvg0yt3nnf2rr
Add errors page to drizzle client docs
Add link to specific error in migration docs
Minor changes to migration docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
186
186
  return false;
187
187
}
188
188
 
189
 
bool TemporalInterval::addDate(DRIZZLE_TIME *ltime, interval_type int_type)
 
189
bool TemporalInterval::addDate(type::Time *ltime, interval_type int_type)
190
190
{
191
191
  long period, sign;
192
192
 
211
211
  case INTERVAL_DAY_MINUTE:
212
212
  case INTERVAL_DAY_HOUR:
213
213
    int64_t sec, days, daynr, microseconds, extra_sec;
214
 
    ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME; // Return full date
 
214
    ltime->time_type= type::DRIZZLE_TIMESTAMP_DATETIME; // Return full date
215
215
    microseconds= ltime->second_part + sign*second_part;
216
216
    extra_sec= microseconds/1000000L;
217
217
    microseconds= microseconds%1000000L;
241
241
    /* Day number from year 0 to 9999-12-31 */
242
242
    if ((uint64_t) daynr > MAX_DAY_NUMBER)
243
243
      goto invalid_date;
244
 
    get_date_from_daynr((long) daynr, &ltime->year, &ltime->month,
245
 
        &ltime->day);
 
244
    get_date_from_daynr((long) daynr, &ltime->year, &ltime->month, &ltime->day);
246
245
    break;
247
246
  case INTERVAL_DAY:
248
247
  case INTERVAL_WEEK:
311
310
    const char *start= str;
312
311
    for (value= 0 ; str != end && my_isdigit(cs,*str) ; str++)
313
312
      value= value * 10L + (int64_t) (*str - '0');
314
 
    if (transform_msec && x == count - 1) // microseconds always last
 
313
    if (transform_msec && (x == count - 1 || str == end)) // microseconds always last
315
314
    {
316
315
      long msec_length= 6 - (str - start);
317
316
      if (msec_length > 0)
323
322
    if (str == end && x != count-1)
324
323
    {
325
324
      x++;
326
 
      /* Change values[0...x-1] -> values[0...count-1] */
 
325
      /* Change values[0...x-1] -> values[count-x...count-1] */
327
326
      internal::bmove_upp((unsigned char*) (values+count),
328
327
                          (unsigned char*) (values+x),
329
328
                          sizeof(*values)*x);