I am performing
SELECT … FOR UPDATE
or row level locking with InnoDB tables.
My intention is to only one request can read the same row. So if two users make request for the same data as the same time. Only one of them get data, who fires the query first.
But How can i test that locking is placed or not. as I am testing it by retrieving the same data at same time and both users getting the data.
Note: My tables are InnoDB, My query executes in transaction, my query as below:
SELECT * FROM table_name WHERE cond FOR UPDATE;
Any other thing I have to check for this to make work?
As far as I know, When we use FOR UPDATE in SELECT query then selected rows will get locked until transaction commits or Roll back and no other mysql thread can even select those rows. Is that correct?