~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/timestamp.cc

  • Committer: Monty Taylor
  • Date: 2008-10-22 21:31:15 UTC
  • Revision ID: monty@inaugust.com-20081022213115-xuxc80r939tl88p1
Renamed drizzle_common again. Removed sql_common. (empty) 
Now all we need to do is merge/disect base.h, common.h, common_includes.h, server_includes.h and globa.h (good grief)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifdef USE_PRAGMA_IMPLEMENTATION
22
 
#pragma implementation                          // gcc: Class implementation
23
 
#endif
24
21
 
25
22
#include <drizzled/server_includes.h>
26
23
#include <drizzled/field/timestamp.h>
150
147
  int error;
151
148
  bool have_smth_to_conv;
152
149
  bool in_dst_time_gap;
153
 
  THD *thd= table ? table->in_use : current_thd;
 
150
  Session *session= table ? table->in_use : current_session;
154
151
 
155
152
  /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
156
153
  have_smth_to_conv= (str_to_datetime(from, len, &l_time, 1, &error) >
166
163
  /* Only convert a correct date (not a zero date) */
167
164
  if (have_smth_to_conv && l_time.month)
168
165
  {
169
 
    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)))
170
167
    {
171
168
      set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
172
169
                           ER_WARN_DATA_OUT_OF_RANGE,
209
206
  my_time_t timestamp= 0;
210
207
  int error;
211
208
  bool in_dst_time_gap;
212
 
  THD *thd= table ? table->in_use : current_thd;
 
209
  Session *session= table ? table->in_use : current_session;
213
210
 
214
211
  /* We don't want to store invalid or fuzzy datetime values in TIMESTAMP */
215
 
  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 &
216
213
                                                 MODE_NO_ZERO_DATE), &error);
217
214
  if (tmp == INT64_C(-1))
218
215
  {
221
218
 
222
219
  if (!error && tmp)
223
220
  {
224
 
    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)))
225
222
    {
226
223
      set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
227
224
                           ER_WARN_DATA_OUT_OF_RANGE,
253
250
{
254
251
  uint32_t temp;
255
252
  DRIZZLE_TIME time_tmp;
256
 
  THD  *thd= table ? table->in_use : current_thd;
 
253
  Session  *session= table ? table->in_use : current_session;
257
254
 
258
 
  thd->time_zone_used= 1;
 
255
  session->time_zone_used= 1;
259
256
#ifdef WORDS_BIGENDIAN
260
257
  if (table && table->s->db_low_byte_first)
261
258
    temp=uint4korr(ptr);
266
263
  if (temp == 0L)                               // No time
267
264
    return(0);                                  /* purecov: inspected */
268
265
  
269
 
  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);
270
267
  
271
268
  return time_tmp.year * INT64_C(10000000000) +
272
269
         time_tmp.month * INT64_C(100000000) +
279
276
{
280
277
  uint32_t temp, temp2;
281
278
  DRIZZLE_TIME time_tmp;
282
 
  THD *thd= table ? table->in_use : current_thd;
 
279
  Session *session= table ? table->in_use : current_session;
283
280
  char *to;
284
281
 
285
282
  val_buffer->alloc(field_length+1);
286
283
  to= (char*) val_buffer->ptr();
287
284
  val_buffer->length(field_length);
288
285
 
289
 
  thd->time_zone_used= 1;
 
286
  session->time_zone_used= 1;
290
287
#ifdef WORDS_BIGENDIAN
291
288
  if (table && table->s->db_low_byte_first)
292
289
    temp=uint4korr(ptr);
301
298
  }
302
299
  val_buffer->set_charset(&my_charset_bin);     // Safety
303
300
  
304
 
  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);
305
302
 
306
303
  temp= time_tmp.year % 100;
307
304
  if (temp < YY_PART_YEAR - 1)
350
347
bool Field_timestamp::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
351
348
{
352
349
  long temp;
353
 
  THD *thd= table ? table->in_use : current_thd;
354
 
  thd->time_zone_used= 1;
 
350
  Session *session= table ? table->in_use : current_session;
 
351
  session->time_zone_used= 1;
355
352
#ifdef WORDS_BIGENDIAN
356
353
  if (table && table->s->db_low_byte_first)
357
354
    temp=uint4korr(ptr);
366
363
  }
367
364
  else
368
365
  {
369
 
    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);
370
367
  }
371
368
  return 0;
372
369
}
433
430
 
434
431
void Field_timestamp::set_time()
435
432
{
436
 
  THD *thd= table ? table->in_use : current_thd;
437
 
  long tmp= (long) thd->query_start();
 
433
  Session *session= table ? table->in_use : current_session;
 
434
  long tmp= (long) session->query_start();
438
435
  set_notnull();
439
436
  store_timestamp(tmp);
440
437
}