Bug #30886 Union returns wrong column type size
Submitted: 7 Sep 2007 10:16 Modified: 7 Sep 2007 11:18
Reporter: Ajasja Ljubetič
Status: Verified
Category:Server: DML Severity:S3 (Non-critical)
Version:5.0.45, 4.1, 5.0, 5.1, 5.2 BK OS:Any (Linux, Windows XP SP2)
Assigned to: Evgeny Potemkin Target Version:
Tags: column type, UNION
Triage: Triaged: D4 (Minor) / R3 (Medium) / E4 (High)

[7 Sep 2007 10:16] Ajasja Ljubetič
Description:
When selecting a union of two tables, the result column type’s size does not mach the
underlying tables.

For example the union of two tinyint(1) fields will return tinyint(4) instead of
tinyint(1). 
The union of two int(10) unsigned will return int(11) unsigned.

Tested with 5.0.41 and 5.0.45 on Win XP SP2.

How to repeat:
DROP TABLE IF EXISTS `t1`;
CREATE TABLE  `t1` (
  `ID` int(10) unsigned NOT NULL auto_increment primary key,
  `Boolean` tinyint(1) NOT NULL default '0'
)ENGINE=InnoDB;

DROP TABLE IF EXISTS `t2`;
CREATE TABLE  `t2` (
  `ID` int(10) unsigned NOT NULL auto_increment primary key,
  `Boolean` tinyint(1) NOT NULL default '0'
) ENGINE=InnoDB;

DROP TABLE IF EXISTS `t3`;
CREATE TABLE t3
SELECT * FROM t1
UNION
SELECT * FROM t2;

SHOW CREATE TABLE t3;

###################
RETURNS:
CREATE TABLE `t3` (
  `ID` int(11) unsigned NOT NULL default '0',
  `Boolean` tinyint(4) NOT NULL default '0'
) ENGINE=InnoDB 

Suggested fix:
None.
[7 Sep 2007 11:18] Sveta Smirnova
Thank you for the report.

Verified as described.