Commit 0004b99b authored by mhansson/martin@linux-st28.site's avatar mhansson/martin@linux-st28.site
Browse files

Merge mhansson@bk-internal:/home/bk/mysql-5.0-opt

into  linux-st28.site:/home/martin/mysql/src/bug32848/my50-bug32848
parents 1a8b8eb9 867a7865
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -1482,4 +1482,28 @@ ERROR HY000: Incorrect usage of UNION and INTO
SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;
ERROR HY000: Incorrect usage of UNION and INTO
DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2 SELECT * FROM (SELECT NULL) a UNION SELECT a FROM t1;
DESC t2;
Field	Type	Null	Key	Default	Extra
NULL	int(11)	YES		NULL	
CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a;
DESC t3;
Field	Type	Null	Key	Default	Extra
a	int(11)	YES		NULL	
CREATE TABLE t4 SELECT NULL;
DESC t4;
Field	Type	Null	Key	Default	Extra
NULL	binary(0)	YES		NULL	
CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
DESC t5;
Field	Type	Null	Key	Default	Extra
NULL	binary(0)	YES		NULL	
CREATE TABLE t6 
SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
DESC t6;
Field	Type	Null	Key	Default	Extra
NULL	int(11)	YES		NULL	
DROP TABLE t1, t2, t3, t4, t5, t6;
End of 5.0 tests
+22 −0
Original line number Diff line number Diff line
@@ -978,4 +978,26 @@ SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1;

DROP TABLE t1;

# Bug#32848: Data type conversion bug in union subselects in MySQL 5.0.38
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (3);

CREATE TABLE t2 SELECT * FROM (SELECT NULL) a UNION SELECT a FROM t1;
DESC t2;

CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a;
DESC t3;

CREATE TABLE t4 SELECT NULL;
DESC t4;

CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
DESC t5;

CREATE TABLE t6 
SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
DESC t6;

DROP TABLE t1, t2, t3, t4, t5, t6;
--echo End of 5.0 tests
+2 −1
Original line number Diff line number Diff line
@@ -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*) "";
+10 −0
Original line number Diff line number Diff line
@@ -89,6 +89,16 @@ class Field
  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,
+4 −0
Original line number Diff line number Diff line
@@ -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;
  }
Loading