~drizzle-trunk/drizzle/development

« back to all changes in this revision

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