3

I have a MySQL Innodb table with 'id' as auto increment primary key column.

My Scripts are doing following operations:

  1. insert ignore into tablename set x='a', y='b'
  2. update ignore tablename set x='a', y='b' where id = 'smthing'
  3. delete from tablename where id = 'smthing'

Now after running the script when I insert something manually (insert into tablename set x='ax', y='bx') I get the following error:

Duplicate Entry for Auto Increment Value. 

On check I see that Auto Increment is trying to put the highest possible value of int that MySql will support as new value even and it already exist in db.

The table has two index: id+x, id+y though idk if this is related to this issue.

marc_s
9,0626 gold badges46 silver badges52 bronze badges
asked Mar 1, 2012 at 3:39
1
  • 3
    Is your title a true statement? We used to get similar reports for MS Access but in reality it would turn out that in order to generate the duplicate values the system had silently dropped the primary key constraint. If it is true that you have duplicate columns within a column with a PK constraint still in place then that is a very worrying bug in mySQL. Commented Mar 1, 2012 at 8:50

1 Answer 1

1

I reached the max possible value of an int column. Problem resolved by altering table and setting big int than int.

The signed range of MIDINT is –8388608 to 8388607. The unsigned range is 0 to 16777215

Reference: http://help.scibit.com/mascon/masconMySQL_Field_Types.html

marc_s
9,0626 gold badges46 silver badges52 bronze badges
answered Mar 1, 2012 at 4:30
2
  • How is that in terms with your "Auto Increment is trying to put 765 as new value" ? Commented Mar 1, 2012 at 9:47
  • For example a took a simple value (765). The actual value was 8388607 Commented Mar 3, 2012 at 15:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.