~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Joe Daly
  • Date: 2010-04-29 03:08:04 UTC
  • mto: This revision was merged to the branch mainline in revision 1523.
  • Revision ID: skinny.moey@gmail.com-20100429030804-ppssp19xwyrgm5of
remove com_stat_vars and rework lock in scoreboard to not lock on Sessions locating a slot they previously owned

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
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
 
#include <drizzled/temporal.h>
23
 
#include <drizzled/error.h>
24
 
#include <drizzled/session.h>
25
 
#include <drizzled/function/time/month.h>
26
 
#include <drizzled/typelib.h>
 
22
#include "drizzled/temporal.h"
 
23
#include "drizzled/error.h"
 
24
#include "drizzled/session.h"
 
25
#include "drizzled/function/time/month.h"
27
26
 
28
27
namespace drizzled
29
28
{
59
58
        char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
60
59
        String tmp(buff,sizeof(buff), &my_charset_utf8_bin);
61
60
        String *res= args[0]->val_str(&tmp);
62
 
 
63
 
        if (res && (res != &tmp))
64
 
        {
65
 
          tmp.copy(*res);
66
 
        }
67
 
 
68
 
        if (! temporal.from_string(tmp.c_ptr(), tmp.length()))
 
61
        if (! temporal.from_string(res->c_ptr(), res->length()))
69
62
        {
70
63
          /* 
71
64
          * Could not interpret the function argument as a temporal value, 
72
65
          * so throw an error and return 0
73
66
          */
74
 
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
67
          my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
75
68
          return 0;
76
69
        }
77
70
      }
93
86
 
94
87
        res= args[0]->val_str(&tmp);
95
88
 
96
 
        if (res && (res != &tmp))
97
 
        {
98
 
          tmp.copy(*res);
99
 
        }
100
 
 
101
 
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
 
89
        my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
102
90
        return 0;
103
91
      }
104
92
  }
117
105
  }
118
106
  const char *month_name;
119
107
  uint32_t   month= (uint) val_int();
 
108
  Session *session= current_session;
120
109
 
121
110
  if (null_value || !month)
122
111
  {
124
113
    return (String*) 0;
125
114
  }
126
115
  null_value=0;
127
 
  month_name= getSession().variables.lc_time_names->month_names->type_names[month-1];
 
116
  month_name= session->variables.lc_time_names->month_names->type_names[month-1];
128
117
  str->set(month_name, strlen(month_name), system_charset_info);
129
118
  return str;
130
119
}