Commit f468b91f authored by unknown's avatar unknown

Fix for Bug#3904 "COUNT DISTINCT performance anomaly in 4.1"

The bug was caused by error in hash calculation function: it
always returned hash value for last field in a composite key, so 
for keys like (a text, b char(1)) we were always
getting bad hash values.
 


myisam/mi_unique.c:
  Fix for bug #3904:
  We should take into account existing hash value when calculating hash for
  next key in a composite unique index.
parent 350ad500
...@@ -71,6 +71,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) ...@@ -71,6 +71,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
const byte *pos, *end; const byte *pos, *end;
ha_checksum crc=0; ha_checksum crc=0;
HA_KEYSEG *keyseg; HA_KEYSEG *keyseg;
ulong seed= 4;
for (keyseg=def->seg ; keyseg < def->end ; keyseg++) for (keyseg=def->seg ; keyseg < def->end ; keyseg++)
{ {
...@@ -108,9 +109,8 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) ...@@ -108,9 +109,8 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
end= pos+length; end= pos+length;
if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT) if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT)
{ {
ulong nr=1, nr2=4; keyseg->charset->coll->hash_sort(keyseg->charset,
keyseg->charset->coll->hash_sort(keyseg->charset,(const uchar*)pos,length,&nr, &nr2); (const uchar*) pos, length, &crc, &seed);
crc=nr;
} }
else else
while (pos != end) while (pos != end)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment