diff options
author | Alexander Barkov <bar@mariadb.org> | 2013-08-15 15:24:34 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2013-08-15 15:24:34 +0400 |
commit | e9ca686137f0498cc1bc25d1c67fb32769d88218 (patch) | |
tree | eb16367beb707e7f00d4d9afe1d31575b1e1f87e /sql/item_create.cc | |
parent | 3462b6d3d29eebc246dbf8942baffd0ae5dd0b4f (diff) | |
download | mariadb-git-e9ca686137f0498cc1bc25d1c67fb32769d88218.tar.gz |
MDEV-4871 Temporal literals do not accept nanoseconds
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 4bd3d4f7e47..3d0a2f58eb7 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -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) { |