Hi,

Is this correct for MySQL to increment the auto_increment counter if the
INSERT query fails? For example:

mysql> CREATE TABLE test ( i INT NOT NULL AUTO_INCREMENT, c CHAR(16) NOT
NULL, PRIMARY KEY(i), UNIQUE(c)) type=InnoDB;
Query OK, 0 rows affected (0.25 sec)

mysql> INSERT INTO test VALUES('', 'test1');
Query OK, 1 row affected (0.05 sec)

mysql> INSERT INTO test VALUES('', 'test2');
Query OK, 1 row affected (0.24 sec)

mysql> INSERT INTO test VALUES('', 'test2');
ERROR 1062: Duplicate entry 'test2' for key 2
mysql> INSERT INTO test VALUES('', 'test3');
Query OK, 1 row affected (0.02 sec)

mysql> SELECT * FROM test;
+---+-------+
| i | c     |
+---+-------+
| 1 | test1 |
| 2 | test2 |
| 4 | test3 |
+---+-------+
3 rows in set (0.00 sec)


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to