summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_gconcat.test
diff options
context:
space:
mode:
authorunknown <wax@kishkin.ru>2003-03-18 04:07:40 +0500
committerunknown <wax@kishkin.ru>2003-03-18 04:07:40 +0500
commit0b505fb437eedd1b31c99888247c2259539c095b (patch)
treed5655e0a1fd7bd5c629fbc934a708f44ea818663 /mysql-test/t/func_gconcat.test
parentc312cd45786f22f0fed89d4cb2d6bba7c6c87644 (diff)
downloadmariadb-git-0b505fb437eedd1b31c99888247c2259539c095b.tar.gz
This is full commit of group_concat with support subselects
include/mysqld_error.h: add warning sql/field.h: add friend class sql/item_sum.cc: add function sql/item_sum.h: add class sql/lex.h: add lex sql/mysql_priv.h: change push_warning sql/mysqld.cc: add new option sql/set_var.cc: add new system variable sql/share/english/errmsg.txt: add new message text sql/sql_class.h: change MY_ERROR class sql/sql_error.cc: change push_warning sql/sql_lex.h: add qorder_list for function sql/sql_yacc.yy: add structure of group_concat BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'mysql-test/t/func_gconcat.test')
-rw-r--r--mysql-test/t/func_gconcat.test77
1 files changed, 77 insertions, 0 deletions
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
new file mode 100644
index 00000000000..a122f612bfc
--- /dev/null
+++ b/mysql-test/t/func_gconcat.test
@@ -0,0 +1,77 @@
+#
+# simple test of group_concat function
+#
+
+drop table if exists t1;
+create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
+insert into t1 values (1,1,"a","a");
+insert into t1 values (2,2,"b","a");
+insert into t1 values (2,3,"c","b");
+insert into t1 values (3,4,"E","a");
+insert into t1 values (3,5,"C","b");
+insert into t1 values (3,6,"D","b");
+insert into t1 values (3,7,"d","d");
+insert into t1 values (3,8,"d","d");
+insert into t1 values (3,9,"D","c");
+
+# Test of MySQL simple request
+select grp,group_concat(c) from t1 group by grp;
+select grp,group_concat(a,c) from t1 group by grp;
+select grp,group_concat("(",a,":",c,")") from t1 group by grp;
+
+# Test of MySQL with options
+select grp,group_concat(c separator ",") from t1 group by grp;
+select grp,group_concat(c separator "---->") from t1 group by grp;
+select grp,group_concat(c order by c) from t1 group by grp;
+select grp,group_concat(c order by c desc) from t1 group by grp;
+select grp,group_concat(d order by a) from t1 group by grp;
+select grp,group_concat(d order by a desc) from t1 group by grp;
+select grp,group_concat(a order by a,d+c) from t1 group by grp;
+select grp,group_concat(c order by 1) from t1 group by grp;
+select grp,group_concat(c order by "c") from t1 group by grp;
+select grp,group_concat(distinct c order by c) from t1 group by grp;
+select grp,group_concat(distinct c order by c desc) from t1 group by grp;
+select grp,group_concat(c order by c separator ",") from t1 group by grp;
+select grp,group_concat(c order by c desc separator ",") from t1 group by grp;
+select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
+select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
+
+# Test of SQL_LIST objects
+select grp,group_concat(c order by grp desc) from t1 group by grp order by grp;
+
+
+# Test transfer to real values
+
+select grp, group_concat(a separator "")+0 from t1 group by grp;
+select grp, group_concat(a separator "")+0.0 from t1 group by grp;
+select grp, ROUND(group_concat(a separator "")) from t1 group by grp;
+
+# Test NULL values
+
+drop table if exists t1;
+create table t1 (grp int, c char(10));
+insert into t1 values (1,NULL);
+insert into t1 values (2,"b");
+insert into t1 values (2,NULL);
+insert into t1 values (3,"E");
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (3,NULL);
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+select grp,group_concat(c order by c) from t1 group by grp;
+
+# Test warnings
+
+set group_concat_max_len = 5;
+select grp,group_concat(c) from t1 group by grp;
+show warnings;
+
+# Test errors
+
+--error 1111
+select group_concat(sum(a)) from t1 group by grp;
+--error 1054
+select grp,group_concat(c order by 2) from t1 group by grp;
+
+drop table if exists t1;