summaryrefslogtreecommitdiff
path: root/myisammrg
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-09-23 10:15:11 +0200
committerunknown <ingo@mysql.com>2005-09-23 10:15:11 +0200
commit674c8165ea4b3430f397d84b0c79642de7b12ce4 (patch)
treecc4780b69204be49c89964f8598a382e90523fe0 /myisammrg
parenta89807336f8fa8b39bd519198f26db6c2b1fb247 (diff)
downloadmariadb-git-674c8165ea4b3430f397d84b0c79642de7b12ce4.tar.gz
Bug#9112 - Merge table with composite index producing invalid results with some queries
The problem was an ab-use of last_rkey_length. Formerly we saved the packed key length (of the search key) in this element. But in certain cases it got replaced by the (packed) result key length. Now we use a new element of MI_INFO to save the packed key length of the search key. myisam/mi_dbug.c: Bug#9112 - Merge table with composite index producing invalid results with some queries Fixed the recognition of NULL values in _mi_print_key(). myisam/mi_rkey.c: Bug#9112 - Merge table with composite index producing invalid results with some queries Saved the packed key length in a new element of MI_INFO. myisam/mi_search.c: Bug#9112 - Merge table with composite index producing invalid results with some queries Added a comment and trace prints. myisam/myisamdef.h: Bug#9112 - Merge table with composite index producing invalid results with some queries Added a new element to store the packed key length for use by the MyISAMMRG engine. myisammrg/myrg_rkey.c: Bug#9112 - Merge table with composite index producing invalid results with some queries Changed to use the new element of MI_INFO to get at the packed key length. mysql-test/r/merge.result: Bug#9112 - Merge table with composite index producing invalid results with some queries The test result. mysql-test/t/merge.test: Bug#9112 - Merge table with composite index producing invalid results with some queries The test case.
Diffstat (limited to 'myisammrg')
-rw-r--r--myisammrg/myrg_rkey.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c
index fbfa7f24921..5208cb52ac2 100644
--- a/myisammrg/myrg_rkey.c
+++ b/myisammrg/myrg_rkey.c
@@ -44,11 +44,12 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key,
MYRG_TABLE *table;
MI_INFO *mi;
int err;
+ DBUG_ENTER("myrg_rkey");
LINT_INIT(key_buff);
LINT_INIT(pack_key_length);
if (_myrg_init_queue(info,inx,search_flag))
- return my_errno;
+ DBUG_RETURN(my_errno);
for (table=info->open_tables ; table != info->end_table ; table++)
{
@@ -57,8 +58,9 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key,
if (table == info->open_tables)
{
err=mi_rkey(mi,0,inx,key,key_len,search_flag);
+ /* Get the saved packed key and packed key length. */
key_buff=(byte*) mi->lastkey+mi->s->base.max_key_length;
- pack_key_length=mi->last_rkey_length;
+ pack_key_length=mi->pack_key_length;
}
else
{
@@ -72,16 +74,21 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key,
{
if (err == HA_ERR_KEY_NOT_FOUND)
continue;
- return err;
+ DBUG_PRINT("exit", ("err: %d", err));
+ DBUG_RETURN(err);
}
/* adding to queue */
queue_insert(&(info->by_key),(byte *)table);
}
+ DBUG_PRINT("info", ("tables with matches: %u", info->by_key.elements));
if (!info->by_key.elements)
- return HA_ERR_KEY_NOT_FOUND;
+ DBUG_RETURN(HA_ERR_KEY_NOT_FOUND);
mi=(info->current_table=(MYRG_TABLE *)queue_top(&(info->by_key)))->table;
- return _myrg_mi_read_record(mi,buf);
+ DBUG_PRINT("info", ("using table no: %d",
+ info->current_table - info->open_tables + 1));
+ DBUG_DUMP("result key", (byte*) mi->lastkey, mi->lastkey_length);
+ DBUG_RETURN(_myrg_mi_read_record(mi,buf));
}