Bug #9360 MAX and UNION on NOT NULL column returns error
Submitted: 23 Mar 2005 14:20 Modified: 19 Apr 2005 1:52
Reporter: Alexandre Avrane Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:4.1 OS:Linux (Linux)
Assigned to: Igor Babaev CPU Architecture:Any

[23 Mar 2005 14:20] Alexandre Avrane
Description:
Using MAX, MIN, etc functions in SELECT's in UNION or UNION ALL returns an error if the SELECT's do not return any row

How to repeat:
select max(c1) from toto where 1=2
union
select max(c1) from toto where 2=3

returns: Column 'max(c1)' cannot be null
if c1 is defined as a non-null column (any datatype)

mySQL 4.0 returned correctly a null tuple
[19 Apr 2005 1:52] MySQL Verification Team
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

I tested again with latest BK source 4.1 and I wasn't able to repeat naymore.