Bug #41126 columns with NOT NULL constraints accepting empty string
Submitted: 29 Nov 2008 17:50 Modified: 29 Nov 2008 18:12
Reporter: bharati gouda Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:My SQL server 5.0 OS:Microsoft Windows (Windows Vista)
Assigned to: CPU Architecture:Any

[29 Nov 2008 17:50] bharati gouda
Description:
Hi All,

I am using MySQL community server version 5.0. I have a table with column  
username VARCHAR (10)NOT NULL PRIMARY KEY .But if omit to insert any value 
in this column, the row is saved with username as an empty string. What do
I need to do so as to make the system report an error if no value is inserted
into a column defined as NOT NULL ?

Regards,
bharati.

How to repeat:
I am using MySQL community server version 5.0. I have a table with column  
username VARCHAR (10)NOT NULL PRIMARY KEY .But if omit to insert any value 
in this column, the row is saved with username as an empty string. What do
I need to do so as to make the system report an error if no value is inserted
into a column defined as NOT NULL ?
[29 Nov 2008 18:12] Jon Stephens
If you are performing multi-row inserts on a NOT NULL column, then this is expected behaviour.

See http://dev.mysql.com/doc/refman/5.0/en/constraint-invalid-data.html, beginning with: "If you try to store NULL into a column that doesn't take NULL values..."