~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-10-15 00:22:33 UTC
  • mto: (1183.1.11 merge)
  • mto: This revision was merged to the branch mainline in revision 1198.
  • Revision ID: brian@gaz-20091015002233-fa4ao2mbc67wls91
First pass of information engine. OMG, ponies... is it so much easier to
deal with creating and engine.

The list table iterator though... its ass, needs to go. We should also
abstract out share. Very few engines need a custom one. Just say'in

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
22
22
#include "drizzled/temporal.h"
23
23
#include "drizzled/error.h"
24
24
#include "drizzled/session.h"
25
25
#include "drizzled/function/time/month.h"
26
26
 
27
 
namespace drizzled
28
 
{
29
 
 
30
27
int64_t Item_func_month::val_int()
31
28
{
32
29
  assert(fixed);
39
36
  }
40
37
 
41
38
  /* Grab the first argument as a DateTime object */
42
 
  DateTime temporal;
 
39
  drizzled::DateTime temporal;
43
40
  Item_result arg0_result_type= args[0]->result_type();
44
41
  
45
42
  switch (arg0_result_type)
58
55
        char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
59
56
        String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
60
57
        String *res= args[0]->val_str(&tmp);
61
 
 
62
 
        if (res && (res != &tmp))
63
 
        {
64
 
          tmp.copy(*res);
65
 
        }
66
 
 
67
 
        if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
 
58
        if (! temporal.from_string(res->c_ptr(), res->length()))
68
59
        {
69
60
          /* 
70
61
          * Could not interpret the function argument as a temporal value, 
71
62
          * so throw an error and return 0
72
63
          */
73
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
64
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
74
65
          return 0;
75
66
        }
76
67
      }
92
83
 
93
84
        res= args[0]->val_str(&tmp);
94
85
 
95
 
        if (res && (res != &tmp))
96
 
        {
97
 
          tmp.copy(*res);
98
 
        }
99
 
 
100
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
86
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
101
87
        return 0;
102
88
      }
103
89
  }
128
114
  str->set(month_name, strlen(month_name), system_charset_info);
129
115
  return str;
130
116
}
131
 
 
132
 
} /* namespace drizzled */