46
46
const CHARSET_INFO * const )
49
DRIZZLE_TIME time_tmp;
52
enum enum_drizzle_timestamp_type func_res;
53
Session *session= table ? table->in_use : current_session;
55
func_res= str_to_datetime(from, len, &time_tmp,
57
(session->variables.sql_mode &
58
(MODE_NO_ZERO_DATE | MODE_INVALID_DATES))),
60
if ((int) func_res > (int) DRIZZLE_TIMESTAMP_ERROR)
61
tmp= TIME_to_uint64_t_datetime(&time_tmp);
63
error= 1; // Fix if invalid zero date
66
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
67
ER_WARN_DATA_OUT_OF_RANGE,
68
from, len, DRIZZLE_TIMESTAMP_DATETIME, 1);
70
#ifdef WORDS_BIGENDIAN
71
if (table && table->s->db_low_byte_first)
77
int64_tstore(ptr,tmp);
78
#endif /* NOTDEFINED */
80
49
* Try to create a DateTime from the supplied string. Throw an error
81
50
* if unable to create a valid DateTime.
157
int Field_datetime::store_time(DRIZZLE_TIME *ltime,
158
enum enum_drizzle_timestamp_type time_type)
126
int Field_datetime::store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type)
163
We don't perform range checking here since values stored in TIME
164
structure always fit into DATETIME range.
166
if (time_type == DRIZZLE_TIMESTAMP_DATE ||
167
time_type == DRIZZLE_TIMESTAMP_DATETIME)
169
tmp=((ltime->year*10000L+ltime->month*100+ltime->day)*INT64_C(1000000)+
170
(ltime->hour*10000L+ltime->minute*100+ltime->second));
171
if (check_date(ltime, tmp != 0,
173
(current_session->variables.sql_mode &
174
(MODE_NO_ZERO_DATE | MODE_INVALID_DATES))), &error))
176
char buff[MAX_DATE_STRING_REP_LENGTH];
177
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
178
make_datetime(ltime, &str);
179
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
180
str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATETIME,1);
187
set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
128
drizzled::DateTime temporal;
130
temporal.set_years(ltime->year);
131
temporal.set_months(ltime->month);
132
temporal.set_days(ltime->day);
133
temporal.set_hours(ltime->hour);
134
temporal.set_minutes(ltime->minute);
135
temporal.set_seconds(ltime->second);
137
if (! temporal.is_valid())
139
char tmp_string[MAX_DATE_STRING_REP_LENGTH];
140
size_t tmp_string_len;
142
temporal.to_string(tmp_string, &tmp_string_len);
143
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp_string);
148
temporal.to_int64_t(&int_value);
189
150
#ifdef WORDS_BIGENDIAN
190
151
if (table && table->s->db_low_byte_first)
153
int8store(ptr, int_value);
196
int64_tstore(ptr,tmp);
157
int64_tstore(ptr, int_value);
200
161
double Field_datetime::val_real(void)