summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2003-06-25 17:16:53 +0500
committerunknown <hf@deer.(none)>2003-06-25 17:16:53 +0500
commitd02e22c45cc8afd709c9f2ae3298efde2ac55a74 (patch)
tree2981074647633880c26b0927616e00b382ffd920
parent8f46e0e24c4863e8af0c1d9d87810a413355033e (diff)
parent24a30612f175c0f84f4479bbef5d5d096e2b22b3 (diff)
downloadmariadb-git-d02e22c45cc8afd709c9f2ae3298efde2ac55a74.tar.gz
Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.0
into deer.(none):/home/hf/work/mysql-4.0.674 sql/sql_select.cc: Auto merged
-rw-r--r--mysql-test/r/sel000100.result10
-rw-r--r--mysql-test/t/sel000100.test15
-rw-r--r--sql/sql_select.cc3
3 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/r/sel000100.result b/mysql-test/r/sel000100.result
index f9234815a2b..3ffa4004b84 100644
--- a/mysql-test/r/sel000100.result
+++ b/mysql-test/r/sel000100.result
@@ -26,3 +26,13 @@ ORDER BY link;
key_link_id link
NULL NULL
drop table t1,t2;
+CREATE TABLE t1 (
+html varchar(5) default NULL,
+rin int(11) default '0',
+out int(11) default '0'
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES ('1',1,0);
+SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
+html prod
+1 0.00
+drop table t1;
diff --git a/mysql-test/t/sel000100.test b/mysql-test/t/sel000100.test
index cedb78b17e7..d587fa4ebd0 100644
--- a/mysql-test/t/sel000100.test
+++ b/mysql-test/t/sel000100.test
@@ -29,3 +29,18 @@ GROUP BY t1.id
ORDER BY link;
drop table t1,t2;
+
+#
+# test case for #674
+#
+CREATE TABLE t1 (
+ html varchar(5) default NULL,
+ rin int(11) default '0',
+ out int(11) default '0'
+) TYPE=MyISAM;
+
+INSERT INTO t1 VALUES ('1',1,0);
+
+SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
+
+drop table t1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 67bec77e245..e03b007f8b7 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -453,6 +453,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
goto err;
thd->proc_info="preparing";
+
+ select_distinct= select_distinct && (join.const_tables != join.tables);
+
if (result->initialize_tables(&join))
goto err;
if (join.const_table_map != join.found_const_table_map &&