summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-10-05 16:02:10 +0300
committerunknown <marko@hundin.mysql.fi>2004-10-05 16:02:10 +0300
commitfdbc804c3295fb4ba46e07b89554bb924cbd7d92 (patch)
tree8f74f907801c9488862cd502c6059497de0b5d2e
parent15c2ecb543156cc3a72b1503eb0f3dac634c6b6c (diff)
parent08e56fae9887d3adc4a3c3c1c351f7a3c388573f (diff)
downloadmariadb-git-fdbc804c3295fb4ba46e07b89554bb924cbd7d92.tar.gz
Merge marko@build.mysql.com:/home/bk/mysql-4.1
into hundin.mysql.fi:/home/marko/j/mysql-4.1
-rw-r--r--mysql-test/r/func_group.result26
-rw-r--r--mysql-test/t/func_group.test24
-rw-r--r--sql/ha_heap.cc8
3 files changed, 52 insertions, 6 deletions
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 011a47874c2..c25f89d4df3 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -693,3 +693,29 @@ SELECT MIN(a) FROM t1 WHERE a < 0;
MIN(a)
NULL
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;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 7f48f2b92bd..3e001961f90 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -431,6 +431,30 @@ SELECT MIN(a) FROM t1 WHERE a < 0;
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;
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 5be51ec8494..9344bfc0c8c 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -428,12 +428,8 @@ int ha_heap::create(const char *name, TABLE *table_arg,
seg->type= field->key_type();
else
{
- if (!f_is_packed(flag) &&
- f_packtype(flag) == (int) FIELD_TYPE_DECIMAL &&
- !(field->charset() == &my_charset_bin))
- seg->type= (int) HA_KEYTYPE_TEXT;
- else
- seg->type= (int) HA_KEYTYPE_BINARY;
+ if ((seg->type = field->key_type()) != (int) HA_KEYTYPE_TEXT)
+ seg->type= HA_KEYTYPE_BINARY;
}
seg->start= (uint) key_part->offset;
seg->length= (uint) key_part->length;