summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ramil/ram@ramil.myoffice.izhnet.ru>2007-10-15 09:44:22 +0500
committerunknown <ramil/ram@ramil.myoffice.izhnet.ru>2007-10-15 09:44:22 +0500
commitb777dbfba87eb4acb22f1601a3951717a33227c4 (patch)
treea407143dd2bb6c74aaa0f76d989528867fa0215d
parent8a88cacb6121f8b6b245157c60e57c3f861d90b4 (diff)
parent24a567e9f6e73f4158eba43cf16d30ad1c8c86b4 (diff)
downloadmariadb-git-b777dbfba87eb4acb22f1601a3951717a33227c4.tar.gz
Merge mysql.com:/home/ram/work/b31154/b31154.5.0
into mysql.com:/home/ram/work/b31154/b31154.5.1 mysql-test/r/func_gconcat.result: Auto merged mysql-test/t/func_gconcat.test: Auto merged sql/item_sum.cc: Auto merged
-rw-r--r--mysql-test/r/func_gconcat.result42
-rw-r--r--mysql-test/t/func_gconcat.test28
-rw-r--r--sql/item_sum.cc31
3 files changed, 95 insertions, 6 deletions
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index b17c5e5409c..7ae7806baea 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -825,4 +825,46 @@ id group_concat(b.name)
1 óra,óra
2 óra,óra
drop table t1;
+create table t1(a bit not null);
+insert into t1 values (), (), ();
+Warnings:
+Warning 1364 Field 'a' doesn't have a default value
+select group_concat(distinct a) from t1;
+group_concat(distinct a)
+0
+select group_concat(distinct a order by a) from t1;
+group_concat(distinct a order by a)
+0
+drop table t1;
+create table t1(a bit(2) not null);
+insert into t1 values (1), (0), (0), (3), (1);
+select group_concat(distinct a) from t1;
+group_concat(distinct a)
+1,0,3
+select group_concat(distinct a order by a) from t1;
+group_concat(distinct a order by a)
+0,1,3
+select group_concat(distinct a order by a desc) from t1;
+group_concat(distinct a order by a desc)
+3,1,0
+drop table t1;
+create table t1(a bit(2), b varchar(10), c bit);
+insert into t1 values (1, 'a', 0), (0, 'b', 1), (0, 'c', 0), (3, 'd', 1),
+(1, 'e', 1), (3, 'f', 1), (0, 'g', 1);
+select group_concat(distinct a, c) from t1;
+group_concat(distinct a, c)
+10,01,00,31,11
+select group_concat(distinct a, c order by a) from t1;
+group_concat(distinct a, c order by a)
+00,01,11,10,31
+select group_concat(distinct a, c) from t1;
+group_concat(distinct a, c)
+10,01,00,31,11
+select group_concat(distinct a, c order by a, c) from t1;
+group_concat(distinct a, c order by a, c)
+00,01,10,11,31
+select group_concat(distinct a, c order by a desc, c desc) from t1;
+group_concat(distinct a, c order by a desc, c desc)
+31,11,10,01,00
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index 6f9b5399b7b..4c5dd6467bd 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -562,4 +562,32 @@ insert into t1 (id, name) values (2, "óra");
select b.id, group_concat(b.name) from t1 a, t1 b group by b.id;
drop table t1;
+#
+# Bug #31154: group_concat() and bit fields;
+#
+create table t1(a bit not null);
+insert into t1 values (), (), ();
+select group_concat(distinct a) from t1;
+select group_concat(distinct a order by a) from t1;
+drop table t1;
+
+create table t1(a bit(2) not null);
+insert into t1 values (1), (0), (0), (3), (1);
+select group_concat(distinct a) from t1;
+select group_concat(distinct a order by a) from t1;
+select group_concat(distinct a order by a desc) from t1;
+drop table t1;
+
+create table t1(a bit(2), b varchar(10), c bit);
+insert into t1 values (1, 'a', 0), (0, 'b', 1), (0, 'c', 0), (3, 'd', 1),
+(1, 'e', 1), (3, 'f', 1), (0, 'g', 1);
+select group_concat(distinct a, c) from t1;
+select group_concat(distinct a, c order by a) from t1;
+select group_concat(distinct a, c) from t1;
+select group_concat(distinct a, c order by a, c) from t1;
+select group_concat(distinct a, c order by a desc, c desc) from t1;
+
+drop table t1;
+
+
--echo End of 5.0 tests
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 2684cce16ac..571e387cf7b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3328,15 +3328,34 @@ bool Item_func_group_concat::setup(THD *thd)
count_field_types(select_lex, tmp_table_param, all_fields, 0);
tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0);
- /*
- Currently we have to force conversion of BLOB values to VARCHAR's
- if we are to store them in TREE objects used for ORDER BY and
- DISTINCT. This leads to truncation if the BLOB's size exceeds
- Field_varstring::MAX_SIZE.
- */
if (arg_count_order > 0 || distinct)
+ {
+ /*
+ Currently we have to force conversion of BLOB values to VARCHAR's
+ if we are to store them in TREE objects used for ORDER BY and
+ DISTINCT. This leads to truncation if the BLOB's size exceeds
+ Field_varstring::MAX_SIZE.
+ */
set_if_smaller(tmp_table_param->convert_blob_length,
Field_varstring::MAX_SIZE);
+
+ /*
+ Force the create_tmp_table() to convert BIT columns to INT
+ as we cannot compare two table records containg BIT fields
+ stored in the the tree used for distinct/order by.
+ Moreover we don't even save in the tree record null bits
+ where BIT fields store parts of their data.
+ */
+ List_iterator_fast<Item> li(all_fields);
+ Item *item;
+ while ((item= li++))
+ {
+ if (item->type() == Item::FIELD_ITEM &&
+ ((Item_field*) item)->field->type() == FIELD_TYPE_BIT)
+ item->marker= 4;
+ }
+ }
+
/*
We have to create a temporary table to get descriptions of fields
(types, sizes and so on).