summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-08-05 18:39:12 -0700
committerunknown <igor@olga.mysql.com>2007-08-05 18:39:12 -0700
commit9e5f383b26c2eaf740d62dfc37cbe7b273e71511 (patch)
treea961f3da443fbacf0fbef90d6e4e208edbc49c61
parent5807eb18b8f34bd68f081c1f4295713e4124e5d9 (diff)
parent29e8718970ceaf735abbf5f534b25fca97c11d85 (diff)
downloadmariadb-git-9e5f383b26c2eaf740d62dfc37cbe7b273e71511.tar.gz
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.1-opt-bug30219 mysql-test/r/type_bit.result: Auto merged mysql-test/t/type_bit.test: Auto merged sql/mysqld.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_table.cc: Auto merged BitKeeper/deleted/.del-readme.txt~3: Auto merged sql/field.h: Manual merge.
-rw-r--r--mysql-test/r/type_bit.result32
-rw-r--r--mysql-test/t/type_bit.test24
-rw-r--r--sql/field.h13
3 files changed, 66 insertions, 3 deletions
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index 8d7843cc0b1..ccfa601693c 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -618,6 +618,38 @@ bit_field int_field
 2
handler t1 close;
drop table t1;
+CREATE TABLE t1 (b BIT(2));
+INSERT INTO t1 (b) VALUES (1), (3), (0), (3);
+SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b;
+b+0 COUNT(DISTINCT b)
+0 1
+1 1
+3 1
+DROP TABLE t1;
+CREATE TABLE t1 (b BIT(2), a VARCHAR(5));
+INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
+SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
+b+0 COUNT(DISTINCT a)
+0 1
+1 1
+3 2
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(5), b BIT(2));
+INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
+SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
+b+0 COUNT(DISTINCT a)
+0 1
+1 1
+3 2
+DROP TABLE t1;
+CREATE TABLE t1 (a INT, b BIT(2));
+INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
+SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
+b+0 COUNT(DISTINCT a)
+0 1
+1 1
+3 2
+DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
insert into t1 values(0x40);
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index ae725b3b235..8d6b8fbbc4f 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -272,6 +272,30 @@ handler t1 read a=(1);
handler t1 close;
drop table t1;
+#
+# Bug #30219: GROUP BY a column of the BIT type
+#
+
+CREATE TABLE t1 (b BIT(2));
+INSERT INTO t1 (b) VALUES (1), (3), (0), (3);
+SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b;
+DROP TABLE t1;
+
+CREATE TABLE t1 (b BIT(2), a VARCHAR(5));
+INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
+SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(5), b BIT(2));
+INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
+SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT, b BIT(2));
+INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
+SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
+DROP TABLE t1;
+
--echo End of 5.0 tests
#
diff --git a/sql/field.h b/sql/field.h
index bcdacd43082..1861a5d6e6f 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -275,9 +275,9 @@ public:
if (null_ptr)
null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*);
}
- inline void get_image(uchar *buff,uint length, CHARSET_INFO *cs)
+ virtual void get_image(uchar *buff, uint length, CHARSET_INFO *cs)
{ memcpy(buff,ptr,length); }
- inline void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)
+ virtual void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)
{ memcpy(ptr,buff,length); }
@@ -1573,7 +1573,10 @@ public:
virtual bool str_needs_quotes() { return TRUE; }
my_decimal *val_decimal(my_decimal *);
int cmp(const uchar *a, const uchar *b)
- { return cmp_binary(a, b); }
+ {
+ DBUG_ASSERT(ptr == a);
+ return Field_bit::key_cmp((const byte *) b, bytes_in_rec+test(bit_len));
+ }
int cmp_binary_offset(uint row_offset)
{ return cmp_offset(row_offset); }
int cmp_max(const uchar *a, const uchar *b, uint max_length);
@@ -1581,6 +1584,10 @@ public:
{ return cmp_binary((uchar *) a, (uchar *) b); }
int key_cmp(const uchar *str, uint length);
int cmp_offset(uint row_offset);
+ void get_image(uchar *buff, uint length, CHARSET_INFO *cs)
+ { get_key_image(buff, length, itRAW); }
+ void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)
+ { Field_bit::store(buff, length, cs); }
uint get_key_image(uchar *buff, uint length, imagetype type);
void set_key_image(const uchar *buff, uint length)
{ Field_bit::store((char*) buff, length, &my_charset_bin); }