~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/datetime.cc

  • Committer: Brian Aker
  • Date: 2010-10-28 17:12:01 UTC
  • mfrom: (1887.1.3 merge)
  • Revision ID: brian@tangent.org-20101028171201-baj6l1bnntn1s4ad
Merge in POTFILES changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
  temporal.to_int64_t(&int_value);
62
62
 
63
63
#ifdef WORDS_BIGENDIAN
64
 
  if (getTable() && getTable()->isDatabaseLowByteFirst())
 
64
  if (getTable() && getTable()->getShare()->db_low_byte_first)
65
65
  {
66
66
    int8store(ptr, int_value);
67
67
  }
111
111
  temporal.to_int64_t(&int_value);
112
112
 
113
113
#ifdef WORDS_BIGENDIAN
114
 
  if (getTable() && getTable()->isDatabaseLowByteFirst())
 
114
  if (getTable() && getTable()->getShare()->db_low_byte_first)
115
115
  {
116
116
    int8store(ptr, int_value);
117
117
  }
121
121
  return 0;
122
122
}
123
123
 
124
 
int Field_datetime::store_time(type::Time &ltime, type::timestamp_t)
 
124
int Field_datetime::store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type)
125
125
{
126
126
  DateTime temporal;
127
127
 
128
 
  temporal.set_years(ltime.year);
129
 
  temporal.set_months(ltime.month);
130
 
  temporal.set_days(ltime.day);
131
 
  temporal.set_hours(ltime.hour);
132
 
  temporal.set_minutes(ltime.minute);
133
 
  temporal.set_seconds(ltime.second);
 
128
  temporal.set_years(ltime->year);
 
129
  temporal.set_months(ltime->month);
 
130
  temporal.set_days(ltime->day);
 
131
  temporal.set_hours(ltime->hour);
 
132
  temporal.set_minutes(ltime->minute);
 
133
  temporal.set_seconds(ltime->second);
134
134
 
135
135
  if (! temporal.is_valid())
136
136
  {
137
 
    char tmp_string[type::Time::MAX_STRING_LENGTH];
 
137
    char tmp_string[MAX_DATE_STRING_REP_LENGTH];
138
138
    size_t tmp_string_len;
139
139
 
140
 
    tmp_string_len= temporal.to_string(tmp_string, type::Time::MAX_STRING_LENGTH);
141
 
    assert(tmp_string_len < type::Time::MAX_STRING_LENGTH);
 
140
    tmp_string_len= temporal.to_string(tmp_string, MAX_DATE_STRING_REP_LENGTH);
 
141
    assert(tmp_string_len < MAX_DATE_STRING_REP_LENGTH);
142
142
    my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp_string);
143
143
    return 1;
144
144
  }
147
147
  temporal.to_int64_t(&int_value);
148
148
 
149
149
#ifdef WORDS_BIGENDIAN
150
 
  if (getTable() && getTable()->isDatabaseLowByteFirst())
 
150
  if (getTable() && getTable()->getShare()->db_low_byte_first)
151
151
  {
152
152
    int8store(ptr, int_value);
153
153
  }
154
154
  else
155
155
#endif
156
156
    int64_tstore(ptr, int_value);
157
 
 
158
157
  return 0;
159
158
}
160
159
 
170
169
  ASSERT_COLUMN_MARKED_FOR_READ;
171
170
 
172
171
#ifdef WORDS_BIGENDIAN
173
 
  if (getTable() && getTable()->isDatabaseLowByteFirst())
 
172
  if (getTable() && getTable()->getShare()->db_low_byte_first)
174
173
    j=sint8korr(ptr);
175
174
  else
176
175
#endif
189
188
  ASSERT_COLUMN_MARKED_FOR_READ;
190
189
 
191
190
#ifdef WORDS_BIGENDIAN
192
 
  if (getTable() && getTable()->isDatabaseLowByteFirst())
 
191
  if (getTable() && getTable()->getShare()->db_low_byte_first)
193
192
    tmp=sint8korr(ptr);
194
193
  else
195
194
#endif
217
216
  return val_buffer;
218
217
}
219
218
 
220
 
bool Field_datetime::get_date(type::Time &ltime, uint32_t fuzzydate)
 
219
bool Field_datetime::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
221
220
{
222
221
  int64_t tmp=Field_datetime::val_int();
223
222
  uint32_t part1,part2;
224
223
  part1=(uint32_t) (tmp/INT64_C(1000000));
225
224
  part2=(uint32_t) (tmp - (uint64_t) part1*INT64_C(1000000));
226
225
 
227
 
  ltime.time_type=      type::DRIZZLE_TIMESTAMP_DATETIME;
228
 
  ltime.neg=            0;
229
 
  ltime.second_part=    0;
230
 
  ltime.second= (int) (part2%100);
231
 
  ltime.minute= (int) (part2/100%100);
232
 
  ltime.hour=           (int) (part2/10000);
233
 
  ltime.day=            (int) (part1%100);
234
 
  ltime.month=  (int) (part1/100%100);
235
 
  ltime.year=           (int) (part1/10000);
236
 
 
237
 
  return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime.month || !ltime.day)) ? 1 : 0;
 
226
  ltime->time_type=     DRIZZLE_TIMESTAMP_DATETIME;
 
227
  ltime->neg=           0;
 
228
  ltime->second_part=   0;
 
229
  ltime->second=        (int) (part2%100);
 
230
  ltime->minute=        (int) (part2/100%100);
 
231
  ltime->hour=          (int) (part2/10000);
 
232
  ltime->day=           (int) (part1%100);
 
233
  ltime->month=         (int) (part1/100%100);
 
234
  ltime->year=          (int) (part1/10000);
 
235
  return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0;
238
236
}
239
237
 
240
 
bool Field_datetime::get_time(type::Time &ltime)
 
238
bool Field_datetime::get_time(DRIZZLE_TIME *ltime)
241
239
{
242
240
  return Field_datetime::get_date(ltime,0);
243
241
}
246
244
{
247
245
  int64_t a,b;
248
246
#ifdef WORDS_BIGENDIAN
249
 
  if (getTable() && getTable()->isDatabaseLowByteFirst())
 
247
  if (getTable() && getTable()->getShare()->db_low_byte_first)
250
248
  {
251
249
    a=sint8korr(a_ptr);
252
250
    b=sint8korr(b_ptr);
264
262
void Field_datetime::sort_string(unsigned char *to,uint32_t )
265
263
{
266
264
#ifdef WORDS_BIGENDIAN
267
 
  if (not getTable() || not getTable()->isDatabaseLowByteFirst())
 
265
  if (!getTable() || !getTable()->getShare()->db_low_byte_first)
268
266
  {
269
267
    to[0] = ptr[0];
270
268
    to[1] = ptr[1];