summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-11-03 20:45:52 +0300
committerKonstantin Osipov <kostja@sun.com>2009-11-03 20:45:52 +0300
commitcb0cca865587da1da071a67e0932dcfaa54a4b0c (patch)
treeec0ceb4d9e1f2553a541ffe6bbca3a5fef4381d0 /sql/sql_select.h
parent7b7f01499a6c5569f58484326a8a4cbb976096ae (diff)
parent06c9d62a9f72c1554b3619f10388092da4ee9c04 (diff)
downloadmariadb-git-cb0cca865587da1da071a67e0932dcfaa54a4b0c.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/innodb_lock_wait_timeout_1.result: Update results (Bug41756). mysql-test/t/innodb_lock_wait_timeout_1.test: Add a test case (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/sql_select.h')
-rw-r--r--sql/sql_select.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index d2703004df2..c9cd3ecba42 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -58,6 +58,8 @@ class store_key;
typedef struct st_table_ref
{
bool key_err;
+ /** True if something was read into buffer in join_read_key. */
+ bool has_record;
uint key_parts; ///< num of ...
uint key_length; ///< length of key_buff
int key; ///< key no
@@ -85,6 +87,11 @@ typedef struct st_table_ref
table_map depend_map; ///< Table depends on these tables.
/* null byte position in the key_buf. Used for REF_OR_NULL optimization */
uchar *null_ref_key;
+ /*
+ The number of times the record associated with this key was used
+ in the join.
+ */
+ ha_rows use_count;
} TABLE_REF;