~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Stewart.

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
56
56
  char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
57
57
  String tmp_time(time_buff,sizeof(time_buff), &my_charset_utf8_bin);
58
58
  String *time_res= args[0]->val_str(&tmp_time);
59
 
 
60
 
  if (time_res && (time_res != &tmp_time))
61
 
  {
62
 
    tmp_time.copy(*time_res);
63
 
  }
64
 
 
65
 
  if (! temporal_time.from_string(tmp_time.c_ptr(), tmp_time.length()))
 
59
  if (! temporal_time.from_string(time_res->c_ptr(), time_res->length()))
66
60
  {
67
61
    /* 
68
62
     * OK, we failed to match the first argument as a string
88
82
          char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
89
83
          String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
90
84
          String *res= args[0]->val_str(&tmp);
91
 
 
92
 
          if (res && (res != &tmp))
93
 
          {
94
 
            tmp.copy(*res);
95
 
          }
96
 
 
97
 
          if (! temporal_datetime.from_string(tmp.c_ptr(), tmp.length()))
 
85
          if (! temporal_datetime.from_string(res->c_ptr(), res->length()))
98
86
          {
99
87
            /* 
100
88
            * Could not interpret the function argument as a temporal value, 
101
89
            * so throw an error and return 0
102
90
            */
103
 
            my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
91
            my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
104
92
            return 0;
105
93
          }
106
94
        }
122
110
 
123
111
          res= args[0]->val_str(&tmp);
124
112
 
125
 
          if (res && (res != &tmp))
126
 
          {
127
 
            tmp.copy(*res);
128
 
          }
129
 
 
130
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
113
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
131
114
          return 0;
132
115
        }
133
116
    }