Commit 438cc71a authored by unknown's avatar unknown

Fix for bug #5555: "GROUP BY enum_field" returns incorrect results

parent e767d7a4
...@@ -693,3 +693,29 @@ SELECT MIN(a) FROM t1 WHERE a < 0; ...@@ -693,3 +693,29 @@ SELECT MIN(a) FROM t1 WHERE a < 0;
MIN(a) MIN(a)
NULL NULL
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
val enum('one','two','three') NOT NULL default 'one',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES
(1,'one'),(2,'two'),(3,'three'),(4,'one'),(5,'two');
select val, count(*) from t1 group by val;
val count(*)
one 2
two 2
three 1
drop table t1;
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
val set('one','two','three') NOT NULL default 'one',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES
(1,'one'),(2,'two'),(3,'three'),(4,'one'),(5,'two');
select val, count(*) from t1 group by val;
val count(*)
one 2
two 2
three 1
drop table t1;
...@@ -431,6 +431,30 @@ SELECT MIN(a) FROM t1 WHERE a < 0; ...@@ -431,6 +431,30 @@ SELECT MIN(a) FROM t1 WHERE a < 0;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #5555 GROUP BY enum_field" returns incorrect results
#
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
val enum('one','two','three') NOT NULL default 'one',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES
(1,'one'),(2,'two'),(3,'three'),(4,'one'),(5,'two');
select val, count(*) from t1 group by val;
drop table t1;
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
val set('one','two','three') NOT NULL default 'one',
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES
(1,'one'),(2,'two'),(3,'three'),(4,'one'),(5,'two');
select val, count(*) from t1 group by val;
drop table t1;
...@@ -428,12 +428,8 @@ int ha_heap::create(const char *name, TABLE *table_arg, ...@@ -428,12 +428,8 @@ int ha_heap::create(const char *name, TABLE *table_arg,
seg->type= field->key_type(); seg->type= field->key_type();
else else
{ {
if (!f_is_packed(flag) && if ((seg->type = field->key_type()) != (int) HA_KEYTYPE_TEXT)
f_packtype(flag) == (int) FIELD_TYPE_DECIMAL && seg->type= HA_KEYTYPE_BINARY;
!(field->charset() == &my_charset_bin))
seg->type= (int) HA_KEYTYPE_TEXT;
else
seg->type= (int) HA_KEYTYPE_BINARY;
} }
seg->start= (uint) key_part->offset; seg->start= (uint) key_part->offset;
seg->length= (uint) key_part->length; seg->length= (uint) key_part->length;
......
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