summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mhansson/martin@linux-st28.site>2007-12-19 15:59:05 +0100
committerunknown <mhansson/martin@linux-st28.site>2007-12-19 15:59:05 +0100
commit5480cbd69ec553dbb266533474989ce62774516c (patch)
tree3f1a6986c8f700958371ae168aab9940cd26789b /sql
parent55d284d424c954888536f615731a61d039d80ac1 (diff)
parent94f75ffcce4daddfb709bd269fc90d1513833966 (diff)
downloadmariadb-git-5480cbd69ec553dbb266533474989ce62774516c.tar.gz
Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt
into linux-st28.site:/home/martin/mysql/src/bug32848/my50-bug32848 sql/field.cc: Auto merged sql/field.h: Auto merged sql/item.cc: Auto merged sql/sql_select.cc: Auto merged mysql-test/r/union.result: Bug#32848: Manual merge mysql-test/t/union.test: Bug#32848: Manual merge
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc3
-rw-r--r--sql/field.h10
-rw-r--r--sql/item.cc4
-rw-r--r--sql/sql_select.cc2
4 files changed, 18 insertions, 1 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 3f00b6750bc..b1cc3701f3d 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1304,7 +1304,8 @@ Field::Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
field_name(field_name_arg),
query_id(0), key_start(0), part_of_key(0), part_of_sortkey(0),
unireg_check(unireg_check_arg),
- field_length(length_arg), null_bit(null_bit_arg)
+ field_length(length_arg), null_bit(null_bit_arg),
+ is_created_from_null_item(FALSE)
{
flags=null_ptr ? 0: NOT_NULL_FLAG;
comment.str= (char*) "";
diff --git a/sql/field.h b/sql/field.h
index 05c22092e53..e5c473ed556 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -89,6 +89,16 @@ public:
uint field_index; // field number in fields array
uint16 flags;
uchar null_bit; // Bit used to test null bit
+ /**
+ If true, this field was created in create_tmp_field_from_item from a NULL
+ value. This means that the type of the field is just a guess, and the type
+ may be freely coerced to another type.
+
+ @see create_tmp_field_from_item
+ @see Item_type_holder::get_real_type
+
+ */
+ bool is_created_from_null_item;
Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,uchar null_bit_arg,
utype unireg_check_arg, const char *field_name_arg,
diff --git a/sql/item.cc b/sql/item.cc
index 975b517284f..2d49c7b6d60 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -6608,6 +6608,8 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
*/
Field *field= ((Item_field *) item)->field;
enum_field_types type= field->real_type();
+ if (field->is_created_from_null_item)
+ return MYSQL_TYPE_NULL;
/* work around about varchar type field detection */
if (type == MYSQL_TYPE_STRING && field->type() == MYSQL_TYPE_VAR_STRING)
return MYSQL_TYPE_VAR_STRING;
@@ -6859,6 +6861,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table)
Field::NONE, name,
table, get_set_pack_length(enum_set_typelib->count),
enum_set_typelib, collation.collation);
+ case MYSQL_TYPE_NULL:
+ return make_string_field(table);
default:
break;
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d6cb072ce9b..47a4097964a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -9041,6 +9041,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
*((*copy_func)++) = item; // Save for copy_funcs
if (modify_item)
item->set_result_field(new_field);
+ if (item->type() == MYSQL_TYPE_NULL)
+ new_field->is_created_from_null_item= TRUE;
return new_field;
}