mysql> \. ~/bugs/28781/bt.sql -------------- drop table if exists `t1` -------------- ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 1 Current database: test Query OK, 0 rows affected (0.02 sec) -------------- create table `t1` (`c1` int auto_increment, `c2` int unsigned not null, counter int not null default 1, primary key (c1), unique key (`c2`)) engine = innodb -------------- Query OK, 0 rows affected (0.01 sec) -------------- select version() -------------- +---------------------+ | version() | +---------------------+ | 5.1.23-rc-debug-log | +---------------------+ 1 row in set (0.00 sec) -------------- show variables like '%autoinc%' -------------- +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | innodb_autoinc_lock_mode | 1 | +--------------------------+-------+ 1 row in set (0.01 sec) -------------- insert into t1 (c1, c2) values (NULL, 1) on duplicate key update counter = counter + 1 -------------- Query OK, 1 row affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 1) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 2) on duplicate key update counter = counter + 1 -------------- Query OK, 1 row affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 1) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.01 sec) -------------- insert into t1 (c1, c2) values (NULL, 2) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 2) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 3) on duplicate key update counter = counter + 1 -------------- Query OK, 1 row affected (0.00 sec) -------------- SELECT * FROM t1 -------------- +----+----+---------+ | c1 | c2 | counter | +----+----+---------+ | 1 | 1 | 3 | | 3 | 2 | 3 | | 7 | 3 | 1 | +----+----+---------+ 3 rows in set (0.00 sec) mysql> use test; No connection. Trying to reconnect... Connection id: 1 Current database: *** NONE *** Database changed mysql> \. ~/bugs/28781/bt.sql -------------- drop table if exists `t1` -------------- Query OK, 0 rows affected (0.02 sec) -------------- create table `t1` (`c1` int auto_increment, `c2` int unsigned not null, counter int not null default 1, primary key (c1), unique key (`c2`)) engine = innodb -------------- Query OK, 0 rows affected (0.01 sec) -------------- select version() -------------- +---------------------+ | version() | +---------------------+ | 5.1.23-rc-debug-log | +---------------------+ 1 row in set (0.00 sec) -------------- show variables like '%autoinc%' -------------- +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | innodb_autoinc_lock_mode | 0 | +--------------------------+-------+ 1 row in set (0.01 sec) -------------- insert into t1 (c1, c2) values (NULL, 1) on duplicate key update counter = counter + 1 -------------- Query OK, 1 row affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 1) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 2) on duplicate key update counter = counter + 1 -------------- Query OK, 1 row affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 1) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 2) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 2) on duplicate key update counter = counter + 1 -------------- Query OK, 2 rows affected (0.00 sec) -------------- insert into t1 (c1, c2) values (NULL, 3) on duplicate key update counter = counter + 1 -------------- Query OK, 1 row affected (0.00 sec) -------------- SELECT * FROM t1 -------------- +----+----+---------+ | c1 | c2 | counter | +----+----+---------+ | 1 | 1 | 3 | | 2 | 2 | 3 | | 3 | 3 | 1 | +----+----+---------+ 3 rows in set (0.01 sec)