summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-05-13 19:26:07 +0300
committerunknown <monty@narttu.mysql.fi>2003-05-13 19:26:07 +0300
commitd05cd28c10bdc94783074ebaba40a3ed1fabe6a6 (patch)
tree475f7895f8b8ca9b87712c500177e254a1b0e08e
parentdc1e55f8194db83e7a40dea5bf49e9fef970826c (diff)
downloadmariadb-git-d05cd28c10bdc94783074ebaba40a3ed1fabe6a6.tar.gz
Fixed problem with ansi mode and GROUP BY with constants. (Bug #387)
sql/sql_select.cc: Fixed problem with ansi mode and GROUP BY with constants
-rw-r--r--mysql-test/r/ansi.result10
-rw-r--r--mysql-test/t/ansi-master.opt1
-rw-r--r--mysql-test/t/ansi.test17
-rw-r--r--sql/sql_select.cc3
4 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/r/ansi.result b/mysql-test/r/ansi.result
new file mode 100644
index 00000000000..f9f96310b73
--- /dev/null
+++ b/mysql-test/r/ansi.result
@@ -0,0 +1,10 @@
+drop table if exists t1;
+SELECT 'A' || 'B';
+'A' || 'B'
+AB
+CREATE TABLE t1 (id INT, id2 int);
+SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
+id NULL 1 1.1 a
+SELECT id FROM t1 GROUP BY id2;
+'t1.id' isn't in GROUP BY
+drop table t1;
diff --git a/mysql-test/t/ansi-master.opt b/mysql-test/t/ansi-master.opt
new file mode 100644
index 00000000000..6bf7a4f30e2
--- /dev/null
+++ b/mysql-test/t/ansi-master.opt
@@ -0,0 +1 @@
+--ansi
diff --git a/mysql-test/t/ansi.test b/mysql-test/t/ansi.test
new file mode 100644
index 00000000000..e1ac8ffd4f9
--- /dev/null
+++ b/mysql-test/t/ansi.test
@@ -0,0 +1,17 @@
+#
+# Test of ansi mode
+#
+
+drop table if exists t1;
+
+# Test some functions that works different in ansi mode
+
+SELECT 'A' || 'B';
+
+# Test GROUP BY behaviour
+
+CREATE TABLE t1 (id INT, id2 int);
+SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
+--error 1055
+SELECT id FROM t1 GROUP BY id2;
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index daf388c9ff3..ff6fde1ca0c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6668,7 +6668,8 @@ setup_group(THD *thd,TABLE_LIST *tables,List<Item> &fields,
while ((item=li++))
{
- if (item->type() != Item::SUM_FUNC_ITEM && !item->marker)
+ if (item->type() != Item::SUM_FUNC_ITEM && !item->marker &&
+ !item->const_item())
{
my_printf_error(ER_WRONG_FIELD_WITH_GROUP,
ER(ER_WRONG_FIELD_WITH_GROUP),