Trouble With MySQL Auto-Increment

From: Date: Tue, 16 Jan 2001 23:14:52 +0000
Subject: Trouble With MySQL Auto-Increment
Groups: php.general 
Request: Send a blank email to php-general+get-34920@lists.php.net to get a copy of this message
Hello All, I have been using PHP4 with mysql-3.23.29a-gamma-dec-osf4.0f-alphaev6 running on a machine running Digital UNIX V4.0F. Since upgrading the database from 3.22 to 3.23, auto-increment fields have been acting strangely. A brief description of the table looks like: +--------------------+-----------------------+------+-----+--------------------------------+----------------+---------------------------------+ | Field | Type | Null | Key |Default | Extra +--------------------+-----------------------+------+-----+--------------------------------+----------------+---------------------------------+ | scientist_pk | mediumint(8) unsigned | | PRI | NULL | auto_increment . . . At the moment, the largest scientist_pk in the database is 254: mysql> select login,passwd,scientist_pk from users order by scientist_pk desc limit 1; +----------+------------------+--------------+ | login | passwd | scientist_pk | +----------+------------------+--------------+ | jimbo | 18ac6f1d2a33923d | 254 | However, if I do an insert, the next scientist_pk should be 255, but is instead BIG (i.e. 65548). mysql> INSERT INTO users (login,passwd) VALUES ("fred" , PASSWORD("bob")); mysql> select login,passwd,scientist_pk from users order by scientist_pk desc limit 1; +----------+------------------+--------------+ | login | passwd | scientist_pk | +----------+------------------+--------------+ | fred | 7d67547927a4589e | 65548 | I don't know if this helps, but if I insert one more time: mysql> select login,passwd,scientist_pk from users order by scientist_pk desc limit 10; +----------+------------------+--------------+ | login | passwd | scientist_pk | +----------+------------------+--------------+ | fred | 7d67547927a4589e | 65549 | | fred | 7d67547927a4589e | 65548 | Strange, huh? It just seems to like jumping to 65548, which makes zippo sense since the unsigned range is 0 to 16777215 for a mediumint. Has anyone seen this before and know how to fix it?! Thanks much, Parag M

« previous php.general (#34920) next »