diff options
author | ingo@mysql.com <> | 2006-03-10 15:03:04 +0100 |
---|---|---|
committer | ingo@mysql.com <> | 2006-03-10 15:03:04 +0100 |
commit | d0c6eb885d7bb3a78bd2261372d7f41164636d40 (patch) | |
tree | 801bfa5ba08dc20436d5731d021e7d7e7cf2f4e5 /myisam/mi_unique.c | |
parent | e75a62aeaee8d429d7e725bf8f2ac7399dc3cd8b (diff) | |
download | mariadb-git-d0c6eb885d7bb3a78bd2261372d7f41164636d40.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).
Diffstat (limited to 'myisam/mi_unique.c')
-rw-r--r-- | myisam/mi_unique.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/myisam/mi_unique.c b/myisam/mi_unique.c index ad685f4cbdc..b5baa448609 100644 --- a/myisam/mi_unique.c +++ b/myisam/mi_unique.c @@ -30,6 +30,9 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, mi_unique_store(record+key->seg->start, unique_hash); _mi_make_key(info,def->key,key_buff,record,0); + /* The above changed info->lastkey2. Inform mi_rnext_same(). */ + info->update&= ~HA_STATE_RNEXT_SAME; + if (_mi_search(info,info->s->keyinfo+def->key,key_buff,MI_UNIQUE_HASH_LENGTH, SEARCH_FIND,info->s->state.key_root[def->key])) { |