~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/sysdate_local.cc

  • Committer: lbieber
  • Date: 2010-10-01 13:06:31 UTC
  • mfrom: (1802.2.2 drizzle-bug-651948)
  • mto: This revision was merged to the branch mainline in revision 1805.
  • Revision ID: lbieber@orisndriz08-20101001130631-xubscnhmj7r5dn6g
Merge Andrew - Fix bug 651948 - Index lengths not retrieved using drizzledump

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
27
27
{
28
28
 
29
29
/**
30
 
    Converts current time in time_t to type::Time represenatation for local
 
30
    Converts current time in time_t to DRIZZLE_TIME represenatation for local
31
31
    time zone. Defines time zone (local) used for whole SYSDATE function.
32
32
*/
33
 
void Item_func_sysdate_local::store_now_in_TIME(type::Time &now_time)
 
33
void Item_func_sysdate_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
34
34
{
35
35
  Session *session= current_session;
36
36
  session->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
40
40
String *Item_func_sysdate_local::val_str(String *)
41
41
{
42
42
  assert(fixed == 1);
43
 
  store_now_in_TIME(ltime);
44
 
 
45
 
  size_t length= type::Time::MAX_STRING_LENGTH;
46
 
  ltime.convert(buff, length);
47
 
  buff_length= length;
48
 
  str_value.set(buff, length, &my_charset_bin);
49
 
 
 
43
  store_now_in_TIME(&ltime);
 
44
  buff_length= (uint) my_datetime_to_str(&ltime, buff);
 
45
  str_value.set(buff, buff_length, &my_charset_bin);
50
46
  return &str_value;
51
47
}
52
48
 
54
50
int64_t Item_func_sysdate_local::val_int()
55
51
{
56
52
  assert(fixed == 1);
57
 
  store_now_in_TIME(ltime);
58
 
  int64_t tmp;
59
 
  ltime.convert(tmp);
60
 
 
61
 
  return tmp;
 
53
  store_now_in_TIME(&ltime);
 
54
  return (int64_t) TIME_to_uint64_t_datetime(&ltime);
62
55
}
63
56
 
64
57
double Item_func_sysdate_local::val_real()
65
58
{
66
59
  assert(fixed == 1);
67
 
 
68
 
  store_now_in_TIME(ltime);
69
 
  int64_t tmp;
70
 
  ltime.convert(tmp);
71
 
 
72
 
  return int64_t2double(tmp);
 
60
  store_now_in_TIME(&ltime);
 
61
  return uint64_t2double(TIME_to_uint64_t_datetime(&ltime));
73
62
}
74
63
 
75
64
 
81
70
}
82
71
 
83
72
 
84
 
bool Item_func_sysdate_local::get_date(type::Time &res, uint32_t )
 
73
bool Item_func_sysdate_local::get_date(DRIZZLE_TIME *res,
 
74
                                       uint32_t )
85
75
{
86
 
  store_now_in_TIME(ltime);
87
 
  res= ltime;
 
76
  store_now_in_TIME(&ltime);
 
77
  *res= ltime;
88
78
  return 0;
89
79
}
90
80
 
91
81
 
92
82
int Item_func_sysdate_local::save_in_field(Field *to, bool )
93
83
{
94
 
  store_now_in_TIME(ltime);
 
84
  store_now_in_TIME(&ltime);
95
85
  to->set_notnull();
96
 
  to->store_time(ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
97
 
 
 
86
  to->store_time(&ltime, DRIZZLE_TIMESTAMP_DATETIME);
98
87
  return 0;
99
88
}
100
89