Commit efc82fb8 authored by mmakela's avatar mmakela

branches/innodb+: Buffer DELETE and purge on UNIQUE indexes. Sunny

noted that the check for ignore_secondary_unique might not be disabled
for deletes.  Indeed, I see no reason for the check to exist for deletes.

btr_op_enum: Document the constants. Add BTR_INSERT_IGNORE_UNIQUE_OP.

btr_cur_search_to_nth_level(): Remove the variable
ignore_sec_unique. Use btr_op instead. Invoke ibuf_should_try() with
ignore_sec_unique = (btr_op != BTR_INSERT_OP), that is, always ignore
the UNIQUE constraint when buffering delete-mark and purge.

BTR_IGNORE_SEC_UNIQUE: Note that the flag only makes sense in
conjunction with BTR_INSERT.

rb://274 approved by Sunny Bains.  This addresses Issue #471.
parent 66ed2719
......@@ -68,12 +68,13 @@ Created 10/16/1994 Heikki Tuuri
#include "lock0lock.h"
#include "zlib.h"
/* Btree operation types, introduced as part of delete buffering. */
/** Buffered B-tree operation types, introduced as part of delete buffering. */
typedef enum btr_op_enum {
BTR_NO_OP = 0,
BTR_INSERT_OP,
BTR_DELETE_OP,
BTR_DELMARK_OP
BTR_NO_OP = 0, /*!< Not buffered */
BTR_INSERT_OP, /*!< Insert, do not ignore UNIQUE */
BTR_INSERT_IGNORE_UNIQUE_OP, /*!< Insert, ignoring UNIQUE */
BTR_DELETE_OP, /*!< Purge a delete-marked record */
BTR_DELMARK_OP /*!< Mark a record for deletion */
} btr_op_t;
#ifdef UNIV_DEBUG
......@@ -375,8 +376,7 @@ btr_cur_search_to_nth_level(
ulint estimate;
ulint zip_size;
page_cur_t* page_cursor;
ulint ignore_sec_unique;
btr_op_t btr_op = BTR_NO_OP;
btr_op_t btr_op;
ulint root_height = 0; /* remove warning */
#ifdef BTR_CUR_ADAPT
......@@ -406,9 +406,12 @@ btr_cur_search_to_nth_level(
& (BTR_INSERT | BTR_DELETE | BTR_DELETE_MARK),
0)) {
case 0:
btr_op = BTR_NO_OP;
break;
case BTR_INSERT:
btr_op = BTR_INSERT_OP;
btr_op = (latch_mode & BTR_IGNORE_SEC_UNIQUE)
? BTR_INSERT_IGNORE_UNIQUE_OP
: BTR_INSERT_OP;
break;
case BTR_DELETE:
btr_op = BTR_DELETE_OP;
......@@ -429,7 +432,6 @@ btr_cur_search_to_nth_level(
ut_ad(btr_op == BTR_NO_OP || !dict_index_is_clust(index));
estimate = latch_mode & BTR_ESTIMATE;
ignore_sec_unique = latch_mode & BTR_IGNORE_SEC_UNIQUE;
/* Turn the flags unrelated to the latch mode off. */
latch_mode &= ~(BTR_INSERT
......@@ -573,7 +575,7 @@ search_loop:
rw_latch = latch_mode;
if (btr_op != BTR_NO_OP
&& ibuf_should_try(index, ignore_sec_unique)) {
&& ibuf_should_try(index, btr_op != BTR_INSERT_OP)) {
/* Try to buffer the operation if the leaf
page is not in the buffer pool. */
......@@ -600,6 +602,7 @@ retry_page_get:
switch (btr_op) {
case BTR_INSERT_OP:
case BTR_INSERT_IGNORE_UNIQUE_OP:
ut_ad(buf_mode == BUF_GET_IF_IN_POOL);
if (ibuf_insert(IBUF_OP_INSERT, tuple, index,
......
......@@ -79,7 +79,7 @@ When the record is not in the buffer pool, try to use the insert buffer. */
optimization */
#define BTR_ESTIMATE 1024
/** This flag ORed to btr_latch_mode says that we can ignore possible
/** This flag ORed to BTR_INSERT says that we can ignore possible
UNIQUE definition on secondary indexes when we decide if we can use
the insert buffer to speed up inserts */
#define BTR_IGNORE_SEC_UNIQUE 2048
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment