[MDEV-29206] DEFAULT NULL for NOT NULL columns is not always detected Created: 2022-07-29  Updated: 2022-07-30  Resolved: 2022-07-30

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Sergei Golubchik Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-29075 Changing explicit_defaults_for_timest... Closed

 Description   

Normally DEFAULT NULL is not allowed for NOT NULL columns:

MariaDB [test]> create table t1 (a int not null default null);
ERROR 1067 (42000): Invalid default value for 'a'
MariaDB [test]> create table t1 (a int default null primary key);
ERROR 1067 (42000): Invalid default value for 'a'

But this error condition is not always detected and sometimes DEFAULT NULL is silently ignored:

MariaDB [test]> create table t1 (a int default null, primary key (a));
Query OK, 0 rows affected (0.014 sec)
 
MariaDB [test]> show create table t1\G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `a` int(11) NOT NULL,
  PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.001 sec)



 Comments   
Comment by Sergei Golubchik [ 2022-07-30 ]

https://mariadb.com/kb/en/primary-keys-with-nullable-columns/

Generated at Thu Feb 08 10:06:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.