summaryrefslogtreecommitdiff
path: root/myisam/mi_rkey.c
diff options
context:
space:
mode:
authorunknown <monty@mysql.com/narttu.mysql.fi>2006-08-10 22:41:19 +0300
committerunknown <monty@mysql.com/narttu.mysql.fi>2006-08-10 22:41:19 +0300
commitdcb665900136fb4015589680c612add8abf1deca (patch)
tree646dde4e78f50732e480c83d04296548ed4e1249 /myisam/mi_rkey.c
parent189a6879715ca293a560e37a17984c8b3a952e49 (diff)
downloadmariadb-git-dcb665900136fb4015589680c612add8abf1deca.tar.gz
Better bug fix for #14400 "Query joins wrong rows from table which is subject of "concurrent insert""
The previous bug fix didn't work when using partial keys. Don't use GNUC min/max operations are they are depricated. Fixed valgrind warning BitKeeper/etc/ignore: Added */.libs/* include/my_global.h: Don't use GNUC min/max operations are they are depricated myisam/mi_rkey.c: Better bug fix for #14400 "Query joins wrong rows from table which is subject of "concurrent insert"" The previous bug fix didn't work when using partial keys. myisam/mi_test_all.res: Updated results to match mi_test_all.sh myisam/mi_test_all.sh: Removed confusing warning mysql-test/r/myisam.result: Added test case for #14400 mysql-test/t/myisam.test: Added test case for #14400 sql/sql_select.cc: Fixed valgrind warning (in field_string::val_int())
Diffstat (limited to 'myisam/mi_rkey.c')
-rw-r--r--myisam/mi_rkey.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/myisam/mi_rkey.c b/myisam/mi_rkey.c
index 41c2e173b70..f051558cae5 100644
--- a/myisam/mi_rkey.c
+++ b/myisam/mi_rkey.c
@@ -78,32 +78,39 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
if (!_mi_search(info,keyinfo, key_buff, use_key_length,
myisam_read_vec[search_flag], info->s->state.key_root[inx]))
{
- /*
- If we are searching for an exact key (including the data pointer)
- and this was added by an concurrent insert,
- then the result is "key not found".
- */
- if ((search_flag == HA_READ_KEY_EXACT) &&
- (info->lastpos >= info->state->data_file_length))
+ if (info->lastpos >= info->state->data_file_length)
{
- my_errno= HA_ERR_KEY_NOT_FOUND;
- info->lastpos= HA_OFFSET_ERROR;
- }
- else while (info->lastpos >= info->state->data_file_length)
- {
- /*
- Skip rows that are inserted by other threads since we got a lock
- Note that this can only happen if we are not searching after an
- exact key, because the keys are sorted according to position
- */
- if (_mi_search_next(info, keyinfo, info->lastkey,
- info->lastkey_length,
- myisam_readnext_vec[search_flag],
- info->s->state.key_root[inx]))
- break;
+ do
+ {
+ uint not_used;
+ /*
+ If we are searching for an exact key, abort if we find a bigger
+ key.
+ */
+ if (search_flag == HA_READ_KEY_EXACT &&
+ (use_key_length == USE_WHOLE_KEY ||
+ _mi_key_cmp(keyinfo->seg, key_buff, info->lastkey, use_key_length,
+ SEARCH_FIND, &not_used)))
+ {
+ my_errno= HA_ERR_END_OF_FILE;
+ info->lastpos= HA_OFFSET_ERROR;
+ break;
+ }
+ /*
+ Skip rows that are inserted by other threads since we got a lock
+ Note that this can only happen if we are not searching after an
+ full length exact key, because the keys are sorted
+ according to position
+ */
+ if (_mi_search_next(info, keyinfo, info->lastkey,
+ info->lastkey_length,
+ myisam_readnext_vec[search_flag],
+ info->s->state.key_root[inx]))
+ break;
+ }
+ while (info->lastpos >= info->state->data_file_length);
}
}
-
if (share->concurrent_insert)
rw_unlock(&share->key_root_lock[inx]);