From a292b42436e476de109c2ffce6a3b469d738ca44 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 30 Jul 2005 05:53:35 +0400 Subject: Fix bug #11335 View redefines TinyInt(1) column definition Item_type_holder doesn't store information about length and exact type of original item which results in redefining length to max_length and geometry type to longtext. Changed the way derived tables except unions are built. Now they are created from original field list instead of list of Item_type_holder. mysql-test/r/subselect.result: Fixed wrong test case result. bug#11335 mysql-test/r/view_grant.result: Fixed wrong test case result. bug#11335 mysql-test/r/view.result: Added test case for bug #11335. Fixed wrong test case result. mysql-test/t/view.test: Test case for bug #11335 View redefines TinyInt(1) column definition. sql/sql_union.cc: Fix bug #11335 View redefines TinyInt(1) column definition. Changed the way derived tables except unions are built. Now they are created from original field list instead of list of Item_type_holders. sql/sql_select.cc: Fix bug #11335 View redefines TinyInt(1) column definition. Added special handling of DATE/TIME fields to preserve field's type in tmp field creation. In create_tmp_field() for Item_field added special handling of case when item have to be able to store NULLs but underlaid field is NOT NULL. sql/item_sum.cc: Fix bug #11335 View redefines TinyInt(1) column definition. Added special handling of DATE/TIME fields to preserve field's type while tmp field created in Item_sum_hybrid::create_tmp_field(). --- sql/item_sum.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sql/item_sum.cc') diff --git a/sql/item_sum.cc b/sql/item_sum.cc index d2f1016891b..2dedc6b6bc5 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -321,6 +321,22 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table, field->flags&= ~NOT_NULL_FLAG; return field; } + /* + DATE/TIME fields have STRING_RESULT result types. + In order to preserve field type, it's needed to handle DATE/TIME + fields creations separately. + */ + switch (args[0]->field_type()) { + case MYSQL_TYPE_DATE: + return new Field_date(maybe_null, name, table, collation.collation); + case MYSQL_TYPE_TIME: + return new Field_time(maybe_null, name, table, collation.collation); + case MYSQL_TYPE_TIMESTAMP: + case MYSQL_TYPE_DATETIME: + return new Field_datetime(maybe_null, name, table, collation.collation); + default: + break; + } return Item_sum::create_tmp_field(group, table, convert_blob_length); } -- cgit v1.2.1