List:Bugs« Previous MessageNext Message »
From:Michael Widenius Date:May 1 2000 9:12am
Subject:RE: AUTO_INCREMENT bug after inserting negative value
View as plain text  
>>>>> "jason" == jason king <jason@stripped> writes:

jason> -----BEGIN PGP SIGNED MESSAGE-----
jason> Hash: SHA1

jason> Michael Widenius writes ..

>> The problem is that MySQL only supports unsigned values for
>> auto_increment-fields;  This is true even if you define the
>> auto_increment field as a signed value.  (This is basicly sound as it
>> will ensure that MySQL can use the full potential range for a number
>> as autoincrement values).
>> 
>> Inserting -1 is basicly the same as inserting the max value for the
>> field. As MySQL can't give you a higher value for the next value it
>> will insert the max possible value for the column in the table.

jason> hmm .. now I'm confused .. negative auto_increment values work in my
jason> Windows version

jason>   mysql  Ver 9.38 Distrib 3.22.32, for Win95/Win98 (i586)

jason>   Windows NT Version 4.0 Server Service Pack 6a

mysql> create table blah ( id INTEGER NOT NULL AUTO_INCREMENT PRIMARY
jason> KEY );
jason> Query OK, 0 rows affected (0.03 sec)

mysql> insert blah values (-1);
jason> Query OK, 1 row affected (0.00 sec)

mysql> insert blah values (null);
jason> Query OK, 1 row affected (0.00 sec)

mysql> select * from blah;
jason> +----+
jason> | id |
jason> +----+
jason> | -1 |
jason> |  0 |
jason> +----+
jason> 2 rows in set (0.01 sec)

Yes, it works accidently in 3.22 but doesn't work anymore in MySQL
3.23 with the new MyISAM tables.  The above behaveour was not
something we did do by design and wasn't a intended one. Anyway, the
new AUTO_INCREMENT option in MySQL 3.23 is a much nicer way to get the
beahavour you want!

I will see to it that this gets documented properly!

Regards,
Monty
Thread
AUTO_INCREMENT bug after inserting negative valueManuel Lemos30 Apr
  • Re: AUTO_INCREMENT bug after inserting negative valuesinisa30 Apr
  • AUTO_INCREMENT bug after inserting negative valueMichael Widenius30 Apr
    • RE: AUTO_INCREMENT bug after inserting negative valuejason king30 Apr
      • Re: AUTO_INCREMENT bug after inserting negative valueThimble Smith1 May
      • RE: AUTO_INCREMENT bug after inserting negative valueMichael Widenius1 May
    • Re: AUTO_INCREMENT bug after inserting negative valueManuel Lemos30 Apr
      • Re: AUTO_INCREMENT bug after inserting negative valueMichael Widenius1 May
        • Re: AUTO_INCREMENT bug after inserting negative valueManuel Lemos10 May
          • Re: AUTO_INCREMENT bug after inserting negative valueMichael Widenius10 May
            • Re: AUTO_INCREMENT bug after inserting negative valueManuel Lemos5 Jun