86
89
/* Create the stored integer format. @TODO This should go away. Should be up to engine... */
88
91
temporal.to_int64_t(&int_value);
89
#ifdef WORDS_BIGENDIAN
90
if (table && table->s->db_low_byte_first)
92
int8store(ptr, int_value);
96
int64_tstore(ptr, int_value);
100
int Field_datetime::store(double nr)
103
if (nr < 0.0 || nr > 99991231235959.0)
105
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
106
ER_WARN_DATA_OUT_OF_RANGE,
107
nr, DRIZZLE_TIMESTAMP_DATETIME);
111
error|= Field_datetime::store((int64_t) rint(nr), false);
116
int Field_datetime::store(int64_t nr,
119
DRIZZLE_TIME not_used;
121
int64_t initial_nr= nr;
122
Session *session= table ? table->in_use : current_session;
124
nr= number_to_datetime(nr, ¬_used, (TIME_FUZZY_DATE |
125
(session->variables.sql_mode &
127
MODE_INVALID_DATES))), &error);
129
if (nr == INT64_C(-1))
136
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
137
error == 2 ? ER_WARN_DATA_OUT_OF_RANGE :
138
ER_WARN_DATA_TRUNCATED, initial_nr,
139
DRIZZLE_TIMESTAMP_DATETIME, 1);
141
#ifdef WORDS_BIGENDIAN
142
if (table && table->s->db_low_byte_first)
148
int64_tstore(ptr,nr);
93
#ifdef WORDS_BIGENDIAN
94
if (table && table->s->db_low_byte_first)
96
int8store(ptr, int_value);
100
int64_tstore(ptr, int_value);
104
int Field_datetime::store(double from)
106
if (from < 0.0 || from > 99991231235959.0)
108
/* Convert the double to a string using stringstream */
109
std::stringstream ss;
111
ss.precision(18); /* 18 places should be fine for error display of double input. */
112
ss << from; ss >> tmp;
114
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
117
return Field_datetime::store((int64_t) rint(from), false);
120
int Field_datetime::store(int64_t from, bool)
123
* Try to create a DateTime from the supplied string. Throw an error
124
* if unable to create a valid DateTime.
126
drizzled::DateTime temporal;
127
if (! temporal.from_int64_t(from))
129
/* Convert the integer to a string using stringstream */
130
std::stringstream ss;
132
ss << from; ss >> tmp;
134
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
139
* Because "from" may be a silly MySQL-like "datetime number" (like, oh, 101)
140
* we must here get the value of the DateTime as its *real* int64_t, after
141
* the conversion above has been done...yuck. God, save us.
144
temporal.to_int64_t(&int_value);
146
#ifdef WORDS_BIGENDIAN
147
if (table && table->s->db_low_byte_first)
149
int8store(ptr, int_value);
153
int64_tstore(ptr, int_value);
153
157
int Field_datetime::store_time(DRIZZLE_TIME *ltime,
154
158
enum enum_drizzle_timestamp_type time_type)