summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/manual.texi3
-rw-r--r--include/mysql.h8
-rw-r--r--libmysql/libmysql.c2
-rw-r--r--mysql-test/Makefile.am2
-rw-r--r--mysql-test/include/master-slave.inc2
-rw-r--r--mysql-test/install_test_db.sh4
-rw-r--r--mysql-test/mysql-test-run.sh6
-rw-r--r--mysql-test/r/group_by.result4
-rw-r--r--mysql-test/t/group_by.test12
-rwxr-xr-xmysql-test/t/rpl000018-master.sh6
-rw-r--r--sql/sql_select.cc9
11 files changed, 48 insertions, 10 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 523f40ef333..9ae7cf156e7 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -43943,6 +43943,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.38
@itemize @bullet
@item
+Fixed problems with function returning empty string when using
+together with a group functions and a @code{WHERE} that didn't match any rows.
+@item
New program @code{mysqlcheck}.
@item
Added database name to output for admin commands like @code{CHECK},
diff --git a/include/mysql.h b/include/mysql.h
index 350ce860a2f..b5d918a98af 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -20,6 +20,14 @@
#ifndef _mysql_h
#define _mysql_h
+#ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */
+#undef WIN
+#undef _WIN
+#undef _WIN32
+#undef _WIN64
+#undef __WIN__
+#endif
+
#ifndef MYSQL_SERVER
#ifdef __cplusplus
extern "C" {
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 55234fcfe13..9221812ea65 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -16,11 +16,11 @@
MA 02111-1307, USA */
#define DONT_USE_RAID
+#include <global.h>
#if defined(__WIN__) || defined(_WIN32) || defined(_WIN64)
#include <winsock.h>
#include <odbcinst.h>
#endif
-#include <global.h>
#include <my_sys.h>
#include <mysys_err.h>
#include <m_string.h>
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index 1f116a6e313..d98c10a29a9 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -30,7 +30,7 @@ dist-hook:
$(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(distdir)/t
$(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
- $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(distdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.001 $(distdir)/std_data
install-data-local:
$(mkinstalldirs) \
diff --git a/mysql-test/include/master-slave.inc b/mysql-test/include/master-slave.inc
index 69ab73db6b5..61077f898f6 100644
--- a/mysql-test/include/master-slave.inc
+++ b/mysql-test/include/master-slave.inc
@@ -9,5 +9,7 @@ connection master;
reset master;
connection slave;
reset slave;
+# Clean up old test tables
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
@r/slave-running.result show status like 'Slave_running';
diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh
index 6fd32d37cd0..049ac6b1cd7 100644
--- a/mysql-test/install_test_db.sh
+++ b/mysql-test/install_test_db.sh
@@ -25,8 +25,8 @@ then
data=var/slave-data
ldata=$fix_bin/var/slave-data
else
- data=var/lib
- ldata=$fix_bin/var/lib
+ data=var/master-data
+ ldata=$fix_bin/var/master-data
fi
mdata=$data/mysql
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index ccf1aa81270..cb4d750624e 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -188,7 +188,7 @@ done
#--
MYRUN_DIR=$MYSQL_TEST_DIR/var/run
-MASTER_MYDDIR="$MYSQL_TEST_DIR/var/lib"
+MASTER_MYDDIR="$MYSQL_TEST_DIR/var/master-data"
MASTER_MYSOCK="$MYSQL_TMP_DIR/mysql-master.sock"
MASTER_MYPID="$MYRUN_DIR/mysqld.pid"
MASTER_MYLOG="$MYSQL_TEST_DIR/var/log/mysqld.log"
@@ -288,6 +288,8 @@ prompt_user ()
read unused
}
+# We can't use diff -u as this isn't portable
+
show_failed_diff ()
{
reject_file=r/$1.reject
@@ -296,7 +298,7 @@ show_failed_diff ()
then
echo "Below are the diffs between actual and expected results:"
echo "-------------------------------------------------------"
- $DIFF -u $result_file $reject_file
+ $DIFF -c $result_file $reject_file
echo "-------------------------------------------------------"
echo "Please e-mail the above, along with the output of mysqlbug"
echo "and any other relevant info to bugs@lists.mysql.com"
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index ced1a3cd178..2c4a5cecbb1 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -30,3 +30,7 @@ Documentation 0
Host communication 0
kkkkkkkkkkk lllllllllll 3
Test Procedures 0
+1+1 a count(*)
+2 a 0
+1+1 a count(*)
+2 a 0
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index edd3c1fff7e..e75841dc6d0 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -2,6 +2,7 @@
# Test of group (Failed for Lars Hoss <lh@pbm.de>)
#
+drop table if exists t1,t2;
CREATE TABLE t1 (
spID int(10) unsigned,
userID int(10) unsigned,
@@ -208,3 +209,14 @@ select value,description,bug_id from t2 left join t1 on t2.program=t1.product an
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
drop table t1,t2;
+
+#
+# Problem with functions and group functions when no matching rows
+#
+
+create table t1 (foo int);
+insert into t1 values (1);
+select 1+1, "a",count(*) from t1 where foo in (2);
+insert into t1 values (1);
+select 1+1,"a",count(*) from t1 where foo in (2);
+drop table t1;
diff --git a/mysql-test/t/rpl000018-master.sh b/mysql-test/t/rpl000018-master.sh
index 71f0f12d0c5..e570f106ec6 100755
--- a/mysql-test/t/rpl000018-master.sh
+++ b/mysql-test/t/rpl000018-master.sh
@@ -1,3 +1,3 @@
-rm -f $MYSQL_TEST_DIR/var/lib/master-bin.*
-cp $MYSQL_TEST_DIR/std_data/master-bin.001 $MYSQL_TEST_DIR/var/lib/
-echo ./master-bin.001 > $MYSQL_TEST_DIR/var/lib/master-bin.index
+rm -f $MYSQL_TEST_DIR/var/master-data/master-bin.*
+cp $MYSQL_TEST_DIR/std_data/master-bin.001 $MYSQL_TEST_DIR/var/master-data/
+echo ./master-bin.001 > $MYSQL_TEST_DIR/var/master-data/master-bin.index
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 00a41a851b5..63d08b6be5b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4643,7 +4643,11 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
else
{
if (!join->first_record)
+ {
+ /* No matching rows for group function */
clear_tables(join);
+ copy_fields(&join->tmp_table_param);
+ }
if (join->having && join->having->val_int() == 0)
error= -1; // Didn't satisfy having
else
@@ -4875,7 +4879,11 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if (idx < (int) join->send_group_parts)
{
if (!join->first_record)
+ {
+ /* No matching rows for group function */
clear_tables(join);
+ copy_fields(&join->tmp_table_param);
+ }
copy_sum_funcs(join->sum_funcs);
if (!join->having || join->having->val_int())
{
@@ -4899,7 +4907,6 @@ end_write_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
}
if (idx < (int) join->send_group_parts)
{
- copy_fields(&join->tmp_table_param);
copy_funcs(join->tmp_table_param.funcs);
init_sum_functions(join->sum_funcs);
if (join->procedure)