Bug #2609 UNION ALL truncates string constants
Submitted: 2 Feb 2004 6:53 Modified: 2 Feb 2004 7:54
Reporter: Chris Dalla Piazza Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:4.0.14 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[2 Feb 2004 6:53] Chris Dalla Piazza
Description:
SELECT 'True'
UNION ALL
SELECT 'False'

Produces the result:
'True'
'Fals' <-- Truncated

Expected result:
'True'
'False' <-- Not Truncated

Did not test on table data.

How to repeat:
Issue the query:
SELECT 'True'
UNION ALL
SELECT 'False'

Suggested fix:
Pad your string constants with spaces:
SELECT 'True ' <-- Contains an extra space
UNION ALL
SELECT 'False'
[2 Feb 2004 7:54] Alexander Keremidarski
Thank you for your bug report. This issue has already been fixed
in the latest released version of that product, which you can download at 
http://www.mysql.com/downloads/

Additional info:

This is documented limitation of UNION in MySQL 4.0

The problem is that first query determines column types for the whole result including charater lengths.

This is fixed in 4.1 tree.

mysql> SELECT 'True'
    -> UNION ALL
    -> SELECT 'False'
    -> UNION ALL
    -> SELECT VERSION();
+-----------------------+
| True                  |
+-----------------------+
| True                  |
| False                 |
| 4.1.2-alpha-debug-log |
+-----------------------+

see also