Loading myisam/mi_create.c +1 −1 Original line number Diff line number Diff line Loading @@ -224,7 +224,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (uniques) { max_key_block_length= MI_KEY_BLOCK_LENGTH; max_key_length= MI_UNIQUE_HASH_LENGTH; max_key_length= MI_UNIQUE_HASH_LENGTH + pointer; } for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++) Loading myisam/mi_unique.c +10 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, { my_off_t lastpos=info->lastpos; MI_KEYDEF *key= &info->s->keyinfo[def->key]; uchar *key_buff=info->lastkey+info->s->base.max_key_length; uchar *key_buff=info->lastkey2; DBUG_ENTER("mi_check_unique"); mi_unique_store(record+key->seg->start, unique_hash); Loading Loading @@ -80,8 +80,17 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) if (keyseg->null_bit) { if (record[keyseg->null_pos] & keyseg->null_bit) { /* Change crc in a way different from an empty string or 0. (This is an optimisation; The code will work even if this isn't done) */ crc=((crc << 8) + 511+ (crc >> (8*sizeof(ha_checksum)-8))); continue; } } pos= record+keyseg->start; if (keyseg->flag & HA_VAR_LENGTH) { Loading mysql-test/r/group_by.result +8 −0 Original line number Diff line number Diff line Loading @@ -102,3 +102,11 @@ pid c1id c2id value id active id active 1 4 NULL 4 4 Yes NULL NULL max(value) 4 a count(*) NULL 9 3 b 1 a count(*) NULL 9 3 b 1 mysql-test/t/group_by.test +11 −0 Original line number Diff line number Diff line Loading @@ -312,3 +312,14 @@ m.c1id = c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = c2.id AND c2.active = 'Yes' WHERE m.pid=1 AND (c1.id IS NOT NULL OR c2.id IS NOT NULL); drop table t1,t2,t3; # # Test bug in GROUP BY on BLOB that is NULL or empty # create table t1 (a blob null); insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(""),(""),(""),("b"); select a,count(*) from t1 group by a; set option sql_big_tables=1; select a,count(*) from t1 group by a; drop table t1; Loading
myisam/mi_create.c +1 −1 Original line number Diff line number Diff line Loading @@ -224,7 +224,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (uniques) { max_key_block_length= MI_KEY_BLOCK_LENGTH; max_key_length= MI_UNIQUE_HASH_LENGTH; max_key_length= MI_UNIQUE_HASH_LENGTH + pointer; } for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++) Loading
myisam/mi_unique.c +10 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, { my_off_t lastpos=info->lastpos; MI_KEYDEF *key= &info->s->keyinfo[def->key]; uchar *key_buff=info->lastkey+info->s->base.max_key_length; uchar *key_buff=info->lastkey2; DBUG_ENTER("mi_check_unique"); mi_unique_store(record+key->seg->start, unique_hash); Loading Loading @@ -80,8 +80,17 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) if (keyseg->null_bit) { if (record[keyseg->null_pos] & keyseg->null_bit) { /* Change crc in a way different from an empty string or 0. (This is an optimisation; The code will work even if this isn't done) */ crc=((crc << 8) + 511+ (crc >> (8*sizeof(ha_checksum)-8))); continue; } } pos= record+keyseg->start; if (keyseg->flag & HA_VAR_LENGTH) { Loading
mysql-test/r/group_by.result +8 −0 Original line number Diff line number Diff line Loading @@ -102,3 +102,11 @@ pid c1id c2id value id active id active 1 4 NULL 4 4 Yes NULL NULL max(value) 4 a count(*) NULL 9 3 b 1 a count(*) NULL 9 3 b 1
mysql-test/t/group_by.test +11 −0 Original line number Diff line number Diff line Loading @@ -312,3 +312,14 @@ m.c1id = c1.id AND c1.active = 'Yes' LEFT JOIN t3 AS c2 ON m.c2id = c2.id AND c2.active = 'Yes' WHERE m.pid=1 AND (c1.id IS NOT NULL OR c2.id IS NOT NULL); drop table t1,t2,t3; # # Test bug in GROUP BY on BLOB that is NULL or empty # create table t1 (a blob null); insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(""),(""),(""),("b"); select a,count(*) from t1 group by a; set option sql_big_tables=1; select a,count(*) from t1 group by a; drop table t1;