Bug #56769 Error code 1048 received during select
Submitted: 14 Sep 2010 11:15 Modified: 14 Oct 2010 12:05
Reporter: Gary machol Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.35-community-log OS:Windows
Assigned to: CPU Architecture:Any
Tags: Error code 1048, SELECT

[14 Sep 2010 11:15] Gary machol
Description:
Error Code 1048 is received when running a select statement, indicating that a field cannot be null.  Normally this code is reserved for trying to insert into a non-nullable field.
The problem happens with storage engines innodb and myisam at least.

How to repeat:
-- create a table, do not populate it
DROP TABLE IF EXISTS checkbug;
CREATE TABLE checkbug(
	id INT AUTO_INCREMENT PRIMARY KEY,
	val INT
)ENGINE=INNODB;

-- here the inner query brings nulls. The outer query does not run,
-- with or without the external where clause
SELECT derivedTbl.* FROM (
	SELECT id, SUM(val) FROM checkbug WHERE val = 2
) AS derivedTbl
WHERE derivedTbl.id IS NOT NULL;

Exception received:  
Error Code : 1048
Column 'id' cannot be null

Suggested fix:
either make it bring data, or explain better what the problem is.
[14 Sep 2010 12:05] MySQL Verification Team
Thank you for the bug report. Could you please upgrade to the latest released version I couldn't repeat with source server. Thanks in advance.
[14 Oct 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".