From aff8dbe130b08c167c0284c53713318c26da9558 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Fri, 14 Oct 2005 01:22:24 +0400 Subject: [PATCH 1/2] Fix bug #13855 select distinct with group by caused server crash DISTINCT wasn't optimized away and caused creation of tmp table in wrong case. This result in integer overrun and running out of memory. Fix backported from 4.1. Now if optimizer founds that in result be only 1 row it removes distinct. --- mysql-test/r/select.result | 8 ++++++++ mysql-test/t/select.test | 9 +++++++++ sql/sql_select.cc | 1 + 3 files changed, 18 insertions(+) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 11a50d6cabc..98d474821c9 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2477,3 +2477,11 @@ a b c d 1 2 2 1 1 2 3 1 DROP TABLE IF EXISTS t1, t2; +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +count(f2) >0 +1 +drop table t1,t2; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 2607a00bed4..984b467d435 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2013,3 +2013,12 @@ SELECT t2.a, t2.b, IF(t1.b IS NULL,'',c) AS c, COUNT(*) AS d FROM t2,t1 WHERE t2.a = t1.a AND t2.b = t1.b GROUP BY a, b, c; DROP TABLE IF EXISTS t1, t2; +# +# Bug #13855 select distinct with group by caused server crash +# +create table t1 (f1 int primary key, f2 int); +create table t2 (f3 int, f4 int, primary key(f3,f4)); +insert into t1 values (1,1); +insert into t2 values (1,1),(1,2); +select distinct count(f2) >0 from t1 left join t2 on f1=f3 group by f1; +drop table t1,t2; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7c2c233d754..46f0139a608 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -626,6 +626,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, { order=0; // The output has only one row simple_order=1; + select_distinct= 0; // No need in distinct for 1 row } calc_group_buffer(&join,group); From 3e599c09070bed12e4279b8d35fc323676127723 Mon Sep 17 00:00:00 2001 From: "jani@ua141d10.elisa.omakaista.fi" <> Date: Tue, 25 Oct 2005 16:56:25 +0300 Subject: [PATCH 2/2] Imported fixes from 4.1 and 5.0 to 4.0. --- include/config-netware.h | 4 ++++ netware/mysql_test_run.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/config-netware.h b/include/config-netware.h index 578975a1cea..310c9bb7db8 100644 --- a/include/config-netware.h +++ b/include/config-netware.h @@ -45,6 +45,7 @@ extern "C" { #undef HAVE_SCHED_H #undef HAVE_SYS_MMAN_H #undef HAVE_SYNCH_H +#undef HAVE_RINT #define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #define HAVE_PTHREAD_SIGMASK 1 #define HAVE_PTHREAD_YIELD_ZERO_ARG 1 @@ -91,6 +92,9 @@ extern "C" { /* On NetWare, stack grows towards lower address*/ #define STACK_DIRECTION -1 +/* On NetWare, to fix the problem with the deletion of open files */ +#define CANT_DELETE_OPEN_FILES 1 + /* default directory information */ #define DEFAULT_MYSQL_HOME "sys:/mysql" #define PACKAGE "mysql" diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index 28fbe34993d..e8d4c09bc16 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -173,7 +173,7 @@ void report_stats() mtr_log("\nFailed %u/%u test(s), %.02f%% successful.\n", total_fail, total_test, percent); mtr_log("\nThe .out and .err files in %s may give you some\n", result_dir); - mtr_log("hint of what when wrong.\n"); + mtr_log("hint of what went wrong.\n"); mtr_log("\nIf you want to report this error, please first read the documentation\n"); mtr_log("at: http://www.mysql.com/doc/M/y/MySQL_test_suite.html\n"); }