diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-07-24 12:00:17 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-07-24 12:00:17 +0400 |
commit | a78d1aaaa349ebbe3400e48f63903b349050b316 (patch) | |
tree | b20f70c785b6e84ae059357fa97d57c75685f8f8 /sql/item_create.cc | |
parent | fee463238793dcc196273654b6f6abd23a1b35ac (diff) | |
download | mariadb-git-a78d1aaaa349ebbe3400e48f63903b349050b316.tar.gz |
MDEV-16806 Add Type_handler::create_literal_item()
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 904896770c7..80cb830c584 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -7432,84 +7432,6 @@ find_qualified_function_builder(THD *thd) } -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'. - @param thd The current thread - @param str Character literal - @param length Length of str - @param type Type of literal (TIME, DATE or DATETIME) - @param send_error Whether to generate an error on failure -*/ - -Item *create_temporal_literal(THD *thd, - const char *str, size_t length, - CHARSET_INFO *cs, - enum_field_types type, - bool send_error) -{ - MYSQL_TIME_STATUS status; - MYSQL_TIME ltime; - Item *item= NULL; - sql_mode_t flags= sql_mode_for_dates(thd); - - switch(type) - { - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_NEWDATE: - if (!str_to_datetime(cs, str, length, <ime, flags, &status) && - ltime.time_type == MYSQL_TIMESTAMP_DATE && !status.warnings) - item= new (thd->mem_root) Item_date_literal(thd, <ime); - break; - case MYSQL_TYPE_DATETIME: - if (!str_to_datetime(cs, str, length, <ime, flags, &status) && - ltime.time_type == MYSQL_TIMESTAMP_DATETIME && - !have_important_literal_warnings(&status)) - item= new (thd->mem_root) Item_datetime_literal(thd, <ime, - status.precision); - break; - case MYSQL_TYPE_TIME: - if (!str_to_time(cs, str, length, <ime, 0, &status) && - ltime.time_type == MYSQL_TIMESTAMP_TIME && - !have_important_literal_warnings(&status)) - item= new (thd->mem_root) Item_time_literal(thd, <ime, - status.precision); - break; - default: - DBUG_ASSERT(0); - } - - if (likely(item)) - { - if (status.warnings) // e.g. a note on nanosecond truncation - { - ErrConvString err(str, length, cs); - make_truncated_value_warning(thd, - Sql_condition::time_warn_level(status.warnings), - &err, ltime.time_type, 0); - } - return item; - } - - if (send_error) - { - const char *typestr= - (type == MYSQL_TYPE_DATE) ? "DATE" : - (type == MYSQL_TYPE_TIME) ? "TIME" : "DATETIME"; - ErrConvString err(str, length, thd->variables.character_set_client); - my_error(ER_WRONG_VALUE, MYF(0), typestr, err.ptr()); - } - return NULL; -} - - static List<Item> *create_func_dyncol_prepare(THD *thd, DYNCALL_CREATE_DEF **dfs, List<DYNCALL_CREATE_DEF> &list) |