List:Commits« Previous MessageNext Message »
From:Bjorn Munch Date:February 23 2011 12:06pm
Subject:bzr commit into mysql-trunk-mtr branch (bjorn.munch:3030)
View as plain text  
#At file:///home/bm136801/my/mtr-tr/ based on revid:bjorn.munch@stripped

 3030 Bjorn Munch	2011-02-23 [merge]
      merge from trunk

    removed:
      mysql-test/r/crash_commit_before.result
      mysql-test/t/crash_commit_before-master.opt
      mysql-test/t/crash_commit_before.test
      mysql-test/t/partition-master.opt
    added:
      mysql-test/include/check_qep.inc
      mysql-test/include/expect_qep.inc
      mysql-test/r/multi_update_innodb.result
      mysql-test/suite/binlog/r/rpl_crash_safe_master_checksum.result
      mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum-master.opt
      mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum.test
      mysql-test/suite/rpl/r/rpl_crash_safe_master.result
      mysql-test/suite/rpl/t/rpl_crash_safe_master.test
      mysql-test/suite/sys_vars/r/core_file_basic.result
      mysql-test/suite/sys_vars/t/core_file_basic-master.opt
      mysql-test/suite/sys_vars/t/core_file_basic.test
      mysql-test/t/multi_update_innodb.test
    modified:
      client/mysql.cc
      client/mysqltest.cc
      include/my_sys.h
      mysql-test/extra/binlog_tests/ctype_cp932.test
      mysql-test/include/mysqld--help.inc
      mysql-test/r/ctype_ldml.result
      mysql-test/r/ddl_i18n_koi8r.result
      mysql-test/r/ddl_i18n_utf8.result
      mysql-test/r/greedy_optimizer.result
      mysql-test/r/join.result
      mysql-test/r/join_cache_jcl1.result
      mysql-test/r/join_cache_jcl2.result
      mysql-test/r/join_cache_jcl3.result
      mysql-test/r/join_cache_jcl4.result
      mysql-test/r/lock.result
      mysql-test/r/log_state.result
      mysql-test/r/log_tables.result
      mysql-test/r/multi_update.result
      mysql-test/r/partition.result
      mysql-test/r/status.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/system_mysql_db.result
      mysql-test/std_data/Index.xml
      mysql-test/suite/binlog/r/binlog_index.result
      mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test
      mysql-test/suite/binlog/t/binlog_index.test
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result
      mysql-test/suite/rpl/r/rpl_checksum.result
      mysql-test/suite/rpl/r/rpl_corruption.result
      mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
      mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_stm_000001.result
      mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
      mysql-test/suite/rpl/t/rpl_checksum.test
      mysql-test/suite/rpl/t/rpl_corruption.test
      mysql-test/suite/rpl/t/rpl_manual_change_index_file.test
      mysql-test/suite/rpl/t/rpl_stm_000001.test
      mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result
      mysql-test/suite/sys_vars/r/slow_query_log_func.result
      mysql-test/suite/sys_vars/t/slow_query_log_func.test
      mysql-test/t/ctype_ldml.test
      mysql-test/t/grant.test
      mysql-test/t/greedy_optimizer.test
      mysql-test/t/lock.test
      mysql-test/t/log_state.test
      mysql-test/t/log_tables.test
      mysql-test/t/multi_update.test
      mysql-test/t/mysql.test
      mysql-test/t/mysql_cp932.test
      mysql-test/t/mysqlbinlog-cp932.test
      mysql-test/t/partition.test
      mysys/my_conio.c
      mysys/my_rename.c
      scripts/mysql_system_tables.sql
      scripts/mysql_system_tables_fix.sql
      scripts/mysqldumpslow.sh
      sql-common/client.c
      sql/binlog.cc
      sql/binlog.h
      sql/handler.cc
      sql/log.cc
      sql/log.h
      sql/log_event.cc
      sql/mysqld.cc
      sql/share/errmsg-utf8.txt
      sql/sql_plugin.cc
      sql/sql_select.cc
      sql/sql_update.cc
      sql/sys_vars.cc
      sql/sys_vars.h
      strings/ctype-uca.c
      strings/ctype.c
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2011-02-15 12:38:39 +0000
+++ b/client/mysql.cc	2011-02-23 04:53:07 +0000
@@ -195,6 +195,43 @@ static CHARSET_INFO *charset_info= &my_c
 
 const char *default_dbug_option="d:t:o,/tmp/mysql.trace";
 
+#ifdef __WIN__
+/*
+  A flag that indicates if --execute buffer has already been converted,
+  to avoid double conversion on reconnect.
+*/
+static my_bool execute_buffer_conversion_done= 0;
+
+/*
+  my_win_is_console(...) is quite slow.
+  We cache my_win_is_console() results for stdout and stderr.
+  Any other output files, except stdout and stderr,
+  cannot be Windows console.
+  Note, if mysql.exe is executed from a service, its _fileno(stdout) is -1,
+  so shift (1 << -1) can return implementation defined result.
+  This corner case is taken into account, as the shift result
+  will be multiplied to 0 and we'll get 0 as a result.
+  The same is true for stderr.
+*/
+static uint win_is_console_cache= 
+  (test(my_win_is_console(stdout)) * (1 << _fileno(stdout))) |
+  (test(my_win_is_console(stderr)) * (1 << _fileno(stderr)));
+
+static inline my_bool
+my_win_is_console_cached(FILE *file)
+{
+  return win_is_console_cache & (1 << _fileno(file));
+}
+#endif /* __WIN__ */
+
+/* Various printing flags */
+#define MY_PRINT_ESC_0 1  /* Replace 0x00 bytes to "\0"              */
+#define MY_PRINT_SPS_0 2  /* Replace 0x00 bytes to space             */
+#define MY_PRINT_XML   4  /* Encode XML entities                     */
+#define MY_PRINT_MB    8  /* Recognize multi-byte characters         */
+#define MY_PRINT_CTRL 16  /* Replace TAB, NL, CR to "\t", "\n", "\r" */
+
+void tee_write(FILE *file, const char *s, size_t slen, int flags);
 void tee_fprintf(FILE *file, const char *fmt, ...);
 void tee_fputs(const char *s, FILE *file);
 void tee_puts(const char *s, FILE *file);
@@ -1113,6 +1150,11 @@ int main(int argc,char *argv[])
       close(stdout_fileno_copy);             /* Clean up dup(). */
   }
 
+#ifdef __WIN__
+  /* Convert command line parameters from UTF16LE to UTF8MB4. */
+  my_win_translate_command_line_args(&my_charset_utf8mb4_bin, &argc, &argv);
+#endif
+
   if (load_defaults("my",load_default_groups,&argc,&argv))
   {
     my_end(0);
@@ -1885,22 +1927,9 @@ static int read_and_execute(bool interac
         tmpbuf.alloc(65535);
       tmpbuf.length(0);
       buffer.length(0);
-      size_t clen;
-      do
-      {
-	line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen);
-        buffer.append(line, clen);
-        /* 
-           if we got buffer fully filled than there is a chance that
-           something else is still in console input buffer
-        */
-      } while (tmpbuf.alloced_length() <= clen);
-      /* 
-        An empty line is returned from my_cgets when there's error reading :
-        Ctrl-c for example
-      */
-      if (line)
-        line= buffer.c_ptr();
+      line= my_win_console_readline(charset_info,
+                                    (char *) tmpbuf.ptr(),
+                                    tmpbuf.alloced_length());
 #else
       if (opt_outfile)
 	fputs(prompt, OUTFILE);
@@ -3455,19 +3484,12 @@ tee_print_sized_data(const char *data, u
     grid.  (The \0 is also the reason we can't use fprintf() .) 
   */
   unsigned int i;
-  const char *p;
 
   if (right_justified) 
     for (i= data_length; i < total_bytes_to_send; i++)
       tee_putc((int)' ', PAGER);
 
-  for (i= 0, p= data; i < data_length; i+= 1, p+= 1)
-  {
-    if (*p == '\0')
-      tee_putc((int)' ', PAGER);
-    else
-      tee_putc((int)*p, PAGER);
-  }
+  tee_write(PAGER, data, data_length, MY_PRINT_SPS_0 | MY_PRINT_MB);
 
   if (! right_justified) 
     for (i= data_length; i < total_bytes_to_send; i++)
@@ -3587,16 +3609,7 @@ print_table_data_vertically(MYSQL_RES *r
         tee_fprintf(PAGER, "%*s: ",(int) max_length,field->name);
       if (cur[off])
       {
-        unsigned int i;
-        const char *p;
-
-        for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1)
-        {
-          if (*p == '\0')
-            tee_putc((int)' ', PAGER);
-          else
-            tee_putc((int)*p, PAGER);
-        }
+        tee_write(PAGER, cur[off], lengths[off], MY_PRINT_SPS_0 | MY_PRINT_MB);
         tee_putc('\n', PAGER);
       }
       else
@@ -3666,16 +3679,7 @@ xmlencode_print(const char *src, uint le
   if (!src)
     tee_fputs("NULL", PAGER);
   else
-  {
-    for (const char *p = src; length; p++, length--)
-    {
-      const char *t;
-      if ((t = array_value(xmlmeta, *p)))
-	tee_fputs(t, PAGER);
-      else
-	tee_putc(*p, PAGER);
-    }
-  }
+    tee_write(PAGER, src, length, MY_PRINT_XML | MY_PRINT_MB);
 }
 
 
@@ -3686,37 +3690,9 @@ safe_put_field(const char *pos,ulong len
     tee_fputs("NULL", PAGER);
   else
   {
-    if (opt_raw_data)
-    {
-      unsigned long i;
-      /* Can't use tee_fputs(), it stops with NUL characters. */
-      for (i= 0; i < length; i++, pos++)
-        tee_putc(*pos, PAGER);
-    }
-    else for (const char *end=pos+length ; pos != end ; pos++)
-    {
-#ifdef USE_MB
-      int l;
-      if (use_mb(charset_info) &&
-          (l = my_ismbchar(charset_info, pos, end)))
-      {
-	  while (l--)
-	    tee_putc(*pos++, PAGER);
-	  pos--;
-	  continue;
-      }
-#endif
-      if (!*pos)
-	tee_fputs("\\0", PAGER); // This makes everything hard
-      else if (*pos == '\t')
-	tee_fputs("\\t", PAGER); // This would destroy tab format
-      else if (*pos == '\n')
-	tee_fputs("\\n", PAGER); // This too
-      else if (*pos == '\\')
-	tee_fputs("\\\\", PAGER);
-	else
-	tee_putc(*pos, PAGER);
-    }
+    int flags= MY_PRINT_MB | (opt_raw_data ? 0 : (MY_PRINT_ESC_0 | MY_PRINT_CTRL));
+    /* Can't use tee_fputs(), it stops with NUL characters. */
+    tee_write(PAGER, pos, length, flags);
   }
 }
 
@@ -4317,7 +4293,29 @@ sql_real_connect(char *host,char *databa
     mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command);
   }
 
-  mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
+  mysql_set_character_set(&mysql, default_charset);
+#ifdef __WIN__
+  uint cnv_errors;
+  String converted_database, converted_user;
+  if (!my_charset_same(&my_charset_utf8mb4_bin, mysql.charset))
+  {
+    /* Convert user and database from UTF8MB4 to connection character set */
+    if (user)
+    {
+      converted_user.copy(user, strlen(user) + 1,
+                          &my_charset_utf8mb4_bin, mysql.charset,
+                          &cnv_errors);
+      user= (char *) converted_user.ptr();
+    }
+    if (database)
+    {
+      converted_database.copy(database, strlen(database) + 1,
+                              &my_charset_utf8mb4_bin, mysql.charset,
+                              &cnv_errors);
+      database= (char *) converted_database.ptr();
+    }
+  }
+#endif
   
   if (opt_plugin_dir && *opt_plugin_dir)
     mysql_options(&mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
@@ -4339,7 +4337,38 @@ sql_real_connect(char *host,char *databa
     }
     return -1;					// Retryable
   }
-  
+
+#ifdef __WIN__
+  /* Convert --execute buffer from UTF8MB4 to connection character set */
+  if (!execute_buffer_conversion_done++ &&
+      status.line_buff &&
+      !status.line_buff->file && /* Convert only -e buffer, not real file */
+      status.line_buff->buffer < status.line_buff->end && /* Non-empty */
+      !my_charset_same(&my_charset_utf8mb4_bin, mysql.charset))
+  {
+    String tmp;
+    size_t len= status.line_buff->end - status.line_buff->buffer;
+    uint dummy_errors;
+    /*
+      Don't convert trailing '\n' character - it was appended during
+      last batch_readline_command() call. 
+      Oherwise we'll get an extra line, which makes some tests fail.
+    */
+    if (status.line_buff->buffer[len - 1] == '\n')
+      len--;
+    if (tmp.copy(status.line_buff->buffer, len,
+                 &my_charset_utf8mb4_bin, mysql.charset, &dummy_errors))
+      return 1;
+
+    /* Free the old line buffer */
+    batch_readline_end(status.line_buff);
+
+    /* Re-initialize line buffer from the converted string */
+    if (!(status.line_buff= batch_readline_command(NULL, (char *) tmp.c_ptr_safe())))
+      return 1;
+  }
+#endif /* __WIN__ */
+
   charset_info= mysql.charset;
   
   connected=1;
@@ -4645,11 +4674,82 @@ static void remove_cntrl(String &buffer)
 }
 
 
+/**
+  Write data to a stream.
+  Various modes, corresponding to --tab, --xml, --raw parameters,
+  are supported.
+
+  @param file   Stream to write to
+  @param s      String to write
+  @param slen   String length
+  @flags        Flags for --tab, --xml, --raw.
+*/
+void tee_write(FILE *file, const char *s, size_t slen, int flags)
+{
+#ifdef __WIN__
+  my_bool is_console= my_win_is_console_cached(file);
+#endif
+  const char *se;
+  for (se= s + slen; s < se; s++)
+  {
+    const char *t;
+
+    if (flags & MY_PRINT_MB)
+    {
+      int mblen;
+      if (use_mb(charset_info) &&
+          (mblen= my_ismbchar(charset_info, s, se)))
+      {
+#ifdef __WIN__
+        if (is_console)
+          my_win_console_write(charset_info, s, mblen);
+        else
+#endif
+        fwrite(s, 1, mblen, file);
+        if (opt_outfile)
+          fwrite(s, 1, mblen, OUTFILE);
+        s+= mblen - 1;
+        continue;
+      }
+    }
+
+    if ((flags & MY_PRINT_XML) && (t= array_value(xmlmeta, *s)))
+      tee_fputs(t, file);
+    else if ((flags & MY_PRINT_SPS_0) && *s == '\0')
+      tee_putc((int) ' ', file);   // This makes everything hard
+    else if ((flags & MY_PRINT_ESC_0) && *s == '\0')
+      tee_fputs("\\0", file);      // This makes everything hard
+    else if ((flags & MY_PRINT_CTRL) && *s == '\t')
+      tee_fputs("\\t", file);      // This would destroy tab format
+    else if ((flags & MY_PRINT_CTRL) && *s == '\n')
+      tee_fputs("\\n", file);      // This too
+    else if ((flags & MY_PRINT_CTRL) && *s == '\\')
+      tee_fputs("\\\\", file);
+    else
+    {
+#ifdef __WIN__
+      if (is_console)
+        my_win_console_putc(charset_info, (int) *s);
+      else
+#endif
+      putc((int) *s, file);
+      if (opt_outfile)
+        putc((int) *s, OUTFILE);
+    }
+  }
+}
+
+
 void tee_fprintf(FILE *file, const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
+#ifdef __WIN__
+  if (my_win_is_console_cached(file))
+    my_win_console_vfprintf(charset_info, fmt, args);
+  else
+#endif
   (void) vfprintf(file, fmt, args);
   va_end(args);
 
@@ -4662,8 +4762,20 @@ void tee_fprintf(FILE *file, const char
 }
 
 
+/*
+  Write a 0-terminated string to file and OUTFILE.
+  TODO: possibly it's nice to have a version with length some day,
+  e.g. tee_fnputs(s, slen, file),
+  to print numerous ASCII constant strings among mysql.cc
+  code, to avoid strlen(s) in my_win_console_fputs().
+*/
 void tee_fputs(const char *s, FILE *file)
 {
+#ifdef __WIN__
+  if (my_win_is_console_cached(file))
+    my_win_console_fputs(charset_info, s);
+  else
+#endif
   fputs(s, file);
   if (opt_outfile)
     fputs(s, OUTFILE);
@@ -4672,17 +4784,17 @@ void tee_fputs(const char *s, FILE *file
 
 void tee_puts(const char *s, FILE *file)
 {
-  fputs(s, file);
-  fputc('\n', file);
-  if (opt_outfile)
-  {
-    fputs(s, OUTFILE);
-    fputc('\n', OUTFILE);
-  }
+  tee_fputs(s, file);
+  tee_putc('\n', file);
 }
 
 void tee_putc(int c, FILE *file)
 {
+#ifdef __WIN__
+  if (my_win_is_console_cached(file))
+    my_win_console_putc(charset_info, c);
+  else
+#endif
   putc(c, file);
   if (opt_outfile)
     putc(c, OUTFILE);

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2011-01-26 20:13:31 +0000
+++ b/client/mysqltest.cc	2011-02-23 04:53:07 +0000
@@ -302,7 +302,7 @@ enum enum_commands {
   Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
   Q_ENABLE_INFO, Q_DISABLE_INFO,
   Q_ENABLE_METADATA, Q_DISABLE_METADATA,
-  Q_EXEC, Q_DELIMITER,
+  Q_EXEC, Q_EXECW, Q_DELIMITER,
   Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR,
   Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
   Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_SORTED_RESULT,
@@ -373,6 +373,7 @@ const char *command_names[]=
   "enable_metadata",
   "disable_metadata",
   "exec",
+  "execw",
   "delimiter",
   "disable_abort_on_error",
   "enable_abort_on_error",
@@ -2750,8 +2751,52 @@ void free_tmp_sh_file()
 #endif
 
 
-FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode)
+FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode,
+               struct st_command *command)
 {
+#if __WIN__
+  /*
+    --execw is for tests executing commands containing non-ASCII characters.
+
+    To correctly start such a program on Windows, we need to use the "wide"
+    version of popen, with prior translation of the command line from
+    the file character set to wide string. We use the current value
+    of --character_set as a file character set, so before using --execw
+    make sure to set --character_set properly.
+
+    If we use the non-wide version of popen, Windows internally
+    converts command line from the current ANSI code page to wide string.
+    In case when character set of the command line does not match the
+    current ANSI code page, non-ASCII characters get garbled in most cases.
+
+    On Linux, the command line passed to popen() is considered
+    as a binary string, no any internal to-wide and from-wide
+    character set conversion happens, so we don't need to do anything.
+    On Linux --execw is just a synonym to --exec.
+
+    For simplicity, assume that  command line is limited to 4KB
+    (like in cmd.exe) and that mode at most 10 characters.
+  */
+  if (command->type == Q_EXECW)
+  {
+    wchar_t wcmd[4096];
+    wchar_t wmode[10];
+    const char *cmd= ds_cmd->str;
+    uint dummy_errors;
+    size_t len;
+    len= my_convert((char *) wcmd, sizeof(wcmd) - sizeof(wcmd[0]),
+                    &my_charset_utf16le_bin,
+                    ds_cmd->str, strlen(ds_cmd->str), charset_info,
+                    &dummy_errors);
+    wcmd[len / sizeof(wchar_t)]= 0;
+    len= my_convert((char *) wmode, sizeof(wmode) - sizeof(wmode[0]),
+                    &my_charset_utf16le_bin,
+                    mode, strlen(mode), charset_info, &dummy_errors);
+    wmode[len / sizeof(wchar_t)]= 0;
+    return _wpopen(wcmd, wmode);
+  }
+#endif /* __WIN__ */
+
 #if defined __WIN__ && defined USE_CYGWIN
   /* Dump the command into a sh script file and execute with popen */
   str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length);
@@ -2888,7 +2933,7 @@ void do_exec(struct st_command *command)
   DBUG_PRINT("info", ("Executing '%s' as '%s'",
                       command->first_argument, ds_cmd.str));
 
-  if (!(res_file= my_popen(&ds_cmd, "r")) && command->abort_on_error)
+  if (!(res_file= my_popen(&ds_cmd, "r", command)) && command->abort_on_error)
   {
     dynstr_free(&ds_cmd);
     die("popen(\"%s\", \"r\") failed", command->first_argument);
@@ -8763,6 +8808,7 @@ int main(int argc, char **argv)
         do_shutdown_server(command);
         break;
       case Q_EXEC:
+      case Q_EXECW:
 	do_exec(command);
 	command_executed++;
 	break;

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2011-02-08 15:54:12 +0000
+++ b/include/my_sys.h	2011-02-23 04:53:07 +0000
@@ -946,9 +946,14 @@ int my_security_attr_create(SECURITY_ATT
 void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
 
 /* implemented in my_conio.c */
-char* my_cgets(char *string, size_t clen, size_t* plen);
-
-#endif
+my_bool my_win_is_console(FILE *file);
+char *my_win_console_readline(CHARSET_INFO *cs, char *mbbuf, size_t mbbufsize);
+void my_win_console_write(CHARSET_INFO *cs, const char *data, size_t datalen);
+void my_win_console_fputs(CHARSET_INFO *cs, const char *data);
+void my_win_console_putc(CHARSET_INFO *cs, int c);
+void my_win_console_vfprintf(CHARSET_INFO *cs, const char *fmt, va_list args);
+int my_win_translate_command_line_args(CHARSET_INFO *cs, int *ac, char ***av);
+#endif /* __WIN__ */
 
 #include <mysql/psi/psi.h>
 

=== modified file 'mysql-test/extra/binlog_tests/ctype_cp932.test'
--- a/mysql-test/extra/binlog_tests/ctype_cp932.test	2008-02-20 18:49:26 +0000
+++ b/mysql-test/extra/binlog_tests/ctype_cp932.test	2011-02-23 11:32:08 +0000
@@ -462,7 +462,8 @@ drop table t1;
 --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
 
 # its usage to switch internally in mysql to requested charset
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '�\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('�\'); select * from t1;  drop table t1;"
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '�\'"
---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select '�\'"
---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select '�\'"
+--character_set latin1
+--execw $MYSQL --default-character-set=latin1 test -e "charset cp932; select '�\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('--default-character-set=latin1 test -e "charset cp932; select '�\'"
+--execw $MYSQL --default-character-set=latin1 test -e "/*charset cp932 */; set names cp932, character_set_results=utf8; select '�\'"
+--execw $MYSQL --default-character-set=latin1 test -e "/*!\C cp932 */; set character_set_client= cp932; select '�\'"

=== added file 'mysql-test/include/check_qep.inc'
--- a/mysql-test/include/check_qep.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/check_qep.inc	2011-02-22 15:44:04 +0000
@@ -0,0 +1,50 @@
+# include/check_qep.inc
+#
+# SUMMARY
+#
+#    Designed to be used together with include/check_qep.inc
+#
+#    $query should be assigned a select statement using 
+#    straight_join to force the tables to be joined in most 
+#    optimal order.
+#
+#    expect_qep.inc will then store the estimated 'Last_query_cost'
+#    and total # 'Handler_read%' for this straight_joined query.
+#
+#    We should then assign a non-straight_join'ed version of
+#    the same query to $query and execute it using 
+#    'include/check_qep.inc'. Its estimated cost and
+#    #handler_reads will then be verified against the
+#    previous straight_joined query.
+#
+# USAGE
+#
+#    let $query= <select straight_join optimal statement>;
+#    --source include/expect_qep.inc
+#    let $query= <select statement>;
+#    --source include/check_qep.inc
+#
+# EXAMPLE
+#    t/greedy_optimizer.test
+#
+
+flush status;
+eval EXPLAIN $query;
+eval $query;
+
+let $cost=
+ query_get_value(SHOW STATUS LIKE 'Last_query_cost', Value, 1);
+
+let $reads=
+`select sum(variable_value)
+   from information_schema.session_status
+   where VARIABLE_NAME like 'Handler_read%'`;
+
+#echo Cost: $cost, Handler_reads: $reads;
+
+if ($cost != $best_cost)
+{ echo ### FAILED: Query_cost: $cost, expected: $best_cost ###;
+}
+if ($reads != $best_reads)
+{ echo ### FAILED: Handler_reads: $reads, expected: $best_reads ###;
+}

=== added file 'mysql-test/include/expect_qep.inc'
--- a/mysql-test/include/expect_qep.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/expect_qep.inc	2011-02-22 15:44:04 +0000
@@ -0,0 +1,44 @@
+# include/expect_qep.inc
+#
+# SUMMARY
+#
+#    Designed to be used together with include/check_qep.inc
+#
+#    $query should be assigned a select statement using 
+#    straight_join to force the tables to be joined in most 
+#    optimal order.
+#
+#    expect_qep.inc will then store the estimated 'Last_query_cost'
+#    and total # 'Handler_read%' for this straight_joined query.
+#
+#    We should then assign a non-straight_join'ed version of
+#    the same query to $query and execute it using 
+#    'include/check_qep.inc'. Its estimated cost and
+#    #handler_reads will then be verified against the
+#    previous straight_joined query.
+#
+# USAGE
+#
+#    let $query= <select straight_join optimal statement>;
+#    --source include/expect_qep.inc
+#    let $query= <select statement>;
+#    --source include/check_qep.inc
+#
+# EXAMPLE
+#    t/greedy_optimizer.test
+#
+
+flush status;
+eval EXPLAIN $query;
+eval $query;
+
+let $best_cost=
+  query_get_value(SHOW STATUS LIKE 'Last_query_cost', Value, 1);
+
+let $best_reads=
+`select sum(variable_value)
+   from information_schema.session_status
+   where VARIABLE_NAME like 'Handler_read%'`;
+
+#echo Expect, cost: $best_cost, Handler_reads: $best_reads;
+

=== modified file 'mysql-test/include/mysqld--help.inc'
--- a/mysql-test/include/mysqld--help.inc	2010-09-30 13:52:39 +0000
+++ b/mysql-test/include/mysqld--help.inc	2011-02-22 05:37:44 +0000
@@ -8,7 +8,7 @@
 # force symbolic-links=0 (valgrind build has a different default)
 #
 
-exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help --verbose > $MYSQL_TMP_DIR/mysqld--help.txt 2>&1;
+exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help --verbose > $MYSQL_TMP_DIR/mysqld--help.txt 2>/dev/null;
 
 # The inline perl code below will copy $MYSQL_TMP_DIR/mysqld--help.txt
 # to output, but filter away some variable stuff (e.g. paths).

=== removed file 'mysql-test/r/crash_commit_before.result'
--- a/mysql-test/r/crash_commit_before.result	2007-04-03 09:36:33 +0000
+++ b/mysql-test/r/crash_commit_before.result	1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-CREATE TABLE t1(a int) engine=innodb;
-START TRANSACTION;
-insert into t1 values(9);
-SET SESSION debug="d,crash_commit_before";
-COMMIT;
-ERROR HY000: Lost connection to MySQL server during query
-SHOW CREATE TABLE t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` int(11) DEFAULT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-SELECT * FROM t1;
-a
-DROP TABLE t1;

=== modified file 'mysql-test/r/ctype_ldml.result'
--- a/mysql-test/r/ctype_ldml.result	2010-12-20 10:28:06 +0000
+++ b/mysql-test/r/ctype_ldml.result	2011-02-22 13:25:05 +0000
@@ -468,6 +468,7 @@ utf8_5624_4	utf8	357			8
 ucs2_test_ci	ucs2	358			8
 ucs2_vn_ci	ucs2	359			8
 ucs2_5624_1	ucs2	360			8
+utf8_5624_5	utf8	368			8
 utf32_test_ci	utf32	391			8
 utf8_maxuserid_ci	utf8	2047			8
 show collation like '%test%';
@@ -1053,5 +1054,82 @@ wa	GROUP_CONCAT(HEX(CONVERT(a USING ucs2
 15D4	09B909CD
 DROP TABLE t1;
 #
+# WL#5624, shift after, using expansion
+#
+SET NAMES utf8 COLLATE utf8_5624_5;
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0;
+INSERT INTO t1 VALUES ('0'),('1'),('0z'),(_ucs2 0x0030FF9D);
+INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'),('i');
+INSERT INTO t1 VALUES ('j'),('k'),('l'),('m'),('n'),('o'),('p'),('q'),('r');
+INSERT INTO t1 VALUES ('s'),('t'),('u'),('v'),('w'),('x'),('y'),('z');
+INSERT INTO t1 VALUES ('aa'),('aaa');
+INSERT INTO t1 VALUES ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I');
+INSERT INTO t1 VALUES ('J'),('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('R');
+INSERT INTO t1 VALUES ('S'),('T'),('U'),('V'),('W'),('X'),('Y'),('Z');
+INSERT INTO t1 VALUES ('AA'),('AAA');
+SELECT a, HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, LENGTH(a), BINARY(a);
+a	HEX(WEIGHT_STRING(a))
+0	0E29
+0z	0E290E292357
+0���	0E291E81
+a	0E29233E
+b	0E29233F
+c	0E292340
+d	0E292341
+e	0E292342
+f	0E292343
+g	0E292344
+h	0E292345
+i	0E292346
+j	0E292347
+k	0E292348
+l	0E292349
+m	0E29234A
+n	0E29234B
+o	0E29234C
+p	0E29234D
+q	0E29234E
+r	0E29234F
+s	0E292350
+t	0E292351
+u	0E292352
+v	0E292353
+w	0E292354
+x	0E292355
+y	0E292356
+z	0E292357
+aa	0E292358
+aaa	0E292359
+A	0E29333E
+B	0E29333F
+C	0E293340
+D	0E293341
+E	0E293342
+F	0E293343
+G	0E293344
+H	0E293345
+I	0E293346
+J	0E293347
+K	0E293348
+L	0E293349
+M	0E29334A
+N	0E29334B
+O	0E29334C
+P	0E29334D
+Q	0E29334E
+R	0E29334F
+S	0E293350
+T	0E293351
+U	0E293352
+V	0E293353
+W	0E293354
+X	0E293355
+Y	0E293356
+Z	0E293357
+AA	0E293358
+AAA	0E293359
+1	0E2A
+DROP TABLE t1;
+#
 # End of WL#5624
 #

=== modified file 'mysql-test/r/ddl_i18n_koi8r.result'
--- a/mysql-test/r/ddl_i18n_koi8r.result	2010-01-15 11:42:15 +0000
+++ b/mysql-test/r/ddl_i18n_koi8r.result	2011-02-22 14:02:49 +0000
@@ -724,7 +724,7 @@ utf8_general_ci	utf8_general_ci
 CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
 
 USE `mysqltest1`;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -757,8 +757,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -791,7 +791,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
 
@@ -800,7 +800,7 @@ ALTER DATABASE mysqltest1 CHARACTER SET
 CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
 
 USE `mysqltest2`;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -833,8 +833,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -867,7 +867,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest2 to ddl_i18n_koi8r.sp.mysqltest2.sql
 
@@ -1742,7 +1742,7 @@ CREATE TABLE `t1` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1770,8 +1770,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1799,7 +1799,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
 
@@ -1821,7 +1821,7 @@ CREATE TABLE `t1` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1849,8 +1849,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1878,7 +1878,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest2 to ddl_i18n_koi8r.triggers.mysqltest2.sql
 
@@ -2486,7 +2486,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/
 USE `mysqltest1`;
 /*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
 DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2512,9 +2512,9 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2540,7 +2540,7 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;
 /*!50106 SET TIME_ZONE= @save_time_zone */ ;
 
@@ -2553,7 +2553,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/
 USE `mysqltest2`;
 /*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
 DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2579,9 +2579,9 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2607,7 +2607,7 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;
 /*!50106 SET TIME_ZONE= @save_time_zone */ ;
 

=== modified file 'mysql-test/r/ddl_i18n_utf8.result'
--- a/mysql-test/r/ddl_i18n_utf8.result	2010-01-15 11:42:15 +0000
+++ b/mysql-test/r/ddl_i18n_utf8.result	2011-02-22 14:02:49 +0000
@@ -724,7 +724,7 @@ utf8_general_ci	utf8_general_ci
 CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */;
 
 USE `mysqltest1`;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -757,8 +757,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -791,7 +791,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
 
@@ -800,7 +800,7 @@ ALTER DATABASE mysqltest1 CHARACTER SET
 CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */;
 
 USE `mysqltest2`;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -833,8 +833,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -867,7 +867,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest2 to ddl_i18n_utf8sp.mysqltest2.sql
 
@@ -1742,7 +1742,7 @@ CREATE TABLE `t1` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1770,8 +1770,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1799,7 +1799,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
 
@@ -1821,7 +1821,7 @@ CREATE TABLE `t1` (
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 INSERT INTO `t1` VALUES (1),(0),(1);
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1849,8 +1849,8 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;
@@ -1878,7 +1878,7 @@ DELIMITER ;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;
 /*!50003 SET character_set_results = @saved_cs_results */ ;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;
 
 ---> Dumping mysqltest2 to ddl_i18n_utf8triggers.mysqltest2.sql
 
@@ -2486,7 +2486,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/
 USE `mysqltest1`;
 /*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
 DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2512,9 +2512,9 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;;
-ALTER DATABASE mysqltest1 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2540,7 +2540,7 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest1 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;
 /*!50106 SET TIME_ZONE= @save_time_zone */ ;
 
@@ -2553,7 +2553,7 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/
 USE `mysqltest2`;
 /*!50106 SET @save_time_zone= @@TIME_ZONE */ ;
 DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2579,9 +2579,9 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;;
-ALTER DATABASE mysqltest2 CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;;
 /*!50003 SET @saved_cs_results     = @@character_set_results */ ;;
 /*!50003 SET @saved_col_connection = @@collation_connection */ ;;
@@ -2607,7 +2607,7 @@ END */ ;;
 /*!50003 SET character_set_client  = @saved_cs_client */ ;;
 /*!50003 SET character_set_results = @saved_cs_results */ ;;
 /*!50003 SET collation_connection  = @saved_col_connection */ ;;
-ALTER DATABASE mysqltest2 CHARACTER SET cp866 COLLATE cp866_general_ci ;;
+ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ;;
 DELIMITER ;
 /*!50106 SET TIME_ZONE= @save_time_zone */ ;
 

=== modified file 'mysql-test/r/greedy_optimizer.result'
--- a/mysql-test/r/greedy_optimizer.result	2011-02-17 11:38:07 +0000
+++ b/mysql-test/r/greedy_optimizer.result	2011-02-22 14:24:33 +0000
@@ -124,16 +124,16 @@ select @@optimizer_search_depth;
 0
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1372.458334
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -147,16 +147,16 @@ Total_handler_reads
 46
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1372.458334
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -172,14 +172,14 @@ EXPLAIN select t1.c11 from t1, t2, t3, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.430791
+Last_query_cost	362.673673
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -190,19 +190,19 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-1338
+114
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.430791
+Last_query_cost	362.673673
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -213,19 +213,19 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-1338
+114
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.469776
+Last_query_cost	362.776403
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -238,14 +238,14 @@ EXPLAIN select t1.c11 from t7, t6, t5, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.469776
+Last_query_cost	362.776403
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -269,7 +269,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	822.001607
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -292,7 +292,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	822.001607
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -315,7 +315,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.014136
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -338,7 +338,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.014136
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -361,7 +361,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.340548
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -381,7 +381,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.340548
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -396,16 +396,16 @@ select @@optimizer_search_depth;
 62
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1372.458334
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -419,16 +419,16 @@ Total_handler_reads
 46
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1372.458334
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -444,14 +444,14 @@ EXPLAIN select t1.c11 from t1, t2, t3, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.430791
+Last_query_cost	362.673673
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -462,19 +462,19 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-1338
+114
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.430791
+Last_query_cost	362.673673
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -485,19 +485,19 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-1338
+114
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.469776
+Last_query_cost	362.776403
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -510,14 +510,14 @@ EXPLAIN select t1.c11 from t7, t6, t5, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t1	eq_ref	PRIMARY	PRIMARY	4	test.t2.c21	1	Using where
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
+1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	289.469776
+Last_query_cost	362.776403
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -538,14 +538,14 @@ EXPLAIN select t1.c11 from t1, t2, t3, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -561,14 +561,14 @@ EXPLAIN select t1.c11 from t7, t6, t5, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -583,15 +583,15 @@ Total_handler_reads
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	794.968437
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -606,15 +606,15 @@ Total_handler_reads
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	794.968437
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -629,15 +629,15 @@ Total_handler_reads
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.085394
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -645,19 +645,19 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-24
+6
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.085394
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -665,7 +665,7 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-24
+6
 set optimizer_search_depth=1;
 select @@optimizer_search_depth;
 @@optimizer_search_depth
@@ -681,7 +681,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	822.001607
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -704,7 +704,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	822.001607
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -727,7 +727,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.014136
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -750,7 +750,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.014136
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -773,7 +773,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.340548
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -793,7 +793,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.340548
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -810,14 +810,14 @@ EXPLAIN select t1.c11 from t1, t2, t3, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -833,14 +833,14 @@ EXPLAIN select t1.c11 from t7, t6, t5, t
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t4.c42	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t2.c22	1	Using where
 1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t6.c62	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	821.936459
+Last_query_cost	1693.801607
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c12 = t2.c21 and t2.c22 = t3.c31 and t3.c32 = t4.c41 and t4.c42 = t5.c51 and t5.c52 = t6.c61 and t6.c62 = t7.c71;
 c11
@@ -855,15 +855,15 @@ Total_handler_reads
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	794.968437
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -878,15 +878,15 @@ Total_handler_reads
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using index
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using index
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using index
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	794.968437
+Last_query_cost	844.214136
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71;
 c11
@@ -901,15 +901,15 @@ Total_handler_reads
 EXPLAIN select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.085394
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t1, t2, t3, t4, t5, t6, t7 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -917,19 +917,19 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-24
+6
 EXPLAIN select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	PRIMARY	NULL	NULL	NULL	3	Using where
+1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	
+1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
+1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	6	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t4	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (BNL, incremental buffers)
 1	SIMPLE	t6	ALL	NULL	NULL	NULL	NULL	18	Using where; Using join buffer (BNL, incremental buffers)
-1	SIMPLE	t5	eq_ref	PRIMARY	PRIMARY	4	test.t1.c14	1	Using where
-1	SIMPLE	t3	eq_ref	PRIMARY	PRIMARY	4	test.t1.c12	1	Using where
-1	SIMPLE	t7	eq_ref	PRIMARY	PRIMARY	4	test.t1.c16	1	Using where
 SHOW STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	795.085394
+Last_query_cost	844.540548
 FLUSH STATUS;
 select t1.c11 from t7, t6, t5, t4, t3, t2, t1 where t1.c11 = t2.c21 and t1.c12 = t3.c31 and t1.c13 = t4.c41 and t1.c14 = t5.c51 and t1.c15 = t6.c61 and t1.c16 = t7.c71 and t2.c22 = t3.c32 and t2.c23 = t4.c42 and t2.c24 = t5.c52 and t2.c25 = t6.c62 and t2.c26 = t7.c72 and t3.c33 = t4.c43 and t3.c34 = t5.c53 and t3.c35 = t6.c63 and t3.c36 = t7.c73 and t4.c42 = t5.c54 and t4.c43 = t6.c64 and t4.c44 = t7.c74 and t5.c52 = t6.c65 and t5.c53 = t7.c75 and t6.c62 = t7.c76;
 c11
@@ -937,7 +937,7 @@ SELECT SUM(variable_value) AS Total_hand
 FROM information_schema.session_status
 WHERE variable_name LIKE 'Handler_read%';
 Total_handler_reads
-24
+6
 drop table t1,t2,t3,t4,t5,t6,t7;
 CREATE TABLE t1 (a int, b int, d int, i int);
 INSERT INTO t1 VALUES (1,1,1,1);
@@ -1016,3 +1016,1746 @@ t4 LEFT JOIN (t5 JOIN t5_1 ON t5.l = t5_
 SET optimizer_search_depth = DEFAULT;
 DROP TABLE t1,t2,t2_1,t3,t3_1,t4,t4_1,t5,t5_1;
 End of 5.0 tests
+#
+# Bug #59326: Greedy optimizer produce stupid query execution plans.
+#
+CREATE TABLE t10(
+K INT NOT NULL AUTO_INCREMENT,
+I INT,
+PRIMARY KEY(K)
+);
+INSERT INTO t10(I) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(0);
+CREATE TABLE t100 LIKE t10;
+INSERT INTO t100(I)
+SELECT X.I FROM t10 AS X,t10 AS Y;
+CREATE TABLE t10000 LIKE t10;
+INSERT INTO t10000(I)
+SELECT X.I FROM t100 AS X, t100 AS Y;
+EXPLAIN SELECT * FROM t10,t100,t10000;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using join buffer (BNL, incremental buffers)
+EXPLAIN SELECT * FROM t10,t10000,t100;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using join buffer (BNL, incremental buffers)
+EXPLAIN SELECT * FROM t100,t10,t10000;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using join buffer (BNL, incremental buffers)
+EXPLAIN SELECT * FROM t100,t10000,t10;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using join buffer (BNL, incremental buffers)
+EXPLAIN SELECT * FROM t10000,t10,t100;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using join buffer (BNL, incremental buffers)
+EXPLAIN SELECT * FROM t10000,t100,t10;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using join buffer (BNL, incremental buffers)
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t100.K	1	Using where; Using index
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t100.K	1	Using where; Using index
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t100.K	1	Using where; Using index
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	PRIMARY	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.K	1	Using index
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	PRIMARY	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.K	1	Using index
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t100,t10,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	PRIMARY	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.K	1	Using index
+SELECT COUNT(*) FROM t100,t10,t10000
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t100,t10000,t10
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	PRIMARY	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.K	1	Using index
+SELECT COUNT(*) FROM t100,t10000,t10
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10000,t10,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	PRIMARY	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.K	1	Using index
+SELECT COUNT(*) FROM t10000,t10,t100
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10000,t100,t10
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	PRIMARY	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.K	1	Using index
+SELECT COUNT(*) FROM t10000,t100,t10
+WHERE t100.K=t10.I
+AND t10000.K=t10.K;
+COUNT(*)
+9
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+90
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.I=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.I=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+90
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t10.I;
+COUNT(*)
+90
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t100.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t100.I;
+COUNT(*)
+90
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.I=t10.I
+AND t10000.K=t100.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.I=t10.I
+AND t10000.K=t100.I;
+COUNT(*)
+90
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t100.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	t10000	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t100	ALL	NULL	NULL	NULL	NULL	100	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+AND t10000.K=t100.I;
+COUNT(*)
+90
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	index	NULL	PRIMARY	4	NULL	10000	Using index; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+COUNT(*)
+90000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	index	NULL	PRIMARY	4	NULL	10000	Using index; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+COUNT(*)
+90000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	index	NULL	PRIMARY	4	NULL	10000	Using index; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I;
+COUNT(*)
+90000
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=X.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	ALL	NULL	NULL	NULL	NULL	10	Using where
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ALL	NULL	NULL	NULL	NULL	10000	Using where; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=X.K;
+COUNT(*)
+9000
+CREATE INDEX IX ON t10(I);
+CREATE INDEX IX ON t100(I);
+CREATE INDEX IX ON t10000(I);
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	ref	IX	IX	5	test.t100.K	1000	Using where; Using index
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	ref	IX	IX	5	test.t100.K	1000	Using where; Using index
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	t100	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	t10000	ref	IX	IX	5	test.t100.K	1000	Using where; Using index
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+AND t10000.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	index	NULL	PRIMARY	4	NULL	10000	Using index; Using join buffer (BNL, incremental buffers)
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+COUNT(*)
+90000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	index	NULL	PRIMARY	4	NULL	10000	Using index; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+COUNT(*)
+90000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	index	NULL	PRIMARY	4	NULL	10000	Using index; Using join buffer (BNL, incremental buffers)
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I;
+COUNT(*)
+90000
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ref	IX	IX	5	test.X.K	1000	Using where; Using index
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ref	IX	IX	5	test.X.K	1000	Using where; Using index
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ref	IX	IX	5	test.X.K	1000	Using where; Using index
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=t10.I;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ref	IX	IX	5	test.X.K	1000	Using where; Using index
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ref	IX	IX	5	test.X.K	1000	Using where; Using index
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+AND Y.I=X.K;
+COUNT(*)
+9000
+flush status;
+EXPLAIN SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=X.K;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t10	index	IX	IX	5	NULL	10	Using where; Using index
+1	SIMPLE	X	eq_ref	PRIMARY	PRIMARY	4	test.t10.I	1	Using index
+1	SIMPLE	Y	ref	IX	IX	5	test.X.K	1000	Using where; Using index
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+AND Y.I=X.K;
+COUNT(*)
+9000
+#
+# Test improved capabilities of analyzing complex query
+# plans without restricting 'optimizer_search_depth'.
+# Fix problems like those reported as bug#41740 & bug#58225. 
+#
+# EPLAIN of queries using T1-T62 will timeout/hang wo/ fixes
+#
+DROP TABLE t10, t10000;
+CREATE TABLE T1 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T1(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 1;
+CREATE TABLE T2 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T2(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 2;
+CREATE TABLE T3 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T3(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 3;
+CREATE TABLE T4 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T4(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 4;
+CREATE TABLE T5 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T5(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 5;
+CREATE TABLE T6 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T6(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 6;
+CREATE TABLE T7 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T7(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 7;
+CREATE TABLE T8 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T8(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 8;
+CREATE TABLE T9 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T9(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 9;
+CREATE TABLE T10 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T10(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 10;
+CREATE TABLE T11 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T11(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 11;
+CREATE TABLE T12 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T12(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 12;
+CREATE TABLE T13 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T13(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 13;
+CREATE TABLE T14 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T14(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 14;
+CREATE TABLE T15 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T15(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 15;
+CREATE TABLE T16 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T16(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 16;
+CREATE TABLE T17 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T17(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 17;
+CREATE TABLE T18 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T18(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 18;
+CREATE TABLE T19 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T19(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 19;
+CREATE TABLE T20 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T20(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 20;
+CREATE TABLE T21 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T21(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 21;
+CREATE TABLE T22 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T22(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 22;
+CREATE TABLE T23 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T23(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 23;
+CREATE TABLE T24 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T24(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 24;
+CREATE TABLE T25 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T25(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 25;
+CREATE TABLE T26 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T26(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 26;
+CREATE TABLE T27 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T27(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 27;
+CREATE TABLE T28 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T28(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 28;
+CREATE TABLE T29 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T29(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 29;
+CREATE TABLE T30 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T30(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 30;
+CREATE TABLE T31 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T31(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 31;
+CREATE TABLE T32 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T32(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 32;
+CREATE TABLE T33 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T33(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 33;
+CREATE TABLE T34 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T34(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 34;
+CREATE TABLE T35 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T35(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 35;
+CREATE TABLE T36 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T36(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 36;
+CREATE TABLE T37 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T37(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 37;
+CREATE TABLE T38 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T38(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 38;
+CREATE TABLE T39 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T39(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 39;
+CREATE TABLE T40 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T40(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 40;
+CREATE TABLE T41 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T41(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 41;
+CREATE TABLE T42 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T42(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 42;
+CREATE TABLE T43 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T43(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 43;
+CREATE TABLE T44 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T44(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 44;
+CREATE TABLE T45 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T45(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 45;
+CREATE TABLE T46 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T46(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 46;
+CREATE TABLE T47 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T47(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 47;
+CREATE TABLE T48 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T48(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 48;
+CREATE TABLE T49 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T49(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 49;
+CREATE TABLE T50 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T50(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 50;
+CREATE TABLE T51 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T51(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 51;
+CREATE TABLE T52 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T52(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 52;
+CREATE TABLE T53 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T53(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 53;
+CREATE TABLE T54 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T54(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 54;
+CREATE TABLE T55 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T55(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 55;
+CREATE TABLE T56 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T56(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 56;
+CREATE TABLE T57 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T57(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 57;
+CREATE TABLE T58 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T58(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 58;
+CREATE TABLE T59 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T59(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 59;
+CREATE TABLE T60 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T60(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 60;
+CREATE TABLE T61 ( K INT NOT NULL AUTO_INCREMENT,
+I INT,
+A INT,
+PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+INSERT INTO T61(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= 61;
+ANALYZE TABLE t100, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50, T51, T52, T53, T54, T55, T56, T57, T58, T59, T60, T61;
+set optimizer_prune_level=1;
+set optimizer_search_depth=0;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I JOIN T60 ON T60.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I JOIN T49 as T49 ON T49.I=X.I JOIN T49 as T50 ON T50.I=X.I JOIN T49 as T51 ON T51.I=X.I JOIN T49 as T52 ON T52.I=X.I JOIN T49 as T53 ON T53.I=X.I JOIN T49 as T54 ON T54.I=X.I JOIN T49 as T55 ON T55.I=X.I JOIN T49 as T56 ON T56.I=X.I;
+set optimizer_search_depth=1;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I JOIN T60 ON T60.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I JOIN T49 as T49 ON T49.I=X.I JOIN T49 as T50 ON T50.I=X.I JOIN T49 as T51 ON T51.I=X.I JOIN T49 as T52 ON T52.I=X.I JOIN T49 as T53 ON T53.I=X.I JOIN T49 as T54 ON T54.I=X.I JOIN T49 as T55 ON T55.I=X.I JOIN T49 as T56 ON T56.I=X.I;
+set optimizer_search_depth=3;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I JOIN T60 ON T60.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I JOIN T49 as T49 ON T49.I=X.I JOIN T49 as T50 ON T50.I=X.I JOIN T49 as T51 ON T51.I=X.I JOIN T49 as T52 ON T52.I=X.I JOIN T49 as T53 ON T53.I=X.I JOIN T49 as T54 ON T54.I=X.I JOIN T49 as T55 ON T55.I=X.I JOIN T49 as T56 ON T56.I=X.I;
+set optimizer_search_depth=62;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 ON T1.I=X.I JOIN T2 ON T2.I=X.I JOIN T3 ON T3.I=X.I JOIN T4 ON T4.I=X.I JOIN T5 ON T5.I=X.I JOIN T6 ON T6.I=X.I JOIN T7 ON T7.I=X.I JOIN T8 ON T8.I=X.I JOIN T9 ON T9.I=X.I JOIN T10 ON T10.I=X.I JOIN T11 ON T11.I=X.I JOIN T12 ON T12.I=X.I JOIN T13 ON T13.I=X.I JOIN T14 ON T14.I=X.I JOIN T15 ON T15.I=X.I JOIN T16 ON T16.I=X.I JOIN T17 ON T17.I=X.I JOIN T18 ON T18.I=X.I JOIN T19 ON T19.I=X.I JOIN T20 ON T20.I=X.I JOIN T21 ON T21.I=X.I JOIN T22 ON T22.I=X.I JOIN T23 ON T23.I=X.I JOIN T24 ON T24.I=X.I JOIN T25 ON T25.I=X.I JOIN T26 ON T26.I=X.I JOIN T27 ON T27.I=X.I JOIN T28 ON T28.I=X.I JOIN T29 ON T29.I=X.I JOIN T30 ON T30.I=X.I JOIN T31 ON T31.I=X.I JOIN T32 ON T32.I=X.I JOIN T33 ON T33.I=X.I JOIN T34 ON T34.I=X.I JOIN T35 ON T35.I=X.I JOIN T36 ON T36.I=X.I JOIN T37 ON T37.I=X.I JOIN T38 ON T38.I=X.I JOIN T39 ON T39.I=X.I JOIN T40 ON T40.I=X.I JOIN T41 ON T41.I=X.I JOIN T42 ON T42.I=X.I JOIN T43 ON T43.I=X.I JOIN T44 ON T44.I=X.I JOIN T45 ON T45.I=X.I JOIN T46 ON T46.I=X.I JOIN T47 ON T47.I=X.I JOIN T48 ON T48.I=X.I JOIN T49 ON T49.I=X.I JOIN T50 ON T50.I=X.I JOIN T51 ON T51.I=X.I JOIN T52 ON T52.I=X.I JOIN T53 ON T53.I=X.I JOIN T54 ON T54.I=X.I JOIN T55 ON T55.I=X.I JOIN T56 ON T56.I=X.I JOIN T57 ON T57.I=X.I JOIN T58 ON T58.I=X.I JOIN T59 ON T59.I=X.I JOIN T60 ON T60.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I;
+select @@optimizer_prune_level;
+select @@optimizer_search_depth;
+EXPLAIN SELECT COUNT(*) FROM T1 AS X JOIN T1 as T1 ON T1.I=X.I JOIN T1 as T2 ON T2.I=X.I JOIN T1 as T3 ON T3.I=X.I JOIN T1 as T4 ON T4.I=X.I JOIN T1 as T5 ON T5.I=X.I JOIN T1 as T6 ON T6.I=X.I JOIN T1 as T7 ON T7.I=X.I JOIN T1 as T8 ON T8.I=X.I JOIN T9 as T9 ON T9.I=X.I JOIN T9 as T10 ON T10.I=X.I JOIN T9 as T11 ON T11.I=X.I JOIN T9 as T12 ON T12.I=X.I JOIN T9 as T13 ON T13.I=X.I JOIN T9 as T14 ON T14.I=X.I JOIN T9 as T15 ON T15.I=X.I JOIN T9 as T16 ON T16.I=X.I JOIN T17 as T17 ON T17.I=X.I JOIN T17 as T18 ON T18.I=X.I JOIN T17 as T19 ON T19.I=X.I JOIN T17 as T20 ON T20.I=X.I JOIN T17 as T21 ON T21.I=X.I JOIN T17 as T22 ON T22.I=X.I JOIN T17 as T23 ON T23.I=X.I JOIN T17 as T24 ON T24.I=X.I JOIN T25 as T25 ON T25.I=X.I JOIN T25 as T26 ON T26.I=X.I JOIN T25 as T27 ON T27.I=X.I JOIN T25 as T28 ON T28.I=X.I JOIN T25 as T29 ON T29.I=X.I JOIN T25 as T30 ON T30.I=X.I JOIN T25 as T31 ON T31.I=X.I JOIN T25 as T32 ON T32.I=X.I JOIN T33 as T33 ON T33.I=X.I JOIN T33 as T34 ON T34.I=X.I JOIN T33 as T35 ON T35.I=X.I JOIN T33 as T36 ON T36.I=X.I JOIN T33 as T37 ON T37.I=X.I JOIN T33 as T38 ON T38.I=X.I JOIN T33 as T39 ON T39.I=X.I JOIN T33 as T40 ON T40.I=X.I JOIN T41 as T41 ON T41.I=X.I JOIN T41 as T42 ON T42.I=X.I JOIN T41 as T43 ON T43.I=X.I JOIN T41 as T44 ON T44.I=X.I JOIN T41 as T45 ON T45.I=X.I JOIN T41 as T46 ON T46.I=X.I JOIN T41 as T47 ON T47.I=X.I JOIN T41 as T48 ON T48.I=X.I JOIN T49 as T49 ON T49.I=X.I JOIN T49 as T50 ON T50.I=X.I JOIN T49 as T51 ON T51.I=X.I JOIN T49 as T52 ON T52.I=X.I JOIN T49 as T53 ON T53.I=X.I JOIN T49 as T54 ON T54.I=X.I JOIN T49 as T55 ON T55.I=X.I JOIN T49 as T56 ON T56.I=X.I;
+DROP TABLE t100, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50, T51, T52, T53, T54, T55, T56, T57, T58, T59, T60, T61;
+SET OPTIMIZER_SEARCH_DEPTH = DEFAULT;
+END OF 5.6 TESTS

=== modified file 'mysql-test/r/join.result'
--- a/mysql-test/r/join.result	2010-12-16 17:38:26 +0000
+++ b/mysql-test/r/join.result	2011-02-22 14:24:33 +0000
@@ -895,7 +895,7 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	B	eq_ref	PRIMARY	PRIMARY	4	test.A.b	1	
 show status like '%cost%';
 Variable_name	Value
-Last_query_cost	24.016090
+Last_query_cost	28.016090
 select '^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error' Z;
 Z
 ^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error

=== modified file 'mysql-test/r/join_cache_jcl1.result'
--- a/mysql-test/r/join_cache_jcl1.result	2011-02-17 13:25:01 +0000
+++ b/mysql-test/r/join_cache_jcl1.result	2011-02-22 14:24:33 +0000
@@ -1311,11 +1311,11 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t5	eq_ref	PRIMARY,t5_formattypeid	PRIMARY	4	test.t4.formatclassid	1	Using where
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	
 1	SIMPLE	t7	ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	Using index
-1	SIMPLE	t3	ref	t3_metaid,t3_formatid,t3_metaidformatid	t3_metaid	4	test.t1.metaid	2	Using where
 1	SIMPLE	t8	eq_ref	PRIMARY	PRIMARY	4	test.t7.artistid	1	
-1	SIMPLE	t9	index	PRIMARY,t9_subgenreid,t9_metaid	PRIMARY	8	NULL	2	Using where; Using index; Using join buffer (BNL, regular buffers)
+1	SIMPLE	t9	ref	PRIMARY,t9_subgenreid,t9_metaid	t9_metaid	4	test.t7.metaid	2	Using index condition
 1	SIMPLE	t10	eq_ref	PRIMARY,t10_genreid	PRIMARY	4	test.t9.subgenreid	1	
 1	SIMPLE	t11	eq_ref	PRIMARY	PRIMARY	4	test.t10.genreid	1	
+1	SIMPLE	t3	ALL	t3_metaid,t3_formatid,t3_metaidformatid	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, regular buffers)
 SELECT t1.uniquekey, t1.xml AS affiliateXml,
 t8.name AS artistName, t8.artistid, 
 t11.name AS genreName, t11.genreid, t11.priority AS genrePriority,

=== modified file 'mysql-test/r/join_cache_jcl2.result'
--- a/mysql-test/r/join_cache_jcl2.result	2011-02-17 13:25:01 +0000
+++ b/mysql-test/r/join_cache_jcl2.result	2011-02-22 14:24:33 +0000
@@ -1311,11 +1311,11 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t5	eq_ref	PRIMARY,t5_formattypeid	PRIMARY	4	test.t4.formatclassid	1	Using where
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	
 1	SIMPLE	t7	ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	Using index
-1	SIMPLE	t3	ref	t3_metaid,t3_formatid,t3_metaidformatid	t3_metaid	4	test.t1.metaid	2	Using where
 1	SIMPLE	t8	eq_ref	PRIMARY	PRIMARY	4	test.t7.artistid	1	
-1	SIMPLE	t9	index	PRIMARY,t9_subgenreid,t9_metaid	PRIMARY	8	NULL	2	Using where; Using index; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t9	ref	PRIMARY,t9_subgenreid,t9_metaid	t9_metaid	4	test.t7.metaid	2	Using index condition
 1	SIMPLE	t10	eq_ref	PRIMARY,t10_genreid	PRIMARY	4	test.t9.subgenreid	1	
 1	SIMPLE	t11	eq_ref	PRIMARY	PRIMARY	4	test.t10.genreid	1	
+1	SIMPLE	t3	ALL	t3_metaid,t3_formatid,t3_metaidformatid	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, incremental buffers)
 SELECT t1.uniquekey, t1.xml AS affiliateXml,
 t8.name AS artistName, t8.artistid, 
 t11.name AS genreName, t11.genreid, t11.priority AS genrePriority,

=== modified file 'mysql-test/r/join_cache_jcl3.result'
--- a/mysql-test/r/join_cache_jcl3.result	2011-02-17 13:25:01 +0000
+++ b/mysql-test/r/join_cache_jcl3.result	2011-02-22 14:24:33 +0000
@@ -1311,11 +1311,11 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t5	eq_ref	PRIMARY,t5_formattypeid	PRIMARY	4	test.t4.formatclassid	1	Using where
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	
 1	SIMPLE	t7	ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	Using index
-1	SIMPLE	t3	ref	t3_metaid,t3_formatid,t3_metaidformatid	t3_metaid	4	test.t1.metaid	2	Using where
 1	SIMPLE	t8	eq_ref	PRIMARY	PRIMARY	4	test.t7.artistid	1	
-1	SIMPLE	t9	index	PRIMARY,t9_subgenreid,t9_metaid	PRIMARY	8	NULL	2	Using where; Using index; Using join buffer (BNL, regular buffers)
+1	SIMPLE	t9	ref	PRIMARY,t9_subgenreid,t9_metaid	t9_metaid	4	test.t7.metaid	2	Using index condition
 1	SIMPLE	t10	eq_ref	PRIMARY,t10_genreid	PRIMARY	4	test.t9.subgenreid	1	
 1	SIMPLE	t11	eq_ref	PRIMARY	PRIMARY	4	test.t10.genreid	1	
+1	SIMPLE	t3	ALL	t3_metaid,t3_formatid,t3_metaidformatid	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, regular buffers)
 SELECT t1.uniquekey, t1.xml AS affiliateXml,
 t8.name AS artistName, t8.artistid, 
 t11.name AS genreName, t11.genreid, t11.priority AS genrePriority,

=== modified file 'mysql-test/r/join_cache_jcl4.result'
--- a/mysql-test/r/join_cache_jcl4.result	2011-02-17 13:25:01 +0000
+++ b/mysql-test/r/join_cache_jcl4.result	2011-02-22 14:24:33 +0000
@@ -1311,11 +1311,11 @@ id	select_type	table	type	possible_keys
 1	SIMPLE	t5	eq_ref	PRIMARY,t5_formattypeid	PRIMARY	4	test.t4.formatclassid	1	Using where
 1	SIMPLE	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	
 1	SIMPLE	t7	ref	PRIMARY	PRIMARY	4	test.t1.metaid	1	Using index
-1	SIMPLE	t3	ref	t3_metaid,t3_formatid,t3_metaidformatid	t3_metaid	4	test.t1.metaid	2	Using where
 1	SIMPLE	t8	eq_ref	PRIMARY	PRIMARY	4	test.t7.artistid	1	
-1	SIMPLE	t9	index	PRIMARY,t9_subgenreid,t9_metaid	PRIMARY	8	NULL	2	Using where; Using index; Using join buffer (BNL, incremental buffers)
+1	SIMPLE	t9	ref	PRIMARY,t9_subgenreid,t9_metaid	t9_metaid	4	test.t7.metaid	2	Using index condition
 1	SIMPLE	t10	eq_ref	PRIMARY,t10_genreid	PRIMARY	4	test.t9.subgenreid	1	
 1	SIMPLE	t11	eq_ref	PRIMARY	PRIMARY	4	test.t10.genreid	1	
+1	SIMPLE	t3	ALL	t3_metaid,t3_formatid,t3_metaidformatid	NULL	NULL	NULL	2	Using where; Using join buffer (BNL, incremental buffers)
 SELECT t1.uniquekey, t1.xml AS affiliateXml,
 t8.name AS artistName, t8.artistid, 
 t11.name AS genreName, t11.genreid, t11.priority AS genrePriority,

=== modified file 'mysql-test/r/lock.result'
--- a/mysql-test/r/lock.result	2010-02-01 11:43:06 +0000
+++ b/mysql-test/r/lock.result	2011-01-26 22:06:30 +0000
@@ -385,18 +385,7 @@ ERROR HY000: Can't reopen table: 't1'
 alter table t1 add column j int;
 unlock tables;
 drop table t1;
-#
-# Separate case for partitioned tables is important
-# because each partition has an own thr_lock object.
-#
-create table t1 (i int) partition by list (i)
-(partition p0 values in (1),
-partition p1 values in (2,3),
-partition p2 values in (4,5));
-lock tables t1 write, t1 as a read, t1 as b read;
-alter table t1 add column j int;
-unlock tables;
-drop table t1;
+# Moved case for partitioned tables to partition.test
 #
 # Bug #43272 HANDLER SQL command does not work under LOCK TABLES
 #

=== modified file 'mysql-test/r/log_state.result'
--- a/mysql-test/r/log_state.result	2010-11-02 11:53:54 +0000
+++ b/mysql-test/r/log_state.result	2011-02-10 11:13:41 +0000
@@ -41,7 +41,7 @@ select sleep(@long_query_time + 1);
 sleep(@long_query_time + 1)
 0
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
 # Switch to connection default
 set global slow_query_log= ON;
 # Switch to connection con1
@@ -50,8 +50,8 @@ select sleep(@long_query_time + 1);
 sleep(@long_query_time + 1)
 0
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
-TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	select sleep(@long_query_time + 1)
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
+TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	QUERY	THREAD_ID
 # Switch to connection default
 show global variables
 where Variable_name = 'log' or Variable_name = 'log_slow_queries' or

=== modified file 'mysql-test/r/log_tables.result'
--- a/mysql-test/r/log_tables.result	2010-11-15 16:43:41 +0000
+++ b/mysql-test/r/log_tables.result	2011-02-22 05:37:44 +0000
@@ -17,7 +17,7 @@ event_time	user_host	thread_id	server_id
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
 truncate table slow_log;
 select * from slow_log;
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
 truncate table general_log;
 select * from general_log where argument like '%general_log%';
 event_time	user_host	thread_id	server_id	command_type	argument
@@ -81,7 +81,8 @@ slow_log	CREATE TABLE `slow_log` (
   `last_insert_id` int(11) NOT NULL,
   `insert_id` int(11) NOT NULL,
   `server_id` int(10) unsigned NOT NULL,
-  `sql_text` mediumtext NOT NULL
+  `sql_text` mediumtext NOT NULL,
+  `thread_id` int(11) NOT NULL
 ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
 show fields from mysql.slow_log;
 Field	Type	Null	Key	Default	Extra
@@ -96,6 +97,7 @@ last_insert_id	int(11)	NO		NULL
 insert_id	int(11)	NO		NULL	
 server_id	int(10) unsigned	NO		NULL	
 sql_text	mediumtext	NO		NULL	
+thread_id	int(11)	NO		NULL	
 flush logs;
 flush tables;
 SET GLOBAL GENERAL_LOG=ON;
@@ -146,8 +148,8 @@ select sleep(2);
 sleep(2)
 0
 select * from mysql.slow_log;
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
-TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	mysql	0	0	1	select sleep(2)
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
+TIMESTAMP	USER_HOST	QUERY_TIME	00:00:00	1	0	mysql	0	0	1	QUERY	THREAD_ID
 set @@session.long_query_time = @saved_long_query_time;
 alter table mysql.general_log engine=myisam;
 ERROR HY000: You cannot 'ALTER' a log table if logging is enabled
@@ -184,7 +186,8 @@ slow_log	CREATE TABLE `slow_log` (
   `last_insert_id` int(11) NOT NULL,
   `insert_id` int(11) NOT NULL,
   `server_id` int(10) unsigned NOT NULL,
-  `sql_text` mediumtext NOT NULL
+  `sql_text` mediumtext NOT NULL,
+  `thread_id` int(11) NOT NULL
 ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
 alter table mysql.general_log engine=myisam;
 alter table mysql.slow_log engine=myisam;
@@ -211,7 +214,8 @@ slow_log	CREATE TABLE `slow_log` (
   `last_insert_id` int(11) NOT NULL,
   `insert_id` int(11) NOT NULL,
   `server_id` int(10) unsigned NOT NULL,
-  `sql_text` mediumtext NOT NULL
+  `sql_text` mediumtext NOT NULL,
+  `thread_id` int(11) NOT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Slow log'
 set global general_log='ON';
 set global slow_query_log='ON';
@@ -281,7 +285,8 @@ ON UPDATE CURRENT_TIMESTAMP,
 `last_insert_id` int(11) NOT NULL,
 `insert_id` int(11) NOT NULL,
 `server_id` int(10) unsigned NOT NULL,
-`sql_text` mediumtext NOT NULL
+`sql_text` mediumtext NOT NULL,
+`thread_id` int(11) NOT NULL
 ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
 set global general_log='ON';
 set global slow_query_log='ON';
@@ -308,7 +313,7 @@ event_time	user_host	thread_id	server_id
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	select * from general_log
 truncate table slow_log;
 select * from slow_log;
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
 create table general_log_new like general_log;
 rename table general_log TO renamed_general_log, general_log_new TO general_log;
 create table slow_log_new like slow_log;
@@ -329,9 +334,9 @@ TIMESTAMP	USER_HOST	THREAD_ID	1	Query	se
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	create table general_log_new like general_log
 TIMESTAMP	USER_HOST	THREAD_ID	1	Query	rename table general_log TO renamed_general_log, general_log_new TO general_log
 select * from slow_log;
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
 select * from renamed_slow_log;
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	thread_id
 set global general_log='OFF';
 RENAME TABLE general_log TO general_log2;
 set global slow_query_log='OFF';
@@ -368,75 +373,6 @@ slow_log
 slow_log_new
 drop table slow_log_new, general_log_new;
 use test;
-SET GLOBAL LOG_OUTPUT = 'TABLE';
-SET GLOBAL general_log = 0;
-FLUSH LOGS;
-TRUNCATE TABLE mysql.general_log;
-ALTER TABLE mysql.general_log ENGINE = MyISAM;
-ALTER TABLE mysql.general_log
-ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;
-SET GLOBAL general_log = 1;
-FLUSH LOGS;
-SELECT * FROM mysql.general_log;
-event_time	user_host	thread_id	server_id	command_type	argument	seq
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	FLUSH LOGS	1
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT * FROM mysql.general_log	2
-SELECT * FROM mysql.general_log;
-event_time	user_host	thread_id	server_id	command_type	argument	seq
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	FLUSH LOGS	1
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT * FROM mysql.general_log	2
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT * FROM mysql.general_log	3
-SELECT "My own query 1";
-My own query 1
-My own query 1
-SELECT "My own query 2";
-My own query 2
-My own query 2
-SELECT * FROM mysql.general_log;
-event_time	user_host	thread_id	server_id	command_type	argument	seq
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	FLUSH LOGS	1
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT * FROM mysql.general_log	2
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT * FROM mysql.general_log	3
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT "My own query 1"	4
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT "My own query 2"	5
-EVENT_TIME	USER_HOST	THREAD_ID	SERVER_ID	Query	SELECT * FROM mysql.general_log	6
-SET GLOBAL general_log = 0;
-FLUSH LOGS;
-ALTER TABLE mysql.general_log DROP COLUMN seq;
-ALTER TABLE mysql.general_log ENGINE = CSV;
-SET GLOBAL slow_query_log = 0;
-FLUSH LOGS;
-TRUNCATE TABLE mysql.slow_log;
-ALTER TABLE mysql.slow_log ENGINE = MyISAM;
-ALTER TABLE mysql.slow_log
-ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;
-SET SESSION long_query_time = 1;
-SET GLOBAL slow_query_log = 1;
-FLUSH LOGS;
-SELECT "My own slow query", sleep(2);
-My own slow query	sleep(2)
-My own slow query	0
-SELECT "My own slow query", sleep(2);
-My own slow query	sleep(2)
-My own slow query	0
-SELECT "My own slow query", sleep(2);
-My own slow query	sleep(2)
-My own slow query	0
-SELECT "My own slow query", sleep(2);
-My own slow query	sleep(2)
-My own slow query	0
-SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3;
-start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text	seq
-START_TIME	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	SELECT "My own slow query", sleep(2)	2
-START_TIME	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	SELECT "My own slow query", sleep(2)	3
-START_TIME	USER_HOST	QUERY_TIME	00:00:00	1	0	test	0	0	1	SELECT "My own slow query", sleep(2)	4
-SET GLOBAL slow_query_log = 0;
-SET SESSION long_query_time =@saved_long_query_time;
-FLUSH LOGS;
-ALTER TABLE mysql.slow_log DROP COLUMN seq;
-ALTER TABLE mysql.slow_log ENGINE = CSV;
-SET GLOBAL general_log = @old_general_log;
-SET GLOBAL slow_query_log = @old_slow_query_log;
 drop procedure if exists proc25422_truncate_slow;
 drop procedure if exists proc25422_truncate_general;
 drop procedure if exists proc25422_alter_slow;
@@ -533,7 +469,8 @@ CREATE TABLE `db_17876.slow_log_data` (
 `last_insert_id` int(11) default NULL,
 `insert_id` int(11) default NULL,
 `server_id` int(11) default NULL,
-`sql_text` mediumtext 
+`sql_text` mediumtext,
+`thread_id` int(11) default NULL
 );
 CREATE TABLE `db_17876.general_log_data` (
 `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -547,7 +484,7 @@ CREATE procedure `db_17876.archiveSlowLo
 BEGIN
 DECLARE start_time, query_time, lock_time CHAR(20);
 DECLARE user_host MEDIUMTEXT;
-DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT;
+DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id, thread_id INT;
 DECLARE dbname MEDIUMTEXT;
 DECLARE sql_text BLOB;
 DECLARE done INT DEFAULT 0;
@@ -561,14 +498,14 @@ DECLARE CONTINUE HANDLER FOR ER_SP_FETCH
 FETCH cur1 INTO
 start_time, user_host, query_time, lock_time,
 rows_set, rows_examined, dbname, last_insert_id,
-insert_id, server_id, sql_text;
+insert_id, server_id, sql_text, thread_id;
 END;
 IF NOT done THEN
 BEGIN
 INSERT INTO
 `db_17876.slow_log_data`
             VALUES(start_time, user_host, query_time, lock_time, rows_set, rows_examined,
-dbname, last_insert_id,  insert_id, server_id, sql_text);
+dbname, last_insert_id,  insert_id, server_id, sql_text, thread_id);
 END;
 END IF;
 END;

=== modified file 'mysql-test/r/multi_update.result'
--- a/mysql-test/r/multi_update.result	2010-12-14 11:15:13 +0000
+++ b/mysql-test/r/multi_update.result	2011-02-21 15:55:58 +0000
@@ -680,4 +680,21 @@ Warnings:
 Warning	1292	Truncated incorrect datetime value: '1'
 DROP FUNCTION f1;
 DROP TABLE t1;
+#
+# BUG#57373: Multi update+InnoDB reports ER_KEY_NOT_FOUND if a
+#            table is updated twice
+#
+CREATE TABLE t1(
+pk INT,
+a INT,
+PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0,0);
+UPDATE t1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+
+# Should be (1,2)
+SELECT * FROM t1;
+pk	a
+1	2
+DROP TABLE t1;
 end of tests

=== added file 'mysql-test/r/multi_update_innodb.result'
--- a/mysql-test/r/multi_update_innodb.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/multi_update_innodb.result	2011-02-21 15:31:41 +0000
@@ -0,0 +1,29 @@
+#
+# BUG#57373: Multi update+InnoDB reports ER_KEY_NOT_FOUND if a
+#            table is updated twice
+#
+CREATE TABLE t1(
+pk INT,
+a INT,
+b INT,
+PRIMARY KEY (pk)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0,0,0);
+UPDATE t1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'.
+SELECT * FROM t1;
+pk	a	b
+0	0	0
+CREATE VIEW v1 AS SELECT * FROM t1;
+UPDATE v1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'.
+SELECT * FROM t1;
+pk	a	b
+0	0	0
+UPDATE t1 AS A, t1 AS B SET A.a = 1, B.b = 2;
+# Should be (0,1,2)
+SELECT * FROM t1;
+pk	a	b
+0	1	2
+DROP VIEW v1;
+DROP TABLE t1;

=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2011-01-10 16:37:47 +0000
+++ b/mysql-test/r/partition.result	2011-02-22 10:51:21 +0000
@@ -2263,3 +2263,64 @@ INSERT INTO t1 VALUES(0);
 DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
 End of 5.1 tests
+# Start of 5.5 tests
+#
+# BUG#55385: UPDATE statement throws an error, but still updates
+#            the table entries
+CREATE TABLE t1_part (
+partkey int,
+nokey int
+) PARTITION BY LINEAR HASH(partkey) PARTITIONS 3;
+INSERT INTO t1_part VALUES (1, 1) , (10, 10);
+CREATE VIEW v1 AS SELECT * FROM t1_part;
+
+# Should be (1,1),(10,10)
+SELECT * FROM t1_part;
+partkey	nokey
+1	1
+10	10
+
+# Case 1
+# Update is refused because partitioning key is updated
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.partkey = 2, B.nokey = 3;
+ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'.
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2, B.partkey = 3;
+ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'.
+
+# Case 2
+# Like 1, but partition accessed through a view
+UPDATE t1_part AS A NATURAL JOIN v1 as B SET A.nokey = 2 , B.partkey = 3;
+ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'.
+UPDATE v1 AS A NATURAL JOIN t1_part as B SET A.nokey = 2 , B.partkey = 3;
+ERROR HY000: Primary key/partition key update is not allowed since the table is updated both as 'A' and 'B'.
+
+# Should be (1,1),(10,10)
+SELECT * FROM t1_part;
+partkey	nokey
+1	1
+10	10
+
+# Case 3
+# Update is accepted because partitioning key is not updated
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2 , B.nokey = 3;
+
+# Should be (1,3),(10,3)
+SELECT * FROM t1_part;
+partkey	nokey
+1	3
+10	3
+
+DROP VIEW v1;
+DROP TABLE t1_part;
+# Moved from lock.test
+# Separate case for partitioned tables is important
+# because each partition has an own thr_lock object.
+create table t1 (i int) partition by list (i)
+(partition p0 values in (1),
+partition p1 values in (2,3),
+partition p2 values in (4,5));
+lock tables t1 write, t1 as a read, t1 as b read;
+alter table t1 add column j int;
+unlock tables;
+drop table t1;
+# End of 5.5 tests

=== modified file 'mysql-test/r/status.result'
--- a/mysql-test/r/status.result	2010-05-10 09:37:24 +0000
+++ b/mysql-test/r/status.result	2011-02-22 14:24:33 +0000
@@ -149,7 +149,7 @@ a	a
 1	1
 SHOW SESSION STATUS LIKE 'Last_query_cost';
 Variable_name	Value
-Last_query_cost	4.805989
+Last_query_cost	5.205989
 DROP TABLE t1;
 show status like 'com_show_status';
 Variable_name	Value

=== modified file 'mysql-test/r/subquery_sj_none.result'
--- a/mysql-test/r/subquery_sj_none.result	2011-02-21 10:36:31 +0000
+++ b/mysql-test/r/subquery_sj_none.result	2011-02-22 14:24:33 +0000
@@ -76,10 +76,10 @@ a
 explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 1	PRIMARY	t2	index	NULL	a	5	NULL	4	100.00	Using where; Using index
-2	DEPENDENT SUBQUERY	t1	ref	a	a	5	func	1001	100.00	Using index
-2	DEPENDENT SUBQUERY	t3	index	a	a	5	NULL	3	100.00	Using where; Using index; Using join buffer (BNL, incremental buffers)
+2	DEPENDENT SUBQUERY	t3	index	a	a	5	NULL	3	100.00	Using where; Using index
+2	DEPENDENT SUBQUERY	t1	ref	a	a	10	func,test.t3.a	1167	100.00	Using index
 Warnings:
-Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t1`.`b`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
+Note	1003	select `test`.`t2`.`a` AS `a` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`a`,<exists>(select 1 from `test`.`t1` join `test`.`t3` where ((`test`.`t1`.`b` = `test`.`t3`.`a`) and (<cache>(`test`.`t2`.`a`) = `test`.`t1`.`a`))))
 insert into t1 values (3,31);
 select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
 a
@@ -2881,8 +2881,8 @@ t2.b1 IN (select c1 from t3 where c2 > '
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
 2	DEPENDENT SUBQUERY	t1_16	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
-3	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where
-3	DEPENDENT SUBQUERY	t2_16	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where; Using join buffer (BNL, incremental buffers)
+3	DEPENDENT SUBQUERY	t2_16	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
+3	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	5	100.00	Using where; Using join buffer (BNL, incremental buffers)
 4	DEPENDENT SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	4	100.00	Using where
 Warnings:
 Note	1003	select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>(concat(`test`.`t1`.`a1`,'x'),<exists>(select 1 from `test`.`t1_16` where (<in_optimizer>((`test`.`t1_16`.`a1`,`test`.`t1_16`.`a2`),<exists>(select `test`.`t2_16`.`b1`,`test`.`t2_16`.`b2` from `test`.`t2_16` join `test`.`t2` where ((`test`.`t2`.`b2` = substr(`test`.`t2_16`.`b2`,1,6)) and <in_optimizer>(`test`.`t2`.`b1`,<exists>(select 1 from `test`.`t3` where ((`test`.`t3`.`c2` > '0') and (<cache>(`test`.`t2`.`b1`) = `test`.`t3`.`c1`)))) and (<cache>(`test`.`t1_16`.`a1`) = `test`.`t2_16`.`b1`) and (<cache>(`test`.`t1_16`.`a2`) = `test`.`t2_16`.`b2`)))) and (<cache>(concat(`test`.`t1`.`a1`,'x')) = left(`test`.`t1_16`.`a1`,8)))))
@@ -3952,8 +3952,8 @@ WHERE int_nokey IN (SELECT it2.int_key
 FROM it1 LEFT JOIN it2 ON it2.datetime_key);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	ot1	ALL	NULL	NULL	NULL	NULL	20	Using where
+2	DEPENDENT SUBQUERY	it1	index	NULL	int_key	4	NULL	2	Using index
 2	DEPENDENT SUBQUERY	it2	ref	int_key	int_key	4	func	3	Using where
-2	DEPENDENT SUBQUERY	it1	index	NULL	int_key	4	NULL	2	Using index; Using join buffer (BNL, incremental buffers)
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -5221,8 +5221,8 @@ and t2.uid=t1.fid;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	11	Using where
 1	PRIMARY	t2	eq_ref	PRIMARY	PRIMARY	4	test.t1.fid	1	
+2	DEPENDENT SUBQUERY	t4	eq_ref	PRIMARY	PRIMARY	4	func	1	Using index
 2	DEPENDENT SUBQUERY	t3	ref	uid	uid	5	const	4	Using where
-2	DEPENDENT SUBQUERY	t4	eq_ref	PRIMARY	PRIMARY	4	func	1	Using where; Using index
 select name from t2, t1 
 where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid)
 and t2.uid=t1.fid;

=== modified file 'mysql-test/r/system_mysql_db.result'
--- a/mysql-test/r/system_mysql_db.result	2010-12-17 11:28:59 +0000
+++ b/mysql-test/r/system_mysql_db.result	2011-02-10 11:13:41 +0000
@@ -264,7 +264,8 @@ slow_log	CREATE TABLE `slow_log` (
   `last_insert_id` int(11) NOT NULL,
   `insert_id` int(11) NOT NULL,
   `server_id` int(10) unsigned NOT NULL,
-  `sql_text` mediumtext NOT NULL
+  `sql_text` mediumtext NOT NULL,
+  `thread_id` int(11) NOT NULL
 ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
 show tables;
 Tables_in_test

=== modified file 'mysql-test/std_data/Index.xml'
--- a/mysql-test/std_data/Index.xml	2010-12-20 10:28:06 +0000
+++ b/mysql-test/std_data/Index.xml	2011-02-22 13:25:05 +0000
@@ -105,6 +105,22 @@
       </rules>
     </collation>
 
+    <!-- shift after using expansion -->
+    <collation name="utf8_5624_5" id="368" shift-after-method="expand">
+      <rules>
+        <!--
+           Put small basic Latin letters between 0 and 1.
+           Simple shift method would not work, because there is no
+           weight space between 0 and 1 in DUCET.
+           Also, to test it works with contractions, put some after 'z'.
+        -->
+        <reset>0</reset>
+        <pc>abcdefghijklmnopqrstuvwxyz</pc><p>aa</p><p>aaa</p>
+        <reset before="primary">1</reset>
+        <pc>ABCDEFGHIJKLMNOPQRSTUVWXYZ</pc><p>AA</p><p>AAA</p>
+      </rules>
+    </collation>
+
    <collation name="utf8_hugeid_ci" id="2047000000">
       <rules>
         <reset>a</reset>

=== modified file 'mysql-test/suite/binlog/r/binlog_index.result'
--- a/mysql-test/suite/binlog/r/binlog_index.result	2010-12-17 01:29:53 +0000
+++ b/mysql-test/suite/binlog/r/binlog_index.result	2011-01-10 06:17:31 +0000
@@ -181,5 +181,147 @@ master-bin.000011
 master-bin.000012
 master-bin.000013
 
+# Test case6: Set DEBUG POINT before rename index file when
+#             appending a binlog file name to index file.
+show binary logs;
+Log_name	File_size
+master-bin.000006	#
+master-bin.000007	#
+master-bin.000008	#
+master-bin.000009	#
+master-bin.000010	#
+master-bin.000011	#
+master-bin.000012	#
+master-bin.000013	#
+SET SESSION debug="+d,crash_create_before_rename_index_file";
+flush logs;
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test if the index file has the correct data,
+# i.e. binlog file name is added.
+show binary logs;
+Log_name	File_size
+master-bin.000006	#
+master-bin.000007	#
+master-bin.000008	#
+master-bin.000009	#
+master-bin.000010	#
+master-bin.000011	#
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+# Test case7: Set DEBUG POINT after rename index file when
+#             appending a binlog file name to index file.
+SET SESSION debug="+d,crash_create_after_rename_index_file";
+flush logs;
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test if the index file has the correct data,
+# i.e. binlog file name is added.
+show binary logs;
+Log_name	File_size
+master-bin.000006	#
+master-bin.000007	#
+master-bin.000008	#
+master-bin.000009	#
+master-bin.000010	#
+master-bin.000011	#
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+# Test case8: Set DEBUG POINT after rename index file when
+#             purging the index file.
+show binary logs;
+Log_name	File_size
+master-bin.000006	#
+master-bin.000007	#
+master-bin.000008	#
+master-bin.000009	#
+master-bin.000010	#
+master-bin.000011	#
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+SET SESSION debug="+d,crash_create_after_rename_index_file";
+purge binary logs TO 'master-bin.000010';
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test if the index file has the correct data,
+# i.e. requested binlog file names are removed.
+show binary logs;
+Log_name	File_size
+master-bin.000010	#
+master-bin.000011	#
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+master-bin.000018	#
+# Test case9: Set DEBUG POINT befor rename index file when
+#             purging the index file.
+show binary logs;
+Log_name	File_size
+master-bin.000010	#
+master-bin.000011	#
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+master-bin.000018	#
+SET SESSION debug="+d,crash_create_before_rename_index_file";
+purge binary logs TO 'master-bin.000012';
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test if the index file has the correct data,
+# i.e. requested binlog file names are removed.
+show binary logs;
+Log_name	File_size
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+master-bin.000018	#
+master-bin.000019	#
+# Test case10: Inject a fault to copy part content to the temp file
+#              when purging the index file.
+show binary logs;
+Log_name	File_size
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+master-bin.000018	#
+master-bin.000019	#
+SET SESSION debug="+d,fault_injection_copy_part_file";
+purge binary logs TO 'master-bin.000014';
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test the index file is complete, although is not purged successfully.
+show binary logs;
+Log_name	File_size
+master-bin.000012	#
+master-bin.000013	#
+master-bin.000014	#
+master-bin.000015	#
+master-bin.000016	#
+master-bin.000017	#
+master-bin.000018	#
+master-bin.000019	#
+master-bin.000020	#
 SET SESSION debug="";
 End of tests

=== added file 'mysql-test/suite/binlog/r/rpl_crash_safe_master_checksum.result'
--- a/mysql-test/suite/binlog/r/rpl_crash_safe_master_checksum.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/r/rpl_crash_safe_master_checksum.result	2010-12-22 03:31:50 +0000
@@ -0,0 +1,30 @@
+call mtr.add_suppression("Attempting backtrace");
+call mtr.add_suppression("allocated tablespace *., old maximum was 0");
+call mtr.add_suppression("Error in Log_event::read_log_event()");
+call mtr.add_suppression("Buffered warning: Performance schema disabled");
+RESET MASTER;
+CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
+CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM;
+# Test case5: Inject wrong value of crc for a log event, and
+#             then set DBUG POINT to casue the master crash.
+INSERT INTO t2 (a) VALUES (REPEAT('a',1));
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',1));
+SET SESSION debug="d,fault_injection_crc_value";
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+COMMIT;
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',3));
+SET SESSION debug="d,crash_commit_after_prepare";
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test the transaction with a log event injected a wrong crc value
+# will be trimmed from the crashed binlog file
+show binlog events in 'master-bin.000001' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t2)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	COMMIT
+DROP TABLE t1, t2;

=== modified file 'mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test'
--- a/mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test	2009-10-20 08:39:40 +0000
+++ b/mysql-test/suite/binlog/t/binlog_delete_and_flush_index.test	2010-12-22 03:31:50 +0000
@@ -77,6 +77,7 @@ FLUSH LOGS;
 -- remove_file $datadir/master-bin.000001
 
 -- echo ### assertion: index file contains renamed binlog and the new one
+-- chmod 0644 $index
 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 -- eval SET @index=LOAD_FILE('$index')
 -- replace_regex /\.[\\\/]master/master/
@@ -106,6 +107,7 @@ DROP TABLE t1;
 -- file_exists $datadir/$current_binlog
 
 -- echo ### assertion: show index file contents and these should match show binary logs issued above
+-- chmod 0644 $index
 -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 -- eval SET @index=LOAD_FILE('$index')
 -- replace_regex /\.[\\\/]master/master/

=== modified file 'mysql-test/suite/binlog/t/binlog_index.test'
--- a/mysql-test/suite/binlog/t/binlog_index.test	2010-12-17 01:17:03 +0000
+++ b/mysql-test/suite/binlog/t/binlog_index.test	2011-01-10 06:17:31 +0000
@@ -256,6 +256,163 @@ SELECT @index;
 -- replace_regex /\.[\\\/]master/master/
 SELECT @index;
 
+#
+# WL#5493
+# Test case6 verifies if the index file has the correct data,
+# i.e. if binlog file name is added after the master restarts
+# when setting DEBUG POINT before renaming index file. 
+#
+# Test case7 verifies if the index file has the correct data,
+# i.e. if binlog file name is added after the master restarts
+# when setting DEBUG POINT after renaming index file.
+#
+# Test case8 verifies if the index file has the correct data,
+# i.e. if requested binlog file names are removed after the
+# master restarts when setting DEBUG POINT after purging index
+# file.
+#
+# Test case9 verifies if the index file has the correct data,
+# i.e. if requested binlog file names are removed after the
+# master restarts when setting DEBUG POINT before purging index
+# file.
+#
+# Test case10 verifies if the index file has the correct data,
+# i.e. although requested binlog file names are not removed
+# after the master restarts when injecting a fault to the
+# temp file in the process of purging the index file.
+#
+
+-- echo # Test case6: Set DEBUG POINT before rename index file when
+-- echo #             appending a binlog file name to index file.
+-- source include/show_binary_logs.inc
+file_exists $MYSQLD_DATADIR/master-bin.000013;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000014;
+
+# Write file to make mysql-test-run.pl expect crash and restart
+SET SESSION debug="+d,crash_create_before_rename_index_file";
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+--error 2013
+flush logs;
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test if the index file has the correct data,
+-- echo # i.e. binlog file name is added.
+-- source include/show_binary_logs.inc
+file_exists $MYSQLD_DATADIR/master-bin.000014;
+file_exists $MYSQLD_DATADIR/master-bin.000015;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000016;
+
+-- echo # Test case7: Set DEBUG POINT after rename index file when
+-- echo #             appending a binlog file name to index file.
+# Write file to make mysql-test-run.pl expect crash and restart
+SET SESSION debug="+d,crash_create_after_rename_index_file";
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+-- error 2013
+flush logs;
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test if the index file has the correct data,
+-- echo # i.e. binlog file name is added.
+-- source include/show_binary_logs.inc
+file_exists $MYSQLD_DATADIR/master-bin.000016;
+file_exists $MYSQLD_DATADIR/master-bin.000017;
+--error 1
+file_exists $MYSQLD_DATADIR/master-bin.000018;
+
+-- echo # Test case8: Set DEBUG POINT after rename index file when
+-- echo #             purging the index file.
+
+-- source include/show_binary_logs.inc
+# Write file to make mysql-test-run.pl expect crash and restart
+SET SESSION debug="+d,crash_create_after_rename_index_file";
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+-- error 2013
+purge binary logs TO 'master-bin.000010';
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test if the index file has the correct data,
+-- echo # i.e. requested binlog file names are removed.
+-- source include/show_binary_logs.inc
+-- error 1
+file_exists $MYSQLD_DATADIR/master-bin.000008;
+-- error 1
+file_exists $MYSQLD_DATADIR/master-bin.000009;
+file_exists $MYSQLD_DATADIR/master-bin.000010;
+
+-- echo # Test case9: Set DEBUG POINT befor rename index file when
+-- echo #             purging the index file.
+
+-- source include/show_binary_logs.inc
+# Write file to make mysql-test-run.pl expect crash and restart
+SET SESSION debug="+d,crash_create_before_rename_index_file";
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+-- error 2013
+purge binary logs TO 'master-bin.000012';
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test if the index file has the correct data,
+-- echo # i.e. requested binlog file names are removed.
+-- source include/show_binary_logs.inc
+-- error 1
+file_exists $MYSQLD_DATADIR/master-bin.000010;
+-- error 1
+file_exists $MYSQLD_DATADIR/master-bin.000011;
+file_exists $MYSQLD_DATADIR/master-bin.000012;
+
+-- echo # Test case10: Inject a fault to copy part content to the temp file
+-- echo #              when purging the index file.
+
+-- source include/show_binary_logs.inc
+# Write file to make mysql-test-run.pl expect crash and restart
+SET SESSION debug="+d,fault_injection_copy_part_file";
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+-- error 2013
+purge binary logs TO 'master-bin.000014';
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test the index file is complete, although is not purged successfully.
+-- source include/show_binary_logs.inc
+file_exists $MYSQLD_DATADIR/master-bin.000012;
+file_exists $MYSQLD_DATADIR/master-bin.000013;
+file_exists $MYSQLD_DATADIR/master-bin.000014;
+
 eval SET SESSION debug="$old";
 
 --echo End of tests

=== added file 'mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum-master.opt'
--- a/mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum-master.opt	2010-12-22 03:31:50 +0000
@@ -0,0 +1 @@
+--binlog-checksum=CRC32 --master-verify-checksum=1

=== added file 'mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum.test'
--- a/mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/binlog/t/rpl_crash_safe_master_checksum.test	2010-12-22 03:31:50 +0000
@@ -0,0 +1,61 @@
+#
+# WL#5493 & WL#5440
+# Test case5 verifies if a transaction with a wrong crc value
+# will be trimmed from the crashed binlog file after
+# master restarts when injecting a wrong crc value
+# for a statment of the transaction and then setting
+# DEBUG POINT to cause master crash.
+#
+
+# Don't test this under valgrind, memory leaks will occur
+-- source include/not_valgrind.inc
+-- source include/not_embedded.inc
+-- source include/have_debug.inc
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+
+call mtr.add_suppression("Attempting backtrace");
+call mtr.add_suppression("allocated tablespace *., old maximum was 0");
+call mtr.add_suppression("Error in Log_event::read_log_event()");
+call mtr.add_suppression("Buffered warning: Performance schema disabled");
+
+# Reset master
+RESET MASTER;
+
+CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
+CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM;
+
+-- echo # Test case5: Inject wrong value of crc for a log event, and
+-- echo #             then set DBUG POINT to casue the master crash.
+# Write file to make mysql-test-run.pl expect crash and restart
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
+-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+INSERT INTO t2 (a) VALUES (REPEAT('a',1));
+
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',1));
+SET SESSION debug="d,fault_injection_crc_value";
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+COMMIT;
+
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',3));
+SET SESSION debug="d,crash_commit_after_prepare";
+# Run the crashing query
+-- error 2013
+COMMIT;
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test the transaction with a log event injected a wrong crc value
+-- echo # will be trimmed from the crashed binlog file
+-- source include/show_binlog_events.inc
+
+DROP TABLE t1, t2;
+

=== modified file 'mysql-test/suite/funcs_1/r/is_columns_mysql.result'
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2010-12-17 11:28:59 +0000
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result	2011-02-22 05:37:44 +0000
@@ -188,6 +188,7 @@ def	mysql	slow_log	rows_sent	5	NULL	NO	i
 def	mysql	slow_log	server_id	10	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(10) unsigned			select,insert,update,references	
 def	mysql	slow_log	sql_text	11	NULL	NO	mediumtext	16777215	16777215	NULL	NULL	utf8	utf8_general_ci	mediumtext			select,insert,update,references	
 def	mysql	slow_log	start_time	1	CURRENT_TIMESTAMP	NO	timestamp	NULL	NULL	NULL	NULL	NULL	NULL	timestamp		on update CURRENT_TIMESTAMP	select,insert,update,references	
+def	mysql	slow_log	thread_id	12	NULL	NO	int	NULL	NULL	10	0	NULL	NULL	int(11)			select,insert,update,references	
 def	mysql	slow_log	user_host	2	NULL	NO	mediumtext	16777215	16777215	NULL	NULL	utf8	utf8_general_ci	mediumtext			select,insert,update,references	
 def	mysql	tables_priv	Column_priv	8		NO	set	31	93	NULL	NULL	utf8	utf8_general_ci	set('Select','Insert','Update','References')			select,insert,update,references	
 def	mysql	tables_priv	Db	2		NO	char	64	192	NULL	NULL	utf8	utf8_bin	char(64)	PRI		select,insert,update,references	
@@ -511,6 +512,7 @@ NULL	mysql	slow_log	last_insert_id	int	N
 NULL	mysql	slow_log	insert_id	int	NULL	NULL	NULL	NULL	int(11)
 NULL	mysql	slow_log	server_id	int	NULL	NULL	NULL	NULL	int(10) unsigned
 1.0000	mysql	slow_log	sql_text	mediumtext	16777215	16777215	utf8	utf8_general_ci	mediumtext
+NULL	mysql	slow_log	thread_id	int	NULL	NULL	NULL	NULL	int(11)
 3.0000	mysql	tables_priv	Host	char	60	180	utf8	utf8_bin	char(60)
 3.0000	mysql	tables_priv	Db	char	64	192	utf8	utf8_bin	char(64)
 3.0000	mysql	tables_priv	User	char	16	48	utf8	utf8_bin	char(16)

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-12-09 16:17:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2011-02-22 05:37:44 +0000
@@ -31,7 +31,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -67,7 +67,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -101,7 +101,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -135,7 +135,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -169,7 +169,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-12-09 16:17:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2011-02-22 05:37:44 +0000
@@ -31,7 +31,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -67,7 +67,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -101,7 +101,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -135,7 +135,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -169,7 +169,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-12-09 16:17:13 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2011-02-22 02:58:40 +0000
@@ -31,7 +31,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -67,7 +67,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -101,7 +101,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -135,7 +135,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -169,7 +169,7 @@ ERROR 1050 (42S01) at line 341: Table 't
 ERROR 1050 (42S01) at line 385: Table 'table_io_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 464: Table 'table_lock_waits_summary_by_table' already exists
 ERROR 1050 (42S01) at line 484: Table 'threads' already exists
-ERROR 1644 (HY000) at line 902: Unexpected content found in the performance_schema database.
+ERROR 1644 (HY000) at line 904: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/rpl/r/rpl_checksum.result'
--- a/mysql-test/suite/rpl/r/rpl_checksum.result	2011-02-07 15:31:01 +0000
+++ b/mysql-test/suite/rpl/r/rpl_checksum.result	2011-02-21 13:23:29 +0000
@@ -3,7 +3,7 @@ include/master-slave.inc
 call mtr.add_suppression('Slave can not handle replication events with the checksum that master is configured to log');
 call mtr.add_suppression('Replication event checksum verification failed');
 call mtr.add_suppression('Relay log write failure: could not queue event from master');
-call mtr.add_suppression('Master is configured to log replication events with checksum, but will not send such events to slaves that cannot process');
+call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
 set @master_save_binlog_checksum= @@global.binlog_checksum;
 set @save_master_verify_checksum =  @@global.master_verify_checksum;
 select @@global.binlog_checksum as 'must be CRC32 because of the command line option';

=== modified file 'mysql-test/suite/rpl/r/rpl_corruption.result'
--- a/mysql-test/suite/rpl/r/rpl_corruption.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_corruption.result	2011-01-10 06:17:31 +0000
@@ -4,6 +4,7 @@ call mtr.add_suppression('Found invalid
 call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
 call mtr.add_suppression('event read from binlog did not pass crc check');
 call mtr.add_suppression('Replication event checksum verification failed');
+call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
 SET @old_master_verify_checksum = @@master_verify_checksum;
 # 1. Creating test table/data and set corruption position for testing
 * insert/update/delete rows in table t1 *

=== added file 'mysql-test/suite/rpl/r/rpl_crash_safe_master.result'
--- a/mysql-test/suite/rpl/r/rpl_crash_safe_master.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_crash_safe_master.result	2011-01-13 03:14:52 +0000
@@ -0,0 +1,124 @@
+include/master-slave.inc
+[connection master]
+include/stop_slave.inc
+RESET MASTER;
+include/start_slave.inc
+call mtr.add_suppression("Attempting backtrace");
+call mtr.add_suppression("allocated tablespace *., old maximum was 0");
+call mtr.add_suppression("Error in Log_event::read_log_event()");
+call mtr.add_suppression("Buffered warning: Performance schema disabled");
+CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
+# Test case1: Set DEBUG POINT before binlog to make
+#             the master crash for transaction
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+SET SESSION debug="d,crash_commit_after_prepare";
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test the transaction statements will not be binlogged
+show binlog events in 'master-bin.000001' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB
+# On master, test the data will be rolled back after restart.
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+# On slave, test replication will work fine, and the data 
+#           is not replicated
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+# Test case2: Set DEBUG POINT after binlog, and before the date
+#             is committed to make crash for transaction
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+SET SESSION debug="d,crash_commit_after_log";
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test the transaction statements will be binlogged
+show binlog events in 'master-bin.000002' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Query	#	#	BEGIN
+master-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000002	#	Xid	#	#	COMMIT /* XID */
+# On master, test the data will be recovered after the master restart
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+# On slave, test replication will work fine, and the data is replicated
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+DROP TABLE t1;
+include/stop_slave.inc
+CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
+# Test case3: Set DEBUG POINT in the middle of binlog to
+#             make the master crash for transaction.
+SET SESSION debug="d,half_binlogged_transaction";
+BEGIN;
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+COMMIT;
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test the halfly binlogged transaction will be trimmed
+# from the crashed binlog file
+show binlog events in 'master-bin.000003' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB
+# Test the data will not be recovered successfully
+# after the master restart.
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+0
+# Test case4: Set DEBUG POINT in the middle of binlog to
+#             make the master crash for non-transaction.
+SET SESSION debug="d,half_binlogged_transaction";
+CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM;
+INSERT INTO t2 (a) VALUES (REPEAT('a',16384));
+ERROR HY000: Lost connection to MySQL server during query
+# Restart the master server
+# Test the halfly binlogged non-transaction statement will be trimmed
+# from the crashed binlog file
+show binlog events in 'master-bin.000004' from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000004	#	Query	#	#	use `test`; CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM
+# Test the data will not be recovered successfully
+# after the master restart.
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+0
+DROP TABLE t1, t2;

=== modified file 'mysql-test/suite/rpl/r/rpl_manual_change_index_file.result'
--- a/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_manual_change_index_file.result	2011-01-17 10:10:06 +0000
@@ -32,31 +32,26 @@ call mtr.add_suppression("Got fatal erro
 CREATE TABLE t1(c1 int);
 DROP TABLE t1;
 FLUSH LOGS;
-FLUSH LOGS;
 CREATE TABLE t2(c1 int);
 DROP TABLE t2;
 [ on slave ]
 include/stop_slave.inc
 [ on master ]
-# Remove master-bin.000001 and master-bin.000002 from index file.
-PURGE MASTER LOGS TO 'master-bin.000003';
-# Re-insert master-bin.000002 into index file manually.
-# PURGE is used to update IO_CACHE of index file.  After this statement,
-# master knows that master-bin.000002 is in index file.
-PURGE MASTER LOGS TO 'master-bin.000002';
+# This operation will result in error EE_FILENOTFOUND which happens
+# when slave IO thread is connecting to master.
 [ on slave ]
-CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000002';
+CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000001';
 START SLAVE IO_THREAD;
-# Instead of EE_FILENOTFOUND, ER_MASTER_FATAL_ERROR_READING_BINLOG and the
-# specific information are sent to slave.
+# Instead of EE_FILENOTFOUND, ER_MASTER_FATAL_ERROR_READING_BINLOG
+# and the specific information are sent to slave.
 include/wait_for_slave_io_error.inc [errno=1236]
 Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Could not open log file''
-CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000003';
+[ on master ]
+# Restore master-bin.000001 file
+[ on slave ]
+CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000002';
 include/start_slave.inc
 [ on master ]
-# Restore the correct index file.
-FLUSH LOGS;
-PURGE MASTER LOGS TO 'master-bin.000004';
 CREATE TABLE t1(c1 INT);
 [ on slave ]
 SELECT * FROM t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result	2011-02-22 08:01:58 +0000
@@ -8,7 +8,7 @@ Warning	1712	Option binlog_cache_size (3
 SET GLOBAL binlog_cache_size = 4096;
 SET GLOBAL max_binlog_stmt_cache_size = 4096;
 Warnings:
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET GLOBAL binlog_stmt_cache_size = 4096;
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
@@ -133,7 +133,7 @@ Warning	1712	Option binlog_cache_size (3
 SET GLOBAL binlog_cache_size = 4096;
 SET GLOBAL max_binlog_stmt_cache_size = 4096;
 Warnings:
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET GLOBAL binlog_stmt_cache_size = 4096;
 include/stop_slave.inc
 include/start_slave.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result	2011-02-22 08:01:58 +0000
@@ -8,7 +8,7 @@ Warning	1712	Option binlog_cache_size (3
 SET GLOBAL binlog_cache_size = 4096;
 SET GLOBAL max_binlog_stmt_cache_size = 4096;
 Warnings:
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET GLOBAL binlog_stmt_cache_size = 4096;
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
@@ -134,7 +134,7 @@ Warning	1712	Option binlog_cache_size (3
 SET GLOBAL binlog_cache_size = 4096;
 SET GLOBAL max_binlog_stmt_cache_size = 4096;
 Warnings:
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET GLOBAL binlog_stmt_cache_size = 4096;
 include/stop_slave.inc
 include/start_slave.inc

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_000001.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_000001.result	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_000001.result	2011-02-22 07:52:45 +0000
@@ -34,6 +34,7 @@ create table t1 (n int) engine=myisam;
 reset master;
 stop slave;
 reset slave;
+# Asserted this: We should have generated greater than 16 KB relay log
 lock tables t1 read;
 start slave;
 include/sync_slave_io_with_master.inc
@@ -52,7 +53,7 @@ Got one of the listed errors
 include/wait_for_slave_sql_error_and_skip.inc [errno=1053]
 select count(*) from t1;
 count(*)
-5000
+100
 drop table t1;
 create table t1 (n int);
 insert into t1 values(3456);

=== modified file 'mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result	2011-02-22 08:01:58 +0000
@@ -8,7 +8,7 @@ Warning	1712	Option binlog_cache_size (3
 SET GLOBAL binlog_cache_size = 4096;
 SET GLOBAL max_binlog_stmt_cache_size = 4096;
 Warnings:
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET GLOBAL binlog_stmt_cache_size = 4096;
 CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=Innodb;
 CREATE TABLE t2(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MyIsam;
@@ -133,7 +133,7 @@ Warning	1712	Option binlog_cache_size (3
 SET GLOBAL binlog_cache_size = 4096;
 SET GLOBAL max_binlog_stmt_cache_size = 4096;
 Warnings:
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET GLOBAL binlog_stmt_cache_size = 4096;
 include/stop_slave.inc
 include/start_slave.inc

=== modified file 'mysql-test/suite/rpl/t/rpl_checksum.test'
--- a/mysql-test/suite/rpl/t/rpl_checksum.test	2011-02-14 16:32:36 +0000
+++ b/mysql-test/suite/rpl/t/rpl_checksum.test	2011-02-21 13:23:29 +0000
@@ -9,7 +9,7 @@ call mtr.add_suppression('Slave can not
 call mtr.add_suppression('Replication event checksum verification failed');
 # due to C failure simulation
 call mtr.add_suppression('Relay log write failure: could not queue event from master');
-call mtr.add_suppression('Master is configured to log replication events with checksum, but will not send such events to slaves that cannot process');
+call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
 
 # A. read/write access to the global vars:
 # binlog_checksum master_verify_checksum slave_sql_verify_checksum

=== modified file 'mysql-test/suite/rpl/t/rpl_corruption.test'
--- a/mysql-test/suite/rpl/t/rpl_corruption.test	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/t/rpl_corruption.test	2011-01-10 06:17:31 +0000
@@ -15,6 +15,7 @@ call mtr.add_suppression('Found invalid
 call mtr.add_suppression('Slave I/O: Relay log write failure: could not queue event from master');
 call mtr.add_suppression('event read from binlog did not pass crc check');
 call mtr.add_suppression('Replication event checksum verification failed');
+call mtr.add_suppression('Event crc check failed! Most likely there is event corruption');
 
 SET @old_master_verify_checksum = @@master_verify_checksum;
 

=== added file 'mysql-test/suite/rpl/t/rpl_crash_safe_master.test'
--- a/mysql-test/suite/rpl/t/rpl_crash_safe_master.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_crash_safe_master.test	2011-02-15 08:25:14 +0000
@@ -0,0 +1,194 @@
+#
+# WL#5493 & WL#5440
+# Test case1 verifies if the transaction statements will not be
+# binlogged and replication will work fine, but the data will
+# be rolled back on master after the master restarts when setting
+# DEBUG POINT before binlog to make the master crash.
+# 
+# Test case2 verifies if the transaction statements will be
+# binlogged and replication will work fine, and the data will
+# be recovered after the master restarts when setting DEBUG
+# POINT after binlog, and before the date is committed to make
+# the master crash.
+#
+# Test case3 verifies if the halfly binlogged transaction 
+# statements will be trimmed from the crashed binlog file
+# and the data will not be recovered successfully after
+# the master restarts when setting DEBUG POINT in the
+# middle of binlog to make the master crash
+#
+# Test case4 verifies if the halfly binlogged non-transaction
+# statement will be trimmed from the crashed binlog file
+# and the data will not be recovered successfully after
+# the master restarts when setting DEBUG POINT in the
+# middle of binlog to make the master crash.
+#
+
+# Don't test this under valgrind, memory leaks will occur
+-- source include/not_valgrind.inc
+-- source include/not_embedded.inc
+-- source include/master-slave.inc
+-- source include/have_debug.inc
+-- source include/have_innodb.inc
+-- source include/have_binlog_format_row.inc
+
+# Reset master
+connection slave;
+--source include/stop_slave.inc 
+
+connection master;
+RESET MASTER;
+
+connection slave;
+--source include/start_slave.inc
+
+connection master;
+call mtr.add_suppression("Attempting backtrace");
+call mtr.add_suppression("allocated tablespace *., old maximum was 0");
+call mtr.add_suppression("Error in Log_event::read_log_event()");
+call mtr.add_suppression("Buffered warning: Performance schema disabled");
+
+-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
+-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
+
+-- echo # Test case1: Set DEBUG POINT before binlog to make
+-- echo #             the master crash for transaction
+BEGIN;
+let $rows= 3;
+WHILE($rows)
+{
+  INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+  dec $rows;
+}
+# Write file to make mysql-test-run.pl expect crash and restart
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug="d,crash_commit_after_prepare";
+# Run the crashing query
+-- error 2013
+COMMIT;
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc 
+-- disable_reconnect
+
+-- echo # Test the transaction statements will not be binlogged
+-- source include/show_binlog_events.inc
+
+-- echo # On master, test the data will be rolled back after restart.
+SELECT COUNT(*) FROM t1;
+
+sync_slave_with_master;
+-- echo # On slave, test replication will work fine, and the data 
+-- echo #           is not replicated
+SELECT COUNT(*) FROM t1;
+
+connection master;
+-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
+-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+-- echo # Test case2: Set DEBUG POINT after binlog, and before the date
+-- echo #             is committed to make crash for transaction
+BEGIN;
+let $rows= 3;
+WHILE($rows)
+{
+  INSERT INTO t1 (a) VALUES (REPEAT('a',2));
+  dec $rows;
+}
+# Write file to make mysql-test-run.pl expect crash and restart
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+SET SESSION debug="d,crash_commit_after_log";
+# Run the crashing query
+-- error 2013
+COMMIT;
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test the transaction statements will be binlogged
+-- source include/show_binlog_events.inc
+
+-- echo # On master, test the data will be recovered after the master restart
+SELECT COUNT(*) FROM t1;
+
+sync_slave_with_master;
+-- echo # On slave, test replication will work fine, and the data is replicated
+SELECT COUNT(*) FROM t1;
+
+connection master;
+DROP TABLE t1;
+sync_slave_with_master;
+-- source include/stop_slave.inc
+
+connection master;
+-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
+-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+# Test transaction with large data inserted
+CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
+
+-- echo # Test case3: Set DEBUG POINT in the middle of binlog to
+-- echo #             make the master crash for transaction.
+SET SESSION debug="d,half_binlogged_transaction";
+BEGIN;
+let $rows= 24;
+WHILE($rows)
+{
+  INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
+  dec $rows;
+}
+# Write file to make mysql-test-run.pl expect crash and restart
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+# Run the crashing query
+-- error 2013
+COMMIT;
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test the halfly binlogged transaction will be trimmed
+-- echo # from the crashed binlog file
+-- source include/show_binlog_events.inc
+
+-- echo # Test the data will not be recovered successfully
+-- echo # after the master restart.
+SELECT COUNT(*) FROM t1;
+
+-- echo # Test case4: Set DEBUG POINT in the middle of binlog to
+-- echo #             make the master crash for non-transaction.
+SET SESSION debug="d,half_binlogged_transaction";
+# Write file to make mysql-test-run.pl expect crash and restart
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
+-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM;
+-- error 2013
+INSERT INTO t2 (a) VALUES (REPEAT('a',16384));
+
+-- source include/wait_until_disconnected.inc
+-- enable_reconnect
+-- echo # Restart the master server
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- source include/wait_until_connected_again.inc
+-- disable_reconnect
+
+-- echo # Test the halfly binlogged non-transaction statement will be trimmed
+-- echo # from the crashed binlog file
+-- source include/show_binlog_events.inc
+
+-- echo # Test the data will not be recovered successfully
+-- echo # after the master restart.
+SELECT COUNT(*) FROM t2;
+
+DROP TABLE t1, t2;
+

=== modified file 'mysql-test/suite/rpl/t/rpl_manual_change_index_file.test'
--- a/mysql-test/suite/rpl/t/rpl_manual_change_index_file.test	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/t/rpl_manual_change_index_file.test	2011-01-17 10:10:06 +0000
@@ -1,3 +1,4 @@
+source include/not_windows.inc;
 source include/master-slave.inc;
 
 #
@@ -113,86 +114,49 @@ sync_slave_with_master;
 --echo # I/O thread stops immediately.
 
 --source include/rpl_reset.inc
---echo [ on master ]
 connection master;
-
-let $MASTER_DATADIR= `SELECT @@DATADIR`;
-
+--echo [ on master ]
 call mtr.add_suppression("Got fatal error 1236 from master when reading data from binary log:");
+let $MASTER_DATADIR= `SELECT @@DATADIR`;
 CREATE TABLE t1(c1 int);
 DROP TABLE t1;
 
 FLUSH LOGS;
-FLUSH LOGS;
 
 CREATE TABLE t2(c1 int);
 DROP TABLE t2;
 sync_slave_with_master;
-
 --echo [ on slave ]
 source include/stop_slave.inc;
 
---echo [ on master ]
 connection master;
---echo # Remove master-bin.000001 and master-bin.000002 from index file.
-PURGE MASTER LOGS TO 'master-bin.000003';
-
---echo # Re-insert master-bin.000002 into index file manually.
-if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64', 'Windows')`)
-{
-append_file $MASTER_DATADIR/master-bin.index;
-./master-bin.000002
-EOF
-sleep 0.00000001;
-}
-if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`)
-{
-append_file $MASTER_DATADIR/master-bin.index;
-.\master-bin.000002
-EOF
-sleep 0.00000001;
-}
---echo # PURGE is used to update IO_CACHE of index file.  After this statement,
---echo # master knows that master-bin.000002 is in index file.
-PURGE MASTER LOGS TO 'master-bin.000002';
+--echo [ on master ]
+--echo # This operation will result in error EE_FILENOTFOUND which happens
+--echo # when slave IO thread is connecting to master.
+move_file $MASTER_DATADIR/master-bin.000001 $MASTER_DATADIR/master-bin.bak;
 
---echo [ on slave ]
 connection slave;
-CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000002';
+--echo [ on slave ]
+CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000001';
 START SLAVE IO_THREAD;
-
---echo # Instead of EE_FILENOTFOUND, ER_MASTER_FATAL_ERROR_READING_BINLOG and the
---echo # specific information are sent to slave.
+--echo # Instead of EE_FILENOTFOUND, ER_MASTER_FATAL_ERROR_READING_BINLOG
+--echo # and the specific information are sent to slave.
 let $slave_io_errno= 1236;
 let $show_slave_io_error= 1;
 source include/wait_for_slave_io_error.inc;
 
-CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000003';
-source include/start_slave.inc;
+connection master;
+--echo [ on master ]
+--echo # Restore master-bin.000001 file
+move_file $MASTER_DATADIR/master-bin.bak $MASTER_DATADIR/master-bin.000001;
 
+connection slave;
+--echo [ on slave ]
+CHANGE MASTER TO master_host='127.0.0.1', master_log_file='master-bin.000002';
+source include/start_slave.inc;
 
---echo [ on master ]
 connection master;
---echo # Restore the correct index file.
-let $file= $MASTER_DATADIR/master-bin.index;
-source include/truncate_file.inc;
-if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64', 'Windows')`)
-{
-append_file $MASTER_DATADIR/master-bin.index;
-./master-bin.000003
-EOF
-sleep 0.00000001;
-}
-if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`)
-{
-append_file $MASTER_DATADIR/master-bin.index;
-.\master-bin.000003
-EOF
-sleep 0.00000001;
-}
-FLUSH LOGS;
-PURGE MASTER LOGS TO 'master-bin.000004';
-
+--echo [ on master ]
 CREATE TABLE t1(c1 INT);
 sync_slave_with_master;
 --echo [ on slave ]
@@ -200,4 +164,6 @@ SELECT * FROM t1;
 
 connection master;
 DROP TABLE t1;
+
 --source include/rpl_end.inc
+

=== modified file 'mysql-test/suite/rpl/t/rpl_stm_000001.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_000001.test	2010-12-19 17:15:12 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_000001.test	2011-02-22 07:52:45 +0000
@@ -54,8 +54,9 @@ stop slave;
 reset slave;
 
 connection master;
-let $1=5000;
+let $1=100;
 # Generate 16K of relay log
+--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
 disable_query_log;
 while ($1)
 {
@@ -64,6 +65,10 @@ while ($1)
 }
 enable_query_log;
 
+--let $assert_text= We should have generated greater than 16 KB relay log
+--let $assert_cond= [SHOW MASTER STATUS, Position, 1] - $pos > 16384
+--source include/rpl_assert.inc
+
 # Try to cause a large relay log lag on the slave by locking t1
 connection slave;
 lock tables t1 read;

=== added file 'mysql-test/suite/sys_vars/r/core_file_basic.result'
--- a/mysql-test/suite/sys_vars/r/core_file_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/core_file_basic.result	2011-02-10 04:52:55 +0000
@@ -0,0 +1,6 @@
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE '%core%';
+VARIABLE_NAME	VARIABLE_VALUE
+CORE_FILE	ON
+SHOW GLOBAL VARIABLES LIKE '%core%';
+Variable_name	Value
+core_file	ON

=== modified file 'mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result'
--- a/mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result	2010-12-05 22:51:49 +0000
+++ b/mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result	2011-02-22 08:01:58 +0000
@@ -10,7 +10,7 @@ SELECT @start_binlog_stmt_cache_size;
 SET @@global.max_binlog_stmt_cache_size = 5000;
 Warnings:
 Warning	1292	Truncated incorrect max_binlog_stmt_cache_size value: '5000'
-Warning	1725	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
+Warning	1726	Option binlog_stmt_cache_size (32768) is greater than max_binlog_stmt_cache_size (4096); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size.
 SET @@global.max_binlog_stmt_cache_size = DEFAULT;
 SELECT @@global.max_binlog_stmt_cache_size;
 @@global.max_binlog_stmt_cache_size

=== modified file 'mysql-test/suite/sys_vars/r/slow_query_log_func.result'
--- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result	2010-08-30 06:38:09 +0000
+++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result	2011-01-06 13:21:47 +0000
@@ -14,12 +14,17 @@ count(*)
 '----When slow_query_log = ON-----'
 SET @@global.slow_query_log = ON;
 TRUNCATE mysql.slow_log;
-SELECT sleep(2);
-sleep(2)
+SELECT sleep(2) AS bug53630;
+bug53630
 0
-SELECT count(*) > 0 FROM mysql.slow_log;
+SELECT count(*) > 0 FROM mysql.slow_log WHERE sql_text LIKE '% bug53630';
 count(*) > 0
 1
+SELECT thread_id - connection_id() FROM mysql.slow_log
+WHERE sql_text LIKE '% bug53630'
+                                   ORDER BY start_time DESC LIMIT 1;
+thread_id - connection_id()
+0
 'Bug#47905 stored procedures not logged correctly to slow query log'
 TRUNCATE mysql.slow_log;
 CREATE PROCEDURE p_test() 

=== added file 'mysql-test/suite/sys_vars/t/core_file_basic-master.opt'
--- a/mysql-test/suite/sys_vars/t/core_file_basic-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/core_file_basic-master.opt	2011-02-10 04:52:55 +0000
@@ -0,0 +1,2 @@
+--core-file
+

=== added file 'mysql-test/suite/sys_vars/t/core_file_basic.test'
--- a/mysql-test/suite/sys_vars/t/core_file_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/core_file_basic.test	2011-02-10 04:52:55 +0000
@@ -0,0 +1,2 @@
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE '%core%';
+SHOW GLOBAL VARIABLES LIKE '%core%';

=== modified file 'mysql-test/suite/sys_vars/t/slow_query_log_func.test'
--- a/mysql-test/suite/sys_vars/t/slow_query_log_func.test	2010-06-08 08:58:19 +0000
+++ b/mysql-test/suite/sys_vars/t/slow_query_log_func.test	2011-01-06 13:21:47 +0000
@@ -27,10 +27,12 @@ SELECT count(*) FROM mysql.slow_log;
 SET @@global.slow_query_log = ON;
 TRUNCATE mysql.slow_log;
 # The sleep is the slow query
-SELECT sleep(2);
-
-SELECT count(*) > 0 FROM mysql.slow_log;
+SELECT sleep(2) AS bug53630;
 
+SELECT count(*) > 0 FROM mysql.slow_log WHERE sql_text LIKE '% bug53630';
+SELECT thread_id - connection_id() FROM mysql.slow_log
+                                   WHERE sql_text LIKE '% bug53630'
+                                   ORDER BY start_time DESC LIMIT 1;
 
 #==========================================================================
 --echo 'Bug#47905 stored procedures not logged correctly to slow query log'

=== removed file 'mysql-test/t/crash_commit_before-master.opt'
--- a/mysql-test/t/crash_commit_before-master.opt	2010-06-21 07:58:54 +0000
+++ b/mysql-test/t/crash_commit_before-master.opt	1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
---skip-stack-trace --skip-core-file
---default-storage-engine=MyISAM
---innodb-file-per-table=0

=== removed file 'mysql-test/t/crash_commit_before.test'
--- a/mysql-test/t/crash_commit_before.test	2007-12-12 17:19:24 +0000
+++ b/mysql-test/t/crash_commit_before.test	1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
--- source include/not_embedded.inc
-# Don't test this under valgrind, memory leaks will occur
---source include/not_valgrind.inc
-
-# Binary must be compiled with debug for crash to occur
---source include/have_debug.inc
-
---source include/have_innodb.inc
-
-CREATE TABLE t1(a int) engine=innodb;
-START TRANSACTION;
-insert into t1 values(9);
-
-# Setup the mysqld to crash at certain point
-SET SESSION debug="d,crash_commit_before";
-
-# Write file to make mysql-test-run.pl expect crash and restart
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-
-# Run the crashing query
---error 2013
-COMMIT;
-
-# Turn on reconnect
---enable_reconnect
-
-# Call script that will poll the server waiting for it to be back online again
---source include/wait_until_connected_again.inc
-
-SHOW CREATE TABLE t1;
-
-SELECT * FROM t1;
-
-
-DROP TABLE t1;

=== modified file 'mysql-test/t/ctype_ldml.test'
--- a/mysql-test/t/ctype_ldml.test	2010-12-20 10:28:06 +0000
+++ b/mysql-test/t/ctype_ldml.test	2011-02-22 13:25:05 +0000
@@ -347,5 +347,24 @@ FROM t1 GROUP BY a ORDER BY a;
 DROP TABLE t1;
 
 --echo #
+--echo # WL#5624, shift after, using expansion
+--echo #
+SET NAMES utf8 COLLATE utf8_5624_5;
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0;
+INSERT INTO t1 VALUES ('0'),('1'),('0z'),(_ucs2 0x0030FF9D);
+INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'),('i');
+INSERT INTO t1 VALUES ('j'),('k'),('l'),('m'),('n'),('o'),('p'),('q'),('r');
+INSERT INTO t1 VALUES ('s'),('t'),('u'),('v'),('w'),('x'),('y'),('z');
+INSERT INTO t1 VALUES ('aa'),('aaa');
+INSERT INTO t1 VALUES ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I');
+INSERT INTO t1 VALUES ('J'),('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('R');
+INSERT INTO t1 VALUES ('S'),('T'),('U'),('V'),('W'),('X'),('Y'),('Z');
+INSERT INTO t1 VALUES ('AA'),('AAA');
+
+SELECT a, HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a, LENGTH(a), BINARY(a);
+DROP TABLE t1;
+
+
+--echo #
 --echo # End of WL#5624
 --echo #

=== modified file 'mysql-test/t/grant.test'
--- a/mysql-test/t/grant.test	2010-12-15 16:15:40 +0000
+++ b/mysql-test/t/grant.test	2011-02-23 04:53:07 +0000
@@ -1401,9 +1401,10 @@ use test;
 #
 # Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
 #
+--character_set utf8
 set names utf8;
 grant select on test.* to ��������_lt-character-set=utf8 --user=��������_�������� -e "select user()"
+--execw $MYSQL --default-character-set=utf8 --user=��������_�������� -e "select user()"
 revoke all on test.* from ��������_����_��������@localhost;
 --error ER_WRONG_STRING_LENGTH

=== modified file 'mysql-test/t/greedy_optimizer.test'
--- a/mysql-test/t/greedy_optimizer.test	2011-02-17 11:38:07 +0000
+++ b/mysql-test/t/greedy_optimizer.test	2011-02-22 14:24:33 +0000
@@ -424,3 +424,471 @@ SET optimizer_search_depth = DEFAULT;
 DROP TABLE t1,t2,t2_1,t3,t3_1,t4,t4_1,t5,t5_1;
 
 --echo End of 5.0 tests
+
+
+
+--echo #
+--echo # Bug #59326: Greedy optimizer produce stupid query execution plans.
+--echo #
+
+CREATE TABLE t10(
+  K INT NOT NULL AUTO_INCREMENT,
+  I INT,
+  PRIMARY KEY(K)
+);
+INSERT INTO t10(I) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(0);
+
+CREATE TABLE t100 LIKE t10;
+INSERT INTO t100(I)
+SELECT X.I FROM t10 AS X,t10 AS Y;
+
+CREATE TABLE t10000 LIKE t10;
+INSERT INTO t10000(I)
+SELECT X.I FROM t100 AS X, t100 AS Y;
+
+let $total_handler_reads=
+select sum(variable_value) from information_schema.session_status
+ where VARIABLE_NAME like 'Handler_read%';
+
+
+## All crossproducts should be executed in order t10,t100,t10000
+EXPLAIN SELECT * FROM t10,t100,t10000;
+EXPLAIN SELECT * FROM t10,t10000,t100;
+EXPLAIN SELECT * FROM t100,t10,t10000;
+EXPLAIN SELECT * FROM t100,t10000,t10;
+EXPLAIN SELECT * FROM t10000,t10,t100;
+EXPLAIN SELECT * FROM t10000,t100,t10;
+
+######
+## Ordering between T100,T10000 EQ-joined T10 will
+## normally be with smallest EQ-table joined first
+######
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.K=t10.I;
+--source include/expect_qep.inc
+
+## However, swapping EQ_REF-joined tables gives the same cost
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+  AND t10000.K=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expect all variants of EQ joining t100 & t10000 with T10
+# to have same cost # handler_reads:
+let $query=
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.K=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+  AND t10000.K=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.K=t10.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+  AND t10000.K=t10.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t100,t10,t10000
+WHERE t100.K=t10.I
+  AND t10000.K=t10.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t100,t10000,t10
+WHERE t100.K=t10.I
+  AND t10000.K=t10.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10000,t10,t100
+WHERE t100.K=t10.I
+  AND t10000.K=t10.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10000,t100,t10
+WHERE t100.K=t10.I
+  AND t10000.K=t10.K;
+--source include/check_qep.inc
+
+
+#####
+## EQ_REF Should be executed before table scan(ALL)
+## - Independent of #records in table being EQ_REF-joined
+#####
+#####
+# Expect: Join EQ_REF(t100) before ALL(t10000)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.I=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.I=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+  AND t10000.I=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expect: Join EQ_REF(t10000) before ALL(t100) (star-join)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+  AND t10000.K=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.I=t10.I
+  AND t10000.K=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+  AND t10000.K=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expect: Join EQ_REF(t10000) before ALL(t100)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+  AND t10000.K=t100.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.I=t10.I
+  AND t10000.K=t100.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.I=t10.I
+  AND t10000.K=t100.I;
+--source include/check_qep.inc
+
+
+#####
+## EQ_REF & ALL join two instances of t10000 with t10:
+## Always EQ_REF join first before producing cross product
+#####
+
+#####
+# Expected QEP: 'join EQ_REF(X) on X.K=t10.I' before 'cross' ALL(Y)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expected QEP: 'join EQ_REF(X) on X.K=t10.I' before ALL(Y)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+  AND Y.I=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expected QEP: 'join EQ_REF(X) on X.K=t10.I' before ALL(Y)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=X.K;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=X.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+  AND Y.I=X.K;
+--source include/check_qep.inc
+
+
+
+## Create indexes to test REF access
+CREATE INDEX IX ON t10(I);
+CREATE INDEX IX ON t100(I);
+CREATE INDEX IX ON t10000(I);
+
+########
+## EQ_REF Should be executed before 'REF'
+## - Independent of #records in table being EQ_REF-joined
+
+####
+# Expected QEP: 'join EQ_REF(t100) on t100.K=t10.I' before REF(t10000)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.I=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t100,t10000
+WHERE t100.K=t10.I
+  AND t10000.I=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000,t100
+WHERE t100.K=t10.I
+  AND t10000.I=t10.I;
+--source include/check_qep.inc
+
+
+#####
+## EQ_REF & REF join two instances of t10000 with t10:
+#####
+
+#####
+## Expect this QEP, cost & #handler_read
+# Expected QEP: 'join EQ_REF(X) on X.K=t10.I' before 'cross' ALL(Y)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expected QEP: 'join EQ_REF(X) on X.K=t10.I' before REF(Y)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=t10.I;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=t10.I;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+  AND Y.I=t10.I;
+--source include/check_qep.inc
+
+#####
+# Expected QEP: 'join EQ_REF(X) on X.K=t10.I' before REF(Y)
+let $query=
+SELECT STRAIGHT_JOIN COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=X.K;
+--source include/expect_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 X,t10000 Y
+WHERE X.K=t10.I
+  AND Y.I=X.K;
+--source include/check_qep.inc
+
+let $query=
+SELECT COUNT(*) FROM t10,t10000 Y,t10000 X
+WHERE X.K=t10.I
+  AND Y.I=X.K;
+--source include/check_qep.inc
+
+########
+
+
+
+########
+
+--echo #
+--echo # Test improved capabilities of analyzing complex query
+--echo # plans without restricting 'optimizer_search_depth'.
+--echo # Fix problems like those reported as bug#41740 & bug#58225. 
+--echo #
+--echo # EPLAIN of queries using T1-T62 will timeout/hang wo/ fixes
+--echo #
+
+DROP TABLE t10, t10000;
+
+--disable_result_log
+
+let $tabledef=
+( K INT NOT NULL AUTO_INCREMENT,
+  I INT,
+  A INT,
+  PRIMARY KEY(K), KEY IX(A)
+) engine = InnoDB;
+
+let $analyze = ANALYZE TABLE t100;
+
+let $i= 1;
+while ($i < 62)
+{
+  let $create= CREATE TABLE T$i $tabledef;
+  eval $create;
+
+  let $insert =
+  INSERT INTO T$i(I,A) SELECT X.K,X.K FROM t100 AS X, t100 AS Y WHERE X.K < 20 AND Y.K <= $i;
+  eval $insert;
+
+  let $analyze = $analyze, T$i;
+  inc $i;
+}
+eval $analyze;
+
+set optimizer_prune_level=1;
+
+
+#################
+## The EXPLAIN'ed query itself can't be part of the verified 
+## result as the QEP is not 100% predictable due to variation
+## in statistics from the engines. This is believed to be
+## caused by:
+##  - Variations in table fill degree.
+##  - 'Fuzzy' statistics provided by engines.
+##  - Round errors caused by 'cost' calculation using 
+##    'only' 64-bit double precision.
+##  - Other bugs...?
+##
+###############
+
+## Will test with optimizer_search_depth= [0,1,3,62]
+let $depth= 0;
+while ($depth<4)
+{
+  if ($depth==0)
+  {
+    set optimizer_search_depth=0; 
+  }
+  if ($depth==1)
+  {
+    set optimizer_search_depth=1;
+  }
+  if ($depth==2)
+  {
+    set optimizer_search_depth=3;
+  }
+  if ($depth==3)
+  {
+    set optimizer_search_depth=62;
+  }
+  inc $depth;
+
+
+  ## Test pruning of joined table scans (ALL) 
+  ## Prepare of QEP without timeout is heavily dependent
+  ## on maintaining correctly '#rows-sorted' plan
+  ##
+  let $query= SELECT COUNT(*) FROM T1 AS X;
+  let $i= 1;
+  while ($i < 61)
+  {
+    let $query= $query JOIN T$i ON T$i.I=X.I;
+    inc $i;
+
+    select @@optimizer_prune_level;
+    select @@optimizer_search_depth;
+    eval EXPLAIN $query;
+  }
+
+  ## Test pruning of joined table scans (ALL) 
+  ## with multiple instances of same table.
+  ## (All instances being equally expensive)
+  let $query= SELECT COUNT(*) FROM T1 AS X;
+  let $i= 1;
+  while ($i <= 56)
+  {
+    let $t= T$i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+    let $query= $query JOIN $t as T$i ON T$i.I=X.I;
+    inc $i;
+
+    select @@optimizer_prune_level;
+    select @@optimizer_search_depth;
+    eval EXPLAIN $query;
+  }
+}
+
+let $drop = DROP TABLE t100;
+let $i= 1;
+while ($i < 62)
+{
+  let $drop = $drop, T$i;
+  inc $i;
+}
+eval $drop;
+
+--enable_result_log
+
+SET OPTIMIZER_SEARCH_DEPTH = DEFAULT;
+
+--ECHO END OF 5.6 TESTS
+

=== modified file 'mysql-test/t/lock.test'
--- a/mysql-test/t/lock.test	2010-02-01 11:43:06 +0000
+++ b/mysql-test/t/lock.test	2011-01-26 22:06:30 +0000
@@ -451,18 +451,7 @@ lock tables t1 write, t1 as a read, t1 a
 alter table t1 add column j int;
 unlock tables;
 drop table t1;
---echo #
---echo # Separate case for partitioned tables is important
---echo # because each partition has an own thr_lock object.
---echo #
-create table t1 (i int) partition by list (i)
-  (partition p0 values in (1),
-   partition p1 values in (2,3),
-   partition p2 values in (4,5));
-lock tables t1 write, t1 as a read, t1 as b read;
-alter table t1 add column j int;
-unlock tables;
-drop table t1;
+--echo # Moved case for partitioned tables to partition.test
 
 
 --echo #

=== modified file 'mysql-test/t/log_state.test'
--- a/mysql-test/t/log_state.test	2010-11-02 11:53:54 +0000
+++ b/mysql-test/t/log_state.test	2011-02-10 11:13:41 +0000
@@ -48,7 +48,7 @@ connection con1;
 set @long_query_time = 2;
 set session long_query_time = @long_query_time;
 select sleep(@long_query_time + 1);
---replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 11 QUERY 12 THREAD_ID
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
 --echo # Switch to connection default
 connection default;
@@ -58,7 +58,7 @@ set global slow_query_log= ON;
 connection con1;
 set session long_query_time = @long_query_time;
 select sleep(@long_query_time + 1);
---replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 11 QUERY 12 THREAD_ID
 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%';
 --echo # Switch to connection default
 connection default;

=== modified file 'mysql-test/t/log_tables.test'
--- a/mysql-test/t/log_tables.test	2010-11-08 14:35:45 +0000
+++ b/mysql-test/t/log_tables.test	2011-02-22 05:37:44 +0000
@@ -180,7 +180,7 @@ drop table bug16905;
 truncate table mysql.slow_log;
 set session long_query_time=1;
 select sleep(2);
---replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME
+--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 11 QUERY 12 THREAD_ID
 select * from mysql.slow_log;
 set @@session.long_query_time = @saved_long_query_time;
 
@@ -311,7 +311,8 @@ CREATE TABLE `slow_log` (
   `last_insert_id` int(11) NOT NULL,
   `insert_id` int(11) NOT NULL,
   `server_id` int(10) unsigned NOT NULL,
-  `sql_text` mediumtext NOT NULL
+  `sql_text` mediumtext NOT NULL,
+  `thread_id` int(11) NOT NULL
 ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
 
 set global general_log='ON';
@@ -471,77 +472,6 @@ drop table slow_log_new, general_log_new
 use test;
 
 #
-# Bug#27857 (Log tables supplies the wrong value for generating
-#            AUTO_INCREMENT numbers)
-#
-
-SET GLOBAL LOG_OUTPUT = 'TABLE';
-
-## test the general log
-
-SET GLOBAL general_log = 0;
-FLUSH LOGS;
-
-TRUNCATE TABLE mysql.general_log;
-ALTER TABLE mysql.general_log ENGINE = MyISAM;
-ALTER TABLE mysql.general_log
-  ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;
-
-SET GLOBAL general_log = 1;
-FLUSH LOGS;
-
---replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID
-SELECT * FROM mysql.general_log;
---replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID
-SELECT * FROM mysql.general_log;
-SELECT "My own query 1";
-SELECT "My own query 2";
---replace_column 1 EVENT_TIME 2 USER_HOST 3 THREAD_ID 4 SERVER_ID
-SELECT * FROM mysql.general_log;
-
-SET GLOBAL general_log = 0;
-FLUSH LOGS;
-
-ALTER TABLE mysql.general_log DROP COLUMN seq;
-ALTER TABLE mysql.general_log ENGINE = CSV;
-
-## test the slow query log
-
-SET GLOBAL slow_query_log = 0;
-FLUSH LOGS;
-
-TRUNCATE TABLE mysql.slow_log;
-ALTER TABLE mysql.slow_log ENGINE = MyISAM;
-
-ALTER TABLE mysql.slow_log
-  ADD COLUMN seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;
-
-SET SESSION long_query_time = 1;
-SET GLOBAL slow_query_log = 1;
-FLUSH LOGS;
-
-## FLUSH LOGS above might be slow, so the following is
-## logged as either seq 1-4 or seq 2-5
-SELECT "My own slow query", sleep(2);
-SELECT "My own slow query", sleep(2);
-SELECT "My own slow query", sleep(2);
-SELECT "My own slow query", sleep(2);
-
-## So we look for seq 2-4
---replace_column 1 START_TIME 2 USER_HOST 3 QUERY_TIME
-SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3;
-
-SET GLOBAL slow_query_log = 0;
-SET SESSION long_query_time =@saved_long_query_time;
-FLUSH LOGS;
-
-ALTER TABLE mysql.slow_log DROP COLUMN seq;
-ALTER TABLE mysql.slow_log ENGINE = CSV;
-
-SET GLOBAL general_log = @old_general_log;
-SET GLOBAL slow_query_log = @old_slow_query_log;
-
-#
 # Bug#25422 (Hang with log tables)
 #
 
@@ -727,7 +657,8 @@ CREATE TABLE `db_17876.slow_log_data` (
   `last_insert_id` int(11) default NULL,
   `insert_id` int(11) default NULL,
   `server_id` int(11) default NULL,
-  `sql_text` mediumtext 
+  `sql_text` mediumtext,
+  `thread_id` int(11) default NULL
 );
 
 CREATE TABLE `db_17876.general_log_data` (
@@ -745,7 +676,7 @@ CREATE procedure `db_17876.archiveSlowLo
 BEGIN
   DECLARE start_time, query_time, lock_time CHAR(20);
   DECLARE user_host MEDIUMTEXT;
-  DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id INT;
+  DECLARE rows_set, rows_examined, last_insert_id, insert_id, server_id, thread_id INT;
   DECLARE dbname MEDIUMTEXT;
   DECLARE sql_text BLOB;
   DECLARE done INT DEFAULT 0;
@@ -763,7 +694,7 @@ BEGIN
         FETCH cur1 INTO
            start_time, user_host, query_time, lock_time,
            rows_set, rows_examined, dbname, last_insert_id,
-           insert_id, server_id, sql_text;
+           insert_id, server_id, sql_text, thread_id;
       END;
 
       IF NOT done THEN
@@ -771,7 +702,7 @@ BEGIN
           INSERT INTO
             `db_17876.slow_log_data`
             VALUES(start_time, user_host, query_time, lock_time, rows_set, rows_examined,
-                   dbname, last_insert_id,  insert_id, server_id, sql_text);
+                   dbname, last_insert_id,  insert_id, server_id, sql_text, thread_id);
         END;
       END IF;
     END;

=== modified file 'mysql-test/t/multi_update.test'
--- a/mysql-test/t/multi_update.test	2010-12-14 11:15:13 +0000
+++ b/mysql-test/t/multi_update.test	2011-02-21 15:55:58 +0000
@@ -683,4 +683,24 @@ UPDATE (SELECT 1 FROM t1 WHERE f1 = (SEL
 DROP FUNCTION f1;
 DROP TABLE t1;
 
+--echo #
+--echo # BUG#57373: Multi update+InnoDB reports ER_KEY_NOT_FOUND if a
+--echo #            table is updated twice
+--echo #
+
+# Results differ between storage engines.
+# See multi_update_innodb.test for the InnoDB variant of this test
+CREATE TABLE t1(
+  pk INT,
+  a INT,
+  PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+
+INSERT INTO t1 VALUES (0,0);
+UPDATE t1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+--echo
+--echo # Should be (1,2)
+SELECT * FROM t1;
+DROP TABLE t1;
+
 --echo end of tests

=== added file 'mysql-test/t/multi_update_innodb.test'
--- a/mysql-test/t/multi_update_innodb.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/multi_update_innodb.test	2011-02-21 15:31:41 +0000
@@ -0,0 +1,33 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # BUG#57373: Multi update+InnoDB reports ER_KEY_NOT_FOUND if a
+--echo #            table is updated twice
+--echo #
+
+# Results differ between storage engines.
+# See multi_update.test for the MyISAM variant of this test
+CREATE TABLE t1(
+  pk INT,
+  a INT,
+  b INT,
+  PRIMARY KEY (pk)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES (0,0,0);
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+SELECT * FROM t1;
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE v1 AS A, t1 AS B SET A.pk = 1, B.a = 2;
+SELECT * FROM t1;
+
+UPDATE t1 AS A, t1 AS B SET A.a = 1, B.b = 2;
+--echo # Should be (0,1,2)
+SELECT * FROM t1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2011-02-05 05:06:29 +0000
+++ b/mysql-test/t/mysql.test	2011-02-23 04:53:07 +0000
@@ -51,13 +51,14 @@ drop table t1;
 #
 # Bug#17939 Wrong table format when using UTF8 strings
 #
---exec $MYSQL --default-character-set=utf8 --table -e "SELECT 'John Doe' as '__ta��g�� ter-set=utf8 --table -e "SELECT '__ta��g�� ����m��' as 'John Doe'" 2>&1
+--character_set utf8
+--execw $MYSQL --default-character-set=utf8 --table -e "SELECT 'John Doe' as '__ta��g�� ����m�table -e "SELECT '__ta��g�� ����m��' as 'John Doe'" 2>&1
 
 #
 # Bug#18265 -- mysql client: No longer right-justifies numeric columns
 #
---exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int, k char(25) charset utf8); insert into t1 (i) values (1); insert into t1 (k) values ('<----------------------->'); insert into t1 (k) values ('<-----'); insert into t1 (k) values ('���� ������1; DROP TABLE t1;"
+--execw $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int, k char(25) charset utf8); insert into t1 (i) values (1); insert into t1 (k) values ('<----------------------->'); insert into t1 (k) values ('<-----'); insert into t1 (k) values ('���� ������������'); insert into t1 (k) values ('������ ���������'); select * from t1; DROP TABLE t1;"
 
 #
 # "DESCRIBE" commands may return strange NULLness flags.

=== modified file 'mysql-test/t/mysql_cp932.test'
--- a/mysql-test/t/mysql_cp932.test	2007-02-21 16:50:48 +0000
+++ b/mysql-test/t/mysql_cp932.test	2011-02-23 04:53:07 +0000
@@ -15,8 +15,9 @@
 --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
 
 # its usage to switch internally in mysql to requested charset
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '�\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('�\'); select * from t1;  drop table t1;"
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '�\'"
---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select '�\'"
---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select '�\'"
+--character_set latin1
+--execw $MYSQL --default-character-set=latin1 test -e "charset cp932; select '�\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('�\'); select * from t1;  drop table t1;"
+--execw $MYSQL --default-character-set=latin1 test -e "charset cp932; select '�\'"
+--execw $MYSQL --default-character-set=latin1 test -e "/*charset cp932 */; set names cp932, character_set_results=utf8; select '�\'"
+--execw $MYSQL --default-character-set=latin1 test -e "/*!\C cp932 */; set character_set_client= cp932; select '�\'"
 

=== modified file 'mysql-test/t/mysqlbinlog-cp932.test'
--- a/mysql-test/t/mysqlbinlog-cp932.test	2009-09-07 05:42:54 +0000
+++ b/mysql-test/t/mysqlbinlog-cp932.test	2011-02-23 04:53:07 +0000
@@ -10,8 +10,10 @@ RESET MASTER;
 # Bug#16217 (mysql client did not know how not switch its internal charset)
 create table t3 (f text character set utf8);
 create table t4 (f text character set cp932); 
---exec $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'���')"
---exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'�\');"
+--character_set utf8
+--execw $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'���')"
+--character_set cp932
+--execw $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'�\');"
 flush logs;
 rename table t3 to t03, t4 to t04;
 let $MYSQLD_DATADIR= `select @@datadir`;

=== removed file 'mysql-test/t/partition-master.opt'
--- a/mysql-test/t/partition-master.opt	2006-09-08 09:57:37 +0000
+++ b/mysql-test/t/partition-master.opt	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
---symbolic-links=1

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2011-01-10 16:37:47 +0000
+++ b/mysql-test/t/partition.test	2011-02-22 10:51:21 +0000
@@ -2266,3 +2266,69 @@ DROP TABLE t1;
 SET GLOBAL myisam_use_mmap=default;
 
 --echo End of 5.1 tests
+--echo # Start of 5.5 tests
+
+--echo #
+--echo # BUG#55385: UPDATE statement throws an error, but still updates
+--echo #            the table entries
+
+CREATE TABLE t1_part (
+  partkey int,
+  nokey int
+) PARTITION BY LINEAR HASH(partkey) PARTITIONS 3;
+
+INSERT INTO t1_part VALUES (1, 1) , (10, 10);
+CREATE VIEW v1 AS SELECT * FROM t1_part;
+
+--echo
+--echo # Should be (1,1),(10,10)
+SELECT * FROM t1_part;
+
+--echo
+--echo # Case 1
+--echo # Update is refused because partitioning key is updated
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.partkey = 2, B.nokey = 3;
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2, B.partkey = 3;
+
+--echo
+--echo # Case 2
+--echo # Like 1, but partition accessed through a view
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE t1_part AS A NATURAL JOIN v1 as B SET A.nokey = 2 , B.partkey = 3;
+--error ER_MULTI_UPDATE_KEY_CONFLICT
+UPDATE v1 AS A NATURAL JOIN t1_part as B SET A.nokey = 2 , B.partkey = 3;
+
+--echo
+--echo # Should be (1,1),(10,10)
+SELECT * FROM t1_part;
+
+--echo
+--echo # Case 3
+--echo # Update is accepted because partitioning key is not updated
+UPDATE t1_part AS A NATURAL JOIN t1_part B SET A.nokey = 2 , B.nokey = 3;
+
+--echo
+--echo # Should be (1,3),(10,3)
+SELECT * FROM t1_part;
+
+--echo
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1_part;
+
+--echo # Moved from lock.test
+--echo # Separate case for partitioned tables is important
+--echo # because each partition has an own thr_lock object.
+
+create table t1 (i int) partition by list (i)
+  (partition p0 values in (1),
+   partition p1 values in (2,3),
+   partition p2 values in (4,5));
+lock tables t1 write, t1 as a read, t1 as b read;
+alter table t1 add column j int;
+unlock tables;
+drop table t1;
+
+--echo # End of 5.5 tests

=== modified file 'mysys/my_conio.c'
--- a/mysys/my_conio.c	2009-02-13 16:41:47 +0000
+++ b/mysys/my_conio.c	2011-02-23 04:53:07 +0000
@@ -18,205 +18,260 @@
 
 #ifdef __WIN__
 
-static HANDLE my_coninpfh= 0;     /* console input */
 
-/*
-  functions my_pthread_auto_mutex_lock & my_pthread_auto_mutex_free
-  are experimental at this moment, they are intended to bring
-  ability of protecting code sections without necessity to explicitly
-  initialize synchronization object in one of threads
+/* Windows console handling */
 
-  if found useful they are to be exported in mysys
-*/
+/* Maximum line length on Windows console */
+#define MAX_CONSOLE_LINE_SIZE 65535
 
+/**
+  Determine if a file is a windows console
 
-/*
-  int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, 
-                                 int id, int time)
-  NOTES
-    creates a mutex with given name and tries to lock it time msec.
-    mutex name is appended with id to allow system wide or process wide
-    locks. Handle to created mutex returned in ph argument.
-
-  RETURN
-    0	              thread owns mutex
-    <>0	            error
-*/
-
-static
-int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time)
-{
-  int res;
-  char tname[FN_REFLEN];
-  
-  sprintf(tname, "%s-%08X", name, id);
-  
-  *ph= CreateMutex(NULL, FALSE, tname);
-  if (*ph == NULL)
-    return GetLastError();
-
-  res= WaitForSingleObject(*ph, time);
-  
-  if (res == WAIT_TIMEOUT)
-    return ERROR_SEM_TIMEOUT;
-
-  if (res == WAIT_FAILED)
-    return GetLastError();
+  @param file Input stream
 
+  @return
+  @retval  0 if file is not Windows console
+  @retval  1 if file is Windows console
+*/
+my_bool
+my_win_is_console(FILE *file)
+{
+  DWORD mode;
+  if (GetConsoleMode((HANDLE) _get_osfhandle(_fileno(file)), &mode))
+    return 1;
   return 0;
 }
 
-/*
-  int my_pthread_auto_mutex_free(HANDLE* ph)
-
-  NOTES
-    releases a mutex.
 
-  RETURN
-    0	              thread released mutex
-    <>0	            error
+/**
+  Read line from Windows console using Unicode API
+  and translate input to session character set.
+  Note, as Windows API breaks supplementary characters
+  into two wchar_t pieces, we cannot read and convert individual
+  wchar_t values separately. So let's use a buffer for
+  Unicode console input, and then convert it to "cs" in a single shot.
+  String is terminated with '\0' character.
+
+  @param cs         Character string to convert to.
+  @param mbbuf      Write input data here.
+  @param mbbufsize  Number of bytes available in mbbuf.
 
+  @rerval           Pointer to mbbuf, or NULL on I/0 error.
 */
-static
-int my_pthread_auto_mutex_free(HANDLE* ph)
+char *
+my_win_console_readline(CHARSET_INFO *cs, char *mbbuf, size_t mbbufsize)
 {
-  if (*ph)
+  uint dummy_errors;
+  static wchar_t u16buf[MAX_CONSOLE_LINE_SIZE + 1], *pos;
+  size_t mblen;
+  DWORD console_mode;
+  HANDLE console= GetStdHandle(STD_INPUT_HANDLE);
+
+  DBUG_ASSERT(mbbufsize > 0); /* Need space for at least trailing '\0' */
+  GetConsoleMode(console, &console_mode);
+  SetConsoleMode(console, ENABLE_LINE_INPUT |
+                          ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT);
+  for(pos= u16buf; pos < &u16buf[MAX_CONSOLE_LINE_SIZE] ; )
   {
-    ReleaseMutex(*ph);
-    CloseHandle(*ph);
-    *ph= NULL;
+    DWORD nchars;
+    if (!ReadConsoleW(console, pos, 1, &nchars, NULL) || nchars == 0)
+    {
+      SetConsoleMode(console, console_mode);
+      return NULL;
+    }
+    if (*pos == L'\r') /* We don't need '\r' in the result string, skip it */
+      continue;
+    if (*pos == L'\n')
+      break;
+    pos++;
   }
+  SetConsoleMode(console, console_mode);
+  /* Convert Unicode to session character set */
+  mblen= my_convert(mbbuf, mbbufsize - 1, cs,
+                    (const char *) u16buf, (pos - u16buf) * sizeof(wchar_t),
+                    &my_charset_utf16le_bin, &dummy_errors);
+  DBUG_ASSERT(mblen < mbbufsize); /* Safety */
+  mbbuf[mblen]= 0;
+  return mbbuf;
+}
 
-  return 0;
+
+/**
+  Translate client charset to Windows wchars for console I/O.
+  Unlike copy_and_convert(), in case of a wrong multi-byte sequence
+  we don't print '?' character, we fallback to ISO-8859-1 instead.
+  This gives a better idea how binary data (e.g. BLOB) look like.
+
+  @param cs           Character set of the input string
+  @param from         Input string
+  @param from_length  Length of the input string
+  @param to[OUT]      Write Unicode data here
+  @param to_chars     Number of characters available in "to"
+*/
+static size_t
+my_mbstou16s(CHARSET_INFO *cs, const uchar * from, size_t from_length,
+             wchar_t *to, size_t to_chars)
+{
+  CHARSET_INFO *to_cs= &my_charset_utf16le_bin;
+  const uchar *from_end= from + from_length;
+  wchar_t *to_orig= to, *to_end= to + to_chars;
+  my_charset_conv_mb_wc mb_wc= cs->cset->mb_wc;
+  my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb;
+  while (from < from_end)
+  {
+    int cnvres;
+    my_wc_t wc;
+    if ((cnvres= (*mb_wc)(cs, &wc, from, from_end)) > 0)
+    {
+      if (!wc)
+        break;
+      from+= cnvres;
+    }
+    else if (cnvres == MY_CS_ILSEQ)
+    {
+      wc= (my_wc_t) (uchar) *from; /* Fallback to ISO-8859-1 */
+      from+= 1;
+    }
+    else if (cnvres > MY_CS_TOOSMALL)
+    {
+      /*
+        A correct multibyte sequence detected
+        But it doesn't have Unicode mapping. 
+      */
+      wc= '?';
+      from+= (-cnvres); /* Note: cnvres is negative here */
+    }
+    else /* Incomplete character */
+    {
+      wc= (my_wc_t) (uchar) *from; /* Fallback to ISO-8859-1 */
+      from+= 1;
+    }
+outp:
+    if ((cnvres= (*wc_mb)(to_cs, wc, (uchar *) to, (uchar *) to_end)) > 0)
+    {
+      /* We can never convert only a part of wchar_t */
+      DBUG_ASSERT((cnvres % sizeof(wchar_t)) == 0);
+      /* cnvres returns number of bytes, convert to number of wchar_t's */
+      to+= cnvres / sizeof(wchar_t);
+    }
+    else if (cnvres == MY_CS_ILUNI && wc != '?')
+    {
+      wc= '?';
+      goto outp;
+    }
+    else
+      break; /* Not enough space */
+  }
+  return to - to_orig;
 }
 
 
-#define pthread_auto_mutex_decl(name)                           \
-  HANDLE __h##name= NULL;
+/**
+  Write a string in the given character set to Windows console. 
+  As Window breaks supplementary characters into two parts,
+  we cannot use a simple loop sending the result of
+  cs->cset->mb_wc() to console.
+  So we converts string from client charset to an array of wchar_t,
+  then write the array to console in a single shot.
+
+  @param cs       Character set of the string
+  @param data     String to print
+  @param datalen  Length of input string in bytes
+*/
+void
+my_win_console_write(CHARSET_INFO *cs, const char *data, size_t datalen)
+{
+  static wchar_t u16buf[MAX_CONSOLE_LINE_SIZE + 1];
+  size_t nchars= my_mbstou16s(cs, (const uchar *) data, datalen,
+                              u16buf, sizeof(u16buf));
+  DWORD nwritten;
+  WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),
+                u16buf, (DWORD) nchars, &nwritten, NULL);
+}
 
-#define pthread_auto_mutex_lock(name, proc, time)               \
-  my_pthread_auto_mutex_lock(&__h##name, #name, (proc), (time))
 
-#define pthread_auto_mutex_free(name)                           \
-  my_pthread_auto_mutex_free(&__h##name)
+/**
+  Write a single-byte character to console.
+  Note: one should not send parts of the same multi-byte character
+  in separate consequent my_win_console_putc() calls.
+  For multi-byte characters use my_win_colsole_write() instead.
 
+  @param cs  Character set of the input character
+  @param c   Character (single byte)
+*/
+void
+my_win_console_putc(CHARSET_INFO *cs, int c)
+{
+  char ch= (char) c;
+  my_win_console_write(cs, &ch, 1);
+}
 
-/*
-  char* my_cgets()
 
-  NOTES
-    Replaces _cgets from libc to support input of more than 255 chars.
-    Reads from the console via ReadConsole into buffer which 
-    should be at least clen characters.
-    Actual length of string returned in plen.
-
-  WARNING
-    my_cgets() does NOT check the pushback character buffer (i.e., _chbuf).
-    Thus, my_cgets() will not return any character that is pushed back by 
-    the _ungetch() call.
-
-  RETURN
-    string pointer	ok
-    NULL	          Error
+/**
+  Write a 0-terminated string to Windows console.
 
+  @param cs    Character set of the string to print
+  @param data  String to print
 */
+void
+my_win_console_fputs(CHARSET_INFO *cs, const char *data)
+{
+  my_win_console_write(cs, data, strlen(data));
+}
 
-char* my_cgets(char *buffer, size_t clen, size_t* plen)
-{
-  ULONG state;
-  char *result;
-  DWORD plen_res;
-  CONSOLE_SCREEN_BUFFER_INFO csbi;
-  
-  pthread_auto_mutex_decl(my_conio_cs);
- 
-  /* lock the console for the current process*/
-  if (pthread_auto_mutex_lock(my_conio_cs, GetCurrentProcessId(), INFINITE))
-  {
-    /* can not lock console */
-    pthread_auto_mutex_free(my_conio_cs);  
-    return NULL;
-  }
 
-  /* init console input */
-  if (my_coninpfh == 0)
-  {
-    /* same handle will be used until process termination */
-    my_coninpfh= CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE,
-                            FILE_SHARE_READ | FILE_SHARE_WRITE,
-                            NULL, OPEN_EXISTING, 0, NULL);
-  }
+/*
+  Handle formatted output on the Windows console.
+*/
+void
+my_win_console_vfprintf(CHARSET_INFO *cs, const char *fmt, va_list args)
+{
+  static char buff[MAX_CONSOLE_LINE_SIZE + 1];
+  size_t len= vsnprintf(buff, sizeof(buff) - 1, fmt, args);
+  my_win_console_write(cs, buff, len);
+}
 
-  if (my_coninpfh == INVALID_HANDLE_VALUE) 
-  {
-    /* unlock the console */
-    pthread_auto_mutex_free(my_conio_cs);  
-    return(NULL);
-  }
 
-  GetConsoleMode((HANDLE)my_coninpfh, &state);
-  SetConsoleMode((HANDLE)my_coninpfh, ENABLE_LINE_INPUT | 
-                 ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT);
-
-  GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
-
-  /* 
-    there is no known way to determine allowed buffer size for input
-    though it is known it should not be more than 64K               
-    so we cut 64K and try first size of screen buffer               
-    if it is still to large we cut half of it and try again         
-    later we may want to cycle from min(clen, 65535) to allowed size
-    with small decrement to determine exact allowed buffer           
-  */
-  clen= min(clen, 65535);
-  do
-  {
-    clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
-    if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
-                     NULL))
-    {
-      result= NULL;
-      clen>>= 1;
-    }
-    else
-    {
-      result= buffer;
-      break;
-    }
-  }
-  while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
-  *plen= plen_res;
+#include <shellapi.h>
 
-  /* We go here on error reading the string (Ctrl-C for example) */
-  if (!*plen)
-    result= NULL;                              /* purecov: inspected */
+/**
+  Translate Unicode command line parameters to the given character set
+  (Typically to utf8mb4).
+  Translated parameters are allocated using my_once_alloc().
+
+  @param      tocs    Character set to convert parameters to.
+  @param[OUT] argc    Write number of parameters here
+  @param[OUT] argv    Write pointer to allocated parameters here.
+*/
+int
+my_win_translate_command_line_args(CHARSET_INFO *cs, int *argc, char ***argv)
+{
+  int i, ac;
+  char **av;
+  wchar_t *command_line= GetCommandLineW();
+  wchar_t **wargs= CommandLineToArgvW(command_line, &ac);
+  size_t nbytes= (ac + 1) * sizeof(char *);
 
-  if (result != NULL)
-  {
-    if (*plen > 1 && buffer[*plen - 2] == '\r')
-    {
-      *plen= *plen - 2;
-    }
-    else 
-    {
-      if (*plen > 0 && buffer[*plen - 1] == '\r')
-      {
-        char tmp[3];
-        int  tmplen= sizeof(tmp);
+  /* Allocate new command line parameter */
+  av= (char **) my_once_alloc(nbytes, MYF(MY_ZEROFILL));
 
-        *plen= *plen - 1;
-        /* read /n left in the buffer */
-        ReadConsole((HANDLE)my_coninpfh, (LPVOID)tmp, tmplen, &tmplen, NULL);
-      }
-    }
-    buffer[*plen]= '\0';
+  for(i= 0; i < *argc; i++)
+  {
+    uint dummy_errors;
+    size_t arg_len= wcslen(wargs[i]);
+    size_t len, alloced_len= arg_len * cs->mbmaxlen + 1;
+    av[i]= (char *) my_once_alloc(alloced_len, MYF(0));
+    len= my_convert(av[i], alloced_len, cs,
+                    (const char *) wargs[i], arg_len * sizeof(wchar_t),
+                    &my_charset_utf16le_bin, &dummy_errors);
+    DBUG_ASSERT(len < alloced_len);
+    av[i][len]= '\0';
   }
-
-  SetConsoleMode((HANDLE)my_coninpfh, state);
-  /* unlock the console */
-  pthread_auto_mutex_free(my_conio_cs);  
-
-  return result;
+  *argv= av;
+  *argc= ac;
+  /* Cleanup on exit */
+  LocalFree((HLOCAL) wargs);
+  return 0;
 }
 
 #endif /* __WIN__ */

=== modified file 'mysys/my_rename.c'
--- a/mysys/my_rename.c	2010-07-15 11:41:37 +0000
+++ b/mysys/my_rename.c	2010-12-22 03:31:50 +0000
@@ -48,16 +48,11 @@ int my_rename(const char *from, const ch
                            MOVEFILE_REPLACE_EXISTING))
   {
     my_osmaperr(GetLastError());
-    my_errno= errno;
 #else
-#if defined(HAVE_RENAME)
   if (rename(from,to))
-#else
-  if (link(from, to) || unlink(from))
-#endif
   {
-    my_errno=errno;
 #endif
+    my_errno=errno;
     error = -1;
     if (MyFlags & (MY_FAE+MY_WME))
       my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2011-01-03 13:39:18 +0000
+++ b/scripts/mysql_system_tables.sql	2011-02-22 02:58:40 +0000
@@ -89,7 +89,7 @@ DROP PREPARE stmt;
 
 -- Create slow_log if CSV is enabled.
 
-SET @str = IF (@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
+SET @str = IF (@have_csv = 'YES', 'CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP NOT NULL, user_host MEDIUMTEXT NOT NULL, query_time TIME NOT NULL, lock_time TIME NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMTEXT NOT NULL, thread_id INTEGER NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log"', 'SET @dummy = 0');
 
 PREPARE stmt FROM @str;
 EXECUTE stmt;

=== modified file 'scripts/mysql_system_tables_fix.sql'
--- a/scripts/mysql_system_tables_fix.sql	2010-12-29 00:38:59 +0000
+++ b/scripts/mysql_system_tables_fix.sql	2011-02-09 08:12:43 +0000
@@ -255,6 +255,8 @@ ALTER TABLE slow_log
   MODIFY insert_id INTEGER NOT NULL,
   MODIFY server_id INTEGER UNSIGNED NOT NULL,
   MODIFY sql_text MEDIUMTEXT NOT NULL;
+ALTER TABLE slow_log
+  ADD COLUMN thread_id INTEGER NOT NULL AFTER sql_text;
 SET GLOBAL slow_query_log = @old_log_state;
 
 ALTER TABLE plugin

=== modified file 'scripts/mysqldumpslow.sh'
--- a/scripts/mysqldumpslow.sh	2010-12-28 23:47:05 +0000
+++ b/scripts/mysqldumpslow.sh	2011-02-09 08:12:43 +0000
@@ -99,7 +99,7 @@ while ( defined($_ = shift @pending) or
     }
 
     s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//;
-    my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('','');
+    my ($user,$host,$dummy,$thread_id) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+)\s+\S+(\s+Id:\s+(\d+))?.*\n// ? ($1,$2,$3,$4) : ('','','','','');
 
     s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+).*\n//;
     my ($t, $l, $r) = ($1, $2, $3);

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2011-01-31 15:55:58 +0000
+++ b/sql-common/client.c	2011-02-23 04:53:07 +0000
@@ -4246,11 +4246,31 @@ int STDCALL mysql_set_character_set(MYSQ
   if (mysql->options.charset_dir)
     charsets_dir= mysql->options.charset_dir;
 
+  if (!mysql->net.vio)
+  {
+    /* Initialize with automatic OS character set detection. */
+    mysql_options(mysql, MYSQL_SET_CHARSET_NAME, cs_name);
+    mysql_init_character_set(mysql);
+    /* 
+      In case of automatic OS character set detection
+      mysql_init_character_set changes mysql->options.charset_name
+      from "auto" to the real character set name.
+      Reset cs_name to the detected character set name, accordingly.
+    */
+    cs_name= mysql->options.charset_name;
+  }
+
   if (strlen(cs_name) < MY_CS_NAME_SIZE &&
      (cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))))
   {
     char buff[MY_CS_NAME_SIZE + 10];
     charsets_dir= save_csdir;
+    if (!mysql->net.vio)
+    {
+      /* If there is no connection yet we don't send "SET NAMES" query */
+      mysql->charset= cs;
+      return 0;
+    }
     /* Skip execution of "SET NAMES" for pre-4.1 servers */
     if (mysql_get_server_version(mysql) < 40100)
       return 0;

=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc	2010-12-17 02:01:32 +0000
+++ b/sql/binlog.cc	2011-01-10 06:17:31 +0000
@@ -1269,58 +1269,51 @@ int query_error_code(THD *thd, bool not_
 
 
 /**
-  Move all data up in a file in an filename index file.
+  Copy content of 'from' file from offset to 'to' file.
 
-    We do the copy outside of the IO_CACHE as the cache buffers would just
-    make things slower and more complicated.
-    In most cases the copy loop should only do one read.
+  - We do the copy outside of the IO_CACHE as the cache
+  buffers would just make things slower and more complicated.
+  In most cases the copy loop should only do one read.
 
-  @param index_file			File to move
-  @param offset			Move everything from here to beginning
+  @param from          File to copy.
+  @param to            File to copy to.
+  @param offset        Offset in 'from' file.
 
-  @note
-    File will be truncated to be 'offset' shorter or filled up with newlines
 
   @retval
-    0	ok
+    0    ok
+  @retval
+    -1    error
 */
-
-#ifdef HAVE_REPLICATION
-
-static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset)
+static bool copy_file(IO_CACHE *from, IO_CACHE *to, my_off_t offset)
 {
   int bytes_read;
-  my_off_t init_offset= offset;
-  File file= index_file->file;
   uchar io_buf[IO_SIZE*2];
-  DBUG_ENTER("copy_up_file_and_fill");
+  DBUG_ENTER("copy_file");
 
-  for (;; offset+= bytes_read)
+  mysql_file_seek(from->file, offset, MY_SEEK_SET, MYF(0));
+  while(TRUE)
   {
-    mysql_file_seek(file, offset, MY_SEEK_SET, MYF(0));
-    if ((bytes_read= (int) mysql_file_read(file, io_buf, sizeof(io_buf),
+    if ((bytes_read= (int) mysql_file_read(from->file, io_buf, sizeof(io_buf),
                                            MYF(MY_WME)))
-	< 0)
+        < 0)
       goto err;
+    if (DBUG_EVALUATE_IF("fault_injection_copy_part_file", 1, 0))
+      bytes_read= bytes_read/2;
     if (!bytes_read)
-      break;					// end of file
-    mysql_file_seek(file, offset-init_offset, MY_SEEK_SET, MYF(0));
-    if (mysql_file_write(file, io_buf, bytes_read, MYF(MY_WME | MY_NABP)))
+      break;                                    // end of file
+    if (mysql_file_write(to->file, io_buf, bytes_read, MYF(MY_WME | MY_NABP)))
       goto err;
   }
-  /* The following will either truncate the file or fill the end with \n' */
-  if (mysql_file_chsize(file, offset - init_offset, '\n', MYF(MY_WME)) ||
-      mysql_file_sync(file, MYF(MY_WME)))
-    goto err;
 
-  /* Reset data in old index cache */
-  reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 1);
   DBUG_RETURN(0);
 
 err:
   DBUG_RETURN(1);
 }
 
+
+#ifdef HAVE_REPLICATION
 /**
    Load data's io cache specific hook to be executed
    before a chunk of data is being read into the cache's buffer
@@ -1574,6 +1567,7 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_
   index_file_name[0] = 0;
   bzero((char*) &index_file, sizeof(index_file));
   bzero((char*) &purge_index_file, sizeof(purge_index_file));
+  bzero((char*) &crash_safe_index_file, sizeof(crash_safe_index_file));
 }
 
 /* this is called only once */
@@ -1635,13 +1629,34 @@ bool MYSQL_BIN_LOG::open_index_file(cons
   }
   fn_format(index_file_name, index_file_name_arg, mysql_data_home,
             ".index", opt);
+
+  if (set_crash_safe_index_file_name(index_file_name_arg))
+  {
+    sql_print_error("MYSQL_BIN_LOG::set_crash_safe_index_file_name failed.");
+    return TRUE;
+  }
+
+  /*
+    We need move crash_safe_index_file to index_file if the index_file
+    does not exist and crash_safe_index_file exists when mysqld server
+    restarts.
+  */
+  if (my_access(index_file_name, F_OK) &&
+      !my_access(crash_safe_index_file_name, F_OK) &&
+      my_rename(crash_safe_index_file_name, index_file_name, MYF(MY_WME)))
+  {
+    sql_print_error("MYSQL_BIN_LOG::open_index_file failed to "
+                    "move crash_safe_index_file to index file.");
+    return TRUE;
+  }
+
   if ((index_file_nr= mysql_file_open(key_file_binlog_index,
                                       index_file_name,
                                       O_RDWR | O_CREAT | O_BINARY,
                                       MYF(MY_WME))) < 0 ||
        mysql_file_sync(index_file_nr, MYF(MY_WME)) ||
        init_io_cache(&index_file, index_file_nr,
-                     IO_SIZE, WRITE_CACHE,
+                     IO_SIZE, READ_CACHE,
                      mysql_file_seek(index_file_nr, 0L, MY_SEEK_END, MYF(0)),
                                      0, MYF(MY_WME | MY_WAIT_IF_FULL)) ||
       DBUG_EVALUATE_IF("fault_injection_openning_index", 1, 0))
@@ -1862,18 +1877,15 @@ bool MYSQL_BIN_LOG::open(const char *log
 #endif
 
       DBUG_ASSERT(my_b_inited(&index_file) != 0);
-      reinit_io_cache(&index_file, WRITE_CACHE,
-                      my_b_filelength(&index_file), 0, 0);
+
       /*
-        As this is a new log file, we write the file name to the index
-        file. As every time we write to the index file, we sync it.
+        The new log file name is appended into crash safe index file after
+        all the content of index file is copyed into the crash safe index
+        file. Then move the crash safe index file to index file.
       */
       if (DBUG_EVALUATE_IF("fault_injection_updating_index", 1, 0) ||
-          my_b_write(&index_file, (uchar*) log_file_name,
-                     strlen(log_file_name)) ||
-          my_b_write(&index_file, (uchar*) "\n", 1) ||
-          flush_io_cache(&index_file) ||
-          mysql_file_sync(index_file.file, MYF(MY_WME)))
+          add_log_to_index((uchar*) log_file_name, strlen(log_file_name),
+                           need_mutex))
         goto err;
 
 #ifdef HAVE_REPLICATION
@@ -1910,6 +1922,135 @@ shutdown the MySQL server and restart it
 }
 
 
+/**
+  Move crash safe index file to index file.
+
+  @param need_mutex    Set it to FALSE if its caller already has a
+                       lock on LOCK_index
+
+  @retval
+    0    ok
+  @retval
+    -1    error
+*/
+int MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file(bool need_mutex)
+{
+  int error= 0;
+  File fd= -1;
+  DBUG_ENTER("MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file");
+
+  if (need_mutex)
+    mysql_mutex_lock(&LOCK_index);
+  mysql_mutex_assert_owner(&LOCK_index);
+
+  if (my_b_inited(&index_file))
+  {
+    end_io_cache(&index_file);
+    if (mysql_file_close(index_file.file, MYF(0)) < 0)
+    {
+      error= -1;
+      sql_print_error("MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file "
+                      "failed to close the index file.");
+      goto err;
+    }
+    mysql_file_delete(key_file_binlog_index, index_file_name, MYF(MY_WME));
+  }
+
+  DBUG_EXECUTE_IF("crash_create_before_rename_index_file", DBUG_SUICIDE(););
+  if (my_rename(crash_safe_index_file_name, index_file_name, MYF(MY_WME)))
+  {
+    error= -1;
+    sql_print_error("MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file "
+                    "failed to move crash_safe_index_file to index file.");
+    goto err;
+  }
+  DBUG_EXECUTE_IF("crash_create_after_rename_index_file", DBUG_SUICIDE(););
+
+  if ((fd= mysql_file_open(key_file_binlog_index,
+                           index_file_name,
+                           O_RDWR | O_CREAT | O_BINARY,
+                           MYF(MY_WME))) < 0 ||
+           mysql_file_sync(fd, MYF(MY_WME)) ||
+           init_io_cache(&index_file, fd, IO_SIZE, READ_CACHE,
+                         mysql_file_seek(fd, 0L, MY_SEEK_END, MYF(0)),
+                                         0, MYF(MY_WME | MY_WAIT_IF_FULL)))
+  {
+    error= -1;
+    sql_print_error("MYSQL_BIN_LOG::move_crash_safe_index_file_to_index_file "
+                    "failed to open the index file.");
+    goto err;
+  }
+
+err:
+  if (need_mutex)
+    mysql_mutex_unlock(&LOCK_index);
+  DBUG_RETURN(error);
+}
+
+
+/**
+  Append log file name to index file.
+
+  - To make crash safe, we copy all the content of index file
+  to crash safe index file firstly and then append the log
+  file name to the crash safe index file. Finally move the
+  crash safe index file to index file.
+
+  @retval
+    0   ok
+  @retval
+    -1   error
+*/
+int MYSQL_BIN_LOG::add_log_to_index(uchar* log_file_name,
+                                    int name_len, bool need_mutex)
+{
+  DBUG_ENTER("MYSQL_BIN_LOG::add_log_to_index");
+
+  if (open_crash_safe_index_file())
+  {
+    sql_print_error("MYSQL_BIN_LOG::add_log_to_index failed to "
+                    "open the crash safe index file.");
+    goto err;
+  }
+
+  if (copy_file(&index_file, &crash_safe_index_file, 0))
+  {
+    sql_print_error("MYSQL_BIN_LOG::add_log_to_index failed to "
+                    "copy index file to crash safe index file.");
+    goto err;
+  }
+
+  if (my_b_write(&crash_safe_index_file, log_file_name, name_len) ||
+      my_b_write(&crash_safe_index_file, (uchar*) "\n", 1) ||
+      flush_io_cache(&crash_safe_index_file) ||
+      mysql_file_sync(crash_safe_index_file.file, MYF(MY_WME)))
+  {
+    sql_print_error("MYSQL_BIN_LOG::add_log_to_index failed to "
+                    "append log file name: %s, to crash "
+                    "safe index file.", log_file_name);
+    goto err;
+  }
+
+  if (close_crash_safe_index_file())
+  {
+    sql_print_error("MYSQL_BIN_LOG::add_log_to_index failed to "
+                    "close the crash safe index file.");
+    goto err;
+  }
+
+  if (move_crash_safe_index_file_to_index_file(need_mutex))
+  {
+    sql_print_error("MYSQL_BIN_LOG::add_log_to_index failed to "
+                    "move crash safe index file to index file.");
+    goto err;
+  }
+
+  DBUG_RETURN(0);
+
+err:
+  DBUG_RETURN(-1);
+}
+
 int MYSQL_BIN_LOG::get_current_log(LOG_INFO* linfo)
 {
   mysql_mutex_lock(&LOCK_log);
@@ -2015,7 +2156,7 @@ int MYSQL_BIN_LOG::find_log_pos(LOG_INFO
   mysql_mutex_assert_owner(&LOCK_index);
 
   /* As the file is flushed, we can't get an error here */
-  (void) reinit_io_cache(&index_file, READ_CACHE, (my_off_t) 0, 0, 0);
+  my_b_seek(&index_file, (my_off_t) 0);
 
   for (;;)
   {
@@ -2086,8 +2227,7 @@ int MYSQL_BIN_LOG::find_next_log(LOG_INF
   mysql_mutex_assert_owner(&LOCK_index);
 
   /* As the file is flushed, we can't get an error here */
-  (void) reinit_io_cache(&index_file, READ_CACHE, linfo->index_file_offset, 0,
-			 0);
+  my_b_seek(&index_file, linfo->index_file_offset);
 
   linfo->index_file_start_offset= linfo->index_file_offset;
   if ((length=my_b_gets(&index_file, fname, FN_REFLEN)) <= 1)
@@ -2246,6 +2386,92 @@ err:
 
 
 /**
+  Set the name of crash safe index file.
+
+  @retval
+    0   ok
+  @retval
+    1   error
+*/
+int MYSQL_BIN_LOG::set_crash_safe_index_file_name(const char *base_file_name)
+{
+  int error= 0;
+  DBUG_ENTER("MYSQL_BIN_LOG::set_crash_safe_index_file_name");
+  if (fn_format(crash_safe_index_file_name, base_file_name, mysql_data_home,
+                ".index_crash_safe", MYF(MY_UNPACK_FILENAME | MY_SAFE_PATH |
+                                         MY_REPLACE_EXT)) == NULL)
+  {
+    error= 1;
+    sql_print_error("MYSQL_BIN_LOG::set_crash_safe_index_file_name failed "
+                    "to set file name.");
+  }
+  DBUG_RETURN(error);
+}
+
+
+/**
+  Open a (new) crash safe index file.
+
+  @note
+    The crash safe index file is a special file
+    used for guaranteeing index file crash safe.
+  @retval
+    0   ok
+  @retval
+    1   error
+*/
+int MYSQL_BIN_LOG::open_crash_safe_index_file()
+{
+  int error= 0;
+  File file= -1;
+
+  DBUG_ENTER("MYSQL_BIN_LOG::open_crash_safe_index_file");
+
+  if (!my_b_inited(&crash_safe_index_file))
+  {
+    if ((file= my_open(crash_safe_index_file_name, O_RDWR | O_CREAT | O_BINARY,
+                       MYF(MY_WME | ME_WAITTANG))) < 0  ||
+        init_io_cache(&crash_safe_index_file, file, IO_SIZE, WRITE_CACHE,
+                      0, 0, MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)))
+    {
+      error= 1;
+      sql_print_error("MYSQL_BIN_LOG::open_crash_safe_index_file failed "
+                      "to open temporary index file.");
+    }
+  }
+  DBUG_RETURN(error);
+}
+
+
+/**
+  Close the crash safe index file.
+
+  @note
+    The crash safe file is just closed, is not deleted.
+    Because it is moved to index file later on.
+  @retval
+    0   ok
+  @retval
+    1   error
+*/
+int MYSQL_BIN_LOG::close_crash_safe_index_file()
+{
+  int error= 0;
+
+  DBUG_ENTER("MYSQL_BIN_LOG::close_crash_safe_index_file");
+
+  if (my_b_inited(&crash_safe_index_file))
+  {
+    end_io_cache(&crash_safe_index_file);
+    error= my_close(crash_safe_index_file.file, MYF(0));
+  }
+  bzero((char*) &crash_safe_index_file, sizeof(crash_safe_index_file));
+
+  DBUG_RETURN(error);
+}
+
+
+/**
   Delete relay log files prior to rli->group_relay_log_name
   (i.e. all logs which are not involved in a non-finished group
   (transaction)), remove them from the index file and start on next
@@ -2380,19 +2606,67 @@ err:
   DBUG_RETURN(error);
 }
 
+
 /**
-  Update log index_file.
-*/
+  Remove logs from index file.
+
+  - To make crash safe, we copy the content of index file
+  from index_file_start_offset recored in log_info to
+  crash safe index file firstly and then move the crash
+  safe index file to index file.
+
+  @param linfo                  Store here the found log file name and
+                                position to the NEXT log file name in
+                                the index file.
+
+  @param need_update_threads    If we want to update the log coordinates
+                                of all threads. False for relay logs,
+                                true otherwise.
 
-int MYSQL_BIN_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads)
+  @retval
+    0    ok
+  @retval
+    LOG_INFO_IO    Got IO error while reading/writing file
+*/
+int MYSQL_BIN_LOG::remove_logs_from_index(LOG_INFO* log_info, bool need_update_threads)
 {
-  if (copy_up_file_and_fill(&index_file, log_info->index_file_start_offset))
-    return LOG_INFO_IO;
+  if (open_crash_safe_index_file())
+  {
+    sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to "
+                    "open the crash safe index file.");
+    goto err;
+  }
+
+  if (copy_file(&index_file, &crash_safe_index_file,
+                log_info->index_file_start_offset))
+  {
+    sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to "
+                    "copy index file to crash safe index file.");
+    goto err;
+  }
+
+  if (close_crash_safe_index_file())
+  {
+    sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to "
+                    "close the crash safe index file.");
+    goto err;
+  }
+  DBUG_EXECUTE_IF("fault_injection_copy_part_file", DBUG_SUICIDE(););
+
+  if (move_crash_safe_index_file_to_index_file(FALSE))
+  {
+    sql_print_error("MYSQL_BIN_LOG::remove_logs_from_index failed to "
+                    "move crash safe index file to index file.");
+    goto err;
+  }
 
   // now update offsets in index file for running threads
   if (need_update_threads)
     adjust_linfo_offsets(log_info->index_file_start_offset);
   return 0;
+
+err:
+  return LOG_INFO_IO;
 }
 
 /**
@@ -2477,7 +2751,7 @@ int MYSQL_BIN_LOG::purge_logs(const char
   }
 
   /* We know how many files to delete. Update index file. */
-  if ((error=update_log_index(&log_info, need_update_threads)))
+  if ((error=remove_logs_from_index(&log_info, need_update_threads)))
   {
     sql_print_error("MSYQL_BIN_LOG::purge_logs failed to update the index file");
     goto err;
@@ -3628,6 +3902,9 @@ int MYSQL_BIN_LOG::write_cache(IO_CACHE
   if (do_checksum)
     crc= crc_0= my_checksum(0L, NULL, 0);
 
+  if (DBUG_EVALUATE_IF("fault_injection_crc_value", 1, 0))
+    crc= crc - 1;
+
   do
   {
     /*
@@ -3901,9 +4178,9 @@ bool MYSQL_BIN_LOG::write(THD *thd, IO_C
         goto err;
 
       bool synced= 0;
+      DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_SUICIDE(););
       if (flush_and_sync(&synced))
         goto err;
-      DBUG_EXECUTE_IF("half_binlogged_transaction", DBUG_SUICIDE(););
       if (cache->error)				// Error on read
       {
         sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno);
@@ -4167,6 +4444,9 @@ int MYSQL_BIN_LOG::open(const char *opt_
     Log_event  *ev=0;
     Format_description_log_event fdle(BINLOG_VERSION);
     char        log_name[FN_REFLEN];
+    my_off_t    valid_pos= 0;
+    my_off_t    binlog_size;
+    MY_STAT     s;
 
     if (! fdle.is_valid())
       goto err;
@@ -4188,13 +4468,17 @@ int MYSQL_BIN_LOG::open(const char *opt_
       goto err;
     }
 
+    my_stat(log_name, &s, MYF(0));
+    binlog_size= s.st_size;
+
     if ((ev= Log_event::read_log_event(&log, 0, &fdle,
                                        opt_master_verify_checksum)) &&
         ev->get_type_code() == FORMAT_DESCRIPTION_EVENT &&
         ev->flags & LOG_EVENT_BINLOG_IN_USE_F)
     {
       sql_print_information("Recovering after a crash using %s", opt_name);
-      error= recover(&log, (Format_description_log_event *)ev);
+      valid_pos= my_b_tell(&log);
+      error= recover(&log, (Format_description_log_event *)ev, &valid_pos);
     }
     else
       error=0;
@@ -4205,6 +4489,51 @@ int MYSQL_BIN_LOG::open(const char *opt_
 
     if (error)
       goto err;
+
+    /* Trim the crashed binlog file to last valid transaction
+      or event (non-transaction) base on valid_pos. */
+    if (valid_pos > 0)
+    {
+      if ((file= mysql_file_open(key_file_binlog, log_name,
+                                 O_RDWR | O_BINARY, MYF(MY_WME))) < 0)
+      {
+        sql_print_error("Failed to open the crashed binlog file "
+                        "when master server is recovering it.");
+        return -1;
+      }
+
+      /* Change binlog file size to valid_pos */
+      if (valid_pos < binlog_size)
+      {
+        if (my_chsize(file, valid_pos, 0, MYF(MY_WME)))
+        {
+          sql_print_error("Failed to trim the crashed binlog file "
+                          "when master server is recovering it.");
+          mysql_file_close(file, MYF(MY_WME));
+          return -1;
+        }
+        else
+        {
+          sql_print_information("Crashed binlog file %s size is %llu, "
+                                "but recovered up to %llu. Binlog trimmed to %llu bytes.",
+                                log_name, binlog_size, valid_pos, valid_pos);
+        }
+      }
+
+      /* Clear LOG_EVENT_BINLOG_IN_USE_F */
+      my_off_t offset= BIN_LOG_HEADER_SIZE + FLAGS_OFFSET;
+      uchar flags= 0;
+      if (mysql_file_pwrite(file, &flags, 1, offset, MYF(0)) != 1)
+      {
+        sql_print_error("Failed to clear LOG_EVENT_BINLOG_IN_USE_F "
+                        "for the crashed binlog file when master "
+                        "server is recovering it.");
+        mysql_file_close(file, MYF(MY_WME));
+        return -1;
+      }
+
+      mysql_file_close(file, MYF(MY_WME));
+    } //end if
   }
 
 err:
@@ -4254,11 +4583,32 @@ int MYSQL_BIN_LOG::unlog(ulong cookie, m
   DBUG_RETURN(rotate_and_purge(0));     // as ::write() did not rotate
 }
 
-int MYSQL_BIN_LOG::recover(IO_CACHE *log, Format_description_log_event *fdle)
+
+/**
+  MYSQLD server recovers from last crashed binlog.
+
+  @param log           IO_CACHE of the crashed binlog.
+  @param fdle          Format_description_log_event of the crashed binlog.
+  @param valid_pos     The position of the last valid transaction or
+                       event(non-transaction) of the crashed binlog.
+
+  @retval
+    0                  ok
+  @retval
+    1                  error
+*/
+int MYSQL_BIN_LOG::recover(IO_CACHE *log, Format_description_log_event *fdle,
+                            my_off_t *valid_pos)
 {
   Log_event  *ev;
   HASH xids;
   MEM_ROOT mem_root;
+  my_off_t last_valid_pos= *valid_pos;
+  /*
+    The flag is used for handling the case that a transaction
+    is partially written to the binlog.
+  */
+  bool in_transaction= TRUE;
 
   if (! fdle->is_valid() ||
       my_hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0,
@@ -4267,14 +4617,31 @@ int MYSQL_BIN_LOG::recover(IO_CACHE *log
 
   init_alloc_root(&mem_root, TC_LOG_PAGE_SIZE, TC_LOG_PAGE_SIZE);
 
-  fdle->flags&= ~LOG_EVENT_BINLOG_IN_USE_F; // abort on the first error
-
-  while ((ev= Log_event::read_log_event(log, 0, fdle,
-                                        opt_master_verify_checksum))
+  while ((ev= Log_event::read_log_event(log, 0, fdle, TRUE))
          && ev->is_valid())
   {
-    if (ev->get_type_code() == XID_EVENT)
+    /*
+      Recorded valid position for the crashed binlog file
+      which contains incorrect events.
+    */
+    if (ev->get_type_code() == QUERY_EVENT &&
+        !strcmp(((Query_log_event*)ev)->query, "BEGIN"))
     {
+      in_transaction= TRUE;
+      *valid_pos= last_valid_pos;
+    }
+    last_valid_pos= my_b_tell(log);
+
+    if (ev->get_type_code() == QUERY_EVENT &&
+        !strcmp(((Query_log_event*)ev)->query, "COMMIT"))
+    {
+      DBUG_ASSERT(in_transaction == TRUE);
+      in_transaction= FALSE;
+    }
+    else if (ev->get_type_code() == XID_EVENT)
+    {
+      DBUG_ASSERT(in_transaction == TRUE);
+      in_transaction= FALSE;
       Xid_log_event *xev=(Xid_log_event *)ev;
       uchar *x= (uchar *) memdup_root(&mem_root, (uchar*) &xev->xid,
                                       sizeof(xev->xid));
@@ -4284,6 +4651,13 @@ int MYSQL_BIN_LOG::recover(IO_CACHE *log
     delete ev;
   }
 
+  /*
+    Recorded valid position for the crashed binlog file
+    which did not contain incorrect events.
+  */
+  if (!log->error && !in_transaction)
+    *valid_pos= last_valid_pos;
+
   if (ha_recover(&xids))
     goto err2;
 

=== modified file 'sql/binlog.h'
--- a/sql/binlog.h	2010-12-10 16:55:50 +0000
+++ b/sql/binlog.h	2011-01-10 06:17:31 +0000
@@ -35,6 +35,12 @@ class MYSQL_BIN_LOG: public TC_LOG, priv
   IO_CACHE index_file;
   char index_file_name[FN_REFLEN];
   /*
+    crash_safe_index_file is temp file used for guaranteeing
+    index file crash safe when master server restarts.
+  */
+  IO_CACHE crash_safe_index_file;
+  char crash_safe_index_file_name[FN_REFLEN];
+  /*
     purge_file is a temp file used in purge_logs so that the index file
     can be updated before deleting files from disk, yielding better crash
     recovery. It is created on demand the first time purge_logs is called
@@ -152,6 +158,8 @@ public:
   int open(const char *opt_name);
   void close();
   int log_xid(THD *thd, my_xid xid);
+  int recover(IO_CACHE *log, Format_description_log_event *fdle,
+              my_off_t *valid_pos);
   int unlog(ulong cookie, my_xid xid);
   int recover(IO_CACHE *log, Format_description_log_event *fdle);
 #if !defined(MYSQL_CLIENT)
@@ -218,7 +226,7 @@ public:
 
   void make_log_name(char* buf, const char* log_ident);
   bool is_active(const char* log_file_name);
-  int update_log_index(LOG_INFO* linfo, bool need_update_threads);
+  int remove_logs_from_index(LOG_INFO* linfo, bool need_update_threads);
   int rotate_and_purge(uint flags);
   /**
      Flush binlog cache and synchronize to disk.
@@ -240,6 +248,11 @@ public:
                  ulonglong *decrease_log_space);
   int purge_logs_before_date(time_t purge_time);
   int purge_first_log(Relay_log_info* rli, bool included);
+  int set_crash_safe_index_file_name(const char *base_file_name);
+  int open_crash_safe_index_file();
+  int close_crash_safe_index_file();
+  int add_log_to_index(uchar* log_file_name, int name_len, bool need_mutex);
+  int move_crash_safe_index_file_to_index_file(bool need_mutex);
   int set_purge_index_file_name(const char *base_file_name);
   int open_purge_index_file(bool destroy);
   bool is_inited_purge_index_file();

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-02-14 10:40:42 +0000
+++ b/sql/handler.cc	2011-02-21 15:55:58 +0000
@@ -2910,6 +2910,7 @@ void handler::print_error(int error, myf
     break;
   case HA_ERR_KEY_NOT_FOUND:
   case HA_ERR_NO_ACTIVE_RECORD:
+  case HA_ERR_RECORD_DELETED:
   case HA_ERR_END_OF_FILE:
     textno=ER_KEY_NOT_FOUND;
     break;

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2011-02-09 07:31:17 +0000
+++ b/sql/log.cc	2011-02-22 02:58:40 +0000
@@ -48,6 +48,142 @@
 #define MAX_LOG_BUFFER_SIZE 1024
 #define MAX_TIME_SIZE 32
 
+static
+const TABLE_FIELD_TYPE slow_query_log_table_fields[SQLT_FIELD_COUNT] =
+{
+  {
+    { C_STRING_WITH_LEN("start_time") },
+    { C_STRING_WITH_LEN("timestamp") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("user_host") },
+    { C_STRING_WITH_LEN("mediumtext") },
+    { C_STRING_WITH_LEN("utf8") }
+  },
+  {
+    { C_STRING_WITH_LEN("query_time") },
+    { C_STRING_WITH_LEN("time") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("lock_time") },
+    { C_STRING_WITH_LEN("time") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("rows_sent") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("rows_examined") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("db") },
+    { C_STRING_WITH_LEN("varchar(512)") },
+    { C_STRING_WITH_LEN("utf8") }
+  },
+  {
+    { C_STRING_WITH_LEN("last_insert_id") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("insert_id") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("server_id") },
+    { C_STRING_WITH_LEN("int(10) unsigned") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("sql_text") },
+    { C_STRING_WITH_LEN("mediumtext") },
+    { C_STRING_WITH_LEN("utf8") }
+  },
+  {
+    { C_STRING_WITH_LEN("thread_id") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0 }
+  }
+};
+
+static const TABLE_FIELD_DEF
+  slow_query_log_table_def= {SQLT_FIELD_COUNT, slow_query_log_table_fields};
+
+class Slow_query_log_table_intact : public Table_check_intact
+{
+protected:
+  void report_error(uint, const char *fmt, ...)
+  {
+    va_list args;
+    va_start(args, fmt);
+    error_log_print(ERROR_LEVEL, fmt, args);
+    va_end(args);
+  }
+};
+
+/** In case of an error, a message is printed to the error log. */
+static Slow_query_log_table_intact sqlt_intact;
+
+static
+const TABLE_FIELD_TYPE general_log_table_fields[GLT_FIELD_COUNT] =
+{
+  {
+    { C_STRING_WITH_LEN("event_time") },
+    { C_STRING_WITH_LEN("timestamp") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("user_host") },
+    { C_STRING_WITH_LEN("mediumtext") },
+    { C_STRING_WITH_LEN("utf8") }
+  },
+  {
+    { C_STRING_WITH_LEN("thread_id") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("server_id") },
+    { C_STRING_WITH_LEN("int(10) unsigned") },
+    { NULL, 0 }
+  },
+  {
+    { C_STRING_WITH_LEN("command_type") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { C_STRING_WITH_LEN("utf8") }
+  },
+  {
+    { C_STRING_WITH_LEN("argument") },
+    { C_STRING_WITH_LEN("mediumtext") },
+    { C_STRING_WITH_LEN("utf8") }
+  }
+};
+
+static const TABLE_FIELD_DEF
+  general_log_table_def= {GLT_FIELD_COUNT, general_log_table_fields};
+
+class General_log_table_intact : public Table_check_intact
+{
+protected:
+  void report_error(uint, const char *fmt, ...)
+  {
+    va_list args;
+    va_start(args, fmt);
+    error_log_print(ERROR_LEVEL, fmt, args);
+    va_end(args);
+  }
+};
+
+/** In case of an error, a message is printed to the error log. */
+static General_log_table_intact glt_intact;
+
 LOGGER logger;
 
 static bool test_if_number(const char *str,
@@ -275,7 +411,7 @@ bool Log_to_csv_event_handler::
                             TL_WRITE_CONCURRENT_INSERT);
 
   /*
-    1) open_log_table generates an error of the
+    1) open_log_table generates an error if the
     table can not be opened or is corrupted.
     2) "INSERT INTO general_log" can generate warning sometimes.
 
@@ -293,6 +429,9 @@ bool Log_to_csv_event_handler::
 
   need_close= TRUE;
 
+  if (glt_intact.check(table_list.table, &general_log_table_def))
+    goto err;
+
   if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
       table->file->ha_rnd_init(0))
     goto err;
@@ -316,35 +455,40 @@ bool Log_to_csv_event_handler::
   if (table->s->fields < 6)
     goto err;
 
-  DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP);
+  DBUG_ASSERT(table->field[GLT_FIELD_EVENT_TIME]->type() == MYSQL_TYPE_TIMESTAMP);
 
-  ((Field_timestamp*) table->field[0])->store_timestamp((my_time_t)
-                                                        event_time);
+  ((Field_timestamp*) table->field[GLT_FIELD_EVENT_TIME])->store_timestamp(
+      (my_time_t) event_time);
 
   /* do a write */
-  if (table->field[1]->store(user_host, user_host_len, client_cs) ||
-      table->field[2]->store((longlong) thread_id, TRUE) ||
-      table->field[3]->store((longlong) server_id, TRUE) ||
-      table->field[4]->store(command_type, command_type_len, client_cs))
+  if (table->field[GLT_FIELD_USER_HOST]->store(user_host, user_host_len,
+                                               client_cs) ||
+      table->field[GLT_FIELD_THREAD_ID]->store((longlong) thread_id, TRUE) ||
+      table->field[GLT_FIELD_SERVER_ID]->store((longlong) server_id, TRUE) ||
+      table->field[GLT_FIELD_COMMAND_TYPE]->store(command_type,
+                                                  command_type_len, client_cs))
     goto err;
 
   /*
     A positive return value in store() means truncation.
     Still logging a message in the log in this case.
   */
-  table->field[5]->flags|= FIELDFLAG_HEX_ESCAPE;
-  if (table->field[5]->store(sql_text, sql_text_len, client_cs) < 0)
+  table->field[GLT_FIELD_ARGUMENT]->flags|= FIELDFLAG_HEX_ESCAPE;
+  if (table->field[GLT_FIELD_ARGUMENT]->store(sql_text, sql_text_len,
+                                              client_cs) < 0)
     goto err;
 
   /* mark all fields as not null */
-  table->field[1]->set_notnull();
-  table->field[2]->set_notnull();
-  table->field[3]->set_notnull();
-  table->field[4]->set_notnull();
-  table->field[5]->set_notnull();
+  table->field[GLT_FIELD_USER_HOST]->set_notnull();
+  table->field[GLT_FIELD_THREAD_ID]->set_notnull();
+  table->field[GLT_FIELD_SERVER_ID]->set_notnull();
+  table->field[GLT_FIELD_COMMAND_TYPE]->set_notnull();
+  table->field[GLT_FIELD_ARGUMENT]->set_notnull();
 
   /* Set any extra columns to their default values */
-  for (field_index= 6 ; field_index < table->s->fields ; field_index++)
+  for (field_index= GLT_FIELD_COUNT ;
+       field_index < table->s->fields ;
+       field_index++)
   {
     table->field[field_index]->set_default();
   }
@@ -439,6 +583,9 @@ bool Log_to_csv_event_handler::
 
   need_close= TRUE;
 
+  if (sqlt_intact.check(table_list.table, &slow_query_log_table_def))
+    goto err;
+
   if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
       table->file->ha_rnd_init(0))
     goto err;
@@ -450,15 +597,12 @@ bool Log_to_csv_event_handler::
 
   restore_record(table, s->default_values);    // Get empty record
 
-  /* check that all columns exist */
-  if (table->s->fields < 11)
-    goto err;
-
   /* store the time and user values */
-  DBUG_ASSERT(table->field[0]->type() == MYSQL_TYPE_TIMESTAMP);
-  ((Field_timestamp*) table->field[0])->store_timestamp((my_time_t)
-                                                        current_time);
-  if (table->field[1]->store(user_host, user_host_len, client_cs))
+  DBUG_ASSERT(table->field[SQLT_FIELD_START_TIME]->type() == MYSQL_TYPE_TIMESTAMP);
+  ((Field_timestamp*) table->field[SQLT_FIELD_START_TIME])->store_timestamp(
+      (my_time_t) current_time);
+  if (table->field[SQLT_FIELD_USER_HOST]->store(user_host, user_host_len,
+                                                client_cs))
     goto err;
 
   if (query_start_arg)
@@ -475,42 +619,43 @@ bool Log_to_csv_event_handler::
 
     /* fill in query_time field */
     calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-    if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
+    if (table->field[SQLT_FIELD_QUERY_TIME]->store_time(&t, MYSQL_TIMESTAMP_TIME))
       goto err;
     /* lock_time */
     calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
-    if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
+    if (table->field[SQLT_FIELD_LOCK_TIME]->store_time(&t, MYSQL_TIMESTAMP_TIME))
       goto err;
     /* rows_sent */
-    if (table->field[4]->store((longlong) thd->sent_row_count, TRUE))
+    if (table->field[SQLT_FIELD_ROWS_SENT]->store((longlong) thd->sent_row_count, TRUE))
       goto err;
     /* rows_examined */
-    if (table->field[5]->store((longlong) thd->examined_row_count, TRUE))
+    if (table->field[SQLT_FIELD_ROWS_EXAMINED]->store((longlong) thd->examined_row_count, TRUE))
       goto err;
   }
   else
   {
-    table->field[2]->set_null();
-    table->field[3]->set_null();
-    table->field[4]->set_null();
-    table->field[5]->set_null();
+    table->field[SQLT_FIELD_QUERY_TIME]->set_null();
+    table->field[SQLT_FIELD_LOCK_TIME]->set_null();
+    table->field[SQLT_FIELD_ROWS_SENT]->set_null();
+    table->field[SQLT_FIELD_ROWS_EXAMINED]->set_null();
   }
   /* fill database field */
   if (thd->db)
   {
-    if (table->field[6]->store(thd->db, thd->db_length, client_cs))
+    if (table->field[SQLT_FIELD_DATABASE]->store(thd->db, thd->db_length,
+                                                 client_cs))
       goto err;
-    table->field[6]->set_notnull();
+    table->field[SQLT_FIELD_DATABASE]->set_notnull();
   }
 
   if (thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt)
   {
     if (table->
-        field[7]->store((longlong)
+        field[SQLT_FIELD_LAST_INSERT_ID]->store((longlong)
                         thd->first_successful_insert_id_in_prev_stmt_for_binlog,
                         TRUE))
       goto err;
-    table->field[7]->set_notnull();
+    table->field[SQLT_FIELD_LAST_INSERT_ID]->set_notnull();
   }
 
   /*
@@ -522,22 +667,27 @@ bool Log_to_csv_event_handler::
   if (thd->auto_inc_intervals_in_cur_stmt_for_binlog.nb_elements() > 0)
   {
     if (table->
-        field[8]->store((longlong)
+        field[SQLT_FIELD_INSERT_ID]->store((longlong)
           thd->auto_inc_intervals_in_cur_stmt_for_binlog.minimum(), TRUE))
       goto err;
-    table->field[8]->set_notnull();
+    table->field[SQLT_FIELD_INSERT_ID]->set_notnull();
   }
 
-  if (table->field[9]->store((longlong) server_id, TRUE))
+  if (table->field[SQLT_FIELD_SERVER_ID]->store((longlong) server_id, TRUE))
     goto err;
-  table->field[9]->set_notnull();
+  table->field[SQLT_FIELD_SERVER_ID]->set_notnull();
 
   /*
     Column sql_text.
     A positive return value in store() means truncation.
     Still logging a message in the log in this case.
   */
-  if (table->field[10]->store(sql_text, sql_text_len, client_cs) < 0)
+  if (table->field[SQLT_FIELD_SQL_TEXT]->store(sql_text, sql_text_len,
+                                               client_cs) < 0)
+    goto err;
+
+  if (table->field[SQLT_FIELD_THREAD_ID]->store((longlong) thd->thread_id,
+                                                TRUE))
     goto err;
 
   /* log table entries are not replicated */
@@ -1769,12 +1919,9 @@ bool MYSQL_QUERY_LOG::write(THD *thd, ti
         if (my_b_write(&log_file, (uchar*) buff, buff_len))
           tmp_errno= errno;
       }
-      const uchar uh[]= "# User@Host: ";
-      if (my_b_write(&log_file, uh, sizeof(uh) - 1))
-        tmp_errno= errno;
-      if (my_b_write(&log_file, (uchar*) user_host, user_host_len))
-        tmp_errno= errno;
-      if (my_b_write(&log_file, (uchar*) "\n", 1))
+      buff_len= my_snprintf(buff, 14, "%5ld", (long) thd->thread_id);
+      if (my_b_printf(&log_file, "# User@Host: %s  Id: %s\n", user_host, buff)
+          == (uint) -1)
         tmp_errno= errno;
     }
     /* For slow query log */

=== modified file 'sql/log.h'
--- a/sql/log.h	2010-12-10 16:55:50 +0000
+++ b/sql/log.h	2011-02-09 08:12:43 +0000
@@ -216,6 +216,37 @@ public:
 #endif
 };
 
+
+enum enum_general_log_table_field
+{
+  GLT_FIELD_EVENT_TIME = 0,
+  GLT_FIELD_USER_HOST,
+  GLT_FIELD_THREAD_ID,
+  GLT_FIELD_SERVER_ID,
+  GLT_FIELD_COMMAND_TYPE,
+  GLT_FIELD_ARGUMENT,
+  GLT_FIELD_COUNT
+};
+
+
+enum enum_slow_query_log_table_field
+{
+  SQLT_FIELD_START_TIME = 0,
+  SQLT_FIELD_USER_HOST,
+  SQLT_FIELD_QUERY_TIME,
+  SQLT_FIELD_LOCK_TIME,
+  SQLT_FIELD_ROWS_SENT,
+  SQLT_FIELD_ROWS_EXAMINED,
+  SQLT_FIELD_DATABASE,
+  SQLT_FIELD_LAST_INSERT_ID,
+  SQLT_FIELD_INSERT_ID,
+  SQLT_FIELD_SERVER_ID,
+  SQLT_FIELD_SQL_TEXT,
+  SQLT_FIELD_THREAD_ID,
+  SQLT_FIELD_COUNT
+};
+
+
 class MYSQL_QUERY_LOG: public MYSQL_LOG
 {
 public:

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2011-01-11 05:13:23 +0000
+++ b/sql/log_event.cc	2011-02-15 08:25:14 +0000
@@ -1323,6 +1323,8 @@ err:
       enough to stop the SQL thread now ; as we are skipping the current event,
       going on with reading and successfully executing other events can
       only corrupt the slave's databases. So stop.
+      The file->error is also checked to record the position of
+      the last valid event when master server recovers.
     */
     file->error= -1;
   }
@@ -1395,20 +1397,15 @@ Log_event* Log_event::read_log_event(con
   if (crc_check &&
       event_checksum_test((uchar *) buf, event_len, alg))
   {
-#ifdef MYSQL_CLIENT
     *error= "Event crc check failed! Most likely there is event corruption.";
+#ifdef MYSQL_CLIENT
     if (force_opt)
     {
       ev= new Unknown_log_event(buf, description_event);
       DBUG_RETURN(ev);
     }
-    else
-      DBUG_RETURN(NULL);
-#else
-    *error= ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE);
-    sql_print_error("%s", ER(ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE));
-    DBUG_RETURN(NULL);
 #endif
+    DBUG_RETURN(NULL);
   }
 
   if (event_type > description_event->number_of_event_types &&

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-02-21 11:34:14 +0000
+++ b/sql/mysqld.cc	2011-02-22 02:58:40 +0000
@@ -1085,6 +1085,8 @@ static void close_connections(void)
     statements and inform their clients that the server is about to die.
   */
 
+  sql_print_information("Giving client threads a chance to die gracefully");
+
   THD *tmp;
   mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
 
@@ -1117,6 +1119,8 @@ static void close_connections(void)
   mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list
 
   Events::deinit();
+
+  sql_print_information("Shutting down slave threads");
   end_slave();
 
   if (thread_count)
@@ -1128,6 +1132,7 @@ static void close_connections(void)
     client on a blocking read call are aborted.
   */
 
+  sql_print_information("Forcefully disconnecting remaining clients");
   for (;;)
   {
     DBUG_PRINT("quit",("Locking LOCK_thread_count"));
@@ -1428,6 +1433,7 @@ void clean_up(bool print_message)
     make sure that handlers finish up
     what they have that is dependent on the binlog
   */
+  sql_print_information("Binlog end");
   ha_binlog_end(current_thd);
 
   logger.cleanup_base();
@@ -5147,11 +5153,17 @@ static bool read_init_file(char *file_na
   MYSQL_FILE *file;
   DBUG_ENTER("read_init_file");
   DBUG_PRINT("enter",("name: %s",file_name));
+
+  sql_print_information("Execution of init_file \'%s\' started.", file_name);
+
   if (!(file= mysql_file_fopen(key_file_init, file_name,
                                O_RDONLY, MYF(MY_WME))))
     DBUG_RETURN(TRUE);
   bootstrap(file);
   mysql_file_fclose(file, MYF(MY_WME));
+
+  sql_print_information("Execution of init_file \'%s\' ended.", file_name);
+
   DBUG_RETURN(FALSE);
 }
 

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2011-02-21 11:34:14 +0000
+++ b/sql/share/errmsg-utf8.txt	2011-02-21 15:55:58 +0000
@@ -6452,6 +6452,10 @@ ER_BINLOG_READ_EVENT_CHECKSUM_FAILURE
 
 ER_STMT_CACHE_FULL  
         eng "Multi-row statements required more than 'max_binlog_stmt_cache_size' bytes of storage; increase this mysqld variable and try again"
+
+ER_MULTI_UPDATE_KEY_CONFLICT
+  eng "Primary key/partition key update is not allowed since the table is updated both as '%-.192s' and '%-.192s'."
+
 ER_BINLOG_STMT_CACHE_SIZE_GREATER_THAN_MAX
   eng "Option binlog_stmt_cache_size (%lu) is greater than max_binlog_stmt_cache_size (%lu); setting binlog_stmt_cache_size equal to max_binlog_stmt_cache_size."
 

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2011-02-18 11:39:05 +0000
+++ b/sql/sql_plugin.cc	2011-02-22 02:58:40 +0000
@@ -957,7 +957,10 @@ static void reap_plugins(void)
 
   list= reap;
   while ((plugin= *(--list)))
+  {
+    sql_print_information("Shutting down plugin '%s'", plugin->name.str);
     plugin_deinitialize(plugin, true);
+  }
 
   mysql_mutex_lock(&LOCK_plugin);
 

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-02-18 10:59:18 +0000
+++ b/sql/sql_select.cc	2011-02-22 14:24:33 +0000
@@ -7792,7 +7792,8 @@ optimize_straight_join(JOIN *join, table
 
     /* compute the cost of the new plan extended with 's' */
     record_count*= join->positions[idx].records_read;
-    read_time+=    join->positions[idx].read_time;
+    read_time+=    join->positions[idx].read_time
+                   + record_count / (double) TIME_FOR_COMPARE;
     advance_sj_state(join, join_tables, s, idx, &record_count, &read_time,
                      &loose_scan_pos);
 
@@ -7800,13 +7801,19 @@ optimize_straight_join(JOIN *join, table
     ++idx;
   }
 
-  read_time+= record_count / (double) TIME_FOR_COMPARE;
   if (join->sort_by_table &&
       join->sort_by_table != join->positions[join->const_tables].table->table)
     read_time+= record_count;  // We have to make a temp table
   memcpy((uchar*) join->best_positions, (uchar*) join->positions,
          sizeof(POSITION)*idx);
-  join->best_read= read_time;
+
+  /**
+   * If many plans have identical cost, which one will be used
+   * depends on how compiler optimizes floating-point calculations.
+   * this fix adds repeatability to the optimizer.
+   * (Similar code in best_extension_by_li...)
+   */
+  join->best_read= read_time - 0.001;
 }
 
 
@@ -8037,12 +8044,19 @@ greedy_search(JOIN      *join,
     while (pos && best_table != pos)
       pos= join->best_ref[++best_idx];
     DBUG_ASSERT((pos != NULL)); // should always find 'best_table'
-    /* move 'best_table' at the first free position in the array of joins */
-    swap_variables(JOIN_TAB*, join->best_ref[idx], join->best_ref[best_idx]);
+    /*
+      Maintain '#rows-sorted' order of 'best_ref[]':
+       - Shift 'best_ref[]' to make first position free. 
+       - Insert 'best_table' at the first free position in the array of joins.
+    */
+    memmove(join->best_ref + idx + 1, join->best_ref + idx,
+            sizeof(JOIN_TAB*) * (best_idx - idx));
+    join->best_ref[idx]= best_table;
 
     /* compute the cost of the new plan extended with 'best_table' */
     record_count*= join->positions[idx].records_read;
-    read_time+=    join->positions[idx].read_time;
+    read_time+=    join->positions[idx].read_time
+                   + record_count / (double) TIME_FOR_COMPARE;
 
     remaining_tables&= ~(best_table->table->map);
     --size_remain;
@@ -8087,10 +8101,11 @@ void get_partial_join_cost(JOIN *join, u
     if (join->best_positions[i].records_read)
     {
       record_count *= join->best_positions[i].records_read;
-      read_time += join->best_positions[i].read_time;
+      read_time += join->best_positions[i].read_time
+                   + record_count / (double) TIME_FOR_COMPARE;
     }
   }
-  *read_time_arg= read_time;// + record_count / TIME_FOR_COMPARE;
+  *read_time_arg= read_time;
   *record_count_arg= record_count;
 }
 
@@ -8231,7 +8246,6 @@ best_extension_by_limited_search(JOIN
      'join' is a partial plan with lower cost than the best plan so far,
      so continue expanding it further with the tables in 'remaining_tables'.
   */
-  JOIN_TAB *s;
   double best_record_count= DBL_MAX;
   double best_read_time=    DBL_MAX;
 
@@ -8244,9 +8258,23 @@ best_extension_by_limited_search(JOIN
 
   bool has_sj= !join->select_lex->sj_nests.is_empty();
 
+  JOIN_TAB *s;
+  JOIN_TAB *saved_refs[MAX_TABLES];
+  // Save 'best_ref[]' as we has to restore before return.
+  memcpy(saved_refs, join->best_ref + idx, 
+         sizeof(JOIN_TAB*) * (join->tables - idx));
+
   for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++)
   {
     table_map real_table_bit= s->table->map;
+
+    /*
+      Don't move swap inside conditional code: All items should
+      be uncond. swapped to maintain '#rows-ordered' best_ref[].
+      This is critical for early pruning of bad plans.
+    */
+    swap_variables(JOIN_TAB*, join->best_ref[idx], *pos);
+
     if ((remaining_tables & real_table_bit) && 
         (allowed_tables & real_table_bit) &&
         !(remaining_tables & s->dependent) && 
@@ -8258,12 +8286,13 @@ best_extension_by_limited_search(JOIN
       /* Find the best access method from 's' to the current partial plan */
       POSITION loose_scan_pos;
       best_access_path(join, s, remaining_tables, idx, FALSE, record_count, 
-                       join->positions + idx, &loose_scan_pos);
+                       position, &loose_scan_pos);
 
       /* Compute the cost of extending the plan with 's' */
-
       current_record_count= record_count * position->records_read;
-      current_read_time=    read_time + position->read_time;
+      current_read_time=    read_time
+                            + position->read_time
+                            + current_record_count / (double) TIME_FOR_COMPARE;
 
       if (has_sj)
       {
@@ -8281,15 +8310,12 @@ best_extension_by_limited_search(JOIN
         join->positions[idx].sj_strategy= SJ_OPT_NONE;
 
       /* Expand only partial plans with lower cost than the best QEP so far */
-      if ((current_read_time +
-           current_record_count / (double) TIME_FOR_COMPARE) >= join->best_read)
+      if (current_read_time >= join->best_read)
       {
         DBUG_EXECUTE("opt", print_plan(join, idx+1,
                                        current_record_count,
                                        read_time,
-                                       (current_read_time +
-                                        current_record_count / 
-                                        (double) TIME_FOR_COMPARE),
+                                       current_read_time,
                                        "prune_by_cost"););
         backout_nj_sj_state(remaining_tables, s);
         continue;
@@ -8329,8 +8355,8 @@ best_extension_by_limited_search(JOIN
       }
 
       if ( (search_depth > 1) && (remaining_tables & ~real_table_bit) & allowed_tables )
-      { /* Recursively expand the current partial plan */
-        swap_variables(JOIN_TAB*, join->best_ref[idx], *pos);
+      {
+        /* Explore more best extensions of plan */
         if (best_extension_by_limited_search(join,
                                              remaining_tables & ~real_table_bit,
                                              idx + 1,
@@ -8339,14 +8365,12 @@ best_extension_by_limited_search(JOIN
                                              search_depth - 1,
                                              prune_level))
           DBUG_RETURN(TRUE);
-        swap_variables(JOIN_TAB*, join->best_ref[idx], *pos);
       }
       else
       { /*
           'join' is either the best partial QEP with 'search_depth' relations,
           or the best complete QEP so far, whichever is smaller.
         */
-        current_read_time+= current_record_count / (double) TIME_FOR_COMPARE;
         if (join->sort_by_table &&
             join->sort_by_table !=
             join->positions[join->const_tables].table->table)
@@ -8356,7 +8380,7 @@ best_extension_by_limited_search(JOIN
              Hence it may be wrong.
           */
           current_read_time+= current_record_count;
-        if ((search_depth == 1) || (current_read_time < join->best_read))
+        if (current_read_time < join->best_read)
         {
           memcpy((uchar*) join->best_positions, (uchar*) join->positions,
                  sizeof(POSITION) * (idx + 1));
@@ -8371,6 +8395,9 @@ best_extension_by_limited_search(JOIN
       backout_nj_sj_state(remaining_tables, s);
     }
   }
+
+  // Restore previous #rows sorted best_ref[]
+  memcpy(join->best_ref + idx, saved_refs, sizeof(JOIN_TAB*) * (join->tables-idx));
   DBUG_RETURN(FALSE);
 }
 
@@ -14397,7 +14424,7 @@ void advance_sj_state(JOIN *join, table_
   proceeds up the tree to NJ1, incrementing its counter as well. All join
   nests are now completely covered by the QEP.
 
-  restore_prev_nj_state() does the above in reverse. As seen above, the node
+  backout_nj_sj_state() does the above in reverse. As seen above, the node
   NJ1 contains the nodes t2, t3, and NJ2. Its counter being equal to 3 means
   that the plan covers t2, t3, and NJ2, @e and that the sub-plan (t4 x t5)
   completely covers NJ2. The removal of t5 from the partial plan will first
@@ -14408,7 +14435,7 @@ void advance_sj_state(JOIN *join, table_
   NJ2.
 
   SYNOPSIS
-    restore_prev_nj_state()
+    backout_nj_sj_state()
       last  join table to remove, it is assumed to be the last in current 
             partial join order.
      

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2010-12-29 00:38:59 +0000
+++ b/sql/sql_update.cc	2011-02-21 15:55:58 +0000
@@ -999,6 +999,98 @@ static table_map get_table_map(List<Item
   return map;
 }
 
+/**
+  If one row is updated through two different aliases and the first
+  update physically moves the row, the second update will error
+  because the row is no longer located where expected. This function
+  checks if the multiple-table update is about to do that and if so
+  returns with an error.
+
+  The following update operations physically moves rows:
+    1) Update of a column in a clustered primary key
+    2) Update of a column used to calculate which partition the row belongs to
+
+  This function returns with an error if both of the following are
+  true:
+
+    a) A table in the multiple-table update statement is updated
+       through multiple aliases (including views)
+    b) At least one of the updates on the table from a) may physically
+       moves the row. Note: Updating a column used to calculate which
+       partition a row belongs to does not necessarily mean that the
+       row is moved. The new value may or may not belong to the same
+       partition.
+
+  @param leaves               First leaf table
+  @param tables_for_update    Map of tables that are updated
+
+  @return
+    true   if the update is unsafe, in which case an error message is also set,
+    false  otherwise.
+*/
+static
+bool unsafe_key_update(TABLE_LIST *leaves, table_map tables_for_update)
+{
+  TABLE_LIST *tl= leaves;
+
+  for (tl= leaves; tl ; tl= tl->next_leaf)
+  {
+    if (tl->table->map & tables_for_update)
+    {
+      TABLE *table1= tl->table;
+      bool primkey_clustered= (table1->file->primary_key_is_clustered() &&
+                               table1->s->primary_key != MAX_KEY);
+
+      bool table_partitioned= false;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+      table_partitioned= (table1->part_info != NULL);
+#endif
+
+      if (!table_partitioned && !primkey_clustered)
+        continue;
+
+      for (TABLE_LIST* tl2= tl->next_leaf; tl2 ; tl2= tl2->next_leaf)
+      {
+        /*
+          Look at "next" tables only since all previous tables have
+          already been checked
+        */
+        TABLE *table2= tl2->table;
+        if (table2->map & tables_for_update && table1->s == table2->s)
+        {
+          // A table is updated through two aliases
+          if (table_partitioned &&
+              (partition_key_modified(table1, table1->write_set) ||
+               partition_key_modified(table2, table2->write_set)))
+          {
+            // Partitioned key is updated
+            my_error(ER_MULTI_UPDATE_KEY_CONFLICT, MYF(0),
+                     tl->belong_to_view ? tl->belong_to_view->alias
+                                        : tl->alias,
+                     tl2->belong_to_view ? tl2->belong_to_view->alias
+                                         : tl2->alias);
+            return true;
+          }
+
+          if (primkey_clustered &&
+              (bitmap_is_set(table1->write_set, table1->s->primary_key) ||
+               bitmap_is_set(table2->write_set, table2->s->primary_key)))
+          {
+            // Clustered primary key is updated
+            my_error(ER_MULTI_UPDATE_KEY_CONFLICT, MYF(0),
+                     tl->belong_to_view ? tl->belong_to_view->alias
+                                        : tl->alias,
+                     tl2->belong_to_view ? tl2->belong_to_view->alias
+                                         : tl2->alias);
+            return true;
+          }
+        }
+      }
+    }
+  }
+  return false;
+}
+
 
 /*
   make update specific preparation and checks after opening tables
@@ -1078,10 +1170,14 @@ int mysql_multi_update_prepare(THD *thd)
 
   thd->table_map_for_update= tables_for_update= get_table_map(fields);
 
+  leaves= lex->select_lex.leaf_tables;
+
+  if (unsafe_key_update(leaves, tables_for_update))
+    DBUG_RETURN(true);
+
   /*
     Setup timestamp handling and locking mode
   */
-  leaves= lex->select_lex.leaf_tables;
   for (tl= leaves; tl; tl= tl->next_leaf)
   {
     TABLE *table= tl->table;

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-02-17 11:58:08 +0000
+++ b/sql/sys_vars.cc	2011-02-22 02:58:40 +0000
@@ -359,6 +359,9 @@ static bool fix_binlog_format_after_upda
   return false;
 }
 
+static Sys_var_test_flag Sys_core_file(
+       "core_file", "write a core-file on crashes", TEST_CORE_ON_SIGNAL);
+
 static Sys_var_enum Sys_binlog_format(
        "binlog_format", "What form of binary logging the master will "
        "use: either ROW for row-based binary logging, STATEMENT "
@@ -1520,7 +1523,7 @@ static Sys_var_proxy_user Sys_proxy_user
        "proxy_user", "The proxy user account name used when logging in",
        IN_SYSTEM_CHARSET);
 
-static Sys_var_external_user Sys_exterenal_user(
+static Sys_var_external_user Sys_external_user(
        "external_user", "The external user account used when logging in",
        IN_SYSTEM_CHARSET);
 

=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h	2010-12-21 15:27:40 +0000
+++ b/sql/sys_vars.h	2011-02-10 05:29:15 +0000
@@ -842,6 +842,35 @@ public:
 };
 
 /**
+  The class for @test_flags (core_file for now).
+  It's derived from Sys_var_mybool.
+
+  Class specific constructor arguments:
+    Caller need not pass in a variable as we make up the value on the
+    fly, that is, we derive it from the global test_flags bit vector.
+
+  Backing store: my_bool
+*/
+class Sys_var_test_flag: public Sys_var_mybool
+{
+private:
+  my_bool test_flag_value;
+  uint    test_flag_mask;
+public:
+  Sys_var_test_flag(const char *name_arg, const char *comment, uint mask)
+  : Sys_var_mybool(name_arg, comment, READ_ONLY GLOBAL_VAR(test_flag_value),
+          NO_CMD_LINE, DEFAULT(FALSE))
+  {
+    test_flag_mask= mask;
+  }
+  uchar *global_value_ptr(THD *thd, LEX_STRING *base)
+  {
+    test_flag_value= ((test_flags & test_flag_mask) > 0);
+    return (uchar*) &test_flag_value;
+  }
+};
+
+/**
   The class for the @max_user_connections.
   It's derived from Sys_var_uint, but non-standard session value
   requires a new class.

=== modified file 'strings/ctype-uca.c'
--- a/strings/ctype-uca.c	2011-01-19 13:35:54 +0000
+++ b/strings/ctype-uca.c	2011-02-22 13:25:05 +0000
@@ -20929,6 +20929,18 @@ my_coll_rule_reset(MY_COLL_RULE *r)
 }
 
 
+/*
+  Shift methods:
+  Simple: "&B < C" : weight('C') = weight('B') + 1
+  Expand: weght('C') =  { weight('B'), weight(last_non_ignorable) + 1 }
+*/
+typedef enum
+{
+  my_shift_method_simple= 0,
+  my_shift_method_expand
+} my_coll_shift_method;
+
+
 typedef struct my_coll_rules_st
 {
   uint version;              /* Unicode version, e.g. 400 or 520  */
@@ -20937,6 +20949,7 @@ typedef struct my_coll_rules_st
   size_t mrules;             /* Number of allocated rules         */
   MY_COLL_RULE *rule;        /* Rule array                        */
   MY_CHARSET_LOADER *loader;
+  my_coll_shift_method shift_after_method;
 } MY_COLL_RULES;
 
 
@@ -21204,6 +21217,14 @@ my_coll_parser_scan_setting(MY_COLL_RULE
     rules->version= 520;
     rules->uca= &my_uca_v520;
   }
+  else if (!lex_cmp(lexem, C_STRING_WITH_LEN("[shift-after-method expand]")))
+  {
+    rules->shift_after_method= my_shift_method_expand;
+  }
+  else if (!lex_cmp(lexem, C_STRING_WITH_LEN("[shift-after-method simple]")))
+  {
+    rules->shift_after_method= my_shift_method_simple;
+  }
   else
   {
     return 0;
@@ -21415,7 +21436,8 @@ my_coll_parser_scan_reset_sequence(MY_CO
       return 0;
   }
 
-  if (p->rule.before_level == 1) /* Apply "before primary" option  */
+  if (p->rules->shift_after_method == my_shift_method_expand ||
+      p->rule.before_level == 1) /* Apply "before primary" option  */
   {
     /*
       Suppose we have this rule:  &B[before primary] < C
@@ -21435,6 +21457,10 @@ my_coll_parser_scan_reset_sequence(MY_CO
 
       We'll compose weight for C as: [BBBB-1][MMMM+1]
       where [MMMM] is weight for "last_non_ignorable".
+      
+      We also do the same trick for "reset after" if the collation
+      option says so. E.g. for the rules "&B < C", weight for
+      C will be calculated as: [BBBB][MMMM+1]
 
       At this point we only need to store codepoints
       'B' and 'last_non_ignorable'. Actual weights for 'C'
@@ -21924,7 +21950,27 @@ create_tailoring(CHARSET_INFO *cs, MY_CH
       if (r->before_level == 1) /* Apply "&[before primary]" */
       {
         if (nweights >= 2)
+        {
           to[nweights - 2]--; /* Reset before */
+          if (rules.shift_after_method == my_shift_method_expand)
+          {
+            /*
+              Special case. Don't let characters shifted after X
+              and before next(X) intermix to each other.
+              
+              For example:
+              "[shift-after-method expand] &0 < a &[before primary]1 < A".
+              I.e. we reorder 'a' after '0', and then 'A' before '1'.
+              'a' must be sorted before 'A'.
+              
+              Note, there are no real collations in CLDR which shift
+              after and before two neighbourgh characters. We need this
+              just in case. Reserving 4096 (0x1000) weights for such
+              cases is perfectly enough.
+            */
+            to[nweights - 1]+= 0x1000;
+          }
+        }
         else
         {
           my_snprintf(loader->error, sizeof(loader->error),

=== modified file 'strings/ctype.c'
--- a/strings/ctype.c	2011-02-15 11:30:56 +0000
+++ b/strings/ctype.c	2011-02-22 13:25:05 +0000
@@ -88,6 +88,7 @@ struct my_cs_file_section_st
 #define _CS_UCA_VERSION                 100
 #define _CS_CL_SUPPRESS_CONTRACTIONS    101
 #define _CS_CL_OPTIMIZE                 102
+#define _CS_CL_SHIFT_AFTER_METHOD       103
 
 
 /* Collation Settings */
@@ -187,6 +188,7 @@ static struct my_cs_file_section_st sec[
   {_CS_UCA_VERSION,              "charsets/charset/collation/version"},
   {_CS_CL_SUPPRESS_CONTRACTIONS, "charsets/charset/collation/suppress_contractions"},
   {_CS_CL_OPTIMIZE,              "charsets/charset/collation/optimize"},
+  {_CS_CL_SHIFT_AFTER_METHOD,    "charsets/charset/collation/shift-after-method"},
 
   /* Collation Settings */
   {_CS_ST_SETTINGS,              "charsets/charset/collation/settings"},
@@ -646,6 +648,10 @@ static int cs_value(MY_XML_PARSER *st,co
     rc= tailoring_append(st, "[optimize %.*s]", len, attr);
     break;
 
+  case _CS_CL_SHIFT_AFTER_METHOD:
+    rc= tailoring_append(st, "[shift-after-method %.*s]", len, attr);
+    break;
+
   /* Collation Settings */
   case _CS_ST_STRENGTH:
     /* 1, 2, 3, 4, 5, or primary, secondary, tertiary, quaternary, identical */

No bundle (reason: revision is a merge).
Thread
bzr commit into mysql-trunk-mtr branch (bjorn.munch:3030) Bjorn Munch23 Feb