MySQL Forums
Forum List  »  InnoDB

Next-key locking?
Posted by: Constantin Michael
Date: May 28, 2008 03:15PM

Hi,

Can anyone explain the following scenario.

Given a single table 't', with a single integer primary key, why would user B have to wait.

User A

START TRANSACTION;
SELECT * FROM t WHERE t.PrimaryKey <= 3 FOR UPDATE;
COMMIT;

User B

START TRANSACTION;
SELECT * FROM t WHERE t.PrimaryKey > 3 LOCK IN SHARE MODE;
COMMIT;

Surely, seeing that the set of primary keys < 3 being {1,2} and the set of primary keys >=3 being {3, 4, ..., n}, n = number of rows in the table, there would be no reason for user B to wait, seeing that they are mutually exclusive?

Many thanks

Constantin

Options: ReplyQuote


Subject
Views
Written By
Posted
Next-key locking?
2674
May 28, 2008 03:15PM
1486
June 08, 2008 06:54PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.