diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-04-17 18:51:54 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-04-19 11:27:00 +0200 |
commit | 95fe71afa6f1243af63429c5295b8b4bd74d6459 (patch) | |
tree | 80b2732df2fc4f5d7f3fd05bafad37ff0f7779c5 /sql/sql_select.cc | |
parent | 3294cd11f852357b638cac74ba32578ffb456fc7 (diff) | |
download | mariadb-git-95fe71afa6f1243af63429c5295b8b4bd74d6459.tar.gz |
MDEV-9707 MAX(timestamp(6) column) in correlated sub-query returns non-existent row data in original table
special treatment for temporal values in
create_tmp_field_from_item().
old code only did it when result_type() was STRING_RESULT,
but Item_cache_temporal::result_type() is INT_RESULT
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b1e22537b37..828dab7ef99 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14544,6 +14544,14 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, Field *new_field; LINT_INIT(new_field); + /* + To preserve type or DATE/TIME and GEOMETRY fields, + they need to be handled separately. + */ + if (item->cmp_type() == TIME_RESULT || + item->field_type() == MYSQL_TYPE_GEOMETRY) + new_field= item->tmp_table_field_from_field_type(table, 1); + else switch (item->result_type()) { case REAL_RESULT: new_field= new Field_double(item->max_length, maybe_null, @@ -14566,18 +14574,11 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, case STRING_RESULT: DBUG_ASSERT(item->collation.collation); - /* - DATE/TIME and GEOMETRY fields have STRING_RESULT result type. - To preserve type they needed to be handled separately. - */ - if (item->cmp_type() == TIME_RESULT || - item->field_type() == MYSQL_TYPE_GEOMETRY) - new_field= item->tmp_table_field_from_field_type(table, 1); /* Make sure that the blob fits into a Field_varstring which has 2-byte lenght. */ - else if (item->max_length/item->collation.collation->mbmaxlen > 255 && + if (item->max_length/item->collation.collation->mbmaxlen > 255 && convert_blob_length <= Field_varstring::MAX_SIZE && convert_blob_length) new_field= new Field_varstring(convert_blob_length, maybe_null, |