~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/datetime.cc

  • Committer: Monty Taylor
  • Date: 2011-01-26 19:15:55 UTC
  • mto: This revision was merged to the branch mainline in revision 2126.
  • Revision ID: mordred@inaugust.com-20110126191555-nq5nnzyscvngsip2
Turns on -fvisibility=hidden by default. Symbols intended to be used by
plugins need to be marked with DRIZZLED_API.

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()->getShare()->db_low_byte_first)
 
64
  if (getTable() && getTable()->isDatabaseLowByteFirst())
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()->getShare()->db_low_byte_first)
 
114
  if (getTable() && getTable()->isDatabaseLowByteFirst())
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, enum enum_drizzle_timestamp_type)
 
124
int Field_datetime::store_time(type::Time &ltime, type::timestamp_t)
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[MAX_DATE_STRING_REP_LENGTH];
 
137
    char tmp_string[type::Time::MAX_STRING_LENGTH];
138
138
    size_t tmp_string_len;
139
139
 
140
 
    tmp_string_len= temporal.to_string(tmp_string, MAX_DATE_STRING_REP_LENGTH);
141
 
    assert(tmp_string_len < MAX_DATE_STRING_REP_LENGTH);
 
140
    tmp_string_len= temporal.to_string(tmp_string, type::Time::MAX_STRING_LENGTH);
 
141
    assert(tmp_string_len < type::Time::MAX_STRING_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()->getShare()->db_low_byte_first)
 
150
  if (getTable() && getTable()->isDatabaseLowByteFirst())
151
151
  {
152
152
    int8store(ptr, int_value);
153
153
  }
154
154
  else
155
155
#endif
156
156
    int64_tstore(ptr, int_value);
 
157
 
157
158
  return 0;
158
159
}
159
160
 
169
170
  ASSERT_COLUMN_MARKED_FOR_READ;
170
171
 
171
172
#ifdef WORDS_BIGENDIAN
172
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
173
  if (getTable() && getTable()->isDatabaseLowByteFirst())
173
174
    j=sint8korr(ptr);
174
175
  else
175
176
#endif
188
189
  ASSERT_COLUMN_MARKED_FOR_READ;
189
190
 
190
191
#ifdef WORDS_BIGENDIAN
191
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
192
  if (getTable() && getTable()->isDatabaseLowByteFirst())
192
193
    tmp=sint8korr(ptr);
193
194
  else
194
195
#endif
216
217
  return val_buffer;
217
218
}
218
219
 
219
 
bool Field_datetime::get_date(type::Time *ltime, uint32_t fuzzydate)
 
220
bool Field_datetime::get_date(type::Time &ltime, uint32_t fuzzydate)
220
221
{
221
222
  int64_t tmp=Field_datetime::val_int();
222
223
  uint32_t part1,part2;
223
224
  part1=(uint32_t) (tmp/INT64_C(1000000));
224
225
  part2=(uint32_t) (tmp - (uint64_t) part1*INT64_C(1000000));
225
226
 
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;
 
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;
236
238
}
237
239
 
238
 
bool Field_datetime::get_time(type::Time *ltime)
 
240
bool Field_datetime::get_time(type::Time &ltime)
239
241
{
240
242
  return Field_datetime::get_date(ltime,0);
241
243
}
244
246
{
245
247
  int64_t a,b;
246
248
#ifdef WORDS_BIGENDIAN
247
 
  if (getTable() && getTable()->getShare()->db_low_byte_first)
 
249
  if (getTable() && getTable()->isDatabaseLowByteFirst())
248
250
  {
249
251
    a=sint8korr(a_ptr);
250
252
    b=sint8korr(b_ptr);
262
264
void Field_datetime::sort_string(unsigned char *to,uint32_t )
263
265
{
264
266
#ifdef WORDS_BIGENDIAN
265
 
  if (!getTable() || !getTable()->getShare()->db_low_byte_first)
 
267
  if (not getTable() || not getTable()->isDatabaseLowByteFirst())
266
268
  {
267
269
    to[0] = ptr[0];
268
270
    to[1] = ptr[1];