Bug#390173: Someone needs to try to reproduce this

Keith Lawson keith at nowhere.ca
Tue Apr 26 00:51:45 UTC 2011


On Mon, 25 Apr 2011 20:39:59 +0100, Nicholas Bamber wrote:
> I would suggest trying to reproduce this and then debug through the 
> DBI
> code at least. Then it should either be forwarded or marked
> unreproducible.

MySQL won't even let me create the situation described. While it will 
allow for NULL or 0 in a primary key field it only allows for one of 
them:

mysql> desc test_table;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| pkey  | int(11)      | NO   | PRI | NULL    |       |
| text  | varchar(100) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.02 sec)

mysql> select * from test_table;
+------+-------------+
| pkey | text        |
+------+-------------+
|    0 | test no key |
+------+-------------+
1 row in set (0.00 sec)

mysql> insert into test_table (pkey,text) values ('null','test no 
key');
ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'

mysql> desc test_table_varchar;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| pkey  | varchar(16)  | NO   | PRI | NULL    |       |
| text  | varchar(100) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.01 sec)

mysql> select * from test_table_varchar;
+------+---------------+
| pkey | text          |
+------+---------------+
|      | test no key   |
| NULL | test no key 2 |
+------+---------------+
2 rows in set (0.00 sec)

mysql> insert into test_table (pkey,text) values ('null','test no 
key');
ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'
mysql> insert into test_table (text) values ('test no key again!');
ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'

Granted I'm using MySQL 5.1 but the documentation for both 5.0 and 5.1 
reads:

"A PRIMARY KEY is a unique index where all key columns must be defined 
as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL 
declares them so implicitly (and silently)."

I fail to see how it's even possible to create a table with multiple 
NULL primary keys to even test DBI or DBD::MySQL against it.

Keith.





More information about the pkg-perl-maintainers mailing list