mirror of
https://github.com/MariaDB/server.git
synced 2026-04-27 02:35:29 +02:00
MDEV-4871 Temporal literals do not accept nanoseconds
This commit is contained in:
parent
3462b6d3d2
commit
e9ca686137
11 changed files with 156 additions and 33 deletions
|
|
@ -5796,6 +5796,13 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type,
|
|||
}
|
||||
|
||||
|
||||
static bool
|
||||
have_important_literal_warnings(const MYSQL_TIME_STATUS *status)
|
||||
{
|
||||
return (status->warnings & ~MYSQL_TIME_NOTE_TRUNCATED) != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Builder for datetime literals:
|
||||
TIME'00:00:00', DATE'2001-01-01', TIMESTAMP'2001-01-01 00:00:00'.
|
||||
|
|
@ -5827,13 +5834,15 @@ Item *create_temporal_literal(THD *thd,
|
|||
break;
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
if (!str_to_datetime(cs, str, length, <ime, flags, &status) &&
|
||||
ltime.time_type == MYSQL_TIMESTAMP_DATETIME && !status.warnings)
|
||||
ltime.time_type == MYSQL_TIMESTAMP_DATETIME &&
|
||||
!have_important_literal_warnings(&status))
|
||||
item= new (thd->mem_root) Item_datetime_literal(<ime,
|
||||
status.precision);
|
||||
break;
|
||||
case MYSQL_TYPE_TIME:
|
||||
if (!str_to_time(cs, str, length, <ime, 0, &status) &&
|
||||
ltime.time_type == MYSQL_TIMESTAMP_TIME && !status.warnings)
|
||||
ltime.time_type == MYSQL_TIMESTAMP_TIME &&
|
||||
!have_important_literal_warnings(&status))
|
||||
item= new (thd->mem_root) Item_time_literal(<ime,
|
||||
status.precision);
|
||||
break;
|
||||
|
|
@ -5842,7 +5851,16 @@ Item *create_temporal_literal(THD *thd,
|
|||
}
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (status.warnings) // e.g. a note on nanosecond truncation
|
||||
{
|
||||
ErrConvString err(str, length, cs);
|
||||
make_truncated_value_warning(current_thd,
|
||||
Sql_condition::time_warn_level(status.warnings),
|
||||
&err, ltime.time_type, 0);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
if (send_error)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue