MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:November 20 2009 12:54pm
Subject:bzr push into mysql-6.0-codebase-bugfixing branch (kostja:3710 to 3719)
View as plain text  
 3719 Konstantin Osipov	2009-11-20 [merge]
      Merge with next-mr

    modified:
      client/mysqltest.cc
      sql/sql_insert.cc
      vio/vio_priv.h
 3718 Konstantin Osipov	2009-11-20 [merge]
      Null-merge next-mr-runtime.

 3717 Guilhem Bichot	2009-11-18 [merge]
      null-merge from mysql-next-mr-bugfixing (a backport)

 3716 Tor Didriksen	2009-11-18
      Disable test which always fails until bug is fixed.
     @ mysql-test/collections/default.experimental
        The query which fails has been disabled.
     @ mysql-test/r/merge.result
        Disable query.
     @ mysql-test/t/merge.test
        Disable query.

    modified:
      mysql-test/collections/default.experimental
      mysql-test/r/merge.result
      mysql-test/t/merge.test
 3715 Alexey Botchkov	2009-11-17 [merge]
      merging.

    modified:
      client/mysql.cc
      client/mysql_upgrade.c
      client/mysqladmin.cc
      client/mysqlbinlog.cc
      client/mysqlcheck.c
      client/mysqldump.c
      client/mysqlimport.c
      client/mysqlshow.c
      client/mysqlslap.c
      client/mysqltest.cc
      extra/my_print_defaults.c
      include/my_sys.h
      mysys/default.c
      sql/item_sum.cc
      sql/item_sum.h
      sql/mysqld.cc
      storage/archive/archive_reader.c
      storage/myisam/myisamchk.c
      storage/myisam/myisampack.c
      tests/mysql_client_test.c
      tests/thread_test.c
 3714 Tor Didriksen	2009-11-18
      Bug #47338 assertion in handler::ha_external_lock
      
      Cleanup after an underlying error was not handled gracefully in
      DsMrr_impl::dsmrr_init()
     @ mysql-test/r/analyse.result
        Add test case.
     @ mysql-test/t/analyse.test
        Add test case.
     @ mysys/my_open.c
        Dont call DBUG_RETURN(functio_call())
        it makes DEBUG output very confusing.
     @ sql/handler.cc
        Avoid double delete of member variable 'h2'
        
        Dont call DBUG_RETURN(functio_call())
        it makes DEBUG output very confusing.

    modified:
      mysql-test/r/analyse.result
      mysql-test/t/analyse.test
      mysys/my_open.c
      sql/handler.cc
 3713 Jorgen Loland	2009-11-18
      Bug#43618: MyISAM&Maria returns wrong results with 'between' 
                 on timestamp
         
      When conditions are pushed to an index (ICP), the same conditions
      is not checked for records returned by the index. It is assumed
      that all records qualify for these conditions.
            
      However, for MyISAM, these conditions were checked only for
      forward index lookups (mi_rnext), and not for reverse order
      lookups (mi_rprev). Thus, records that did not qualify could be
      returned if mi_rprev was used.
            
      This patch makes mi_rprev check the pushed conditions in the 
      same way as mi_rnext does.
     @ mysql-test/r/select.result
        Added test for BUG#43618
     @ mysql-test/r/select_jcl6.result
        Added test for BUG#43618
     @ mysql-test/r/subselect3.result
        Records that did not qualify for insertion due to non-matching WHERE condition were inserted due to missing condition check for reverse index lookup with ICP. These records are no longer inserted.
     @ mysql-test/r/subselect3_jcl6.result
        Records that did not qualify for insertion due to non-matching WHERE condition were inserted due to missing condition check for reverse index lookup with ICP. These records are no longer inserted.
     @ mysql-test/t/select.test
        Added test for BUG#43618
     @ storage/myisam/mi_rnext.c
        Modify comment to reflect that record is skipped if it does not qualify for some pushed condition (ICP)
     @ storage/myisam/mi_rprev.c
        Skip record if record does not qualify for a pushed condition (ICP)

    modified:
      mysql-test/r/select.result
      mysql-test/r/select_jcl6.result
      mysql-test/r/subselect3.result
      mysql-test/r/subselect3_jcl6.result
      mysql-test/t/select.test
      storage/myisam/mi_rnext.c
      storage/myisam/mi_rprev.c
 3712 Tor Didriksen	2009-11-17
      Bug#46550 Azalea returning duplicate results for some IN subqueries w/ semijoin=on
      
      The optimizer was choosing an illegal plan for FirstMatch.
      Add an explicit check that all inner tables are part of 'remaining_tables'
      when we initiate the FirstMatch algorithm.
     @ mysql-test/r/subselect_sj.result
        Add test case.
     @ mysql-test/r/subselect_sj_jcl6.result
        Add test case.
     @ mysql-test/t/subselect_sj.test
        Add test case.
     @ sql/sql_select.cc
        Add an explicit check that all inner tables are part of 'remaining_tables'
        when we initiate the FirstMatch algorithm.
        
        Some cosmetics for readability and coding style compliance.

    modified:
      mysql-test/r/subselect_sj.result
      mysql-test/r/subselect_sj_jcl6.result
      mysql-test/t/subselect_sj.test
      sql/sql_select.cc
 3711 Alexey Botchkov	2009-11-15 [merge]
      merging

    modified:
      mysql-test/r/mysqlbinlog_row.result
      mysql-test/r/mysqlbinlog_row_innodb.result
      mysql-test/r/mysqlbinlog_row_myisam.result
      mysql-test/r/mysqlbinlog_row_trans.result
 3710 Olav Sandstaa	2009-11-13 [merge]
      Local merge

    modified:
      client/mysqltest.cc
      mysql-test/r/loadxml.result
      mysql-test/t/loadxml.test
      storage/myisam/mi_dynrec.c
=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2009-11-12 03:14:04 +0000
+++ b/.bzr-mysql/default.conf	2009-11-12 03:21:14 +0000
@@ -1,4 +1,4 @@
 [MYSQL]
 post_commit_to = "commits@stripped"
 post_push_to = "commits@stripped"
-tree_name = "mysql-6.0-codebase"
+tree_name = "mysql-6.0-codebase-bugfixing"

=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2009-11-09 10:27:46 +0000
+++ b/client/mysql.cc	2009-11-20 12:49:47 +0000
@@ -1120,7 +1120,11 @@ int main(int argc,char *argv[])
       close(stdout_fileno_copy);             /* Clean up dup(). */
   }
 
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+  {
+    my_end(0);
+    exit(1);
+  }
   defaults_argv=argv;
   if (get_options(argc, (char **) argv))
   {

=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2009-10-29 13:11:10 +0000
+++ b/client/mysql_upgrade.c	2009-11-17 11:46:17 +0000
@@ -819,7 +819,8 @@ int main(int argc, char **argv)
       init_dynamic_string(&conn_args, "", 512, 256))
     die("Out of memory");
 
-  load_defaults("my", load_default_groups, &argc, &argv);
+  if (load_defaults("my", load_default_groups, &argc, &argv))
+    die(NULL);
   defaults_argv= argv; /* Must be freed by 'free_defaults' */
 
   if (handle_options(&argc, &argv, my_long_options, get_one_option))

=== modified file 'client/mysqladmin.cc'
--- a/client/mysqladmin.cc	2009-10-25 13:39:16 +0000
+++ b/client/mysqladmin.cc	2009-11-19 22:24:07 +0000
@@ -304,7 +304,8 @@ int main(int argc,char *argv[])
 
   MY_INIT(argv[0]);
   mysql_init(&mysql);
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+   exit(1); 
   save_argv = argv;				/* Save for free_defaults */
   if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
   {

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-11-09 10:27:46 +0000
+++ b/client/mysqlbinlog.cc	2009-11-17 11:46:17 +0000
@@ -2028,7 +2028,8 @@ int main(int argc, char** argv)
 
   my_init_time(); // for time functions
 
-  load_defaults("my", load_default_groups, &argc, &argv);
+  if (load_defaults("my", load_default_groups, &argc, &argv))
+    exit(1);
   defaults_argv= argv;
   parse_args(&argc, (char***)&argv);
 

=== modified file 'client/mysqlcheck.c'
--- a/client/mysqlcheck.c	2009-10-25 13:39:16 +0000
+++ b/client/mysqlcheck.c	2009-11-19 22:24:07 +0000
@@ -344,9 +344,8 @@ static int get_options(int *argc, char *
     exit(0);
   }
 
-  load_defaults("my", load_default_groups, argc, argv);
-
-  if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
+  if ((ho_error= load_defaults("my", load_default_groups, argc, argv)) ||
+      (ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
     exit(ho_error);
 
   if (!what_to_do)

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2009-11-02 15:11:43 +0000
+++ b/client/mysqldump.c	2009-11-19 22:24:07 +0000
@@ -890,7 +890,8 @@ static int get_options(int *argc, char *
   opt_net_buffer_length= *mysql_params->p_net_buffer_length;
 
   md_result_file= stdout;
-  load_defaults("my",load_default_groups,argc,argv);
+  if (load_defaults("my",load_default_groups,argc,argv))
+    return 1;
   defaults_argv= *argv;
 
   if (my_hash_init(&ignore_table, charset_info, 16, 0, 0,

=== modified file 'client/mysqlimport.c'
--- a/client/mysqlimport.c	2009-10-25 13:39:16 +0000
+++ b/client/mysqlimport.c	2009-11-17 11:46:17 +0000
@@ -592,7 +592,8 @@ int main(int argc, char **argv)
   char **argv_to_free;
   MY_INIT(argv[0]);
 
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+    return 1;
   /* argv is changed in the program */
   argv_to_free= argv;
   if (get_options(&argc, &argv))

=== modified file 'client/mysqlshow.c'
--- a/client/mysqlshow.c	2009-10-22 16:07:09 +0000
+++ b/client/mysqlshow.c	2009-11-17 11:46:17 +0000
@@ -63,7 +63,9 @@ int main(int argc, char **argv)
   char *wild;
   MYSQL mysql;
   MY_INIT(argv[0]);
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+    exit(1);
+
   get_options(&argc,&argv);
 
   wild=0;

=== modified file 'client/mysqlslap.c'
--- a/client/mysqlslap.c	2009-10-23 06:24:37 +0000
+++ b/client/mysqlslap.c	2009-11-17 11:46:17 +0000
@@ -343,7 +343,11 @@ int main(int argc, char **argv)
   if (!(mysql_thread_safe()))
       fprintf(stderr, "This application was compiled incorrectly. Please recompile with thread support.\n");
 
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+  {
+    my_end(0);
+    exit(1);
+  }
   defaults_argv=argv;
   if (get_options(&argc,&argv))
   {

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2009-11-12 00:55:14 +0000
+++ b/client/mysqltest.cc	2009-11-20 12:49:47 +0000
@@ -288,7 +288,6 @@ enum enum_commands {
   Q_SEND_SHUTDOWN, Q_SHUTDOWN_SERVER,
   Q_RESULT_FORMAT_VERSION,
   Q_MOVE_FILE, Q_SEND_EVAL,
-
   Q_UNKNOWN,			       /* Unknown command.   */
   Q_COMMENT,			       /* Comments, ignored. */
   Q_COMMENT_WITH_COMMAND,
@@ -6047,7 +6046,9 @@ get_one_option(int optid, const struct m
 
 int parse_args(int argc, char **argv)
 {
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+    exit(1);
+
   default_argv= argv;
 
   if ((handle_options(&argc, &argv, my_long_options, get_one_option)))

=== modified file 'extra/my_print_defaults.c'
--- a/extra/my_print_defaults.c	2009-10-26 14:02:26 +0000
+++ b/extra/my_print_defaults.c	2009-11-17 11:46:17 +0000
@@ -189,6 +189,7 @@ int main(int argc, char **argv)
 		config_file);
     }
     error= 2;
+    exit(error);
   }
 
   for (argument= arguments+1 ; *argument ; argument++)
@@ -197,5 +198,5 @@ int main(int argc, char **argv)
   my_free((char*) load_default_groups,MYF(0));
   free_defaults(arguments);
 
-  exit(error);
+  exit(0);
 }

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2009-11-10 07:47:59 +0000
+++ b/include/my_sys.h	2009-11-17 11:46:17 +0000
@@ -64,7 +64,7 @@ extern int NEAR my_errno;		/* Last error
 #define MY_WME		16	/* Write message on error */
 #define MY_WAIT_IF_FULL 32	/* Wait and try again if disk full error */
 #define MY_IGNORE_BADFD 32      /* my_sync: ignore 'bad descriptor' errors */
-#define MY_SYNC_DIR     1024    /* my_create/delete/rename: sync directory */
+#define MY_SYNC_DIR     8192    /* my_create/delete/rename: sync directory */
 #define MY_RAID         64      /* Support for RAID */
 #define MY_FULL_IO     512      /* For my_read - loop intil I/O is complete */
 #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */

=== modified file 'mysql-test/collections/default.experimental'
--- a/mysql-test/collections/default.experimental	2009-11-09 10:27:46 +0000
+++ b/mysql-test/collections/default.experimental	2009-11-18 15:06:15 +0000
@@ -30,7 +30,6 @@ main.lock_multi_bug38499                
 main.lock_multi_bug38691 @solaris        # Bug#47792 2009-10-02 alik main.lock_multi_bug38691 times out sporadically on Solaris 10
 main.locktrans_innodb                    # Bug#37775 2009-09-29 alik main.locktrans_innodb and rpl.rpl_locktrans_innodb fail randomly
 main.log_tables                          # Bug#47924 2009-10-08 alik main.log_tables times out sporadically 
-main.merge                               # Bug#47648 2009-09-25 alik main.merge fails sporadically
 main.plugin*  @solaris                   # Bug#47146 Linking problem with example plugin when dtrace enabled
 main.plugin_load                         # Bug#47146
 main.plugin_notembedded                  # Bug#47662 2009-09-27 alik main.plugin_notembedded fails sporadically in pb2

=== added file 'mysql-test/collections/mysql-6.0-codebase-bugfixing.daily'
--- a/mysql-test/collections/mysql-6.0-codebase-bugfixing.daily	1970-01-01 00:00:00 +0000
+++ b/mysql-test/collections/mysql-6.0-codebase-bugfixing.daily	2009-11-13 09:50:24 +0000
@@ -0,0 +1,5 @@
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=n_mix          --vardir=var-n_mix                        --mysqld=--binlog-format=mixed  --suite=main,backup,backup_engines,backup_ptr,binlog,federated,rpl
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=ps_row         --vardir=var-ps_row         --ps-protocol --mysqld=--binlog-format=row    --suite=main,backup,backup_engines,backup_ptr,binlog,federated,rpl
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=embedded       --vardir=var-emebbed        --embedded                                    --suite=main,backup,backup_engines,backup_ptr,binlog,federated,rpl
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=rpl_binlog_row --vardir=var-rpl_binlog_row               --mysqld=--binlog-format=row    --suite=rpl,binlog
+perl mysql-test-run.pl --timer --force --parallel=auto --experimental=collections/default.experimental --comment=funcs_1        --vardir=var-funcs_1                                                      --suite=funcs_1

=== modified file 'mysql-test/extra/rpl_tests/rpl_insert_id.test'
--- a/mysql-test/extra/rpl_tests/rpl_insert_id.test	2009-10-01 14:35:40 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test	2009-11-04 08:53:57 +0000
@@ -117,6 +117,7 @@ sync_slave_with_master;
 --echo #
 
 connection master;
+set @@session.sql_auto_is_null=1;
 eval create table t1(a int auto_increment, key(a)) engine=$engine_type;
 eval create table t2(a int) engine=$engine_type;
 insert into t1 (a) values (null);
@@ -551,4 +552,5 @@ connection master;
 drop table t1, t2;
 drop procedure foo;
 SET @@global.concurrent_insert= @old_concurrent_insert;
+set @@session.sql_auto_is_null=default;
 sync_slave_with_master;

=== modified file 'mysql-test/r/analyse.result'
--- a/mysql-test/r/analyse.result	2009-10-30 09:56:32 +0000
+++ b/mysql-test/r/analyse.result	2009-11-18 08:15:50 +0000
@@ -123,3 +123,18 @@ CREATE TABLE t2 SELECT 1 FROM t1, t1 t3 
 ERROR HY000: Incorrect usage of PROCEDURE and non-SELECT
 DROP TABLE t1;
 End of 5.0 tests
+#
+# Bug #47338 assertion in handler::ha_external_lock
+#
+call mtr.add_suppression("Incorrect key file for table .*");
+drop table if exists t1;
+CREATE TEMPORARY TABLE t1 (f2 INT, f1 INT, PRIMARY KEY (f1)) ENGINE = MyISAM;
+INSERT t1 ( f1 ) VALUES ( 5 );
+INSERT t1 ( f1 ) VALUES ( 6 );
+ALTER TABLE t1 ENGINE = MyISAM;
+ANALYZE TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	analyze	status	OK
+SELECT f1,f2 FROM t1 A WHERE f1 BETWEEN 0 AND 1;
+ERROR HY000: Incorrect key file for table 'path hidden'; try to repair it
+drop table t1;

=== modified file 'mysql-test/r/ctype_utf8.result'
--- a/mysql-test/r/ctype_utf8.result	2009-10-23 06:24:37 +0000
+++ b/mysql-test/r/ctype_utf8.result	2009-11-09 11:58:51 +0000
@@ -1915,6 +1915,24 @@ CONVERT(a, CHAR)	CONVERT(b, CHAR)
 70000	1092
 DROP TABLE t1;
 End of 5.0 tests
+Start of 5.4 tests
+CREATE TABLE t1 (
+clipid INT NOT NULL,
+Tape TINYTEXT,
+PRIMARY KEY (clipid),
+KEY tape(Tape(255))
+) CHARACTER SET=utf8;
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `clipid` int(11) NOT NULL,
+  `mos` tinyint(4) DEFAULT '0',
+  `Tape` tinytext,
+  PRIMARY KEY (`clipid`),
+  KEY `tape` (`Tape`(255))
+) ENGINE=MyISAM DEFAULT CHARSET=utf8
+DROP TABLE t1;
 DROP TABLE IF EXISTS t1;
 CREATE TABLE t1 (
 predicted_order int NOT NULL,
@@ -2025,7 +2043,10 @@ predicted_order	hex(utf8_encoding)
 100	E0B78AE2808DE0B6BA
 101	E0B78AE2808DE0B6BB
 DROP TABLE t1;
-End of 5.1 tests
+End of 5.4 tests
+#
+# Start of 6.0 tests
+#
 set names utf8;
 select @@collation_connection;
 @@collation_connection
@@ -2401,131 +2422,6 @@ b
 c
 drop table t1;
 set max_sort_length=default;
-CREATE TABLE t1 (
-clipid INT NOT NULL,
-Tape TINYTEXT,
-PRIMARY KEY (clipid),
-KEY tape(Tape(255))
-) CHARACTER SET=utf8;
-ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `clipid` int(11) NOT NULL,
-  `mos` tinyint(4) DEFAULT '0',
-  `Tape` tinytext,
-  PRIMARY KEY (`clipid`),
-  KEY `tape` (`Tape`(255))
-) ENGINE=MyISAM DEFAULT CHARSET=utf8
-DROP TABLE t1;
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (
-predicted_order int NOT NULL,
-utf8_encoding VARCHAR(10) NOT NULL
-) CHARACTER SET utf8;
-INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17,
  x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
-SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci;
-predicted_order	hex(utf8_encoding)
-1	E0B7B4
-2	E0B685
-3	E0B686
-4	E0B687
-5	E0B688
-6	E0B689
-7	E0B68A
-8	E0B68B
-9	E0B68C
-10	E0B68D
-11	E0B68E
-12	E0B68F
-13	E0B690
-14	E0B691
-15	E0B692
-16	E0B693
-17	E0B694
-18	E0B695
-19	E0B696
-20	E0B682
-21	E0B683
-22	E0B69A
-23	E0B69AE0B78F
-24	E0B69AE0B790
-25	E0B69AE0B791
-26	E0B69AE0B792
-27	E0B69AE0B793
-28	E0B69AE0B794
-29	E0B69AE0B796
-30	E0B69AE0B798
-31	E0B69AE0B7B2
-32	E0B69AE0B79F
-33	E0B69AE0B7B3
-34	E0B69AE0B799
-35	E0B69AE0B79A
-36	E0B69AE0B79B
-37	E0B69AE0B79C
-38	E0B69AE0B79D
-39	E0B69AE0B79E
-40	E0B69AE0B78A
-41	E0B69B
-42	E0B69C
-43	E0B69D
-44	E0B69E
-45	E0B69F
-46	E0B6A0
-47	E0B6A1
-48	E0B6A2
-49	E0B6A3
-50	E0B6A5
-51	E0B6A4
-52	E0B6A6
-53	E0B6A7
-54	E0B6A8
-55	E0B6A9
-56	E0B6AA
-57	E0B6AB
-58	E0B6AC
-59	E0B6AD
-60	E0B6AE
-61	E0B6AF
-62	E0B6B0
-63	E0B6B1
-64	E0B6B3
-65	E0B6B4
-66	E0B6B5
-67	E0B6B6
-68	E0B6B7
-69	E0B6B8
-70	E0B6B9
-71	E0B6BA
-72	E0B6BB
-73	E0B6BBE0B78AE2808D
-74	E0B6BD
-75	E0B780
-76	E0B781
-77	E0B782
-78	E0B783
-79	E0B784
-80	E0B785
-81	E0B786
-82	E0B78F
-83	E0B790
-84	E0B791
-85	E0B792
-86	E0B793
-87	E0B794
-88	E0B796
-89	E0B798
-90	E0B7B2
-91	E0B79F
-92	E0B7B3
-93	E0B799
-94	E0B79A
-95	E0B79B
-96	E0B79C
-97	E0B79D
-98	E0B79E
-99	E0B78A
-100	E0B78AE2808DE0B6BA
-101	E0B78AE2808DE0B6BB
-DROP TABLE t1;
-End of tests
+#
+# End of 6.0 tests
+#

=== modified file 'mysql-test/r/func_isnull.result'
--- a/mysql-test/r/func_isnull.result	2002-05-16 20:35:09 +0000
+++ b/mysql-test/r/func_isnull.result	2009-11-03 13:54:41 +0000
@@ -5,3 +5,8 @@ flush tables;
 select * from t1 where isnull(to_days(mydate));
 id	mydate
 drop table t1;
+CREATE TABLE t1 (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id));
+INSERT INTO t1( id ) VALUES ( NULL );
+SELECT t1.id  FROM t1  WHERE (id  is not null and id is null );
+id
+DROP TABLE t1;

=== modified file 'mysql-test/r/innodb_mysql.result'
--- a/mysql-test/r/innodb_mysql.result	2009-11-09 10:27:46 +0000
+++ b/mysql-test/r/innodb_mysql.result	2009-11-12 12:13:55 +0000
@@ -2323,4 +2323,35 @@ b
 1
 set join_cache_level=default;
 DROP TABLE t1,t2;
+#
+# BUG#48093: 6.0 Server not processing equivalent IN clauses properly 
+#            with Innodb tables
+#
+CREATE TABLE t1 (
+i int(11) DEFAULT NULL,
+v1 varchar(1) DEFAULT NULL,
+v2 varchar(20) DEFAULT NULL,
+KEY i (i),
+KEY v (v1,i)
+) ENGINE=innodb;
+INSERT INTO t1 VALUES (1,'f','no');
+INSERT INTO t1 VALUES (2,'u','yes-u');
+INSERT INTO t1 VALUES (2,'h','yes-h');
+INSERT INTO t1 VALUES (3,'d','no');
+
+SELECT v2  
+FROM t1
+WHERE v1  IN  ('f', 'd', 'h', 'u' ) AND i  =  2;
+v2
+yes-u
+yes-h
+
+# Should not use index_merge
+EXPLAIN
+SELECT v2  
+FROM t1
+WHERE v1  IN  ('f', 'd', 'h', 'u' ) AND i  =  2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	i,v	i	5	const	2	Using where
+DROP TABLE t1;
 End of 6.0 tests

=== modified file 'mysql-test/r/lock.result'
--- a/mysql-test/r/lock.result	2009-10-12 09:08:34 +0000
+++ b/mysql-test/r/lock.result	2009-11-10 08:27:24 +0000
@@ -41,7 +41,7 @@ lock tables t1 write;
 check table t2;
 Table	Op	Msg_type	Msg_text
 test.t2	check	Error	Table 't2' was not locked with LOCK TABLES
-test.t2	check	error	Corrupt
+test.t2	check	status	Operation failed
 insert into t1 select index1,nr from t1;
 ERROR HY000: Table 't1' was not locked with LOCK TABLES
 unlock tables;

=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2009-11-02 15:16:58 +0000
+++ b/mysql-test/r/merge.result	2009-11-18 15:06:15 +0000
@@ -640,9 +640,8 @@ ALTER TABLE t4 UNION=(t1,t2);
 UNLOCK TABLES;
 # MERGE table and function.
 CREATE FUNCTION f1 () RETURNS INT RETURN (SELECT max(c1) FROM t3);
-SELECT * FROM t4 WHERE c1 < f1();
-c1
-3
+Disable this, because of:
+Bug #47648 main.merge fails sporadically
 DROP FUNCTION f1;
 DROP TABLE t4, t3, t2, t1;
 CREATE TABLE t1 (

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2009-09-30 02:45:14 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2009-11-04 08:53:57 +0000
@@ -21,7 +21,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -67,7 +67,7 @@ DELIMITER /*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -99,7 +99,7 @@ DELIMITER /*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -121,7 +121,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -167,7 +167,7 @@ DELIMITER /*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -199,7 +199,7 @@ DELIMITER /*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -299,7 +299,7 @@ DELIMITER /*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -349,7 +349,7 @@ DELIMITER /*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/r/mysqlbinlog2.result'
--- a/mysql-test/r/mysqlbinlog2.result	2008-04-02 09:49:22 +0000
+++ b/mysql-test/r/mysqlbinlog2.result	2009-11-03 13:54:41 +0000
@@ -22,7 +22,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -65,7 +65,7 @@ SET INSERT_ID=1/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -104,7 +104,7 @@ SET INSERT_ID=4/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -130,7 +130,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -165,7 +165,7 @@ SET INSERT_ID=4/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -188,7 +188,7 @@ SET INSERT_ID=3/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -218,7 +218,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -249,7 +249,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -284,7 +284,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -307,7 +307,7 @@ SET INSERT_ID=1/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -338,7 +338,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -361,7 +361,7 @@ SET INSERT_ID=4/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -380,7 +380,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -402,7 +402,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -448,7 +448,7 @@ SET INSERT_ID=3/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -471,7 +471,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -493,7 +493,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -523,7 +523,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -566,7 +566,7 @@ SET INSERT_ID=1/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -604,7 +604,7 @@ SET INSERT_ID=4/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -630,7 +630,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -664,7 +664,7 @@ SET INSERT_ID=4/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -687,7 +687,7 @@ SET INSERT_ID=3/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -717,7 +717,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -747,7 +747,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -782,7 +782,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -805,7 +805,7 @@ SET INSERT_ID=1/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -836,7 +836,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -858,7 +858,7 @@ SET INSERT_ID=4/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609946/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -877,7 +877,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -899,7 +899,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -945,7 +945,7 @@ SET INSERT_ID=3/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609944/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -968,7 +968,7 @@ SET INSERT_ID=6/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609943/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -990,7 +990,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -1020,7 +1020,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1579609942/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/r/mysqlbinlog_row.result'
--- a/mysql-test/r/mysqlbinlog_row.result	2009-06-05 13:21:53 +0000
+++ b/mysql-test/r/mysqlbinlog_row.result	2009-11-15 19:23:09 +0000
@@ -339,7 +339,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/r/mysqlbinlog_row_innodb.result'
--- a/mysql-test/r/mysqlbinlog_row_innodb.result	2009-06-05 13:21:53 +0000
+++ b/mysql-test/r/mysqlbinlog_row_innodb.result	2009-11-15 19:23:09 +0000
@@ -2256,7 +2256,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;
@@ -3879,7 +3879,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;
@@ -4246,7 +4246,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;
@@ -4807,7 +4807,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;

=== modified file 'mysql-test/r/mysqlbinlog_row_myisam.result'
--- a/mysql-test/r/mysqlbinlog_row_myisam.result	2009-06-05 13:21:53 +0000
+++ b/mysql-test/r/mysqlbinlog_row_myisam.result	2009-11-15 19:23:09 +0000
@@ -2256,7 +2256,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;
@@ -3901,7 +3901,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;
@@ -4274,7 +4274,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;
@@ -4845,7 +4845,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C utf8 *//*!*/;

=== modified file 'mysql-test/r/mysqlbinlog_row_trans.result'
--- a/mysql-test/r/mysqlbinlog_row_trans.result	2009-08-27 09:32:27 +0000
+++ b/mysql-test/r/mysqlbinlog_row_trans.result	2009-11-15 19:19:53 +0000
@@ -135,7 +135,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=#/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/r/odbc.result'
--- a/mysql-test/r/odbc.result	2006-07-10 13:44:05 +0000
+++ b/mysql-test/r/odbc.result	2009-11-03 13:54:41 +0000
@@ -1,4 +1,5 @@
 drop table if exists t1;
+set @@session.sql_auto_is_null=1;
 select {fn length("hello")}, { date "1997-10-20" };
 {fn length("hello")}	1997-10-20
 5	1997-10-20
@@ -7,9 +8,9 @@ insert into t1 SET A=NULL,B=1;
 insert into t1 SET a=null,b=2;
 select * from t1 where a is null and b=2;
 a	b
-2	2
 select * from t1 where a is null;
 a	b
+2	2
 explain select * from t1 where b is null;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
@@ -25,3 +26,4 @@ SELECT sql_no_cache a, last_insert_id() 
 a	last_insert_id()
 1	1
 DROP TABLE t1;
+set @@session.sql_auto_is_null=default;

=== modified file 'mysql-test/r/query_cache.result'
--- a/mysql-test/r/query_cache.result	2009-11-09 10:27:46 +0000
+++ b/mysql-test/r/query_cache.result	2009-11-12 12:22:31 +0000
@@ -292,19 +292,18 @@ create table mysqltest.t1 (i int not nul
 insert into mysqltest.t1 (a) values (1);
 select * from mysqltest.t1 where i is null;
 i	a
-1	1
 create table t1(a int);
 select * from t1;
 a
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
-Qcache_queries_in_cache	1
+Qcache_queries_in_cache	2
 select * from mysqltest.t1;
 i	a
 1	1
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
-Qcache_queries_in_cache	2
+Qcache_queries_in_cache	3
 drop database mysqltest;
 show status like "Qcache_queries_in_cache";
 Variable_name	Value

=== modified file 'mysql-test/r/repair.result'
--- a/mysql-test/r/repair.result	2009-04-14 14:29:45 +0000
+++ b/mysql-test/r/repair.result	2009-11-10 08:27:24 +0000
@@ -157,3 +157,15 @@ REPAIR TABLE tt1 USE_FRM;
 Table	Op	Msg_type	Msg_text
 tt1	repair	error	Cannot repair temporary table from .frm file
 DROP TABLE tt1;
+#
+# Bug #48248 assert in MDL_ticket::upgrade_shared_lock_to_exclusive
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT);
+LOCK TABLES t1 READ;
+REPAIR TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	repair	Error	Table 't1' was locked with a READ lock and can't be updated
+test.t1	repair	status	Operation failed
+UNLOCK TABLES;
+DROP TABLE t1;

=== modified file 'mysql-test/r/select.result'
--- a/mysql-test/r/select.result	2009-11-09 10:27:46 +0000
+++ b/mysql-test/r/select.result	2009-11-18 06:14:20 +0000
@@ -4657,4 +4657,47 @@ Warning	1292	Truncated incorrect DOUBLE 
 Warning	1292	Truncated incorrect DOUBLE value: 'm'
 DROP TABLE CC;
 # End of test#45277
+#
+# BUG#43618: MyISAM&Maria returns wrong results with 'between' 
+#            on timestamp
+#
+CREATE TABLE t1(
+ts TIMESTAMP NOT NULL, 
+c char NULL,
+PRIMARY KEY(ts)
+) ENGINE=myisam;
+INSERT INTO t1 VALUES
+('1971-01-01','a'),
+('2007-05-25','b'),
+('2008-01-01','c'),
+('2038-01-09','d');
+# Enable Index condition pushdown
+select @old_icp:=@@engine_condition_pushdown;
+@old_icp:=@@engine_condition_pushdown
+#
+set session engine_condition_pushdown='on';
+
+# Execute select with invalid timestamp, desc ordering
+SELECT *
+FROM t1 
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' 
+ORDER BY ts DESC
+LIMIT 2;
+ts	c
+2008-01-01 00:00:00	c
+2007-05-25 00:00:00	b
+
+# Should use index condition
+EXPLAIN
+SELECT *
+FROM t1 
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' 
+ORDER BY ts DESC
+LIMIT 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	4	Using index condition
+
+# Restore old value for Index condition pushdown
+set session engine_condition_pushdown=@old_icp;
+DROP TABLE t1;
 End of 6.0 tests

=== modified file 'mysql-test/r/select_jcl6.result'
--- a/mysql-test/r/select_jcl6.result	2009-10-30 15:36:45 +0000
+++ b/mysql-test/r/select_jcl6.result	2009-11-18 06:14:20 +0000
@@ -4661,6 +4661,49 @@ Warning	1292	Truncated incorrect DOUBLE 
 Warning	1292	Truncated incorrect DOUBLE value: 'm'
 DROP TABLE CC;
 # End of test#45277
+#
+# BUG#43618: MyISAM&Maria returns wrong results with 'between' 
+#            on timestamp
+#
+CREATE TABLE t1(
+ts TIMESTAMP NOT NULL, 
+c char NULL,
+PRIMARY KEY(ts)
+) ENGINE=myisam;
+INSERT INTO t1 VALUES
+('1971-01-01','a'),
+('2007-05-25','b'),
+('2008-01-01','c'),
+('2038-01-09','d');
+# Enable Index condition pushdown
+select @old_icp:=@@engine_condition_pushdown;
+@old_icp:=@@engine_condition_pushdown
+#
+set session engine_condition_pushdown='on';
+
+# Execute select with invalid timestamp, desc ordering
+SELECT *
+FROM t1 
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' 
+ORDER BY ts DESC
+LIMIT 2;
+ts	c
+2008-01-01 00:00:00	c
+2007-05-25 00:00:00	b
+
+# Should use index condition
+EXPLAIN
+SELECT *
+FROM t1 
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' 
+ORDER BY ts DESC
+LIMIT 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	4	Using index condition
+
+# Restore old value for Index condition pushdown
+set session engine_condition_pushdown=@old_icp;
+DROP TABLE t1;
 End of 6.0 tests
 set join_cache_level=default;
 show variables like 'join_cache_level';

=== modified file 'mysql-test/r/subselect3.result'
--- a/mysql-test/r/subselect3.result	2009-11-09 10:27:46 +0000
+++ b/mysql-test/r/subselect3.result	2009-11-18 06:14:20 +0000
@@ -1014,7 +1014,7 @@ id	select_type	table	type	possible_keys	
 1	PRIMARY	t11	ALL	NULL	NULL	NULL	NULL	8	Using where; Using temporary; Using filesort; Start materialize; Scan
 1	PRIMARY	t12	ALL	NULL	NULL	NULL	NULL	8	Using where; End materialize; Using join buffer
 1	PRIMARY	t21	ALL	NULL	NULL	NULL	NULL	26	Using where; Using join buffer
-1	PRIMARY	t22	ALL	NULL	NULL	NULL	NULL	32	Using where; Using join buffer
+1	PRIMARY	t22	ALL	NULL	NULL	NULL	NULL	26	Using where; Using join buffer
 select t21.* from t21,t22 where t21.a = t22.a and 
 t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
 a	b	c

=== modified file 'mysql-test/r/subselect3_jcl6.result'
--- a/mysql-test/r/subselect3_jcl6.result	2009-11-03 18:09:53 +0000
+++ b/mysql-test/r/subselect3_jcl6.result	2009-11-18 06:14:20 +0000
@@ -1018,7 +1018,7 @@ id	select_type	table	type	possible_keys	
 1	PRIMARY	t11	ALL	NULL	NULL	NULL	NULL	8	Using where; Using temporary; Using filesort; Start materialize; Scan
 1	PRIMARY	t12	ALL	NULL	NULL	NULL	NULL	8	Using where; End materialize; Using join buffer
 1	PRIMARY	t21	ALL	NULL	NULL	NULL	NULL	26	Using where; Using join buffer
-1	PRIMARY	t22	ALL	NULL	NULL	NULL	NULL	32	Using where; Using join buffer
+1	PRIMARY	t22	ALL	NULL	NULL	NULL	NULL	26	Using where; Using join buffer
 select t21.* from t21,t22 where t21.a = t22.a and 
 t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
 a	b	c

=== modified file 'mysql-test/r/subselect_sj.result'
--- a/mysql-test/r/subselect_sj.result	2009-03-19 17:03:58 +0000
+++ b/mysql-test/r/subselect_sj.result	2009-11-17 10:12:07 +0000
@@ -327,3 +327,139 @@ AND OUTR . varchar_nokey <= 'w' 
 HAVING X > '2012-12-12';
 X
 drop table t1, t2;
+#
+# Bug#45191: Incorrectly initialized semi-join led to a wrong result.
+#
+CREATE TABLE STAFF (EMPNUM   CHAR(3) NOT NULL,
+EMPNAME  CHAR(20), GRADE DECIMAL(4), CITY CHAR(15));
+CREATE TABLE PROJ (PNUM CHAR(3) NOT NULL,
+PNAME    CHAR(20), PTYPE CHAR(6),
+BUDGET   DECIMAL(9),
+CITY     CHAR(15));
+CREATE TABLE WORKS (EMPNUM CHAR(3) NOT NULL,
+PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5));
+INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale');
+INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna');
+INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna');
+INSERT INTO STAFF VALUES ('E4','Don',12,'Deale');
+INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron');
+INSERT INTO PROJ VALUES  ('P1','MXSS','Design',10000,'Deale');
+INSERT INTO PROJ VALUES  ('P2','CALM','Code',30000,'Vienna');
+INSERT INTO PROJ VALUES  ('P3','SDP','Test',30000,'Tampa');
+INSERT INTO PROJ VALUES  ('P4','SDP','Design',20000,'Deale');
+INSERT INTO PROJ VALUES  ('P5','IRM','Test',10000,'Vienna');
+INSERT INTO PROJ VALUES  ('P6','PAYR','Design',50000,'Deale');
+INSERT INTO WORKS VALUES  ('E1','P1',40);
+INSERT INTO WORKS VALUES  ('E1','P2',20);
+INSERT INTO WORKS VALUES  ('E1','P3',80);
+INSERT INTO WORKS VALUES  ('E1','P4',20);
+INSERT INTO WORKS VALUES  ('E1','P5',12);
+INSERT INTO WORKS VALUES  ('E1','P6',12);
+INSERT INTO WORKS VALUES  ('E2','P1',40);
+INSERT INTO WORKS VALUES  ('E2','P2',80);
+INSERT INTO WORKS VALUES  ('E3','P2',20);
+INSERT INTO WORKS VALUES  ('E4','P2',20);
+INSERT INTO WORKS VALUES  ('E4','P4',40);
+INSERT INTO WORKS VALUES  ('E4','P5',80);
+set optimizer_switch='default,materialization=off';
+explain SELECT EMPNUM, EMPNAME
+FROM STAFF
+WHERE EMPNUM IN
+(SELECT EMPNUM  FROM WORKS
+WHERE PNUM IN
+(SELECT PNUM  FROM PROJ));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	STAFF	ALL	NULL	NULL	NULL	NULL	5	
+1	PRIMARY	PROJ	ALL	NULL	NULL	NULL	NULL	6	
+1	PRIMARY	WORKS	ALL	NULL	NULL	NULL	NULL	12	Using where; FirstMatch(STAFF)
+SELECT EMPNUM, EMPNAME
+FROM STAFF
+WHERE EMPNUM IN
+(SELECT EMPNUM  FROM WORKS
+WHERE PNUM IN
+(SELECT PNUM  FROM PROJ));
+EMPNUM	EMPNAME
+E1	Alice
+E2	Betty
+E3	Carmen
+E4	Don
+set optimizer_switch='default';
+drop table STAFF,WORKS,PROJ;
+# End of bug#45191
+#
+# Bug#46550 Azalea returning duplicate results for some IN subqueries
+# w/ semijoin=on
+#
+DROP TABLE IF EXISTS t0, t1, t2;
+CREATE TABLE t0 (
+int_key int(11) DEFAULT NULL,
+varchar_key varchar(1) DEFAULT NULL,
+varchar_nokey varchar(1) DEFAULT NULL,
+KEY int_key (int_key),
+KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t0 VALUES
+(1,'m','m'),
+(40,'h','h'),
+(1,'r','r'),
+(1,'h','h'),
+(9,'x','x'),
+(NULL,'q','q'),
+(NULL,'k','k'),
+(7,'l','l'),
+(182,'k','k'),
+(202,'a','a'),
+(7,'x','x'),
+(6,'j','j'),
+(119,'z','z'),
+(4,'d','d'),
+(5,'h','h'),
+(1,'u','u'),
+(3,'q','q'),
+(7,'a','a'),
+(3,'e','e'),
+(6,'l','l');
+CREATE TABLE t1 (
+int_key int(11) DEFAULT NULL,
+varchar_key varchar(1) DEFAULT NULL,
+varchar_nokey varchar(1) DEFAULT NULL,
+KEY int_key (int_key),
+KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x');
+CREATE TABLE t2 (
+int_key int(11) DEFAULT NULL,
+varchar_key varchar(1) DEFAULT NULL,
+varchar_nokey varchar(1) DEFAULT NULL,
+KEY int_key (int_key),
+KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t2 VALUES (123,NULL,NULL);
+SELECT int_key  
+FROM t0  
+WHERE varchar_nokey  IN (  
+SELECT t1 .varchar_key  from t1
+);
+int_key
+9
+7
+SELECT t0.int_key  
+FROM t0
+WHERE t0.varchar_nokey  IN (  
+SELECT t1_1 .varchar_key  
+FROM t1 AS t1_1  JOIN t1 AS t1_2 ON t1_1 .int_key
+);
+int_key
+9
+7
+SELECT t0.int_key  
+FROM t0, t2
+WHERE t0.varchar_nokey  IN (  
+SELECT t1_1 .varchar_key  
+FROM t1 AS t1_1  JOIN t1 AS t1_2 ON t1_1 .int_key  
+);
+int_key
+9
+7
+DROP TABLE t0, t1, t2;
+# End of bug#46550

=== modified file 'mysql-test/r/subselect_sj2.result'
--- a/mysql-test/r/subselect_sj2.result	2009-03-21 15:31:38 +0000
+++ b/mysql-test/r/subselect_sj2.result	2009-11-12 14:31:12 +0000
@@ -689,3 +689,19 @@ explain select 1 from t2 where c2 = any 
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 drop table t1, t2;
+# 
+# BUG#42742: crash in setup_sj_materialization, Copy_field::set
+# 
+create table t3 ( c1 year) engine=innodb;
+insert into t3 values (2135),(2142);
+create table t2 (c1 tinytext,c2 text,c6 timestamp) engine=innodb;
+# The following must not crash, EXPLAIN should show one SJ strategy, not a mix:
+explain select 1 from t2 where 
+c2 in (select 1 from t3, t2) and
+c1 in (select convert(c6,char(1)) from t2);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	FirstMatch(t2)
+drop table t2, t3;

=== modified file 'mysql-test/r/subselect_sj2_jcl6.result'
--- a/mysql-test/r/subselect_sj2_jcl6.result	2009-06-19 09:12:06 +0000
+++ b/mysql-test/r/subselect_sj2_jcl6.result	2009-11-12 14:31:12 +0000
@@ -693,6 +693,22 @@ explain select 1 from t2 where c2 = any 
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
 drop table t1, t2;
+# 
+# BUG#42742: crash in setup_sj_materialization, Copy_field::set
+# 
+create table t3 ( c1 year) engine=innodb;
+insert into t3 values (2135),(2142);
+create table t2 (c1 tinytext,c2 text,c6 timestamp) engine=innodb;
+# The following must not crash, EXPLAIN should show one SJ strategy, not a mix:
+explain select 1 from t2 where 
+c2 in (select 1 from t3, t2) and
+c1 in (select convert(c6,char(1)) from t2);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	
+1	PRIMARY	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	PRIMARY	t3	ALL	NULL	NULL	NULL	NULL	2	FirstMatch(t2)
+drop table t2, t3;
 set join_cache_level=default;
 show variables like 'join_cache_level';
 Variable_name	Value

=== modified file 'mysql-test/r/subselect_sj_jcl6.result'
--- a/mysql-test/r/subselect_sj_jcl6.result	2009-03-19 17:03:58 +0000
+++ b/mysql-test/r/subselect_sj_jcl6.result	2009-11-17 10:12:07 +0000
@@ -331,6 +331,142 @@ AND OUTR . varchar_nokey <= 'w' 
 HAVING X > '2012-12-12';
 X
 drop table t1, t2;
+#
+# Bug#45191: Incorrectly initialized semi-join led to a wrong result.
+#
+CREATE TABLE STAFF (EMPNUM   CHAR(3) NOT NULL,
+EMPNAME  CHAR(20), GRADE DECIMAL(4), CITY CHAR(15));
+CREATE TABLE PROJ (PNUM CHAR(3) NOT NULL,
+PNAME    CHAR(20), PTYPE CHAR(6),
+BUDGET   DECIMAL(9),
+CITY     CHAR(15));
+CREATE TABLE WORKS (EMPNUM CHAR(3) NOT NULL,
+PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5));
+INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale');
+INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna');
+INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna');
+INSERT INTO STAFF VALUES ('E4','Don',12,'Deale');
+INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron');
+INSERT INTO PROJ VALUES  ('P1','MXSS','Design',10000,'Deale');
+INSERT INTO PROJ VALUES  ('P2','CALM','Code',30000,'Vienna');
+INSERT INTO PROJ VALUES  ('P3','SDP','Test',30000,'Tampa');
+INSERT INTO PROJ VALUES  ('P4','SDP','Design',20000,'Deale');
+INSERT INTO PROJ VALUES  ('P5','IRM','Test',10000,'Vienna');
+INSERT INTO PROJ VALUES  ('P6','PAYR','Design',50000,'Deale');
+INSERT INTO WORKS VALUES  ('E1','P1',40);
+INSERT INTO WORKS VALUES  ('E1','P2',20);
+INSERT INTO WORKS VALUES  ('E1','P3',80);
+INSERT INTO WORKS VALUES  ('E1','P4',20);
+INSERT INTO WORKS VALUES  ('E1','P5',12);
+INSERT INTO WORKS VALUES  ('E1','P6',12);
+INSERT INTO WORKS VALUES  ('E2','P1',40);
+INSERT INTO WORKS VALUES  ('E2','P2',80);
+INSERT INTO WORKS VALUES  ('E3','P2',20);
+INSERT INTO WORKS VALUES  ('E4','P2',20);
+INSERT INTO WORKS VALUES  ('E4','P4',40);
+INSERT INTO WORKS VALUES  ('E4','P5',80);
+set optimizer_switch='default,materialization=off';
+explain SELECT EMPNUM, EMPNAME
+FROM STAFF
+WHERE EMPNUM IN
+(SELECT EMPNUM  FROM WORKS
+WHERE PNUM IN
+(SELECT PNUM  FROM PROJ));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	STAFF	ALL	NULL	NULL	NULL	NULL	5	
+1	PRIMARY	PROJ	ALL	NULL	NULL	NULL	NULL	6	
+1	PRIMARY	WORKS	ALL	NULL	NULL	NULL	NULL	12	Using where; FirstMatch(STAFF)
+SELECT EMPNUM, EMPNAME
+FROM STAFF
+WHERE EMPNUM IN
+(SELECT EMPNUM  FROM WORKS
+WHERE PNUM IN
+(SELECT PNUM  FROM PROJ));
+EMPNUM	EMPNAME
+E1	Alice
+E2	Betty
+E3	Carmen
+E4	Don
+set optimizer_switch='default';
+drop table STAFF,WORKS,PROJ;
+# End of bug#45191
+#
+# Bug#46550 Azalea returning duplicate results for some IN subqueries
+# w/ semijoin=on
+#
+DROP TABLE IF EXISTS t0, t1, t2;
+CREATE TABLE t0 (
+int_key int(11) DEFAULT NULL,
+varchar_key varchar(1) DEFAULT NULL,
+varchar_nokey varchar(1) DEFAULT NULL,
+KEY int_key (int_key),
+KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t0 VALUES
+(1,'m','m'),
+(40,'h','h'),
+(1,'r','r'),
+(1,'h','h'),
+(9,'x','x'),
+(NULL,'q','q'),
+(NULL,'k','k'),
+(7,'l','l'),
+(182,'k','k'),
+(202,'a','a'),
+(7,'x','x'),
+(6,'j','j'),
+(119,'z','z'),
+(4,'d','d'),
+(5,'h','h'),
+(1,'u','u'),
+(3,'q','q'),
+(7,'a','a'),
+(3,'e','e'),
+(6,'l','l');
+CREATE TABLE t1 (
+int_key int(11) DEFAULT NULL,
+varchar_key varchar(1) DEFAULT NULL,
+varchar_nokey varchar(1) DEFAULT NULL,
+KEY int_key (int_key),
+KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x');
+CREATE TABLE t2 (
+int_key int(11) DEFAULT NULL,
+varchar_key varchar(1) DEFAULT NULL,
+varchar_nokey varchar(1) DEFAULT NULL,
+KEY int_key (int_key),
+KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t2 VALUES (123,NULL,NULL);
+SELECT int_key  
+FROM t0  
+WHERE varchar_nokey  IN (  
+SELECT t1 .varchar_key  from t1
+);
+int_key
+9
+7
+SELECT t0.int_key  
+FROM t0
+WHERE t0.varchar_nokey  IN (  
+SELECT t1_1 .varchar_key  
+FROM t1 AS t1_1  JOIN t1 AS t1_2 ON t1_1 .int_key
+);
+int_key
+9
+7
+SELECT t0.int_key  
+FROM t0, t2
+WHERE t0.varchar_nokey  IN (  
+SELECT t1_1 .varchar_key  
+FROM t1 AS t1_1  JOIN t1 AS t1_2 ON t1_1 .int_key  
+);
+int_key
+9
+7
+DROP TABLE t0, t1, t2;
+# End of bug#46550
 set join_cache_level=default;
 show variables like 'join_cache_level';
 Variable_name	Value

=== modified file 'mysql-test/r/user_var-binlog.result'
--- a/mysql-test/r/user_var-binlog.result	2008-04-02 09:49:22 +0000
+++ b/mysql-test/r/user_var-binlog.result	2009-11-03 13:54:41 +0000
@@ -22,7 +22,7 @@ SET @`a b`:=_latin1 0x68656C6C6F COLLATE
 use test/*!*/;
 SET TIMESTAMP=10000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2009-10-19 19:27:33 +0000
+++ b/mysql-test/r/view.result	2009-11-10 08:27:24 +0000
@@ -1955,15 +1955,15 @@ CHECK TABLE v1, v2, v3, v4, v5, v6;
 Table	Op	Msg_type	Msg_text
 test.v1	check	Error	FUNCTION test.f1 does not exist
 test.v1	check	Error	View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-test.v1	check	error	Corrupt
+test.v1	check	status	Operation failed
 test.v2	check	status	OK
 test.v3	check	Error	FUNCTION test.f1 does not exist
 test.v3	check	Error	View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-test.v3	check	error	Corrupt
+test.v3	check	status	Operation failed
 test.v4	check	status	OK
 test.v5	check	Error	FUNCTION test.f1 does not exist
 test.v5	check	Error	View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-test.v5	check	error	Corrupt
+test.v5	check	status	Operation failed
 test.v6	check	status	OK
 create function f1 () returns int return (select max(col1) from t1);
 DROP TABLE t1;

=== modified file 'mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result'
--- a/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result	2009-05-31 05:44:41 +0000
+++ b/mysql-test/suite/binlog/r/binlog_row_ctype_ucs.result	2009-11-03 13:54:41 +0000
@@ -16,7 +16,7 @@ DELIMITER /*!*/;
 ROLLBACK/*!*/;
 SET TIMESTAMP=10000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result'
--- a/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result	2008-10-29 09:52:46 +0000
+++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_ucs.result	2009-11-04 08:53:57 +0000
@@ -16,7 +16,7 @@ SET @`v`:=_ucs2 0x006100620063 COLLATE `
 use test/*!*/;
 SET TIMESTAMP=10000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== added file 'mysql-test/suite/optimizer_unfixed_bugs/r/bug43448.result'
--- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug43448.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug43448.result	2009-11-13 14:41:07 +0000
@@ -0,0 +1,29 @@
+#
+# Bug#43448 - Server crashes on multi table delete with Innodb
+#
+CREATE TABLE t1 (
+id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+t CHAR(12)
+) ENGINE=InnoDB;
+CREATE TABLE t2 (
+id2 INT NOT NULL, 
+t CHAR(12)
+) ENGINE=InnoDB;
+CREATE TABLE t3(
+id3 INT NOT NULL, 
+t CHAR(12), 
+INDEX(id3)
+) ENGINE=InnoDB;
+SELECT COUNT(*) FROM t1 WHERE id1 > 90;
+COUNT(*)
+10
+SELECT COUNT(*) FROM t2 WHERE id2 > 90;
+COUNT(*)
+50
+SELECT COUNT(*) FROM t3 WHERE id3 > 90;
+COUNT(*)
+500
+DELETE t1, t2, t3 
+FROM t1, t2, t3 
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 5;
+DROP TABLE t1, t2, t3;

=== added file 'mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test'
--- a/mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test	2009-11-13 14:41:07 +0000
@@ -0,0 +1,58 @@
+--echo #
+--echo # Bug#43448 - Server crashes on multi table delete with Innodb
+--echo #
+
+--source include/have_debug.inc
+--source include/have_innodb.inc
+
+# crash requires ICP support in InnoDB
+set session debug="+d,optimizer_innodb_icp";
+
+CREATE TABLE t1 (
+  id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+  t CHAR(12)
+) ENGINE=InnoDB;
+
+CREATE TABLE t2 (
+  id2 INT NOT NULL, 
+  t CHAR(12)
+) ENGINE=InnoDB;
+
+CREATE TABLE t3(
+  id3 INT NOT NULL, 
+  t CHAR(12), 
+  INDEX(id3)
+) ENGINE=InnoDB;
+
+disable_query_log;
+
+let $1 = 100;
+while ($1)
+{
+  let $2 = 5;
+  eval INSERT INTO t1(t) VALUES ('$1');
+  while ($2)
+  {
+    eval INSERT INTO t2(id2,t) VALUES ($1,'$2');
+    let $3 = 10;
+    while ($3)
+    {
+      eval INSERT INTO t3(id3,t) VALUES ($1,'$2');
+      dec $3;
+    }
+    dec $2;
+  }
+  dec $1;
+}
+
+enable_query_log;
+
+SELECT COUNT(*) FROM t1 WHERE id1 > 90;
+SELECT COUNT(*) FROM t2 WHERE id2 > 90;
+SELECT COUNT(*) FROM t3 WHERE id3 > 90;
+
+DELETE t1, t2, t3 
+FROM t1, t2, t3 
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 5;
+
+DROP TABLE t1, t2, t3;

=== modified file 'mysql-test/suite/rpl/r/rpl_insert_id.result'
--- a/mysql-test/suite/rpl/r/rpl_insert_id.result	2008-10-08 11:23:53 +0000
+++ b/mysql-test/suite/rpl/r/rpl_insert_id.result	2009-11-03 13:54:41 +0000
@@ -97,6 +97,7 @@ drop table t1;
 #
 # Bug#14553: NULL in WHERE resets LAST_INSERT_ID
 #
+set @@session.sql_auto_is_null=1;
 create table t1(a int auto_increment, key(a)) engine=myisam;
 create table t2(a int) engine=myisam;
 insert into t1 (a) values (null);
@@ -531,3 +532,4 @@ id	last_id
 drop table t1, t2;
 drop procedure foo;
 SET @@global.concurrent_insert= @old_concurrent_insert;
+set @@session.sql_auto_is_null=default;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result'
--- a/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result	2008-04-02 09:49:22 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_mysqlbinlog.result	2009-11-03 13:54:41 +0000
@@ -159,7 +159,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -181,7 +181,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -290,7 +290,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;
@@ -321,7 +321,7 @@ ROLLBACK/*!*/;
 use test/*!*/;
 SET TIMESTAMP=1000000000/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/suite/rpl/r/rpl_sp.result'
--- a/mysql-test/suite/rpl/r/rpl_sp.result	2009-10-26 14:02:26 +0000
+++ b/mysql-test/suite/rpl/r/rpl_sp.result	2009-11-04 08:53:57 +0000
@@ -610,7 +610,7 @@ DELIMITER /*!*/;
 ROLLBACK/*!*/;
 SET TIMESTAMP=t/*!*/;
 SET @@session.pseudo_thread_id=999999999/*!*/;
-SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
+SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 SET @@session.sql_mode=0/*!*/;
 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 /*!\C latin1 *//*!*/;

=== modified file 'mysql-test/t/analyse.test'
--- a/mysql-test/t/analyse.test	2009-10-30 09:56:32 +0000
+++ b/mysql-test/t/analyse.test	2009-11-18 08:15:50 +0000
@@ -133,3 +133,32 @@ DROP TABLE t1;
 
 
 --echo End of 5.0 tests
+
+--echo #
+--echo # Bug #47338 assertion in handler::ha_external_lock
+--echo #
+
+call mtr.add_suppression("Incorrect key file for table .*");
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TEMPORARY TABLE t1 (f2 INT, f1 INT, PRIMARY KEY (f1)) ENGINE = MyISAM;
+
+INSERT t1 ( f1 ) VALUES ( 5 );
+INSERT t1 ( f1 ) VALUES ( 6 );
+
+ALTER TABLE t1 ENGINE = MyISAM;
+ANALYZE TABLE t1;
+
+# TODO(didrik) fix bug in ANALYZE TABLE, so we can remove replace_regex
+# as well as error 126 below.
+# key_cache_read() reports HA_ERR_FILE_TOO_SHORT
+# _mi_fetch_keypage discards that my_errno, and reports HA_ERR_CRASHED instead.
+
+--replace_regex /'.*'/'path hidden'/
+--error 126
+SELECT f1,f2 FROM t1 A WHERE f1 BETWEEN 0 AND 1; 
+
+drop table t1;

=== modified file 'mysql-test/t/ctype_utf8.test'
--- a/mysql-test/t/ctype_utf8.test	2009-11-02 15:11:43 +0000
+++ b/mysql-test/t/ctype_utf8.test	2009-11-12 12:22:31 +0000
@@ -1448,6 +1448,21 @@ DROP TABLE t1;
 
 --echo End of 5.0 tests
 
+
+--echo Start of 5.4 tests
+#
+# Bug#26180: Can't add columns to tables created with utf8 text indexes
+#
+CREATE TABLE t1 (
+  clipid INT NOT NULL,
+  Tape TINYTEXT,
+  PRIMARY KEY (clipid),
+  KEY tape(Tape(255))
+) CHARACTER SET=utf8;
+ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
 #
 # Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
 #
@@ -1462,8 +1477,12 @@ INSERT INTO t1 VALUES (19, x'E0B696'), (
 SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci;
 DROP TABLE t1;
 
---echo End of 5.1 tests
+--echo End of 5.4 tests
 
+--echo #
+--echo # Start of 6.0 tests
+--echo #
+ 
 set names utf8;
 --source include/weight_string.inc
 --source include/weight_string_euro.inc
@@ -1487,31 +1506,6 @@ select * from t1 order by a;
 drop table t1;
 set max_sort_length=default;
 
-#
-# Bug#26180: Can't add columns to tables created with utf8 text indexes
-#
-CREATE TABLE t1 (
-  clipid INT NOT NULL,
-  Tape TINYTEXT,
-  PRIMARY KEY (clipid),
-  KEY tape(Tape(255))
-) CHARACTER SET=utf8;
-ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid;
-SHOW CREATE TABLE t1;
-DROP TABLE t1;
-
-#
-# Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL
-#
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
-CREATE TABLE t1 (
-        predicted_order int NOT NULL,
-        utf8_encoding VARCHAR(10) NOT NULL
-) CHARACTER SET utf8;
-INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17,
  x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682');
-SELECT predicted_order, hex(utf8_encoding) FROM t1 ORDER BY utf8_encoding COLLATE utf8_sinhala_ci;
-DROP TABLE t1;
-
---echo End of tests
+--echo #
+--echo # End of 6.0 tests
+--echo #

=== modified file 'mysql-test/t/func_isnull.test'
--- a/mysql-test/t/func_isnull.test	2005-07-28 00:22:47 +0000
+++ b/mysql-test/t/func_isnull.test	2009-11-03 13:54:41 +0000
@@ -13,3 +13,15 @@ select * from t1 where isnull(to_days(my
 drop table t1;
 
 # End of 4.1 tests
+
+#
+# Bug #41371    Select returns 1 row with condition "col is not null and col is null"
+#
+
+CREATE TABLE t1 (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id));
+INSERT INTO t1( id ) VALUES ( NULL );
+SELECT t1.id  FROM t1  WHERE (id  is not null and id is null );
+DROP TABLE t1;
+
+# End of 5.1 tests
+

=== modified file 'mysql-test/t/innodb_mysql.test'
--- a/mysql-test/t/innodb_mysql.test	2009-11-09 10:27:46 +0000
+++ b/mysql-test/t/innodb_mysql.test	2009-11-12 12:13:55 +0000
@@ -532,4 +532,36 @@ set join_cache_level=default;
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # BUG#48093: 6.0 Server not processing equivalent IN clauses properly 
+--echo #            with Innodb tables
+--echo #
+
+CREATE TABLE t1 (
+  i int(11) DEFAULT NULL,
+  v1 varchar(1) DEFAULT NULL,
+  v2 varchar(20) DEFAULT NULL,
+  KEY i (i),
+  KEY v (v1,i)
+) ENGINE=innodb;
+
+INSERT INTO t1 VALUES (1,'f','no');
+INSERT INTO t1 VALUES (2,'u','yes-u');
+INSERT INTO t1 VALUES (2,'h','yes-h');
+INSERT INTO t1 VALUES (3,'d','no');
+
+--echo
+SELECT v2  
+FROM t1
+WHERE v1  IN  ('f', 'd', 'h', 'u' ) AND i  =  2;
+
+--echo
+--echo # Should not use index_merge
+EXPLAIN
+SELECT v2  
+FROM t1
+WHERE v1  IN  ('f', 'd', 'h', 'u' ) AND i  =  2;
+
+DROP TABLE t1;
+
 --echo End of 6.0 tests

=== modified file 'mysql-test/t/merge.test'
--- a/mysql-test/t/merge.test	2009-11-02 15:11:43 +0000
+++ b/mysql-test/t/merge.test	2009-11-18 15:06:15 +0000
@@ -284,7 +284,11 @@ ALTER TABLE t4 UNION=(t1,t2);
 UNLOCK TABLES;
 --echo # MERGE table and function.
 CREATE FUNCTION f1 () RETURNS INT RETURN (SELECT max(c1) FROM t3);
-SELECT * FROM t4 WHERE c1 < f1();
+
+-- echo Disable this, because of:
+-- echo Bug #47648 main.merge fails sporadically
+## SELECT * FROM t4 WHERE c1 < f1();
+
 DROP FUNCTION f1;
 DROP TABLE t4, t3, t2, t1;
 

=== modified file 'mysql-test/t/odbc.test'
--- a/mysql-test/t/odbc.test	2006-07-10 13:27:03 +0000
+++ b/mysql-test/t/odbc.test	2009-11-03 13:54:41 +0000
@@ -3,6 +3,8 @@
 drop table if exists t1;
 --enable_warnings
 
+set @@session.sql_auto_is_null=1;
+
 #
 # Test some ODBC compatibility
 #
@@ -32,3 +34,5 @@ SELECT sql_no_cache a, last_insert_id() 
 DROP TABLE t1;
 
 # End of 4.1 tests
+
+set @@session.sql_auto_is_null=default;

=== modified file 'mysql-test/t/repair.test'
--- a/mysql-test/t/repair.test	2008-08-04 14:30:50 +0000
+++ b/mysql-test/t/repair.test	2009-11-10 08:27:24 +0000
@@ -158,3 +158,18 @@ CREATE TEMPORARY TABLE tt1 (c1 INT);
 REPAIR TABLE tt1 USE_FRM;
 DROP TABLE tt1;
 
+
+--echo #
+--echo # Bug #48248 assert in MDL_ticket::upgrade_shared_lock_to_exclusive
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT);
+LOCK TABLES t1 READ;
+REPAIR TABLE t1;
+
+UNLOCK TABLES;
+DROP TABLE t1;

=== modified file 'mysql-test/t/select.test'
--- a/mysql-test/t/select.test	2009-10-30 14:51:16 +0000
+++ b/mysql-test/t/select.test	2009-11-18 06:14:20 +0000
@@ -3997,4 +3997,53 @@ SELECT `varchar_nokey` G1  FROM CC  WHER
 DROP TABLE CC;
 --echo # End of test#45277
 
+--echo #
+--echo # BUG#43618: MyISAM&Maria returns wrong results with 'between' 
+--echo #            on timestamp
+--echo #
+
+CREATE TABLE t1(
+   ts TIMESTAMP NOT NULL, 
+   c char NULL,
+   PRIMARY KEY(ts)
+) ENGINE=myisam;
+
+INSERT INTO t1 VALUES
+   ('1971-01-01','a'),
+   ('2007-05-25','b'),
+   ('2008-01-01','c'),
+   ('2038-01-09','d');
+
+--echo # Enable Index condition pushdown
+--replace_column 1 #
+select @old_icp:=@@engine_condition_pushdown;
+set session engine_condition_pushdown='on';
+
+--disable_warnings
+
+--echo
+--echo # Execute select with invalid timestamp, desc ordering
+SELECT *
+FROM t1 
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' 
+ORDER BY ts DESC
+LIMIT 2; 
+
+--echo
+--echo # Should use index condition
+EXPLAIN
+SELECT *
+FROM t1 
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00' 
+ORDER BY ts DESC
+LIMIT 2; 
+--echo
+
+--enable_warnings
+
+--echo # Restore old value for Index condition pushdown
+set session engine_condition_pushdown=@old_icp;
+
+DROP TABLE t1;
+
 --echo End of 6.0 tests

=== modified file 'mysql-test/t/subselect_sj.test'
--- a/mysql-test/t/subselect_sj.test	2009-03-19 17:03:58 +0000
+++ b/mysql-test/t/subselect_sj.test	2009-11-17 10:12:07 +0000
@@ -216,4 +216,144 @@ WHERE 
 HAVING X > '2012-12-12';
 drop table t1, t2;
 
+--echo #
+--echo # Bug#45191: Incorrectly initialized semi-join led to a wrong result.
+--echo #
+CREATE TABLE STAFF (EMPNUM   CHAR(3) NOT NULL,
+    EMPNAME  CHAR(20), GRADE DECIMAL(4), CITY CHAR(15));
 
+CREATE TABLE PROJ (PNUM CHAR(3) NOT NULL,
+    PNAME    CHAR(20), PTYPE CHAR(6),
+    BUDGET   DECIMAL(9),
+    CITY     CHAR(15));
+
+CREATE TABLE WORKS (EMPNUM CHAR(3) NOT NULL,
+    PNUM CHAR(3) NOT NULL, HOURS DECIMAL(5));
+INSERT INTO STAFF VALUES ('E1','Alice',12,'Deale');
+INSERT INTO STAFF VALUES ('E2','Betty',10,'Vienna');
+INSERT INTO STAFF VALUES ('E3','Carmen',13,'Vienna');
+INSERT INTO STAFF VALUES ('E4','Don',12,'Deale');
+INSERT INTO STAFF VALUES ('E5','Ed',13,'Akron');
+
+INSERT INTO PROJ VALUES  ('P1','MXSS','Design',10000,'Deale');
+INSERT INTO PROJ VALUES  ('P2','CALM','Code',30000,'Vienna');
+INSERT INTO PROJ VALUES  ('P3','SDP','Test',30000,'Tampa');
+INSERT INTO PROJ VALUES  ('P4','SDP','Design',20000,'Deale');
+INSERT INTO PROJ VALUES  ('P5','IRM','Test',10000,'Vienna');
+INSERT INTO PROJ VALUES  ('P6','PAYR','Design',50000,'Deale');
+
+INSERT INTO WORKS VALUES  ('E1','P1',40);
+INSERT INTO WORKS VALUES  ('E1','P2',20);
+INSERT INTO WORKS VALUES  ('E1','P3',80);
+INSERT INTO WORKS VALUES  ('E1','P4',20);
+INSERT INTO WORKS VALUES  ('E1','P5',12);
+INSERT INTO WORKS VALUES  ('E1','P6',12);
+INSERT INTO WORKS VALUES  ('E2','P1',40);
+INSERT INTO WORKS VALUES  ('E2','P2',80);
+INSERT INTO WORKS VALUES  ('E3','P2',20);
+INSERT INTO WORKS VALUES  ('E4','P2',20);
+INSERT INTO WORKS VALUES  ('E4','P4',40);
+INSERT INTO WORKS VALUES  ('E4','P5',80);
+
+set optimizer_switch='default,materialization=off';
+
+explain SELECT EMPNUM, EMPNAME
+FROM STAFF
+WHERE EMPNUM IN
+  (SELECT EMPNUM  FROM WORKS
+   WHERE PNUM IN
+     (SELECT PNUM  FROM PROJ));
+
+SELECT EMPNUM, EMPNAME
+FROM STAFF
+WHERE EMPNUM IN
+  (SELECT EMPNUM  FROM WORKS
+   WHERE PNUM IN
+     (SELECT PNUM  FROM PROJ));
+
+set optimizer_switch='default';
+
+drop table STAFF,WORKS,PROJ;
+
+--echo # End of bug#45191
+
+--echo #
+--echo # Bug#46550 Azalea returning duplicate results for some IN subqueries
+--echo # w/ semijoin=on
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t0, t1, t2;
+--enable_warnings
+
+CREATE TABLE t0 (
+  int_key int(11) DEFAULT NULL,
+  varchar_key varchar(1) DEFAULT NULL,
+  varchar_nokey varchar(1) DEFAULT NULL,
+  KEY int_key (int_key),
+  KEY varchar_key (varchar_key,int_key)
+);
+
+INSERT INTO t0 VALUES
+(1,'m','m'),
+(40,'h','h'),
+(1,'r','r'),
+(1,'h','h'),
+(9,'x','x'),
+(NULL,'q','q'),
+(NULL,'k','k'),
+(7,'l','l'),
+(182,'k','k'),
+(202,'a','a'),
+(7,'x','x'),
+(6,'j','j'),
+(119,'z','z'),
+(4,'d','d'),
+(5,'h','h'),
+(1,'u','u'),
+(3,'q','q'),
+(7,'a','a'),
+(3,'e','e'),
+(6,'l','l');
+
+CREATE TABLE t1 (
+  int_key int(11) DEFAULT NULL,
+  varchar_key varchar(1) DEFAULT NULL,
+  varchar_nokey varchar(1) DEFAULT NULL,
+  KEY int_key (int_key),
+  KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t1 VALUES (7,NULL,NULL),(4,'x','x');
+
+CREATE TABLE t2 (
+  int_key int(11) DEFAULT NULL,
+  varchar_key varchar(1) DEFAULT NULL,
+  varchar_nokey varchar(1) DEFAULT NULL,
+  KEY int_key (int_key),
+  KEY varchar_key (varchar_key,int_key)
+);
+INSERT INTO t2 VALUES (123,NULL,NULL);
+
+SELECT int_key  
+FROM t0  
+WHERE varchar_nokey  IN (  
+  SELECT t1 .varchar_key  from t1
+);
+
+SELECT t0.int_key  
+FROM t0
+WHERE t0.varchar_nokey  IN (  
+  SELECT t1_1 .varchar_key  
+  FROM t1 AS t1_1  JOIN t1 AS t1_2 ON t1_1 .int_key
+);
+
+SELECT t0.int_key  
+FROM t0, t2
+WHERE t0.varchar_nokey  IN (  
+  SELECT t1_1 .varchar_key  
+  FROM t1 AS t1_1  JOIN t1 AS t1_2 ON t1_1 .int_key  
+);
+
+DROP TABLE t0, t1, t2;
+
+--echo # End of bug#46550

=== modified file 'mysql-test/t/subselect_sj2.test'
--- a/mysql-test/t/subselect_sj2.test	2009-03-21 15:31:38 +0000
+++ b/mysql-test/t/subselect_sj2.test	2009-10-22 10:45:44 +0000
@@ -872,3 +872,15 @@ create table t2 (c2 double) engine=innod
 explain select 1 from t2 where c2 = any (select log10(null) from t1 where c6 <null)  ;
 drop table t1, t2;
 
+--echo # 
+--echo # BUG#42742: crash in setup_sj_materialization, Copy_field::set
+--echo # 
+create table t3 ( c1 year) engine=innodb;
+insert into t3 values (2135),(2142);
+create table t2 (c1 tinytext,c2 text,c6 timestamp) engine=innodb;
+-- echo # The following must not crash, EXPLAIN should show one SJ strategy, not a mix:
+explain select 1 from t2 where 
+  c2 in (select 1 from t3, t2) and
+  c1 in (select convert(c6,char(1)) from t2);
+drop table t2, t3;
+

=== modified file 'mysys/default.c'
--- a/mysys/default.c	2009-10-26 14:02:26 +0000
+++ b/mysys/default.c	2009-11-17 11:46:17 +0000
@@ -503,9 +503,13 @@ int my_load_defaults(const char *conf_fi
   ctx.args= &args;
   ctx.group= &group;
 
-  error= my_search_option_files(conf_file, argc, argv, &args_used,
-                                handle_default_option, (void *) &ctx,
-                                dirs);
+  if ((error= my_search_option_files(conf_file, argc, argv, &args_used,
+                                     handle_default_option, (void *) &ctx,
+                                     dirs)))
+  {
+    free_root(&alloc,MYF(0));
+    DBUG_RETURN(error);
+  }
   /*
     Here error contains <> 0 only if we have a fully specified conf_file
     or a forced default file
@@ -557,10 +561,10 @@ int my_load_defaults(const char *conf_fi
     exit(0);
   }
 
-  if (error == 0 && default_directories)
+  if (default_directories)
     *default_directories= dirs;
 
-  DBUG_RETURN(error);
+  DBUG_RETURN(0);
 
  err:
   fprintf(stderr,"Fatal error in defaults handling. Program aborted\n");

=== modified file 'mysys/my_open.c'
--- a/mysys/my_open.c	2009-09-27 21:00:41 +0000
+++ b/mysys/my_open.c	2009-11-18 08:15:50 +0000
@@ -49,8 +49,8 @@ File my_open(const char *FileName, int F
   fd = open((char *) FileName, Flags);
 #endif
 
-  DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_OPEN,
-				   EE_FILENOTFOUND, MyFlags));
+  fd= my_register_filename(fd, FileName, FILE_BY_OPEN, EE_FILENOTFOUND, MyFlags);
+  DBUG_RETURN(fd);
 } /* my_open */
 
 

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2009-11-09 10:27:46 +0000
+++ b/sql/handler.cc	2009-11-18 08:15:50 +0000
@@ -4470,8 +4470,10 @@ int DsMrr_impl::dsmrr_init(handler *h_ar
   if (mode & HA_MRR_USE_DEFAULT_IMPL || mode & HA_MRR_SORTED)
   {
     use_default_impl= TRUE;
-    DBUG_RETURN(h->handler::multi_range_read_init(seq_funcs, seq_init_param,
-                                                  n_ranges, mode, buf));
+    const int retval=
+      h->handler::multi_range_read_init(seq_funcs, seq_init_param,
+                                        n_ranges, mode, buf);
+    DBUG_RETURN(retval);
   }
   rowids_buf= buf->buffer;
 
@@ -4590,6 +4592,7 @@ error:
   h2->ha_external_lock(current_thd, F_UNLCK);
   h2->close();
   delete h2;
+  h2= NULL;
   DBUG_RETURN(1);
 }
 
@@ -5569,7 +5572,8 @@ int handler::ha_reset()
   free_io_cache(table);
   /* reset the bitmaps to point to defaults */
   table->default_column_bitmaps();
-  DBUG_RETURN(reset());
+  const int retval= reset();
+  DBUG_RETURN(retval);
 }
 
 

=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc	2009-11-09 10:27:46 +0000
+++ b/sql/item_sum.cc	2009-11-17 11:46:17 +0000
@@ -29,6 +29,18 @@
 #include "sql_select.h"
 
 /**
+  Calculate the affordable RAM limit for structures like TREE or Unique
+  used in Item_sum_*
+*/
+
+ulonglong Item_sum::ram_limitation(THD *thd)
+{
+  return min(thd->variables.tmp_table_size,
+      thd->variables.max_heap_table_size);
+}
+
+
+/**
   Prepare an aggregate function item for checking context conditions.
 
     The function initializes the members of the Item_sum object created
@@ -826,7 +838,7 @@ bool Aggregator_distinct::setup(THD *thd
       }
       DBUG_ASSERT(tree == 0);
       tree= new Unique(compare_key, cmp_arg, tree_key_length,
-                       thd->variables.max_heap_table_size);
+                       item_sum->ram_limitation(thd));
       /*
         The only time tree_key_length could be 0 is if someone does
         count(distinct) on a char(0) field - stupid thing to do,
@@ -895,7 +907,7 @@ bool Aggregator_distinct::setup(THD *thd
       are converted to binary representation as well.
     */
     tree= new Unique(simple_raw_key_cmp, &tree_key_length, tree_key_length,
-                       thd->variables.max_heap_table_size);
+                     item_sum->ram_limitation(thd));
 
     DBUG_RETURN(tree == 0);
   }
@@ -3511,7 +3523,7 @@ bool Item_func_group_concat::setup(THD *
     unique_filter= new Unique(group_concat_key_cmp_with_distinct,
                               (void*)this,
                               tree_key_length,
-                              thd->variables.max_heap_table_size);
+                              ram_limitation(thd));
   
   DBUG_RETURN(FALSE);
 }

=== modified file 'sql/item_sum.h'
--- a/sql/item_sum.h	2009-10-28 12:48:31 +0000
+++ b/sql/item_sum.h	2009-11-17 11:46:17 +0000
@@ -364,6 +364,7 @@ protected:  
   Item **orig_args, *tmp_orig_args[2];
   table_map used_tables_cache;
   bool forced_const;
+  static ulonglong ram_limitation(THD *thd);
 
 public:  
 

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-11-09 10:27:46 +0000
+++ b/sql/mysqld.cc	2009-11-17 11:46:17 +0000
@@ -3467,7 +3467,8 @@ static int init_common_variables(const c
 
   orig_argc=argc;
   orig_argv=argv;
-  load_defaults(conf_file_name, groups, &argc, &argv);
+  if (load_defaults(conf_file_name, groups, &argc, &argv))
+    return 1;
   defaults_argv=argv;
   defaults_argc=argc;
   if (get_options(&defaults_argc, defaults_argv))
@@ -8166,7 +8167,7 @@ static int mysql_init_variables(void)
   log_error_file_ptr= log_error_file;
   lc_messages_dir_ptr= lc_messages_dir;
   mysql_data_home= mysql_real_data_home;
-  thd_startup_options= (OPTION_AUTO_IS_NULL | OPTION_BIN_LOG |
+  thd_startup_options= (OPTION_BIN_LOG |
                         OPTION_QUOTE_SHOW_CREATE | OPTION_SQL_NOTES);
   protocol_version= PROTOCOL_VERSION;
   what_to_log= ~ (1L << (uint) COM_TIME);

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2009-11-10 08:36:20 +0000
+++ b/sql/opt_range.cc	2009-11-12 12:13:55 +0000
@@ -7900,11 +7900,20 @@ ha_rows check_quick_select(PARAM *param,
     */
     param->is_ror_scan= FALSE;
   }
-  else
+  else if (param->table->s->primary_key == keynr && pk_is_clustered)
   {
     /* Clustered PK scan is always a ROR scan (TODO: same as above) */
-    if (param->table->s->primary_key == keynr && pk_is_clustered)
-      param->is_ror_scan= TRUE;
+    param->is_ror_scan= TRUE;
+  }
+  else if (param->range_count > 1)
+  {
+    /* 
+      Scaning multiple key values in the index: the records are ROR
+      for each value, but not between values. E.g, "SELECT ... x IN
+      (1,3)" returns ROR order for all records with x=1, then ROR
+      order for records with x=3
+    */
+    param->is_ror_scan= FALSE;
   }
 
   DBUG_PRINT("exit", ("Records: %lu", (ulong) rows));

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2009-11-09 10:27:46 +0000
+++ b/sql/sql_insert.cc	2009-11-20 12:49:47 +0000
@@ -1971,7 +1971,7 @@ bool delayed_get_table(THD *thd, TABLE_L
       pthread_mutex_lock(&LOCK_thread_count);
       thread_count++;
       pthread_mutex_unlock(&LOCK_thread_count);
-      di->thd.set_db(table_list->db, strlen(table_list->db));
+      di->thd.set_db(table_list->db, (uint) strlen(table_list->db));
       di->thd.set_query(my_strdup(table_list->table_name,
                                   MYF(MY_WME | ME_FATALERROR)), 0);
       if (di->thd.db == NULL || di->thd.query() == NULL)

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-11-10 07:47:59 +0000
+++ b/sql/sql_select.cc	2009-11-20 12:49:47 +0000
@@ -122,7 +122,7 @@ static uint build_bitmap_for_nested_join
 
 static 
 void advance_sj_state(JOIN *join, const table_map remaining_tables, 
-                      const JOIN_TAB *s, uint idx, 
+                      const JOIN_TAB *new_join_tab, uint idx, 
                       double *current_record_count, double *current_read_time,
                       POSITION *loose_scan_pos);
 
@@ -1335,8 +1335,8 @@ int setup_semijoin_dups_elimination(JOIN
             jump_to= tab;
           else
           {
-            tab->first_sj_inner_tab= tab;
-            tab->last_sj_inner_tab= tab + pos->n_sj_tables - 1;
+            j->first_sj_inner_tab= tab;
+            j->last_sj_inner_tab= tab + pos->n_sj_tables - 1;
           }
         }
         j[-1].do_firstmatch= jump_to;
@@ -3400,7 +3400,8 @@ bool convert_subq_to_sj(JOIN *parent_joi
   /* 3. Remove the original subquery predicate from the WHERE/ON */
 
   // The subqueries were replaced for Item_int(1) earlier
-  subq_pred->exec_method= Item_in_subselect::SEMI_JOIN; // for subsequent executions
+  subq_pred->exec_method=
+    Item_in_subselect::SEMI_JOIN;         // for subsequent executions
   /*TODO: also reset the 'with_subselect' there. */
 
   /* n. Adjust the parent_join->tables counter */
@@ -3412,7 +3413,9 @@ bool convert_subq_to_sj(JOIN *parent_joi
     tl->table->map= ((table_map)1) << table_no;
     SELECT_LEX *old_sl= tl->select_lex;
     tl->select_lex= parent_join->select_lex; 
-    for(TABLE_LIST *emb= tl->embedding; emb && emb->select_lex == old_sl; emb= emb->embedding)
+    for (TABLE_LIST *emb= tl->embedding;
+         emb && emb->select_lex == old_sl;
+         emb= emb->embedding)
       emb->select_lex= parent_join->select_lex;
   }
   parent_join->tables += subq_lex->join->tables;
@@ -8082,7 +8085,11 @@ static void fix_semijoin_strategies_for_
     
     uint i_end= first + join->best_positions[first].n_sj_tables;
     for (uint i= first; i < i_end; i++)
+    {
+      if (i != first)
+        join->best_positions[i].sj_strategy= SJ_OPT_NONE;
       handled_tabs |= join->best_positions[i].table->table->map;
+    }
 
     if (tablenr != first)
       pos->sj_strategy= SJ_OPT_NONE;
@@ -10113,15 +10120,19 @@ uint check_join_cache_usage(JOIN_TAB *ta
   */
   if (tab->use_quick == 2)
     goto no_join_cache;
-  
+  /*
+    Use join cache with FirstMatch semi-join strategy only when semi-join
+    contains only one table.
+  */
+  if (tab->is_inner_table_of_semi_join_with_first_match() &&
+      !tab->is_single_inner_of_semi_join_with_first_match())
+    goto no_join_cache;
   /*
     Non-linked join buffers can't guarantee one match
   */
   if (force_unlinked_cache && 
-      ((tab->is_inner_table_of_semi_join_with_first_match() &&
-        !tab->is_single_inner_of_semi_join_with_first_match()) ||
-       (tab->is_inner_table_of_outer_join() &&
-        !tab->is_single_inner_of_outer_join())))
+      (tab->is_inner_table_of_outer_join() &&
+       !tab->is_single_inner_of_outer_join()))
     goto no_join_cache;
 
   /*
@@ -13017,14 +13028,14 @@ void optimize_wo_join_buffering(JOIN *jo
     advance_sj_state()
       join                        The join we're optimizing
       remaining_tables            Tables not in the join prefix
-      s                           Join tab we've just added to the join prefix
+      new_join_tab                Join tab we've just added to the join prefix
       idx                         Index of this join tab (i.e. number of tables
                                   in the prefix minus one)
       current_record_count INOUT  Estimate of #records in join prefix's output
       current_read_time    INOUT  Cost to execute the join prefix
       loose_scan_pos       IN     A POSITION with LooseScan plan to access 
-                                  table s (produced by the last best_access_path 
-                                  call)
+                                  table new_join_tab
+                                  (produced by the last best_access_path call)
 
   DESCRIPTION
     Update semi-join optimization state after we've added another tab (table 
@@ -13060,13 +13071,13 @@ void optimize_wo_join_buffering(JOIN *jo
 
 static 
 void advance_sj_state(JOIN *join, table_map remaining_tables, 
-                      const JOIN_TAB *s, uint idx, 
+                      const JOIN_TAB *new_join_tab, uint idx, 
                       double *current_record_count, double *current_read_time, 
                       POSITION *loose_scan_pos)
 {
   TABLE_LIST *emb_sj_nest;
   POSITION *pos= join->positions + idx;
-  remaining_tables &= ~s->table->map;
+  remaining_tables &= ~new_join_tab->table->map;
 
   pos->prefix_cost.convert_from_cost(*current_read_time);
   pos->prefix_record_count= *current_record_count;
@@ -13084,17 +13095,22 @@ void advance_sj_state(JOIN *join, table_
   else
   {
     // FirstMatch
-    pos->first_firstmatch_table= (pos[-1].sj_strategy == SJ_OPT_FIRST_MATCH)?
-                                  MAX_TABLES : pos[-1].first_firstmatch_table;
+    pos->first_firstmatch_table=
+      (pos[-1].sj_strategy == SJ_OPT_FIRST_MATCH) ?
+      MAX_TABLES : pos[-1].first_firstmatch_table;
     pos->first_firstmatch_rtbl= pos[-1].first_firstmatch_rtbl;
     pos->firstmatch_need_tables= pos[-1].firstmatch_need_tables;
+
     // LooseScan
-    pos->first_loosescan_table= (pos[-1].sj_strategy == SJ_OPT_LOOSE_SCAN)? 
-                                  MAX_TABLES: pos[-1].first_loosescan_table;
+    pos->first_loosescan_table=
+      (pos[-1].sj_strategy == SJ_OPT_LOOSE_SCAN) ?
+      MAX_TABLES : pos[-1].first_loosescan_table;
     pos->loosescan_need_tables= pos[-1].loosescan_need_tables;
+
     // SJ-Materialization Scan
-    pos->sjm_scan_need_tables= (pos[-1].sj_strategy == SJ_OPT_MATERIALIZE_SCAN)? 
-                               0: pos[-1].sjm_scan_need_tables;
+    pos->sjm_scan_need_tables=
+      (pos[-1].sj_strategy == SJ_OPT_MATERIALIZE_SCAN) ?
+      0 : pos[-1].sjm_scan_need_tables;
     pos->sjm_scan_last_inner= pos[-1].sjm_scan_last_inner;
 
     // Duplicate Weedout
@@ -13104,33 +13120,39 @@ void advance_sj_state(JOIN *join, table_
   
   table_map handled_by_fm_or_ls= 0;
   /* FirstMatch Strategy */
+  if (new_join_tab->emb_sj_nest &&
+      optimizer_flag(join->thd, OPTIMIZER_SWITCH_FIRSTMATCH))
   {
+    const table_map outer_corr_tables=
+      new_join_tab->emb_sj_nest->nested_join->sj_corr_tables |
+      new_join_tab->emb_sj_nest->nested_join->sj_depends_on;
+    const table_map sj_inner_tables=
+      new_join_tab->emb_sj_nest->sj_inner_tables;
+
     /* 
       Enter condition:
        1. The next join tab belongs to semi-join nest
+          (verified for the encompassing code block above).
        2. We're not in a duplicate producer range yet
        3. All outer tables that
            - the subquery is correlated with, or
            - referred to from the outer_expr 
           are in the join prefix
+       4. All inner tables are still part of remaining_tables.
     */
-    if (s->emb_sj_nest &&            // (1)
-        !join->cur_sj_inner_tables &&   // (2)
-        !(remaining_tables &                             // (3)
-          (s->emb_sj_nest->nested_join->sj_corr_tables | // (3)
-           s->emb_sj_nest->nested_join->sj_depends_on)) && // (3)
-        optimizer_flag(join->thd, OPTIMIZER_SWITCH_FIRSTMATCH))
+    if (!join->cur_sj_inner_tables &&              // (2)
+        !(remaining_tables & outer_corr_tables) && // (3)
+        (sj_inner_tables ==                        // (4)
+         ((remaining_tables | new_join_tab->table->map) & sj_inner_tables)))
     {
       /* Start tracking potential FirstMatch range */
       pos->first_firstmatch_table= idx;
-      pos->firstmatch_need_tables= s->emb_sj_nest->sj_inner_tables;
+      pos->firstmatch_need_tables= sj_inner_tables;
       pos->first_firstmatch_rtbl= remaining_tables;
     }
 
-    if (pos->first_firstmatch_table != MAX_TABLES && s->emb_sj_nest)
+    if (pos->first_firstmatch_table != MAX_TABLES)
     {
-      table_map outer_corr_tables= s->emb_sj_nest->nested_join->sj_corr_tables |
-                                   s->emb_sj_nest->nested_join->sj_depends_on;
       if (outer_corr_tables & pos->first_firstmatch_rtbl)
       {
         /*
@@ -13142,7 +13164,7 @@ void advance_sj_state(JOIN *join, table_
       else
       {
         /* Record that we need all of this semi-join's inner tables, too */
-        pos->firstmatch_need_tables |= s->emb_sj_nest->sj_inner_tables;
+        pos->firstmatch_need_tables|= sj_inner_tables;
       }
     
       if (!(pos->firstmatch_need_tables & remaining_tables))
@@ -13187,7 +13209,7 @@ void advance_sj_state(JOIN *join, table_
     */
     if ((pos->first_loosescan_table != MAX_TABLES) &&   // (1)
         (first->table->emb_sj_nest->sj_inner_tables & remaining_tables) && //(2)
-        s->emb_sj_nest != first->table->emb_sj_nest)                       //(2)
+        new_join_tab->emb_sj_nest != first->table->emb_sj_nest) //(2)
     {
       pos->first_loosescan_table= MAX_TABLES;
     }
@@ -13199,9 +13221,10 @@ void advance_sj_state(JOIN *join, table_
     if (loose_scan_pos->read_time != DBL_MAX)
     {
       pos->first_loosescan_table= idx;
-      pos->loosescan_need_tables= s->emb_sj_nest->sj_inner_tables | 
-                                  s->emb_sj_nest->nested_join->sj_depends_on |
-                                  s->emb_sj_nest->nested_join->sj_corr_tables;
+      pos->loosescan_need_tables=
+        new_join_tab->emb_sj_nest->sj_inner_tables | 
+        new_join_tab->emb_sj_nest->nested_join->sj_depends_on |
+        new_join_tab->emb_sj_nest->nested_join->sj_corr_tables;
     }
     
     if ((pos->first_loosescan_table != MAX_TABLES) && 
@@ -13245,13 +13268,14 @@ void advance_sj_state(JOIN *join, table_
     Update join->cur_sj_inner_tables (Used by FirstMatch in this function and
     LooseScan detector in best_access_path)
   */
-  if ((emb_sj_nest= s->emb_sj_nest))
+  if ((emb_sj_nest= new_join_tab->emb_sj_nest))
   {
     join->cur_sj_inner_tables |= emb_sj_nest->sj_inner_tables;
     join->cur_dups_producing_tables |= emb_sj_nest->sj_inner_tables;
 
     /* Remove the sj_nest if all of its SJ-inner tables are in cur_table_map */
-    if (!(remaining_tables & emb_sj_nest->sj_inner_tables & ~s->table->map))
+    if (!(remaining_tables &
+          emb_sj_nest->sj_inner_tables & ~new_join_tab->table->map))
       join->cur_sj_inner_tables &= ~emb_sj_nest->sj_inner_tables;
   }
   join->cur_dups_producing_tables &= ~handled_by_fm_or_ls;
@@ -13259,7 +13283,8 @@ void advance_sj_state(JOIN *join, table_
   /* 4. SJ-Materialization and SJ-Materialization-scan strategy handler */
   bool sjm_scan;
   SJ_MATERIALIZATION_INFO *mat_info;
-  if ((mat_info= at_sjmat_pos(join, remaining_tables, s, idx, &sjm_scan)))
+  if ((mat_info= at_sjmat_pos(join, remaining_tables,
+                              new_join_tab, idx, &sjm_scan)))
   {
     if (sjm_scan)
     {
@@ -13282,9 +13307,10 @@ void advance_sj_state(JOIN *join, table_
         The simple way to model this is to remove SJM-SCAN(...) fanout once
         we reach the point #2.
       */
-      pos->sjm_scan_need_tables= s->emb_sj_nest->sj_inner_tables | 
-                                 s->emb_sj_nest->nested_join->sj_depends_on |
-                                 s->emb_sj_nest->nested_join->sj_corr_tables;
+      pos->sjm_scan_need_tables=
+        new_join_tab->emb_sj_nest->sj_inner_tables | 
+        new_join_tab->emb_sj_nest->nested_join->sj_depends_on |
+        new_join_tab->emb_sj_nest->nested_join->sj_corr_tables;
       pos->sjm_scan_last_inner= idx;
     }
     else
@@ -13319,7 +13345,8 @@ void advance_sj_state(JOIN *join, table_
         pos->sj_strategy= SJ_OPT_MATERIALIZE;
         *current_read_time=    mat_read_time;
         *current_record_count= prefix_rec_count;
-        join->cur_dups_producing_tables &= ~s->emb_sj_nest->sj_inner_tables;
+        join->cur_dups_producing_tables&=
+          ~new_join_tab->emb_sj_nest->sj_inner_tables;
       }
     }
   }
@@ -13392,7 +13419,7 @@ void advance_sj_state(JOIN *join, table_
        correlated 
     */
     TABLE_LIST *nest;
-    if ((nest= s->emb_sj_nest))
+    if ((nest= new_join_tab->emb_sj_nest))
     {
       if (!pos->dupsweedout_tables)
         pos->first_dupsweedout_table= idx;
@@ -13403,7 +13430,8 @@ void advance_sj_state(JOIN *join, table_
     }
 
     if (pos->dupsweedout_tables && 
-        !((remaining_tables & ~s->table->map) & pos->dupsweedout_tables))
+        !(remaining_tables &
+          ~new_join_tab->table->map & pos->dupsweedout_tables))
     {
       /*
         Ok, reached a state where we could put a dups weedout point.
@@ -13558,18 +13586,26 @@ optimize_cond(JOIN *join, COND *conds, L
 
 
 /**
-  Remove const and eq items.
+  Handles the reqursive job for remove_eq_conds()
 
-  @return
-    Return new item, or NULL if no condition @n
-    cond_value is set to according:
-    - COND_OK     : query is possible (field = constant)
-    - COND_TRUE   : always true	( 1 = 1 )
-    - COND_FALSE  : always false	( 1 = 2 )
+  Remove const and eq items. Return new item, or NULL if no condition
+  cond_value is set to according:
+  COND_OK    query is possible (field = constant)
+  COND_TRUE  always true	( 1 = 1 )
+  COND_FALSE always false	( 1 = 2 )
+
+  SYNPOSIS
+    internal_remove_eq_conds()
+    thd 			THD environment
+    cond                        the condition to handle
+    cond_value                  the resulting value of the condition
+
+  RETURN
+    *COND with the simplified condition
 */
 
-COND *
-remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
+static COND *
+internal_remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
 {
   if (cond->type() == Item::COND_ITEM)
   {
@@ -13583,7 +13619,7 @@ remove_eq_conds(THD *thd, COND *cond, It
     Item *item;
     while ((item=li++))
     {
-      Item *new_item=remove_eq_conds(thd, item, &tmp_cond_value);
+      Item *new_item=internal_remove_eq_conds(thd, item, &tmp_cond_value);
       if (!new_item)
 	li.remove();
       else if (item != new_item)
@@ -13632,54 +13668,15 @@ remove_eq_conds(THD *thd, COND *cond, It
   else if (cond->type() == Item::FUNC_ITEM &&
 	   ((Item_func*) cond)->functype() == Item_func::ISNULL_FUNC)
   {
-    /*
-      Handles this special case for some ODBC applications:
-      The are requesting the row that was just updated with a auto_increment
-      value with this construct:
-
-      SELECT * from table_name where auto_increment_column IS NULL
-      This will be changed to:
-      SELECT * from table_name where auto_increment_column = LAST_INSERT_ID
-    */
-
     Item_func_isnull *func=(Item_func_isnull*) cond;
     Item **args= func->arguments();
     if (args[0]->type() == Item::FIELD_ITEM)
     {
       Field *field=((Item_field*) args[0])->field;
-      if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null &&
-	  (thd->options & OPTION_AUTO_IS_NULL) &&
-	  (thd->first_successful_insert_id_in_prev_stmt > 0 &&
-           thd->substitute_null_with_insert_id))
-      {
-#ifdef HAVE_QUERY_CACHE
-	query_cache_abort(&thd->query_cache_tls);
-#endif
-	COND *new_cond;
-	if ((new_cond= new Item_func_eq(args[0],
-					new Item_int("last_insert_id()",
-                                                     thd->read_first_successful_insert_id_in_prev_stmt(),
-                                                     MY_INT64_NUM_DECIMAL_DIGITS))))
-	{
-	  cond=new_cond;
-          /*
-            Item_func_eq can't be fixed after creation so we do not check
-            cond->fixed, also it do not need tables so we use 0 as second
-            argument.
-          */
-	  cond->fix_fields(thd, &cond);
-	}
-        /*
-          IS NULL should be mapped to LAST_INSERT_ID only for first row, so
-          clear for next row
-        */
-        thd->substitute_null_with_insert_id= FALSE;
-      }
       /* fix to replace 'NULL' dates with '0' (shreeve@stripped) */
-      else if (((field->type() == MYSQL_TYPE_DATE) ||
-		(field->type() == MYSQL_TYPE_DATETIME)) &&
-		(field->flags & NOT_NULL_FLAG) &&
-	       !field->table->maybe_null)
+      if (((field->type() == MYSQL_TYPE_DATE) ||
+            (field->type() == MYSQL_TYPE_DATETIME)) &&
+          (field->flags & NOT_NULL_FLAG) && !field->table->maybe_null)
       {
 	COND *new_cond;
 	if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2))))
@@ -13730,6 +13727,83 @@ remove_eq_conds(THD *thd, COND *cond, It
   return cond;					// Point at next and level
 }
 
+/**
+  Remove const and eq items. Return new item, or NULL if no condition
+  cond_value is set to according:
+  COND_OK    query is possible (field = constant)
+  COND_TRUE  always true	( 1 = 1 )
+  COND_FALSE always false	( 1 = 2 )
+
+  SYNPOSIS
+    remove_eq_conds()
+    thd 			THD environment
+    cond                        the condition to handle
+    cond_value                  the resulting value of the condition
+
+  NOTES
+    calls the inner_remove_eq_conds to check all the tree reqursively
+
+  RETURN
+    *COND with the simplified condition
+*/
+
+COND *
+remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
+{
+  if (cond->type() == Item::FUNC_ITEM &&
+      ((Item_func*) cond)->functype() == Item_func::ISNULL_FUNC)
+  {
+    /*
+      Handles this special case for some ODBC applications:
+      The are requesting the row that was just updated with a auto_increment
+      value with this construct:
+
+      SELECT * from table_name where auto_increment_column IS NULL
+      This will be changed to:
+      SELECT * from table_name where auto_increment_column = LAST_INSERT_ID
+    */
+
+    Item_func_isnull *func=(Item_func_isnull*) cond;
+    Item **args= func->arguments();
+    if (args[0]->type() == Item::FIELD_ITEM)
+    {
+      Field *field=((Item_field*) args[0])->field;
+      if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null &&
+	  (thd->options & OPTION_AUTO_IS_NULL) &&
+	  (thd->first_successful_insert_id_in_prev_stmt > 0 &&
+           thd->substitute_null_with_insert_id))
+      {
+#ifdef HAVE_QUERY_CACHE
+	query_cache_abort(&thd->query_cache_tls);
+#endif
+	COND *new_cond;
+	if ((new_cond= new Item_func_eq(args[0],
+					new Item_int("last_insert_id()",
+                                                     thd->read_first_successful_insert_id_in_prev_stmt(),
+                                                     MY_INT64_NUM_DECIMAL_DIGITS))))
+	{
+	  cond=new_cond;
+          /*
+            Item_func_eq can't be fixed after creation so we do not check
+            cond->fixed, also it do not need tables so we use 0 as second
+            argument.
+          */
+	  cond->fix_fields(thd, &cond);
+	}
+        /*
+          IS NULL should be mapped to LAST_INSERT_ID only for first row, so
+          clear for next row
+        */
+        thd->substitute_null_with_insert_id= FALSE;
+        *cond_value=Item::COND_OK;
+        return cond;
+      }
+    }
+  }
+  return internal_remove_eq_conds(thd, cond, cond_value); // Scan all the condition
+}
+
+
 /* 
   Check if equality can be used in removing components of GROUP BY/DISTINCT
   

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-11-10 07:47:59 +0000
+++ b/sql/sql_table.cc	2009-11-12 12:22:31 +0000
@@ -4549,6 +4549,7 @@ static bool mysql_admin_table(THD* thd, 
     char table_name[NAME_LEN*2+2];
     char* db = table->db;
     bool fatal_error=0;
+    bool open_error;
 
     DBUG_PRINT("admin", ("table: '%s'.'%s'", table->db, table->table_name));
     DBUG_PRINT("admin", ("extra_open_options: %u", extra_open_options));
@@ -4576,12 +4577,22 @@ static bool mysql_admin_table(THD* thd, 
       if (view_operator_func == NULL)
         table->required_type=FRMTYPE_TABLE;
 
-      open_and_lock_tables_derived(thd, table, TRUE,
-                                   MYSQL_OPEN_TAKE_UPGRADABLE_MDL);
+      open_error= open_and_lock_tables_derived(thd, table, TRUE,
+                                               MYSQL_OPEN_TAKE_UPGRADABLE_MDL);
       thd->no_warnings_for_error= 0;
       table->next_global= save_next_global;
       table->next_local= save_next_local;
       thd->open_options&= ~extra_open_options;
+      /*
+        Under locked tables, we know that the table can be opened,
+        so any errors opening the table are logical errors.
+        In these cases it does not make sense to try to repair.
+      */
+      if (open_error && thd->locked_tables_mode)
+      {
+        result_code= HA_ADMIN_FAILED;
+        goto send_result;
+      }
 #ifdef WITH_PARTITION_STORAGE_ENGINE
       if (table->table)
       {

=== modified file 'storage/archive/archive_reader.c'
--- a/storage/archive/archive_reader.c	2008-12-17 18:40:14 +0000
+++ b/storage/archive/archive_reader.c	2009-11-17 11:46:17 +0000
@@ -339,7 +339,8 @@ static void print_version(void)
 
 static void get_options(int *argc, char ***argv)
 {
-  load_defaults("my", load_default_groups, argc, argv);
+  if (load_defaults("my", load_default_groups, argc, argv))
+    exit(1);
   default_argv= *argv;
 
   handle_options(argc, argv, my_long_options, get_one_option);

=== modified file 'storage/example/Makefile.am'
--- a/storage/example/Makefile.am	2009-11-05 08:44:22 +0000
+++ b/storage/example/Makefile.am	2009-11-12 12:22:31 +0000
@@ -50,7 +50,7 @@ libexample_a_LIBADD = probes_mysql.o
 libexample_a_DEPENDENCIES = probes_mysql.o
 CLEANFILES =
 BUILT_SOURCES =
-DTRACEFILES = ha_example_la-ha_example.o
+DTRACEFILES = libexample_a-ha_example.o
 DTRACEPROVIDER = probes_mysql.d
 
 dtrace_files:

=== modified file 'storage/myisam/mi_rnext.c'
--- a/storage/myisam/mi_rnext.c	2007-06-27 17:48:00 +0000
+++ b/storage/myisam/mi_rnext.c	2009-11-18 06:14:20 +0000
@@ -89,7 +89,10 @@ int mi_rnext(MI_INFO *info, uchar *buf, 
            (info->index_cond_func &&
            !(res= mi_check_index_cond(info, inx, buf))))
     {
-      /* Skip rows inserted by other threads since we got a lock */
+      /* 
+         Skip rows that are either inserted by other threads since
+         we got a lock or do not match pushed index conditions
+      */
       if  ((error=_mi_search_next(info,info->s->keyinfo+inx,
                                   info->lastkey,
                                   info->lastkey_length,

=== modified file 'storage/myisam/mi_rprev.c'
--- a/storage/myisam/mi_rprev.c	2007-05-10 09:59:39 +0000
+++ b/storage/myisam/mi_rprev.c	2009-11-18 06:14:20 +0000
@@ -51,22 +51,36 @@ int mi_rprev(MI_INFO *info, uchar *buf, 
     error=_mi_search(info,share->keyinfo+inx,info->lastkey,
 		     USE_WHOLE_KEY, flag, share->state.key_root[inx]);
 
-  if (share->concurrent_insert)
+  if (!error)
   {
-    if (!error)
+    int res= 0;
+    while ((share->concurrent_insert && 
+            info->lastpos >= info->state->data_file_length) ||
+           (info->index_cond_func &&
+            !(res= mi_check_index_cond(info, inx, buf))))
     {
-      while (info->lastpos >= info->state->data_file_length)
-      {
-	/* Skip rows that are inserted by other threads since we got a lock */
-	if  ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
-				    info->lastkey_length,
-				    SEARCH_SMALLER,
-				    share->state.key_root[inx])))
-	  break;
-      }
+      /* 
+         Skip rows that are either inserted by other threads since
+         we got a lock or do not match pushed index conditions
+      */
+      if  ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey,
+                                  info->lastkey_length,
+                                  SEARCH_SMALLER,
+                                  share->state.key_root[inx])))
+        break;
+    }
+    if (!error && res == 2) 
+    {
+      if (share->concurrent_insert)
+        rw_unlock(&share->key_root_lock[inx]);
+      info->lastpos= HA_OFFSET_ERROR;
+      DBUG_RETURN(my_errno= HA_ERR_END_OF_FILE);
     }
-    rw_unlock(&share->key_root_lock[inx]);
   }
+
+  if (share->concurrent_insert)
+    rw_unlock(&share->key_root_lock[inx]);
+
   info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
   info->update|= HA_STATE_PREV_FOUND;
   if (error)

=== modified file 'storage/myisam/myisamchk.c'
--- a/storage/myisam/myisamchk.c	2009-10-27 13:33:28 +0000
+++ b/storage/myisam/myisamchk.c	2009-11-17 11:46:17 +0000
@@ -743,7 +743,9 @@ static void get_options(register int *ar
 {
   int ho_error;
 
-  load_defaults("my", load_default_groups, argc, argv);
+  if (load_defaults("my", load_default_groups, argc, argv))
+    exit(1);
+
   default_argv= *argv;
   if (isatty(fileno(stdout)))
     check_param.testflag|=T_WRITE_LOOP;

=== modified file 'storage/myisam/myisampack.c'
--- a/storage/myisam/myisampack.c	2009-05-14 21:49:53 +0000
+++ b/storage/myisam/myisampack.c	2009-11-17 11:46:17 +0000
@@ -210,7 +210,9 @@ int main(int argc, char **argv)
   char **default_argv;
   MY_INIT(argv[0]);
 
-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+    exit(1);
+
   default_argv= argv;
   get_options(&argc,&argv);
 

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2009-11-09 10:27:46 +0000
+++ b/tests/mysql_client_test.c	2009-11-17 11:46:17 +0000
@@ -19397,7 +19397,9 @@ int main(int argc, char **argv)
 
   MY_INIT(argv[0]);
 
-  load_defaults("my", client_test_load_default_groups, &argc, &argv);
+  if (load_defaults("my", client_test_load_default_groups, &argc, &argv))
+    exit(1);
+
   defaults_argv= argv;
   get_options(&argc, &argv);
 

=== modified file 'tests/thread_test.c'
--- a/tests/thread_test.c	2008-04-09 00:56:49 +0000
+++ b/tests/thread_test.c	2009-11-17 11:46:17 +0000
@@ -176,9 +176,8 @@ static void get_options(int argc, char *
 {
   int ho_error;
 
-  load_defaults("my",load_default_groups,&argc,&argv);
-
-  if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
+  if ((ho_error= load_defaults("my",load_default_groups,&argc,&argv)) ||
+      (ho_error= handle_options(&argc, &argv, my_long_options, get_one_option)))
     exit(ho_error);
 
   free_defaults(argv);

=== modified file 'vio/vio_priv.h'
--- a/vio/vio_priv.h	2009-11-09 10:27:46 +0000
+++ b/vio/vio_priv.h	2009-11-20 12:49:47 +0000
@@ -43,6 +43,20 @@ my_bool vio_is_connected_shared_memory(V
 int vio_close_shared_memory(Vio * vio);
 #endif
 
+#ifdef __WIN__
+size_t vio_read_pipe(Vio *vio, uchar * buf, size_t size);
+size_t vio_write_pipe(Vio *vio, const uchar * buf, size_t size);
+my_bool vio_is_connected_pipe(Vio *vio);
+int vio_close_pipe(Vio * vio);
+#endif
+
+#ifdef HAVE_SMEM
+size_t vio_read_shared_memory(Vio *vio, uchar * buf, size_t size);
+size_t vio_write_shared_memory(Vio *vio, const uchar * buf, size_t size);
+my_bool vio_is_connected_shared_memory(Vio *vio);
+int vio_close_shared_memory(Vio * vio);
+#endif
+
 void	vio_timeout(Vio *vio,uint which, uint timeout);
 
 #ifdef HAVE_OPENSSL


Attachment: [text/bzr-bundle] bzr/kostja@sun.com-20091120124947-yi6h2jbgw0kbciwm.bundle
Thread
bzr push into mysql-6.0-codebase-bugfixing branch (kostja:3710 to 3719)Konstantin Osipov20 Nov