~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/date.cc

  • Committer: Monty Taylor
  • Date: 2008-08-09 02:24:34 UTC
  • mto: (266.1.8 codestyle)
  • mto: This revision was merged to the branch mainline in revision 279.
  • Revision ID: monty@inaugust.com-20080809022434-97na8pnugghskxip
Removed mystringslt conv lib and replaced it with a noinst lib.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 MySQL
51
51
*/
52
52
 
53
53
int Field_newdate::store(const char *from,
54
 
                         uint32_t len,
 
54
                         uint len,
55
55
                         const CHARSET_INFO * const cs __attribute__((unused)))
56
56
{
57
57
  long tmp;
62
62
  if ((ret= str_to_datetime(from, len, &l_time,
63
63
                            (TIME_FUZZY_DATE |
64
64
                             (thd->variables.sql_mode &
65
 
                              (MODE_NO_ZERO_DATE | MODE_INVALID_DATES))),
 
65
                              (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
 
66
                               MODE_INVALID_DATES))),
66
67
                            &error)) <= DRIZZLE_TIMESTAMP_ERROR)
67
68
  {
68
69
    tmp= 0;
110
111
  if (number_to_datetime(nr, &l_time,
111
112
                         (TIME_FUZZY_DATE |
112
113
                          (thd->variables.sql_mode &
113
 
                           (MODE_NO_ZERO_DATE | MODE_INVALID_DATES))),
114
 
                         &error) == INT64_C(-1))
 
114
                           (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
 
115
                            MODE_INVALID_DATES))),
 
116
                         &error) == -1LL)
115
117
  {
116
118
    tmp= 0L;
117
119
    error= 2;
135
137
}
136
138
 
137
139
 
138
 
int Field_newdate::store_time(DRIZZLE_TIME *ltime,
139
 
                              enum enum_drizzle_timestamp_type time_type)
 
140
int Field_newdate::store_time(DRIZZLE_TIME *ltime,timestamp_type time_type)
140
141
{
141
142
  long tmp;
142
143
  int error= 0;
147
148
    if (check_date(ltime, tmp != 0,
148
149
                   (TIME_FUZZY_DATE |
149
150
                    (current_thd->variables.sql_mode &
150
 
                     (MODE_NO_ZERO_DATE | MODE_INVALID_DATES))), &error))
 
151
                     (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE |
 
152
                      MODE_INVALID_DATES))), &error))
151
153
    {
152
154
      char buff[MAX_DATE_STRING_REP_LENGTH];
153
 
      String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
155
      String str(buff, sizeof(buff), &my_charset_latin1);
154
156
      make_date((DATE_TIME_FORMAT *) 0, ltime, &str);
155
157
      set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
156
158
                           str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
159
161
        (ltime->hour || ltime->minute || ltime->second || ltime->second_part))
160
162
    {
161
163
      char buff[MAX_DATE_STRING_REP_LENGTH];
162
 
      String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
 
164
      String str(buff, sizeof(buff), &my_charset_latin1);
163
165
      make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str);
164
166
      set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE,
165
167
                           ER_WARN_DATA_TRUNCATED,
194
196
 
195
197
int64_t Field_newdate::val_int(void)
196
198
{
197
 
  uint32_t j= uint3korr(ptr);
 
199
  ulong j= uint3korr(ptr);
198
200
  j= (j % 32L)+(j / 32L % 16L)*100L + (j/(16L*32L))*10000L;
199
201
  return (int64_t) j;
200
202
}
228
230
}
229
231
 
230
232
 
231
 
bool Field_newdate::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
233
bool Field_newdate::get_date(DRIZZLE_TIME *ltime,uint fuzzydate)
232
234
{
233
235
  uint32_t tmp=(uint32_t) uint3korr(ptr);
234
236
  ltime->day=   tmp & 31;
247
249
}
248
250
 
249
251
 
250
 
int Field_newdate::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)
 
252
int Field_newdate::cmp(const uchar *a_ptr, const uchar *b_ptr)
251
253
{
252
254
  uint32_t a,b;
253
255
  a=(uint32_t) uint3korr(a_ptr);
256
258
}
257
259
 
258
260
 
259
 
void Field_newdate::sort_string(unsigned char *to,uint32_t length __attribute__((unused)))
 
261
void Field_newdate::sort_string(uchar *to,uint length __attribute__((unused)))
260
262
{
261
263
  to[0] = ptr[2];
262
264
  to[1] = ptr[1];