summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorAnnamalai Gurusami <annamalai.gurusami@oracle.com>2012-07-12 16:42:07 +0530
committerAnnamalai Gurusami <annamalai.gurusami@oracle.com>2012-07-12 16:42:07 +0530
commite612f55237d79ae67f613391657447e6059321d3 (patch)
tree0fbfb9778a7081cd41d12ac6a3fbf1d6d0742dbb /sql/handler.cc
parentf4fd8bcfae5fc70a79f9f54f8db387489e373011 (diff)
downloadmariadb-git-e612f55237d79ae67f613391657447e6059321d3.tar.gz
Bug #11765218 58157: INNODB LOCKS AN UNMATCHED ROW EVEN THOUGH USING
RBR AND RC Description: When scanning and locking rows with < or <=, InnoDB locks the next row even though row based binary logging and read committed is used. Solution: In the handler, when the row is identified to fall outside of the range (as specified in the query predicates), then request the storage engine to unlock the row (if possible). This is done in handler::read_range_first() and handler::read_range_next().
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc29
1 files changed, 27 insertions, 2 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 9e43d5aba93..4f5c613a6a4 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4287,7 +4287,19 @@ int handler::read_range_first(const key_range *start_key,
? HA_ERR_END_OF_FILE
: result);
- DBUG_RETURN (compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
+ if (compare_key(end_range) <= 0)
+ {
+ DBUG_RETURN(0);
+ }
+ else
+ {
+ /*
+ The last read row does not fall in the range. So request
+ storage engine to release row lock if possible.
+ */
+ unlock_row();
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
}
@@ -4319,7 +4331,20 @@ int handler::read_range_next()
result= index_next(table->record[0]);
if (result)
DBUG_RETURN(result);
- DBUG_RETURN(compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
+
+ if (compare_key(end_range) <= 0)
+ {
+ DBUG_RETURN(0);
+ }
+ else
+ {
+ /*
+ The last read row does not fall in the range. So request
+ storage engine to release row lock if possible.
+ */
+ unlock_row();
+ DBUG_RETURN(HA_ERR_END_OF_FILE);
+ }
}