witness the destruction of mysql (read all 5 entries…)
Why God why?!!?! 4 years ago

How asinine is this?!? The best part is

The auto-increment counter is stored only in main memory, not on disk.

Let’s see how this lets us have fun.

  1. Create a table with an auto-increment key
  2. Insert two entries into said table
  3. Delete entry with greatest key; note key value
  4. Stop MySQL
  5. Start MySQL
  6. Insert a single entry into our favorite table

The newly inserted key value will be equal to the deleted key value. Wait, what? Another way to have fun with this is

  1. Create a table with an auto-increment key
  2. Insert a single entry into our favorite table; note key value
  3. Delete entry (using where id =); table should be empty
  4. Stop MySQL
  5. Start MySQL
  6. Insert a single entry into our favorite table

The newly inserted key value will be 1, regardless of the deleted key value. Why bother having auto_increment functionality if it always wants to reset itself?



Comments:

Also, note...

this hasn’t been fixed in 5.0.

(This comment was deleted.)

 

I want to:
43 Things Login