~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/microsecond.cc

  • Committer: Monty Taylor
  • Date: 2010-08-12 20:27:32 UTC
  • mto: (1720.1.5 build)
  • mto: This revision was merged to the branch mainline in revision 1722.
  • Revision ID: mordred@inaugust.com-20100812202732-9kzchbkvkyki4n3u
Merged libdrizzle directly into tree.

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, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
 
#include <drizzled/temporal.h>
23
 
#include <drizzled/error.h>
24
 
#include <drizzled/function/time/microsecond.h>
 
22
#include "drizzled/temporal.h"
 
23
#include "drizzled/error.h"
 
24
#include "drizzled/function/time/microsecond.h"
25
25
 
26
26
namespace drizzled
27
27
{
57
57
  char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
58
58
  String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
59
59
  String *time_res= args[0]->val_str(&tmp_time);
60
 
 
61
 
  if (time_res && (time_res != &tmp_time))
62
 
  {
63
 
    tmp_time.copy(*time_res);
64
 
  }
65
 
 
66
 
  if (! temporal_time.from_string(tmp_time.c_ptr(), tmp_time.length()))
 
60
  if (! temporal_time.from_string(time_res->c_ptr(), time_res->length()))
67
61
  {
68
62
    /* 
69
63
     * OK, we failed to match the first argument as a string
89
83
          char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
90
84
          String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
91
85
          String *res= args[0]->val_str(&tmp);
92
 
 
93
 
          if (res && (res != &tmp))
94
 
          {
95
 
            tmp.copy(*res);
96
 
          }
97
 
 
98
 
          if (! temporal_datetime.from_string(tmp.c_ptr(), tmp.length()))
 
86
          if (! temporal_datetime.from_string(res->c_ptr(), res->length()))
99
87
          {
100
88
            /* 
101
89
            * Could not interpret the function argument as a temporal value, 
102
90
            * so throw an error and return 0
103
91
            */
104
 
            my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
92
            my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
105
93
            return 0;
106
94
          }
107
95
        }
123
111
 
124
112
          res= args[0]->val_str(&tmp);
125
113
 
126
 
          if (res && (res != &tmp))
127
 
          {
128
 
            tmp.copy(*res);
129
 
          }
130
 
 
131
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
114
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
132
115
          return 0;
133
116
        }
134
117
    }