113
113
/* Convert the integer to a string using boost::lexical_cast */
114
114
std::string tmp(boost::lexical_cast<std::string>(from));
116
my_error(ER_INVALID_DATE_VALUE, MYF(ME_FATALERROR), tmp.c_str());
116
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
120
120
/* Create the stored integer format. @TODO This should go away. Should be up to engine... */
121
121
uint32_t int_value= (temporal.years() * 10000) + (temporal.months() * 100) + temporal.days();
122
122
int4store(ptr, int_value);
127
int Field_date::store_time(type::Time <ime,
128
type::timestamp_t time_type)
126
int Field_date::store_time(DRIZZLE_TIME *ltime,
127
enum enum_drizzle_timestamp_type time_type)
132
if (time_type == type::DRIZZLE_TIMESTAMP_DATE || time_type == type::DRIZZLE_TIMESTAMP_DATETIME)
131
if (time_type == DRIZZLE_TIMESTAMP_DATE ||
132
time_type == DRIZZLE_TIMESTAMP_DATETIME)
134
tmp= ltime.year*10000 + ltime.month*100 + ltime.day;
136
Session *session= getTable() ? getTable()->in_use : current_session;
137
type::cut_t cut_error= type::VALID;
138
if (ltime.check(tmp != 0,
140
(session->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_INVALID_DATES))), cut_error))
134
tmp= ltime->year*10000 + ltime->month*100 + ltime->day;
135
if (check_date(ltime, tmp != 0,
137
(current_session->variables.sql_mode &
138
(MODE_NO_ZERO_DATE | MODE_INVALID_DATES))), &error))
142
char buff[type::Time::MAX_STRING_LENGTH];
140
char buff[MAX_DATE_STRING_REP_LENGTH];
143
141
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
144
ltime.convert(str, type::DRIZZLE_TIMESTAMP_DATE);
142
make_date(ltime, &str);
145
143
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
146
str.ptr(), str.length(), type::DRIZZLE_TIMESTAMP_DATE, 1);
144
str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
149
error= static_cast<int>(cut_error);
151
if (not error && ltime.time_type != type::DRIZZLE_TIMESTAMP_DATE &&
152
(ltime.hour || ltime.minute || ltime.second || ltime.second_part))
146
if (!error && ltime->time_type != DRIZZLE_TIMESTAMP_DATE &&
147
(ltime->hour || ltime->minute || ltime->second || ltime->second_part))
154
char buff[type::Time::MAX_STRING_LENGTH];
149
char buff[MAX_DATE_STRING_REP_LENGTH];
155
150
String str(buff, sizeof(buff), &my_charset_utf8_general_ci);
151
make_datetime(ltime, &str);
157
152
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE,
158
153
ER_WARN_DATA_TRUNCATED,
159
str.ptr(), str.length(), type::DRIZZLE_TIMESTAMP_DATE, 1);
154
str.ptr(), str.length(), DRIZZLE_TIMESTAMP_DATE, 1);
216
209
return val_buffer;
219
bool Field_date::get_date(type::Time <ime, uint32_t fuzzydate)
212
bool Field_date::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
221
214
uint32_t tmp=(uint32_t) uint4korr(ptr);
222
ltime.day= (int) (tmp%100);
223
ltime.month= (int) (tmp/100%100);
224
ltime.year= (int) (tmp/10000);
225
ltime.time_type= type::DRIZZLE_TIMESTAMP_DATE;
226
ltime.hour= ltime.minute= ltime.second= ltime.second_part= ltime.neg= 0;
228
return ((!(fuzzydate & TIME_FUZZY_DATE) && (!ltime.month || !ltime.day)) ?
215
ltime->day= (int) (tmp%100);
216
ltime->month= (int) (tmp/100%100);
217
ltime->year= (int) (tmp/10000);
218
ltime->time_type= DRIZZLE_TIMESTAMP_DATE;
219
ltime->hour= ltime->minute= ltime->second= ltime->second_part= ltime->neg= 0;
220
return ((!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ?
232
bool Field_date::get_time(type::Time <ime)
224
bool Field_date::get_time(DRIZZLE_TIME *ltime)
234
return Field_date::get_date(ltime ,0);
226
return Field_date::get_date(ltime,0);
237
229
int Field_date::cmp(const unsigned char *a_ptr, const unsigned char *b_ptr)