codeigniter - Unexpected AUTO_INCREMENT behaviour -


we have server running php 5.6.7, mariadb 10.0.17-mariadb. have codeigniter application, in have 2 tables: point_trigger , trigger_filter, connected point_trigger_id, one-to-many. both have id column set integer auto_increment (so no composite keys). heppened:

  1. a client removed 1 of point_triggers web interface. sa called controller removed row point_trigger , row (just 1 in case) trigger_filter. call logged, ends /delete/235, meaning point_trigger_id used locate rows deleted set 235. far good.

  2. couple of days later client goes web interface again , adds new point_trigger.

  3. client calls because point trigger created behaves unexpectedly.

  4. we check database, and... point_trigger table not have gap in ids, meaning point_trigger user created has the same id 235. check associated trigger_filter table , 1 doesn't have gap, autoincremented id table next one.

what know (or think know) both delete , add went ok in terms of removing rows. think because point_trigger client created after removing previous 1 has different parameters, , no edits logged before delete , add.

so apperantly there made auto_increment recalculate in time between delete , add of point_trigger. can tell or point be?

thanks in advance!

that user created has same id 235

could sequence of events?

  1. insert row , 235 assigned
  2. delete 235, leaving max(id)=234
  3. shut down mariadb
  4. start mariadb
  5. insert row , 235 again.

to elaborate on step 5:

  • open table -- find max(id)+1 (234+1) next id assign auto_increment
  • insert gets value (235).

sorry, way works. auto_increment guarantees uniqueness @ moment in time, not on time.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -