98 Item_result arg0_result_type= args[0]->result_type();
100 switch (arg0_result_type)
113 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
114 String tmp(buff,
sizeof(buff), &my_charset_utf8_bin);
115 String *res= args[0]->val_str(&tmp);
117 if (res && (res != &tmp))
122 if (! datetime_temporal.
from_string(tmp.c_ptr(), tmp.length()))
128 my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
145 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
146 String tmp(buff,
sizeof(buff), &my_charset_utf8_bin);
149 res= args[0]->val_str(&tmp);
151 if (res && (res != &tmp))
156 my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
164 temporal= &datetime_temporal;
184 char time_buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
185 String tmp_time(time_buff,
sizeof(time_buff), &my_charset_utf8_bin);
186 String *time_res= args[0]->val_str(&tmp_time);
188 if (time_res && (time_res != &tmp_time))
190 tmp_time.copy(*time_res);
193 if (! time_temporal.
from_string(tmp_time.c_ptr(), tmp_time.length()))
200 Item_result arg0_result_type= args[0]->result_type();
202 switch (arg0_result_type)
215 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
216 String tmp(buff,
sizeof(buff), &my_charset_utf8_bin);
217 String *res= args[0]->val_str(&tmp);
219 if (res && (res != &tmp))
224 if (! datetime_temporal.
from_string(tmp.c_ptr(), tmp.length()))
230 my_error(ER_INVALID_DATETIME_VALUE, MYF(0), tmp.c_ptr());
247 char buff[DRIZZLE_MAX_LENGTH_DATETIME_AS_STRING];
248 String tmp(buff,
sizeof(buff), &my_charset_utf8_bin);
251 res= args[0]->val_str(&tmp);
253 my_error(ER_INVALID_DATETIME_VALUE, MYF(0), res->c_ptr());
258 temporal= &datetime_temporal;
263 temporal= &time_temporal;
270 return (int64_t) temporal->
years();
271 case INTERVAL_YEAR_MONTH:
272 return (int64_t) ((temporal->
years() * 100L) + temporal->
months());
273 case INTERVAL_QUARTER:
274 return (int64_t) (temporal->
months() + 2) / 3;
276 return (int64_t) temporal->
months();
282 return (int64_t) temporal->
days();
283 case INTERVAL_DAY_HOUR:
284 return (int64_t) ((temporal->
days() * 100L) + temporal->
hours());
285 case INTERVAL_DAY_MINUTE:
286 return (int64_t) ((temporal->
days() * 10000L)
287 + (temporal->
hours() * 100L)
289 case INTERVAL_DAY_SECOND:
291 (int64_t) (temporal->
days() * 1000000L)
292 + (int64_t) (temporal->
hours() * 10000L)
296 return (int64_t) temporal->
hours();
297 case INTERVAL_HOUR_MINUTE:
298 return (int64_t) (temporal->
hours() * 100L)
300 case INTERVAL_HOUR_SECOND:
301 return (int64_t) (temporal->
hours() * 10000L)
304 case INTERVAL_MINUTE:
305 return (int64_t) temporal->
minutes();
306 case INTERVAL_MINUTE_SECOND:
307 return (int64_t) (temporal->
minutes() * 100L) + temporal->
seconds();
308 case INTERVAL_SECOND:
309 return (int64_t) temporal->
seconds();
310 case INTERVAL_MICROSECOND:
311 return (int64_t) temporal->
useconds();
312 case INTERVAL_DAY_MICROSECOND:
316 (int64_t) (temporal->
days() * 1000000L)
317 + (int64_t) (temporal->
hours() * 10000L)
324 case INTERVAL_HOUR_MICROSECOND:
328 (int64_t) (temporal->
hours() * 10000L)
335 case INTERVAL_MINUTE_MICROSECOND:
345 case INTERVAL_SECOND_MICROSECOND:
346 return (int64_t) (temporal->
seconds() * 1000000L)