List:Commits« Previous MessageNext Message »
From:Hakan Kuecuekyilmaz Date:November 5 2008 3:59pm
Subject:bzr push into mysql-6.0-falcon-team branch (hky:2902 to 2903)
View as plain text  
 2903 Hakan Kuecuekyilmaz	2008-11-05 [merge]
      Merged:
          mysql-6.0 --> mysql-6.0-falcon --> mysql-6.0-falcon-team.
removed:
  mysql-test/suite/falcon/r/falcon_bug_28095_II.result
  mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt
  mysql-test/suite/falcon/t/falcon_bug_28095_II.test
added:
  mysql-test/include/restart_mysqld.inc
  mysql-test/include/wait_until_disconnected.inc
renamed:
  mysql-test/suite/falcon/r/falcon_bug_28095_I.result => mysql-test/suite/falcon/r/falcon_bug_28095.result
  mysql-test/suite/falcon/t/falcon_bug_28095_I.test => mysql-test/suite/falcon/t/falcon_bug_28095.test
modified:
  .bzrignore
  BUILD/compile-dist
  client/mysqltest.c
  configure.in
  mysql-test/include/wait_until_connected_again.inc
  mysql-test/r/group_by.result
  mysql-test/r/innodb_mrr.result
  mysql-test/r/myisam_mrr.result
  mysql-test/r/ps_ddl.result
  mysql-test/r/subselect3.result
  mysql-test/r/sum_distinct.result
  mysql-test/suite/falcon/t/disabled.def
  mysql-test/t/group_by.test
  mysql-test/t/innodb_mrr.test
  mysql-test/t/myisam_mrr.test
  mysql-test/t/ps_ddl.test
  mysql-test/t/subselect3.test
  mysql-test/t/sum_distinct.test
  sql/hostname.cc
  sql/item_sum.cc
  sql/item_sum.h
  sql/mysql_priv.h
  sql/mysqld.cc
  sql/net_serv.cc
  sql/sql_select.cc
  sql/sql_select.h
  storage/falcon/StorageVersion.h
  storage/myisam/ha_myisam.cc
  zlib/gzio.c
  mysql-test/suite/falcon/r/falcon_bug_28095.result
  mysql-test/suite/falcon/t/falcon_bug_28095.test

 2902 lars-erik.bjork@stripped	2008-11-05
      Removing IGNORE keywords from INSERT statements in the testcase, after request from Hakan
modified:
  mysql-test/suite/falcon/r/falcon_bug_40130.result
  mysql-test/suite/falcon/t/falcon_bug_40130.test

=== modified file '.bzrignore'
--- a/.bzrignore	2008-10-23 21:08:32 +0000
+++ b/.bzrignore	2008-10-29 14:20:12 +0000
@@ -600,6 +600,7 @@ libmysqld/protocol_cursor.cc
 libmysqld/records.cc
 libmysqld/repl_failsafe.cc
 libmysqld/rpl_filter.cc
+libmysqld/rpl_handler.cc
 libmysqld/rpl_injector.cc
 libmysqld/rpl_record.cc
 libmysqld/rpl_record_old.cc
@@ -875,6 +876,7 @@ mysql-test/suite/partitions/r/partition_
 mysql-test/suite/partitions/r/partition_t55.out
 mysql-test/suite/partitions/r/partition_t55.refout
 mysql-test/suite/partitions/t/partition.test
+mysql-test/suite/rpl/t/rpl_view-slave.opt
 mysql-test/t.log
 mysql-test/t/index_merge.load
 mysql-test/t/tmp.test

=== modified file 'BUILD/compile-dist'
--- a/BUILD/compile-dist	2008-05-29 15:44:11 +0000
+++ b/BUILD/compile-dist	2008-10-30 21:49:14 +0000
@@ -13,31 +13,47 @@ path=`dirname $0`
 
 # Default to gcc for CC and CXX
 if test -z "$CXX" ; then
-  export CXX=gcc
+  CXX=gcc
   # Set some required compile options
   if test -z "$CXXFLAGS" ; then
-    export CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti"
+    CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti"
   fi
 fi
 
 if test -z "$CC" ; then
-  export CC=gcc
+  CC=gcc
 fi
 
 
 # Use ccache, if available
 if ccache -V > /dev/null 2>&1
 then
-  if ! (echo "$CC" | grep "ccache" > /dev/null)
+  if echo "$CC" | grep "ccache" > /dev/null
   then
-    export CC="ccache $CC"
+    :
+  else
+    CC="ccache $CC"
   fi
-  if ! (echo "$CXX" | grep "ccache" > /dev/null)
+  if echo "$CXX" | grep "ccache" > /dev/null
   then
-    export CXX="ccache $CXX"
+    :
+  else
+    CXX="ccache $CXX"
   fi
 fi
 
+if test -z "$MAKE"
+then
+  if gmake -v > /dev/null 2>&1
+  then
+    MAKE="gmake"
+  else
+    MAKE="make"
+  fi
+fi
+
+export CC CXX MAKE
+
 # Make sure to enable all features that affect "make dist"
 # Remember that configure restricts the man pages to the configured features !
 ./configure \
@@ -45,4 +61,5 @@ fi
   --with-embedded-server \
   --with-falcon \
   --with-ndbcluster
-make
+$MAKE
+

=== modified file 'client/mysqltest.c'
--- a/client/mysqltest.c	2008-10-20 09:16:47 +0000
+++ b/client/mysqltest.c	2008-11-03 17:51:36 +0000
@@ -279,6 +279,7 @@ enum enum_commands {
   Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES,
   Q_SEND_QUIT, Q_CHANGE_USER, Q_MKDIR, Q_RMDIR, Q_LIST_FILES,
   Q_LIST_FILES_WRITE_FILE, Q_LIST_FILES_APPEND_FILE,
+  Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
 
   Q_UNKNOWN,			       /* Unknown command.   */
   Q_COMMENT,			       /* Comments, ignored. */
@@ -370,6 +371,8 @@ const char *command_names[]=
   "list_files",
   "list_files_write_file",
   "list_files_append_file",
+  "send_shutdown",
+  "shutdown_server",
 
   0
 };
@@ -3855,6 +3858,145 @@ void do_set_charset(struct st_command *c
 }
 
 
+/*
+  Run query and return one field in the result set from the
+  first row and <column>
+*/
+
+int query_get_string(MYSQL* mysql, const char* query,
+                     int column, DYNAMIC_STRING* ds)
+{
+  MYSQL_RES *res= NULL;
+  MYSQL_ROW row;
+
+  if (mysql_query(mysql, query))
+    die("'%s' failed: %d %s", query,
+        mysql_errno(mysql), mysql_error(mysql));
+  if ((res= mysql_store_result(mysql)) == NULL)
+    die("Failed to store result: %d %s",
+        mysql_errno(mysql), mysql_error(mysql));
+
+  if ((row= mysql_fetch_row(res)) == NULL)
+  {
+    mysql_free_result(res);
+    ds= 0;
+    return 1;
+  }
+  init_dynamic_string(ds, (row[column] ? row[column] : "NULL"), ~0, 32);
+  mysql_free_result(res);
+  return 0;
+}
+
+
+static int my_kill(int pid, int sig)
+{
+#ifdef __WIN__
+  HANDLE proc;
+  if ((proc= OpenProcess(PROCESS_TERMINATE, FALSE, pid)) == NULL)
+    return -1;
+  if (sig == 0)
+  {
+    CloseHandle(proc);
+    return 0;
+  }
+  (void)TerminateProcess(proc, 201);
+  CloseHandle(proc);
+  return 1;
+#else
+  return kill(pid, sig);
+#endif
+}
+
+
+
+/*
+  Shutdown the server of current connection and
+  make sure it goes away within <timeout> seconds
+
+  NOTE! Currently only works with local server
+
+  SYNOPSIS
+  do_shutdown_server()
+  command  called command
+
+  DESCRIPTION
+  shutdown [<timeout>]
+
+*/
+
+void do_shutdown_server(struct st_command *command)
+{
+  int timeout=60, pid;
+  DYNAMIC_STRING ds_pidfile_name;
+  MYSQL* mysql = &cur_con->mysql;
+  static DYNAMIC_STRING ds_timeout;
+  const struct command_arg shutdown_args[] = {
+    {"timeout", ARG_STRING, FALSE, &ds_timeout, "Timeout before killing server"}
+  };
+  DBUG_ENTER("do_shutdown_server");
+
+  check_command_args(command, command->first_argument, shutdown_args,
+                     sizeof(shutdown_args)/sizeof(struct command_arg),
+                     ' ');
+
+  if (ds_timeout.length)
+  {
+    timeout= atoi(ds_timeout.str);
+    if (timeout == 0)
+      die("Illegal argument for timeout: '%s'", ds_timeout.str);
+  }
+  dynstr_free(&ds_timeout);
+
+  /* Get the servers pid_file name and use it to read pid */
+  if (query_get_string(mysql, "SHOW VARIABLES LIKE 'pid_file'", 1,
+                       &ds_pidfile_name))
+    die("Failed to get pid_file from server");
+
+  /* Read the pid from the file */
+  {
+    int fd;
+    char buff[32];
+
+    if ((fd= my_open(ds_pidfile_name.str, O_RDONLY, MYF(0))) < 0)
+      die("Failed to open file '%s'", ds_pidfile_name.str);
+    dynstr_free(&ds_pidfile_name);
+
+    if (my_read(fd, (uchar*)&buff,
+                sizeof(buff), MYF(0)) <= 0){
+      my_close(fd, MYF(0));
+      die("pid file was empty");
+    }
+    my_close(fd, MYF(0));
+
+    pid= atoi(buff);
+    if (pid == 0)
+      die("Pidfile didn't contain a valid number");
+  }
+  DBUG_PRINT("info", ("Got pid %d", pid));
+
+  /* Tell server to shutdown if timeout > 0*/
+  if (timeout && mysql_shutdown(mysql, SHUTDOWN_DEFAULT))
+    die("mysql_shutdown failed");
+
+  /* Check that server dies */
+  while(timeout--){
+    if (my_kill(0, pid) < 0){
+      DBUG_PRINT("info", ("Process %d does not exist anymore", pid));
+      break;
+    }
+    DBUG_PRINT("info", ("Sleeping, timeout: %d", timeout));
+    my_sleep(1000000L);
+  }
+
+  /* Kill the server */
+  DBUG_PRINT("info", ("Killing server, pid: %d", pid));
+  (void)my_kill(9, pid);
+
+  DBUG_VOID_RETURN;
+
+}
+
+
 #if MYSQL_VERSION_ID >= 50000
 /* List of error names to error codes, available from 5.0 */
 typedef struct
@@ -7440,6 +7582,14 @@ int main(int argc, char **argv)
       case Q_PING:
 	(void) mysql_ping(&cur_con->mysql);
 	break;
+      case Q_SEND_SHUTDOWN:
+        handle_command_error(command,
+                             mysql_shutdown(&cur_con->mysql,
+                                            SHUTDOWN_DEFAULT));
+        break;
+      case Q_SHUTDOWN_SERVER:
+        do_shutdown_server(command);
+        break;
       case Q_EXEC:
 	do_exec(command);
 	command_executed++;

=== modified file 'configure.in'
--- a/configure.in	2008-11-03 08:56:28 +0000
+++ b/configure.in	2008-11-05 15:41:45 +0000
@@ -11,7 +11,7 @@ AC_CANONICAL_SYSTEM
 # When changing major version number please also check switch statement
 # in mysqlbinlog::check_master_version().
 
-AM_INIT_AUTOMAKE(mysql, 6.0.8-alpha)
+AM_INIT_AUTOMAKE(mysql, 6.0.9-alpha)
 AM_CONFIG_HEADER([include/config.h:config.h.in])
 
 NDB_VERSION_MAJOR=6
@@ -431,12 +431,15 @@ dnl Find paths to some shell programs
 AC_PATH_PROG(LN, ln, ln)
 # This must be able to take a -f flag like normal unix ln.
 AC_PATH_PROG(LN_CP_F, ln, ln)
-if ! ( expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null ); then
-# If ln -f does not exists use -s (AFS systems)
-if test -n "$LN_CP_F"; then
-  LN_CP_F="$LN_CP_F -s"
-fi
-fi
+case $SYSTEM_TYPE in
+  *netware*) ;;
+  *)
+    # If ln -f does not exists use -s (AFS systems)
+    if test -n "$LN_CP_F"; then
+      LN_CP_F="$LN_CP_F -s"
+    fi
+    ;;
+esac
 
 AC_PATH_PROG(MV, mv, mv)
 AC_PATH_PROG(RM, rm, rm)
@@ -1661,14 +1664,16 @@ else
   OPTIMIZE_CXXFLAGS="-O"
 fi
 
-if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null; then
-  DEBUG_CFLAGS="-g -DDEBUG -sym internal,codeview4"
-  DEBUG_CXXFLAGS="-g -DDEBUG -sym internal,codeview4"
-  DEBUG_OPTIMIZE_CC="-DDEBUG"
-  DEBUG_OPTIMIZE_CXX="-DDEBUG"
-  OPTIMIZE_CFLAGS="-O3 -DNDEBUG"
-  OPTIMIZE_CXXFLAGS="-O3 -DNDEBUG"
-fi
+case $SYSTEM_TYPE in
+  *netware*)
+    DEBUG_CFLAGS="-g -DDEBUG -sym internal,codeview4"
+    DEBUG_CXXFLAGS="-g -DDEBUG -sym internal,codeview4"
+    DEBUG_OPTIMIZE_CC="-DDEBUG"
+    DEBUG_OPTIMIZE_CXX="-DDEBUG"
+    OPTIMIZE_CFLAGS="-O3 -DNDEBUG"
+    OPTIMIZE_CXXFLAGS="-O3 -DNDEBUG"
+    ;;
+esac
 
 # If the user specified CFLAGS, we won't add any optimizations
 if test -n "$SAVE_CFLAGS"
@@ -1953,15 +1958,18 @@ MYSQL_TZNAME
 # Do the c++ compiler have a bool type
 MYSQL_CXX_BOOL
 # Check some common bugs with gcc 2.8.# on sparc
-if ! ( expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null ); then
-MYSQL_CHECK_LONGLONG_TO_FLOAT
-if test "$ac_cv_conv_longlong_to_float" != "yes"
-then
-  AC_MSG_ERROR([Your compiler cannot convert a longlong value to a float!
-If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
-again])
-fi
-fi
+case $SYSTEM_TYPE in
+  *netware*) ;;
+  *)
+    MYSQL_CHECK_LONGLONG_TO_FLOAT
+    if test "$ac_cv_conv_longlong_to_float" != "yes"
+    then
+      AC_MSG_ERROR([Your compiler cannot convert a longlong value to a float!
+ If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
+    again])
+    fi
+    ;;
+esac
 AC_CHECK_TYPES([sigset_t, off_t], [], [], [#include <sys/types.h>])
 AC_CHECK_TYPES([size_t], [], [], [#include <stdio.h>])
 AC_CHECK_TYPES([u_int32_t])
@@ -2586,11 +2594,12 @@ readline_h_ln_cmd=""
 readline_link=""
 want_to_use_readline="no"
 
-if expr "$SYSTEM_TYPE" : ".*netware.*" > /dev/null
-then
+case $SYSTEM_TYPE in
+  *netware*)
     # For NetWare, do not need readline
     echo "Skipping readline"
-else
+    ;;
+  *)
     if [test "$with_libedit" = "yes"] || [test "$with_libedit" = "undefined"] && [test "$with_readline" = "undefined"]
     then
 	readline_topdir="cmd-line-utils"
@@ -2643,7 +2652,8 @@ else
 	      be built with libreadline. Please use --with-libedit to use
 	      the bundled version of libedit instead.])
     fi
-fi
+    ;;
+esac
 
 AC_SUBST(readline_dir)
 AC_SUBST(readline_topdir)

=== added file 'mysql-test/include/restart_mysqld.inc'
--- a/mysql-test/include/restart_mysqld.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/restart_mysqld.inc	2008-11-03 17:51:36 +0000
@@ -0,0 +1,28 @@
+
+# Write file to make mysql-test-run.pl expect the "crash", but don't start
+# it until it's told to
+--write_file $MYSQLTEST_VARDIR/tmp/master0.expect
+wait
+EOF
+
+# Send shutdown to the connected server and give
+# it 10 seconds to die before zapping it
+shutdown_server 10;
+
+# Check server is gone
+--source include/wait_until_disconnected.inc
+
+# Write file to make mysql-test-run.pl start up the server again
+--append_file $MYSQLTEST_VARDIR/tmp/master0.expect
+restart
+EOF
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+

=== modified file 'mysql-test/include/wait_until_connected_again.inc'
--- a/mysql-test/include/wait_until_connected_again.inc	2008-02-06 17:04:06 +0000
+++ b/mysql-test/include/wait_until_connected_again.inc	2008-11-03 17:51:36 +0000
@@ -4,11 +4,14 @@
 # You should have done --enable_reconnect first
 --disable_result_log
 --disable_query_log
-let $counter= 5000;
-let $mysql_errno= 1;
+let $counter= 300;
+let $mysql_errno= 9999;
 while ($mysql_errno)
 {
-  --error 0,2002,2003,2006,1053
+  # Strangely enough, the server might return "Too many connections"
+  # while being shutdown, thus 1040 is an "allowed" error
+  # See BUG#36228
+  --error 0,1040,1053,2002,2003,2006,2013
   show status;
 
   dec $counter;

=== added file 'mysql-test/include/wait_until_disconnected.inc'
--- a/mysql-test/include/wait_until_disconnected.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/wait_until_disconnected.inc	2008-11-03 17:51:36 +0000
@@ -0,0 +1,21 @@
+#
+# Include this script to wait until the connection to the
+# server has been dropped
+--disable_result_log
+--disable_query_log
+let $counter= 500;
+let $mysql_errno= 9999;
+while (!$mysql_errno)
+{
+  --error 0,1053,2002,2006
+  show status;
+
+  dec $counter;
+  if (!$counter)
+  {
+    --die Server failed to dissapear
+  }
+  --sleep 0.1
+}
+--enable_query_log
+--enable_result_log

=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result	2008-04-01 15:13:57 +0000
+++ b/mysql-test/r/group_by.result	2008-09-09 19:36:23 +0000
@@ -1624,7 +1624,7 @@ b
 NULL
 1
 2
-DROP TABLE t1;
+DROP TABLE t1, t2;
 CREATE TABLE t1 ( a INT, b INT );
 SELECT b c, (SELECT a FROM t1 WHERE b = c)
 FROM t1;
@@ -1661,3 +1661,33 @@ FROM t1;
 ERROR 21000: Subquery returns more than 1 row
 DROP TABLE t1;
 SET @@sql_mode = @old_sql_mode;
+
+BUG#38072: Wrong result: HAVING not observed in a query with aggregate
+
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_nokey int(11) NOT NULL,
+int_key int(11) NOT NULL,
+varchar_key varchar(1) NOT NULL,
+varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key),
+KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES 
+(1,5,5, 'h','h'),
+(2,1,1, '{','{'),
+(3,1,1, 'z','z'),
+(4,8,8, 'x','x'),
+(5,7,7, 'o','o'),
+(6,3,3, 'p','p'),
+(7,9,9, 'c','c'),
+(8,0,0, 'k','k'),
+(9,6,6, 't','t'),
+(10,0,0,'c','c');
+explain SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible HAVING
+SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+X
+drop table t1;

=== modified file 'mysql-test/r/innodb_mrr.result'
--- a/mysql-test/r/innodb_mrr.result	2008-01-24 00:46:18 +0000
+++ b/mysql-test/r/innodb_mrr.result	2008-09-05 14:36:37 +0000
@@ -314,3 +314,40 @@ f1	f2	f3	f4
 9	9	9	A
 10	10	10	A
 drop table t1;
+
+BUG#37977: Wrong result returned on GROUP BY + OR + Innodb
+
+CREATE TABLE t1 (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`int_key` int(11) NOT NULL,
+`date_key` date NOT NULL,
+`date_nokey` date NOT NULL,
+`time_key` time NOT NULL,
+`time_nokey` time NOT NULL,
+`datetime_key` datetime NOT NULL,
+`datetime_nokey` datetime NOT NULL,
+`varchar_key` varchar(5) DEFAULT NULL,
+`varchar_nokey` varchar(5) DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `int_key` (`int_key`),
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `datetime_key` (`datetime_key`),
+KEY `varchar_key` (`varchar_key`)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES 
+(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'),
+(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'),
+(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'),
+(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL),
+(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu');
+select pk from t1 WHERE `varchar_key` > 'kr' group by pk;
+pk
+1
+5
+select pk from t1 WHERE `int_nokey` IS NULL OR  `varchar_key` > 'kr' group by pk;
+pk
+1
+5
+drop table t1;

=== modified file 'mysql-test/r/myisam_mrr.result'
--- a/mysql-test/r/myisam_mrr.result	2008-01-10 22:04:59 +0000
+++ b/mysql-test/r/myisam_mrr.result	2008-09-05 19:23:07 +0000
@@ -303,3 +303,32 @@ ID	col1	key1	key2	text1	text2	col2	col3	
 3	NULL	1130	NULL	red	NULL	100	bodyandsubject	0
 4	NULL	1130	NULL	yellow	NULL	100	bodyandsubject	0
 drop table t1;
+
+BUG#37851: Crash in test_if_skip_sort_order tab->select is zero
+
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_key int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key)
+);
+INSERT INTO t2 VALUES (1,1),(2,6),(3,0);
+EXPLAIN EXTENDED
+SELECT MIN(t1.pk)
+FROM t1 WHERE EXISTS (
+SELECT t2.pk
+FROM t2
+WHERE t2.int_key IS NULL
+GROUP BY t2.pk
+);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
+2	SUBQUERY	t2	ALL	int_key	int_key	5		3	33.33	Using index condition; Using filesort
+Warnings:
+Note	1003	select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where 0
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/ps_ddl.result'
--- a/mysql-test/r/ps_ddl.result	2008-08-13 20:05:34 +0000
+++ b/mysql-test/r/ps_ddl.result	2008-09-13 14:16:20 +0000
@@ -1655,6 +1655,18 @@ SQL statement where it is needed.
 #
 # SQLCOM_SELECT
 #
+drop table if exists t1;
+create table t1 (a int);
+prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
+drop table t1;
+create table t1 (x int);
+execute stmt;
+res
+drop table t1;
+deallocate prepare stmt;
+call p_verify_reprepare_count(1);
+SUCCESS
+
 #
 # SQLCOM_CREATE_TABLE
 #

=== modified file 'mysql-test/r/subselect3.result'
--- a/mysql-test/r/subselect3.result	2008-08-20 01:52:25 +0000
+++ b/mysql-test/r/subselect3.result	2008-09-13 14:16:20 +0000
@@ -1,4 +1,4 @@
-drop table if exists t0, t1, t2, t3, t4, t5;
+drop table if exists t0, t1, t2, t3, t4;
 create table t1 (oref int, grp int, ie int) ;
 insert into t1 (oref, grp, ie) values
 (1, 1, 1),
@@ -789,29 +789,10 @@ a	b
 1	0.123
 drop table t1;
 End of 5.0 tests
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t1 (
-a int(11) default null,
-b int(11) default null,
-key (a)
-);
-insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C;
-create table t2 (a int(11) default null);
-insert into t2 values (0),(1);
-create table t3 (a int(11) default null);
-insert into t3 values (0),(1);
-create table t4 (a int(11) default null);
-insert into t4 values (0),(1);
-create table t5 (a int(11) default null);
-insert into t5 values (0),(1),(0),(1);
-select * from t2, t3 
-where
-t2.a < 10 and
-t3.a+1 = 2 and
-t3.a in (select t1.b from t1
-where t1.a+1=t1.a+1 and
-t1.a < (select t4.a+10                                  
-from t4, t5 limit 2));
-ERROR 21000: Subquery returns more than 1 row
-drop table t0, t1, t2, t3, t4, t5;
+#  
+# BUG#36896: Server crash on SELECT FROM DUAL
+# 
+create table t1 (a int);
+select 1 as res from dual where (1) in (select * from t1);
+res
+drop table t1;

=== modified file 'mysql-test/r/sum_distinct.result'
--- a/mysql-test/r/sum_distinct.result	2005-04-07 16:24:14 +0000
+++ b/mysql-test/r/sum_distinct.result	2008-09-05 19:01:46 +0000
@@ -95,3 +95,26 @@ SELECT SUM(DISTINCT id % 11) FROM t1;
 SUM(DISTINCT id % 11)
 55
 DROP TABLE t1;
+
+BUG#37891: Column cannot be null error with aggregate in a subquery
+
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_key int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key)
+);
+INSERT INTO t1 VALUES (1,10);
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+time_nokey time DEFAULT NULL,
+datetime_key time DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY datetime_key (datetime_key)
+);
+INSERT INTO t2 VALUES (1,'18:19:29',NOW());
+SELECT * FROM t1 WHERE int_key IN ( SELECT SUM(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+pk	int_key
+SELECT * FROM t1 WHERE int_key IN ( SELECT AVG(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+pk	int_key
+drop table t1,t2;

=== renamed file 'mysql-test/suite/falcon/r/falcon_bug_28095_I.result' => 'mysql-test/suite/falcon/r/falcon_bug_28095.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_28095_I.result	2007-09-20 15:44:25 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_28095.result	2008-11-04 15:22:06 +0000
@@ -1,15 +1,35 @@
-SET STORAGE_ENGINE = Falcon;
-*** Bug #126: First phase ***
-*** Also covering bug #113 ***
+*** Bug #28095: First phase ***
+SET @@storage_engine = 'Falcon';
 DROP TABLE IF EXISTS t1;
 DROP TABLE IF EXISTS t2;
 CREATE TABLE t1 (a int);
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-SELECT * FROM t1;
+SELECT * FROM t1 ORDER BY a;
 a
 1
 2
 3
 CREATE TABLE t2 (b int);
+SELECT @@GLOBAL.falcon_debug_mask;
+@@GLOBAL.falcon_debug_mask
+0
+SET GLOBAL falcon_debug_mask = 4096;
+SELECT @@GLOBAL.falcon_debug_mask;
+@@GLOBAL.falcon_debug_mask
+4096
+*** Bug #28095: Second phase ***
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+SELECT count(*) FROM t1;
+count(*)
+3
+SELECT @@GLOBAL.falcon_debug_mask;
+@@GLOBAL.falcon_debug_mask
+0
+DROP TABLE t1;
+DROP TABLE t2;

=== removed file 'mysql-test/suite/falcon/r/falcon_bug_28095_II.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_28095_II.result	2008-03-28 17:13:51 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_28095_II.result	1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
-*** Bug #126: Second phase ***
-*** Also test for bug #123 ***
-SET @@storage_engine = Falcon;
-SELECT * FROM t1;
-a
-1
-2
-3
-DROP TABLE t1, t2;

=== modified file 'mysql-test/suite/falcon/t/disabled.def'
--- a/mysql-test/suite/falcon/t/disabled.def	2008-09-11 16:28:29 +0000
+++ b/mysql-test/suite/falcon/t/disabled.def	2008-11-04 15:22:06 +0000
@@ -10,6 +10,4 @@
 #
 ##############################################################################
 
-falcon_bug_28095_I  : Bug#xxxxx 2008-04-22 hakank Disabled until soft restart is in main tree
-falcon_bug_28095_II : Bug#xxxxx 2008-03-22 hakank Disabled until soft restart is in main tree
 falcon_bug_32398 : HF disabled until new fix for this bug is developed

=== renamed file 'mysql-test/suite/falcon/t/falcon_bug_28095_I.test' => 'mysql-test/suite/falcon/t/falcon_bug_28095.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_28095_I.test	2007-09-29 04:30:42 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_28095.test	2008-11-04 16:50:26 +0000
@@ -1,20 +1,62 @@
 --source include/have_falcon.inc
-SET STORAGE_ENGINE = Falcon;
+
+#
+# Bug #28095: Falcon Drop table causes crash
 #
-# Mantis bug #126 first phase: Drop table causes crash
-# Mantis bug #113: JStar is crashing on shutdown
+# Note: This test consists of two phases involving a "soft"
+#    server restart with --shutdown_server. We do the
+#    restart with the help of include/restart_mysqld.inc.
 #
---echo *** Bug #126: First phase ***
---echo *** Also covering bug #113 ***
+--echo *** Bug #28095: First phase ***
+
+# ----------------------------------------------------- #
+# --- Initialisation                                --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
 --disable_warnings
 DROP TABLE IF EXISTS t1;
 DROP TABLE IF EXISTS t2;
 --enable_warnings
 
 CREATE TABLE t1 (a int);
+
+# ----------------------------------------------------- #
+# --- Test                                          --- #
+# ----------------------------------------------------- #
 INSERT INTO t1 VALUES (1);
 INSERT INTO t1 VALUES (2);
 INSERT INTO t1 VALUES (3);
-SELECT * FROM t1;
+SELECT * FROM t1 ORDER BY a;
 
 CREATE TABLE t2 (b int);
+
+#
+# We set a global variable to make sure that the
+# following restart really works. Global variables
+# should be resetted after a server restart.
+#
+SELECT @@GLOBAL.falcon_debug_mask;
+SET GLOBAL falcon_debug_mask = 4096;
+SELECT @@GLOBAL.falcon_debug_mask;
+
+# ----------------------------------------------------- #
+# --- Restart server                                --- #
+# ----------------------------------------------------- #
+--source include/restart_mysqld.inc
+
+--echo *** Bug #28095: Second phase ***
+SELECT * FROM t1 ORDER BY a;
+
+# ----------------------------------------------------- #
+# --- Check                                         --- #
+# ----------------------------------------------------- #
+SELECT count(*) FROM t1;
+SELECT @@GLOBAL.falcon_debug_mask;
+
+# ----------------------------------------------------- #
+# --- Final cleanup                                 --- #
+# ----------------------------------------------------- #
+DROP TABLE t1;
+DROP TABLE t2;

=== removed file 'mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt'
--- a/mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt	2008-03-28 17:13:51 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_28095_II-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---sql_mode=''

=== removed file 'mysql-test/suite/falcon/t/falcon_bug_28095_II.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_28095_II.test	2008-03-28 17:13:51 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_28095_II.test	1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
---source include/have_falcon.inc
-#
-# Mantis bug #126 second phase: Drop table causes crash
-# Mantis bug #123: Table cannot be read after restarting mysqld
-#
---echo *** Bug #126: Second phase ***
---echo *** Also test for bug #123 ***
-SET @@storage_engine = Falcon;
-
-SELECT * FROM t1;
-DROP TABLE t1, t2;

=== modified file 'mysql-test/t/group_by.test'
--- a/mysql-test/t/group_by.test	2008-04-01 15:13:57 +0000
+++ b/mysql-test/t/group_by.test	2008-09-09 19:36:23 +0000
@@ -1062,7 +1062,7 @@ SELECT a from t2 GROUP BY a;
 EXPLAIN SELECT b from t2 GROUP BY b;
 SELECT b from t2 GROUP BY b;
 
-DROP TABLE t1;
+DROP TABLE t1, t2;
 
 #
 # Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING
@@ -1109,5 +1109,32 @@ FROM t1;
 DROP TABLE t1;
 SET @@sql_mode = @old_sql_mode;
 
-
+--echo
+--echo BUG#38072: Wrong result: HAVING not observed in a query with aggregate
+--echo 
+CREATE TABLE t1 (
+  pk int(11) NOT NULL AUTO_INCREMENT,
+  int_nokey int(11) NOT NULL,
+  int_key int(11) NOT NULL,
+  varchar_key varchar(1) NOT NULL,
+  varchar_nokey varchar(1) NOT NULL,
+  PRIMARY KEY (pk),
+  KEY int_key (int_key),
+  KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES 
+(1,5,5, 'h','h'),
+(2,1,1, '{','{'),
+(3,1,1, 'z','z'),
+(4,8,8, 'x','x'),
+(5,7,7, 'o','o'),
+(6,3,3, 'p','p'),
+(7,9,9, 'c','c'),
+(8,0,0, 'k','k'),
+(9,6,6, 't','t'),
+(10,0,0,'c','c');
+
+explain SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+drop table t1;
 

=== modified file 'mysql-test/t/innodb_mrr.test'
--- a/mysql-test/t/innodb_mrr.test	2008-01-24 00:46:18 +0000
+++ b/mysql-test/t/innodb_mrr.test	2008-09-05 14:36:37 +0000
@@ -66,3 +66,36 @@ select * from t1 where (f3>=5 and f3<=10
 
 drop table t1;
 
+--echo
+--echo BUG#37977: Wrong result returned on GROUP BY + OR + Innodb
+--echo
+CREATE TABLE t1 (
+  `pk` int(11) NOT NULL AUTO_INCREMENT,
+  `int_nokey` int(11) NOT NULL,
+  `int_key` int(11) NOT NULL,
+  `date_key` date NOT NULL,
+  `date_nokey` date NOT NULL,
+  `time_key` time NOT NULL,
+  `time_nokey` time NOT NULL,
+  `datetime_key` datetime NOT NULL,
+  `datetime_nokey` datetime NOT NULL,
+  `varchar_key` varchar(5) DEFAULT NULL,
+  `varchar_nokey` varchar(5) DEFAULT NULL,
+  PRIMARY KEY (`pk`),
+  KEY `int_key` (`int_key`),
+  KEY `date_key` (`date_key`),
+  KEY `time_key` (`time_key`),
+  KEY `datetime_key` (`datetime_key`),
+  KEY `varchar_key` (`varchar_key`)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES 
+(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'),
+(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'),
+(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'),
+(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL),
+(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu');
+select pk from t1 WHERE `varchar_key` > 'kr' group by pk;
+select pk from t1 WHERE `int_nokey` IS NULL OR  `varchar_key` > 'kr' group by pk;
+drop table t1;
+

=== modified file 'mysql-test/t/myisam_mrr.test'
--- a/mysql-test/t/myisam_mrr.test	2008-01-10 22:04:59 +0000
+++ b/mysql-test/t/myisam_mrr.test	2008-09-05 19:23:07 +0000
@@ -45,3 +45,32 @@ select * FROM t1 WHERE key1=1130 AND col
 
 drop table t1;
 
+
+--echo 
+--echo  BUG#37851: Crash in test_if_skip_sort_order tab->select is zero
+--echo 
+CREATE TABLE t1 (
+  pk int(11) NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (
+  pk int(11) NOT NULL AUTO_INCREMENT,
+  int_key int(11) DEFAULT NULL,
+  PRIMARY KEY (pk),
+  KEY int_key (int_key)
+);
+INSERT INTO t2 VALUES (1,1),(2,6),(3,0);
+
+EXPLAIN EXTENDED
+SELECT MIN(t1.pk)
+FROM t1 WHERE EXISTS (
+ SELECT t2.pk
+ FROM t2
+ WHERE t2.int_key IS NULL
+ GROUP BY t2.pk
+);
+
+DROP TABLE t1, t2;
+

=== modified file 'mysql-test/t/ps_ddl.test'
--- a/mysql-test/t/ps_ddl.test	2008-08-13 20:05:34 +0000
+++ b/mysql-test/t/ps_ddl.test	2008-09-13 14:16:20 +0000
@@ -1407,17 +1407,17 @@ deallocate prepare stmt_sp;
 --echo # SQLCOM_SELECT
 --echo #
 
-#--disable_warnings
-#drop table if exists t1;
-#--enable_warnings
-#create table t1 (a int);
-#prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
-#drop table t1;
-#create table t1 (x int);
-#execute stmt;
-#drop table t1;
-#deallocate prepare stmt;
-#call p_verify_reprepare_count(1);
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
+drop table t1;
+create table t1 (x int);
+execute stmt;
+drop table t1;
+deallocate prepare stmt;
+call p_verify_reprepare_count(1);
 
 --echo #
 --echo # SQLCOM_CREATE_TABLE

=== modified file 'mysql-test/t/subselect3.test'
--- a/mysql-test/t/subselect3.test	2008-10-09 10:58:51 +0000
+++ b/mysql-test/t/subselect3.test	2008-10-24 03:46:27 +0000
@@ -1,5 +1,5 @@
 --disable_warnings
-drop table if exists t0, t1, t2, t3, t4, t5;
+drop table if exists t0, t1, t2, t3, t4;
 --enable_warnings
 
 #
@@ -634,41 +634,10 @@ let $datadir=`select @@datadir`;
 
 --echo End of 5.0 tests
 
-#
-# BUG#36135 "void Diagnostics_area::set_eof_status(THD*): Assertion `!is_set()' failed."
-#
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-
-create table t1 (
-  a int(11) default null,
-  b int(11) default null,
-  key (a)
-);
-# produce numbers 0..999
-insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C;
-
-create table t2 (a int(11) default null);
-insert into t2 values (0),(1);
-
-create table t3 (a int(11) default null);
-insert into t3 values (0),(1);
-
-create table t4 (a int(11) default null);
-insert into t4 values (0),(1);
-
-create table t5 (a int(11) default null);
-insert into t5 values (0),(1),(0),(1);
-
-# this must not fail assertion
---error 1242
-select * from t2, t3 
-where
-    t2.a < 10 and
-    t3.a+1 = 2 and
-    t3.a in (select t1.b from t1
-                 where t1.a+1=t1.a+1 and
-                       t1.a < (select t4.a+10                                  
-                                  from t4, t5 limit 2));
+--echo #  
+--echo # BUG#36896: Server crash on SELECT FROM DUAL
+--echo # 
+create table t1 (a int);
+select 1 as res from dual where (1) in (select * from t1);
+drop table t1;
 
-drop table t0, t1, t2, t3, t4, t5;

=== modified file 'mysql-test/t/sum_distinct.test'
--- a/mysql-test/t/sum_distinct.test	2005-04-07 16:24:14 +0000
+++ b/mysql-test/t/sum_distinct.test	2008-09-05 19:01:46 +0000
@@ -93,3 +93,28 @@ SELECT SUM(DISTINCT id) FROM t1;
 SELECT SUM(DISTINCT id % 11) FROM t1;
 
 DROP TABLE t1;
+
+--echo 
+--echo BUG#37891: Column cannot be null error with aggregate in a subquery
+--echo
+CREATE TABLE t1 (
+  pk int(11) NOT NULL AUTO_INCREMENT,
+  int_key int(11) DEFAULT NULL,
+  PRIMARY KEY (pk),
+  KEY int_key (int_key)
+);
+INSERT INTO t1 VALUES (1,10);
+
+CREATE TABLE t2 (
+  pk int(11) NOT NULL AUTO_INCREMENT,
+  time_nokey time DEFAULT NULL,
+  datetime_key time DEFAULT NULL,
+  PRIMARY KEY (pk),
+  KEY datetime_key (datetime_key)
+);
+INSERT INTO t2 VALUES (1,'18:19:29',NOW());
+
+SELECT * FROM t1 WHERE int_key IN ( SELECT SUM(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+SELECT * FROM t1 WHERE int_key IN ( SELECT AVG(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+drop table t1,t2;
+

=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2008-09-01 10:11:50 +0000
+++ b/sql/hostname.cc	2008-10-24 03:46:27 +0000
@@ -49,7 +49,6 @@ public:
 };
 
 static hash_filo *hostname_cache;
-static pthread_mutex_t LOCK_hostname;
 
 void hostname_cache_refresh()
 {
@@ -66,7 +65,6 @@ bool hostname_cache_init()
 				     &my_charset_bin)))
     return 1;
   hostname_cache->clear();
-  (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
 
   return 0;
 }
@@ -75,7 +73,6 @@ void hostname_cache_free()
 {
   if (hostname_cache)
   {
-    (void) pthread_mutex_destroy(&LOCK_hostname);
     delete hostname_cache;
     hostname_cache= 0;
   }

=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc	2008-06-26 16:17:05 +0000
+++ b/sql/item_sum.cc	2008-09-05 19:01:46 +0000
@@ -978,6 +978,17 @@ void Item_sum_distinct::fix_length_and_d
 }
 
 
+bool Item_sum_distinct::fix_fields(THD *thd, Item **ref)
+{
+  int res= Item_sum_num::fix_fields(thd, ref);
+  /*
+    SUM(DISTINCT x) and AVG(DISTINCT x) may have NULL value even when x is
+    not nullable:
+  */
+  maybe_null= TRUE;
+  return res;
+}
+
 /**
   @todo
   check that the case of CHAR(0) works OK

=== modified file 'sql/item_sum.h'
--- a/sql/item_sum.h	2008-06-12 19:04:52 +0000
+++ b/sql/item_sum.h	2008-09-05 19:01:46 +0000
@@ -488,6 +488,7 @@ public:
   void reset_field() {} // not used
   void update_field() {} // not used
   virtual void no_rows_in_result() {}
+  bool fix_fields(THD *thd, Item **ref);
   void fix_length_and_dec();
   enum Item_result result_type () const { return val.traits->type(); }
   virtual void calculate_val_and_count();

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-10-22 11:51:28 +0000
+++ b/sql/mysql_priv.h	2008-10-29 20:39:29 +0000
@@ -2083,14 +2083,14 @@ extern FILE *bootstrap_file;
 extern int bootstrap_error;
 extern FILE *stderror_file;
 extern pthread_key(MEM_ROOT**,THR_MALLOC);
-extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
+extern pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
        LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status,
        LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_short,
        LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
        LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
        LOCK_global_system_variables, LOCK_user_conn,
        LOCK_prepared_stmt_count,
-       LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
+       LOCK_connection_count;
 #ifdef HAVE_OPENSSL
 extern pthread_mutex_t LOCK_des_key_file;
 #endif

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2008-10-24 11:01:06 +0000
+++ b/sql/mysqld.cc	2008-11-01 17:24:56 +0000
@@ -686,11 +686,11 @@ SHOW_COMP_OPTION have_community_features
 
 pthread_key(MEM_ROOT**,THR_MALLOC);
 pthread_key(THD*, THR_THD);
-pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
+pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
 		LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
 		LOCK_error_log,
 		LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
-		LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
+		LOCK_crypt,
 	        LOCK_global_system_variables,
                 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
                 LOCK_connection_count;
@@ -1460,7 +1460,6 @@ static void clean_up_mutexes()
 {
   (void) pthread_mutex_destroy(&LOCK_mysql_create_db);
   (void) pthread_mutex_destroy(&LOCK_lock_db);
-  (void) pthread_mutex_destroy(&LOCK_Acl);
   (void) rwlock_destroy(&LOCK_grant);
   (void) pthread_mutex_destroy(&LOCK_open);
   (void) pthread_mutex_destroy(&LOCK_thread_count);
@@ -1472,8 +1471,6 @@ static void clean_up_mutexes()
   (void) pthread_mutex_destroy(&LOCK_delayed_create);
   (void) pthread_mutex_destroy(&LOCK_manager);
   (void) pthread_mutex_destroy(&LOCK_crypt);
-  (void) pthread_mutex_destroy(&LOCK_bytes_sent);
-  (void) pthread_mutex_destroy(&LOCK_bytes_received);
   (void) pthread_mutex_destroy(&LOCK_user_conn);
   (void) pthread_mutex_destroy(&LOCK_connection_count);
   Events::destroy_mutexes();
@@ -3703,7 +3700,6 @@ static int init_thread_environment()
 {
   (void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
   (void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
-  (void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
   (void) pthread_mutex_init(&LOCK_open, NULL);
   (void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
@@ -3714,8 +3710,6 @@ static int init_thread_environment()
   (void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
   (void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
-  (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
-  (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
   (void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);

=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc	2008-10-02 12:08:09 +0000
+++ b/sql/net_serv.cc	2008-10-24 03:46:27 +0000
@@ -97,7 +97,6 @@ void sql_print_error(const char *format,
 */
 extern uint test_flags;
 extern ulong bytes_sent, bytes_received, net_big_packet_count;
-extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
 #ifndef MYSQL_INSTANCE_MANAGER
 #ifdef HAVE_QUERY_CACHE
 #define USE_QUERY_CACHE

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2008-10-20 19:13:22 +0000
+++ b/sql/sql_select.cc	2008-10-30 18:02:08 +0000
@@ -570,7 +570,7 @@ JOIN::prepare(Item ***rref_pointer_array
           4. Subquery does not use aggregate functions or HAVING
           5. Subquery predicate is at the AND-top-level of ON/WHERE clause
           6. No execution method was already chosen (by a prepared statement).
-
+          7. Parent SELECT is not a confluent "SELECT ... FROM DUAL" w/o tables
           (*). We are not in a subquery of a single table UPDATE/DELETE that 
                doesn't have a JOIN (TODO: We should handle this at some
                point by switching to multi-table UPDATE/DELETE)
@@ -586,7 +586,8 @@ JOIN::prepare(Item ***rref_pointer_array
           select_lex->outer_select()->join &&                           // (*)
           select_lex->master_unit()->first_select()->leaf_tables &&     // (**) 
           do_semijoin &&
-          in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED)   // 6
+          in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED && // 6
+          select_lex->outer_select()->leaf_tables)                     // 7
       {
         DBUG_PRINT("info", ("Subquery is semi-join conversion candidate"));
 
@@ -634,6 +635,11 @@ JOIN::prepare(Item ***rref_pointer_array
           2. Subquery is a single SELECT (not a UNION)
           3. Subquery is not a table-less query. In this case there is no
              point in materializing.
+          3A The upper query is not a confluent SELECT ... FROM DUAL. We
+             can't do materialization for SELECT .. FROM DUAL because it
+             does not call setup_subquery_materialization(). We could make 
+             SELECT ... FROM DUAL call that function but that doesn't seem
+             to be the case that is worth handling.
           4. Subquery predicate is a top-level predicate
              (this implies it is not negated)
              TODO: this is a limitation that should be lifeted once we
@@ -660,7 +666,8 @@ JOIN::prepare(Item ***rref_pointer_array
             in_subs  &&                                                   // 1
             !select_lex->master_unit()->first_select()->next_select() &&  // 2
             select_lex->master_unit()->first_select()->leaf_tables &&     // 3
-            thd->lex->sql_command == SQLCOM_SELECT)                       // *
+            thd->lex->sql_command == SQLCOM_SELECT &&                     // *
+            select_lex->outer_select()->leaf_tables)                      // 3A
         {
           if (in_subs->is_top_level_item() &&                             // 4
               !in_subs->is_correlated &&                                  // 5
@@ -2431,8 +2438,7 @@ JOIN::exec()
     if (!items1)
     {
       items1= items0 + all_fields.elements;
-      if (sort_and_group || curr_tmp_table->group ||
-          tmp_table_param.precomputed_group_by)
+      if (sort_and_group || curr_tmp_table->group)
       {
 	if (change_to_use_tmp_fields(thd, items1,
 				     tmp_fields_list1, tmp_all_fields1,
@@ -3628,10 +3634,10 @@ bool find_eq_ref_candidate(TABLE *table,
      - It is accessed 
 
     POSTCONDITIONS
-     * Pulled out tables have JOIN_TAB::emb_sj_nest == NULL (like the outer
-       tables)
-     * Tables that were not pulled out have JOIN_TAB::emb_sj_nest.
-     * Semi-join nests TABLE_LIST::sj_inner_tables
+     * Tables that were pulled out have JOIN_TAB::emb_sj_nest == NULL
+     * Tables that were not pulled out have JOIN_TAB::emb_sj_nest pointing 
+       to semi-join nest they are in.
+     * Semi-join nests' TABLE_LIST::sj_inner_tables is updated accordingly
 
     This operation is (and should be) performed at each PS execution since
     tables may become/cease to be constant across PS reexecutions.
@@ -11701,8 +11707,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
   ENGINE_COLUMNDEF *recinfo;
   uint total_uneven_bit_length= 0;
   bool force_copy_fields= param->force_copy_fields;
-  /* Treat sum functions as normal ones when loose index scan is used. */
-  save_sum_fields|= param->precomputed_group_by;
   DBUG_ENTER("create_tmp_table");
   DBUG_PRINT("enter",
              ("distinct: %d  save_sum_fields: %d  rows_limit: %lu  group: %d",
@@ -13004,8 +13008,7 @@ static bool create_internal_tmp_table(TA
 bool create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
                                          ENGINE_COLUMNDEF *start_recinfo,
                                          ENGINE_COLUMNDEF **recinfo, 
-                                         int error,
-                                         bool ignore_last_dupp_key_error)
+                                         int error, bool ignore_last_dupp_key_error)
 {
   return create_internal_tmp_table_from_heap2(thd, table,
                                               start_recinfo, recinfo, error,
@@ -15916,7 +15919,11 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
       if (table->covering_keys.is_set(ref_key))
 	usable_keys.intersect(table->covering_keys);
       if (tab->pre_idx_push_select_cond)
-        tab->select_cond= tab->select->cond= tab->pre_idx_push_select_cond;
+      {
+        tab->select_cond= tab->pre_idx_push_select_cond;
+        if (tab->select)
+          tab->select->cond= tab->select_cond;
+      }
       if ((new_ref_key= test_if_subkey(order, table, ref_key, ref_key_parts,
 				       &usable_keys)) < MAX_KEY)
       {
@@ -16184,7 +16191,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
             table->key_read= 0;
             table->file->extra(HA_EXTRA_NO_KEYREAD);
           }
-
+          if (tab->pre_idx_push_select_cond)
+          {
+            if (tab->select)
+              tab->select->cond= tab->select_cond;
+            tab->select_cond= tab->pre_idx_push_select_cond;
+          }
           table->file->ha_index_or_rnd_end();
           if (join->select_options & SELECT_DESCRIBE)
           {

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2008-09-04 18:30:34 +0000
+++ b/sql/sql_select.h	2008-10-24 03:46:27 +0000
@@ -683,7 +683,7 @@ public:
   bool send_row_on_empty_set()
   {
     return (do_send_rows && tmp_table_param.sum_func_count != 0 &&
-	    !group_list);
+	    !group_list && having_value != Item::COND_FALSE);
   }
   bool change_result(select_result *result);
   bool is_top_level_join() const

=== modified file 'storage/falcon/StorageVersion.h'
--- a/storage/falcon/StorageVersion.h	2008-10-30 16:13:48 +0000
+++ b/storage/falcon/StorageVersion.h	2008-11-05 15:41:45 +0000
@@ -14,5 +14,5 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 
-#define FALCON_VERSION	"T1.3-2"
-#define FALCON_DATE		"30 October, 2008"
+#define FALCON_VERSION	"T1.3-3"
+#define FALCON_DATE		"05 November, 2008"

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2008-10-20 09:16:47 +0000
+++ b/storage/myisam/ha_myisam.cc	2008-10-29 20:39:29 +0000
@@ -1482,7 +1482,6 @@ C_MODE_START
 my_bool index_cond_func_myisam(void *arg)
 {
   ha_myisam *h= (ha_myisam*)arg;
-  /*if (h->in_range_read)*/
   if (h->end_range)
   {
     if (h->compare_key2(h->end_range) > 0)
@@ -1497,7 +1496,6 @@ C_MODE_END
 int ha_myisam::index_init(uint idx, bool sorted)
 { 
   active_index=idx;
-  //in_range_read= FALSE;
   if (pushed_idx_cond_keyno == idx)
     mi_set_index_cond_func(file, index_cond_func_myisam, this);
   return 0; 
@@ -1605,13 +1603,7 @@ int ha_myisam::read_range_first(const ke
                                 bool sorted /* ignored */)
 {
   int res;
-  //if (!eq_range_arg)
-  //  in_range_read= TRUE;
-
   res= handler::read_range_first(start_key, end_key, eq_range_arg, sorted);
-
-  //if (res)
-  //  in_range_read= FALSE;
   return res;
 }
 
@@ -1619,8 +1611,6 @@ int ha_myisam::read_range_first(const ke
 int ha_myisam::read_range_next()
 {
   int res= handler::read_range_next();
-  //if (res)
-  //  in_range_read= FALSE;
   return res;
 }
 

=== modified file 'zlib/gzio.c'
--- a/zlib/gzio.c	2008-08-25 17:14:21 +0000
+++ b/zlib/gzio.c	2008-10-17 15:39:36 +0000
@@ -7,6 +7,11 @@
 
 /* @(#) $Id$ */
 
+/* Need to be included "early" to control other headers */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdio.h>
 
 #include "zutil.h"

Thread
bzr push into mysql-6.0-falcon-team branch (hky:2902 to 2903) Hakan Kuecuekyilmaz5 Nov