drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
sysdate_local.cc
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008 Sun Microsystems, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <config.h>
21
22#include <drizzled/function/time/sysdate_local.h>
23#include <drizzled/session.h>
24#include <drizzled/field.h>
25#include <drizzled/system_variables.h>
26
27namespace drizzled {
28
34{
35 now_time.store(time(NULL));
36}
37
38
40{
41 assert(fixed == 1);
42 store_now_in_TIME(ltime);
43
44 size_t length= type::Time::MAX_STRING_LENGTH;
45 ltime.convert(buff, length);
46 buff_length= length;
47 str_value.set(buff, length, &my_charset_bin);
48
49 return &str_value;
50}
51
52
54{
55 assert(fixed == 1);
56 store_now_in_TIME(ltime);
57 int64_t tmp;
58 ltime.convert(tmp);
59
60 return tmp;
61}
62
64{
65 assert(fixed == 1);
66
67 store_now_in_TIME(ltime);
68 int64_t tmp;
69 ltime.convert(tmp);
70
71 return int64_t2double(tmp);
72}
73
74
75void Item_func_sysdate_local::fix_length_and_dec()
76{
77 decimals= 0;
78 collation.set(&my_charset_bin);
79 max_length= DateTime::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
80}
81
82
84{
85 store_now_in_TIME(ltime);
86 res= ltime;
87 return 0;
88}
89
90
91int Item_func_sysdate_local::save_in_field(Field *to, bool )
92{
93 store_now_in_TIME(ltime);
94 to->set_notnull();
95 to->store_time(ltime, type::DRIZZLE_TIMESTAMP_DATETIME);
96
97 return 0;
98}
99
100} /* namespace drizzled */
static const int MAX_STRING_LENGTH
Definition temporal.h:608
virtual int store_time(type::Time &ltime, type::timestamp_t t_type)
Definition field.cc:1094
void store_now_in_TIME(type::Time &now_time)
bool get_date(type::Time &res, uint32_t fuzzy_date)
bool fixed
Definition item.h:122
String str_value
Definition item.h:109
TODO: Rename this file - func.h is stupid.