Commit 4648b523 authored by unknown's avatar unknown
Browse files

Relaxed lock wait rules so that record lock does not need to wait for a

gap type lock.


innobase/lock/lock0lock.c:
  Record lock (LOCK_ORDINARY or LOCK_REC_NOT_GAP) does not need to wait for a
  gap type lock.
innobase/row/row0ins.c:
  Polishing.
parent 96dba685
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -775,17 +775,20 @@ lock_rec_has_to_wait(

		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. */
			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)
		if (!(type_mode & LOCK_INSERT_INTENTION)
						&& lock_rec_get_gap(lock2)) {
			/* Lock on just the record does not need to wait for
			a gap type lock */

			/* Record lock (LOCK_ORDINARY or LOCK_REC_NOT_GAP
			does not need to wait for a gap type lock */

			return(FALSE);
		}
+26 −21
Original line number Diff line number Diff line
@@ -1635,21 +1635,24 @@ row_ins_duplicate_error_in_clust(
			sure that in roll-forward we get the same duplicate
			errors as in original execution */

			dict_accept(*trx->mysql_query_str, "REPLACE", &success);
			dict_accept(*trx->mysql_query_str, "REPLACE", 
				    &success);

			if (success) {

				/* The manual defines the REPLACE semantics that it 
				is either an INSERT or DELETE(s) for duplicate key
				+ INSERT. Therefore, we should take X-lock for
				duplicates */
				/* The manual defines the REPLACE semantics 
				that it is either an INSERT or DELETE(s) 
				for duplicate key + INSERT. Therefore, we 
				should take X-lock for duplicates */
				
				err = row_ins_set_exclusive_rec_lock(
					LOCK_REC_NOT_GAP,rec,cursor->index,thr);
					LOCK_REC_NOT_GAP,rec,cursor->index,
					thr);
			} else {
				
				err = row_ins_set_shared_rec_lock(
					LOCK_REC_NOT_GAP,rec, cursor->index, thr);
					LOCK_REC_NOT_GAP,rec, cursor->index, 
					thr);
			} 

			if (err != DB_SUCCESS) {
@@ -1679,19 +1682,21 @@ row_ins_duplicate_error_in_clust(
			duplicates.
		        */

                        
			/* Is the first word in MySQL query REPLACE ? */

                        dict_accept(*trx->mysql_query_str, "REPLACE", &success);
		 	dict_accept(*trx->mysql_query_str, "REPLACE", 
				    &success);

			if (success) {

				err = row_ins_set_exclusive_rec_lock(
			       LOCK_REC_NOT_GAP,rec,cursor->index,thr);
						LOCK_REC_NOT_GAP,
						rec,cursor->index,thr);
			} else {

				err = row_ins_set_shared_rec_lock(
                               LOCK_REC_NOT_GAP,rec, cursor->index, thr);
						LOCK_REC_NOT_GAP,rec, 
						cursor->index, thr);
			}

			if (err != DB_SUCCESS) {