summaryrefslogtreecommitdiff
path: root/innobase/lock
diff options
context:
space:
mode:
authorjan@hundin.mysql.fi <>2004-08-12 13:38:10 +0300
committerjan@hundin.mysql.fi <>2004-08-12 13:38:10 +0300
commit38255a2cadc7fb85995bf6885b6e574cce995fea (patch)
treec84eabb3549018fae4e8e4265a3c652b67d34b78 /innobase/lock
parentd35df170fd4b7e3eb4fba73be10f3d1bf4c22f0d (diff)
downloadmariadb-git-38255a2cadc7fb85995bf6885b6e574cce995fea.tar.gz
This change includes optimization for a lock wait rules and a new behaviour for
a REPLACE command.
Diffstat (limited to 'innobase/lock')
-rw-r--r--innobase/lock/lock0lock.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 2ace0822a82..2d326f7392f 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -758,10 +758,10 @@ lock_rec_has_to_wait(
lock_t* lock2, /* in: another record lock; NOTE that it is assumed
that this has a lock bit set on the same record as
in the new lock we are setting */
- ibool lock_is_on_supremum) /* in: TRUE if we are setting the lock
- on the 'supremum' record of an index page: we know
- then that the lock request is really for a 'gap' type
- lock */
+ ibool lock_is_on_supremum) /* in: TRUE if we are setting the lock
+ on the 'supremum' record of an index
+ page: we know then that the lock request
+ is really for a 'gap' type lock */
{
ut_ad(trx && lock2);
ut_ad(lock_get_type(lock2) == LOCK_REC);
@@ -773,15 +773,15 @@ lock_rec_has_to_wait(
/* We have somewhat complex rules when gap type record locks
cause waits */
- if( lock_is_on_supremum && !(type_mode & LOCK_INSERT_INTENTION))
- {
- /* Lock on the supremum record is really a 'gap' type lock
- and gap type lock do not need to wait if it
- is not LOCK_INSERT_INTENSION type lock */
-
- return(FALSE);
- }
-
+ if (( lock_is_on_supremum || (type_mode & LOCK_GAP))
+ && !(type_mode & LOCK_INSERT_INTENTION)) {
+ /* Gap type locks without LOCK_INSERT_INTENTION flag
+ do not need to wait for anything. This is because different
+ users can have conflicting lock types on gaps. */
+
+ return(FALSE);
+ }
+
if ((type_mode & LOCK_REC_NOT_GAP)
&& lock_rec_get_gap(lock2)) {
/* Lock on just the record does not need to wait for
@@ -842,9 +842,12 @@ lock_has_to_wait(
if (lock_get_type(lock1) == LOCK_REC) {
ut_ad(lock_get_type(lock2) == LOCK_REC);
-
+ /* If this lock request is for a supremum record
+ then the second bit on the lock bitmap is set */
+
return(lock_rec_has_to_wait(lock1->trx,
- lock1->type_mode, lock2,(ibool)lock_rec_get_nth_bit(lock1,1)));
+ lock1->type_mode, lock2,
+ lock_rec_get_nth_bit(lock1,1)));
}
return(TRUE);
@@ -1433,7 +1436,8 @@ lock_rec_other_has_conflicting(
lock = lock_rec_get_first(rec);
while (lock) {
- if (lock_rec_has_to_wait(trx, mode, lock, (ibool)page_rec_is_supremum(rec))) {
+ if (lock_rec_has_to_wait(trx, mode, lock,
+ page_rec_is_supremum(rec))) {
return(lock);
}