summaryrefslogtreecommitdiff
path: root/myisam/mi_key.c
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2006-03-10 15:03:04 +0100
committerunknown <ingo@mysql.com>2006-03-10 15:03:04 +0100
commitfbe17c2a36dcaa99c5a6570f7096745126113301 (patch)
tree801bfa5ba08dc20436d5731d021e7d7e7cf2f4e5 /myisam/mi_key.c
parenta7abbd918ba952e2f387cec28ed0f74997b14975 (diff)
downloadmariadb-git-fbe17c2a36dcaa99c5a6570f7096745126113301.tar.gz
Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX
For "count(*) while index_column = value" an index read is done. It consists of an index scan and retrieval of each key. For efficiency reasons the index scan stores the key in the special buffer 'lastkey2' once only. At the first iteration it notes this fact with the flag HA_STATE_RNEXT_SAME in 'info->update'. For efficiency reasons, the key retrieval for blobs does not allocate a new buffer, but uses 'lastkey2'... Now I clear the HA_STATE_RNEXT_SAME flag whenever the buffer has been polluted. In this case, the index scan copies the key value again (and sets the flag again). include/my_base.h: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Changed the comment for HA_STATE_RNEXT_SAME as a warning for future uses. myisam/mi_delete.c: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Removing the flag HA_STATE_RNEXT_SAME from info->update if info->lastkey2 was reused for another purpose than index scanning. myisam/mi_key.c: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Removing the flag HA_STATE_RNEXT_SAME from info->update if info->lastkey2 was reused for another purpose than index scanning. myisam/mi_rnext_same.c: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Removed trailing space and fixed a comment. myisam/mi_unique.c: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Removing the flag HA_STATE_RNEXT_SAME from info->update if info->lastkey2 was reused for another purpose than index scanning. myisam/mi_update.c: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Removing the flag HA_STATE_RNEXT_SAME from info->update if info->lastkey2 was reused for another purpose than index scanning. myisam/mi_write.c: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Removing the flag HA_STATE_RNEXT_SAME from info->update if info->lastkey2 was reused for another purpose than index scanning. mysql-test/r/myisam.result: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Added test result. mysql-test/t/myisam.test: Bug#14980 - COUNT(*) incorrect on MyISAM table with certain INDEX Added test.
Diffstat (limited to 'myisam/mi_key.c')
-rw-r--r--myisam/mi_key.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/myisam/mi_key.c b/myisam/mi_key.c
index f4b92f969db..cb85febd869 100644
--- a/myisam/mi_key.c
+++ b/myisam/mi_key.c
@@ -393,6 +393,10 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr,
(char*) &blob_ptr,sizeof(char*));
memcpy(blob_ptr,key,length);
blob_ptr+=length;
+
+ /* The above changed info->lastkey2. Inform mi_rnext_same(). */
+ info->update&= ~HA_STATE_RNEXT_SAME;
+
_my_store_blob_length(record+keyseg->start,
(uint) keyseg->bit_start,length);
key+=length;