summaryrefslogtreecommitdiff
path: root/sql/records.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-11-03 19:58:54 +0300
committerKonstantin Osipov <kostja@sun.com>2009-11-03 19:58:54 +0300
commit06c9d62a9f72c1554b3619f10388092da4ee9c04 (patch)
tree1b46031b7251ae32976a8ee0a622f7a7f3235cc5 /sql/records.cc
parent9819885177059fd75f3250b917142eb9d6ae5b8c (diff)
downloadmariadb-git-06c9d62a9f72c1554b3619f10388092da4ee9c04.tar.gz
A fix and a test case for
Bug#41756 "Strange error messages about locks from InnoDB". In JT_EQ_REF (join_read_key()) access method, don't try to unlock rows in the handler, unless certain that a) they were locked b) they are not used. Unlocking of rows is done by the logic of the nested join loop, and is unaware of the possible caching that the access method may have. This could lead to double unlocking, when a row was unlocked first after reading into the cache, and then when taken from cache, as well as to unlocking of rows which were actually used (but taken from cache). Delegate part of the unlocking logic to the access method, and in JT_EQ_REF count how many times a record was actually used in the join. Unlock it only if it's usage count is 0. Implemented review comments. mysql-test/r/bug41756.result: Add result file (Bug#41756) mysql-test/t/bug41756-master.opt: Use --innodb-locks-unsafe-for-binlog, as in 5.0 just using read_committed isolation is not sufficient to reproduce the bug. mysql-test/t/bug41756.test: Add a test file (Bug#41756) sql/item_subselect.cc: Complete struct READ_RECORD initialization with a new member to unlock records. sql/records.cc: Extend READ_RECORD API with a method to unlock read records. sql/sql_select.cc: In JT_EQ_REF (join_read_key()) access method, don't try to unlock rows in the handler, unless certain that a) they were locked b) they are not used. sql/sql_select.h: Add members to TABLE_REF to count TABLE_REF buffer usage count. sql/structs.h: Update declarations.
Diffstat (limited to 'sql/records.cc')
-rw-r--r--sql/records.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/records.cc b/sql/records.cc
index d564533ae7a..26f4fd4aa23 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -61,6 +61,7 @@ void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
info->file= table->file;
info->record= table->record[0];
info->print_error= print_error;
+ info->unlock_row= rr_unlock_row;
table->status=0; /* And it's always found */
if (!table->file->inited)
@@ -135,6 +136,7 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
}
info->select=select;
info->print_error=print_error;
+ info->unlock_row= rr_unlock_row;
info->ignore_not_found_rows= 0;
table->status=0; /* And it's always found */