Convert lldiv_t to datetime. @param lld The value to convert from. @param OUT ltime The variable to convert to. @param flags Conversion flags. @param IN/OUT warnings Warning flags. @return False on success, true on error. */
| 406 | @return False on success, true on error. |
| 407 | */ |
| 408 | static bool |
| 409 | lldiv_t_to_datetime(lldiv_t lld, MYSQL_TIME *ltime, uint flags, int *warnings) |
| 410 | { |
| 411 | if (lld.rem < 0 || // Catch negative numbers with zero int part, e.g: -0.1 |
| 412 | number_to_datetime(lld.quot, ltime, flags, warnings) == LL(-1)) |
| 413 | { |
| 414 | /* number_to_datetime does not clear ltime in case of ZERO DATE */ |
| 415 | set_zero_time(ltime, MYSQL_TIMESTAMP_ERROR); |
| 416 | if (!*warnings) /* Neither sets warnings in case of ZERO DATE */ |
| 417 | *warnings|= MYSQL_TIME_WARN_TRUNCATED; |
| 418 | return true; |
| 419 | } |
| 420 | else if (ltime->time_type == MYSQL_TIMESTAMP_DATE) |
| 421 | { |
| 422 | /* |
| 423 | Generate a warning in case of DATE with fractional part: |
| 424 | 20011231.1234 -> '2001-12-31' |
| 425 | unless the caller does not want the warning: for example, CAST does. |
| 426 | */ |
| 427 | if (lld.rem && !(flags & TIME_NO_DATE_FRAC_WARN)) |
| 428 | *warnings|= MYSQL_TIME_WARN_TRUNCATED; |
| 429 | } |
| 430 | else if (!(flags & TIME_NO_NSEC_ROUNDING)) |
| 431 | { |
| 432 | ltime->second_part= lld.rem / 1000; |
| 433 | return datetime_add_nanoseconds_with_round(ltime, lld.rem % 1000, warnings); |
| 434 | } |
| 435 | return false; |
| 436 | } |
| 437 | |
| 438 | |
| 439 | /** |
no test coverage detected