locking a specific record in MySQL -


i implement record locking mechanism follows:

table1:     field: "id" (autoincrement, primary)     field: "name" (text)     field: "more fields..."  table2:     field: "id" (unique) 

in order lock specific record in table1, i'll create record in table2 same id. if creation fails due such record existing, record must locked process , spin. if succeeds, have lock , can modify record. when i'm done, delete lock record in table2.

my question whether valid way implement per-record lock, , if not, there such thing?

cheers, charlie.

you can use innodb row-based locking,
or read-lock instead of impose locking table,
(rather let mysql handle race-condition)


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -