Bug #21465 | Unable to insert zero value int(0) into primary key column. | ||
---|---|---|---|
Submitted: | 6 Aug 2006 22:02 | Modified: | 7 Aug 2006 22:20 |
Reporter: | Radek Zyka | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 4.1.8-nt and 4.1.20 Free BSD | OS: | Windows (win && Linux) |
Assigned to: | CPU Architecture: | Any | |
Tags: | insert zero value, primary key |
[6 Aug 2006 22:02]
Radek Zyka
[7 Aug 2006 6:02]
Hartmut Holzgraefe
Which version of mysqldump did you use to create the dump? If it was a version from 4.0 then this is expected behavior, if it was a mysqldump binary from a 4.1 distribuion then please reopen the bug.
[7 Aug 2006 21:56]
Radek Zyka
You misunderstand me, is no matter what program is used for dump. Point is, that is impossible insert zero (integer 0) into table with primary key autoincrement. Please read my post again. Especially this part: 2. mysql> INSERT INTO `test` VALUES (-1,'Abc'); INSERT INTO `test` VALUES (0,'def'); Query OK, 1 row affected Query OK, 1 row affected 3. mysql> SELECT * FROM test; +----+-------+ | id | nazev | +----+-------+ | -1 | Abc | | 1 | def | <- here is 1 !!! How is this possible ? I inserted value 0 ... +----+-------+ 2 rows in set I'm sorry, if i'm wrong, but this is still bug IMO.
[7 Aug 2006 22:20]
Hartmut Holzgraefe
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php http://dev.mysql.com/doc/refman/4.1/en/create-table.html As of MySQL 4.1.1, if the NO_AUTO_VALUE_ON_ZERO SQL mode is enabled, you can store 0 in AUTO_INCREMENT columns as 0 without generating a new sequence value. See Section 5.2.5, “The Server SQL Mode”. mysqldump as of 4.1 also takes care of setting NO_AUTO_VALUE_ON_ZERO in the header of the dump file it generates, that's why i was asking for its version.