~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/timestamp.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 04:28:21 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020042821-rqqdrccuu8195k3y
Second pass of thd cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
  int error;
148
148
  bool have_smth_to_conv;
149
149
  bool in_dst_time_gap;
150
 
  Session *thd= table ? table->in_use : current_thd;
 
150
  Session *session= table ? table->in_use : current_session;
151
151
 
152
152
  /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
153
153
  have_smth_to_conv= (str_to_datetime(from, len, &l_time, 1, &error) >
163
163
  /* Only convert a correct date (not a zero date) */
164
164
  if (have_smth_to_conv && l_time.month)
165
165
  {
166
 
    if (!(tmp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap)))
 
166
    if (!(tmp= TIME_to_timestamp(session, &l_time, &in_dst_time_gap)))
167
167
    {
168
168
      set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
169
169
                           ER_WARN_DATA_OUT_OF_RANGE,
206
206
  my_time_t timestamp= 0;
207
207
  int error;
208
208
  bool in_dst_time_gap;
209
 
  Session *thd= table ? table->in_use : current_thd;
 
209
  Session *session= table ? table->in_use : current_session;
210
210
 
211
211
  /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
212
 
  int64_t tmp= number_to_datetime(nr, &l_time, (thd->variables.sql_mode &
 
212
  int64_t tmp= number_to_datetime(nr, &l_time, (session->variables.sql_mode &
213
213
                                                 MODE_NO_ZERO_DATE), &error);
214
214
  if (tmp == INT64_C(-1))
215
215
  {
218
218
 
219
219
  if (!error && tmp)
220
220
  {
221
 
    if (!(timestamp= TIME_to_timestamp(thd, &l_time, &in_dst_time_gap)))
 
221
    if (!(timestamp= TIME_to_timestamp(session, &l_time, &in_dst_time_gap)))
222
222
    {
223
223
      set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
224
224
                           ER_WARN_DATA_OUT_OF_RANGE,
250
250
{
251
251
  uint32_t temp;
252
252
  DRIZZLE_TIME time_tmp;
253
 
  Session  *thd= table ? table->in_use : current_thd;
 
253
  Session  *session= table ? table->in_use : current_session;
254
254
 
255
 
  thd->time_zone_used= 1;
 
255
  session->time_zone_used= 1;
256
256
#ifdef WORDS_BIGENDIAN
257
257
  if (table && table->s->db_low_byte_first)
258
258
    temp=uint4korr(ptr);
263
263
  if (temp == 0L)                               // No time
264
264
    return(0);                                  /* purecov: inspected */
265
265
  
266
 
  thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp);
 
266
  session->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp);
267
267
  
268
268
  return time_tmp.year * INT64_C(10000000000) +
269
269
         time_tmp.month * INT64_C(100000000) +
276
276
{
277
277
  uint32_t temp, temp2;
278
278
  DRIZZLE_TIME time_tmp;
279
 
  Session *thd= table ? table->in_use : current_thd;
 
279
  Session *session= table ? table->in_use : current_session;
280
280
  char *to;
281
281
 
282
282
  val_buffer->alloc(field_length+1);
283
283
  to= (char*) val_buffer->ptr();
284
284
  val_buffer->length(field_length);
285
285
 
286
 
  thd->time_zone_used= 1;
 
286
  session->time_zone_used= 1;
287
287
#ifdef WORDS_BIGENDIAN
288
288
  if (table && table->s->db_low_byte_first)
289
289
    temp=uint4korr(ptr);
298
298
  }
299
299
  val_buffer->set_charset(&my_charset_bin);     // Safety
300
300
  
301
 
  thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp);
 
301
  session->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp);
302
302
 
303
303
  temp= time_tmp.year % 100;
304
304
  if (temp < YY_PART_YEAR - 1)
347
347
bool Field_timestamp::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
348
348
{
349
349
  long temp;
350
 
  Session *thd= table ? table->in_use : current_thd;
351
 
  thd->time_zone_used= 1;
 
350
  Session *session= table ? table->in_use : current_session;
 
351
  session->time_zone_used= 1;
352
352
#ifdef WORDS_BIGENDIAN
353
353
  if (table && table->s->db_low_byte_first)
354
354
    temp=uint4korr(ptr);
363
363
  }
364
364
  else
365
365
  {
366
 
    thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp);
 
366
    session->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp);
367
367
  }
368
368
  return 0;
369
369
}
430
430
 
431
431
void Field_timestamp::set_time()
432
432
{
433
 
  Session *thd= table ? table->in_use : current_thd;
434
 
  long tmp= (long) thd->query_start();
 
433
  Session *session= table ? table->in_use : current_session;
 
434
  long tmp= (long) session->query_start();
435
435
  set_notnull();
436
436
  store_timestamp(tmp);
437
437
}