~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:18:23 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051823-14fyn2kvg8pc5a15
\r and trailing whitespace removed.

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 buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
58
58
        String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
59
59
        String *res= args[0]->val_str(&tmp);
60
 
        if (! temporal.from_string(res->c_ptr(), res->length()))
 
60
 
 
61
        if (res && (res != &tmp))
 
62
        {
 
63
          tmp.copy(*res);
 
64
        }
 
65
 
 
66
        if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
61
67
        {
62
68
          /* 
63
69
          * Could not interpret the function argument as a temporal value, 
64
70
          * so throw an error and return 0
65
71
          */
66
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
 
72
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
67
73
          return 0;
68
74
        }
69
75
      }
85
91
 
86
92
        res= args[0]->val_str(&tmp);
87
93
 
88
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
 
94
        if (res && (res != &tmp))
 
95
        {
 
96
          tmp.copy(*res);
 
97
        }
 
98
 
 
99
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
89
100
        return 0;
90
101
      }
91
102
  }