~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-01-30 04:45:55 UTC
  • mfrom: (779.4.10 devel)
  • mto: (779.7.3 devel)
  • mto: This revision was merged to the branch mainline in revision 823.
  • Revision ID: mordred@inaugust.com-20090130044555-ntb3509c8o6e3sb5
MergedĀ fromĀ me.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
21
22
#include "drizzled/temporal.h"
22
 
#include CSTDINT_H
 
23
#include "drizzled/error.h"
23
24
#include "drizzled/function/time/year.h"
24
 
#include "drizzled/error.h"
25
25
 
26
26
int64_t Item_func_year::val_int()
27
27
{
42
42
  {
43
43
    case STRING_RESULT:
44
44
      {
45
 
        char buff[40];
 
45
        char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
46
46
        String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
47
47
        String *res= args[0]->val_str(&tmp);
48
48
        if (! temporal.from_string(res->c_ptr(), res->length()))
57
57
      }
58
58
      break;
59
59
    case INT_RESULT:
60
 
      if (! temporal.from_int64_t(args[0]->val_int()))
61
 
      {
62
 
        /* 
63
 
        * Could not interpret the function argument as a temporal value, 
64
 
        * so throw an error and return 0
65
 
        */
66
 
        null_value= true;
67
 
        char buff[40];
68
 
        String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
69
 
        String *res;
70
 
 
71
 
        res= args[0]->val_str(&tmp);
72
 
 
73
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
74
 
        return 0;
75
 
      }
76
 
      break;
 
60
      if (temporal.from_int64_t(args[0]->val_int()))
 
61
        break;
 
62
      /* Intentionally fall-through on invalid conversion from integer */
77
63
    default:
78
64
      {
79
65
        /* 
81
67
        * so throw an error and return 0
82
68
        */
83
69
        null_value= true;
84
 
        char buff[40];
 
70
        char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
85
71
        String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
86
72
        String *res;
87
73