~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/datetime.cc

  • Committer: Brian Aker
  • Date: 2010-08-03 19:24:14 UTC
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: brian@gaz-20100803192414-jk20j0u6cnze3ja6
Do comparison via non-case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
#include "config.h"
22
 
#include <boost/lexical_cast.hpp>
23
22
#include "drizzled/field/datetime.h"
24
23
#include "drizzled/error.h"
25
24
#include "drizzled/table.h"
39
38
** datetime type
40
39
** In string context: YYYY-MM-DD HH:MM:DD
41
40
** In number context: YYYYMMDDHHMMDD
 
41
** Stored as a 8 byte unsigned int. Should sometimes be change to a 6 byte int.
42
42
****************************************************************************/
43
43
 
44
44
int Field_datetime::store(const char *from,
61
61
  temporal.to_int64_t(&int_value);
62
62
 
63
63
#ifdef WORDS_BIGENDIAN
64
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
64
  if (getTable() && getTable()->s->db_low_byte_first)
65
65
  {
66
66
    int8store(ptr, int_value);
67
67
  }
76
76
  ASSERT_COLUMN_MARKED_FOR_WRITE;
77
77
  if (from < 0.0 || from > 99991231235959.0)
78
78
  {
79
 
    /* Convert the double to a string using boost::lexical_cast */
80
 
    std::string tmp(boost::lexical_cast<std::string>(from));
 
79
    /* Convert the double to a string using stringstream */
 
80
    std::stringstream ss;
 
81
    std::string tmp;
 
82
    ss.precision(18); /* 18 places should be fine for error display of double input. */
 
83
    ss << from; ss >> tmp;
81
84
 
82
85
    my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
83
86
    return 2;
95
98
  DateTime temporal;
96
99
  if (! temporal.from_int64_t(from))
97
100
  {
98
 
    /* Convert the integer to a string using boost::lexical_cast */
99
 
    std::string tmp(boost::lexical_cast<std::string>(from));
 
101
    /* Convert the integer to a string using stringstream */
 
102
    std::stringstream ss;
 
103
    std::string tmp;
 
104
    ss << from; ss >> tmp;
100
105
 
101
106
    my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
102
107
    return 2;
111
116
  temporal.to_int64_t(&int_value);
112
117
 
113
118
#ifdef WORDS_BIGENDIAN
114
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
119
  if (getTable() && getTable()->s->db_low_byte_first)
115
120
  {
116
121
    int8store(ptr, int_value);
117
122
  }
147
152
  temporal.to_int64_t(&int_value);
148
153
 
149
154
#ifdef WORDS_BIGENDIAN
150
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
155
  if (getTable() && getTable()->s->db_low_byte_first)
151
156
  {
152
157
    int8store(ptr, int_value);
153
158
  }
169
174
  ASSERT_COLUMN_MARKED_FOR_READ;
170
175
 
171
176
#ifdef WORDS_BIGENDIAN
172
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
177
  if (getTable() && getTable()->s->db_low_byte_first)
173
178
    j=sint8korr(ptr);
174
179
  else
175
180
#endif
188
193
  ASSERT_COLUMN_MARKED_FOR_READ;
189
194
 
190
195
#ifdef WORDS_BIGENDIAN
191
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
196
  if (getTable() && getTable()->s->db_low_byte_first)
192
197
    tmp=sint8korr(ptr);
193
198
  else
194
199
#endif
202
207
   * not null without a default value.
203
208
   */
204
209
  dt.from_int64_t(tmp, false); /* NOTE: this does *NOT* attempt convertion
205
 
                                 from formats such as 20090101 as
206
 
                                 the stored value has already been
207
 
                                 converted.
208
 
                               */
 
210
                                        from formats such as 20090101 as
 
211
                                        the stored value has already been
 
212
                                        converted.
 
213
                               */
209
214
 
210
215
  int rlen;
211
216
  rlen= dt.to_string((char*)val_buffer->ptr(), DateTime::MAX_STRING_LENGTH);
244
249
{
245
250
  int64_t a,b;
246
251
#ifdef WORDS_BIGENDIAN
247
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
252
  if (getTable() && getTable()->s->db_low_byte_first)
248
253
  {
249
254
    a=sint8korr(a_ptr);
250
255
    b=sint8korr(b_ptr);
262
267
void Field_datetime::sort_string(unsigned char *to,uint32_t )
263
268
{
264
269
#ifdef WORDS_BIGENDIAN
265
 
  if (!getTable() || !getTable()->getShare()->db_low_byte_first)
 
270
  if (!getTable() || !getTable()->s->db_low_byte_first)
266
271
  {
267
272
    to[0] = ptr[0];
268
273
    to[1] = ptr[1];