[Pkg-mysql-commits] [mariadb-5.5] 01/03: Imported Upstream version 5.5.46

Otto Kekäläinen ottok-guest at moszumanska.debian.org
Wed Nov 4 06:38:38 UTC 2015


This is an automated email from the git hooks/post-receive script.

ottok-guest pushed a commit to branch ubuntu-14.04
in repository mariadb-5.5.

commit a90934f371a8979dca5461418b17f34deda5d14e
Author: Otto Kekäläinen <otto at seravo.fi>
Date:   Tue Nov 3 11:31:42 2015 +0200

    Imported Upstream version 5.5.46
---
 Docs/INFO_SRC                                      |   10 +-
 VERSION                                            |    2 +-
 client/CMakeLists.txt                              |    3 +-
 client/mysql_upgrade.c                             |    3 +-
 client/mysqlbinlog.cc                              |    7 +
 client/mysqlimport.c                               |   19 +-
 client/mysqlslap.c                                 |   49 +-
 cmake/os/Windows.cmake                             |   10 +-
 extra/yassl/README                                 |   29 +
 extra/yassl/include/openssl/ssl.h                  |    2 +-
 extra/yassl/include/yassl_error.hpp                |    3 +-
 extra/yassl/src/buffer.cpp                         |    2 +-
 extra/yassl/src/handshake.cpp                      |    2 +
 extra/yassl/src/ssl.cpp                            |   29 +-
 extra/yassl/src/yassl_error.cpp                    |    4 +
 extra/yassl/src/yassl_imp.cpp                      |   15 +-
 extra/yassl/taocrypt/src/asn.cpp                   |    9 +-
 extra/yassl/taocrypt/src/rsa.cpp                   |    4 +
 extra/yassl/testsuite/cipher-test.sh               |    1 +
 mysql-test/disabled.def                            |    3 +-
 .../binlog_tests/mix_innodb_myisam_binlog.test     |    2 +-
 mysql-test/include/restart_mysqld.inc              |   17 +-
 mysql-test/mysql-test-run.pl                       |    1 +
 mysql-test/r/func_gconcat.result                   |   16 +
 mysql-test/r/func_if.result                        |   17 +
 mysql-test/r/func_misc.result                      |  211 ++
 mysql-test/r/information_schema2.result            |   24 +-
 mysql-test/r/innodb_load_xa.result                 |    2 +
 mysql-test/r/loadxml.result                        |   27 +
 mysql-test/r/lowercase_fs_on.result                |    3 +
 mysql-test/r/lowercase_table3.result               |   11 -
 ...{merge_recover.result => myisam_recover.result} |   57 +-
 mysql-test/r/mysqldump.result                      |   29 +-
 mysql-test/r/partition_error.result                |    2 +-
 mysql-test/r/sp-group.result                       |  156 ++
 mysql-test/r/subselect.result                      |   70 +-
 mysql-test/r/subselect_mat.result                  |   18 +
 mysql-test/r/subselect_no_mat.result               |   70 +-
 mysql-test/r/subselect_no_opts.result              |   70 +-
 mysql-test/r/subselect_no_scache.result            |   70 +-
 mysql-test/r/subselect_no_semijoin.result          |   70 +-
 mysql-test/r/subselect_sj_mat.result               |   18 +
 mysql-test/r/update.result                         |   15 +
 mysql-test/r/view.result                           |   50 +
 mysql-test/std_data/bug16171518_1.dat              |   59 +
 mysql-test/std_data/bug16171518_2.dat              |   12 +
 .../suite/binlog/r/binlog_mysqlbinlog_row.result   |    6 +-
 .../binlog/r/binlog_mysqlbinlog_row_innodb.result  |   72 +-
 .../binlog/r/binlog_mysqlbinlog_row_myisam.result  |   72 +-
 .../binlog/r/binlog_row_mix_innodb_myisam.result   |    2 +-
 .../binlog/r/binlog_stm_mix_innodb_myisam.result   |    4 +-
 .../iuds/r/strings_charsets_update_delete.result   |  Bin 112951 -> 113361 bytes
 mysql-test/suite/innodb/r/add_constraint.result    |   13 +
 .../suite/innodb/r/innodb-fk-warnings.result       |  105 +
 mysql-test/suite/innodb/r/innodb-fk.result         |    3 +
 mysql-test/suite/innodb/r/innodb_bug68148.result   |   36 +
 mysql-test/suite/innodb/r/innodb_uninstall.result  |   22 +
 mysql-test/suite/innodb/t/add_constraint.test      |   21 +
 mysql-test/suite/innodb/t/innodb-fk-warnings.test  |  130 ++
 .../suite/innodb/t/innodb_bug60229-master.opt      |    1 -
 mysql-test/suite/innodb/t/innodb_bug60229.test     |    4 +
 mysql-test/suite/innodb/t/innodb_bug68148.test     |   41 +
 mysql-test/suite/innodb/t/innodb_uninstall.opt     |    3 +
 mysql-test/suite/innodb/t/innodb_uninstall.test    |   58 +
 mysql-test/suite/innodb/t/xa_recovery.test         |    6 +
 mysql-test/suite/jp/t/jp_enum_sjis-master.opt      |    1 -
 mysql-test/suite/jp/t/jp_enum_sjis.test            |    4 +
 mysql-test/suite/jp/t/jp_enum_ucs2-master.opt      |    1 -
 mysql-test/suite/jp/t/jp_enum_ucs2.test            |    4 +
 mysql-test/suite/jp/t/jp_enum_ujis-master.opt      |    1 -
 mysql-test/suite/jp/t/jp_enum_ujis.test            |    4 +
 mysql-test/suite/jp/t/jp_enum_utf8-master.opt      |    1 -
 mysql-test/suite/jp/t/jp_enum_utf8.test            |    4 +
 mysql-test/suite/ndb/r/ndb_restore_discover.result |   33 +
 mysql-test/suite/ndb/t/ndb_restore_discover.test   |   70 +
 mysql-test/suite/perfschema/r/query_cache.result   |    4 +-
 mysql-test/suite/perfschema/t/query_cache.test     |    2 +
 .../suite/plugins/r/feedback_plugin_load.result    |    7 +-
 .../suite/plugins/r/feedback_plugin_send.result    |    7 +-
 .../suite/plugins/t/feedback_plugin_load.test      |   19 +-
 .../suite/plugins/t/feedback_plugin_send.test      |    9 +
 mysql-test/suite/rpl/r/rpl_alter.result            |  105 +
 .../rpl/r/show_status_stop_slave_race-7126.result  |    2 +
 mysql-test/suite/rpl/t/rpl_alter.test              |   53 +
 mysql-test/suite/rpl/t/rpl_innodb_bug30888.opt     |    1 +
 .../rpl/t/show_status_stop_slave_race-7126.test    |    7 +
 mysql-test/t/func_gconcat.test                     |   11 +
 mysql-test/t/func_if.test                          |   14 +
 mysql-test/t/func_misc.test                        |  204 ++
 mysql-test/t/information_schema2.test              |   19 +-
 mysql-test/t/innodb_load_xa.test                   |    3 +
 mysql-test/t/loadxml.test                          |   14 +
 mysql-test/t/lowercase_fs_on.test                  |   38 +
 mysql-test/t/lowercase_table3-master.opt           |    1 -
 mysql-test/t/lowercase_table3.test                 |   37 -
 ...ecover-master.opt => myisam_recover-master.opt} |    0
 .../t/{merge_recover.test => myisam_recover.test}  |   77 +-
 mysql-test/t/mysql_upgrade.test                    |    1 -
 mysql-test/t/mysqldump.test                        |   36 +-
 mysql-test/t/partition_error.test                  |    2 +-
 mysql-test/t/sp-group.test                         |  187 ++
 mysql-test/t/subselect.test                        |   76 +-
 mysql-test/t/subselect_sj_mat.test                 |   17 +-
 mysql-test/t/update.test                           |   15 +
 mysql-test/t/view.test                             |   65 +
 mysys/ptr_cmp.c                                    |    3 +-
 regex/regcomp.c                                    |   24 +-
 sql/field.cc                                       |    3 +-
 sql/field.h                                        |   19 +-
 sql/field_conv.cc                                  |   16 +-
 sql/item.cc                                        |   56 +-
 sql/item.h                                         |    7 +-
 sql/item_cmpfunc.cc                                |   53 +-
 sql/item_func.cc                                   |   71 +-
 sql/item_func.h                                    |   39 +-
 sql/item_subselect.cc                              |   34 +-
 sql/item_subselect.h                               |    6 +
 sql/item_sum.cc                                    |   14 +-
 sql/item_sum.h                                     |    1 +
 sql/log.cc                                         |   33 +-
 sql/log_event.cc                                   |   25 +-
 sql/mysqld.cc                                      |   34 +-
 sql/opt_range.cc                                   |   17 +-
 sql/opt_subselect.cc                               |   49 +-
 sql/partition_info.cc                              |   16 +-
 sql/rpl_handler.cc                                 |   54 +-
 sql/rpl_utility.cc                                 |   21 +-
 sql/slave.cc                                       |   10 +-
 sql/sql_acl.cc                                     |   43 +-
 sql/sql_base.cc                                    |   73 +-
 sql/sql_class.cc                                   |    4 +
 sql/sql_class.h                                    |   16 +-
 sql/sql_handler.cc                                 |   37 +-
 sql/sql_handler.h                                  |    5 +-
 sql/sql_insert.cc                                  |   56 +-
 sql/sql_lex.cc                                     |    2 +-
 sql/sql_lex.h                                      |    2 -
 sql/sql_load.cc                                    |   13 +-
 sql/sql_parse.cc                                   |   35 +-
 sql/sql_select.cc                                  |   19 +-
 sql/sql_select.h                                   |    4 +
 sql/sql_show.cc                                    |   20 +-
 sql/sql_table.cc                                   |    6 +
 sql/sql_test.cc                                    |    7 +-
 sql/sql_union.cc                                   |    3 +-
 sql/sql_yacc.cc                                    | 2164 ++++++++++----------
 sql/sql_yacc.yy                                    |   12 +
 sql/table.cc                                       |    2 +-
 storage/innobase/CMakeLists.txt                    |   18 +-
 storage/innobase/btr/btr0cur.c                     |   31 +-
 storage/innobase/dict/dict0crea.c                  |  143 +-
 storage/innobase/dict/dict0dict.c                  |  539 ++++-
 storage/innobase/handler/ha_innodb.cc              |   27 +
 storage/innobase/include/dict0crea.h               |   11 +
 storage/innobase/include/ha_prototypes.h           |    9 +
 storage/innobase/include/os0sync.h                 |  152 +-
 storage/innobase/include/row0purge.h               |   13 +-
 storage/innobase/include/sync0sync.h               |    9 +-
 storage/innobase/include/sync0sync.ic              |    9 +-
 storage/innobase/lock/lock0lock.c                  |   10 +-
 storage/innobase/os/os0file.c                      |   13 +-
 storage/innobase/row/row0purge.c                   |   93 +-
 storage/perfschema/pfs_timer.cc                    |   43 +-
 .../tokudb/ft-index/util}/tests/sm-basic.cc        |    0
 .../ft-index/util}/tests/sm-crash-double-free.cc   |    0
 .../tokudb/mysql-test/tokudb_bugs}/r/db805.result  |    0
 .../tokudb/mysql-test/tokudb_bugs}/r/db806.result  |    0
 .../tokudb/mysql-test/tokudb_bugs}/r/db811.result  |    0
 .../tokudb/mysql-test/tokudb_bugs}/r/db811s.result |    0
 .../tokudb/mysql-test/tokudb_bugs}/r/db823.result  |    0
 .../tokudb/mysql-test/tokudb_bugs}/t/db805.test    |    0
 .../tokudb/mysql-test/tokudb_bugs}/t/db806.test    |    0
 .../tokudb/mysql-test/tokudb_bugs}/t/db811.test    |    0
 .../tokudb/mysql-test/tokudb_bugs}/t/db811s.test   |    0
 .../tokudb/mysql-test/tokudb_bugs}/t/db823.test    |    0
 storage/xtradb/buf/buf0buf.c                       |    6 +-
 storage/xtradb/dict/dict0crea.c                    |  143 +-
 storage/xtradb/dict/dict0dict.c                    |  542 ++++-
 storage/xtradb/handler/ha_innodb.cc                |   60 +-
 storage/xtradb/include/dict0crea.h                 |   11 +
 storage/xtradb/include/ha_prototypes.h             |    9 +
 storage/xtradb/include/row0purge.h                 |   14 +-
 storage/xtradb/include/srv0srv.h                   |    1 -
 storage/xtradb/include/univ.i                      |    4 +-
 storage/xtradb/os/os0file.c                        |   13 +-
 storage/xtradb/row/row0purge.c                     |   94 +-
 storage/xtradb/srv/srv0srv.c                       |    1 -
 storage/xtradb/srv/srv0start.c                     |    4 +-
 storage/xtradb/sync/sync0arr.c                     |    7 +-
 storage/xtradb/trx/trx0trx.c                       |    4 +-
 support-files/mysql.spec.sh                        |   14 +-
 vio/viosslfactories.c                              |   47 +-
 win/packaging/ca/CustomAction.cpp                  |    2 +
 193 files changed, 6348 insertions(+), 1934 deletions(-)

diff --git a/Docs/INFO_SRC b/Docs/INFO_SRC
index 56070a8..bc3dc61 100644
--- a/Docs/INFO_SRC
+++ b/Docs/INFO_SRC
@@ -1,8 +1,8 @@
-commit: 5a44e1a4024f1760021e5c6fd65773584d60513a
-date: 2015-06-09 22:16:26 +0200
-build-date: 2015-06-09 22:25:59 +0200 
-short: 5a44e1a
+commit: 16c4b3c68b06653592a9500050ad977a38f4ebae
+date: 2015-10-09 16:43:59 +0200
+build-date: 2015-10-09 18:51:17 +0200 
+short: 16c4b3c
 branch: HEAD
 
 
-MySQL source 5.5.44
+MySQL source 5.5.46
diff --git a/VERSION b/VERSION
index fa54860..45f770d 100644
--- a/VERSION
+++ b/VERSION
@@ -1,4 +1,4 @@
 MYSQL_VERSION_MAJOR=5
 MYSQL_VERSION_MINOR=5
-MYSQL_VERSION_PATCH=44
+MYSQL_VERSION_PATCH=46
 MYSQL_VERSION_EXTRA=
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index e4507f9..e3edacc 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -47,6 +47,7 @@ MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
 TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
 
 MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
+SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
 TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
 
 MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c COMPONENT Server)
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index d513d5d..ee6845d 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -1061,7 +1061,7 @@ int main(int argc, char **argv)
     printf("This installation of MySQL is already upgraded to %s, "
            "use --force if you still need to run mysql_upgrade\n",
            MYSQL_SERVER_VERSION);
-    die(NULL);
+    goto end;
   }
 
   if (opt_version_check && check_version_match())
@@ -1084,6 +1084,7 @@ int main(int argc, char **argv)
   /* Create a file indicating upgrade has been performed */
   create_mysql_upgrade_info_file();
 
+end:
   free_used_memory();
   my_end(my_end_arg);
   exit(0);
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 5749257..250dc60 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -66,6 +66,7 @@ ulong server_id = 0;
 ulong bytes_sent = 0L, bytes_received = 0L;
 ulong mysqld_net_retry_count = 10L;
 ulong open_files_limit;
+ulong opt_binlog_rows_event_max_size;
 uint test_flags = 0; 
 static uint opt_protocol= 0;
 static FILE *result_file;
@@ -1432,6 +1433,12 @@ that may lead to an endless loop.",
    "Used to reserve file descriptors for use by this program.",
    &open_files_limit, &open_files_limit, 0, GET_ULONG,
    REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
+  {"binlog-row-event-max-size", 0,
+   "The maximum size of a row-based binary log event in bytes. Rows will be "
+   "grouped into events smaller than this size if possible. "
+   "This value must be a multiple of 256.",
+   &opt_binlog_rows_event_max_size, &opt_binlog_rows_event_max_size, 0,
+   GET_ULONG, REQUIRED_ARG, UINT_MAX,  256, ULONG_MAX,  0, 256,  0},
   {"verify-binlog-checksum", 'c', "Verify checksum binlog events.",
    (uchar**) &opt_verify_binlog_checksum, (uchar**) &opt_verify_binlog_checksum,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 686f26c..a22774b 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -1,5 +1,6 @@
 /*
-   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2011, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,19 +31,14 @@
 
 #include "client_priv.h"
 #include "mysql_version.h"
-#ifdef HAVE_LIBPTHREAD
-#include <my_pthread.h>
-#endif
 
 #include <welcome_copyright_notice.h>   /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
 
 
 /* Global Thread counter */
-uint counter;
-#ifdef HAVE_LIBPTHREAD
+uint counter= 0;
 pthread_mutex_t counter_mutex;
 pthread_cond_t count_threshhold;
-#endif
 
 static void db_error_with_table(MYSQL *mysql, char *table);
 static void db_error(MYSQL *mysql);
@@ -486,6 +482,11 @@ static void safe_exit(int error, MYSQL *mysql)
 {
   if (error && ignore_errors)
     return;
+
+  /* in multi-threaded mode protect from concurrent safe_exit's */
+  if (counter)
+    pthread_mutex_lock(&counter_mutex);
+
   if (mysql)
     mysql_close(mysql);
 
@@ -568,7 +569,6 @@ static char *field_escape(char *to,const char *from,uint length)
 
 int exitcode= 0;
 
-#ifdef HAVE_LIBPTHREAD
 pthread_handler_t worker_thread(void *arg)
 {
   int error;
@@ -608,7 +608,6 @@ error:
 
   return 0;
 }
-#endif
 
 
 int main(int argc, char **argv)
@@ -628,7 +627,6 @@ int main(int argc, char **argv)
   }
   sf_leaking_memory=0; /* from now on we cleanup properly */
 
-#ifdef HAVE_LIBPTHREAD
   if (opt_use_threads && !lock_tables)
   {
     pthread_t mainthread;            /* Thread descriptor */
@@ -682,7 +680,6 @@ int main(int argc, char **argv)
     pthread_attr_destroy(&attr);
   }
   else
-#endif
   {
     MYSQL *mysql= 0;
     if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 536535b..03301b0 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -1,5 +1,6 @@
 /*
-   Copyright (c) 2005, 2012, Oracle and/or its affiliates.
+   Copyright (c) 2005, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2010, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -244,7 +245,7 @@ void print_conclusions_csv(conclusions *con);
 void generate_stats(conclusions *con, option_string *eng, stats *sptr);
 uint parse_comma(const char *string, uint **range);
 uint parse_delimiter(const char *script, statement **stmt, char delm);
-uint parse_option(const char *origin, option_string **stmt, char delm);
+int parse_option(const char *origin, option_string **stmt, char delm);
 static int drop_schema(MYSQL *mysql, const char *db);
 uint get_random_string(char *buf);
 static statement *build_table_string(void);
@@ -1259,7 +1260,13 @@ get_options(int *argc,char ***argv)
   if (num_int_cols_opt)
   {
     option_string *str;
-    parse_option(num_int_cols_opt, &str, ',');
+    if(parse_option(num_int_cols_opt, &str, ',') == -1)
+    {
+      fprintf(stderr, "Invalid value specified for the option "
+              "'number-int-cols'\n");
+      option_cleanup(str);
+      return 1;
+    }
     num_int_cols= atoi(str->string);
     if (str->option)
       num_int_cols_index= atoi(str->option);
@@ -1270,7 +1277,13 @@ get_options(int *argc,char ***argv)
   if (num_char_cols_opt)
   {
     option_string *str;
-    parse_option(num_char_cols_opt, &str, ',');
+    if(parse_option(num_char_cols_opt, &str, ',') == -1)
+    {
+      fprintf(stderr, "Invalid value specified for the option "
+              "'number-char-cols'\n");
+      option_cleanup(str);
+      return 1;
+    }
     num_char_cols= atoi(str->string);
     if (str->option)
       num_char_cols_index= atoi(str->option);
@@ -1507,7 +1520,13 @@ get_options(int *argc,char ***argv)
     printf("Parsing engines to use.\n");
 
   if (default_engine)
-    parse_option(default_engine, &engine_options, ',');
+  {
+    if(parse_option(default_engine, &engine_options, ',') == -1)
+    {
+      fprintf(stderr, "Invalid value specified for the option 'engine'\n");
+      return 1;
+    }
+  }
 
   if (tty_password)
     opt_password= get_tty_password(NullS);
@@ -1984,7 +2003,7 @@ end:
   DBUG_RETURN(0);
 }
 
-uint
+int
 parse_option(const char *origin, option_string **stmt, char delm)
 {
   char *retstr;
@@ -2009,6 +2028,13 @@ parse_option(const char *origin, option_string **stmt, char delm)
     char buffer[HUGE_STRING_LENGTH]= "";
     char *buffer_ptr;
 
+    /*
+      Return an error if the length of the any of the comma seprated value
+      exceeds HUGE_STRING_LENGTH.
+    */
+    if ((size_t)(retstr - ptr) > HUGE_STRING_LENGTH)
+      return -1;
+
     count++;
     strncpy(buffer, ptr, (size_t)(retstr - ptr));
     /*
@@ -2048,6 +2074,13 @@ parse_option(const char *origin, option_string **stmt, char delm)
   {
     char *origin_ptr;
 
+    /*
+      Return an error if the length of the any of the comma seprated value
+      exceeds HUGE_STRING_LENGTH.
+    */
+    if (strlen(ptr) > HUGE_STRING_LENGTH)
+      return -1;
+
     if ((origin_ptr= strchr(ptr, ':')))
     {
       char *option_ptr;
@@ -2058,13 +2091,13 @@ parse_option(const char *origin, option_string **stmt, char delm)
       option_ptr= (char *)ptr + 1 + tmp->length;
 
       /* Move past the : and the first string */
-      tmp->option_length= (size_t)((ptr + length) - option_ptr);
+      tmp->option_length= strlen(option_ptr);
       tmp->option= my_strndup(option_ptr, tmp->option_length,
                               MYF(MY_FAE));
     }
     else
     {
-      tmp->length= (size_t)((ptr + length) - ptr);
+      tmp->length= strlen(ptr);
       tmp->string= my_strndup(ptr, tmp->length, MYF(MY_FAE));
     }
 
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake
index 16c2743..5999ae6 100644
--- a/cmake/os/Windows.cmake
+++ b/cmake/os/Windows.cmake
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -50,10 +50,12 @@ IF(CMAKE_C_COMPILER MATCHES "icl")
  SET(MSVC TRUE)
 ENDIF()
 
-ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
-ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501")
+ADD_DEFINITIONS(-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE)
+ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501)
+# We do not want the windows.h macros min/max
+ADD_DEFINITIONS(-DNOMINMAX)
 # Speed up build process excluding unused header files
-ADD_DEFINITIONS("-DWIN32_LEAN_AND_MEAN")
+ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
   
 # Adjust compiler and linker flags
 IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
diff --git a/extra/yassl/README b/extra/yassl/README
index da399c3..bf0e1c9 100644
--- a/extra/yassl/README
+++ b/extra/yassl/README
@@ -12,6 +12,35 @@ before calling SSL_new();
 
 *** end Note ***
 
+yaSSL Release notes, version 2.3.8 (9/17/2015)
+    This release of yaSSL fixes a high security vulnerability.  All users
+    SHOULD update.  If using yaSSL for TLS on the server side with private
+    RSA keys allowing ephemeral key exchange you MUST update and regenerate
+    the RSA private keys.  This report is detailed in:
+    https://people.redhat.com/~fweimer/rsa-crt-leaks.pdf
+    yaSSL now detects RSA signature faults and returns an error.
+
+yaSSL Patch notes, version 2.3.7e (6/26/2015)
+    This release of yaSSL includes a fix for Date less than comparison.
+    Previously yaSSL would return true on less than comparisons if the Dates
+    were equal. Reported by Oracle. No security problem, but if a cert was
+    generated right now, a server started using it in the same second, and a
+    client tried to verify it in the same second it would report not yet valid.
+
+yaSSL Patch notes, version 2.3.7d (6/22/2015)
+    This release of yaSSL includes a fix for input_buffer set_current with
+    index 0.  SSL_peek() at front of waiting data could trigger.  Robert
+    Golebiowski of Oracle identified and suggested a fix, thanks!
+
+yaSSL Patch notes, version 2.3.7c (6/12/2015)
+    This release of yaSSL does certificate DATE comparisons to the second
+    instead of to the minute, helpful when using freshly generated certs.
+    Though keep in mind that time sync differences could still show up.
+
+yaSSL Patch notes, version 2.3.7b (3/18/2015)
+    This release of yaSSL fixes a potential crash with corrupted private keys.
+    Also detects bad keys earlier for user.
+
 yaSSL Release notes, version 2.3.7 (12/10/2014)
     This release of yaSSL fixes the potential to process duplicate handshake
     messages by explicitly marking/checking received handshake messages.
diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h
index 24acc7e..b0a7592 100644
--- a/extra/yassl/include/openssl/ssl.h
+++ b/extra/yassl/include/openssl/ssl.h
@@ -35,7 +35,7 @@
 #include "rsa.h"
 
 
-#define YASSL_VERSION "2.3.7"
+#define YASSL_VERSION "2.3.8"
 
 
 #if defined(__cplusplus)
diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp
index beba7b0..d63244d 100644
--- a/extra/yassl/include/yassl_error.hpp
+++ b/extra/yassl/include/yassl_error.hpp
@@ -53,7 +53,8 @@ enum YasslError {
     compress_error      = 118,
     decompress_error    = 119,
     pms_version_error   = 120,
-    sanityCipher_error  = 121
+    sanityCipher_error  = 121,
+    rsaSignFault_error  = 122
 
     // !!!! add error message to .cpp !!!!
 
diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp
index ee5e0cc..532da38 100644
--- a/extra/yassl/src/buffer.cpp
+++ b/extra/yassl/src/buffer.cpp
@@ -165,7 +165,7 @@ void input_buffer::set_error()
 
 void input_buffer::set_current(uint i) 
 {
-    if (error_ == 0 && (i == 0 || check(i - 1, size_) == 0))
+    if (error_ == 0 && check(i ? i - 1 : 0, size_) == 0)
         current_ = i;
     else
         error_ = -1;
diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp
index 33303b1..aa2de39 100644
--- a/extra/yassl/src/handshake.cpp
+++ b/extra/yassl/src/handshake.cpp
@@ -1172,6 +1172,8 @@ void sendCertificateVerify(SSL& ssl, BufferOutput buffer)
 
     CertificateVerify  verify;
     verify.Build(ssl);
+    if (ssl.GetError()) return;
+
     RecordLayerHeader  rlHeader;
     HandShakeHeader    hsHeader;
     mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);
diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp
index 9c1016b..9516e8b 100644
--- a/extra/yassl/src/ssl.cpp
+++ b/extra/yassl/src/ssl.cpp
@@ -37,6 +37,8 @@
 #include "file.hpp"             // for TaoCrypt Source
 #include "coding.hpp"           // HexDecoder
 #include "helpers.hpp"          // for placement new hack
+#include "rsa.hpp"              // for TaoCrypt RSA key decode
+#include "dsa.hpp"              // for TaoCrypt DSA key decode
 #include <stdio.h>
 
 #ifdef _WIN32
@@ -54,6 +56,8 @@ namespace yaSSL {
 
 int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
 {
+    int ret = SSL_SUCCESS;
+
     if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)
         return SSL_BAD_FILETYPE;
 
@@ -141,8 +145,31 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
             }
         }
     }
+
+    if (type == PrivateKey && ctx->privateKey_) {
+        // see if key is valid early
+        TaoCrypt::Source rsaSource(ctx->privateKey_->get_buffer(),
+                                   ctx->privateKey_->get_length());
+        TaoCrypt::RSA_PrivateKey rsaKey;
+        rsaKey.Initialize(rsaSource);
+
+        if (rsaSource.GetError().What()) {
+            // rsa failed see if DSA works
+
+            TaoCrypt::Source dsaSource(ctx->privateKey_->get_buffer(),
+                                       ctx->privateKey_->get_length());
+            TaoCrypt::DSA_PrivateKey dsaKey;
+            dsaKey.Initialize(dsaSource);
+
+            if (rsaSource.GetError().What()) {
+                // neither worked
+                ret = SSL_FAILURE;
+            }
+        }
+    }
+
     fclose(input);
-    return SSL_SUCCESS;
+    return ret;
 }
 
 
diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp
index 36e286a..fec6a33 100644
--- a/extra/yassl/src/yassl_error.cpp
+++ b/extra/yassl/src/yassl_error.cpp
@@ -148,6 +148,10 @@ void SetErrorString(YasslError error, char* buffer)
         strncpy(buffer, "sanity check on cipher text size error", max);
         break;
 
+    case rsaSignFault_error:
+        strncpy(buffer, "rsa signature fault error", max);
+        break;
+
         // openssl errors
     case SSL_ERROR_WANT_READ :
         strncpy(buffer, "the read operation would block", max);
diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp
index 742d079..e1a4100 100644
--- a/extra/yassl/src/yassl_imp.cpp
+++ b/extra/yassl/src/yassl_imp.cpp
@@ -196,9 +196,16 @@ void DH_Server::build(SSL& ssl)
     sha.update(tmp.get_buffer(), tmp.get_size());
     sha.get_digest(&hash[MD5_LEN]);
 
-    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo)
+    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) {
         auth->sign(signature_, hash, sizeof(hash),
                    ssl.getCrypto().get_random());
+        // check for rsa signautre fault
+        if (!auth->verify(hash, sizeof(hash), signature_,
+                                              auth->get_signatureLength())) {
+            ssl.SetError(rsaSignFault_error);
+            return;
+        }
+    }
     else {
         auth->sign(signature_, &hash[MD5_LEN], SHA_LEN,
                    ssl.getCrypto().get_random());
@@ -2159,6 +2166,12 @@ void CertificateVerify::Build(SSL& ssl)
         memcpy(sig.get(), len, VERIFY_HEADER);
         rsa.sign(sig.get() + VERIFY_HEADER, hashes_.md5_, sizeof(Hashes),
                  ssl.getCrypto().get_random());
+        // check for rsa signautre fault
+        if (!rsa.verify(hashes_.md5_, sizeof(Hashes), sig.get() + VERIFY_HEADER,
+                                                      rsa.get_cipherLength())) {
+            ssl.SetError(rsaSignFault_error);
+            return;
+        }
     }
     else {  // DSA
         DSS dss(cert.get_privateKey(), cert.get_privateKeyLength(), false);
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index d521088..c419ec0 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -39,7 +39,7 @@ namespace TaoCrypt {
 namespace { // locals
 
 
-// to the minute
+// to the second
 bool operator>(tm& a, tm& b)
 {
     if (a.tm_year > b.tm_year)
@@ -60,13 +60,18 @@ bool operator>(tm& a, tm& b)
         a.tm_min > b.tm_min)
         return true;
 
+    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon &&
+        a.tm_mday == b.tm_mday && a.tm_hour == b.tm_hour &&
+        a.tm_min  == b.tm_min  && a.tm_sec > b.tm_sec)
+        return true;
+
     return false;
 }
 
 
 bool operator<(tm& a, tm&b)
 {
-    return !(a>b);
+    return (b>a);
 }
 
 
diff --git a/extra/yassl/taocrypt/src/rsa.cpp b/extra/yassl/taocrypt/src/rsa.cpp
index 79a8a8f..73f678e 100644
--- a/extra/yassl/taocrypt/src/rsa.cpp
+++ b/extra/yassl/taocrypt/src/rsa.cpp
@@ -140,6 +140,10 @@ word32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
 void RSA_BlockType1::Pad(const byte* input, word32 inputLen, byte* pkcsBlock,
                          word32 pkcsBlockLen, RandomNumberGenerator&) const
 {
+    // sanity checks
+    if (input == NULL || pkcsBlock == NULL)
+        return;
+
     // convert from bit length to byte length
     if (pkcsBlockLen % 8 != 0)
     {
diff --git a/extra/yassl/testsuite/cipher-test.sh b/extra/yassl/testsuite/cipher-test.sh
index 5ce2945..d3e6914 100644
--- a/extra/yassl/testsuite/cipher-test.sh
+++ b/extra/yassl/testsuite/cipher-test.sh
@@ -4,6 +4,7 @@
 # 
 
 
+no_pid=-1
 server_pid=$no_pid
 
 
diff --git a/mysql-test/disabled.def b/mysql-test/disabled.def
index 6dc3066..3108906 100644
--- a/mysql-test/disabled.def
+++ b/mysql-test/disabled.def
@@ -11,9 +11,8 @@
 ##############################################################################
 tablespace               : disabled in MariaDB (no TABLESPACE table attribute)
 events_time_zone         : Test is not predictable as it depends on precise timing.
-lowercase_table3         : Bug#11762269 2010-06-30 alik main.lowercase_table3 on Mac OSX
 read_many_rows_innodb    : Bug#11748886 2010-11-15 mattiasj report already exists
-archive-big              : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc
 log_tables-big           : Bug#11756699 2010-11-15 mattiasj report already exists
 mysql_embedded           : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836
 file_contents            : MDEV-6526 these files are not installed anymore
+lowercase_fs_on          : lower_case_table_names=0 is not an error until 10.1
diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
index b41bfea..336b111 100644
--- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
+++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
@@ -228,7 +228,7 @@ rollback;
 create table t0 (n int);
 insert t0 select * from t1;
 set autocommit=1;
-insert into t0 select GET_LOCK("lock1",null);
+insert into t0 select GET_LOCK("lock1",0);
 set autocommit=0;
 create table t2 (n int) engine=innodb;
 insert into t2 values (3); 
diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc
index 7cb9c79..ed0fe64 100644
--- a/mysql-test/include/restart_mysqld.inc
+++ b/mysql-test/include/restart_mysqld.inc
@@ -1,3 +1,8 @@
+# ==== Usage ====
+#
+# [--let $shutdown_timeout= 30]
+# [--let $allow_rpl_inited= 1]
+# --source include/restart_mysqld.inc
 
 if ($rpl_inited)
 {
@@ -7,6 +12,16 @@ if ($rpl_inited)
   }
 }
 
+--let $server_shutdown_timeout= 10
+if ($shutdown_timeout) 
+{
+  --let $server_shutdown_timeout= $shutdown_timeout
+}
+if ($shutdown_timeout == 0)
+{
+  --let $server_shutdown_timeout= 0
+}
+
 # Write file to make mysql-test-run.pl expect the "crash", but don't start
 # it until it's told to
 --let $_server_id= `SELECT @@server_id`
@@ -15,7 +30,7 @@ if ($rpl_inited)
 
 # Send shutdown to the connected server and give
 # it 10 seconds to die before zapping it
-shutdown_server 10;
+shutdown_server $server_shutdown_timeout;
 
 # Write file to make mysql-test-run.pl start up the server again
 --exec echo "restart" > $_expect_file_name
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 566423a..26b31d3 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -4806,6 +4806,7 @@ sub extract_warning_lines ($$) {
      qr|Plugin 'FEEDBACK' registration as a INFORMATION SCHEMA failed|,
      qr|Failed to setup SSL|,
      qr|SSL error: Failed to set ciphers to use|,
+     qr/Plugin 'InnoDB' will be forced to shutdown/,
     );
 
   my $matched_lines= [];
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index f12a0c1..0bc31a5 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -1103,3 +1103,19 @@ ORDER BY field;
 field
 c,c
 drop table t3, t2, t1;
+#
+# MDEV-7821 - Server crashes in Item_func_group_concat::fix_fields on 2nd
+#             execution of PS
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1),(2);
+PREPARE stmt FROM "SELECT GROUP_CONCAT(t1a.a ORDER BY 1, t1a.a=0) FROM t1 AS t1a, t1 AS t1b GROUP BY t1a.a";
+EXECUTE stmt;
+GROUP_CONCAT(t1a.a ORDER BY 1, t1a.a=0)
+1,1
+2,2
+EXECUTE stmt;
+GROUP_CONCAT(t1a.a ORDER BY 1, t1a.a=0)
+1,1
+2,2
+DROP TABLE t1;
diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result
index c7f548a..61f63cc 100644
--- a/mysql-test/r/func_if.result
+++ b/mysql-test/r/func_if.result
@@ -234,3 +234,20 @@ SELECT if(1, NULL, (SELECT min('hello')));
 if(1, NULL, (SELECT min('hello')))
 NULL
 End of 5.2 tests
+#
+# MDEV-8663: IF Statement returns multiple values erroneously
+# (or Assertion `!null_value' failed in Item::send(Protocol*, String*)
+#
+CREATE TABLE `t1` (
+`datas` VARCHAR(25) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+Warnings:
+Warning	1286	Unknown storage engine 'InnoDB'
+Warning	1266	Using storage engine MyISAM for table 't1'
+INSERT INTO `t1` VALUES ('1,2'), ('2,3'), ('3,4');
+SELECT IF(FIND_IN_SET('1', `datas`), 1.5, IF(FIND_IN_SET('2', `datas`), 2, NULL)) AS `First`, '1' AS `Second`, '2' AS `Third` FROM `t1`;
+First	Second	Third
+1.5	1	2
+2.0	1	2
+NULL	1	2
+drop table t1;
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index d5db28f..a121bd3 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -361,5 +361,216 @@ set optimizer_switch=@optimizer_switch_save;
 drop view  v_merge, vm;
 drop table t1,tv;
 #
+# MDEV-4017 - GET_LOCK() with negative timeouts has strange behavior
+#
+SELECT GET_LOCK('ul1', NULL);
+GET_LOCK('ul1', NULL)
+NULL
+Warnings:
+Warning	1411	Incorrect timeout value: 'NULL' for function get_lock
+SELECT GET_LOCK('ul1', -1);
+GET_LOCK('ul1', -1)
+NULL
+Warnings:
+Warning	1411	Incorrect timeout value: '-1' for function get_lock
+#
+# MDEV-8624 MariaDB hangs on query with many logical condition
+#
+CREATE TABLE `t1` (
+`id` int(11) NOT NULL AUTO_INCREMENT,
+`submitdate` datetime DEFAULT NULL,
+`lastpage` int(11) DEFAULT NULL,
+`startlanguage` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
+`token` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
+`datestamp` datetime NOT NULL,
+`startdate` datetime NOT NULL,
+`ipaddr` text COLLATE utf8_unicode_ci,
+`refurl` text COLLATE utf8_unicode_ci,
+`57813X540X1723` text COLLATE utf8_unicode_ci,
+`57813X540X1724` text COLLATE utf8_unicode_ci,
+`57813X540X1725` text COLLATE utf8_unicode_ci,
+`57813X540X1726` double DEFAULT NULL,
+`57813X540X1909` double DEFAULT NULL,
+`57813X541X17271` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X541X17272` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X541X17273` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X541X17274` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X541X17275` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X541X17276` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X541X17281` text COLLATE utf8_unicode_ci,
+`57813X541X17282` text COLLATE utf8_unicode_ci,
+`57813X541X17283` text COLLATE utf8_unicode_ci,
+`57813X541X17284` text COLLATE utf8_unicode_ci,
+`57813X541X17285` text COLLATE utf8_unicode_ci,
+`57813X541X17286` text COLLATE utf8_unicode_ci,
+`57813X542X18131` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18132` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18133` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18134` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18135` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18136` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18137` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18138` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18139` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X542X18141` text COLLATE utf8_unicode_ci,
+`57813X542X18142` text COLLATE utf8_unicode_ci,
+`57813X542X18143` text COLLATE utf8_unicode_ci,
+`57813X542X18144` text COLLATE utf8_unicode_ci,
+`57813X542X18145` text COLLATE utf8_unicode_ci,
+`57813X542X18146` text COLLATE utf8_unicode_ci,
+`57813X542X18147` text COLLATE utf8_unicode_ci,
+`57813X542X18148` text COLLATE utf8_unicode_ci,
+`57813X542X18149` text COLLATE utf8_unicode_ci,
+`57813X543X18451` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X543X18452` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X543X18453` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X543X18454` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X543X18455` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X543X18456` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X543X18461` text COLLATE utf8_unicode_ci,
+`57813X543X18462` text COLLATE utf8_unicode_ci,
+`57813X543X18463` text COLLATE utf8_unicode_ci,
+`57813X543X18464` text COLLATE utf8_unicode_ci,
+`57813X543X18465` text COLLATE utf8_unicode_ci,
+`57813X543X18466` text COLLATE utf8_unicode_ci,
+`57813X544X18711` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18712` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18713` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18714` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18715` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18716` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18717` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18718` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X544X18721` text COLLATE utf8_unicode_ci,
+`57813X544X18722` text COLLATE utf8_unicode_ci,
+`57813X544X18723` text COLLATE utf8_unicode_ci,
+`57813X544X18724` text COLLATE utf8_unicode_ci,
+`57813X544X18725` text COLLATE utf8_unicode_ci,
+`57813X544X18726` text COLLATE utf8_unicode_ci,
+`57813X544X18727` text COLLATE utf8_unicode_ci,
+`57813X544X18728` text COLLATE utf8_unicode_ci,
+`57813X546X1902` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X546X1903` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X546X1904` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+`57813X545X1901` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
+PRIMARY KEY (`id`),
+KEY `lime_survey_57813_idx` (`token`),
+KEY `57813X540X1723` (`57813X540X1723`(100)),
+KEY `57813X540X1724` (`57813X540X1724`(100)),
+KEY `57813X540X1726` (`57813X540X1726`),
+KEY `57813X540X1725` (`57813X540X1725`(100)),
+KEY `57813X546X1902` (`57813X546X1902`),
+KEY `57813X546X1903` (`57813X546X1903`),
+KEY `57813X546X1904` (`57813X546X1904`)
+);
+SELECT 
+COUNT(*) as `N`, 
+ROUND( 
+( 
+SUM( 
+( 
+( 
+IF( 57813X541X17271 IS NOT NULL AND 57813X541X17271 != '' AND 57813X541X17271 != '99', 57813X541X17271, 0 ) + 
+IF( 57813X541X17272 IS NOT NULL AND 57813X541X17272 != '' AND 57813X541X17272 != '99', 57813X541X17272, 0 ) + 
+IF( 57813X541X17273 IS NOT NULL AND 57813X541X17273 != '' AND 57813X541X17273 != '99', 57813X541X17273, 0 ) + 
+IF( 57813X541X17274 IS NOT NULL AND 57813X541X17274 != '' AND 57813X541X17274 != '99', 57813X541X17274, 0 ) + 
+IF( 57813X541X17275 IS NOT NULL AND 57813X541X17275 != '' AND 57813X541X17275 != '99', 57813X541X17275, 0 ) +
+IF( 57813X541X17276 IS NOT NULL AND 57813X541X17276 != '' AND 57813X541X17276 != '99', 57813X541X17276, 0 ) + 
+IF( 57813X542X18131 IS NOT NULL AND 57813X542X18131 != '' AND 57813X542X18131 != '99', 57813X542X18131, 0 ) + 
+IF( 57813X542X18132 IS NOT NULL AND 57813X542X18132 != '' AND 57813X542X18132 != '99', 57813X542X18132, 0 ) + 
+IF( 57813X542X18133 IS NOT NULL AND 57813X542X18133 != '' AND 57813X542X18133 != '99', 57813X542X18133, 0 ) + 
+IF( 57813X542X18134 IS NOT NULL AND 57813X542X18134 != '' AND 57813X542X18134 != '99', 57813X542X18134, 0 ) + 
+IF( 57813X542X18135 IS NOT NULL AND 57813X542X18135 != '' AND 57813X542X18135 != '99', 57813X542X18135, 0 ) + 
+IF( 57813X542X18136 IS NOT NULL AND 57813X542X18136 != '' AND 57813X542X18136 != '99', 57813X542X18136, 0 ) + 
+IF( 57813X542X18137 IS NOT NULL AND 57813X542X18137 != '' AND 57813X542X18137 != '99', 57813X542X18137, 0 ) + 
+IF( 57813X542X18138 IS NOT NULL AND 57813X542X18138 != '' AND 57813X542X18138 != '99', 57813X542X18138, 0 ) + 
+IF( 57813X542X18139 IS NOT NULL AND 57813X542X18139 != '' AND 57813X542X18139 != '99', 57813X542X18139, 0 ) + 
+IF( 57813X543X18451 IS NOT NULL AND 57813X543X18451 != '' AND 57813X543X18451 != '99', 57813X543X18451, 0 ) + 
+IF( 57813X543X18452 IS NOT NULL AND 57813X543X18452 != '' AND 57813X543X18452 != '99', 57813X543X18452, 0 ) + 
+IF( 57813X543X18453 IS NOT NULL AND 57813X543X18453 != '' AND 57813X543X18453 != '99', 57813X543X18453, 0 ) + 
+IF( 57813X543X18454 IS NOT NULL AND 57813X543X18454 != '' AND 57813X543X18454 != '99', 57813X543X18454, 0 ) + 
+IF( 57813X543X18455 IS NOT NULL AND 57813X543X18455 != '' AND 57813X543X18455 != '99', 57813X543X18455, 0 ) + 
+IF( 57813X543X18456 IS NOT NULL AND 57813X543X18456 != '' AND 57813X543X18456 != '99', 57813X543X18456, 0 ) + 
+IF( 57813X544X18711 IS NOT NULL AND 57813X544X18711 != '' AND 57813X544X18711 != '99', 57813X544X18711, 0 ) + 
+IF( 57813X544X18712 IS NOT NULL AND 57813X544X18712 != '' AND 57813X544X18712 != '99', 57813X544X18712, 0 ) + 
+IF( 57813X544X18713 IS NOT NULL AND 57813X544X18713 != '' AND 57813X544X18713 != '99', 57813X544X18713, 0 ) + 
+IF( 57813X544X18714 IS NOT NULL AND 57813X544X18714 != '' AND 57813X544X18714 != '99', 57813X544X18714, 0 ) + 
+IF( 57813X544X18715 IS NOT NULL AND 57813X544X18715 != '' AND 57813X544X18715 != '99', 57813X544X18715, 0 ) + 
+IF( 57813X544X18716 IS NOT NULL AND 57813X544X18716 != '' AND 57813X544X18716 != '99', 57813X544X18716, 0 ) + 
+IF( 57813X544X18717 IS NOT NULL AND 57813X544X18717 != '' AND 57813X544X18717 != '99', 57813X544X18717, 0 ) + 
+IF( 57813X544X18718 IS NOT NULL AND 57813X544X18718 != '' AND 57813X544X18718 != '99', 57813X544X18718, 0 ) 
+) 
+/ 
+(
+IF( 57813X541X17271 IS NOT NULL AND 57813X541X17271 != '' AND 57813X541X17271 != '99', 1, 0 ) + 
+IF( 57813X541X17272 IS NOT NULL AND 57813X541X17272 != '' AND 57813X541X17272 != '99', 1, 0 ) + 
+IF( 57813X541X17273 IS NOT NULL AND 57813X541X17273 != '' AND 57813X541X17273 != '99', 1, 0 ) + 
+IF( 57813X541X17274 IS NOT NULL AND 57813X541X17274 != '' AND 57813X541X17274 != '99', 1, 0 ) + 
+IF( 57813X541X17275 IS NOT NULL AND 57813X541X17275 != '' AND 57813X541X17275 != '99', 1, 0 ) + 
+IF( 57813X541X17276 IS NOT NULL AND 57813X541X17276 != '' AND 57813X541X17276 != '99', 1, 0 ) + 
+IF( 57813X542X18131 IS NOT NULL AND 57813X542X18131 != '' AND 57813X542X18131 != '99', 1, 0 ) + 
+IF( 57813X542X18132 IS NOT NULL AND 57813X542X18132 != '' AND 57813X542X18132 != '99', 1, 0 ) + 
+IF( 57813X542X18133 IS NOT NULL AND 57813X542X18133 != '' AND 57813X542X18133 != '99', 1, 0 ) + 
+IF( 57813X542X18134 IS NOT NULL AND 57813X542X18134 != '' AND 57813X542X18134 != '99', 1, 0 ) + 
+IF( 57813X542X18135 IS NOT NULL AND 57813X542X18135 != '' AND 57813X542X18135 != '99', 1, 0 ) + 
+IF( 57813X542X18136 IS NOT NULL AND 57813X542X18136 != '' AND 57813X542X18136 != '99', 1, 0 ) + 
+IF( 57813X542X18137 IS NOT NULL AND 57813X542X18137 != '' AND 57813X542X18137 != '99', 1, 0 ) + 
+IF( 57813X542X18138 IS NOT NULL AND 57813X542X18138 != '' AND 57813X542X18138 != '99', 1, 0 ) + 
+IF( 57813X542X18139 IS NOT NULL AND 57813X542X18139 != '' AND 57813X542X18139 != '99', 1, 0 ) + 
+IF( 57813X543X18451 IS NOT NULL AND 57813X543X18451 != '' AND 57813X543X18451 != '99', 1, 0 ) + 
+IF( 57813X543X18452 IS NOT NULL AND 57813X543X18452 != '' AND 57813X543X18452 != '99', 1, 0 ) + 
+IF( 57813X543X18453 IS NOT NULL AND 57813X543X18453 != '' AND 57813X543X18453 != '99', 1, 0 ) + 
+IF( 57813X543X18454 IS NOT NULL AND 57813X543X18454 != '' AND 57813X543X18454 != '99', 1, 0 ) + 
+IF( 57813X543X18455 IS NOT NULL AND 57813X543X18455 != '' AND 57813X543X18455 != '99', 1, 0 ) + 
+IF( 57813X543X18456 IS NOT NULL AND 57813X543X18456 != '' AND 57813X543X18456 != '99', 1, 0 ) + 
+IF( 57813X544X18711 IS NOT NULL AND 57813X544X18711 != '' AND 57813X544X18711 != '99', 1, 0 ) + 
+IF( 57813X544X18712 IS NOT NULL AND 57813X544X18712 != '' AND 57813X544X18712 != '99', 1, 0 ) + 
+IF( 57813X544X18713 IS NOT NULL AND 57813X544X18713 != '' AND 57813X544X18713 != '99', 1, 0 ) + 
+IF( 57813X544X18714 IS NOT NULL AND 57813X544X18714 != '' AND 57813X544X18714 != '99', 1, 0 ) + 
+IF( 57813X544X18715 IS NOT NULL AND 57813X544X18715 != '' AND 57813X544X18715 != '99', 1, 0 ) + 
+IF( 57813X544X18716 IS NOT NULL AND 57813X544X18716 != '' AND 57813X544X18716 != '99', 1, 0 ) + 
+IF( 57813X544X18717 IS NOT NULL AND 57813X544X18717 != '' AND 57813X544X18717 != '99', 1, 0 ) + 
+IF( 57813X544X18718 IS NOT NULL AND 57813X544X18718 != '' AND 57813X544X18718 != '99', 1, 0 ) 
+) 
+) 
+) 
+/ COUNT(*) ), 4) as `AVG`
+FROM `t1` 
+WHERE `submitdate` IS NOT NULL 
+AND ( 
+( 57813X541X17271 IS NOT NULL AND 57813X541X17271 != '' AND 57813X541X17271 != '99' ) OR 
+( 57813X541X17272 IS NOT NULL AND 57813X541X17272 != '' AND 57813X541X17272 != '99' ) OR 
+( 57813X541X17273 IS NOT NULL AND 57813X541X17273 != '' AND 57813X541X17273 != '99' ) OR 
+( 57813X541X17274 IS NOT NULL AND 57813X541X17274 != '' AND 57813X541X17274 != '99' ) OR 
+( 57813X541X17275 IS NOT NULL AND 57813X541X17275 != '' AND 57813X541X17275 != '99' ) OR 
+( 57813X541X17276 IS NOT NULL AND 57813X541X17276 != '' AND 57813X541X17276 != '99' ) OR 
+( 57813X542X18131 IS NOT NULL AND 57813X542X18131 != '' AND 57813X542X18131 != '99' ) OR 
+( 57813X542X18132 IS NOT NULL AND 57813X542X18132 != '' AND 57813X542X18132 != '99' ) OR 
+( 57813X542X18133 IS NOT NULL AND 57813X542X18133 != '' AND 57813X542X18133 != '99' ) OR 
+( 57813X542X18134 IS NOT NULL AND 57813X542X18134 != '' AND 57813X542X18134 != '99' ) OR 
+( 57813X542X18135 IS NOT NULL AND 57813X542X18135 != '' AND 57813X542X18135 != '99' ) OR 
+( 57813X542X18136 IS NOT NULL AND 57813X542X18136 != '' AND 57813X542X18136 != '99' ) OR 
+( 57813X542X18137 IS NOT NULL AND 57813X542X18137 != '' AND 57813X542X18137 != '99' ) OR 
+( 57813X542X18138 IS NOT NULL AND 57813X542X18138 != '' AND 57813X542X18138 != '99' ) OR 
+( 57813X542X18139 IS NOT NULL AND 57813X542X18139 != '' AND 57813X542X18139 != '99' ) OR 
+( 57813X543X18451 IS NOT NULL AND 57813X543X18451 != '' AND 57813X543X18451 != '99' ) OR 
+( 57813X543X18452 IS NOT NULL AND 57813X543X18452 != '' AND 57813X543X18452 != '99' ) OR 
+( 57813X543X18453 IS NOT NULL AND 57813X543X18453 != '' AND 57813X543X18453 != '99' ) OR 
+( 57813X543X18454 IS NOT NULL AND 57813X543X18454 != '' AND 57813X543X18454 != '99' ) OR 
+( 57813X543X18455 IS NOT NULL AND 57813X543X18455 != '' AND 57813X543X18455 != '99' ) OR 
+( 57813X543X18456 IS NOT NULL AND 57813X543X18456 != '' AND 57813X543X18456 != '99' ) OR 
+( 57813X544X18711 IS NOT NULL AND 57813X544X18711 != '' AND 57813X544X18711 != '99' ) OR 
+( 57813X544X18712 IS NOT NULL AND 57813X544X18712 != '' AND 57813X544X18712 != '99' ) OR 
+( 57813X544X18713 IS NOT NULL AND 57813X544X18713 != '' AND 57813X544X18713 != '99' ) OR 
+( 57813X544X18714 IS NOT NULL AND 57813X544X18714 != '' AND 57813X544X18714 != '99' ) OR 
+( 57813X544X18715 IS NOT NULL AND 57813X544X18715 != '' AND 57813X544X18715 != '99' ) OR 
+( 57813X544X18716 IS NOT NULL AND 57813X544X18716 != '' AND 57813X544X18716 != '99' ) OR 
+( 57813X544X18717 IS NOT NULL AND 57813X544X18717 != '' AND 57813X544X18717 != '99' ) OR 
+( 57813X544X18718 IS NOT NULL AND 57813X544X18718 != '' AND 57813X544X18718 != '99' ) ) 
+AND 57813X540X1723 = 'Test';
+N	AVG
+0	NULL
+drop table t1;
+#
 # End of 5.5 tests
 #
diff --git a/mysql-test/r/information_schema2.result b/mysql-test/r/information_schema2.result
index 3f7f3ec..7e9bdd7 100644
--- a/mysql-test/r/information_schema2.result
+++ b/mysql-test/r/information_schema2.result
@@ -6,15 +6,15 @@ select variable_name from information_schema.session_variables where variable_na
 (select variable_name from information_schema.session_variables where variable_name = 'basedir');
 variable_name
 BASEDIR
-create table t1 (a char);
-insert t1 values ('a'),('t'),('z');
-flush status;
-select a, exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) from t1;
-a	exists (select 1 from information_schema.columns where table_schema=concat('tes',a))
-a	0
-t	1
-z	0
-show status like 'created_tmp_tables';
-Variable_name	Value
-Created_tmp_tables	38
-drop table t1;
+create table t1 (x int);
+create table t2 (x int);
+create table t3 (x int);
+create table t4 AS select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE' ;
+delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
+select * from t4;
+table_name
+t1
+t2
+t3
+t4
+drop table t1, t2, t3, t4;
diff --git a/mysql-test/r/innodb_load_xa.result b/mysql-test/r/innodb_load_xa.result
index e738ca6..8b8de20 100644
--- a/mysql-test/r/innodb_load_xa.result
+++ b/mysql-test/r/innodb_load_xa.result
@@ -18,3 +18,5 @@ mysqld-bin.000001	#	Query	#	#	use `test`; insert t1 values (2)
 mysqld-bin.000001	#	Query	#	#	COMMIT
 drop table t1;
 uninstall plugin innodb;
+Warnings:
+Warning	1620	Plugin is busy and will be uninstalled on shutdown
diff --git a/mysql-test/r/loadxml.result b/mysql-test/r/loadxml.result
index 7742f45..1128caf 100644
--- a/mysql-test/r/loadxml.result
+++ b/mysql-test/r/loadxml.result
@@ -93,3 +93,30 @@ a	b
 216	!&bb b;
 3	!b3
 DROP TABLE t1;
+#
+# Bug#16171518 LOAD XML DOES NOT HANDLE EMPTY ELEMENTS
+#
+CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 VARCHAR(3), col4 VARCHAR(4));
+LOAD XML INFILE '../../std_data/bug16171518_1.dat' INTO TABLE t1;
+SELECT * FROM t1 ORDER BY col1, col2, col3, col4;
+col1	col2	col3	col4
+0bc	def	ghi	jkl
+1no	NULL	pqr	stu
+2BC	DEF	GHI	JKL
+3NO	NULL	PQR	STU
+4bc	def	ghi	jkl
+5no	pqr	stu	vwx
+6BC	DEF	NULL	JKL
+7NO	PQR	STU	VWX
+8bc	def	ghi	NULL
+9kl	NULL	mno	pqr
+ABC	DEF	NULL	JKL
+MNO	NULL	STU	VWX
+DROP TABLE t1;
+CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 INTEGER);
+LOAD XML INFILE '../../std_data/bug16171518_2.dat' INTO TABLE t1;
+SELECT * FROM t1 ORDER BY col1, col2, col3;
+col1	col2	col3
+ABC	DEF	NULL
+GHI	NULL	123
+DROP TABLE t1;
diff --git a/mysql-test/r/lowercase_fs_on.result b/mysql-test/r/lowercase_fs_on.result
new file mode 100644
index 0000000..a090f46
--- /dev/null
+++ b/mysql-test/r/lowercase_fs_on.result
@@ -0,0 +1,3 @@
+#
+# Bug#20198490 : LOWER_CASE_TABLE_NAMES=0 ON WINDOWS LEADS TO PROBLEMS
+#
diff --git a/mysql-test/r/lowercase_table3.result b/mysql-test/r/lowercase_table3.result
deleted file mode 100644
index 22e80aa..0000000
--- a/mysql-test/r/lowercase_table3.result
+++ /dev/null
@@ -1,11 +0,0 @@
-call mtr.add_suppression("Cannot find or open table test/BUG29839 from");
-DROP TABLE IF EXISTS t1,T1;
-CREATE TABLE t1 (a INT);
-SELECT * FROM T1;
-a
-FLUSH TABLES;
-DROP TABLE t1;
-CREATE TABLE bug29839 (a INT) ENGINE=INNODB;
-SELECT * FROM BUG29839;
-ERROR 42S02: Table 'test.BUG29839' doesn't exist
-DROP TABLE bug29839;
diff --git a/mysql-test/r/merge_recover.result b/mysql-test/r/myisam_recover.result
similarity index 62%
rename from mysql-test/r/merge_recover.result
rename to mysql-test/r/myisam_recover.result
index 871c12c..0829c1e 100644
--- a/mysql-test/r/merge_recover.result
+++ b/mysql-test/r/myisam_recover.result
@@ -1,5 +1,7 @@
 #
-# Test of MyISAM MRG tables with corrupted children.
+# Tests for corrupted MyISAM tables and MyISAMMRG tables with corrupted
+# children..
+#
 # Run with --myisam-recover=force option.
 #
 # Preparation: we need to make sure that the merge parent
@@ -44,20 +46,20 @@ drop procedure p_create;
 # Switching to connection 'default'
 #
 #
-# We have to disable the ps-protocol, to avoid 
+# We have to disable the ps-protocol, to avoid
 # "Prepared statement needs to be re-prepared" errors
 # -- table def versions change all the time with full table cache.
-# 
+#
 drop table if exists t1, t1_mrg, t1_copy;
 #
 # Prepare a MERGE engine table, that refers to a corrupted
 # child.
-# 
+#
 create table t1 (a int, key(a)) engine=myisam;
 create table t1_mrg (a int) union (t1) engine=merge;
 #
 # Create a table with a corrupted index file:
-# save an old index file, insert more rows, 
+# save an old index file, insert more rows,
 # overwrite the new index file with the old one.
 #
 insert into  t1 (a) values (1), (2), (3);
@@ -101,3 +103,48 @@ execute stmt;
 deallocate prepare stmt;
 set @@global.table_definition_cache=default;
 set @@global.table_open_cache=default;
+#
+# 18075170 - sql node restart required to avoid deadlock after
+#            restore
+#
+# Check that auto-repair for MyISAM tables can now happen in the
+# middle of transaction, without aborting it.
+create table t1 (a int, key(a)) engine=myisam;
+create table t2 (a int);
+insert into t2 values (1);
+# Create a table with a corrupted index file:
+# save an old index file, insert more rows,
+# overwrite the new index file with the old one.
+insert into  t1 (a) values (1);
+flush table t1;
+insert into  t1 (a) values (4);
+flush table t1;
+# Check table is needed to mark the table as crashed.
+check table t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	warning	Size of datafile is: 14       Should be: 7
+test.t1	check	error	Record-count is not ok; is 2   Should be: 1
+test.t1	check	warning	Found 2 key parts. Should be: 1
+test.t1	check	error	Corrupt
+# At this point we have a corrupt t1
+set autocommit = 0;
+select * from t2;
+a
+1
+# Without fix select from t1 will break the transaction. After the fix
+# transaction should be active and should hold lock on table t2. Alter
+# table from con2 will wait only if the transaction is not broken.
+select * from t1;
+a
+1
+4
+Warnings:
+Error	145	Table 't1' is marked as crashed and should be repaired
+Error	1194	Table 't1' is marked as crashed and should be repaired
+Error	1034	Number of rows changed from 1 to 2
+ALTER TABLE t2 ADD val INT;
+# With fix we should have alter table waiting for t2 lock here.
+ROLLBACK;
+SET autocommit = 1;
+# Cleanup
+drop table t1, t2;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 49fd199..43601f4 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -4292,7 +4292,6 @@ Abernathy
 aberrant
 aberration
 drop table words;
-mysqlimport: Error: 1146, Table 'test.words' doesn't exist, when using table: words
 drop table t1;
 drop table t2;
 drop table words2;
@@ -5281,6 +5280,34 @@ drop table t1, t2;
 #
 # End of 5.1 tests
 #
+#
+# Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE MULTIPLE THREADS
+#
+CREATE DATABASE db_20772273;
+USE db_20772273;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (3), (4);
+SELECT * FROM t1;
+a
+1
+2
+SELECT * FROM t2;
+a
+3
+4
+SELECT * FROM t1;
+a
+1
+2
+SELECT * FROM t2;
+a
+3
+4
+DROP TABLE t1;
+DROP TABLE t2;
+DROP DATABASE db_20772273;
 Usage: mysqldump [OPTIONS] database [tables]
 OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
 OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result
index 0fe1034..0c15ded 100644
--- a/mysql-test/r/partition_error.result
+++ b/mysql-test/r/partition_error.result
@@ -1089,7 +1089,7 @@ partition by key (a)
 subpartition by hash (sin(a+b))
 (partition x1 (subpartition x11, subpartition x12),
 partition x2 (subpartition x21, subpartition x22));
-ERROR HY000: It is only possible to mix RANGE/LIST partitioning with HASH/KEY partitioning for subpartitioning
+ERROR HY000: This partition function is not allowed
 select load_file('$MYSQLD_DATADIR/test/t1.par');
 load_file('$MYSQLD_DATADIR/test/t1.par')
 NULL
diff --git a/mysql-test/r/sp-group.result b/mysql-test/r/sp-group.result
new file mode 100644
index 0000000..9744bbe
--- /dev/null
+++ b/mysql-test/r/sp-group.result
@@ -0,0 +1,156 @@
+drop table if exists t1;
+Warnings:
+Note	1051	Unknown table 't1'
+drop view if exists view_t1;
+Warnings:
+Note	1051	Unknown table 'test.view_t1'
+SET sql_mode=ONLY_FULL_GROUP_BY;
+CREATE TABLE t1 (
+pk INT, 
+f0 INT, f1 INT, f2 INT, f3 INT, f4 INT, 
+f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, 
+PRIMARY KEY (pk)
+);
+CREATE VIEW view_t1 AS SELECT * FROM t1;
+CREATE PROCEDURE s1() 
+SELECT * FROM (
+INFORMATION_SCHEMA.`INNODB_BUFFER_PAGE_LRU` AS table1
+LEFT JOIN test.view_t1 AS table2
+ON ( table2.`f6` = table1.FREE_PAGE_CLOCK) 
+) 
+ORDER BY table1.NUMBER_RECORDS
+LIMIT 0
+;
+CALL s1;
+POOL_ID	LRU_POSITION	SPACE	PAGE_NUMBER	PAGE_TYPE	FLUSH_TYPE	FIX_COUNT	IS_HASHED	NEWEST_MODIFICATION	OLDEST_MODIFICATION	ACCESS_TIME	TABLE_NAME	INDEX_NAME	NUMBER_RECORDS	DATA_SIZE	COMPRESSED_SIZE	COMPRESSED	IO_FIX	IS_OLD	FREE_PAGE_CLOCK	pk	f0	f1	f2	f3	f4	f5	f6	f7	f8	f9
+CALL s1;
+POOL_ID	LRU_POSITION	SPACE	PAGE_NUMBER	PAGE_TYPE	FLUSH_TYPE	FIX_COUNT	IS_HASHED	NEWEST_MODIFICATION	OLDEST_MODIFICATION	ACCESS_TIME	TABLE_NAME	INDEX_NAME	NUMBER_RECORDS	DATA_SIZE	COMPRESSED_SIZE	COMPRESSED	IO_FIX	IS_OLD	FREE_PAGE_CLOCK	pk	f0	f1	f2	f3	f4	f5	f6	f7	f8	f9
+drop table t1;
+drop view view_t1;
+drop procedure s1;
+CREATE TABLE A (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+CREATE VIEW view_A AS SELECT * FROM A;
+CREATE TABLE C (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_date_key DATE,
+col_date_nokey DATE,
+col_time_key TIME,
+col_time_nokey TIME,
+col_datetime_key DATETIME,
+col_datetime_nokey DATETIME,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+CREATE VIEW view_C AS SELECT * FROM C;
+CREATE TABLE AA (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_date_key DATE,
+col_date_nokey DATE,
+col_time_key TIME,
+col_time_nokey TIME,
+col_datetime_key DATETIME,
+col_datetime_nokey DATETIME,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_varchar_key, col_int_key)
+) ENGINE=MyISAM;
+CREATE VIEW view_AA AS SELECT * FROM AA;
+CREATE TABLE BB (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_varchar_key, col_int_key)
+) ENGINE=MyISAM;
+CREATE VIEW view_BB AS SELECT * FROM BB;
+CREATE TABLE DD (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_date_key DATE,
+col_time_key TIME,
+col_datetime_key DATETIME,
+col_varchar_key VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_varchar_key, col_int_key)
+) ENGINE=MyISAM;
+CREATE VIEW view_DD AS SELECT * FROM DD;
+CREATE TRIGGER k BEFORE INSERT ON `DD` FOR EACH ROW INSERT INTO `view_BB` SELECT * FROM `view_A` LIMIT 0 ;
+CREATE TRIGGER r BEFORE INSERT ON `A` FOR EACH ROW INSERT INTO `view_AA` SELECT * FROM `view_C` LIMIT 0 ;
+ALTER TABLE `DD` DROP PRIMARY KEY;
+ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
+INSERT INTO `view_A` ( `pk` ) VALUES (NULL);
+INSERT INTO `DD` ( `pk` ) VALUES (NULL);
+INSERT INTO `A` ( `pk` ) VALUES (NULL);
+INSERT INTO `view_DD` ( `pk` ) VALUES (NULL);
+drop trigger r;
+drop trigger k;
+drop view view_A,view_AA,view_C,view_BB,view_DD;
+drop table A,C,AA,BB,DD;
+CREATE TABLE A (
+i INT,
+i1 INT,
+i2 INT,
+d1 DATE,
+d2 DATE,
+col_time_nokey1 TIME,
+col_time_nokey2 TIME,
+col_datetime_nokey1 DATETIME,
+col_datetime_nokey2 DATETIME,
+col_varchar_nokey1 VARCHAR(1),
+col_varchar_nokey2 VARCHAR(1)
+) ENGINE=MyISAM;
+CREATE VIEW view_A AS SELECT * FROM A;
+CREATE TABLE B (
+col_varchar_nokey VARCHAR(1)
+) ENGINE=MyISAM;
+CREATE TABLE AA (
+i INT,
+i1 INT,
+i2 INT,
+d1 DATE,
+d2 DATE,
+col_time_nokey1 TIME,
+col_time_nokey2 TIME,
+col_datetime_nokey1 DATETIME,
+col_datetime_nokey2 DATETIME,
+col_varchar_nokey1 VARCHAR(1),
+col_varchar_nokey2 VARCHAR(1)
+) ENGINE=MyISAM;
+CREATE VIEW view_AA AS SELECT * FROM AA;
+CREATE TABLE DD (
+i INT,
+i1 INT,
+i2 INT,
+d1 DATE,
+d2 DATE,
+col_time_nokey1 TIME,
+col_time_nokey2 TIME,
+col_datetime_nokey1 DATETIME,
+col_datetime_nokey2 DATETIME,
+col_varchar_nokey1 VARCHAR(1),
+col_varchar_nokey2 VARCHAR(1)
+) ENGINE=MyISAM;
+CREATE VIEW view_DD AS SELECT * FROM DD;
+CREATE TRIGGER tr1 BEFORE INSERT ON `AA` FOR EACH ROW INSERT INTO `view_A` SELECT * FROM `view_AA` LIMIT 0 ;
+CREATE TRIGGER tr2 BEFORE INSERT ON `B` FOR EACH ROW INSERT INTO `D` SELECT * FROM `A` LIMIT 0 ;
+INSERT INTO `view_AA` ( `i` ) VALUES (1);
+INSERT INTO `AA` ( `i` ) VALUES (2);
+DELETE FROM `B`;
+INSERT INTO `view_DD` ( `i` ) VALUES (1);
+INSERT INTO `view_AA` ( `i` ) VALUES (3);
+drop trigger tr1;
+drop trigger tr2;
+drop view view_A, view_AA,view_DD;
+drop table A,B,AA,DD;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 4afde93..ba52fd9 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -81,7 +81,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
 ERROR HY000: Incorrect usage of PROCEDURE and subquery
 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
 ERROR 42S22: Unknown column 'a' in 'field list'
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
 drop table t1, t2;
 CREATE TABLE t1 (a INT);
 CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
-ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
+ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
 CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
 ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
 SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7015,3 +7015,69 @@ select exists(select 1 from t1 group by `c` in (select `c` from t1));
 exists(select 1 from t1 group by `c` in (select `c` from t1))
 0
 drop table t1;
+#
+# MDEV-7565: Server crash with Signal 6 (part 2)
+#
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+ControlRev
+NULL
+#
+# MDEV-7445:Server crash with Signal 6
+#
+CREATE PROCEDURE procedure2()
+BEGIN
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+  From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+END |
+call procedure2();
+ControlRev
+NULL
+call procedure2();
+ControlRev
+NULL
+drop procedure procedure2;
+SELECT
+(SELECT user FROM mysql.user
+WHERE h.host in (SELECT host FROM mysql.user)
+) AS sq
+FROM mysql.host h GROUP BY h.host;
+sq
+#
+# MDEV-7846:Server crashes in Item_subselect::fix
+#_fields or fails with Thread stack overrun
+#
+CREATE TABLE t1 (column1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (3),(9);
+CREATE TABLE t2 (column2 INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(4);
+CREATE TABLE t3 (column3 INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (6),(8);
+CREATE TABLE t4 (column4 INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (2),(5);
+PREPARE stmt FROM "
+SELECT ( 
+  SELECT MAX( table1.column1 ) AS field1 
+  FROM t1 AS table1
+  WHERE table3.column3 IN ( SELECT table2.column2 AS field2 FROM t2 AS table2 ) 
+) AS sq
+FROM t3 AS table3, t4 AS table4 GROUP BY sq
+";
+EXECUTE stmt;
+sq
+NULL
+EXECUTE stmt;
+sq
+NULL
+deallocate prepare stmt;
+drop table t1,t2,t3,t4;
diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result
index 7039bbf..e484392 100644
--- a/mysql-test/r/subselect_mat.result
+++ b/mysql-test/r/subselect_mat.result
@@ -2145,6 +2145,24 @@ drop database mysqltest1;
 drop database mysqltest2;
 drop database mysqltest3;
 drop database mysqltest4;
+#
+# MDEV-7810 Wrong result on execution of a query as a PS
+# (both 1st and further executions)
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0),(8);
+SELECT a FROM (SELECT DISTINCT * FROM t1) AS sq WHERE a IN (SELECT MIN(t2.a) FROM (t1 AS t2));
+a
+0
+PREPARE stmt FROM "
+SELECT a FROM (SELECT DISTINCT * FROM t1) AS sq WHERE a IN (SELECT MIN(t2.a) FROM (t1 AS t2))
+";
+execute stmt;
+a
+0
+execute stmt;
+a
+0
+drop table t1;
 # End of 5.5 tests
 set @subselect_mat_test_optimizer_switch_value=null;
 set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index 9df216d..d8d5c4e 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -88,7 +88,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
 ERROR HY000: Incorrect usage of PROCEDURE and subquery
 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
 ERROR 42S22: Unknown column 'a' in 'field list'
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -3594,7 +3594,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
 drop table t1, t2;
 CREATE TABLE t1 (a INT);
 CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
-ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
+ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
 CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
 ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
 SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7012,6 +7012,72 @@ select exists(select 1 from t1 group by `c` in (select `c` from t1));
 exists(select 1 from t1 group by `c` in (select `c` from t1))
 0
 drop table t1;
+#
+# MDEV-7565: Server crash with Signal 6 (part 2)
+#
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+ControlRev
+NULL
+#
+# MDEV-7445:Server crash with Signal 6
+#
+CREATE PROCEDURE procedure2()
+BEGIN
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+  From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+END |
+call procedure2();
+ControlRev
+NULL
+call procedure2();
+ControlRev
+NULL
+drop procedure procedure2;
+SELECT
+(SELECT user FROM mysql.user
+WHERE h.host in (SELECT host FROM mysql.user)
+) AS sq
+FROM mysql.host h GROUP BY h.host;
+sq
+#
+# MDEV-7846:Server crashes in Item_subselect::fix
+#_fields or fails with Thread stack overrun
+#
+CREATE TABLE t1 (column1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (3),(9);
+CREATE TABLE t2 (column2 INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(4);
+CREATE TABLE t3 (column3 INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (6),(8);
+CREATE TABLE t4 (column4 INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (2),(5);
+PREPARE stmt FROM "
+SELECT ( 
+  SELECT MAX( table1.column1 ) AS field1 
+  FROM t1 AS table1
+  WHERE table3.column3 IN ( SELECT table2.column2 AS field2 FROM t2 AS table2 ) 
+) AS sq
+FROM t3 AS table3, t4 AS table4 GROUP BY sq
+";
+EXECUTE stmt;
+sq
+NULL
+EXECUTE stmt;
+sq
+NULL
+deallocate prepare stmt;
+drop table t1,t2,t3,t4;
 set optimizer_switch=default;
 select @@optimizer_switch like '%materialization=on%';
 @@optimizer_switch like '%materialization=on%'
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 7b93f27..78908bc 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -84,7 +84,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
 ERROR HY000: Incorrect usage of PROCEDURE and subquery
 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
 ERROR 42S22: Unknown column 'a' in 'field list'
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
 drop table t1, t2;
 CREATE TABLE t1 (a INT);
 CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
-ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
+ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
 CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
 ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
 SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7010,4 +7010,70 @@ select exists(select 1 from t1 group by `c` in (select `c` from t1));
 exists(select 1 from t1 group by `c` in (select `c` from t1))
 0
 drop table t1;
+#
+# MDEV-7565: Server crash with Signal 6 (part 2)
+#
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+ControlRev
+NULL
+#
+# MDEV-7445:Server crash with Signal 6
+#
+CREATE PROCEDURE procedure2()
+BEGIN
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+  From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+END |
+call procedure2();
+ControlRev
+NULL
+call procedure2();
+ControlRev
+NULL
+drop procedure procedure2;
+SELECT
+(SELECT user FROM mysql.user
+WHERE h.host in (SELECT host FROM mysql.user)
+) AS sq
+FROM mysql.host h GROUP BY h.host;
+sq
+#
+# MDEV-7846:Server crashes in Item_subselect::fix
+#_fields or fails with Thread stack overrun
+#
+CREATE TABLE t1 (column1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (3),(9);
+CREATE TABLE t2 (column2 INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(4);
+CREATE TABLE t3 (column3 INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (6),(8);
+CREATE TABLE t4 (column4 INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (2),(5);
+PREPARE stmt FROM "
+SELECT ( 
+  SELECT MAX( table1.column1 ) AS field1 
+  FROM t1 AS table1
+  WHERE table3.column3 IN ( SELECT table2.column2 AS field2 FROM t2 AS table2 ) 
+) AS sq
+FROM t3 AS table3, t4 AS table4 GROUP BY sq
+";
+EXECUTE stmt;
+sq
+NULL
+EXECUTE stmt;
+sq
+NULL
+deallocate prepare stmt;
+drop table t1,t2,t3,t4;
 set @optimizer_switch_for_subselect_test=null;
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index b6d3a89..d1de4b8 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -87,7 +87,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
 ERROR HY000: Incorrect usage of PROCEDURE and subquery
 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
 ERROR 42S22: Unknown column 'a' in 'field list'
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -3596,7 +3596,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
 drop table t1, t2;
 CREATE TABLE t1 (a INT);
 CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
-ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
+ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
 CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
 ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
 SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7021,6 +7021,72 @@ select exists(select 1 from t1 group by `c` in (select `c` from t1));
 exists(select 1 from t1 group by `c` in (select `c` from t1))
 0
 drop table t1;
+#
+# MDEV-7565: Server crash with Signal 6 (part 2)
+#
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+ControlRev
+NULL
+#
+# MDEV-7445:Server crash with Signal 6
+#
+CREATE PROCEDURE procedure2()
+BEGIN
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+  From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+END |
+call procedure2();
+ControlRev
+NULL
+call procedure2();
+ControlRev
+NULL
+drop procedure procedure2;
+SELECT
+(SELECT user FROM mysql.user
+WHERE h.host in (SELECT host FROM mysql.user)
+) AS sq
+FROM mysql.host h GROUP BY h.host;
+sq
+#
+# MDEV-7846:Server crashes in Item_subselect::fix
+#_fields or fails with Thread stack overrun
+#
+CREATE TABLE t1 (column1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (3),(9);
+CREATE TABLE t2 (column2 INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(4);
+CREATE TABLE t3 (column3 INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (6),(8);
+CREATE TABLE t4 (column4 INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (2),(5);
+PREPARE stmt FROM "
+SELECT ( 
+  SELECT MAX( table1.column1 ) AS field1 
+  FROM t1 AS table1
+  WHERE table3.column3 IN ( SELECT table2.column2 AS field2 FROM t2 AS table2 ) 
+) AS sq
+FROM t3 AS table3, t4 AS table4 GROUP BY sq
+";
+EXECUTE stmt;
+sq
+NULL
+EXECUTE stmt;
+sq
+NULL
+deallocate prepare stmt;
+drop table t1,t2,t3,t4;
 set optimizer_switch=default;
 select @@optimizer_switch like '%subquery_cache=on%';
 @@optimizer_switch like '%subquery_cache=on%'
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index d51d211..524a5dd 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -84,7 +84,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
 ERROR HY000: Incorrect usage of PROCEDURE and subquery
 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT 1))' at line 1
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
 ERROR 42S22: Unknown column 'a' in 'field list'
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -3590,7 +3590,7 @@ delete from t1 where c <= 1140006215 and (select b from t2 where a = 2) = 1;
 drop table t1, t2;
 CREATE TABLE t1 (a INT);
 CREATE VIEW v1 AS SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
-ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
+ERROR 42S22: Unknown column 'no_such_column' in 'IN/ALL/ANY subquery'
 CREATE VIEW v2 AS SELECT * FROM t1 WHERE no_such_column = (SELECT 1);
 ERROR 42S22: Unknown column 'no_such_column' in 'where clause'
 SELECT * FROM t1 WHERE no_such_column = ANY (SELECT 1);
@@ -7010,5 +7010,71 @@ select exists(select 1 from t1 group by `c` in (select `c` from t1));
 exists(select 1 from t1 group by `c` in (select `c` from t1))
 0
 drop table t1;
+#
+# MDEV-7565: Server crash with Signal 6 (part 2)
+#
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+ControlRev
+NULL
+#
+# MDEV-7445:Server crash with Signal 6
+#
+CREATE PROCEDURE procedure2()
+BEGIN
+Select 
+(Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+) As `ControlRev`
+  From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+END |
+call procedure2();
+ControlRev
+NULL
+call procedure2();
+ControlRev
+NULL
+drop procedure procedure2;
+SELECT
+(SELECT user FROM mysql.user
+WHERE h.host in (SELECT host FROM mysql.user)
+) AS sq
+FROM mysql.host h GROUP BY h.host;
+sq
+#
+# MDEV-7846:Server crashes in Item_subselect::fix
+#_fields or fails with Thread stack overrun
+#
+CREATE TABLE t1 (column1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (3),(9);
+CREATE TABLE t2 (column2 INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(4);
+CREATE TABLE t3 (column3 INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (6),(8);
+CREATE TABLE t4 (column4 INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (2),(5);
+PREPARE stmt FROM "
+SELECT ( 
+  SELECT MAX( table1.column1 ) AS field1 
+  FROM t1 AS table1
+  WHERE table3.column3 IN ( SELECT table2.column2 AS field2 FROM t2 AS table2 ) 
+) AS sq
+FROM t3 AS table3, t4 AS table4 GROUP BY sq
+";
+EXECUTE stmt;
+sq
+NULL
+EXECUTE stmt;
+sq
+NULL
+deallocate prepare stmt;
+drop table t1,t2,t3,t4;
 set @optimizer_switch_for_subselect_test=null;
 set @join_cache_level_for_subselect_test=NULL;
diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result
index 5881067..cfcbf61 100644
--- a/mysql-test/r/subselect_sj_mat.result
+++ b/mysql-test/r/subselect_sj_mat.result
@@ -2185,4 +2185,22 @@ drop database mysqltest1;
 drop database mysqltest2;
 drop database mysqltest3;
 drop database mysqltest4;
+#
+# MDEV-7810 Wrong result on execution of a query as a PS
+# (both 1st and further executions)
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0),(8);
+SELECT a FROM (SELECT DISTINCT * FROM t1) AS sq WHERE a IN (SELECT MIN(t2.a) FROM (t1 AS t2));
+a
+0
+PREPARE stmt FROM "
+SELECT a FROM (SELECT DISTINCT * FROM t1) AS sq WHERE a IN (SELECT MIN(t2.a) FROM (t1 AS t2))
+";
+execute stmt;
+a
+0
+execute stmt;
+a
+0
+drop table t1;
 # End of 5.5 tests
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index 3f3a3ac..3ea5855 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -561,6 +561,21 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function
 DROP VIEW v1;
 DROP FUNCTION f1;
 DROP TABLE t1;
+# Bug #21143080: UPDATE ON VARCHAR AND TEXT COLUMNS PRODUCE INCORRECT
+#                RESULTS
+CREATE TABLE t1 (a VARCHAR(50), b TEXT, c CHAR(50)) ENGINE=INNODB;
+INSERT INTO t1 (a, b, c) VALUES ('start trail', '', 'even longer string');
+UPDATE t1 SET b = a, a = 'inject';
+SELECT a, b FROM t1;
+a	b
+inject	start trail
+UPDATE t1 SET b = c, c = 'inject';
+SELECT c, b FROM t1;
+c	b
+inject	even longer string
+DROP TABLE t1;
+#
+# MDEV-3948 Assertion `records_are_comparable(table)' fails in compare_record(const TABLE*) on UPDATE with simple AND condition, index_merge+index_merge_intersection, InnoDB
 #
 # Verify that UPDATE does the same number of handler_update
 # operations, no matter if there is ORDER BY or not.
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index cbacb2c..57065d7 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4830,6 +4830,41 @@ View	Create View	character_set_client	collation_connection
 v4	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS (select 'BUG#14117018' AS `col1`) union all (select '' AS `col2`) union all (select '' AS `Name_exp_1`)	latin1	latin1_swedish_ci
 DROP VIEW v1, v2, v3, v4, v5;
 #
+# BUG#19886430: VIEW CREATION WITH NAMED COLUMNS, OVER UNION,
+#               IS REJECTED
+# Without the patch, reports an error.
+CREATE VIEW v1 (fld1, fld2) AS
+SELECT 1 AS a, 2 AS b
+UNION ALL
+SELECT 1 AS a, 1 AS a;
+# The column names are explicitly specified and not duplicates, hence
+# succeeds.
+CREATE VIEW v2 (fld1, fld2) AS
+SELECT 1 AS a, 2 AS a
+UNION ALL
+SELECT 1 AS a, 1 AS a;
+# The column name in the first SELECT are not duplicates, hence succeeds.
+CREATE VIEW v3 AS
+SELECT 1 AS a, 2 AS b
+UNION ALL
+SELECT 1 AS a, 1 AS a;
+# Should report an error, since the explicitly specified column names are
+# duplicates.
+CREATE VIEW v4 (fld1, fld1) AS
+SELECT 1 AS a, 2 AS b
+UNION ALL
+SELECT 1 AS a, 1 AS a;
+ERROR 42S21: Duplicate column name 'fld1'
+# Should report an error, since duplicate column name is specified in the
+# First SELECT.
+CREATE VIEW v4 AS
+SELECT 1 AS a, 2 AS a
+UNION ALL
+SELECT 1 AS a, 1 AS a;
+ERROR 42S21: Duplicate column name 'a'
+# Cleanup
+DROP VIEW v1, v2, v3;
+#
 # lp:833600 Wrong result with view + outer join + uncorrelated subquery (non-semijoin) 
 #
 CREATE TABLE t1 ( a int, b int );
@@ -5429,6 +5464,21 @@ View	Create View	character_set_client	collation_connection
 v2	CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select (`t1`.`b` + 1) AS `c` from `t1`	latin1	latin1_swedish_ci
 drop view v2;
 drop table t1;
+#
+# MDEV-8554: Server crashes in base_list_iterator::next_fast on 1st execution of PS with a multi-table update
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4);
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (5),(6);
+CREATE OR REPLACE ALGORITHM=MERGE VIEW v3 AS SELECT * FROM t3;
+PREPARE stmt FROM 'UPDATE t1, t2 SET a = 1 WHERE a IN ( SELECT 0 FROM t3 )';
+UPDATE t1, t2 SET a = 1 WHERE a IN ( SELECT 0 FROM v3 );
+EXECUTE stmt;
+DROP TABLE t1, t2, t3;
+DROP VIEW v3;
 # -----------------------------------------------------------------
 # -- End of 5.5 tests.
 # -----------------------------------------------------------------
diff --git a/mysql-test/std_data/bug16171518_1.dat b/mysql-test/std_data/bug16171518_1.dat
new file mode 100644
index 0000000..b65b935
--- /dev/null
+++ b/mysql-test/std_data/bug16171518_1.dat
@@ -0,0 +1,59 @@
+<test_rows>
+  <row>
+    <col1>0bc</col1>
+    <col2>def</col2>
+    <col3>ghi</col3>
+    <col4>jkl</col4>
+  </row>
+  <row>
+    <col1>1no</col1>
+    <col2/>
+    <col3>pqr</col3>
+    <col4>stu</col4>
+  </row>
+
+  <row>
+    <col1>2BC</col1>
+    <col2>DEF</col2>
+    <col3>GHI</col3>
+    <col4>JKL</col4>
+  </row>
+  <row>
+    <col1>3NO</col1>
+    <col2 />
+    <col3>PQR</col3>
+    <col4>STU</col4>
+  </row>
+
+  <row col1="4bc" col2="def" col3="ghi" col4="jkl"/>
+  <row col1="5no"   col2="pqr"   col3="stu"   col4="vwx"   />
+
+  <row>
+    <field name='col1'>6BC</field>
+    <field name='col2'>DEF</field>
+    <field name='col3'></field>
+    <field name='col4'>JKL</field>
+  </row>
+  <row>
+    <field name='col1'>7NO</field>
+    <field name='col2'>PQR</field>
+    <field name='col3'>STU</field>
+    <field name='col4'>VWX</field>
+  </row>
+
+  <row>
+    <col1>8bc</col1>
+    <col2>def</col2>
+    <col3>ghi</col3>
+    <col4 />
+  </row>
+  <row>
+    <col1>9kl</col1>
+    <col2/>
+    <col3>mno</col3>
+    <col4>pqr</col4>
+  </row>
+
+  <row col1="ABC" col2="DEF" col3="" col4="JKL"/>
+  <row col1="MNO" col2="" col3="STU" col4="VWX"/>
+</test_rows>
diff --git a/mysql-test/std_data/bug16171518_2.dat b/mysql-test/std_data/bug16171518_2.dat
new file mode 100644
index 0000000..8a48333
--- /dev/null
+++ b/mysql-test/std_data/bug16171518_2.dat
@@ -0,0 +1,12 @@
+<test_rows>
+  <row>
+    <col1>ABC</col1>
+    <col2>DEF</col2>
+    <col3 />
+  </row>
+  <row>
+    <col1>GHI</col1>
+    <col2 />
+    <col3>123</col3>
+  </row>
+</test_rows>
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
index 469e670..3604f5e 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
@@ -1409,7 +1409,7 @@ BEGIN
 #010909  4:46:40 server id 1  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
 ### INSERT INTO `test`.`t1`
 ### SET
-###   @1=000000124.450000000 /* DECIMAL(10,5) meta=2565 nullable=1 is_null=0 */
+###   @1=124.45000 /* DECIMAL(10,5) meta=2565 nullable=1 is_null=0 */
 # at #
 #010909  4:46:40 server id 1  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
 SET TIMESTAMP=1000000000/*!*/;
@@ -1426,7 +1426,7 @@ BEGIN
 #010909  4:46:40 server id 1  end_log_pos # 	Write_rows: table id # flags: STMT_END_F
 ### INSERT INTO `test`.`t1`
 ### SET
-###   @1=-000000543.210000000 /* DECIMAL(10,5) meta=2565 nullable=1 is_null=0 */
+###   @1=-543.21000 /* DECIMAL(10,5) meta=2565 nullable=1 is_null=0 */
 # at #
 #010909  4:46:40 server id 1  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
 SET TIMESTAMP=1000000000/*!*/;
@@ -1443,7 +1443,7 @@ BEGIN
 #010909  4:46:40 server id 1  end_log_pos # 	Delete_rows: table id # flags: STMT_END_F
 ### DELETE FROM `test`.`t1`
 ### WHERE
-###   @1=000000124.450000000 /* DECIMAL(10,5) meta=2565 nullable=1 is_null=0 */
+###   @1=124.45000 /* DECIMAL(10,5) meta=2565 nullable=1 is_null=0 */
 # at #
 #010909  4:46:40 server id 1  end_log_pos # 	Query	thread_id=#	exec_time=#	error_code=0
 SET TIMESTAMP=1000000000/*!*/;
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
index 8e75d20..e942071 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result
@@ -2390,9 +2390,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2483,9 +2483,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2659,9 +2659,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2752,9 +2752,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2832,9 +2832,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2925,9 +2925,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3005,9 +3005,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3178,9 +3178,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3271,9 +3271,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3444,9 +3444,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3537,9 +3537,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3630,9 +3630,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
index b4ea855..29a1704 100644
--- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result
@@ -2390,9 +2390,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2485,9 +2485,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2663,9 +2663,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2758,9 +2758,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2838,9 +2838,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -2933,9 +2933,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3013,9 +3013,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3188,9 +3188,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3283,9 +3283,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3458,9 +3458,9 @@ BEGIN
 ###   @22=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='9999:12:31' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=9999-12-31 23:59:59 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=2146522447 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3553,9 +3553,9 @@ BEGIN
 ###   @22=-1.797... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=0 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000000 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=0 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='1000:01:01' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=1000-01-01 00:00:00 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=75601 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
@@ -3648,9 +3648,9 @@ BEGIN
 ###   @22=-2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @23=2.225... /* DOUBLE meta=8 nullable=1 is_null=0 */
 ###   @24=1 /* DOUBLE meta=8 nullable=1 is_null=0 */
-###   @25=-000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @26=000000009.999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
-###   @27=000000001 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @25=-9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @26=9999999999 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
+###   @27=1 /* DECIMAL(10,0) meta=2560 nullable=1 is_null=0 */
 ###   @28='2008:08:04' /* DATE meta=0 nullable=1 is_null=0 */
 ###   @29=2008-08-04 16:18:06 /* DATETIME meta=0 nullable=1 is_null=0 */
 ###   @30=1217855904 /* TIMESTAMP meta=0 nullable=0 is_null=0 */
diff --git a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
index ac36412..ed6e711 100644
--- a/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
@@ -258,7 +258,7 @@ Warning	1196	Some non-transactional changed tables couldn't be rolled back
 create table t0 (n int);
 insert t0 select * from t1;
 set autocommit=1;
-insert into t0 select GET_LOCK("lock1",null);
+insert into t0 select GET_LOCK("lock1",0);
 set autocommit=0;
 create table t2 (n int) engine=innodb;
 insert into t2 values (3);
diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
index c10aa7a..7309c61 100644
--- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
@@ -242,7 +242,7 @@ Warning	1196	Some non-transactional changed tables couldn't be rolled back
 create table t0 (n int);
 insert t0 select * from t1;
 set autocommit=1;
-insert into t0 select GET_LOCK("lock1",null);
+insert into t0 select GET_LOCK("lock1",0);
 Warnings:
 Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave.
 set autocommit=0;
@@ -288,7 +288,7 @@ master-bin.000001	#	Query	#	#	BEGIN
 master-bin.000001	#	Query	#	#	use `test`; insert t0 select * from t1
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	BEGIN
-master-bin.000001	#	Query	#	#	use `test`; insert into t0 select GET_LOCK("lock1",null)
+master-bin.000001	#	Query	#	#	use `test`; insert into t0 select GET_LOCK("lock1",0)
 master-bin.000001	#	Query	#	#	COMMIT
 master-bin.000001	#	Query	#	#	use `test`; create table t2 (n int) engine=innodb
 master-bin.000001	#	Query	#	#	use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t1`,`ti`
diff --git a/mysql-test/suite/engines/iuds/r/strings_charsets_update_delete.result b/mysql-test/suite/engines/iuds/r/strings_charsets_update_delete.result
index 08eecb1..c1d0a7f 100644
Binary files a/mysql-test/suite/engines/iuds/r/strings_charsets_update_delete.result and b/mysql-test/suite/engines/iuds/r/strings_charsets_update_delete.result differ
diff --git a/mysql-test/suite/innodb/r/add_constraint.result b/mysql-test/suite/innodb/r/add_constraint.result
new file mode 100644
index 0000000..cbbcb4e
--- /dev/null
+++ b/mysql-test/suite/innodb/r/add_constraint.result
@@ -0,0 +1,13 @@
+#
+# Bug #20762798 FK DDL: CRASH IN DICT_FOREIGN_REMOVE_FROM_CACHE
+#
+create table t1(a int, b int, key(a),key(b))engine=innodb;
+create table t2(a int, b int, key(a),key(b))engine=innodb;
+alter table t2 add constraint b foreign key (b) references t1(a);
+alter table t1 add constraint b1 foreign key (b) references t2(a);
+alter table t2 add constraint b1 foreign key (b) references t1(a);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 121)
+alter table t2 drop foreign key b;
+alter table t1 drop foreign key b1;
+drop table t2;
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-fk-warnings.result b/mysql-test/suite/innodb/r/innodb-fk-warnings.result
new file mode 100644
index 0000000..542fc97
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb-fk-warnings.result
@@ -0,0 +1,105 @@
+CREATE TABLE t1 (
+id int(11) NOT NULL PRIMARY KEY,
+a int(11) NOT NULL,
+b int(11) NOT NULL,
+c int not null,
+CONSTRAINT test FOREIGN KEY (b) REFERENCES t1 (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE t2 (
+id int(11) NOT NULL PRIMARY KEY,
+a int(11) NOT NULL,
+b int(11) NOT NULL,
+c int not null,
+CONSTRAINT mytest FOREIGN KEY (c) REFERENCES t1(id),
+CONSTRAINT test FOREIGN KEY (b) REFERENCES t2 (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+ERROR HY000: Can't create table 'test.t2' (errno: 121)
+show warnings;
+Level	Code	Message
+Warning	121	Create or Alter table `test`.`t2` with foreign key constraint failed. Foreign key constraint `test/test` already exists on data dictionary. Foreign key constraint names need to be unique in database. Error in foreign key definition: CONSTRAINT `test` FOREIGN KEY (`b`) REFERENCES `test`.`t2` (`id`).
+Error	1005	Can't create table 'test.t2' (errno: 121)
+drop table t1;
+create table t1(a int) engine=innodb;
+create table t2(a int, constraint a foreign key a (a) references t1(a)) engine=innodb;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Create  table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns. Error close to  foreign key a (a) references t1(a)) engine=innodb.
+Error	1005	Can't create table 'test.t2' (errno: 150)
+drop table t1;
+create table t1(a int not null primary key, b int) engine=innodb;
+create table t2(a int, b int, constraint a foreign key a (a) references t1(a),
+constraint a foreign key a (a) references t1(b)) engine=innodb;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Create  table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns. Error close to  foreign key a (a) references t1(b)) engine=innodb.
+Error	1005	Can't create table 'test.t2' (errno: 150)
+create table t2(a int, b int, constraint a foreign key a (a) references t1(a)) engine=innodb;
+alter table t2 add constraint b foreign key (b) references t2(b);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Alter  table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns. Error close to  foreign key (b) references t2(b).
+Error	1005	Can't create table '#sql-temporary' (errno: 150)
+drop table t2, t1;
+create table t1 (f1 integer primary key) engine=innodb;
+alter table t1 add constraint c1 foreign key (f1) references t11(f1);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Alter  table `test`.`t1` with foreign key constraint failed. Referenced table `test`.`t11` not found in the data dictionary close to  foreign key (f1) references t11(f1).
+Error	1005	Can't create table '#sql-temporary' (errno: 150)
+drop table t1;
+create temporary table t1(a int not null primary key, b int, key(b)) engine=innodb;
+create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Create  table `mysqld.1`.`t2` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary close to foreign key(a) references t1(a)) engine=innodb.
+Error	1005	Can't create table 'test.t2' (errno: 150)
+alter table t1 add foreign key(b) references t1(a);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Alter  table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary close to foreign key(b) references t1(a).
+Error	1005	Can't create table '#sql-temporary' (errno: 150)
+drop table t1;
+create table t1(a int not null primary key, b int, key(b)) engine=innodb;
+alter table t1 add foreign key(a,b) references t1(a);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Alter  table `test`.`t1` with foreign key constraint failed. Foreign key constraint parse error in foreign key(a,b) references t1(a) close to ). Too few referenced columns, you have 1 when you should have 2.
+Error	1005	Can't create table '#sql-temporary' (errno: 150)
+drop table t1;
+create table t1(a int not null primary key, b int, key(b)) engine=innodb;
+alter table t1 add foreign key(a) references t1(a,b);
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Alter  table `test`.`t1` with foreign key constraint failed. Foreign key constraint parse error in foreign key(a) references t1(a,b) close to ). Too few referenced columns, you have 2 when you should have 1.
+Error	1005	Can't create table '#sql-temporary' (errno: 150)
+drop table t1;
+create table t1 (f1 integer not null primary key) engine=innodb;
+alter table t1 add constraint c1 foreign key (f1) references t1(f1) on update set null;
+ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Alter  table `test`.`t1` with foreign key constraint failed. You have defined a SET NULL condition but column f1 is defined as NOT NULL in  foreign key (f1) references t1(f1) on update set null close to  on update set null.
+Error	1005	Can't create table '#sql-temporary' (errno: 150)
+create table t2(a int not null, foreign key(a) references t1(f1) on delete set null) engine=innodb;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Create  table `test`.`t2` with foreign key constraint failed. You have defined a SET NULL condition but column a is defined as NOT NULL in foreign key(a) references t1(f1) on delete set null) engine=innodb close to  on delete set null) engine=innodb.
+Error	1005	Can't create table 'test.t2' (errno: 150)
+drop table t1;
+create table t1 (id int not null primary key, f1 int, f2 int, key(f1)) engine=innodb;
+create table t2(a char(20), key(a), foreign key(a) references t1(f1)) engine=innodb;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+show warnings;
+Level	Code	Message
+Warning	150	Create  table `test`.`t2` with foreign key constraint failed. Field type or character set for column a does not mach referenced column f1 close to foreign key(a) references t1(f1)) engine=innodb
+Error	1005	Can't create table 'test.t2' (errno: 150)
+drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result
index 3c55753..2b53bc2 100644
--- a/mysql-test/suite/innodb/r/innodb-fk.result
+++ b/mysql-test/suite/innodb/r/innodb-fk.result
@@ -50,6 +50,8 @@ CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE
 ERROR HY000: Can't create table 'test.t2' (errno: 150)
 show warnings;
 Level	Code	Message
+Warning	150	Create  table `test`.`t2` with foreign key constraint failed. Referenced table `test`.`t3` not found in the data dictionary close to  FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE
+) ENGINE=InnoDB.
 Error	1005	Can't create table 'test.t2' (errno: 150)
 CREATE TABLE t2 (
 id int(11) NOT NULL AUTO_INCREMENT,
@@ -62,6 +64,7 @@ ALTER TABLE t2 ADD CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE
 ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
 show warnings;
 Level	Code	Message
+Warning	150	Alter  table `test`.`t2` with foreign key constraint failed. Referenced table `test`.`t3` not found in the data dictionary close to  FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE.
 Error	1005	Can't create table '#sql-temporary' (errno: 150)
 drop table t2;
 drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb_bug68148.result b/mysql-test/suite/innodb/r/innodb_bug68148.result
new file mode 100644
index 0000000..8824705
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_bug68148.result
@@ -0,0 +1,36 @@
+set global innodb_file_per_table=1;
+CREATE TABLE ref_table1 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+CREATE TABLE ref_table2 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+CREATE TABLE `main` (
+`id` int(11) NOT NULL AUTO_INCREMENT,
+`ref_id1` int(11) NOT NULL,
+`ref_id2` int(11) NOT NULL,
+PRIMARY KEY (`id`),
+UNIQUE KEY `idx_1` (`ref_id1`,`ref_id2`),
+KEY `FK_set_out_analysis_route_id` (`ref_id2`),
+CONSTRAINT `FK_1` FOREIGN KEY (`ref_id1`) REFERENCES `ref_table1` (`id`) ,
+CONSTRAINT `FK_2` FOREIGN KEY (`ref_id2`) REFERENCES `ref_table2` (`id`)
+) ENGINE=InnoDB;
+SET FOREIGN_KEY_CHECKS=0;
+DROP INDEX `idx_1` ON `main`;
+SHOW TABLES;
+Tables_in_test
+main
+ref_table1
+ref_table2
+# restart and see if we can still access the main table
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
+SHOW CREATE TABLE `main`;
+Table	Create Table
+main	CREATE TABLE `main` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `ref_id1` int(11) NOT NULL,
+  `ref_id2` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  KEY `FK_set_out_analysis_route_id` (`ref_id2`),
+  KEY `idx_1` (`ref_id1`),
+  CONSTRAINT `FK_1` FOREIGN KEY (`ref_id1`) REFERENCES `ref_table1` (`id`),
+  CONSTRAINT `FK_2` FOREIGN KEY (`ref_id2`) REFERENCES `ref_table2` (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE  main, ref_table1, ref_table2;
diff --git a/mysql-test/suite/innodb/r/innodb_uninstall.result b/mysql-test/suite/innodb/r/innodb_uninstall.result
new file mode 100644
index 0000000..2064269
--- /dev/null
+++ b/mysql-test/suite/innodb/r/innodb_uninstall.result
@@ -0,0 +1,22 @@
+install plugin innodb soname 'ha_innodb';
+create table t1(a int not null primary key) engine=innodb;
+begin;
+insert into t1 values(1);
+flush tables;
+uninstall plugin innodb;
+select sleep(1);
+sleep(1)
+0
+Warnings:
+Warning	1620	Plugin is busy and will be uninstalled on shutdown
+drop table t1;
+install plugin innodb soname 'ha_innodb';
+create table t2(a int not null primary key) engine=innodb;
+insert into t2 values(1);
+drop table t2;
+uninstall plugin innodb;
+select sleep(1);
+sleep(1)
+0
+Warnings:
+Warning	1620	Plugin is busy and will be uninstalled on shutdown
diff --git a/mysql-test/suite/innodb/t/add_constraint.test b/mysql-test/suite/innodb/t/add_constraint.test
new file mode 100644
index 0000000..eabf064
--- /dev/null
+++ b/mysql-test/suite/innodb/t/add_constraint.test
@@ -0,0 +1,21 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # Bug #20762798 FK DDL: CRASH IN DICT_FOREIGN_REMOVE_FROM_CACHE
+--echo #
+
+create table t1(a int, b int, key(a),key(b))engine=innodb;
+create table t2(a int, b int, key(a),key(b))engine=innodb;
+
+alter table t2 add constraint b foreign key (b) references t1(a);
+alter table t1 add constraint b1 foreign key (b) references t2(a);
+
+--replace_regex /'[^']*test\.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error ER_CANT_CREATE_TABLE
+alter table t2 add constraint b1 foreign key (b) references t1(a);
+
+alter table t2 drop foreign key b;
+alter table t1 drop foreign key b1;
+
+drop table t2;
+drop table t1;
diff --git a/mysql-test/suite/innodb/t/innodb-fk-warnings.test b/mysql-test/suite/innodb/t/innodb-fk-warnings.test
new file mode 100644
index 0000000..fe92f13
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb-fk-warnings.test
@@ -0,0 +1,130 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-8524: Improve error messaging when there is duplicate key or foreign key names
+#
+CREATE TABLE t1 (
+  id int(11) NOT NULL PRIMARY KEY,
+  a int(11) NOT NULL,
+  b int(11) NOT NULL,
+  c int not null,
+  CONSTRAINT test FOREIGN KEY (b) REFERENCES t1 (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+#
+# Below create table fails because constraint name test
+# is reserved for above table.
+#
+--error 1005
+CREATE TABLE t2 (
+  id int(11) NOT NULL PRIMARY KEY,
+  a int(11) NOT NULL,
+  b int(11) NOT NULL,
+  c int not null,
+  CONSTRAINT mytest FOREIGN KEY (c) REFERENCES t1(id),
+  CONSTRAINT test FOREIGN KEY (b) REFERENCES t2 (id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+show warnings;
+
+drop table t1;
+
+#
+# MDEV-6697: Improve foreign keys warnings/errors
+#
+
+#
+# No index for referenced columns
+#
+create table t1(a int) engine=innodb;
+--error 1005
+create table t2(a int, constraint a foreign key a (a) references t1(a)) engine=innodb;
+show warnings;
+drop table t1;
+
+create table t1(a int not null primary key, b int) engine=innodb;
+--error 1005
+create table t2(a int, b int, constraint a foreign key a (a) references t1(a),
+constraint a foreign key a (a) references t1(b)) engine=innodb;
+show warnings;
+create table t2(a int, b int, constraint a foreign key a (a) references t1(a)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+alter table t2 add constraint b foreign key (b) references t2(b);
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t2, t1;
+
+#
+# Referenced table does not exists
+#
+
+create table t1 (f1 integer primary key) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+alter table t1 add constraint c1 foreign key (f1) references t11(f1);
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t1;
+
+#
+# Foreign key on temporal tables
+#
+
+create temporary table t1(a int not null primary key, b int, key(b)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+alter table t1 add foreign key(b) references t1(a);
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t1;
+
+#
+# Column numbers do not match
+#
+create table t1(a int not null primary key, b int, key(b)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+alter table t1 add foreign key(a,b) references t1(a);
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t1;
+create table t1(a int not null primary key, b int, key(b)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+alter table t1 add foreign key(a) references t1(a,b);
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t1;
+
+#
+# ON UPDATE/DELETE SET NULL on NOT NULL column
+#
+create table t1 (f1 integer not null primary key) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+alter table t1 add constraint c1 foreign key (f1) references t1(f1) on update set null;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+create table t2(a int not null, foreign key(a) references t1(f1) on delete set null) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t1;
+
+#
+# Incorrect types
+#
+create table t1 (id int not null primary key, f1 int, f2 int, key(f1)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+--error 1005
+create table t2(a char(20), key(a), foreign key(a) references t1(f1)) engine=innodb;
+--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
+show warnings;
+drop table t1;
diff --git a/mysql-test/suite/innodb/t/innodb_bug60229-master.opt b/mysql-test/suite/innodb/t/innodb_bug60229-master.opt
deleted file mode 100644
index 9b27aef..0000000
--- a/mysql-test/suite/innodb/t/innodb_bug60229-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---lower_case_table_names=0
diff --git a/mysql-test/suite/innodb/t/innodb_bug60229.test b/mysql-test/suite/innodb/t/innodb_bug60229.test
index 8dcf151..aee0b96 100644
--- a/mysql-test/suite/innodb/t/innodb_bug60229.test
+++ b/mysql-test/suite/innodb/t/innodb_bug60229.test
@@ -2,6 +2,10 @@
 # Bug #13083023 - 60229: BROKEN COMPATIBILITY: ERROR WHILE CREATE TABLE
 # WITH FOREIGN KEY CONSTRAINT.
 
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
 -- source include/have_innodb.inc
 
 CREATE TABLE PERSON (
diff --git a/mysql-test/suite/innodb/t/innodb_bug68148.test b/mysql-test/suite/innodb/t/innodb_bug68148.test
new file mode 100644
index 0000000..531baa3
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_bug68148.test
@@ -0,0 +1,41 @@
+-- source include/have_innodb.inc
+-- source include/not_embedded.inc
+
+#
+# Bug #68148: drop index on a foreign key column leads to missing table
+# MDEV-8845: Table disappear after modifying FK
+#
+
+set global innodb_file_per_table=1;
+
+CREATE TABLE ref_table1 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB; 
+
+CREATE TABLE ref_table2 (id int(11) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;
+
+CREATE TABLE `main` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `ref_id1` int(11) NOT NULL,
+  `ref_id2` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `idx_1` (`ref_id1`,`ref_id2`),
+  KEY `FK_set_out_analysis_route_id` (`ref_id2`),
+  CONSTRAINT `FK_1` FOREIGN KEY (`ref_id1`) REFERENCES `ref_table1` (`id`) ,
+  CONSTRAINT `FK_2` FOREIGN KEY (`ref_id2`) REFERENCES `ref_table2` (`id`)
+) ENGINE=InnoDB;
+
+SET FOREIGN_KEY_CHECKS=0;
+
+DROP INDEX `idx_1` ON `main`;
+SHOW TABLES;
+
+--echo # restart and see if we can still access the main table
+--source include/restart_mysqld.inc
+
+# This is required to access the table
+SET FOREIGN_KEY_CHECKS=0;
+ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
+SHOW CREATE TABLE `main`;
+
+DROP TABLE  main, ref_table1, ref_table2;
+
+
diff --git a/mysql-test/suite/innodb/t/innodb_uninstall.opt b/mysql-test/suite/innodb/t/innodb_uninstall.opt
new file mode 100644
index 0000000..918855a
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_uninstall.opt
@@ -0,0 +1,3 @@
+--ignore-builtin-innodb
+--loose-innodb
+
diff --git a/mysql-test/suite/innodb/t/innodb_uninstall.test b/mysql-test/suite/innodb/t/innodb_uninstall.test
new file mode 100644
index 0000000..34fc834
--- /dev/null
+++ b/mysql-test/suite/innodb/t/innodb_uninstall.test
@@ -0,0 +1,58 @@
+--source include/not_embedded.inc
+--source include/not_windows.inc
+
+if (!$HA_INNODB_SO) {
+  --skip Need InnoDB plugin
+}
+
+#
+# MDEV-8474: InnoDB sets per-connection data unsafely
+# Below test caused hang
+#
+install plugin innodb soname 'ha_innodb';
+create table t1(a int not null primary key) engine=innodb;
+
+connect (con1, localhost, root);
+connection con1;
+begin;
+insert into t1 values(1);
+
+connection default;
+flush tables;
+send uninstall plugin innodb;
+
+connection con1;
+select sleep(1);
+disconnect con1;
+
+connection default;
+reap;
+
+--source include/restart_mysqld.inc
+
+drop table t1;
+
+#
+# Another test that caused hang.
+#
+
+connect (con1, localhost, root);
+connection con1;
+install plugin innodb soname 'ha_innodb';
+create table t2(a int not null primary key) engine=innodb;
+insert into t2 values(1);
+drop table t2;
+
+connection default;
+send uninstall plugin innodb;
+
+connection con1;
+select sleep(1);
+disconnect con1;
+
+connection default;
+reap;
+
+--source include/restart_mysqld.inc
+
+
diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test
index ff6da07..aec606d 100644
--- a/mysql-test/suite/innodb/t/xa_recovery.test
+++ b/mysql-test/suite/innodb/t/xa_recovery.test
@@ -6,6 +6,12 @@ if (`select plugin_auth_version <= "5.5.43-MariaDB-37.2" from information_schema
 # Embedded server does not support restarting.
 --source include/not_embedded.inc
 
+# MDEV-8841 - close tables opened by previous tests, 
+# so they don't get marked crashed when the server gets crashed
+--disable_query_log
+FLUSH TABLES;
+--enable_query_log
+
 CREATE TABLE t1 (a INT) ENGINE=InnoDB;
 INSERT INTO t1 VALUES (1);
 connect (con1,localhost,root);
diff --git a/mysql-test/suite/jp/t/jp_enum_sjis-master.opt b/mysql-test/suite/jp/t/jp_enum_sjis-master.opt
deleted file mode 100644
index 9b27aef..0000000
--- a/mysql-test/suite/jp/t/jp_enum_sjis-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---lower_case_table_names=0
diff --git a/mysql-test/suite/jp/t/jp_enum_sjis.test b/mysql-test/suite/jp/t/jp_enum_sjis.test
index e1f22f6..1060f83 100644
--- a/mysql-test/suite/jp/t/jp_enum_sjis.test
+++ b/mysql-test/suite/jp/t/jp_enum_sjis.test
@@ -1,3 +1,7 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
 --source include/have_sjis.inc
 --source include/have_innodb.inc
 --character_set sjis
diff --git a/mysql-test/suite/jp/t/jp_enum_ucs2-master.opt b/mysql-test/suite/jp/t/jp_enum_ucs2-master.opt
deleted file mode 100644
index 9b27aef..0000000
--- a/mysql-test/suite/jp/t/jp_enum_ucs2-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---lower_case_table_names=0
diff --git a/mysql-test/suite/jp/t/jp_enum_ucs2.test b/mysql-test/suite/jp/t/jp_enum_ucs2.test
index a3d7c47..321f895 100644
--- a/mysql-test/suite/jp/t/jp_enum_ucs2.test
+++ b/mysql-test/suite/jp/t/jp_enum_ucs2.test
@@ -1,3 +1,7 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
 --source include/have_ucs2.inc
 --source include/have_innodb.inc
 
diff --git a/mysql-test/suite/jp/t/jp_enum_ujis-master.opt b/mysql-test/suite/jp/t/jp_enum_ujis-master.opt
deleted file mode 100644
index 9b27aef..0000000
--- a/mysql-test/suite/jp/t/jp_enum_ujis-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---lower_case_table_names=0
diff --git a/mysql-test/suite/jp/t/jp_enum_ujis.test b/mysql-test/suite/jp/t/jp_enum_ujis.test
index 17e41e0..10e8ad5 100644
--- a/mysql-test/suite/jp/t/jp_enum_ujis.test
+++ b/mysql-test/suite/jp/t/jp_enum_ujis.test
@@ -1,3 +1,7 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
 --source include/have_ujis.inc
 --source include/have_innodb.inc
 
diff --git a/mysql-test/suite/jp/t/jp_enum_utf8-master.opt b/mysql-test/suite/jp/t/jp_enum_utf8-master.opt
deleted file mode 100644
index 9b27aef..0000000
--- a/mysql-test/suite/jp/t/jp_enum_utf8-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---lower_case_table_names=0
diff --git a/mysql-test/suite/jp/t/jp_enum_utf8.test b/mysql-test/suite/jp/t/jp_enum_utf8.test
index ff5978d..f67939b 100644
--- a/mysql-test/suite/jp/t/jp_enum_utf8.test
+++ b/mysql-test/suite/jp/t/jp_enum_utf8.test
@@ -1,3 +1,7 @@
+#Server variable option 'lower_case_table_names' sets '0' as default value
+#in case sensitive filesystem. Using 'lower_case_table_names=0' in case of
+#insensitive filsystem is not allowed.
+-- source include/have_case_sensitive_file_system.inc
 --source include/have_utf8.inc
 --source include/have_innodb.inc
 --disable_warnings
diff --git a/mysql-test/suite/ndb/r/ndb_restore_discover.result b/mysql-test/suite/ndb/r/ndb_restore_discover.result
new file mode 100644
index 0000000..de10af8
--- /dev/null
+++ b/mysql-test/suite/ndb/r/ndb_restore_discover.result
@@ -0,0 +1,33 @@
+#
+# 18075170 - sql node restart required to avoid deadlock after
+#            restore
+#
+CREATE TABLE t1 (id INT) ENGINE=NDBCluster;
+CREATE TABLE t2 (id INT) ENGINE=NDBCluster;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+DROP TABLE t1;
+DROP TABLE t2;
+SET autocommit = 0;
+SELECT * FROM t1;
+id
+1
+SELECT * FROM t2;
+id
+1
+ROLLBACK;
+SET autocommit = 1;
+drop table t1;
+drop table t2;
+SET autocommit = 0;
+SELECT * FROM t1;
+id
+1
+SELECT * FROM t2;
+id
+1
+ALTER TABLE t1 ADD val INT;
+ROLLBACK;
+SET autocommit = 1;
+drop table t1;
+drop table t2;
diff --git a/mysql-test/suite/ndb/t/ndb_restore_discover.test b/mysql-test/suite/ndb/t/ndb_restore_discover.test
new file mode 100644
index 0000000..6631c74
--- /dev/null
+++ b/mysql-test/suite/ndb/t/ndb_restore_discover.test
@@ -0,0 +1,70 @@
+-- source include/have_ndb.inc
+-- source include/count_sessions.inc
+
+--echo #
+--echo # 18075170 - sql node restart required to avoid deadlock after
+--echo #            restore
+--echo #
+# Test Auto Discover option within a transaction
+# and make sure the transaction is not broken.
+CREATE TABLE t1 (id INT) ENGINE=NDBCluster;
+CREATE TABLE t2 (id INT) ENGINE=NDBCluster;
+
+INSERT INTO t1 VALUES (1);
+INSERT INTO t2 VALUES (1);
+
+-- source include/ndb_backup.inc
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+-- source include/ndb_restore_master.inc
+
+SET autocommit = 0;
+SELECT * FROM t1;
+
+# Without fix below select was resulting in DEADLOCK error. With fix select
+# should succeed.
+SELECT * FROM t2;
+ROLLBACK;
+SET autocommit = 1;
+
+drop table t1;
+drop table t2;
+
+#
+# Checking lock preservation in transaction
+#
+# Using existing backup to create the scenario. Tables are deleted as part of
+# above test cleanup. Thus restoring the backup will bring the system to
+# required state.
+-- source include/ndb_restore_master.inc
+
+SET autocommit = 0;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+connect(con2, localhost, root);
+--SEND ALTER TABLE t1 ADD val INT
+
+connection default;
+# Alter from con2 will be in waiting state as there is a lock on t1 from
+# default connection due to active transaction. We check for this condition
+# then releasing the lock by rollbacking active transaction.
+let $wait_condition=
+  SELECT count(*) = 1 FROM information_schema.processlist WHERE state
+  LIKE "Waiting%" AND info = "ALTER TABLE t1 ADD val INT";
+--source include/wait_condition.inc
+ROLLBACK;
+SET autocommit = 1;
+
+connection con2;
+--REAP
+
+disconnect con2;
+connection default;
+drop table t1;
+drop table t2;
+
+# Wait till all disconnects are completed
+-- source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/perfschema/r/query_cache.result b/mysql-test/suite/perfschema/r/query_cache.result
index 8786cd0..837c257 100644
--- a/mysql-test/suite/perfschema/r/query_cache.result
+++ b/mysql-test/suite/perfschema/r/query_cache.result
@@ -38,7 +38,7 @@ spins
 NULL
 select * from performance_schema.setup_timers where name='wait';
 NAME	TIMER_NAME
-wait	CYCLE
+wait	{CYCLE_OR_NANOSECOND}
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	1
@@ -53,7 +53,7 @@ spins
 NULL
 select * from performance_schema.setup_timers where name='wait';
 NAME	TIMER_NAME
-wait	CYCLE
+wait	{CYCLE_OR_NANOSECOND}
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	1
diff --git a/mysql-test/suite/perfschema/t/query_cache.test b/mysql-test/suite/perfschema/t/query_cache.test
index 60d4a64..802e574 100644
--- a/mysql-test/suite/perfschema/t/query_cache.test
+++ b/mysql-test/suite/perfschema/t/query_cache.test
@@ -34,6 +34,7 @@ show status like "Qcache_hits";
 
 select spins from performance_schema.events_waits_current order by event_name limit 1;
 
+--replace_result CYCLE {CYCLE_OR_NANOSECOND} NANOSECOND {CYCLE_OR_NANOSECOND}
 select * from performance_schema.setup_timers where name='wait';
 
 show status like "Qcache_queries_in_cache";
@@ -42,6 +43,7 @@ show status like "Qcache_hits";
 
 select spins from performance_schema.events_waits_current order by event_name limit 1;
 
+--replace_result CYCLE {CYCLE_OR_NANOSECOND} NANOSECOND {CYCLE_OR_NANOSECOND}
 select * from performance_schema.setup_timers where name='wait';
 
 show status like "Qcache_queries_in_cache";
diff --git a/mysql-test/suite/plugins/r/feedback_plugin_load.result b/mysql-test/suite/plugins/r/feedback_plugin_load.result
index 443b91b..ea6eae9 100644
--- a/mysql-test/suite/plugins/r/feedback_plugin_load.result
+++ b/mysql-test/suite/plugins/r/feedback_plugin_load.result
@@ -1,10 +1,13 @@
 select plugin_status from information_schema.plugins where plugin_name='feedback';
 plugin_status
 ACTIVE
+SELECT variable_value INTO @feedback_used FROM information_schema.feedback where variable_name = 'FEEDBACK used';
+SELECT variable_value = @feedback_used + 1 FROM information_schema.feedback where variable_name = 'FEEDBACK used';
+variable_value = @feedback_used + 1
+1
 select * from information_schema.feedback where variable_name like 'feed%'
-       and variable_name not like  '%_uid';
+       and variable_name not like  '%_uid' and variable_name not like 'FEEDBACK used';
 VARIABLE_NAME	VARIABLE_VALUE
-FEEDBACK used	1
 FEEDBACK version	1.1
 FEEDBACK_SEND_RETRY_WAIT	60
 FEEDBACK_SEND_TIMEOUT	60
diff --git a/mysql-test/suite/plugins/r/feedback_plugin_send.result b/mysql-test/suite/plugins/r/feedback_plugin_send.result
index 2852240..90a37f7 100644
--- a/mysql-test/suite/plugins/r/feedback_plugin_send.result
+++ b/mysql-test/suite/plugins/r/feedback_plugin_send.result
@@ -1,10 +1,13 @@
 select plugin_status from information_schema.plugins where plugin_name='feedback';
 plugin_status
 ACTIVE
+SELECT variable_value INTO @feedback_used FROM information_schema.feedback where variable_name = 'FEEDBACK used';
+SELECT variable_value = @feedback_used + 1 FROM information_schema.feedback where variable_name = 'FEEDBACK used';
+variable_value = @feedback_used + 1
+1
 select * from information_schema.feedback where variable_name like 'feed%'
-       and variable_name not like  '%_uid';
+       and variable_name not like  '%_uid' and variable_name not like 'FEEDBACK used';
 VARIABLE_NAME	VARIABLE_VALUE
-FEEDBACK used	2
 FEEDBACK version	1.1
 FEEDBACK_SEND_RETRY_WAIT	60
 FEEDBACK_SEND_TIMEOUT	60
diff --git a/mysql-test/suite/plugins/t/feedback_plugin_load.test b/mysql-test/suite/plugins/t/feedback_plugin_load.test
index 5ad3016..f7c62b9 100644
--- a/mysql-test/suite/plugins/t/feedback_plugin_load.test
+++ b/mysql-test/suite/plugins/t/feedback_plugin_load.test
@@ -4,7 +4,24 @@ if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'fe
 }
 
 select plugin_status from information_schema.plugins where plugin_name='feedback';
+
+# Every SELECT from INFORMATION_SCHEMA.FEEDBACK increases the value of 'FEEDBACK used'.
+# We cannot record the actual value, because the test can be executed more than once,
+# but we can check that the value indeed increases as expected.
+# There is still a room for some race condition, e.g. if at the very moment
+# between first SELECT to store the value and the next SELECT to check that it increases,
+# the feedback plugin is activated. But the probability of it is close to 0,
+# so lets get back to it if it ever happens.
+
+# Lets say the plugin was used X times before this SELECT
+SELECT variable_value INTO @feedback_used FROM information_schema.feedback where variable_name = 'FEEDBACK used';
+
+# Now $feedback_used == X+1, and 'FEEDBACK used' is also X+1. And variable_value is increased again when we run the next SELECT
+SELECT variable_value = @feedback_used + 1 FROM information_schema.feedback where variable_name = 'FEEDBACK used';
+
+# Now when we are happy with 'FEEDBACK used', we can check everything else
+
 --replace_result https http
 --sorted_result
 select * from information_schema.feedback where variable_name like 'feed%'
-       and variable_name not like  '%_uid';
+       and variable_name not like  '%_uid' and variable_name not like 'FEEDBACK used';
diff --git a/mysql-test/suite/plugins/t/feedback_plugin_send.test b/mysql-test/suite/plugins/t/feedback_plugin_send.test
index 45b507f..31542c3 100644
--- a/mysql-test/suite/plugins/t/feedback_plugin_send.test
+++ b/mysql-test/suite/plugins/t/feedback_plugin_send.test
@@ -14,6 +14,15 @@ if (!$MTR_FEEDBACK_PLUGIN) {
 # is doing some work in other workers.
 #
 sleep 310;
+
+# The test expects that the plugin will send a report at least 2 times,
+# now (5 min after loading) and on server shutdown which happens below. 
+# Since we have already waited for 5 min, let's be generous
+# and make sure the server has enough time to shut down properly.
+# We won't lose anything if the shutdown is fast, but if it's slow, the plugin 
+# will still be able to finish the job and write about it in the error log.
+
+--let $shutdown_timeout= 60
 source include/restart_mysqld.inc;
 
 replace_result https http;
diff --git a/mysql-test/suite/rpl/r/rpl_alter.result b/mysql-test/suite/rpl/r/rpl_alter.result
index 2cffa70..7be3bc5 100644
--- a/mysql-test/suite/rpl/r/rpl_alter.result
+++ b/mysql-test/suite/rpl/r/rpl_alter.result
@@ -14,4 +14,109 @@ select * from mysqltest.t3;
 n
 45
 drop database mysqltest;
+use test;
+#
+# Test bug where ALTER TABLE MODIFY didn't replicate properly
+#
+create table t1 (a int unsigned primary key, b int);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(10) unsigned NOT NULL,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 (a) values (1),((1<<32)-1);
+select * from t1;
+a	b
+1	NULL
+4294967295	NULL
+alter table t1 modify a bigint;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bigint(20) NOT NULL DEFAULT '0',
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+a	b
+1	NULL
+4294967295	NULL
+alter table t1 modify a int unsigned;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(10) unsigned NOT NULL DEFAULT '0',
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+a	b
+1	NULL
+4294967295	NULL
+alter table t1 modify a bigint unsigned;
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bigint(20) unsigned NOT NULL DEFAULT '0',
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+select * from t1;
+a	b
+1	NULL
+4294967295	NULL
+use test;
+select * from t1;
+a	b
+1	NULL
+4294967295	NULL
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` bigint(20) unsigned NOT NULL DEFAULT '0',
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+create table t2 (a int unsigned auto_increment primary key, b int);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t2 modify a bigint;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` bigint(20) NOT NULL DEFAULT '0',
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t2 modify a bigint auto_increment;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` bigint(20) NOT NULL AUTO_INCREMENT,
+  `b` int(11) DEFAULT NULL,
+  PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1,t2;
+#
+# MDEV-8432:  Slave cannot replicate signed integer-type values
+# with high bit set to 1
+# Test replication when we have int on master and bigint on slave
+#
+create table t1 (a int unsigned primary key, b int);
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY';
+alter table t1 modify a bigint unsigned;
+insert into t1 (a) values (1),((1<<32)-1);
+select * from t1;
+a	b
+1	NULL
+4294967295	NULL
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='';
+drop table t1;
 include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result b/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result
index e71bb2e..c2a0498 100644
--- a/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result
+++ b/mysql-test/suite/rpl/r/show_status_stop_slave_race-7126.result
@@ -1,2 +1,4 @@
 include/master-slave.inc
 [connection master]
+start slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_alter.test b/mysql-test/suite/rpl/t/rpl_alter.test
index 630197f..8b8bcfb 100644
--- a/mysql-test/suite/rpl/t/rpl_alter.test
+++ b/mysql-test/suite/rpl/t/rpl_alter.test
@@ -15,4 +15,57 @@ drop database mysqltest;
 sync_slave_with_master;
 
 # End of 4.1 tests
+
+connection master;
+use test;
+
+--echo #
+--echo # Test bug where ALTER TABLE MODIFY didn't replicate properly
+--echo #
+
+create table t1 (a int unsigned primary key, b int);
+show create table t1;
+insert into t1 (a) values (1),((1<<32)-1);
+select * from t1;
+alter table t1 modify a bigint;
+show create table t1;
+select * from t1;
+alter table t1 modify a int unsigned;
+show create table t1;
+select * from t1;
+alter table t1 modify a bigint unsigned;
+show create table t1;
+select * from t1;
+sync_slave_with_master;
+use test;
+select * from t1;
+show create table t1;
+connection master;
+#
+create table t2 (a int unsigned auto_increment primary key, b int);
+show create table t2;
+alter table t2 modify a bigint;
+show create table t2;
+alter table t2 modify a bigint auto_increment;
+show create table t2;
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-8432:  Slave cannot replicate signed integer-type values
+--echo # with high bit set to 1
+--echo # Test replication when we have int on master and bigint on slave
+--echo #
+
+create table t1 (a int unsigned primary key, b int);
+sync_slave_with_master;
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='ALL_NON_LOSSY';
+alter table t1 modify a bigint unsigned;
+connection master;
+insert into t1 (a) values (1),((1<<32)-1);
+sync_slave_with_master;
+select * from t1;
+SET GLOBAL SLAVE_TYPE_CONVERSIONS='';
+connection master;
+drop table t1;
+
 --source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_innodb_bug30888.opt b/mysql-test/suite/rpl/t/rpl_innodb_bug30888.opt
new file mode 100644
index 0000000..e668573
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_innodb_bug30888.opt
@@ -0,0 +1 @@
+--innodb-flush-log-at-trx-commit=2
diff --git a/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test b/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test
index a79a188..38759c9 100644
--- a/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test
+++ b/mysql-test/suite/rpl/t/show_status_stop_slave_race-7126.test
@@ -10,3 +10,10 @@
 --exec $MYSQL_SLAP --silent --socket=$SLAVE_MYSOCK -q "START SLAVE; STOP SLAVE; SHOW GLOBAL STATUS" -c 2 --number-of-queries=100 --create-schema=test
 
 # All done.
+
+--connection slave
+start slave;
+
+--connection master
+--source include/rpl_end.inc
+
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index 42a3076..5550eeb 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -821,3 +821,14 @@ FROM ( SELECT * FROM t2 ) AS sq2, t3
 ORDER BY field;
 
 drop table t3, t2, t1;
+
+--echo #
+--echo # MDEV-7821 - Server crashes in Item_func_group_concat::fix_fields on 2nd
+--echo #             execution of PS
+--echo #
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1),(2);
+PREPARE stmt FROM "SELECT GROUP_CONCAT(t1a.a ORDER BY 1, t1a.a=0) FROM t1 AS t1a, t1 AS t1b GROUP BY t1a.a";
+EXECUTE stmt;
+EXECUTE stmt;
+DROP TABLE t1;
diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test
index 2b89a61..8fdba77 100644
--- a/mysql-test/t/func_if.test
+++ b/mysql-test/t/func_if.test
@@ -206,6 +206,20 @@ SELECT if(1, NULL, (SELECT min('hello')));
 
 --echo End of 5.2 tests
 
+--echo #
+--echo # MDEV-8663: IF Statement returns multiple values erroneously
+--echo # (or Assertion `!null_value' failed in Item::send(Protocol*, String*)
+--echo #
+CREATE TABLE `t1` (
+`datas` VARCHAR(25) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+INSERT INTO `t1` VALUES ('1,2'), ('2,3'), ('3,4');
+
+SELECT IF(FIND_IN_SET('1', `datas`), 1.5, IF(FIND_IN_SET('2', `datas`), 2, NULL)) AS `First`, '1' AS `Second`, '2' AS `Third` FROM `t1`;
+
+drop table t1;
+
 --disable_query_log
 # Restore timezone to default
 set time_zone= @@global.time_zone;
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 24fe1ef..5991220 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -391,6 +391,210 @@ set optimizer_switch=@optimizer_switch_save;
 drop view  v_merge, vm;
 drop table t1,tv;
 
+--echo #
+--echo # MDEV-4017 - GET_LOCK() with negative timeouts has strange behavior
+--echo #
+SELECT GET_LOCK('ul1', NULL);
+SELECT GET_LOCK('ul1', -1);
+
+--echo #
+--echo # MDEV-8624 MariaDB hangs on query with many logical condition
+--echo #
+CREATE TABLE `t1` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `submitdate` datetime DEFAULT NULL,
+  `lastpage` int(11) DEFAULT NULL,
+  `startlanguage` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
+  `token` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `datestamp` datetime NOT NULL,
+  `startdate` datetime NOT NULL,
+  `ipaddr` text COLLATE utf8_unicode_ci,
+  `refurl` text COLLATE utf8_unicode_ci,
+  `57813X540X1723` text COLLATE utf8_unicode_ci,
+  `57813X540X1724` text COLLATE utf8_unicode_ci,
+  `57813X540X1725` text COLLATE utf8_unicode_ci,
+  `57813X540X1726` double DEFAULT NULL,
+  `57813X540X1909` double DEFAULT NULL,
+  `57813X541X17271` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X541X17272` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X541X17273` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X541X17274` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X541X17275` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X541X17276` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X541X17281` text COLLATE utf8_unicode_ci,
+  `57813X541X17282` text COLLATE utf8_unicode_ci,
+  `57813X541X17283` text COLLATE utf8_unicode_ci,
+  `57813X541X17284` text COLLATE utf8_unicode_ci,
+  `57813X541X17285` text COLLATE utf8_unicode_ci,
+  `57813X541X17286` text COLLATE utf8_unicode_ci,
+  `57813X542X18131` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18132` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18133` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18134` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18135` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18136` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18137` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18138` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18139` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X542X18141` text COLLATE utf8_unicode_ci,
+  `57813X542X18142` text COLLATE utf8_unicode_ci,
+  `57813X542X18143` text COLLATE utf8_unicode_ci,
+  `57813X542X18144` text COLLATE utf8_unicode_ci,
+  `57813X542X18145` text COLLATE utf8_unicode_ci,
+  `57813X542X18146` text COLLATE utf8_unicode_ci,
+  `57813X542X18147` text COLLATE utf8_unicode_ci,
+  `57813X542X18148` text COLLATE utf8_unicode_ci,
+  `57813X542X18149` text COLLATE utf8_unicode_ci,
+  `57813X543X18451` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X543X18452` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X543X18453` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X543X18454` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X543X18455` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X543X18456` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X543X18461` text COLLATE utf8_unicode_ci,
+  `57813X543X18462` text COLLATE utf8_unicode_ci,
+  `57813X543X18463` text COLLATE utf8_unicode_ci,
+  `57813X543X18464` text COLLATE utf8_unicode_ci,
+  `57813X543X18465` text COLLATE utf8_unicode_ci,
+  `57813X543X18466` text COLLATE utf8_unicode_ci,
+  `57813X544X18711` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18712` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18713` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18714` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18715` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18716` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18717` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18718` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X544X18721` text COLLATE utf8_unicode_ci,
+  `57813X544X18722` text COLLATE utf8_unicode_ci,
+  `57813X544X18723` text COLLATE utf8_unicode_ci,
+  `57813X544X18724` text COLLATE utf8_unicode_ci,
+  `57813X544X18725` text COLLATE utf8_unicode_ci,
+  `57813X544X18726` text COLLATE utf8_unicode_ci,
+  `57813X544X18727` text COLLATE utf8_unicode_ci,
+  `57813X544X18728` text COLLATE utf8_unicode_ci,
+  `57813X546X1902` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X546X1903` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X546X1904` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
+  `57813X545X1901` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `lime_survey_57813_idx` (`token`),
+  KEY `57813X540X1723` (`57813X540X1723`(100)),
+  KEY `57813X540X1724` (`57813X540X1724`(100)),
+  KEY `57813X540X1726` (`57813X540X1726`),
+  KEY `57813X540X1725` (`57813X540X1725`(100)),
+  KEY `57813X546X1902` (`57813X546X1902`),
+  KEY `57813X546X1903` (`57813X546X1903`),
+  KEY `57813X546X1904` (`57813X546X1904`)
+);
+
+SELECT 
+COUNT(*) as `N`, 
+ROUND( 
+      ( 
+        SUM( 
+            ( 
+             ( 
+	      IF( 57813X541X17271 IS NOT NULL AND 57813X541X17271 != '' AND 57813X541X17271 != '99', 57813X541X17271, 0 ) + 
+              IF( 57813X541X17272 IS NOT NULL AND 57813X541X17272 != '' AND 57813X541X17272 != '99', 57813X541X17272, 0 ) + 
+              IF( 57813X541X17273 IS NOT NULL AND 57813X541X17273 != '' AND 57813X541X17273 != '99', 57813X541X17273, 0 ) + 
+              IF( 57813X541X17274 IS NOT NULL AND 57813X541X17274 != '' AND 57813X541X17274 != '99', 57813X541X17274, 0 ) + 
+              IF( 57813X541X17275 IS NOT NULL AND 57813X541X17275 != '' AND 57813X541X17275 != '99', 57813X541X17275, 0 ) +
+              IF( 57813X541X17276 IS NOT NULL AND 57813X541X17276 != '' AND 57813X541X17276 != '99', 57813X541X17276, 0 ) + 
+              IF( 57813X542X18131 IS NOT NULL AND 57813X542X18131 != '' AND 57813X542X18131 != '99', 57813X542X18131, 0 ) + 
+              IF( 57813X542X18132 IS NOT NULL AND 57813X542X18132 != '' AND 57813X542X18132 != '99', 57813X542X18132, 0 ) + 
+              IF( 57813X542X18133 IS NOT NULL AND 57813X542X18133 != '' AND 57813X542X18133 != '99', 57813X542X18133, 0 ) + 
+              IF( 57813X542X18134 IS NOT NULL AND 57813X542X18134 != '' AND 57813X542X18134 != '99', 57813X542X18134, 0 ) + 
+              IF( 57813X542X18135 IS NOT NULL AND 57813X542X18135 != '' AND 57813X542X18135 != '99', 57813X542X18135, 0 ) + 
+              IF( 57813X542X18136 IS NOT NULL AND 57813X542X18136 != '' AND 57813X542X18136 != '99', 57813X542X18136, 0 ) + 
+              IF( 57813X542X18137 IS NOT NULL AND 57813X542X18137 != '' AND 57813X542X18137 != '99', 57813X542X18137, 0 ) + 
+              IF( 57813X542X18138 IS NOT NULL AND 57813X542X18138 != '' AND 57813X542X18138 != '99', 57813X542X18138, 0 ) + 
+              IF( 57813X542X18139 IS NOT NULL AND 57813X542X18139 != '' AND 57813X542X18139 != '99', 57813X542X18139, 0 ) + 
+              IF( 57813X543X18451 IS NOT NULL AND 57813X543X18451 != '' AND 57813X543X18451 != '99', 57813X543X18451, 0 ) + 
+              IF( 57813X543X18452 IS NOT NULL AND 57813X543X18452 != '' AND 57813X543X18452 != '99', 57813X543X18452, 0 ) + 
+              IF( 57813X543X18453 IS NOT NULL AND 57813X543X18453 != '' AND 57813X543X18453 != '99', 57813X543X18453, 0 ) + 
+              IF( 57813X543X18454 IS NOT NULL AND 57813X543X18454 != '' AND 57813X543X18454 != '99', 57813X543X18454, 0 ) + 
+              IF( 57813X543X18455 IS NOT NULL AND 57813X543X18455 != '' AND 57813X543X18455 != '99', 57813X543X18455, 0 ) + 
+              IF( 57813X543X18456 IS NOT NULL AND 57813X543X18456 != '' AND 57813X543X18456 != '99', 57813X543X18456, 0 ) + 
+              IF( 57813X544X18711 IS NOT NULL AND 57813X544X18711 != '' AND 57813X544X18711 != '99', 57813X544X18711, 0 ) + 
+              IF( 57813X544X18712 IS NOT NULL AND 57813X544X18712 != '' AND 57813X544X18712 != '99', 57813X544X18712, 0 ) + 
+              IF( 57813X544X18713 IS NOT NULL AND 57813X544X18713 != '' AND 57813X544X18713 != '99', 57813X544X18713, 0 ) + 
+              IF( 57813X544X18714 IS NOT NULL AND 57813X544X18714 != '' AND 57813X544X18714 != '99', 57813X544X18714, 0 ) + 
+              IF( 57813X544X18715 IS NOT NULL AND 57813X544X18715 != '' AND 57813X544X18715 != '99', 57813X544X18715, 0 ) + 
+              IF( 57813X544X18716 IS NOT NULL AND 57813X544X18716 != '' AND 57813X544X18716 != '99', 57813X544X18716, 0 ) + 
+              IF( 57813X544X18717 IS NOT NULL AND 57813X544X18717 != '' AND 57813X544X18717 != '99', 57813X544X18717, 0 ) + 
+              IF( 57813X544X18718 IS NOT NULL AND 57813X544X18718 != '' AND 57813X544X18718 != '99', 57813X544X18718, 0 ) 
+             ) 
+             / 
+             (
+              IF( 57813X541X17271 IS NOT NULL AND 57813X541X17271 != '' AND 57813X541X17271 != '99', 1, 0 ) + 
+              IF( 57813X541X17272 IS NOT NULL AND 57813X541X17272 != '' AND 57813X541X17272 != '99', 1, 0 ) + 
+              IF( 57813X541X17273 IS NOT NULL AND 57813X541X17273 != '' AND 57813X541X17273 != '99', 1, 0 ) + 
+              IF( 57813X541X17274 IS NOT NULL AND 57813X541X17274 != '' AND 57813X541X17274 != '99', 1, 0 ) + 
+              IF( 57813X541X17275 IS NOT NULL AND 57813X541X17275 != '' AND 57813X541X17275 != '99', 1, 0 ) + 
+              IF( 57813X541X17276 IS NOT NULL AND 57813X541X17276 != '' AND 57813X541X17276 != '99', 1, 0 ) + 
+              IF( 57813X542X18131 IS NOT NULL AND 57813X542X18131 != '' AND 57813X542X18131 != '99', 1, 0 ) + 
+              IF( 57813X542X18132 IS NOT NULL AND 57813X542X18132 != '' AND 57813X542X18132 != '99', 1, 0 ) + 
+              IF( 57813X542X18133 IS NOT NULL AND 57813X542X18133 != '' AND 57813X542X18133 != '99', 1, 0 ) + 
+              IF( 57813X542X18134 IS NOT NULL AND 57813X542X18134 != '' AND 57813X542X18134 != '99', 1, 0 ) + 
+              IF( 57813X542X18135 IS NOT NULL AND 57813X542X18135 != '' AND 57813X542X18135 != '99', 1, 0 ) + 
+              IF( 57813X542X18136 IS NOT NULL AND 57813X542X18136 != '' AND 57813X542X18136 != '99', 1, 0 ) + 
+              IF( 57813X542X18137 IS NOT NULL AND 57813X542X18137 != '' AND 57813X542X18137 != '99', 1, 0 ) + 
+              IF( 57813X542X18138 IS NOT NULL AND 57813X542X18138 != '' AND 57813X542X18138 != '99', 1, 0 ) + 
+              IF( 57813X542X18139 IS NOT NULL AND 57813X542X18139 != '' AND 57813X542X18139 != '99', 1, 0 ) + 
+              IF( 57813X543X18451 IS NOT NULL AND 57813X543X18451 != '' AND 57813X543X18451 != '99', 1, 0 ) + 
+              IF( 57813X543X18452 IS NOT NULL AND 57813X543X18452 != '' AND 57813X543X18452 != '99', 1, 0 ) + 
+              IF( 57813X543X18453 IS NOT NULL AND 57813X543X18453 != '' AND 57813X543X18453 != '99', 1, 0 ) + 
+              IF( 57813X543X18454 IS NOT NULL AND 57813X543X18454 != '' AND 57813X543X18454 != '99', 1, 0 ) + 
+              IF( 57813X543X18455 IS NOT NULL AND 57813X543X18455 != '' AND 57813X543X18455 != '99', 1, 0 ) + 
+              IF( 57813X543X18456 IS NOT NULL AND 57813X543X18456 != '' AND 57813X543X18456 != '99', 1, 0 ) + 
+              IF( 57813X544X18711 IS NOT NULL AND 57813X544X18711 != '' AND 57813X544X18711 != '99', 1, 0 ) + 
+              IF( 57813X544X18712 IS NOT NULL AND 57813X544X18712 != '' AND 57813X544X18712 != '99', 1, 0 ) + 
+              IF( 57813X544X18713 IS NOT NULL AND 57813X544X18713 != '' AND 57813X544X18713 != '99', 1, 0 ) + 
+              IF( 57813X544X18714 IS NOT NULL AND 57813X544X18714 != '' AND 57813X544X18714 != '99', 1, 0 ) + 
+              IF( 57813X544X18715 IS NOT NULL AND 57813X544X18715 != '' AND 57813X544X18715 != '99', 1, 0 ) + 
+              IF( 57813X544X18716 IS NOT NULL AND 57813X544X18716 != '' AND 57813X544X18716 != '99', 1, 0 ) + 
+              IF( 57813X544X18717 IS NOT NULL AND 57813X544X18717 != '' AND 57813X544X18717 != '99', 1, 0 ) + 
+              IF( 57813X544X18718 IS NOT NULL AND 57813X544X18718 != '' AND 57813X544X18718 != '99', 1, 0 ) 
+              ) 
+             ) 
+            ) 
+        / COUNT(*) ), 4) as `AVG`
+FROM `t1` 
+WHERE `submitdate` IS NOT NULL 
+AND ( 
+     ( 57813X541X17271 IS NOT NULL AND 57813X541X17271 != '' AND 57813X541X17271 != '99' ) OR 
+     ( 57813X541X17272 IS NOT NULL AND 57813X541X17272 != '' AND 57813X541X17272 != '99' ) OR 
+     ( 57813X541X17273 IS NOT NULL AND 57813X541X17273 != '' AND 57813X541X17273 != '99' ) OR 
+     ( 57813X541X17274 IS NOT NULL AND 57813X541X17274 != '' AND 57813X541X17274 != '99' ) OR 
+     ( 57813X541X17275 IS NOT NULL AND 57813X541X17275 != '' AND 57813X541X17275 != '99' ) OR 
+     ( 57813X541X17276 IS NOT NULL AND 57813X541X17276 != '' AND 57813X541X17276 != '99' ) OR 
+     ( 57813X542X18131 IS NOT NULL AND 57813X542X18131 != '' AND 57813X542X18131 != '99' ) OR 
+     ( 57813X542X18132 IS NOT NULL AND 57813X542X18132 != '' AND 57813X542X18132 != '99' ) OR 
+     ( 57813X542X18133 IS NOT NULL AND 57813X542X18133 != '' AND 57813X542X18133 != '99' ) OR 
+     ( 57813X542X18134 IS NOT NULL AND 57813X542X18134 != '' AND 57813X542X18134 != '99' ) OR 
+     ( 57813X542X18135 IS NOT NULL AND 57813X542X18135 != '' AND 57813X542X18135 != '99' ) OR 
+     ( 57813X542X18136 IS NOT NULL AND 57813X542X18136 != '' AND 57813X542X18136 != '99' ) OR 
+     ( 57813X542X18137 IS NOT NULL AND 57813X542X18137 != '' AND 57813X542X18137 != '99' ) OR 
+     ( 57813X542X18138 IS NOT NULL AND 57813X542X18138 != '' AND 57813X542X18138 != '99' ) OR 
+     ( 57813X542X18139 IS NOT NULL AND 57813X542X18139 != '' AND 57813X542X18139 != '99' ) OR 
+     ( 57813X543X18451 IS NOT NULL AND 57813X543X18451 != '' AND 57813X543X18451 != '99' ) OR 
+     ( 57813X543X18452 IS NOT NULL AND 57813X543X18452 != '' AND 57813X543X18452 != '99' ) OR 
+     ( 57813X543X18453 IS NOT NULL AND 57813X543X18453 != '' AND 57813X543X18453 != '99' ) OR 
+     ( 57813X543X18454 IS NOT NULL AND 57813X543X18454 != '' AND 57813X543X18454 != '99' ) OR 
+     ( 57813X543X18455 IS NOT NULL AND 57813X543X18455 != '' AND 57813X543X18455 != '99' ) OR 
+     ( 57813X543X18456 IS NOT NULL AND 57813X543X18456 != '' AND 57813X543X18456 != '99' ) OR 
+     ( 57813X544X18711 IS NOT NULL AND 57813X544X18711 != '' AND 57813X544X18711 != '99' ) OR 
+     ( 57813X544X18712 IS NOT NULL AND 57813X544X18712 != '' AND 57813X544X18712 != '99' ) OR 
+     ( 57813X544X18713 IS NOT NULL AND 57813X544X18713 != '' AND 57813X544X18713 != '99' ) OR 
+     ( 57813X544X18714 IS NOT NULL AND 57813X544X18714 != '' AND 57813X544X18714 != '99' ) OR 
+     ( 57813X544X18715 IS NOT NULL AND 57813X544X18715 != '' AND 57813X544X18715 != '99' ) OR 
+     ( 57813X544X18716 IS NOT NULL AND 57813X544X18716 != '' AND 57813X544X18716 != '99' ) OR 
+     ( 57813X544X18717 IS NOT NULL AND 57813X544X18717 != '' AND 57813X544X18717 != '99' ) OR 
+     ( 57813X544X18718 IS NOT NULL AND 57813X544X18718 != '' AND 57813X544X18718 != '99' ) ) 
+AND 57813X540X1723 = 'Test';
+
+drop table t1;
 
 --echo #
 --echo # End of 5.5 tests
diff --git a/mysql-test/t/information_schema2.test b/mysql-test/t/information_schema2.test
index 06bc6d1..9810c5a 100644
--- a/mysql-test/t/information_schema2.test
+++ b/mysql-test/t/information_schema2.test
@@ -8,15 +8,12 @@ select variable_name from information_schema.session_variables where variable_na
 (select variable_name from information_schema.session_variables where variable_name = 'basedir');
 
 #
-# information_schema tables inside subqueries, they should not be re-populated
-# (i_s.columns needs to scan i_s itself, creating a tmp table for every i_s
-# table. if it's re-populated, it'll do that multiple times)
+# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
 #
-create table t1 (a char);
-insert t1 values ('a'),('t'),('z');
-flush status;
-select a, exists (select 1 from information_schema.columns where table_schema=concat('tes',a)) from t1;
-# fix the result in ps-protocol
---replace_result 39 38
-show status like 'created_tmp_tables';
-drop table t1;
+create table t1 (x int);
+create table t2 (x int);
+create table t3 (x int);
+create table t4 AS select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE' ;
+delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
+select * from t4;
+drop table t1, t2, t3, t4;
diff --git a/mysql-test/t/innodb_load_xa.test b/mysql-test/t/innodb_load_xa.test
index 5286215..9ecddde 100644
--- a/mysql-test/t/innodb_load_xa.test
+++ b/mysql-test/t/innodb_load_xa.test
@@ -16,3 +16,6 @@ commit;
 --source include/show_binlog_events.inc
 drop table t1;
 uninstall plugin innodb;
+
+--source include/restart_mysqld.inc
+
diff --git a/mysql-test/t/loadxml.test b/mysql-test/t/loadxml.test
index 6faf712..93e6e82 100644
--- a/mysql-test/t/loadxml.test
+++ b/mysql-test/t/loadxml.test
@@ -116,3 +116,17 @@ LOAD XML INFILE '../../std_data/loadxml.dat' INTO TABLE t1
 ROWS IDENTIFIED BY '<row>' (a, at b) SET b=concat('!', at b);
 SELECT * FROM t1 ORDER BY a;
 DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#16171518 LOAD XML DOES NOT HANDLE EMPTY ELEMENTS
+--echo #
+CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 VARCHAR(3), col4 VARCHAR(4));
+LOAD XML INFILE '../../std_data/bug16171518_1.dat' INTO TABLE t1;
+SELECT * FROM t1 ORDER BY col1, col2, col3, col4;
+DROP TABLE t1;
+
+CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 INTEGER);
+LOAD XML INFILE '../../std_data/bug16171518_2.dat' INTO TABLE t1;
+SELECT * FROM t1 ORDER BY col1, col2, col3;
+DROP TABLE t1;
diff --git a/mysql-test/t/lowercase_fs_on.test b/mysql-test/t/lowercase_fs_on.test
new file mode 100644
index 0000000..6da3ef3
--- /dev/null
+++ b/mysql-test/t/lowercase_fs_on.test
@@ -0,0 +1,38 @@
+#
+# Specific tests for case-insensitive file systems
+# i.e. lower_case_filesystem=ON
+#
+-- source include/have_case_insensitive_file_system.inc
+# Embedded server does not support restarting.
+--source include/not_embedded.inc
+
+--echo #
+--echo # Bug#20198490 : LOWER_CASE_TABLE_NAMES=0 ON WINDOWS LEADS TO PROBLEMS
+--echo #
+
+let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err;
+
+--error 0,1
+--remove_file $SEARCH_FILE
+
+#Shutdown the server
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--shutdown_server
+--source include/wait_until_disconnected.inc
+
+#Start the server with --lower_case_table_names=0 in Windows.
+--enable_reconnect
+--error 1
+--exec $MYSQLD_CMD --lower_case_table_names=0 > $SEARCH_FILE  2>&1
+
+#Search for the error messege in the server error log.
+let SEARCH_PATTERN= \[ERROR\] The server option \'lower_case_table_names\' is configured to use case sensitive table names but the data directory is on a case-insensitive file system which is an unsupported combination\. Please consider either using a case sensitive file system for your data directory or switching to a case-insensitive table name mode\.;
+--source include/search_pattern_in_file.inc
+
+#Restart the server
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--source include/wait_until_connected_again.inc
+
+#Cleanup
+--error 0,1
+--remove_file $SEARCH_FILE
diff --git a/mysql-test/t/lowercase_table3-master.opt b/mysql-test/t/lowercase_table3-master.opt
deleted file mode 100644
index 9b27aef..0000000
--- a/mysql-test/t/lowercase_table3-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---lower_case_table_names=0
diff --git a/mysql-test/t/lowercase_table3.test b/mysql-test/t/lowercase_table3.test
deleted file mode 100644
index f7ca821..0000000
--- a/mysql-test/t/lowercase_table3.test
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Test of force of lower-case-table-names=0
-# (User has case insensitive file system and wants to preserve case of
-# table names)
-#
-
---source include/have_innodb.inc
---source include/have_lowercase0.inc
---source include/have_case_insensitive_file_system.inc
---source include/not_windows.inc
-
-call mtr.add_suppression("Cannot find or open table test/BUG29839 from");
-
---disable_warnings
-DROP TABLE IF EXISTS t1,T1;
---enable_warnings
-
-#
-# This is actually an error, but ok as the user has forced this
-# by using --lower-case-table-names=0
-CREATE TABLE t1 (a INT);
-SELECT * FROM T1;
-FLUSH TABLES;
-DROP TABLE t1;
-
-#
-# InnoDB should in this case be case sensitive
-# Note that this is not true on windows as no this OS, InnoDB is always
-# storing things in lower case.
-#
-
-CREATE TABLE bug29839 (a INT) ENGINE=INNODB;
---error ER_NO_SUCH_TABLE
-SELECT * FROM BUG29839;
-DROP TABLE bug29839;
-
-# End of 4.1 tests
diff --git a/mysql-test/t/merge_recover-master.opt b/mysql-test/t/myisam_recover-master.opt
similarity index 100%
rename from mysql-test/t/merge_recover-master.opt
rename to mysql-test/t/myisam_recover-master.opt
diff --git a/mysql-test/t/merge_recover.test b/mysql-test/t/myisam_recover.test
similarity index 61%
rename from mysql-test/t/merge_recover.test
rename to mysql-test/t/myisam_recover.test
index f2cb204..49fe9c3 100644
--- a/mysql-test/t/merge_recover.test
+++ b/mysql-test/t/myisam_recover.test
@@ -1,5 +1,9 @@
+--source include/count_sessions.inc
+
+--echo #
+--echo # Tests for corrupted MyISAM tables and MyISAMMRG tables with corrupted
+--echo # children..
 --echo #
---echo # Test of MyISAM MRG tables with corrupted children.
 --echo # Run with --myisam-recover=force option.
 --echo #
 --echo # Preparation: we need to make sure that the merge parent
@@ -57,10 +61,10 @@ eval $lock;
 --echo #
 connection default;
 --echo #
---echo # We have to disable the ps-protocol, to avoid 
+--echo # We have to disable the ps-protocol, to avoid
 --echo # "Prepared statement needs to be re-prepared" errors
 --echo # -- table def versions change all the time with full table cache.
---echo # 
+--echo #
 --disable_ps_protocol
 --disable_warnings
 drop table if exists t1, t1_mrg, t1_copy;
@@ -69,12 +73,12 @@ let $MYSQLD_DATADIR=`select @@datadir`;
 --echo #
 --echo # Prepare a MERGE engine table, that refers to a corrupted
 --echo # child.
---echo # 
+--echo #
 create table t1 (a int, key(a)) engine=myisam;
 create table t1_mrg (a int) union (t1) engine=merge;
 --echo #
 --echo # Create a table with a corrupted index file:
---echo # save an old index file, insert more rows, 
+--echo # save an old index file, insert more rows,
 --echo # overwrite the new index file with the old one.
 --echo #
 insert into  t1 (a) values (1), (2), (3);
@@ -111,3 +115,66 @@ set @@global.table_open_cache=default;
 disconnect con1;
 connection default;
 --enable_ps_protocol
+
+--echo #
+--echo # 18075170 - sql node restart required to avoid deadlock after
+--echo #            restore
+--echo #
+--echo # Check that auto-repair for MyISAM tables can now happen in the
+--echo # middle of transaction, without aborting it.
+--enable_prepare_warnings
+
+connection default;
+
+create table t1 (a int, key(a)) engine=myisam;
+create table t2 (a int);
+insert into t2 values (1);
+
+--echo # Create a table with a corrupted index file:
+--echo # save an old index file, insert more rows,
+--echo # overwrite the new index file with the old one.
+insert into  t1 (a) values (1);
+flush table t1;
+--copy_file $MYSQLD_DATADIR/test/t1.MYI $MYSQLD_DATADIR/test/t1_copy.MYI
+insert into  t1 (a) values (4);
+flush table t1;
+--remove_file $MYSQLD_DATADIR/test/t1.MYI
+--copy_file $MYSQLD_DATADIR/test/t1_copy.MYI $MYSQLD_DATADIR/test/t1.MYI
+--remove_file $MYSQLD_DATADIR/test/t1_copy.MYI
+
+--echo # Check table is needed to mark the table as crashed.
+check table t1;
+
+--echo # At this point we have a corrupt t1
+set autocommit = 0;
+select * from t2;
+--echo # Without fix select from t1 will break the transaction. After the fix
+--echo # transaction should be active and should hold lock on table t2. Alter
+--echo # table from con2 will wait only if the transaction is not broken.
+--replace_regex /'.*[\/\\]/'/
+select * from t1;
+
+connect(con2, localhost, root);
+--SEND ALTER TABLE t2 ADD val INT
+
+connection default;
+--echo # With fix we should have alter table waiting for t2 lock here.
+let $wait_condition=
+  SELECT count(*) = 1 FROM information_schema.processlist WHERE state
+  LIKE "Waiting%" AND info = "ALTER TABLE t2 ADD val INT";
+
+--source include/wait_condition.inc
+ROLLBACK;
+SET autocommit = 1;
+
+connection con2;
+--REAP
+
+connection default;
+disconnect con2;
+
+--echo # Cleanup
+drop table t1, t2;
+
+# Wait till all disconnects are completed
+-- source include/wait_until_count_sessions.inc
diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test
index e4923e5..13be03a 100644
--- a/mysql-test/t/mysql_upgrade.test
+++ b/mysql-test/t/mysql_upgrade.test
@@ -14,7 +14,6 @@ file_exists $MYSQLD_DATADIR/mysql_upgrade_info;
 
 --echo Run it again - should say already completed
 --replace_result $MYSQL_SERVER_VERSION VERSION
---error 1
 --exec $MYSQL_UPGRADE 2>&1
 
 # It should have created a file in the MySQL Servers datadir
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 249f16e..e0c0ce3 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -901,13 +901,8 @@ select * from t1;
 create  view v1 as
 select * from v3 where b in (1, 2, 3, 4, 5, 6, 7);
 
-# Disable warnings since LIMIT warning for unsafe statement if
-# binlog_format = STATEMENT. Note: after BUG#45832, the warning should
-# not be issued.
---disable_warnings
 create  view v2 as
 select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
---enable_warnings
 
 --exec $MYSQL_DUMP --skip-comments test
 
@@ -1777,7 +1772,7 @@ drop table words;
 --replace_regex /.*mysqlimport(\.exe)*/mysqlimport/
 --replace_result mysqldump.exe mysqldump
 --error 1
---exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data/words.dat $MYSQLTEST_VARDIR/std_data/words2.dat 2>&1
+--exec $MYSQL_IMPORT --silent --use-threads=2 test $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt $MYSQLTEST_VARDIR/std_data/words.dat $MYSQLTEST_VARDIR/std_data/words2.dat
 
 drop table t1;
 drop table t2;
@@ -2456,6 +2451,35 @@ drop table t1, t2;
 --echo # End of 5.1 tests
 --echo #
 
+--echo #
+--echo # Bug #20772273 : MYSQLIMPORT --USE-THREADS DOESN'T USE MULTIPLE THREADS
+--echo #
+
+CREATE DATABASE db_20772273;
+USE db_20772273;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE TABLE t2(a INT);
+INSERT INTO t2 VALUES (3), (4);
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ db_20772273
+--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t1.sql
+--exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t2.sql
+
+# Test mysqlimport with multiple threads
+--exec $MYSQL_IMPORT --silent --use-threads=2 db_20772273 $MYSQLTEST_VARDIR/tmp/t1.txt $MYSQLTEST_VARDIR/tmp/t2.txt
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+#Cleanup
+DROP TABLE t1;
+DROP TABLE t2;
+DROP DATABASE db_20772273;
+
 #
 # MDEV-6091 mysqldump goes in a loop and segfaults if --dump-slave is specified and it cannot connect to the server
 #
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 6479957..6b6e54b 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -1146,7 +1146,7 @@ subpartition by hash (rand(a+b));
 #
 # Subpartition by hash, wrong subpartition function
 #
---error ER_SUBPARTITION_ERROR
+--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
 CREATE TABLE t1 (
 a int not null,
 b int not null,
diff --git a/mysql-test/t/sp-group.test b/mysql-test/t/sp-group.test
new file mode 100644
index 0000000..2083ac9
--- /dev/null
+++ b/mysql-test/t/sp-group.test
@@ -0,0 +1,187 @@
+--source include/have_innodb.inc
+
+drop table if exists t1;
+drop view if exists view_t1;
+
+#
+# Test case for MDEV 7601, MDEV-7594 and MDEV-7555
+# Server crashes in functions related to stored procedures
+# Server crashes in different ways while executing concurrent
+# flow involving views and non-empty sql_mode with ONLY_FULL_GROUP_BY
+#
+
+SET sql_mode=ONLY_FULL_GROUP_BY;
+
+CREATE TABLE t1 (
+  pk INT, 
+  f0 INT, f1 INT, f2 INT, f3 INT, f4 INT, 
+  f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, 
+  PRIMARY KEY (pk)
+);
+
+CREATE VIEW view_t1 AS SELECT * FROM t1;
+CREATE PROCEDURE s1() 
+  SELECT * FROM (
+  INFORMATION_SCHEMA.`INNODB_BUFFER_PAGE_LRU` AS table1
+  LEFT JOIN test.view_t1 AS table2
+  ON ( table2.`f6` = table1.FREE_PAGE_CLOCK) 
+  ) 
+  ORDER BY table1.NUMBER_RECORDS
+  LIMIT 0
+;
+CALL s1;
+CALL s1;
+
+drop table t1;
+drop view view_t1;
+drop procedure s1;
+
+#
+# MDEV-7590
+# Server crashes in st_select_lex_unit::cleanup on executing a trigger
+#
+
+CREATE TABLE A (
+    pk INTEGER AUTO_INCREMENT,
+    col_int_key INTEGER,
+    col_varchar_key VARCHAR(1),
+    PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+CREATE VIEW view_A AS SELECT * FROM A;
+CREATE TABLE C (
+    pk INTEGER AUTO_INCREMENT,
+    col_int_nokey INTEGER,
+    col_int_key INTEGER,
+    col_date_key DATE,
+    col_date_nokey DATE,
+    col_time_key TIME,
+    col_time_nokey TIME,
+    col_datetime_key DATETIME,
+    col_datetime_nokey DATETIME,
+    col_varchar_key VARCHAR(1),
+    col_varchar_nokey VARCHAR(1),
+    PRIMARY KEY (pk)
+) ENGINE=MyISAM;
+CREATE VIEW view_C AS SELECT * FROM C;
+CREATE TABLE AA (
+    pk INTEGER AUTO_INCREMENT,
+    col_int_nokey INTEGER,
+    col_int_key INTEGER,
+    col_date_key DATE,
+    col_date_nokey DATE,
+    col_time_key TIME,
+    col_time_nokey TIME,
+    col_datetime_key DATETIME,
+    col_datetime_nokey DATETIME,
+    col_varchar_key VARCHAR(1),
+    col_varchar_nokey VARCHAR(1),
+    PRIMARY KEY (pk),
+    KEY (col_varchar_key, col_int_key)
+) ENGINE=MyISAM;
+CREATE VIEW view_AA AS SELECT * FROM AA;
+CREATE TABLE BB (
+    pk INTEGER AUTO_INCREMENT,
+    col_int_key INTEGER,
+    col_varchar_key VARCHAR(1),
+    col_varchar_nokey VARCHAR(1),
+    PRIMARY KEY (pk),
+    KEY (col_varchar_key, col_int_key)
+) ENGINE=MyISAM;
+CREATE VIEW view_BB AS SELECT * FROM BB;
+CREATE TABLE DD (
+    pk INTEGER AUTO_INCREMENT,
+    col_int_key INTEGER,
+    col_date_key DATE,
+    col_time_key TIME,
+    col_datetime_key DATETIME,
+    col_varchar_key VARCHAR(1),
+    PRIMARY KEY (pk),
+    KEY (col_varchar_key, col_int_key)
+) ENGINE=MyISAM;
+CREATE VIEW view_DD AS SELECT * FROM DD;
+CREATE TRIGGER k BEFORE INSERT ON `DD` FOR EACH ROW INSERT INTO `view_BB` SELECT * FROM `view_A` LIMIT 0 ;
+CREATE TRIGGER r BEFORE INSERT ON `A` FOR EACH ROW INSERT INTO `view_AA` SELECT * FROM `view_C` LIMIT 0 ;
+--error ER_WRONG_AUTO_KEY
+ALTER TABLE `DD` DROP PRIMARY KEY;
+INSERT INTO `view_A` ( `pk` ) VALUES (NULL);
+--error 0,ER_WRONG_VALUE_COUNT_ON_ROW
+INSERT INTO `DD` ( `pk` ) VALUES (NULL);
+INSERT INTO `A` ( `pk` ) VALUES (NULL);
+--error 0,ER_WRONG_VALUE_COUNT_ON_ROW
+INSERT INTO `view_DD` ( `pk` ) VALUES (NULL);
+
+drop trigger r;
+drop trigger k;
+drop view view_A,view_AA,view_C,view_BB,view_DD;
+drop table A,C,AA,BB,DD;
+
+#
+# MDEV-7581
+# Server crashes in st_select_lex_unit::cleanup after a sequence of statements
+#
+
+CREATE TABLE A (
+ i INT,
+ i1 INT,
+ i2 INT,
+ d1 DATE,
+ d2 DATE,
+ col_time_nokey1 TIME,
+ col_time_nokey2 TIME,
+ col_datetime_nokey1 DATETIME,
+ col_datetime_nokey2 DATETIME,
+ col_varchar_nokey1 VARCHAR(1),
+ col_varchar_nokey2 VARCHAR(1)
+) ENGINE=MyISAM;
+
+CREATE VIEW view_A AS SELECT * FROM A;
+
+CREATE TABLE B (
+ col_varchar_nokey VARCHAR(1)
+) ENGINE=MyISAM;
+
+CREATE TABLE AA (
+ i INT,
+ i1 INT,
+ i2 INT,
+ d1 DATE,
+ d2 DATE,
+ col_time_nokey1 TIME,
+ col_time_nokey2 TIME,
+ col_datetime_nokey1 DATETIME,
+ col_datetime_nokey2 DATETIME,
+ col_varchar_nokey1 VARCHAR(1),
+ col_varchar_nokey2 VARCHAR(1)
+) ENGINE=MyISAM;
+
+CREATE VIEW view_AA AS SELECT * FROM AA;
+
+CREATE TABLE DD (
+ i INT,
+ i1 INT,
+ i2 INT,
+ d1 DATE,
+ d2 DATE,
+ col_time_nokey1 TIME,
+ col_time_nokey2 TIME,
+ col_datetime_nokey1 DATETIME,
+ col_datetime_nokey2 DATETIME,
+ col_varchar_nokey1 VARCHAR(1),
+ col_varchar_nokey2 VARCHAR(1)
+) ENGINE=MyISAM;
+
+CREATE VIEW view_DD AS SELECT * FROM DD;
+
+CREATE TRIGGER tr1 BEFORE INSERT ON `AA` FOR EACH ROW INSERT INTO `view_A` SELECT * FROM `view_AA` LIMIT 0 ; 
+CREATE TRIGGER tr2 BEFORE INSERT ON `B` FOR EACH ROW INSERT INTO `D` SELECT * FROM `A` LIMIT 0 ; 
+
+INSERT INTO `view_AA` ( `i` ) VALUES (1);
+INSERT INTO `AA` ( `i` ) VALUES (2);
+DELETE FROM `B`;
+INSERT INTO `view_DD` ( `i` ) VALUES (1);
+INSERT INTO `view_AA` ( `i` ) VALUES (3);
+
+drop trigger tr1;
+drop trigger tr2;
+drop view view_A, view_AA,view_DD;
+drop table A,B,AA,DD;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index d1c3774..67eac0d 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -53,7 +53,7 @@ SELECT 1 IN (SELECT 1);
 SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
 -- error ER_WRONG_USAGE
 select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
--- error ER_WRONG_PARAMETERS_TO_PROCEDURE
+-- error ER_PARSE_ERROR
 SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
 -- error ER_BAD_FIELD_ERROR
 SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
@@ -5890,3 +5890,77 @@ DROP TABLE t1,t2;
 create table t1 (c int);
 select exists(select 1 from t1 group by `c` in (select `c` from t1));
 drop table t1;
+
+--echo #
+--echo # MDEV-7565: Server crash with Signal 6 (part 2)
+--echo #
+Select 
+  (Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+    Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+  ) As `ControlRev`
+From 
+(Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+Group By  TestCase.Revenue, TestCase.TemplateID;
+
+--echo #
+--echo # MDEV-7445:Server crash with Signal 6
+--echo #
+
+--delimiter |
+CREATE PROCEDURE procedure2()
+BEGIN
+  Select 
+    (Select Sum(`TestCase`.Revenue) From mysql.slow_log E           
+      Where TestCase.TemplateID not in (Select 1 from mysql.slow_log where 2=2)
+     ) As `ControlRev`
+  From 
+  (Select  3 as Revenue, 4 as TemplateID) As `TestCase` 
+  Group By  TestCase.Revenue, TestCase.TemplateID;
+
+END |
+--delimiter ;
+call procedure2();
+call procedure2();
+
+drop procedure procedure2;
+
+
+SELECT
+  (SELECT user FROM mysql.user
+    WHERE h.host in (SELECT host FROM mysql.user)
+  ) AS sq
+FROM mysql.host h GROUP BY h.host;
+
+
+--echo #
+--echo # MDEV-7846:Server crashes in Item_subselect::fix
+--echo #_fields or fails with Thread stack overrun
+--echo #
+CREATE TABLE t1 (column1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (3),(9);
+
+CREATE TABLE t2 (column2 INT) ENGINE=MyISAM;
+
+INSERT INTO t2 VALUES (1),(4);
+
+CREATE TABLE t3 (column3 INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (6),(8);
+
+CREATE TABLE t4 (column4 INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (2),(5);
+
+
+PREPARE stmt FROM "
+SELECT ( 
+  SELECT MAX( table1.column1 ) AS field1 
+  FROM t1 AS table1
+  WHERE table3.column3 IN ( SELECT table2.column2 AS field2 FROM t2 AS table2 ) 
+) AS sq
+FROM t3 AS table3, t4 AS table4 GROUP BY sq
+";
+
+EXECUTE stmt;
+EXECUTE stmt;
+
+deallocate prepare stmt;
+drop table t1,t2,t3,t4;
diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test
index 912e9d5..dd30b21 100644
--- a/mysql-test/t/subselect_sj_mat.test
+++ b/mysql-test/t/subselect_sj_mat.test
@@ -1841,5 +1841,20 @@ drop database mysqltest2;
 drop database mysqltest3;
 drop database mysqltest4;
 
---echo # End of 5.5 tests
+--echo #
+--echo # MDEV-7810 Wrong result on execution of a query as a PS
+--echo # (both 1st and further executions)
+
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (0),(8);
+
+SELECT a FROM (SELECT DISTINCT * FROM t1) AS sq WHERE a IN (SELECT MIN(t2.a) FROM (t1 AS t2));
+PREPARE stmt FROM "
+SELECT a FROM (SELECT DISTINCT * FROM t1) AS sq WHERE a IN (SELECT MIN(t2.a) FROM (t1 AS t2))
+";
+execute stmt;
+execute stmt;
 
+drop table t1;
+
+--echo # End of 5.5 tests
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index daa2050..be97dd0 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -506,6 +506,21 @@ DROP VIEW v1;
 DROP FUNCTION f1;
 DROP TABLE t1;
 
+--echo # Bug #21143080: UPDATE ON VARCHAR AND TEXT COLUMNS PRODUCE INCORRECT
+--echo #                RESULTS
+
+CREATE TABLE t1 (a VARCHAR(50), b TEXT, c CHAR(50)) ENGINE=INNODB;
+
+INSERT INTO t1 (a, b, c) VALUES ('start trail', '', 'even longer string');
+UPDATE t1 SET b = a, a = 'inject';
+SELECT a, b FROM t1;
+UPDATE t1 SET b = c, c = 'inject';
+SELECT c, b FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-3948 Assertion `records_are_comparable(table)' fails in compare_record(const TABLE*) on UPDATE with simple AND condition, index_merge+index_merge_intersection, InnoDB
 --echo #
 --echo # Verify that UPDATE does the same number of handler_update
 --echo # operations, no matter if there is ORDER BY or not.
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 0432db0..fe04cdf 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -4741,6 +4741,50 @@ SHOW CREATE VIEW v4;
 
 DROP VIEW v1, v2, v3, v4, v5;
 
+
+--echo #
+--echo # BUG#19886430: VIEW CREATION WITH NAMED COLUMNS, OVER UNION,
+--echo #               IS REJECTED
+
+--echo # Without the patch, reports an error.
+CREATE VIEW v1 (fld1, fld2) AS
+  SELECT 1 AS a, 2 AS b
+    UNION ALL
+  SELECT 1 AS a, 1 AS a;
+
+--echo # The column names are explicitly specified and not duplicates, hence
+--echo # succeeds.
+CREATE VIEW v2 (fld1, fld2) AS
+  SELECT 1 AS a, 2 AS a
+    UNION ALL
+  SELECT 1 AS a, 1 AS a;
+
+--echo # The column name in the first SELECT are not duplicates, hence succeeds.
+CREATE VIEW v3 AS
+  SELECT 1 AS a, 2 AS b
+    UNION ALL
+  SELECT 1 AS a, 1 AS a;
+
+--echo # Should report an error, since the explicitly specified column names are
+--echo # duplicates.
+--error ER_DUP_FIELDNAME
+CREATE VIEW v4 (fld1, fld1) AS
+  SELECT 1 AS a, 2 AS b
+    UNION ALL
+  SELECT 1 AS a, 1 AS a;
+
+--echo # Should report an error, since duplicate column name is specified in the
+--echo # First SELECT.
+--error ER_DUP_FIELDNAME
+CREATE VIEW v4 AS
+  SELECT 1 AS a, 2 AS a
+    UNION ALL
+  SELECT 1 AS a, 1 AS a;
+
+--echo # Cleanup
+DROP VIEW v1, v2, v3;
+
+
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc
@@ -5380,6 +5424,27 @@ show create view v2;
 drop view v2;
 drop table t1;
 
+--echo #
+--echo # MDEV-8554: Server crashes in base_list_iterator::next_fast on 1st execution of PS with a multi-table update
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2); # Not necessary, the table can be empty
+
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4); # Not necessary, the table can be empty
+
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (5),(6); # Not necessary, the table can be empty
+
+CREATE OR REPLACE ALGORITHM=MERGE VIEW v3 AS SELECT * FROM t3;
+
+PREPARE stmt FROM 'UPDATE t1, t2 SET a = 1 WHERE a IN ( SELECT 0 FROM t3 )';
+UPDATE t1, t2 SET a = 1 WHERE a IN ( SELECT 0 FROM v3 );
+EXECUTE stmt;
+
+DROP TABLE t1, t2, t3;
+DROP VIEW v3;
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 5.5 tests.
 --echo # -----------------------------------------------------------------
diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c
index a481b4d..6e373e9 100644
--- a/mysys/ptr_cmp.c
+++ b/mysys/ptr_cmp.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -91,6 +91,7 @@ static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
   reg3 int length= *compare_length;
   reg1 uchar *first,*last;
 
+  DBUG_ASSERT(length > 0);
   first= *a; last= *b;
   while (--length)
   {
diff --git a/regex/regcomp.c b/regex/regcomp.c
index abc1817..b1074a1 100644
--- a/regex/regcomp.c
+++ b/regex/regcomp.c
@@ -1,3 +1,11 @@
+/* Copyright 1992, 1993, 1994 Henry Spencer.  All rights reserved.
+   See file COPYRIGHT for details.
+
+   This file was modified by Oracle on 2015-05-18 for 32-bit compatibility.
+
+   Modifications copyright (c) 2015, Oracle and/or its affiliates. All rights
+   reserved. */
+
 #include <my_global.h>
 #include <m_string.h>
 #include <m_ctype.h>
@@ -133,12 +141,26 @@ CHARSET_INFO *charset;
 	} else
 		len = strlen((char *)pattern);
 
+	/*
+	 Find the maximum len we can safely process
+	 without a rollover and a mis-malloc.
+	 p->ssize is a sopno is a long (32+ bit signed);
+	 size_t is 16+ bit unsigned.
+	*/
+	{
+	  size_t new_ssize = len / (size_t)2 * (size_t)3 + (size_t)1; /* ugh */
+	  if ((new_ssize < len) ||	/* size_t rolled over */
+	      ((SIZE_T_MAX / sizeof(sop)) < new_ssize) ||	/* malloc arg */
+	      (new_ssize > LONG_MAX))	/* won't fit in ssize */
+		return(REG_ESPACE);	/* MY_REG_ESPACE or MY_REG_INVARG */
+	  p->ssize = new_ssize;
+	}
+
 	/* do the mallocs early so failure handling is easy */
 	g = (struct re_guts *)malloc(sizeof(struct re_guts) +
 							(NC-1)*sizeof(cat_t));
 	if (g == NULL)
 		return(REG_ESPACE);
-	p->ssize = (long) (len/(size_t)2*(size_t)3 + (size_t)1); /* ugh */
 	p->strip = (sop *)malloc(p->ssize * sizeof(sop));
 	p->slen = 0;
 	if (p->strip == NULL) {
diff --git a/sql/field.cc b/sql/field.cc
index a24ffe2..aeeacf7 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7612,7 +7612,8 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
     }
 
     Field_blob::store_length(length);
-    if (table->copy_blobs || length <= MAX_FIELD_WIDTH)
+    if ((table->copy_blobs || length <= MAX_FIELD_WIDTH) &&
+        from != value.ptr())
     {						// Must make a copy
       value.copy(from, length, cs);
       from= value.ptr();
diff --git a/sql/field.h b/sql/field.h
index 130d33e..b20bedb 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1,7 +1,7 @@
 #ifndef FIELD_INCLUDED
 #define FIELD_INCLUDED
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2008, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -638,6 +638,16 @@ public:
   /* Hash value */
   virtual void hash(ulong *nr, ulong *nr2);
 
+/**
+  Checks whether a string field is part of write_set.
+
+  @return
+    FALSE  - If field is not char/varchar/....
+           - If field is char/varchar/.. and is not part of write set.
+    TRUE   - If field is char/varchar/.. and is part of write set.
+*/
+  virtual bool is_updatable() const { return FALSE; }
+
   /* Check whether the field can be used as a join attribute in hash join */
   virtual bool hash_join_is_possible() { return TRUE; }
   virtual bool eq_cmp_as_binary() { return TRUE; }
@@ -824,6 +834,11 @@ public:
 
   int store_decimal(const my_decimal *d);
   uint32 max_data_length() const;
+  bool is_updatable() const
+  {
+    DBUG_ASSERT(table && table->write_set);
+    return bitmap_is_set(table->write_set, field_index);
+  }
 };
 
 /* base class for float and double and decimal (old one) */
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index d6a53a9..d24f31e 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -1,7 +1,6 @@
 /*
-   Copyright (c) 2000, 2012, Oracle and/or its affiliates.
-   Copyright (c) 2010, 2012, Monty Program Ab
-
+   Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2010, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -863,15 +862,10 @@ int field_conv(Field *to,Field *from)
   {						// Be sure the value is stored
     Field_blob *blob=(Field_blob*) to;
     from->val_str(&blob->value);
-    /*
-      Copy value if copy_blobs is set, or source is not a string and
-      we have a pointer to its internal string conversion buffer.
-    */
-    if (to->table->copy_blobs ||
-        (!blob->value.is_alloced() &&
-         from->real_type() != MYSQL_TYPE_STRING &&
-         from->real_type() != MYSQL_TYPE_VARCHAR))
+
+    if (!blob->value.is_alloced() && from->is_updatable())
       blob->value.copy();
+
     return blob->store(blob->value.ptr(),blob->value.length(),from->charset());
   }
   if (from->real_type() == MYSQL_TYPE_ENUM &&
diff --git a/sql/item.cc b/sql/item.cc
index f8d1c85..878c960 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1146,18 +1146,24 @@ Item *Item::safe_charset_converter(CHARSET_INFO *tocs)
   because Item_singlerow_subselect later calls Item_cache-specific methods,
   e.g. row[i]->store() and row[i]->cache_value().
 
-  Let's wrap Item_func_conv_charset to a new Item_cache,
+  Let's wrap Item_func_conv_charset in a new Item_cache,
   so the Item_cache-specific methods can still be used for
   Item_singlerow_subselect::row[i] safely.
 
+  As a bonus we cache the converted value, instead of converting every time
+
   TODO: we should eventually check all other use cases of change_item_tree().
   Perhaps some more potentially dangerous substitution examples exist.
 */
 Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs)
 {
-  Item_func_conv_charset *conv= new Item_func_conv_charset(example, tocs, 1);
+  if (!example)
+    return Item::safe_charset_converter(tocs);
+  Item *conv= example->safe_charset_converter(tocs);
+  if (conv == example)
+    return this;
   Item_cache *cache;
-  if (!conv || !conv->safe || !(cache= new Item_cache_str(conv)))
+  if (!conv || !(cache= new Item_cache_str(conv)))
     return NULL; // Safe conversion is not possible, or OEM
   cache->setup(conv);
   cache->fixed= false; // Make Item::fix_fields() happy
@@ -4409,18 +4415,23 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
                               Item_ident *resolved_item,
                               Item_ident *mark_item)
 {
-  const char *db_name= (resolved_item->db_name ?
-                        resolved_item->db_name : "");
-  const char *table_name= (resolved_item->table_name ?
-                           resolved_item->table_name : "");
+  DBUG_ENTER("mark_as_dependent");
+
   /* store pointer on SELECT_LEX from which item is dependent */
   if (mark_item && mark_item->can_be_depended)
+  {
+    DBUG_PRINT("info", ("mark_item: %p  lex: %p", mark_item, last));
     mark_item->depended_from= last;
-  if (current->mark_as_dependent(thd, last, /** resolved_item psergey-thu
-    **/mark_item))
-    return TRUE;
+  }
+  if (current->mark_as_dependent(thd, last,
+                                 /** resolved_item psergey-thu **/ mark_item))
+    DBUG_RETURN(TRUE);
   if (thd->lex->describe & DESCRIBE_EXTENDED)
   {
+    const char *db_name= (resolved_item->db_name ?
+                          resolved_item->db_name : "");
+    const char *table_name= (resolved_item->table_name ?
+                             resolved_item->table_name : "");
     push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
 		 ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED),
                  db_name, (db_name[0] ? "." : ""),
@@ -4428,7 +4439,7 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
                  resolved_item->field_name,
                  current->select_number, last->select_number);
   }
-  return FALSE;
+  DBUG_RETURN(FALSE);
 }
 
 
@@ -4877,7 +4888,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
             non aggregated fields of the outer select.
           */
           marker= select->cur_pos_in_select_list;
-          select->non_agg_fields.push_back(this);
+          select->join->non_agg_fields.push_back(this);
         }
         if (*from_field != view_ref_found)
         {
@@ -5293,9 +5304,10 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
   fixed= 1;
   if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
       !outer_fixed && !thd->lex->in_sum_func &&
-      thd->lex->current_select->cur_pos_in_select_list != UNDEF_POS)
+      thd->lex->current_select->cur_pos_in_select_list != UNDEF_POS &&
+      thd->lex->current_select->join)
   {
-    thd->lex->current_select->non_agg_fields.push_back(this);
+    thd->lex->current_select->join->non_agg_fields.push_back(this);
     marker= thd->lex->current_select->cur_pos_in_select_list;
   }
 mark_non_agg_field:
@@ -6742,7 +6754,7 @@ Item_ref::Item_ref(Name_resolution_context *context_arg,
   /*
     This constructor used to create some internals references over fixed items
   */
-  if (ref && *ref && (*ref)->fixed)
+  if ((set_properties_only= (ref && *ref && (*ref)->fixed)))
     set_properties();
 }
 
@@ -6786,7 +6798,7 @@ Item_ref::Item_ref(TABLE_LIST *view_arg, Item **item,
   /*
     This constructor is used to create some internal references over fixed items
   */
-  if (ref && *ref && (*ref)->fixed)
+  if ((set_properties_only= (ref && *ref && (*ref)->fixed)))
     set_properties();
 }
 
@@ -6861,7 +6873,11 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
   DBUG_ASSERT(fixed == 0);
   SELECT_LEX *current_sel= thd->lex->current_select;
 
-  if (!ref || ref == not_found_item)
+  if (set_properties_only)
+  {
+    /* do nothing */
+  }
+  else if (!ref || ref == not_found_item)
   {
     DBUG_ASSERT(reference_trough_name != 0);
     if (!(ref= resolve_ref_in_select_and_group(thd, this,
@@ -6879,7 +6895,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
       {
         /* The current reference cannot be resolved in this query. */
         my_error(ER_BAD_FIELD_ERROR,MYF(0),
-                 this->full_name(), current_thd->where);
+                 this->full_name(), thd->where);
         goto error;
       }
 
@@ -7014,7 +7030,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
           goto error;
         thd->change_item_tree(reference, fld);
         mark_as_dependent(thd, last_checked_context->select_lex,
-                          thd->lex->current_select, fld, fld);
+                          current_sel, fld, fld);
         /*
           A reference is resolved to a nest level that's outer or the same as
           the nest level of the enclosing set function : adjust the value of
@@ -7031,7 +7047,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
       {
         /* The item was not a table field and not a reference */
         my_error(ER_BAD_FIELD_ERROR, MYF(0),
-                 this->full_name(), current_thd->where);
+                 this->full_name(), thd->where);
         goto error;
       }
       /* Should be checked in resolve_ref_in_select_and_group(). */
diff --git a/sql/item.h b/sql/item.h
index 4aaa67d..f8e8ead 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -631,7 +631,7 @@ public:
   */
   uint name_length;                     /* Length of name */
   uint decimals;
-  int8 marker;
+  int  marker;
   bool maybe_null;			/* If item may be null */
   bool in_rollup;                       /* If used in GROUP BY list
                                            of a query with ROLLUP */ 
@@ -2946,6 +2946,7 @@ class Item_ref :public Item_ident
 {
 protected:
   void set_properties();
+  bool set_properties_only; // the item doesn't need full fix_fields
 public:
   enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF, AGGREGATE_REF };
   Field *result_field;			 /* Save result here */
@@ -2955,7 +2956,7 @@ public:
            const char *db_arg, const char *table_name_arg,
            const char *field_name_arg)
     :Item_ident(context_arg, db_arg, table_name_arg, field_name_arg),
-    result_field(0), ref(0), reference_trough_name(1) {}
+    set_properties_only(0), result_field(0), ref(0), reference_trough_name(1) {}
   /*
     This constructor is used in two scenarios:
     A) *item = NULL
@@ -2978,7 +2979,7 @@ public:
 
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_ref(THD *thd, Item_ref *item)
-    :Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
+    :Item_ident(thd, item), set_properties_only(0), result_field(item->result_field), ref(item->ref) {}
   enum Type type() const		{ return REF_ITEM; }
   enum Type real_type() const           { return ref ? (*ref)->type() :
                                           REF_ITEM; }
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 998cb1c..0c48592 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1442,9 +1442,36 @@ bool Item_in_optimizer::eval_not_null_tables(uchar *opt_arg)
 bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
 {
   DBUG_ENTER("Item_in_optimizer::fix_left");
-  if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) ||
-      (!cache && !(cache= Item_cache::get_cache(args[0]))))
+  /*
+    Here we will store pointer on place of main storage of left expression.
+    For usual IN (ALL/ANY) it is subquery left_expr.
+    For other cases (MAX/MIN optimization, non-transformed EXISTS (10.0))
+    it is args[0].
+  */
+  Item **ref0= args;
+  if (args[1]->type() == Item::SUBSELECT_ITEM &&
+      ((Item_subselect *)args[1])->is_in_predicate())
+  {
+    /*
+       left_expr->fix_fields() may cause left_expr to be substituted for
+       another item. (e.g. an Item_field may be changed into Item_ref). This
+       transformation is undone at the end of statement execution (e.g. the
+       Item_ref is deleted). However, Item_in_optimizer::args[0] may keep
+       the pointer to the post-transformation item. Because of that, on the
+       next execution we need to copy args[1]->left_expr again.
+    */
+    ref0= &(((Item_in_subselect *)args[1])->left_expr);
+    args[0]= ((Item_in_subselect *)args[1])->left_expr;
+  }
+  if ((!(*ref0)->fixed && (*ref0)->fix_fields(thd, ref0)) ||
+      (!cache && !(cache= Item_cache::get_cache(*ref0))))
     DBUG_RETURN(1);
+  /*
+    During fix_field() expression could be substituted.
+    So we copy changes before use
+  */
+  if (args[0] != (*ref0))
+    args[0]= (*ref0);
   DBUG_PRINT("info", ("actual fix fields"));
 
   cache->setup(args[0]);
@@ -1500,6 +1527,16 @@ bool Item_in_optimizer::fix_left(THD *thd, Item **ref)
 bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
 {
   DBUG_ASSERT(fixed == 0);
+  Item_subselect *sub= 0;
+  uint col;
+
+  /*
+     MAX/MIN optimization can convert the subquery into
+     expr + Item_singlerow_subselect
+   */
+  if (args[1]->type() == Item::SUBSELECT_ITEM)
+    sub= (Item_subselect *)args[1];
+
   if (fix_left(thd, ref))
     return TRUE;
   if (args[0]->maybe_null)
@@ -1507,10 +1544,10 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref)
 
   if (!args[1]->fixed && args[1]->fix_fields(thd, args+1))
     return TRUE;
-  Item_in_subselect * sub= (Item_in_subselect *)args[1];
-  if (args[0]->cols() != sub->engine->cols())
+  if ((sub && ((col= args[0]->cols()) != sub->engine->cols())) ||
+      (!sub && (args[1]->cols() != (col= 1))))
   {
-    my_error(ER_OPERAND_COLUMNS, MYF(0), args[0]->cols());
+    my_error(ER_OPERAND_COLUMNS, MYF(0), col);
     return TRUE;
   }
   if (args[1]->maybe_null)
@@ -2692,7 +2729,8 @@ Item_func_if::str_op(String *str)
   String *res=arg->val_str(str);
   if (res)
     res->set_charset(collation.collation);
-  null_value=arg->null_value;
+  if ((null_value=arg->null_value))
+    res= NULL;
   return res;
 }
 
@@ -2703,7 +2741,8 @@ Item_func_if::decimal_op(my_decimal *decimal_value)
   DBUG_ASSERT(fixed == 1);
   Item *arg= args[0]->val_bool() ? args[1] : args[2];
   my_decimal *value= arg->val_decimal(decimal_value);
-  null_value= arg->null_value;
+  if ((null_value= arg->null_value))
+    value= NULL;
   return value;
 }
 
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ed08555..eb5b63f 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -887,7 +887,7 @@ String *Item_func_hybrid_result_type::val_str(String *str)
   case DECIMAL_RESULT:
   {
     my_decimal decimal_value, *val;
-    if (!(val= decimal_op(&decimal_value)))
+    if (!(val= decimal_op_with_null_check(&decimal_value)))
       return 0;                                 // null is set
     my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, FALSE, val);
     str->set_charset(collation.collation);
@@ -914,24 +914,22 @@ String *Item_func_hybrid_result_type::val_str(String *str)
     if (is_temporal_type(field_type()))
     {
       MYSQL_TIME ltime;
-      if (date_op(&ltime,
-                  field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0) ||
-          str->alloc(MAX_DATE_STRING_REP_LENGTH))
-      {
-        null_value= 1;
+      if (date_op_with_null_check(&ltime) ||
+          (null_value= str->alloc(MAX_DATE_STRING_REP_LENGTH)))
         return (String *) 0;
-      }
       ltime.time_type= mysql_type_to_time_type(field_type());
       str->length(my_TIME_to_str(&ltime, const_cast<char*>(str->ptr()), decimals));
       str->set_charset(&my_charset_bin);
+      DBUG_ASSERT(!null_value);
       return str;
     }
-    return str_op(&str_value);
+    return str_op_with_null_check(&str_value);
   case TIME_RESULT:
   case ROW_RESULT:
   case IMPOSSIBLE_RESULT:
     DBUG_ASSERT(0);
   }
+  DBUG_ASSERT(!null_value || (str == NULL));
   return str;
 }
 
@@ -944,7 +942,7 @@ double Item_func_hybrid_result_type::val_real()
   {
     my_decimal decimal_value, *val;
     double result;
-    if (!(val= decimal_op(&decimal_value)))
+    if (!(val= decimal_op_with_null_check(&decimal_value)))
       return 0.0;                               // null is set
     my_decimal2double(E_DEC_FATAL_ERROR, val, &result);
     return result;
@@ -961,18 +959,14 @@ double Item_func_hybrid_result_type::val_real()
     if (is_temporal_type(field_type()))
     {
       MYSQL_TIME ltime;
-      if (date_op(&ltime,
-                  field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
-      {
-        null_value= 1;
+      if (date_op_with_null_check(&ltime))
         return 0;
-      }
       ltime.time_type= mysql_type_to_time_type(field_type());
       return TIME_to_double(&ltime);
     }
     char *end_not_used;
     int err_not_used;
-    String *res= str_op(&str_value);
+    String *res= str_op_with_null_check(&str_value);
     return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
 			     &end_not_used, &err_not_used) : 0.0);
   }
@@ -992,7 +986,7 @@ longlong Item_func_hybrid_result_type::val_int()
   case DECIMAL_RESULT:
   {
     my_decimal decimal_value, *val;
-    if (!(val= decimal_op(&decimal_value)))
+    if (!(val= decimal_op_with_null_check(&decimal_value)))
       return 0;                                 // null is set
     longlong result;
     my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result);
@@ -1007,18 +1001,14 @@ longlong Item_func_hybrid_result_type::val_int()
     if (is_temporal_type(field_type()))
     {
       MYSQL_TIME ltime;
-      if (date_op(&ltime,
-                  field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0))
-      {
-        null_value= 1;
+      if (date_op_with_null_check(&ltime))
         return 0;
-      }
       ltime.time_type= mysql_type_to_time_type(field_type());
       return TIME_to_ulonglong(&ltime);
     }
     int err_not_used;
     String *res;
-    if (!(res= str_op(&str_value)))
+    if (!(res= str_op_with_null_check(&str_value)))
       return 0;
 
     char *end= (char*) res->ptr() + res->length();
@@ -1040,17 +1030,21 @@ my_decimal *Item_func_hybrid_result_type::val_decimal(my_decimal *decimal_value)
   DBUG_ASSERT(fixed == 1);
   switch (cached_result_type) {
   case DECIMAL_RESULT:
-    val= decimal_op(decimal_value);
+    val= decimal_op_with_null_check(decimal_value);
     break;
   case INT_RESULT:
   {
     longlong result= int_op();
+    if (null_value)
+      return NULL;
     int2my_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value);
     break;
   }
   case REAL_RESULT:
   {
     double result= (double)real_op();
+    if (null_value)
+      return NULL;
     double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
     break;
   }
@@ -1059,19 +1053,20 @@ my_decimal *Item_func_hybrid_result_type::val_decimal(my_decimal *decimal_value)
     if (is_temporal_type(field_type()))
     {
       MYSQL_TIME ltime;
-      if (date_op(&ltime,
-                  field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0))
+      if (date_op_with_null_check(&ltime))
       {
         my_decimal_set_zero(decimal_value);
-        null_value= 1;
         return 0;
       }
       ltime.time_type= mysql_type_to_time_type(field_type());
       return date2my_decimal(&ltime, decimal_value);
     }
     String *res;
-    if (!(res= str_op(&str_value)))
+    if (!(res= str_op_with_null_check(&str_value)))
+    {
+      null_value= 1;
       return NULL;
+    }
 
     str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
                    res->length(), res->charset(), decimal_value);
@@ -1094,7 +1089,7 @@ bool Item_func_hybrid_result_type::get_date(MYSQL_TIME *ltime,
   case DECIMAL_RESULT:
   {
     my_decimal value, *res;
-    if (!(res= decimal_op(&value)) ||
+    if (!(res= decimal_op_with_null_check(&value)) ||
         decimal_to_datetime_with_warn(res, ltime, fuzzydate,
                                       field_name_or_null()))
       goto err;
@@ -1124,7 +1119,7 @@ bool Item_func_hybrid_result_type::get_date(MYSQL_TIME *ltime,
       return date_op(ltime, fuzzydate);
     char buff[40];
     String tmp(buff,sizeof(buff), &my_charset_bin),*res;
-    if (!(res= str_op(&tmp)) ||
+    if (!(res= str_op_with_null_check(&tmp)) ||
         str_to_datetime_with_warn(res->charset(), res->ptr(), res->length(),
                                   ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
       goto err;
@@ -4184,7 +4179,25 @@ longlong Item_func_get_lock::val_int()
     it's not guaranteed to be same as on master.
   */
   if (thd->slave_thread)
+  {
+    null_value= 0;
     DBUG_RETURN(1);
+  }
+
+  if (args[1]->null_value ||
+      (!args[1]->unsigned_flag && ((longlong) timeout < 0)))
+  {
+    char buf[22];
+    if (args[1]->null_value)
+      strmov(buf, "NULL");
+    else
+      llstr(((longlong) timeout), buf);
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+                        "timeout", buf, "get_lock");
+    null_value= 1;
+    DBUG_RETURN(0);
+  }
 
   mysql_mutex_lock(&LOCK_user_locks);
 
diff --git a/sql/item_func.h b/sql/item_func.h
index 4b11238..33fa49f 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -377,17 +377,17 @@ public:
 
   void no_rows_in_result()
   {
-    bool_func_call_args info;
-    info.original_func_item= this;
-    info.bool_function= &Item::no_rows_in_result;
-    walk(&Item::call_bool_func_processor, FALSE, (uchar*) &info);
+    for (uint i= 0; i < arg_count; i++)
+    {
+      args[i]->no_rows_in_result();
+    }
   }
   void restore_to_before_no_rows_in_result()
   {
-    bool_func_call_args info;
-    info.original_func_item= this;
-    info.bool_function= &Item::restore_to_before_no_rows_in_result;
-    walk(&Item::call_bool_func_processor, FALSE, (uchar*) &info);
+    for (uint i= 0; i < arg_count; i++)
+    {
+      args[i]->no_rows_in_result();
+    }
   }
 };
 
@@ -411,6 +411,29 @@ public:
 
 class Item_func_hybrid_result_type: public Item_func
 {
+  /*
+    Helper methods to make sure that the result of
+    decimal_op(), str_op() and date_op() is properly synched with null_value.
+  */
+  bool date_op_with_null_check(MYSQL_TIME *ltime)
+  {
+     bool rc= date_op(ltime,
+                      field_type() == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0);
+     DBUG_ASSERT(!rc ^ null_value);
+     return rc;
+  }
+  String *str_op_with_null_check(String *str)
+  {
+    String *res= str_op(str);
+    DBUG_ASSERT((res != NULL) ^ null_value);
+    return res;
+  }
+  my_decimal *decimal_op_with_null_check(my_decimal *decimal_buffer)
+  {
+    my_decimal *res= decimal_op(decimal_buffer);
+    DBUG_ASSERT((res != NULL) ^ null_value);
+    return res;
+  }
 protected:
   Item_result cached_result_type;
 
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 62df666..1107945 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -464,6 +464,7 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
 {
   List_iterator<Ref_to_outside> it(upper_refs);
   Ref_to_outside *upper;
+  DBUG_ENTER("recalc_used_tables");
   
   used_tables_cache= 0;
   while ((upper= it++))
@@ -523,6 +524,8 @@ void Item_subselect::recalc_used_tables(st_select_lex *new_parent,
     he has done const table detection, and that will be our chance to update
     const_tables_cache.
   */
+  DBUG_PRINT("exit", ("used_tables_cache: %llx", used_tables_cache));
+  DBUG_VOID_RETURN;
 }
 
 
@@ -1360,7 +1363,7 @@ Item_in_subselect::Item_in_subselect(Item * left_exp,
   upper_item(0)
 {
   DBUG_ENTER("Item_in_subselect::Item_in_subselect");
-  left_expr= left_exp;
+  left_expr_orig= left_expr= left_exp;
   func= &eq_creator;
   init(select_lex, new select_exists_subselect(this));
   max_columns= UINT_MAX;
@@ -1384,7 +1387,7 @@ Item_allany_subselect::Item_allany_subselect(Item * left_exp,
   :Item_in_subselect(), func_creator(fc), all(all_arg)
 {
   DBUG_ENTER("Item_allany_subselect::Item_allany_subselect");
-  left_expr= left_exp;
+  left_expr_orig= left_expr= left_exp;
   func= func_creator(all_arg);
   init(select_lex, new select_exists_subselect(this));
   max_columns= 1;
@@ -1989,7 +1992,7 @@ bool Item_allany_subselect::is_maxmin_applicable(JOIN *join)
 */
 
 bool
-Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
+Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
                                                    Item **where_item,
                                                    Item **having_item)
 {
@@ -1999,7 +2002,6 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join,
     during JOIN::optimize: this->tmp_having= this->having; this->having= 0;
   */
   Item* join_having= join->having ? join->having : join->tmp_having;
-
   DBUG_ENTER("Item_in_subselect::create_single_in_to_exists_cond");
 
   *where_item= NULL;
@@ -2584,15 +2586,13 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
   arena= thd->activate_stmt_arena_if_needed(&backup);
   if (!optimizer)
   {
-    result= (!(optimizer= new Item_in_optimizer(left_expr, this)));
+    result= (!(optimizer= new Item_in_optimizer(left_expr_orig, this)));
     if (result)
       goto out;
   }
 
   thd->lex->current_select= current->return_after_parsing();
   result= optimizer->fix_left(thd, optimizer->arguments());
-  /* fix_fields can change reference to left_expr, we need reassign it */
-  left_expr= optimizer->arguments()[0];
   thd->lex->current_select= current;
 
   if (changed)
@@ -2651,10 +2651,12 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
 {
   uint outer_cols_num;
   List<Item> *inner_cols;
+  char const *save_where= thd->where;
 
   if (test_strategy(SUBS_SEMI_JOIN))
     return !( (*ref)= new Item_int(1));
 
+  thd->where= "IN/ALL/ANY subquery";
   /*
     Check if the outer and inner IN operands match in those cases when we
     will not perform IN=>EXISTS transformation. Currently this is when we
@@ -2685,7 +2687,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
     if (outer_cols_num != inner_cols->elements)
     {
       my_error(ER_OPERAND_COLUMNS, MYF(0), outer_cols_num);
-      return TRUE;
+      goto err;
     }
     if (outer_cols_num > 1)
     {
@@ -2695,20 +2697,24 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
       {
         inner_col= inner_col_it++;
         if (inner_col->check_cols(left_expr->element_index(i)->cols()))
-          return TRUE;
+          goto err;
       }
     }
   }
 
-  if (thd_arg->lex->is_view_context_analysis() &&
-      left_expr && !left_expr->fixed &&
+  if (left_expr && !left_expr->fixed &&
       left_expr->fix_fields(thd_arg, &left_expr))
-    return TRUE;
+    goto err;
   else
-  if (Item_subselect::fix_fields(thd_arg, ref))
-    return TRUE;
+    if (Item_subselect::fix_fields(thd_arg, ref))
+      goto err;
   fixed= TRUE;
+  thd->where= save_where;
   return FALSE;
+
+err:
+  thd->where= save_where;
+  return TRUE;
 }
 
 
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 592e771..0ee5f73 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -449,6 +449,12 @@ protected:
                                     Item **having_item);
 public:
   Item *left_expr;
+  /*
+    Important for PS/SP: left_expr_orig is the item that left_expr originally
+    pointed at. That item is allocated on the statement arena, while
+    left_expr could later be changed to something on the execution arena.
+  */
+  Item *left_expr_orig;
   /* Priority of this predicate in the convert-to-semi-join-nest process. */
   int sj_convert_priority;
   /*
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index d8970ca..adf48f6 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3514,9 +3514,17 @@ bool Item_func_group_concat::setup(THD *thd)
     "all_fields". The resulting field list is used as input to create
     tmp table columns.
   */
-  if (arg_count_order &&
-      setup_order(thd, args, context->table_list, list, all_fields, *order))
-    DBUG_RETURN(TRUE);
+  if (arg_count_order)
+  {
+    uint n_elems= arg_count_order + all_fields.elements;
+    ref_pointer_array= static_cast<Item**>(thd->alloc(sizeof(Item*) * n_elems));
+    if (!ref_pointer_array)
+      DBUG_RETURN(TRUE);
+    memcpy(ref_pointer_array, args, arg_count * sizeof(Item*));
+    if (setup_order(thd, ref_pointer_array, context->table_list, list,
+                    all_fields, *order))
+      DBUG_RETURN(TRUE);
+  }
 
   count_field_types(select_lex, tmp_table_param, all_fields, 0);
   tmp_table_param->force_copy_fields= force_copy_fields;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index f074cc6..86093f5 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -1394,6 +1394,7 @@ class Item_func_group_concat : public Item_sum
   String *separator;
   TREE tree_base;
   TREE *tree;
+  Item **ref_pointer_array;
 
   /**
      If DISTINCT is used with this GROUP_CONCAT, this member is used to filter
diff --git a/sql/log.cc b/sql/log.cc
index 9722f20..0940cb9 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -3676,6 +3676,7 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
 {
   int error;
   char *to_purge_if_included= NULL;
+  ulonglong log_space_reclaimed= 0;
   DBUG_ENTER("purge_first_log");
 
   DBUG_ASSERT(is_open());
@@ -3724,17 +3725,13 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
 
   DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_SUICIDE(););
 
-  mysql_mutex_lock(&rli->log_space_lock);
   rli->relay_log.purge_logs(to_purge_if_included, included,
-                            0, 0, &rli->log_space_total);
-  mysql_mutex_unlock(&rli->log_space_lock);
+                            0, 0, &log_space_reclaimed);
 
-  /*
-    Ok to broadcast after the critical region as there is no risk of
-    the mutex being destroyed by this thread later - this helps save
-    context switches
-  */
+  mysql_mutex_lock(&rli->log_space_lock);
+  rli->log_space_total-= log_space_reclaimed;
   mysql_cond_broadcast(&rli->log_space_cond);
+  mysql_mutex_unlock(&rli->log_space_lock);
 
   /*
    * Need to update the log pos because purge logs has been called 
@@ -3783,8 +3780,8 @@ int MYSQL_BIN_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads
   @param need_mutex
   @param need_update_threads If we want to update the log coordinates of
                              all threads. False for relay logs, true otherwise.
-  @param freed_log_space     If not null, decrement this variable of
-                             the amount of log space freed
+  @param reclaimeed_log_space If not null, increment this variable to
+                              the amount of log space freed
 
   @note
     If any of the logs before the deleted one is in use,
@@ -3800,10 +3797,10 @@ int MYSQL_BIN_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads
 */
 
 int MYSQL_BIN_LOG::purge_logs(const char *to_log, 
-                          bool included,
-                          bool need_mutex, 
-                          bool need_update_threads, 
-                          ulonglong *decrease_log_space)
+                              bool included,
+                              bool need_mutex, 
+                              bool need_update_threads, 
+                              ulonglong *reclaimed_space)
 {
   int error= 0;
   bool exit_loop= 0;
@@ -3868,7 +3865,7 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
 err:
   /* Read each entry from purge_index_file and delete the file. */
   if (is_inited_purge_index_file() &&
-      (error= purge_index_entry(thd, decrease_log_space, FALSE)))
+      (error= purge_index_entry(thd, reclaimed_space, FALSE)))
     sql_print_error("MSYQL_BIN_LOG::purge_logs failed to process registered files"
                     " that would be purged.");
   close_purge_index_file();
@@ -3973,7 +3970,7 @@ int MYSQL_BIN_LOG::register_create_index_entry(const char *entry)
   DBUG_RETURN(register_purge_index_entry(entry));
 }
 
-int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *decrease_log_space,
+int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *reclaimed_space,
                                      bool need_mutex)
 {
   DBUG_ENTER("MYSQL_BIN_LOG:purge_index_entry");
@@ -4093,8 +4090,8 @@ int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *decrease_log_space,
         DBUG_PRINT("info",("purging %s",log_info.log_file_name));
         if (!my_delete(log_info.log_file_name, MYF(0)))
         {
-          if (decrease_log_space)
-            *decrease_log_space-= s.st_size;
+          if (reclaimed_space)
+            *reclaimed_space+= s.st_size;
         }
         else
         {
diff --git a/sql/log_event.cc b/sql/log_event.cc
index e63884e..c962f19 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1249,9 +1249,10 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
   }
   data_len= uint4korr(buf + EVENT_LEN_OFFSET);
   if (data_len < LOG_EVENT_MINIMAL_HEADER_LEN ||
-      data_len > current_thd->variables.max_allowed_packet)
+      data_len > max(current_thd->variables.max_allowed_packet,
+                     opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
   {
-    DBUG_PRINT("error",("data_len: %ld", data_len));
+    DBUG_PRINT("error",("data_len: %lu", data_len));
     result= ((data_len < LOG_EVENT_MINIMAL_HEADER_LEN) ? LOG_READ_BOGUS :
 	     LOG_READ_TOO_LARGE);
     goto end;
@@ -1372,7 +1373,7 @@ failed my_b_read"));
     */
     DBUG_RETURN(0);
   }
-  uint data_len = uint4korr(head + EVENT_LEN_OFFSET);
+  ulong data_len = uint4korr(head + EVENT_LEN_OFFSET);
   char *buf= 0;
   const char *error= 0;
   Log_event *res=  0;
@@ -1381,7 +1382,8 @@ failed my_b_read"));
   uint max_allowed_packet= thd ? slave_max_allowed_packet:~(uint)0;
 #endif
 
-  if (data_len > max_allowed_packet)
+  if (data_len > max(max_allowed_packet,
+                     opt_binlog_rows_event_max_size + MAX_LOG_EVENT_HEADER))
   {
     error = "Event too big";
     goto err;
@@ -1415,7 +1417,7 @@ err:
   {
     DBUG_ASSERT(error != 0);
     sql_print_error("Error in Log_event::read_log_event(): "
-                    "'%s', data_len: %d, event_type: %d",
+                    "'%s', data_len: %lu, event_type: %d",
 		    error,data_len,head[EVENT_TYPE_OFFSET]);
     my_free(buf);
     /*
@@ -2010,15 +2012,10 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr,
       my_decimal dec;
       binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) ptr, &dec,
                         precision, decimals);
-      int i, end;
-      char buff[512], *pos;
-      pos= buff;
-      pos+= sprintf(buff, "%s", dec.sign() ? "-" : "");
-      end= ROUND_UP(dec.frac) + ROUND_UP(dec.intg)-1;
-      for (i=0; i < end; i++)
-        pos+= sprintf(pos, "%09d.", dec.buf[i]);
-      pos+= sprintf(pos, "%09d", dec.buf[i]);
-      my_b_printf(file, "%s", buff);
+      int length= DECIMAL_MAX_STR_LENGTH;
+      char buff[DECIMAL_MAX_STR_LENGTH + 1];
+      decimal2string(&dec, buff, &length, 0, 0, 0);
+      my_b_write(file, (uchar*)buff, length);
       my_snprintf(typestr, typestr_length, "DECIMAL(%d,%d)",
                   precision, decimals);
       return bin_size;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 0178f92..3ad7b84 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2488,7 +2488,6 @@ void unlink_thd(THD *thd)
   thd->add_status_to_global();
 
   mysql_mutex_lock(&LOCK_thread_count);
-  thread_count--;
   thd->unlink();
   /*
     Used by binlog_reset_master.  It would be cleaner to use
@@ -2496,6 +2495,16 @@ void unlink_thd(THD *thd)
     sync feature has been shut down at this point.
   */
   DBUG_EXECUTE_IF("sleep_after_lock_thread_count_before_delete_thd", sleep(5););
+  if (unlikely(abort_loop))
+  {
+    /*
+      During shutdown, we have to delete thd inside the mutex
+      to not refer to mutexes that may be deleted during shutdown
+    */
+    delete thd;
+    thd= 0;
+  }
+  thread_count--;
   mysql_mutex_unlock(&LOCK_thread_count);
 
   delete thd;
@@ -3875,13 +3884,24 @@ static int init_common_variables()
   {
     if (lower_case_table_names_used)
     {
+#if MYSQL_VERSION_ID < 100100
       if (global_system_variables.log_warnings)
-	sql_print_warning("\
-You have forced lower_case_table_names to 0 through a command-line \
-option, even though your file system '%s' is case insensitive.  This means \
-that you can corrupt a MyISAM table by accessing it with different cases. \
-You should consider changing lower_case_table_names to 1 or 2",
-			mysql_real_data_home);
+        sql_print_warning("You have forced lower_case_table_names to 0 through "
+                          "a command-line option, even though your file system "
+                          "'%s' is case insensitive.  This means that you can "
+                          "corrupt your tables if you access them using names "
+                          "with different letter case. You should consider "
+                          "changing lower_case_table_names to 1 or 2",
+                          mysql_real_data_home);
+#else
+      sql_print_error("The server option 'lower_case_table_names' is "
+                      "configured to use case sensitive table names but the "
+                      "data directory resides on a case-insensitive file system. "
+                      "Please use a case sensitive file system for your data "
+                      "directory or switch to a case-insensitive table name "
+                      "mode.");
+#endif
+      return 1;
     }
     else
     {
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 17b24aa..f4ac47f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
-   Copyright (c) 2008, 2014, Monty Program Ab.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -4081,10 +4081,19 @@ int find_used_partitions(PART_PRUNE_PARAM *ppar, SEL_ARG *key_tree)
                                          key_tree->min_flag |
                                            key_tree->max_flag,
                                          &subpart_iter);
-      DBUG_ASSERT(res); /* We can't get "no satisfying subpartitions" */
+      if (res == 0)
+      {
+        /*
+           The only case where we can get "no satisfying subpartitions"
+           returned from the above call is when an error has occurred.
+        */
+        DBUG_ASSERT(range_par->thd->is_error());
+        return 0;
+      }
+
       if (res == -1)
         goto pop_and_go_right; /* all subpartitions satisfy */
-        
+
       uint32 subpart_id;
       bitmap_clear_all(&ppar->subparts_bitmap);
       while ((subpart_id= subpart_iter.get_next(&subpart_iter)) !=
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index ebf640c..827290f 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -620,6 +620,18 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
         thd->stmt_arena->state != Query_arena::PREPARED)
       */
     {
+      SELECT_LEX *current= thd->lex->current_select;
+      thd->lex->current_select= current->return_after_parsing();
+      char const *save_where= thd->where;
+      thd->where= "IN/ALL/ANY subquery";
+
+      bool failure= !in_subs->left_expr->fixed &&
+                     in_subs->left_expr->fix_fields(thd, &in_subs->left_expr);
+      thd->lex->current_select= current;
+      thd->where= save_where;
+      if (failure)
+        DBUG_RETURN(-1); /* purecov: deadcode */
+
       /*
         Check if the left and right expressions have the same # of
         columns, i.e. we don't have a case like 
@@ -633,18 +645,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
         my_error(ER_OPERAND_COLUMNS, MYF(0), in_subs->left_expr->cols());
         DBUG_RETURN(-1);
       }
-
-      SELECT_LEX *current= thd->lex->current_select;
-      thd->lex->current_select= current->return_after_parsing();
-      char const *save_where= thd->where;
-      thd->where= "IN/ALL/ANY subquery";
-        
-      bool failure= !in_subs->left_expr->fixed &&
-                     in_subs->left_expr->fix_fields(thd, &in_subs->left_expr);
-      thd->lex->current_select= current;
-      thd->where= save_where;
-      if (failure)
-        DBUG_RETURN(-1); /* purecov: deadcode */
     }
 
     DBUG_PRINT("info", ("Checking if subq can be converted to semi-join"));
@@ -703,6 +703,12 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
       if (!optimizer_flag(thd, OPTIMIZER_SWITCH_IN_TO_EXISTS) &&
           !optimizer_flag(thd, OPTIMIZER_SWITCH_MATERIALIZATION))
         my_error(ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES, MYF(0));
+      /*
+        Transform each subquery predicate according to its overloaded
+        transformer.
+      */
+      if (subselect->select_transformer(join))
+        DBUG_RETURN(-1);
 
       /*
         If the subquery predicate is IN/=ANY, analyse and set all possible
@@ -754,12 +760,6 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
         allany_subs->add_strategy(strategy);
       }
 
-      /*
-        Transform each subquery predicate according to its overloaded
-        transformer.
-      */
-      if (subselect->select_transformer(join))
-        DBUG_RETURN(-1);
     }
   }
   DBUG_RETURN(0);
@@ -1592,8 +1592,19 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
   if (subq_pred->left_expr->cols() == 1)
   {
     nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr);
+    /*
+      Create Item_func_eq. Note that
+      1. this is done on the statement, not execution, arena
+      2. if it's a PS then this happens only once - on the first execution.
+         On following re-executions, the item will be fix_field-ed normally.
+      3. Thus it should be created as if it was fix_field'ed, in particular
+         all pointers to items in the execution arena should be protected
+         with thd->change_item_tree
+    */
     Item_func_eq *item_eq=
-      new Item_func_eq(subq_pred->left_expr, subq_lex->ref_pointer_array[0]);
+      new Item_func_eq(subq_pred->left_expr_orig, subq_lex->ref_pointer_array[0]);
+    if (subq_pred->left_expr_orig != subq_pred->left_expr)
+      thd->change_item_tree(item_eq->arguments(), subq_pred->left_expr);
     item_eq->in_equality_no= 0;
     sj_nest->sj_on_expr= and_items(sj_nest->sj_on_expr, item_eq);
   }
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 1bfa886..d8b9017 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1,4 +1,5 @@
-/* Copyright (c) 2006, 2013, Oracle and/or its affiliates.
+/* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2010, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1109,15 +1110,22 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
   {
     int err= 0;
 
+    /* Check for partition expression. */
     if (!list_of_part_fields)
     {
       DBUG_ASSERT(part_expr);
       err= part_expr->walk(&Item::check_partition_func_processor, 0,
                            NULL);
-      if (!err && is_sub_partitioned() && !list_of_subpart_fields)
-        err= subpart_expr->walk(&Item::check_partition_func_processor, 0,
-                                NULL);
     }
+
+    /* Check for sub partition expression. */
+    if (!err && is_sub_partitioned() && !list_of_subpart_fields)
+    {
+      DBUG_ASSERT(subpart_expr);
+      err= subpart_expr->walk(&Item::check_partition_func_processor, 0,
+                              NULL);
+    }
+
     if (err)
     {
       my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc
index 9480a9e..5b75d6c 100644
--- a/sql/rpl_handler.cc
+++ b/sql/rpl_handler.cc
@@ -38,8 +38,6 @@ typedef struct Trans_binlog_info {
   char log_file[FN_REFLEN];
 } Trans_binlog_info;
 
-static pthread_key(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
-
 int get_user_var_int(const char *name,
                      long long int *value, int *null_value)
 {
@@ -143,13 +141,6 @@ int delegates_init()
   }
 #endif
 
-  if (pthread_key_create(&RPL_TRANS_BINLOG_INFO, NULL))
-  {
-    sql_print_error("Error while creating pthread specific data key for replication. "
-                    "Please report a bug.");
-    return 1;
-  }
-
   return 0;
 }
 
@@ -195,27 +186,27 @@ void delegates_destroy()
 int Trans_delegate::after_commit(THD *thd, bool all)
 {
   Trans_param param;
+  Trans_binlog_info *log_info;
   bool is_real_trans= (all || thd->transaction.all.ha_list == 0);
+  int ret= 0;
 
   param.flags = is_real_trans ? TRANS_IS_REAL_TRANS : 0;
 
-  Trans_binlog_info *log_info=
-    my_pthread_getspecific_ptr(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
+  log_info= thd->semisync_info;
 
-  param.log_file= log_info ? log_info->log_file : 0;
+  param.log_file= log_info && log_info->log_file[0] ? log_info->log_file : 0;
   param.log_pos= log_info ? log_info->log_pos : 0;
 
-  int ret= 0;
   FOREACH_OBSERVER(ret, after_commit, false, (&param));
 
   /*
     This is the end of a real transaction or autocommit statement, we
-    can free the memory allocated for binlog file and position.
+    can mark the memory unused.
   */
   if (is_real_trans && log_info)
   {
-    my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, NULL);
-    my_free(log_info);
+    log_info->log_file[0]= 0;
+    log_info->log_pos= 0;
   }
   return ret;
 }
@@ -223,27 +214,27 @@ int Trans_delegate::after_commit(THD *thd, bool all)
 int Trans_delegate::after_rollback(THD *thd, bool all)
 {
   Trans_param param;
+  Trans_binlog_info *log_info;
   bool is_real_trans= (all || thd->transaction.all.ha_list == 0);
+  int ret= 0;
 
   param.flags = is_real_trans ? TRANS_IS_REAL_TRANS : 0;
 
-  Trans_binlog_info *log_info=
-    my_pthread_getspecific_ptr(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
-    
-  param.log_file= log_info ? log_info->log_file : 0;
+  log_info= thd->semisync_info;
+
+  param.log_file= log_info && log_info->log_file[0] ? log_info->log_file : 0;
   param.log_pos= log_info ? log_info->log_pos : 0;
 
-  int ret= 0;
   FOREACH_OBSERVER(ret, after_rollback, false, (&param));
 
   /*
     This is the end of a real transaction or autocommit statement, we
-    can free the memory allocated for binlog file and position.
+    can mark the memory unused.
   */
   if (is_real_trans && log_info)
   {
-    my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, NULL);
-    my_free(log_info);
+    log_info->log_file[0]= 0;
+    log_info->log_pos= 0;
   }
   return ret;
 }
@@ -254,25 +245,24 @@ int Binlog_storage_delegate::after_flush(THD *thd,
                                          bool synced)
 {
   Binlog_storage_param param;
+  Trans_binlog_info *log_info;
   uint32 flags=0;
+  int ret= 0;
+
   if (synced)
     flags |= BINLOG_STORAGE_IS_SYNCED;
 
-  Trans_binlog_info *log_info=
-    my_pthread_getspecific_ptr(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
-    
-  if (!log_info)
+  if (!(log_info= thd->semisync_info))
   {
     if(!(log_info=
-         (Trans_binlog_info *)my_malloc(sizeof(Trans_binlog_info), MYF(0))))
+         (Trans_binlog_info*) my_malloc(sizeof(Trans_binlog_info), MYF(0))))
       return 1;
-    my_pthread_setspecific_ptr(RPL_TRANS_BINLOG_INFO, log_info);
+    thd->semisync_info= log_info;
   }
-    
+
   strcpy(log_info->log_file, log_file+dirname_length(log_file));
   log_info->log_pos = log_pos;
   
-  int ret= 0;
   FOREACH_OBSERVER(ret, after_flush, false,
                    (&param, log_info->log_file, log_info->log_pos, flags));
   return ret;
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index e05ad5a..9a20f71 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -876,6 +876,7 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *
   {
     Create_field *field_def=
       (Create_field*) alloc_root(thd->mem_root, sizeof(Create_field));
+    bool unsigned_flag= 0;
     if (field_list.push_back(field_def))
       DBUG_RETURN(NULL);
 
@@ -885,8 +886,7 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *
     uint32 max_length=
       max_display_length_for_field(type(col), field_metadata(col));
 
-    switch(type(col))
-    {
+    switch(type(col)) {
       int precision;
     case MYSQL_TYPE_ENUM:
     case MYSQL_TYPE_SET:
@@ -925,6 +925,18 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *
       pack_length= field_metadata(col) & 0x00ff;
       break;
 
+    case MYSQL_TYPE_TINY:
+    case MYSQL_TYPE_SHORT:
+    case MYSQL_TYPE_INT24:
+    case MYSQL_TYPE_LONG:
+    case MYSQL_TYPE_LONGLONG:
+      /*
+        As we don't know if the integer was signed or not on the master,
+        assume we have same sign on master and slave.  This is true when not
+        using conversions so it should be true also when using conversions.
+      */
+      unsigned_flag= ((Field_num*) target_table->field[col])->unsigned_flag;
+      break;
     default:
       break;
     }
@@ -932,12 +944,13 @@ TABLE *table_def::create_conversion_table(THD *thd, Relay_log_info *rli, TABLE *
     DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d,"
                          " maybe_null: %d, unsigned_flag: %d, pack_length: %u",
                          type(col), target_table->field[col]->field_name,
-                         max_length, decimals, TRUE, FALSE, pack_length));
+                         max_length, decimals, TRUE, unsigned_flag,
+                         pack_length));
     field_def->init_for_tmp_table(type(col),
                                   max_length,
                                   decimals,
                                   TRUE,         // maybe_null
-                                  FALSE,        // unsigned_flag
+                                  unsigned_flag,
                                   pack_length);
     field_def->charset= target_table->field[col]->charset();
     field_def->interval= interval;
diff --git a/sql/slave.cc b/sql/slave.cc
index 2fe7ebb..fe96b1d 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -3556,9 +3556,7 @@ pthread_handler_t handle_slave_sql(void *arg)
   rli->clear_error();
 
   //tell the I/O thread to take relay_log_space_limit into account from now on
-  mysql_mutex_lock(&rli->log_space_lock);
   rli->ignore_log_space_limit= 0;
-  mysql_mutex_unlock(&rli->log_space_lock);
   rli->trans_retries= 0; // start from "no error"
   DBUG_PRINT("info", ("rli->trans_retries: %lu", rli->trans_retries));
 
@@ -5228,14 +5226,8 @@ static Log_event* next_event(Relay_log_info* rli)
           rli->ignore_log_space_limit= true;
         }
 
-        /*
-          If the I/O thread is blocked, unblock it.  Ok to broadcast
-          after unlock, because the mutex is only destroyed in
-          ~Relay_log_info(), i.e. when rli is destroyed, and rli will
-          not be destroyed before we exit the present function.
-        */
-        mysql_mutex_unlock(&rli->log_space_lock);
         mysql_cond_broadcast(&rli->log_space_cond);
+        mysql_mutex_unlock(&rli->log_space_lock);
         // Note that wait_for_update_relay_log unlocks lock_log !
         rli->relay_log.wait_for_update_relay_log(rli->sql_thd);
         // re-acquire data lock since we released it earlier
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index c4ef699..4588c74 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -4652,16 +4652,19 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
        tl && number-- && tl != first_not_own_table;
        tl= tl->next_global)
   {
-    sctx = test(tl->security_ctx) ? tl->security_ctx : thd->security_ctx;
+    TABLE_LIST *const t_ref=
+      tl->correspondent_table ? tl->correspondent_table : tl;
+    sctx = test(t_ref->security_ctx) ? t_ref->security_ctx :
+                                       thd->security_ctx;
 
     const ACL_internal_table_access *access=
-      get_cached_table_access(&tl->grant.m_internal,
-                              tl->get_db_name(),
-                              tl->get_table_name());
+      get_cached_table_access(&t_ref->grant.m_internal,
+                              t_ref->get_db_name(),
+                              t_ref->get_table_name());
 
     if (access)
     {
-      switch(access->check(orig_want_access, &tl->grant.privilege))
+      switch(access->check(orig_want_access, &t_ref->grant.privilege))
       {
       case ACL_INTERNAL_ACCESS_GRANTED:
         /*
@@ -4685,33 +4688,33 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
     if (!want_access)
       continue;                                 // ok
 
-    if (!(~tl->grant.privilege & want_access) ||
-        tl->is_anonymous_derived_table() || tl->schema_table)
+    if (!(~t_ref->grant.privilege & want_access) ||
+        t_ref->is_anonymous_derived_table() || t_ref->schema_table)
     {
       /*
-        It is subquery in the FROM clause. VIEW set tl->derived after
+        It is subquery in the FROM clause. VIEW set t_ref->derived after
         table opening, but this function always called before table opening.
       */
-      if (!tl->referencing_view)
+      if (!t_ref->referencing_view)
       {
         /*
           If it's a temporary table created for a subquery in the FROM
           clause, or an INFORMATION_SCHEMA table, drop the request for
           a privilege.
         */
-        tl->grant.want_privilege= 0;
+        t_ref->grant.want_privilege= 0;
       }
       continue;
     }
     GRANT_TABLE *grant_table= table_hash_search(sctx->host, sctx->ip,
-                                                tl->get_db_name(),
+                                                t_ref->get_db_name(),
                                                 sctx->priv_user,
-                                                tl->get_table_name(),
+                                                t_ref->get_table_name(),
                                                 FALSE);
 
     if (!grant_table)
     {
-      want_access &= ~tl->grant.privilege;
+      want_access &= ~t_ref->grant.privilege;
       goto err;					// No grants
     }
 
@@ -4722,17 +4725,17 @@ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
     if (any_combination_will_do)
       continue;
 
-    tl->grant.grant_table= grant_table; // Remember for column test
-    tl->grant.version= grant_version;
-    tl->grant.privilege|= grant_table->privs;
-    tl->grant.want_privilege= ((want_access & COL_ACLS) & ~tl->grant.privilege);
+    t_ref->grant.grant_table= grant_table; // Remember for column test
+    t_ref->grant.version= grant_version;
+    t_ref->grant.privilege|= grant_table->privs;
+    t_ref->grant.want_privilege= ((want_access & COL_ACLS) & ~t_ref->grant.privilege);
 
-    if (!(~tl->grant.privilege & want_access))
+    if (!(~t_ref->grant.privilege & want_access))
       continue;
 
-    if (want_access & ~(grant_table->cols | tl->grant.privilege))
+    if (want_access & ~(grant_table->cols | t_ref->grant.privilege))
     {
-      want_access &= ~(grant_table->cols | tl->grant.privilege);
+      want_access &= ~(grant_table->cols | t_ref->grant.privilege);
       goto err;					// impossible
     }
   }
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index fcd17b2..1403fe9 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1682,13 +1682,20 @@ bool close_temporary_tables(THD *thd)
   if (!thd->temporary_tables)
     DBUG_RETURN(FALSE);
 
+  /*
+    Ensure we don't have open HANDLERs for tables we are about to close.
+    This is necessary when close_temporary_tables() is called as part
+    of execution of BINLOG statement (e.g. for format description event).
+  */
+  mysql_ha_rm_temporary_tables(thd);
   if (!mysql_bin_log.is_open())
   {
     TABLE *tmp_next;
-    for (table= thd->temporary_tables; table; table= tmp_next)
+    for (TABLE *t= thd->temporary_tables; t; t= tmp_next)
     {
-      tmp_next= table->next;
-      close_temporary(table, 1, 1);
+      tmp_next= t->next;
+      mysql_lock_remove(thd, thd->lock, t);
+      close_temporary(t, 1, 1);
     }
     thd->temporary_tables= 0;
     DBUG_RETURN(FALSE);
@@ -1783,6 +1790,7 @@ bool close_temporary_tables(THD *thd)
                           strlen(table->s->table_name.str));
         s_query.append(',');
         next= table->next;
+        mysql_lock_remove(thd, thd->lock, table);
         close_temporary(table, 1, 1);
       }
       thd->clear_error();
@@ -4064,10 +4072,11 @@ request_backoff_action(enum_open_table_action action_arg,
     * We met a broken table that needs repair, or a table that
       is not present on this MySQL server and needs re-discovery.
       To perform the action, we need an exclusive metadata lock on
-      the table. Acquiring an X lock while holding other shared
-      locks is very deadlock-prone. If this is a multi- statement
-      transaction that holds metadata locks for completed
-      statements, we don't do it, and report an error instead.
+      the table. Acquiring X lock while holding other shared
+      locks can easily lead to deadlocks. We rely on MDL deadlock
+      detector to discover them. If this is a multi-statement
+      transaction that holds metadata locks for completed statements,
+      we should keep these locks after discovery/repair.
       The action type in this case is OT_DISCOVER or OT_REPAIR.
     * Our attempt to acquire an MDL lock lead to a deadlock,
       detected by the MDL deadlock detector. The current
@@ -4108,7 +4117,7 @@ request_backoff_action(enum_open_table_action action_arg,
       keep tables open between statements and a livelock
       is not possible.
   */
-  if (action_arg != OT_REOPEN_TABLES && m_has_locks)
+  if (action_arg == OT_BACKOFF_AND_RETRY && m_has_locks)
   {
     my_error(ER_LOCK_DEADLOCK, MYF(0));
     m_thd->mark_transaction_to_rollback(true);
@@ -4136,6 +4145,32 @@ request_backoff_action(enum_open_table_action action_arg,
 
 
 /**
+  An error handler to mark transaction to rollback on DEADLOCK error
+  during DISCOVER / REPAIR.
+*/
+class MDL_deadlock_discovery_repair_handler : public Internal_error_handler
+{
+public:
+  virtual bool handle_condition(THD *thd,
+                                  uint sql_errno,
+                                  const char* sqlstate,
+                                  MYSQL_ERROR::enum_warning_level level,
+                                  const char* msg,
+                                  MYSQL_ERROR ** cond_hdl)
+  {
+    if (sql_errno == ER_LOCK_DEADLOCK)
+    {
+      thd->mark_transaction_to_rollback(true);
+    }
+    /*
+      We have marked this transaction to rollback. Return false to allow
+      error to be reported or handled by other handlers.
+    */
+    return false;
+  }
+};
+
+/**
    Recover from failed attempt of open table by performing requested action.
 
    @pre This function should be called only with "action" != OT_NO_ACTION
@@ -4150,6 +4185,12 @@ Open_table_context::
 recover_from_failed_open()
 {
   bool result= FALSE;
+  MDL_deadlock_discovery_repair_handler handler;
+  /*
+    Install error handler to mark transaction to rollback on DEADLOCK error.
+  */
+  m_thd->push_internal_handler(&handler);
+
   /* Execute the action. */
   switch (m_action)
   {
@@ -4171,7 +4212,12 @@ recover_from_failed_open()
 
         m_thd->warning_info->clear_warning_info(m_thd->query_id);
         m_thd->clear_error();                 // Clear error message
-        m_thd->mdl_context.release_transactional_locks();
+        /*
+          Rollback to start of the current statement to release exclusive lock
+          on table which was discovered but preserve locks from previous statements
+          in current transaction.
+        */
+        m_thd->mdl_context.rollback_to_savepoint(start_of_statement_svp());
         break;
       }
     case OT_REPAIR:
@@ -4185,12 +4231,18 @@ recover_from_failed_open()
                          m_failed_table->table_name, FALSE);
 
         result= auto_repair_table(m_thd, m_failed_table);
-        m_thd->mdl_context.release_transactional_locks();
+        /*
+          Rollback to start of the current statement to release exclusive lock
+          on table which was discovered but preserve locks from previous statements
+          in current transaction.
+        */
+        m_thd->mdl_context.rollback_to_savepoint(start_of_statement_svp());
         break;
       }
     default:
       DBUG_ASSERT(0);
   }
+  m_thd->pop_internal_handler();
   /*
     Reset the pointers to conflicting MDL request and the
     TABLE_LIST element, set when we need auto-discovery or repair,
@@ -6859,6 +6911,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
 
   if (item->cached_table)
   {
+    DBUG_PRINT("info", ("using cached table"));
     /*
       This shortcut is used by prepared statements. We assume that
       TABLE_LIST *first_table is not changed during query execution (which
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 76b2031..7b97d58 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -877,6 +877,7 @@ THD::THD()
   file_id = 0;
   query_id= 0;
   query_name_consts= 0;
+  semisync_info= 0;
   db_charset= global_system_variables.collation_database;
   bzero(ha_data, sizeof(ha_data));
   mysys_var=0;
@@ -1263,6 +1264,7 @@ void THD::init(void)
   bzero((char *) &status_var, sizeof(status_var));
   bzero((char *) &org_status_var, sizeof(org_status_var));
   start_bytes_received= 0;
+  status_in_global= 0;
 
   if (variables.sql_log_bin)
     variables.option_bits|= OPTION_BIN_LOG;
@@ -1366,6 +1368,7 @@ void THD::change_user(void)
   cleanup();
   reset_killed();
   cleanup_done= 0;
+  status_in_global= 0;
   init();
   stmt_map.reset();
   my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
@@ -1491,6 +1494,7 @@ THD::~THD()
   mysql_audit_free_thd(this);
   if (rli_slave)
     rli_slave->cleanup_after_session();
+  my_free(semisync_info);
 #endif
 
   free_root(&main_mem_root, MYF(0));
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 67db166..68563ab 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -47,7 +47,6 @@
 
 class Reprepare_observer;
 class Relay_log_info;
-
 class Query_log_event;
 class Load_log_event;
 class Slave_log_event;
@@ -59,6 +58,7 @@ class Rows_log_event;
 class Sroutine_hash_entry;
 class User_level_lock;
 class user_var_entry;
+struct Trans_binlog_info;
 
 enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
 enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
@@ -1670,6 +1670,9 @@ public:
   */
   const char *where;
 
+  /* Needed by MariaDB semi sync replication */
+  Trans_binlog_info *semisync_info;
+
   ulong client_capabilities;		/* What the client supports */
   ulong max_client_packet_length;
 
@@ -1733,11 +1736,11 @@ public:
   /* Do not set socket timeouts for wait_timeout (used with threadpool) */
   bool skip_wait_timeout;
 
-  /* container for handler's private per-connection data */
-  Ha_data ha_data[MAX_HA];
-
   bool prepare_derived_at_open;
 
+  /* Set to 1 if status of this THD is already in global status */
+  bool status_in_global;
+
   /* 
     To signal that the tmp table to be created is created for materialized
     derived table or a view.
@@ -1746,6 +1749,9 @@ public:
 
   bool save_prep_leaf_list;
 
+  /* container for handler's private per-connection data */
+  Ha_data ha_data[MAX_HA];
+
 #ifndef MYSQL_CLIENT
   binlog_cache_mngr *  binlog_setup_trx_data();
 
@@ -3116,6 +3122,8 @@ public:
   {
     mysql_mutex_lock(&LOCK_status);
     add_to_status(&global_status_var, &status_var);
+    /* Mark that this THD status has already been added in global status */
+    status_in_global= 1;
     mysql_mutex_unlock(&LOCK_status);
   }
 
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index c099a2a..f5c79e5 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2001, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2011, 2013, Monty Program Ab.
+/* Copyright (c) 2001, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2011, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -1187,3 +1187,36 @@ void mysql_ha_set_explicit_lock_duration(THD *thd)
   DBUG_VOID_RETURN;
 }
 
+
+/**
+  Remove temporary tables from the HANDLER's hash table. The reason
+  for having a separate function, rather than calling
+  mysql_ha_rm_tables() is that it is not always feasible (e.g. in
+  close_temporary_tables) to obtain a TABLE_LIST containing the
+  temporary tables.
+
+  @See close_temporary_tables
+  @param thd Thread identifier.
+*/
+void mysql_ha_rm_temporary_tables(THD *thd)
+{
+  DBUG_ENTER("mysql_ha_rm_temporary_tables");
+
+  TABLE_LIST *tmp_handler_tables= NULL;
+  for (uint i= 0; i < thd->handler_tables_hash.records; i++)
+  {
+    TABLE_LIST *handler_table= reinterpret_cast<TABLE_LIST*>
+      (my_hash_element(&thd->handler_tables_hash, i));
+
+    if (handler_table->table && handler_table->table->s->tmp_table)
+    {
+      handler_table->next_local= tmp_handler_tables;
+      tmp_handler_tables= handler_table;
+    }
+  }
+
+  if (tmp_handler_tables)
+    mysql_ha_rm_tables(thd, tmp_handler_tables);
+
+  DBUG_VOID_RETURN;
+}
diff --git a/sql/sql_handler.h b/sql/sql_handler.h
index 133f553..7fe5ae5 100644
--- a/sql/sql_handler.h
+++ b/sql/sql_handler.h
@@ -1,6 +1,8 @@
 #ifndef SQL_HANDLER_INCLUDED
 #define SQL_HANDLER_INCLUDED
-/* Copyright (C) 2010 Monty Program Ab
+/* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
+   Copyright (C) 2010, 2015, MariaDB
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; version 2 of the License.
@@ -73,6 +75,7 @@ void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables);
 void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
 void mysql_ha_cleanup(THD *thd);
 void mysql_ha_set_explicit_lock_duration(THD *thd);
+void mysql_ha_rm_temporary_tables(THD *thd);
 
 SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables,
                                    enum enum_ha_read_modes mode, char *keyname,
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 4500c44..640ee5d 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1,6 +1,6 @@
 /*
-   Copyright (c) 2000, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2010, 2014, SkySQL Ab.
+   Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2010, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -3842,7 +3842,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
   /* Add selected items to field list */
   List_iterator_fast<Item> it(*items);
   Item *item;
-  Field *tmp_field;
   DBUG_ENTER("create_table_from_items");
 
   tmp_table.alias= 0;
@@ -3857,24 +3856,49 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
 
   while ((item=it++))
   {
-    Create_field *cr_field;
-    Field *field, *def_field;
+    Field *tmp_table_field;
     if (item->type() == Item::FUNC_ITEM)
     {
       if (item->result_type() != STRING_RESULT)
-        field= item->tmp_table_field(&tmp_table);
+        tmp_table_field= item->tmp_table_field(&tmp_table);
       else
-        field= item->tmp_table_field_from_field_type(&tmp_table, 0);
+        tmp_table_field= item->tmp_table_field_from_field_type(&tmp_table,
+                                                               false);
     }
     else
-      field= create_tmp_field(thd, &tmp_table, item, item->type(),
-                              (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0,
-                              0);
-    if (!field ||
-	!(cr_field=new Create_field(field,(item->type() == Item::FIELD_ITEM ?
-					   ((Item_field *)item)->field :
-					   (Field*) 0))))
-      DBUG_RETURN(0);
+    {
+      Field *from_field, * default_field;
+      tmp_table_field= create_tmp_field(thd, &tmp_table, item, item->type(),
+                              (Item ***) NULL, &from_field, &default_field,
+                              0, 0, 0, 0, 0);
+    }
+
+    if (!tmp_table_field)
+      DBUG_RETURN(NULL);
+
+    Field *table_field;
+
+    switch (item->type())
+    {
+    /*
+      We have to take into account both the real table's fields and
+      pseudo-fields used in trigger's body. These fields are used
+      to copy defaults values later inside constructor of
+      the class Create_field.
+    */
+    case Item::FIELD_ITEM:
+    case Item::TRIGGER_FIELD_ITEM:
+      table_field= ((Item_field *) item)->field;
+      break;
+    default:
+      table_field= NULL;
+    }
+
+    Create_field *cr_field= new Create_field(tmp_table_field, table_field);
+
+    if (!cr_field)
+      DBUG_RETURN(NULL);
+
     if (item->maybe_null)
       cr_field->flags &= ~NOT_NULL_FLAG;
     alter_info->create_list.push_back(cr_field);
@@ -3942,7 +3966,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
     {
       if (!thd->is_error())                     // CREATE ... IF NOT EXISTS
         my_ok(thd);                             //   succeed, but did nothing
-      DBUG_RETURN(0);
+      DBUG_RETURN(NULL);
     }
   }
 
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 1d62acd..9ccafa7 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1917,7 +1917,6 @@ void st_select_lex::init_select()
   with_sum_func= 0;
   is_correlated= 0;
   cur_pos_in_select_list= UNDEF_POS;
-  non_agg_fields.empty();
   cond_value= having_value= Item::COND_UNDEF;
   inner_refs_list.empty();
   insert_tables= 0;
@@ -1925,6 +1924,7 @@ void st_select_lex::init_select()
   m_non_agg_field_used= false;
   m_agg_func_used= false;
   name_visibility_map= 0;
+  join= 0;
 }
 
 /*
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index a0f8e45..aa59d76 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -877,8 +877,6 @@ public:
   bool no_wrap_view_item;
   /* exclude this select from check of unique_table() */
   bool exclude_from_table_unique_test;
-  /* List of fields that aren't under an aggregate function */
-  List<Item_field> non_agg_fields;
   /* index in the select list of the expression currently being fixed */
   int cur_pos_in_select_list;
 
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index b4f8b10..75ddf80 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -1,6 +1,6 @@
 /*
-   Copyright (c) 2000, 2014, Oracle and/or its affiliates.
-   Copyright (c) 2010, 2014, Monty Progrm Ab
+   Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2010, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -2012,8 +2012,15 @@ int READ_INFO::read_xml()
       break;
       
     case '/': /* close tag */
-      level--;
       chr= my_tospace(GET);
+      /* Decrease the 'level' only when (i) It's not an */
+      /* (without space) empty tag i.e. <tag/> or, (ii) */
+      /* It is of format <row col="val" .../>           */
+      if(chr != '>' || in_tag)
+      {
+        level--;
+        in_tag= false;
+      }
       if(chr != '>')   /* if this is an empty tag <tag   /> */
         tag.length(0); /* we should keep tag value          */
       while(chr != '>' && chr != my_b_EOF)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 4ad3f9a..a52d55b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2008, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+   Copyright (c) 2008, 2015, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -5197,9 +5197,12 @@ check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
   for (; i < number && tables != first_not_own_table && tables;
        tables= tables->next_global, i++)
   {
+    TABLE_LIST *const table_ref= tables->correspondent_table ?
+      tables->correspondent_table : tables;
+
     ulong want_access= requirements;
-    if (tables->security_ctx)
-      sctx= tables->security_ctx;
+    if (table_ref->security_ctx)
+      sctx= table_ref->security_ctx;
     else
       sctx= backup_ctx;
 
@@ -5207,26 +5210,26 @@ check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
        Register access for view underlying table.
        Remove SHOW_VIEW_ACL, because it will be checked during making view
      */
-    tables->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
+    table_ref->grant.orig_want_privilege= (want_access & ~SHOW_VIEW_ACL);
 
-    if (tables->schema_table_reformed)
+    if (table_ref->schema_table_reformed)
     {
-      if (check_show_access(thd, tables))
+      if (check_show_access(thd, table_ref))
         goto deny;
       continue;
     }
 
-    DBUG_PRINT("info", ("derived: %d  view: %d", tables->derived != 0,
-                        tables->view != 0));
-    if (tables->is_anonymous_derived_table() ||
-        (tables->table && tables->table->s &&
-         (int)tables->table->s->tmp_table))
+    DBUG_PRINT("info", ("derived: %d  view: %d", table_ref->derived != 0,
+                        table_ref->view != 0));
+    if (table_ref->is_anonymous_derived_table() ||
+        (table_ref->table && table_ref->table->s &&
+         (int)table_ref->table->s->tmp_table))
       continue;
     thd->security_ctx= sctx;
 
-    if (check_access(thd, want_access, tables->get_db_name(),
-                     &tables->grant.privilege,
-                     &tables->grant.m_internal,
+    if (check_access(thd, want_access, table_ref->get_db_name(),
+                     &table_ref->grant.privilege,
+                     &table_ref->grant.m_internal,
                      0, no_errors))
       goto deny;
   }
@@ -5653,6 +5656,8 @@ void THD::reset_for_next_command()
   thd->reset_current_stmt_binlog_format_row();
   thd->binlog_unsafe_warning_flags= 0;
 
+  thd->save_prep_leaf_list= false;
+
   DBUG_PRINT("debug",
              ("is_current_stmt_binlog_format_row(): %d",
               thd->is_current_stmt_binlog_format_row()));
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index fb7cafc..e960a3d 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4904,6 +4904,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
   KEY_FIELD *key_fields, *end, *field;
   uint sz;
   uint m= max(select_lex->max_equal_elems,1);
+  DBUG_ENTER("update_ref_and_keys");
+  DBUG_PRINT("enter", ("normal_tables: %llx", normal_tables));
 
   SELECT_LEX *sel=thd->lex->current_select; 
   sel->cond_count= 0;
@@ -4950,7 +4952,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
   sz= max(sizeof(KEY_FIELD),sizeof(SARGABLE_PARAM))*
     ((sel->cond_count*2 + sel->between_count)*m+1);
   if (!(key_fields=(KEY_FIELD*)	thd->alloc(sz)))
-    return TRUE; /* purecov: inspected */
+    DBUG_RETURN(TRUE); /* purecov: inspected */
   and_level= 0;
   field= end= key_fields;
   *sargables= (SARGABLE_PARAM *) key_fields + 
@@ -4959,7 +4961,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
   (*sargables)[0].field= 0; 
 
   if (my_init_dynamic_array(keyuse,sizeof(KEYUSE),20,64))
-    return TRUE;
+    DBUG_RETURN(TRUE);
 
   if (cond)
   {
@@ -5009,16 +5011,16 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
   for ( ; field != end ; field++)
   {
     if (add_key_part(keyuse,field))
-      return TRUE;
+      DBUG_RETURN(TRUE);
   }
 
   if (select_lex->ftfunc_list->elements)
   {
     if (add_ft_keys(keyuse,join_tab,cond,normal_tables))
-      return TRUE;
+      DBUG_RETURN(TRUE);
   }
 
-  return FALSE;
+  DBUG_RETURN(FALSE);
 }
 
 
@@ -14700,6 +14702,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
   case Item::FIELD_ITEM:
   case Item::DEFAULT_VALUE_ITEM:
   case Item::INSERT_VALUE_ITEM:
+  case Item::TRIGGER_FIELD_ITEM:
   {
     Item_field *field= (Item_field*) item;
     bool orig_modify= modify_item;
@@ -17148,6 +17151,10 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
       if (return_tab < join->return_tab)
         join->return_tab= return_tab;
 
+      /* check for errors evaluating the condition */
+      if (join->thd->is_error())
+        DBUG_RETURN(NESTED_LOOP_ERROR);
+
       if (join->return_tab < join_tab)
         DBUG_RETURN(NESTED_LOOP_OK);
       /*
@@ -20705,7 +20712,7 @@ setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
     Item_field *field;
     int cur_pos_in_select_list= 0;
     List_iterator<Item> li(fields);
-    List_iterator<Item_field> naf_it(thd->lex->current_select->non_agg_fields);
+    List_iterator<Item_field> naf_it(thd->lex->current_select->join->non_agg_fields);
 
     field= naf_it++;
     while (field && (item=li++))
diff --git a/sql/sql_select.h b/sql/sql_select.h
index de5baee..4f807ff 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -922,6 +922,9 @@ public:
   Item *pre_sort_idx_pushed_cond;
   void clean_pre_sort_join_tab();
 
+  /* List of fields that aren't under an aggregate function */
+  List<Item_field> non_agg_fields;
+
   /*
     For "Using temporary+Using filesort" queries, JOIN::join_tab can point to
     either: 
@@ -1301,6 +1304,7 @@ public:
     all_fields= fields_arg;
     if (&fields_list != &fields_arg)      /* Avoid valgrind-warning */
       fields_list= fields_arg;
+    non_agg_fields.empty();
     bzero((char*) &keyuse,sizeof(keyuse));
     tmp_table_param.init();
     tmp_table_param.end_write_records= HA_POS_ERROR;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 2248474..86fc11c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3109,7 +3109,10 @@ void calc_sum_of_all_status(STATUS_VAR *to)
 
   /* Add to this status from existing threads */
   while ((tmp= it++))
-    add_to_status(to, &tmp->status_var);
+  {
+    if (!tmp->status_in_global)
+      add_to_status(to, &tmp->status_var);
+  }
   
   mysql_mutex_unlock(&LOCK_thread_count);
   DBUG_VOID_RETURN;
@@ -7727,13 +7730,14 @@ bool get_schema_tables_result(JOIN *join,
     TABLE_LIST *table_list= tab->table->pos_in_table_list;
     if (table_list->schema_table && thd->fill_information_schema_tables())
     {
-#if MYSQL_VERSION_ID > 100105
-#error I_S tables only need to be re-populated if make_cond_for_info_schema() will preserve outer fields
-      bool is_subselect= (&lex->unit != lex->current_select->master_unit() &&
-                          lex->current_select->master_unit()->item);
-#else
-#define is_subselect false
-#endif
+      /*
+        I_S tables only need to be re-populated if make_cond_for_info_schema()
+        preserves outer fields
+      */
+      bool is_subselect= &lex->unit != lex->current_select->master_unit() &&
+                         lex->current_select->master_unit()->item &&
+                         tab->select_cond &&
+                         tab->select_cond->used_tables() & OUTER_REF_TABLE_BIT;
 
       /* A value of 0 indicates a dummy implementation */
       if (table_list->schema_table->fill_table == 0)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 4139aa7..6e589e2 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4010,6 +4010,12 @@ static bool check_if_created_table_can_be_opened(THD *thd,
   result= (open_table_def(thd, &share, 0) ||
            open_table_from_share(thd, &share, "", 0, (uint) READ_ALL,
                                  0, &table, TRUE));
+  /*
+    Assert that the change list is empty as no partition function currently
+    needs to modify item tree. May need call THD::rollback_item_tree_changes
+    later before calling closefrm if the change list is not empty.
+  */
+  DBUG_ASSERT(thd->change_list.is_empty());
   if (! result)
     (void) closefrm(&table, 0);
 
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index ec426e3..dc6bc81 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -248,7 +248,7 @@ TEST_join(JOIN *join)
 
 #define FT_KEYPART   (MAX_REF_PARTS+10)
 
-void print_keyuse(KEYUSE *keyuse)
+static void print_keyuse(KEYUSE *keyuse)
 {
   char buff[256];
   char buf2[64]; 
@@ -266,14 +266,11 @@ void print_keyuse(KEYUSE *keyuse)
   else
     fieldname= key_info->key_part[keyuse->keypart].field->field_name;
   ll2str(keyuse->used_tables, buf2, 16, 0); 
-  DBUG_LOCK_FILE;
   fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s  optimize: %u  used_tables: %s "
           "ref_table_rows: %lu  keypart_map: %0lx\n",
           keyuse->table->alias.c_ptr(), fieldname, str.ptr(),
           (uint) keyuse->optimize, buf2, (ulong) keyuse->ref_table_rows, 
           (ulong) keyuse->keypart_map);
-  DBUG_UNLOCK_FILE;
-  //key_part_map keypart_map; --?? there can be several? 
 }
 
 
@@ -282,9 +279,9 @@ void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array)
 {
   DBUG_LOCK_FILE;
   fprintf(DBUG_FILE, "KEYUSE array (%d elements)\n", keyuse_array->elements);
-  DBUG_UNLOCK_FILE;
   for(uint i=0; i < keyuse_array->elements; i++)
     print_keyuse((KEYUSE*)dynamic_array_ptr(keyuse_array, i));
+  DBUG_UNLOCK_FILE;
 }
 
 
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 6e2e6e0..87d3e86 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -1021,7 +1021,6 @@ bool st_select_lex::cleanup()
   {
     error= (bool) ((uint) error | (uint) lex_unit->cleanup());
   }
-  non_agg_fields.empty();
   inner_refs_list.empty();
   exclude_from_table_unique_test= FALSE;
   DBUG_RETURN(error);
@@ -1032,6 +1031,7 @@ void st_select_lex::cleanup_all_joins(bool full)
 {
   SELECT_LEX_UNIT *unit;
   SELECT_LEX *sl;
+  DBUG_ENTER("st_select_lex::cleanup_all_joins");
 
   if (join)
     join->cleanup(full);
@@ -1039,6 +1039,7 @@ void st_select_lex::cleanup_all_joins(bool full)
   for (unit= first_inner_unit(); unit; unit= unit->next_unit())
     for (sl= unit->first_select(); sl; sl= sl->next_select())
       sl->cleanup_all_joins(full);
+  DBUG_VOID_RETURN;
 }
 
 
diff --git a/sql/sql_yacc.cc b/sql/sql_yacc.cc
index 9908510..6aee251 100644
--- a/sql/sql_yacc.cc
+++ b/sql/sql_yacc.cc
@@ -3660,114 +3660,114 @@ static const yytype_uint16 yyrline[] =
    10529, 10530, 10534, 10535, 10536, 10540, 10541, 10542, 10543, 10544,
    10545, 10549, 10550, 10551, 10552, 10553, 10557, 10558, 10559, 10560,
    10561, 10565, 10566, 10567, 10568, 10569, 10573, 10578, 10579, 10583,
-   10584, 10587, 10590, 10589, 10620, 10621, 10625, 10626, 10630, 10640,
-   10640, 10650, 10651, 10655, 10674, 10707, 10706, 10719, 10727, 10718,
-   10729, 10741, 10753, 10752, 10770, 10769, 10780, 10780, 10796, 10803,
-   10825, 10845, 10857, 10862, 10861, 10871, 10877, 10884, 10889, 10894,
-   10904, 10905, 10909, 10920, 10921, 10925, 10936, 10937, 10941, 10942,
-   10950, 10958, 10949, 10968, 10975, 10967, 10985, 10993, 10994, 11002,
-   11006, 11007, 11018, 11019, 11023, 11032, 11033, 11034, 11036, 11035,
-   11046, 11047, 11051, 11052, 11054, 11053, 11057, 11056, 11062, 11063,
-   11067, 11068, 11072, 11082, 11083, 11087, 11088, 11093, 11092, 11106,
-   11107, 11111, 11116, 11124, 11125, 11133, 11135, 11135, 11143, 11151,
-   11142, 11173, 11174, 11178, 11186, 11187, 11191, 11201, 11202, 11209,
-   11208, 11224, 11223, 11235, 11234, 11246, 11245, 11259, 11260, 11264,
-   11277, 11293, 11294, 11298, 11299, 11303, 11304, 11305, 11310, 11309,
-   11330, 11332, 11335, 11337, 11340, 11341, 11344, 11348, 11352, 11356,
-   11360, 11364, 11368, 11372, 11376, 11384, 11387, 11397, 11396, 11411,
-   11418, 11426, 11434, 11442, 11450, 11458, 11465, 11467, 11469, 11478,
-   11482, 11487, 11486, 11492, 11491, 11496, 11505, 11512, 11521, 11530,
-   11535, 11537, 11539, 11541, 11543, 11545, 11552, 11560, 11562, 11570,
-   11577, 11584, 11594, 11601, 11607, 11615, 11623, 11627, 11631, 11638,
-   11645, 11652, 11659, 11666, 11673, 11679, 11686, 11693, 11698, 11703,
-   11711, 11713, 11715, 11720, 11721, 11724, 11726, 11730, 11731, 11735,
-   11736, 11740, 11741, 11745, 11746, 11750, 11751, 11754, 11756, 11763,
-   11774, 11773, 11789, 11788, 11798, 11799, 11803, 11804, 11805, 11809,
-   11810, 11811, 11826, 11825, 11838, 11847, 11837, 11849, 11853, 11854,
-   11868, 11869, 11874, 11876, 11878, 11880, 11882, 11884, 11886, 11888,
-   11890, 11892, 11894, 11896, 11901, 11903, 11905, 11907, 11909, 11911,
-   11913, 11918, 11919, 11923, 11924, 11928, 11927, 11937, 11938, 11942,
-   11942, 11944, 11945, 11949, 11950, 11955, 11954, 11965, 11969, 11973,
-   11986, 11985, 11999, 12000, 12001, 12004, 12005, 12006, 12010, 12015,
-   12025, 12037, 12048, 12058, 12068, 12036, 12076, 12077, 12081, 12082,
-   12086, 12087, 12095, 12099, 12100, 12101, 12104, 12106, 12110, 12111,
-   12115, 12120, 12127, 12132, 12139, 12141, 12145, 12146, 12150, 12155,
-   12163, 12164, 12167, 12169, 12177, 12179, 12183, 12184, 12185, 12189,
-   12191, 12196, 12197, 12206, 12207, 12211, 12212, 12216, 12229, 12252,
-   12264, 12275, 12294, 12302, 12314, 12322, 12337, 12357, 12358, 12359,
-   12367, 12368, 12369, 12376, 12382, 12388, 12394, 12400, 12406, 12435,
-   12463, 12464, 12465, 12469, 12479, 12489, 12495, 12504, 12519, 12520,
-   12524, 12533, 12548, 12552, 12598, 12602, 12619, 12623, 12701, 12725,
-   12755, 12756, 12772, 12782, 12786, 12792, 12798, 12808, 12814, 12823,
-   12833, 12834, 12862, 12876, 12890, 12905, 12906, 12916, 12917, 12927,
-   12928, 12929, 12933, 12949, 12970, 12985, 12986, 12987, 12988, 12989,
-   12990, 12991, 12992, 12993, 12994, 12995, 12996, 12997, 12998, 12999,
-   13000, 13001, 13002, 13003, 13004, 13005, 13006, 13007, 13008, 13009,
-   13010, 13011, 13012, 13013, 13014, 13015, 13016, 13017, 13018, 13019,
-   13020, 13021, 13022, 13023, 13024, 13025, 13026, 13027, 13028, 13029,
-   13030, 13031, 13032, 13033, 13034, 13035, 13036, 13037, 13038, 13039,
-   13040, 13041, 13042, 13043, 13053, 13054, 13055, 13056, 13057, 13058,
-   13059, 13060, 13061, 13062, 13063, 13064, 13065, 13066, 13067, 13068,
-   13069, 13070, 13071, 13072, 13073, 13074, 13075, 13076, 13077, 13078,
-   13079, 13080, 13081, 13082, 13083, 13084, 13085, 13086, 13087, 13088,
-   13089, 13090, 13091, 13092, 13093, 13094, 13095, 13096, 13097, 13098,
-   13099, 13100, 13101, 13102, 13103, 13104, 13105, 13106, 13107, 13108,
-   13109, 13110, 13111, 13112, 13113, 13114, 13115, 13116, 13117, 13118,
-   13119, 13120, 13121, 13122, 13123, 13124, 13125, 13126, 13127, 13128,
-   13129, 13130, 13131, 13132, 13133, 13134, 13135, 13136, 13137, 13138,
-   13139, 13140, 13141, 13142, 13143, 13144, 13145, 13146, 13147, 13148,
-   13149, 13150, 13151, 13152, 13153, 13154, 13155, 13156, 13157, 13158,
-   13159, 13160, 13161, 13162, 13163, 13164, 13165, 13166, 13167, 13168,
-   13169, 13170, 13171, 13172, 13173, 13174, 13175, 13176, 13177, 13178,
-   13179, 13180, 13181, 13182, 13183, 13184, 13185, 13186, 13187, 13188,
-   13189, 13190, 13191, 13192, 13193, 13194, 13195, 13196, 13197, 13198,
-   13199, 13200, 13201, 13202, 13203, 13204, 13205, 13206, 13207, 13208,
-   13209, 13210, 13211, 13212, 13213, 13214, 13215, 13216, 13217, 13218,
-   13219, 13220, 13221, 13222, 13223, 13224, 13225, 13226, 13227, 13228,
-   13229, 13230, 13231, 13232, 13233, 13234, 13235, 13236, 13237, 13238,
-   13239, 13240, 13241, 13242, 13243, 13244, 13245, 13246, 13247, 13248,
-   13249, 13250, 13251, 13252, 13253, 13254, 13255, 13256, 13257, 13258,
-   13259, 13260, 13261, 13262, 13263, 13264, 13265, 13266, 13267, 13268,
-   13269, 13270, 13271, 13272, 13273, 13274, 13275, 13276, 13277, 13278,
-   13279, 13280, 13281, 13282, 13283, 13284, 13285, 13286, 13287, 13288,
-   13289, 13290, 13291, 13292, 13293, 13294, 13295, 13296, 13297, 13298,
-   13299, 13300, 13301, 13302, 13303, 13304, 13305, 13306, 13307, 13308,
-   13309, 13310, 13311, 13312, 13313, 13314, 13315, 13316, 13317, 13318,
-   13319, 13320, 13321, 13322, 13323, 13324, 13325, 13326, 13327, 13328,
-   13329, 13330, 13331, 13332, 13333, 13334, 13335, 13336, 13337, 13338,
-   13339, 13340, 13341, 13342, 13343, 13344, 13345, 13352, 13351, 13366,
-   13367, 13371, 13372, 13376, 13376, 13456, 13457, 13458, 13459, 13463,
-   13464, 13468, 13469, 13470, 13471, 13475, 13476, 13477, 13478, 13482,
-   13483, 13487, 13528, 13546, 13557, 13569, 13582, 13597, 13616, 13642,
-   13655, 13681, 13724, 13738, 13739, 13740, 13741, 13745, 13746, 13755,
-   13767, 13768, 13769, 13775, 13781, 13793, 13792, 13808, 13809, 13813,
-   13814, 13818, 13833, 13834, 13835, 13840, 13841, 13846, 13845, 13865,
-   13877, 13890, 13889, 13923, 13924, 13928, 13929, 13933, 13934, 13935,
-   13936, 13938, 13937, 13950, 13951, 13952, 13953, 13954, 13960, 13965,
-   13971, 13982, 13993, 13997, 14007, 14012, 14019, 14031, 14043, 14052,
-   14054, 14058, 14059, 14066, 14068, 14072, 14073, 14078, 14077, 14081,
-   14080, 14084, 14083, 14087, 14086, 14089, 14090, 14091, 14092, 14093,
-   14094, 14095, 14096, 14097, 14098, 14099, 14100, 14101, 14102, 14103,
-   14104, 14105, 14106, 14107, 14108, 14109, 14110, 14111, 14112, 14113,
-   14114, 14118, 14119, 14123, 14124, 14128, 14138, 14148, 14161, 14176,
-   14189, 14202, 14214, 14219, 14227, 14232, 14239, 14239, 14240, 14240,
-   14243, 14270, 14275, 14281, 14287, 14293, 14297, 14301, 14302, 14306,
-   14333, 14335, 14339, 14343, 14347, 14354, 14355, 14359, 14360, 14364,
-   14365, 14369, 14370, 14376, 14382, 14388, 14398, 14397, 14407, 14408,
-   14413, 14414, 14415, 14420, 14421, 14422, 14426, 14427, 14431, 14443,
-   14452, 14462, 14471, 14485, 14486, 14491, 14490, 14506, 14507, 14508,
-   14512, 14513, 14517, 14517, 14539, 14540, 14544, 14545, 14546, 14550,
-   14554, 14561, 14564, 14562, 14578, 14585, 14606, 14630, 14632, 14636,
-   14637, 14641, 14642, 14650, 14651, 14652, 14653, 14659, 14665, 14675,
-   14677, 14679, 14684, 14685, 14686, 14687, 14688, 14692, 14693, 14694,
-   14695, 14696, 14697, 14707, 14708, 14713, 14726, 14739, 14741, 14743,
-   14748, 14753, 14755, 14757, 14763, 14764, 14766, 14772, 14771, 14788,
-   14789, 14793, 14798, 14806, 14806, 14830, 14831, 14836, 14837, 14839,
-   14841, 14859, 14865, 14870, 14852, 14931, 14948, 14972, 15003, 15007,
-   15016, 15039, 14968, 15102, 15126, 15135, 15142, 15101, 15162, 15166,
-   15170, 15174, 15178, 15182, 15189, 15196, 15203, 15213, 15214, 15218,
-   15219, 15220, 15224, 15225, 15230, 15232, 15231, 15237, 15238, 15242,
-   15249, 15259, 15265, 15276
+   10584, 10587, 10590, 10589, 10632, 10633, 10637, 10638, 10642, 10652,
+   10652, 10662, 10663, 10667, 10686, 10719, 10718, 10731, 10739, 10730,
+   10741, 10753, 10765, 10764, 10782, 10781, 10792, 10792, 10808, 10815,
+   10837, 10857, 10869, 10874, 10873, 10883, 10889, 10896, 10901, 10906,
+   10916, 10917, 10921, 10932, 10933, 10937, 10948, 10949, 10953, 10954,
+   10962, 10970, 10961, 10980, 10987, 10979, 10997, 11005, 11006, 11014,
+   11018, 11019, 11030, 11031, 11035, 11044, 11045, 11046, 11048, 11047,
+   11058, 11059, 11063, 11064, 11066, 11065, 11069, 11068, 11074, 11075,
+   11079, 11080, 11084, 11094, 11095, 11099, 11100, 11105, 11104, 11118,
+   11119, 11123, 11128, 11136, 11137, 11145, 11147, 11147, 11155, 11163,
+   11154, 11185, 11186, 11190, 11198, 11199, 11203, 11213, 11214, 11221,
+   11220, 11236, 11235, 11247, 11246, 11258, 11257, 11271, 11272, 11276,
+   11289, 11305, 11306, 11310, 11311, 11315, 11316, 11317, 11322, 11321,
+   11342, 11344, 11347, 11349, 11352, 11353, 11356, 11360, 11364, 11368,
+   11372, 11376, 11380, 11384, 11388, 11396, 11399, 11409, 11408, 11423,
+   11430, 11438, 11446, 11454, 11462, 11470, 11477, 11479, 11481, 11490,
+   11494, 11499, 11498, 11504, 11503, 11508, 11517, 11524, 11533, 11542,
+   11547, 11549, 11551, 11553, 11555, 11557, 11564, 11572, 11574, 11582,
+   11589, 11596, 11606, 11613, 11619, 11627, 11635, 11639, 11643, 11650,
+   11657, 11664, 11671, 11678, 11685, 11691, 11698, 11705, 11710, 11715,
+   11723, 11725, 11727, 11732, 11733, 11736, 11738, 11742, 11743, 11747,
+   11748, 11752, 11753, 11757, 11758, 11762, 11763, 11766, 11768, 11775,
+   11786, 11785, 11801, 11800, 11810, 11811, 11815, 11816, 11817, 11821,
+   11822, 11823, 11838, 11837, 11850, 11859, 11849, 11861, 11865, 11866,
+   11880, 11881, 11886, 11888, 11890, 11892, 11894, 11896, 11898, 11900,
+   11902, 11904, 11906, 11908, 11913, 11915, 11917, 11919, 11921, 11923,
+   11925, 11930, 11931, 11935, 11936, 11940, 11939, 11949, 11950, 11954,
+   11954, 11956, 11957, 11961, 11962, 11967, 11966, 11977, 11981, 11985,
+   11998, 11997, 12011, 12012, 12013, 12016, 12017, 12018, 12022, 12027,
+   12037, 12049, 12060, 12070, 12080, 12048, 12088, 12089, 12093, 12094,
+   12098, 12099, 12107, 12111, 12112, 12113, 12116, 12118, 12122, 12123,
+   12127, 12132, 12139, 12144, 12151, 12153, 12157, 12158, 12162, 12167,
+   12175, 12176, 12179, 12181, 12189, 12191, 12195, 12196, 12197, 12201,
+   12203, 12208, 12209, 12218, 12219, 12223, 12224, 12228, 12241, 12264,
+   12276, 12287, 12306, 12314, 12326, 12334, 12349, 12369, 12370, 12371,
+   12379, 12380, 12381, 12388, 12394, 12400, 12406, 12412, 12418, 12447,
+   12475, 12476, 12477, 12481, 12491, 12501, 12507, 12516, 12531, 12532,
+   12536, 12545, 12560, 12564, 12610, 12614, 12631, 12635, 12713, 12737,
+   12767, 12768, 12784, 12794, 12798, 12804, 12810, 12820, 12826, 12835,
+   12845, 12846, 12874, 12888, 12902, 12917, 12918, 12928, 12929, 12939,
+   12940, 12941, 12945, 12961, 12982, 12997, 12998, 12999, 13000, 13001,
+   13002, 13003, 13004, 13005, 13006, 13007, 13008, 13009, 13010, 13011,
+   13012, 13013, 13014, 13015, 13016, 13017, 13018, 13019, 13020, 13021,
+   13022, 13023, 13024, 13025, 13026, 13027, 13028, 13029, 13030, 13031,
+   13032, 13033, 13034, 13035, 13036, 13037, 13038, 13039, 13040, 13041,
+   13042, 13043, 13044, 13045, 13046, 13047, 13048, 13049, 13050, 13051,
+   13052, 13053, 13054, 13055, 13065, 13066, 13067, 13068, 13069, 13070,
+   13071, 13072, 13073, 13074, 13075, 13076, 13077, 13078, 13079, 13080,
+   13081, 13082, 13083, 13084, 13085, 13086, 13087, 13088, 13089, 13090,
+   13091, 13092, 13093, 13094, 13095, 13096, 13097, 13098, 13099, 13100,
+   13101, 13102, 13103, 13104, 13105, 13106, 13107, 13108, 13109, 13110,
+   13111, 13112, 13113, 13114, 13115, 13116, 13117, 13118, 13119, 13120,
+   13121, 13122, 13123, 13124, 13125, 13126, 13127, 13128, 13129, 13130,
+   13131, 13132, 13133, 13134, 13135, 13136, 13137, 13138, 13139, 13140,
+   13141, 13142, 13143, 13144, 13145, 13146, 13147, 13148, 13149, 13150,
+   13151, 13152, 13153, 13154, 13155, 13156, 13157, 13158, 13159, 13160,
+   13161, 13162, 13163, 13164, 13165, 13166, 13167, 13168, 13169, 13170,
+   13171, 13172, 13173, 13174, 13175, 13176, 13177, 13178, 13179, 13180,
+   13181, 13182, 13183, 13184, 13185, 13186, 13187, 13188, 13189, 13190,
+   13191, 13192, 13193, 13194, 13195, 13196, 13197, 13198, 13199, 13200,
+   13201, 13202, 13203, 13204, 13205, 13206, 13207, 13208, 13209, 13210,
+   13211, 13212, 13213, 13214, 13215, 13216, 13217, 13218, 13219, 13220,
+   13221, 13222, 13223, 13224, 13225, 13226, 13227, 13228, 13229, 13230,
+   13231, 13232, 13233, 13234, 13235, 13236, 13237, 13238, 13239, 13240,
+   13241, 13242, 13243, 13244, 13245, 13246, 13247, 13248, 13249, 13250,
+   13251, 13252, 13253, 13254, 13255, 13256, 13257, 13258, 13259, 13260,
+   13261, 13262, 13263, 13264, 13265, 13266, 13267, 13268, 13269, 13270,
+   13271, 13272, 13273, 13274, 13275, 13276, 13277, 13278, 13279, 13280,
+   13281, 13282, 13283, 13284, 13285, 13286, 13287, 13288, 13289, 13290,
+   13291, 13292, 13293, 13294, 13295, 13296, 13297, 13298, 13299, 13300,
+   13301, 13302, 13303, 13304, 13305, 13306, 13307, 13308, 13309, 13310,
+   13311, 13312, 13313, 13314, 13315, 13316, 13317, 13318, 13319, 13320,
+   13321, 13322, 13323, 13324, 13325, 13326, 13327, 13328, 13329, 13330,
+   13331, 13332, 13333, 13334, 13335, 13336, 13337, 13338, 13339, 13340,
+   13341, 13342, 13343, 13344, 13345, 13346, 13347, 13348, 13349, 13350,
+   13351, 13352, 13353, 13354, 13355, 13356, 13357, 13364, 13363, 13378,
+   13379, 13383, 13384, 13388, 13388, 13468, 13469, 13470, 13471, 13475,
+   13476, 13480, 13481, 13482, 13483, 13487, 13488, 13489, 13490, 13494,
+   13495, 13499, 13540, 13558, 13569, 13581, 13594, 13609, 13628, 13654,
+   13667, 13693, 13736, 13750, 13751, 13752, 13753, 13757, 13758, 13767,
+   13779, 13780, 13781, 13787, 13793, 13805, 13804, 13820, 13821, 13825,
+   13826, 13830, 13845, 13846, 13847, 13852, 13853, 13858, 13857, 13877,
+   13889, 13902, 13901, 13935, 13936, 13940, 13941, 13945, 13946, 13947,
+   13948, 13950, 13949, 13962, 13963, 13964, 13965, 13966, 13972, 13977,
+   13983, 13994, 14005, 14009, 14019, 14024, 14031, 14043, 14055, 14064,
+   14066, 14070, 14071, 14078, 14080, 14084, 14085, 14090, 14089, 14093,
+   14092, 14096, 14095, 14099, 14098, 14101, 14102, 14103, 14104, 14105,
+   14106, 14107, 14108, 14109, 14110, 14111, 14112, 14113, 14114, 14115,
+   14116, 14117, 14118, 14119, 14120, 14121, 14122, 14123, 14124, 14125,
+   14126, 14130, 14131, 14135, 14136, 14140, 14150, 14160, 14173, 14188,
+   14201, 14214, 14226, 14231, 14239, 14244, 14251, 14251, 14252, 14252,
+   14255, 14282, 14287, 14293, 14299, 14305, 14309, 14313, 14314, 14318,
+   14345, 14347, 14351, 14355, 14359, 14366, 14367, 14371, 14372, 14376,
+   14377, 14381, 14382, 14388, 14394, 14400, 14410, 14409, 14419, 14420,
+   14425, 14426, 14427, 14432, 14433, 14434, 14438, 14439, 14443, 14455,
+   14464, 14474, 14483, 14497, 14498, 14503, 14502, 14518, 14519, 14520,
+   14524, 14525, 14529, 14529, 14551, 14552, 14556, 14557, 14558, 14562,
+   14566, 14573, 14576, 14574, 14590, 14597, 14618, 14642, 14644, 14648,
+   14649, 14653, 14654, 14662, 14663, 14664, 14665, 14671, 14677, 14687,
+   14689, 14691, 14696, 14697, 14698, 14699, 14700, 14704, 14705, 14706,
+   14707, 14708, 14709, 14719, 14720, 14725, 14738, 14751, 14753, 14755,
+   14760, 14765, 14767, 14769, 14775, 14776, 14778, 14784, 14783, 14800,
+   14801, 14805, 14810, 14818, 14818, 14842, 14843, 14848, 14849, 14851,
+   14853, 14871, 14877, 14882, 14864, 14943, 14960, 14984, 15015, 15019,
+   15028, 15051, 14980, 15114, 15138, 15147, 15154, 15113, 15174, 15178,
+   15182, 15186, 15190, 15194, 15201, 15208, 15215, 15225, 15226, 15230,
+   15231, 15232, 15236, 15237, 15242, 15244, 15243, 15249, 15250, 15254,
+   15261, 15271, 15277, 15288
 };
 #endif
 
@@ -31782,27 +31782,45 @@ yyreduce:
             if (add_proc_to_list(lex->thd, item))
               MYSQL_YYABORT;
             Lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+
+            /*
+              PROCEDURE CLAUSE cannot handle subquery as one of its parameter,
+              so set expr_allows_subselect as false to disallow any subqueries
+              further. Reset expr_allows_subselect back to true once the
+              parameters are reduced.
+            */
+            Lex->expr_allows_subselect= false;
+          }
+    break;
+
+  case 1573:
+
+/* Line 1455 of yacc.c  */
+#line 10625 "/home/buildbot/git/sql/sql_yacc.yy"
+    {
+            /* Subqueries are allowed from now.*/
+            Lex->expr_allows_subselect= true;
           }
     break;
 
   case 1574:
 
 /* Line 1455 of yacc.c  */
-#line 10620 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10632 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1575:
 
 /* Line 1455 of yacc.c  */
-#line 10621 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10633 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1578:
 
 /* Line 1455 of yacc.c  */
-#line 10631 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10643 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (add_proc_to_list(thd, (yyvsp[(2) - (3)].item)))
               MYSQL_YYABORT;
@@ -31814,7 +31832,7 @@ yyreduce:
   case 1579:
 
 /* Line 1455 of yacc.c  */
-#line 10640 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10652 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (!lex->describe && (!(lex->result= new select_dumpvar())))
@@ -31825,21 +31843,21 @@ yyreduce:
   case 1580:
 
 /* Line 1455 of yacc.c  */
-#line 10646 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10658 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1582:
 
 /* Line 1455 of yacc.c  */
-#line 10651 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10663 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1583:
 
 /* Line 1455 of yacc.c  */
-#line 10656 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10668 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->result) 
@@ -31863,7 +31881,7 @@ yyreduce:
   case 1584:
 
 /* Line 1455 of yacc.c  */
-#line 10675 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10687 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             sp_variable_t *t;
@@ -31897,7 +31915,7 @@ yyreduce:
   case 1585:
 
 /* Line 1455 of yacc.c  */
-#line 10707 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10719 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (! Lex->parsing_options.allows_select_into)
             {
@@ -31910,7 +31928,7 @@ yyreduce:
   case 1587:
 
 /* Line 1455 of yacc.c  */
-#line 10719 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10731 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
@@ -31923,14 +31941,14 @@ yyreduce:
   case 1588:
 
 /* Line 1455 of yacc.c  */
-#line 10727 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10739 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->exchange->cs= (yyvsp[(4) - (4)].charset); }
     break;
 
   case 1590:
 
 /* Line 1455 of yacc.c  */
-#line 10730 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10742 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (!lex->describe)
@@ -31947,7 +31965,7 @@ yyreduce:
   case 1591:
 
 /* Line 1455 of yacc.c  */
-#line 10742 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10754 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
           }
@@ -31956,7 +31974,7 @@ yyreduce:
   case 1592:
 
 /* Line 1455 of yacc.c  */
-#line 10753 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10765 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command = SQLCOM_DO;
@@ -31967,7 +31985,7 @@ yyreduce:
   case 1593:
 
 /* Line 1455 of yacc.c  */
-#line 10759 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10771 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->insert_list= (yyvsp[(3) - (3)].item_list);
           }
@@ -31976,7 +31994,7 @@ yyreduce:
   case 1594:
 
 /* Line 1455 of yacc.c  */
-#line 10770 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10782 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command = SQLCOM_DROP_TABLE;
@@ -31990,21 +32008,21 @@ yyreduce:
   case 1595:
 
 /* Line 1455 of yacc.c  */
-#line 10779 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10791 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1596:
 
 /* Line 1455 of yacc.c  */
-#line 10780 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10792 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1597:
 
 /* Line 1455 of yacc.c  */
-#line 10781 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10793 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             Alter_drop *ad= new Alter_drop(Alter_drop::KEY, (yyvsp[(3) - (6)].lex_str).str);
@@ -32025,7 +32043,7 @@ yyreduce:
   case 1598:
 
 /* Line 1455 of yacc.c  */
-#line 10797 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10809 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_DROP_DB;
@@ -32037,7 +32055,7 @@ yyreduce:
   case 1599:
 
 /* Line 1455 of yacc.c  */
-#line 10804 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10816 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             sp_name *spname;
@@ -32064,7 +32082,7 @@ yyreduce:
   case 1600:
 
 /* Line 1455 of yacc.c  */
-#line 10826 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10838 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             LEX_STRING db= {0, 0};
@@ -32089,7 +32107,7 @@ yyreduce:
   case 1601:
 
 /* Line 1455 of yacc.c  */
-#line 10846 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10858 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->sphead)
@@ -32106,7 +32124,7 @@ yyreduce:
   case 1602:
 
 /* Line 1455 of yacc.c  */
-#line 10858 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10870 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_DROP_USER;
           }
@@ -32115,7 +32133,7 @@ yyreduce:
   case 1603:
 
 /* Line 1455 of yacc.c  */
-#line 10862 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10874 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_DROP_VIEW;
@@ -32128,14 +32146,14 @@ yyreduce:
   case 1604:
 
 /* Line 1455 of yacc.c  */
-#line 10870 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10882 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1605:
 
 /* Line 1455 of yacc.c  */
-#line 10872 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10884 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->drop_if_exists= (yyvsp[(3) - (4)].num);
             Lex->spname= (yyvsp[(4) - (4)].spname);
@@ -32146,7 +32164,7 @@ yyreduce:
   case 1606:
 
 /* Line 1455 of yacc.c  */
-#line 10878 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10890 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_DROP_TRIGGER;
@@ -32158,7 +32176,7 @@ yyreduce:
   case 1607:
 
 /* Line 1455 of yacc.c  */
-#line 10885 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10897 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->alter_tablespace_info->ts_cmd_type= DROP_TABLESPACE;
@@ -32168,7 +32186,7 @@ yyreduce:
   case 1608:
 
 /* Line 1455 of yacc.c  */
-#line 10890 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10902 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->alter_tablespace_info->ts_cmd_type= DROP_LOGFILE_GROUP;
@@ -32178,7 +32196,7 @@ yyreduce:
   case 1609:
 
 /* Line 1455 of yacc.c  */
-#line 10895 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10907 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_DROP_SERVER;
             Lex->drop_if_exists= (yyvsp[(3) - (4)].num);
@@ -32190,7 +32208,7 @@ yyreduce:
   case 1612:
 
 /* Line 1455 of yacc.c  */
-#line 10910 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10922 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (!Select->add_table_to_list(thd, (yyvsp[(1) - (1)].table), NULL,
                                            TL_OPTION_UPDATING,
@@ -32203,7 +32221,7 @@ yyreduce:
   case 1615:
 
 /* Line 1455 of yacc.c  */
-#line 10926 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10938 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (!Select->add_table_to_list(thd, (yyvsp[(1) - (1)].table), NULL,
                                            TL_OPTION_UPDATING | TL_OPTION_ALIAS,
@@ -32216,35 +32234,35 @@ yyreduce:
   case 1616:
 
 /* Line 1455 of yacc.c  */
-#line 10936 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10948 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 0; }
     break;
 
   case 1617:
 
 /* Line 1455 of yacc.c  */
-#line 10937 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10949 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 1; }
     break;
 
   case 1618:
 
 /* Line 1455 of yacc.c  */
-#line 10941 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10953 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 0; }
     break;
 
   case 1619:
 
 /* Line 1455 of yacc.c  */
-#line 10942 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10954 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 1; }
     break;
 
   case 1620:
 
 /* Line 1455 of yacc.c  */
-#line 10950 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10962 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_INSERT;
@@ -32256,7 +32274,7 @@ yyreduce:
   case 1621:
 
 /* Line 1455 of yacc.c  */
-#line 10958 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10970 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Select->set_lock_for_tables((yyvsp[(3) - (5)].lock_type));
             Lex->current_select= &Lex->select_lex;
@@ -32266,14 +32284,14 @@ yyreduce:
   case 1622:
 
 /* Line 1455 of yacc.c  */
-#line 10963 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10975 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1623:
 
 /* Line 1455 of yacc.c  */
-#line 10968 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10980 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command = SQLCOM_REPLACE;
@@ -32285,7 +32303,7 @@ yyreduce:
   case 1624:
 
 /* Line 1455 of yacc.c  */
-#line 10975 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10987 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Select->set_lock_for_tables((yyvsp[(3) - (4)].lock_type));
             Lex->current_select= &Lex->select_lex;
@@ -32295,14 +32313,14 @@ yyreduce:
   case 1625:
 
 /* Line 1455 of yacc.c  */
-#line 10980 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10992 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1626:
 
 /* Line 1455 of yacc.c  */
-#line 10985 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 10997 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             /*
               If it is SP we do not allow insert optimisation when result of
@@ -32316,14 +32334,14 @@ yyreduce:
   case 1627:
 
 /* Line 1455 of yacc.c  */
-#line 10993 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11005 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= TL_WRITE_LOW_PRIORITY; }
     break;
 
   case 1628:
 
 /* Line 1455 of yacc.c  */
-#line 10995 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11007 "/home/buildbot/git/sql/sql_yacc.yy"
     {
           Lex->keyword_delayed_begin_offset= (uint)(YYLIP->get_tok_start() -
                                                     thd->query());
@@ -32336,21 +32354,21 @@ yyreduce:
   case 1629:
 
 /* Line 1455 of yacc.c  */
-#line 11002 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11014 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= TL_WRITE; }
     break;
 
   case 1630:
 
 /* Line 1455 of yacc.c  */
-#line 11006 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11018 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= (yyvsp[(1) - (1)].lock_type); }
     break;
 
   case 1631:
 
 /* Line 1455 of yacc.c  */
-#line 11008 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11020 "/home/buildbot/git/sql/sql_yacc.yy"
     {
           Lex->keyword_delayed_begin_offset= (uint)(YYLIP->get_tok_start() -
                                                     thd->query());
@@ -32363,21 +32381,21 @@ yyreduce:
   case 1632:
 
 /* Line 1455 of yacc.c  */
-#line 11018 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11030 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1633:
 
 /* Line 1455 of yacc.c  */
-#line 11019 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11031 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1634:
 
 /* Line 1455 of yacc.c  */
-#line 11024 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11036 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->field_list.empty();
@@ -32389,28 +32407,28 @@ yyreduce:
   case 1635:
 
 /* Line 1455 of yacc.c  */
-#line 11032 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11044 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1636:
 
 /* Line 1455 of yacc.c  */
-#line 11033 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11045 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1637:
 
 /* Line 1455 of yacc.c  */
-#line 11034 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11046 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1638:
 
 /* Line 1455 of yacc.c  */
-#line 11036 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11048 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (!(lex->insert_list = new List_item) ||
@@ -32422,63 +32440,63 @@ yyreduce:
   case 1640:
 
 /* Line 1455 of yacc.c  */
-#line 11046 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11058 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->field_list.push_back((yyvsp[(3) - (3)].item)); }
     break;
 
   case 1641:
 
 /* Line 1455 of yacc.c  */
-#line 11047 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11059 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->field_list.push_back((yyvsp[(1) - (1)].item)); }
     break;
 
   case 1642:
 
 /* Line 1455 of yacc.c  */
-#line 11051 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11063 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1643:
 
 /* Line 1455 of yacc.c  */
-#line 11052 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11064 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1644:
 
 /* Line 1455 of yacc.c  */
-#line 11054 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11066 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->set_braces(0);}
     break;
 
   case 1645:
 
 /* Line 1455 of yacc.c  */
-#line 11055 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11067 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1646:
 
 /* Line 1455 of yacc.c  */
-#line 11057 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11069 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->set_braces(1);}
     break;
 
   case 1647:
 
 /* Line 1455 of yacc.c  */
-#line 11058 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11070 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1652:
 
 /* Line 1455 of yacc.c  */
-#line 11073 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11085 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->field_list.push_back((yyvsp[(1) - (3)].item)) ||
@@ -32490,35 +32508,35 @@ yyreduce:
   case 1653:
 
 /* Line 1455 of yacc.c  */
-#line 11082 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11094 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1654:
 
 /* Line 1455 of yacc.c  */
-#line 11083 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11095 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1655:
 
 /* Line 1455 of yacc.c  */
-#line 11087 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11099 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1656:
 
 /* Line 1455 of yacc.c  */
-#line 11088 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11100 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1657:
 
 /* Line 1455 of yacc.c  */
-#line 11093 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11105 "/home/buildbot/git/sql/sql_yacc.yy"
     {
               if (!(Lex->insert_list = new List_item))
                 MYSQL_YYABORT;
@@ -32528,7 +32546,7 @@ yyreduce:
   case 1658:
 
 /* Line 1455 of yacc.c  */
-#line 11098 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11110 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->many_values.push_back(lex->insert_list))
@@ -32539,14 +32557,14 @@ yyreduce:
   case 1659:
 
 /* Line 1455 of yacc.c  */
-#line 11106 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11118 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1661:
 
 /* Line 1455 of yacc.c  */
-#line 11112 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11124 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (Lex->insert_list->push_back((yyvsp[(3) - (3)].item)))
               MYSQL_YYABORT;
@@ -32556,7 +32574,7 @@ yyreduce:
   case 1662:
 
 /* Line 1455 of yacc.c  */
-#line 11117 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11129 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (Lex->insert_list->push_back((yyvsp[(1) - (1)].item)))
               MYSQL_YYABORT;
@@ -32566,14 +32584,14 @@ yyreduce:
   case 1663:
 
 /* Line 1455 of yacc.c  */
-#line 11124 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11136 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)= (yyvsp[(1) - (1)].item);}
     break;
 
   case 1664:
 
 /* Line 1455 of yacc.c  */
-#line 11126 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11138 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)= new (thd->mem_root) Item_default_value(Lex->current_context());
             if ((yyval.item) == NULL)
@@ -32584,14 +32602,14 @@ yyreduce:
   case 1666:
 
 /* Line 1455 of yacc.c  */
-#line 11135 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11147 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->duplicates= DUP_UPDATE; }
     break;
 
   case 1668:
 
 /* Line 1455 of yacc.c  */
-#line 11143 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11155 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             mysql_init_select(lex);
@@ -32603,7 +32621,7 @@ yyreduce:
   case 1669:
 
 /* Line 1455 of yacc.c  */
-#line 11151 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11163 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->select_lex.table_list.elements > 1)
@@ -32627,14 +32645,14 @@ yyreduce:
   case 1670:
 
 /* Line 1455 of yacc.c  */
-#line 11169 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11181 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1673:
 
 /* Line 1455 of yacc.c  */
-#line 11179 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11191 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (add_item_to_list(thd, (yyvsp[(1) - (3)].item)) || add_value_to_list(thd, (yyvsp[(3) - (3)].item)))
               MYSQL_YYABORT;
@@ -32644,7 +32662,7 @@ yyreduce:
   case 1676:
 
 /* Line 1455 of yacc.c  */
-#line 11192 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11204 "/home/buildbot/git/sql/sql_yacc.yy"
     {
           LEX *lex= Lex;
           if (lex->update_list.push_back((yyvsp[(1) - (3)].item)) || 
@@ -32656,21 +32674,21 @@ yyreduce:
   case 1677:
 
 /* Line 1455 of yacc.c  */
-#line 11201 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11213 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= TL_WRITE_DEFAULT; }
     break;
 
   case 1678:
 
 /* Line 1455 of yacc.c  */
-#line 11202 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11214 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= TL_WRITE_LOW_PRIORITY; }
     break;
 
   case 1679:
 
 /* Line 1455 of yacc.c  */
-#line 11209 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11221 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_DELETE;
@@ -32686,7 +32704,7 @@ yyreduce:
   case 1681:
 
 /* Line 1455 of yacc.c  */
-#line 11224 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11236 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (!Select->add_table_to_list(thd, (yyvsp[(2) - (2)].table), NULL, TL_OPTION_UPDATING,
                                            YYPS->m_lock_type,
@@ -32700,14 +32718,14 @@ yyreduce:
   case 1682:
 
 /* Line 1455 of yacc.c  */
-#line 11233 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11245 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1683:
 
 /* Line 1455 of yacc.c  */
-#line 11235 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11247 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             mysql_init_multi_delete(Lex);
             YYPS->m_lock_type= TL_READ_DEFAULT;
@@ -32718,7 +32736,7 @@ yyreduce:
   case 1684:
 
 /* Line 1455 of yacc.c  */
-#line 11241 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11253 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (multi_delete_set_locks_and_link_aux_tables(Lex))
               MYSQL_YYABORT;
@@ -32728,7 +32746,7 @@ yyreduce:
   case 1685:
 
 /* Line 1455 of yacc.c  */
-#line 11246 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11258 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             mysql_init_multi_delete(Lex);
             YYPS->m_lock_type= TL_READ_DEFAULT;
@@ -32739,7 +32757,7 @@ yyreduce:
   case 1686:
 
 /* Line 1455 of yacc.c  */
-#line 11252 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11264 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (multi_delete_set_locks_and_link_aux_tables(Lex))
               MYSQL_YYABORT;
@@ -32749,7 +32767,7 @@ yyreduce:
   case 1689:
 
 /* Line 1455 of yacc.c  */
-#line 11265 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11277 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Table_ident *ti= new Table_ident((yyvsp[(1) - (2)].lex_str));
             if (ti == NULL)
@@ -32767,7 +32785,7 @@ yyreduce:
   case 1690:
 
 /* Line 1455 of yacc.c  */
-#line 11278 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11290 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Table_ident *ti= new Table_ident(thd, (yyvsp[(1) - (4)].lex_str), (yyvsp[(3) - (4)].lex_str), 0);
             if (ti == NULL)
@@ -32785,56 +32803,56 @@ yyreduce:
   case 1691:
 
 /* Line 1455 of yacc.c  */
-#line 11293 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11305 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1692:
 
 /* Line 1455 of yacc.c  */
-#line 11294 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11306 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1693:
 
 /* Line 1455 of yacc.c  */
-#line 11298 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11310 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1694:
 
 /* Line 1455 of yacc.c  */
-#line 11299 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11311 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1695:
 
 /* Line 1455 of yacc.c  */
-#line 11303 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11315 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->options|= OPTION_QUICK; }
     break;
 
   case 1696:
 
 /* Line 1455 of yacc.c  */
-#line 11304 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11316 "/home/buildbot/git/sql/sql_yacc.yy"
     { YYPS->m_lock_type= TL_WRITE_LOW_PRIORITY; }
     break;
 
   case 1697:
 
 /* Line 1455 of yacc.c  */
-#line 11305 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11317 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ignore= 1; }
     break;
 
   case 1698:
 
 /* Line 1455 of yacc.c  */
-#line 11310 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11322 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX* lex= Lex;
             lex->sql_command= SQLCOM_TRUNCATE;
@@ -32850,7 +32868,7 @@ yyreduce:
   case 1699:
 
 /* Line 1455 of yacc.c  */
-#line 11321 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11333 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX* lex= thd->lex;
             DBUG_ASSERT(!lex->m_stmt);
@@ -32863,7 +32881,7 @@ yyreduce:
   case 1706:
 
 /* Line 1455 of yacc.c  */
-#line 11345 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11357 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_CPU;
     }
@@ -32872,7 +32890,7 @@ yyreduce:
   case 1707:
 
 /* Line 1455 of yacc.c  */
-#line 11349 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11361 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_MEMORY;
     }
@@ -32881,7 +32899,7 @@ yyreduce:
   case 1708:
 
 /* Line 1455 of yacc.c  */
-#line 11353 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11365 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_BLOCK_IO;
     }
@@ -32890,7 +32908,7 @@ yyreduce:
   case 1709:
 
 /* Line 1455 of yacc.c  */
-#line 11357 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11369 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_CONTEXT;
     }
@@ -32899,7 +32917,7 @@ yyreduce:
   case 1710:
 
 /* Line 1455 of yacc.c  */
-#line 11361 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11373 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_PAGE_FAULTS;
     }
@@ -32908,7 +32926,7 @@ yyreduce:
   case 1711:
 
 /* Line 1455 of yacc.c  */
-#line 11365 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11377 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_IPC;
     }
@@ -32917,7 +32935,7 @@ yyreduce:
   case 1712:
 
 /* Line 1455 of yacc.c  */
-#line 11369 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11381 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_SWAPS;
     }
@@ -32926,7 +32944,7 @@ yyreduce:
   case 1713:
 
 /* Line 1455 of yacc.c  */
-#line 11373 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11385 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_SOURCE;
     }
@@ -32935,7 +32953,7 @@ yyreduce:
   case 1714:
 
 /* Line 1455 of yacc.c  */
-#line 11377 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11389 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_options|= PROFILE_ALL;
     }
@@ -32944,7 +32962,7 @@ yyreduce:
   case 1715:
 
 /* Line 1455 of yacc.c  */
-#line 11384 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11396 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_query_id= 0;
     }
@@ -32953,7 +32971,7 @@ yyreduce:
   case 1716:
 
 /* Line 1455 of yacc.c  */
-#line 11388 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11400 "/home/buildbot/git/sql/sql_yacc.yy"
     {
       Lex->profile_query_id= atoi((yyvsp[(3) - (3)].lex_str).str);
     }
@@ -32962,7 +32980,7 @@ yyreduce:
   case 1717:
 
 /* Line 1455 of yacc.c  */
-#line 11397 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11409 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->wild=0;
@@ -32975,7 +32993,7 @@ yyreduce:
   case 1718:
 
 /* Line 1455 of yacc.c  */
-#line 11405 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11417 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Select->parsing_place= NO_MATTER;
           }
@@ -32984,7 +33002,7 @@ yyreduce:
   case 1719:
 
 /* Line 1455 of yacc.c  */
-#line 11412 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11424 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_DATABASES;
@@ -32996,7 +33014,7 @@ yyreduce:
   case 1720:
 
 /* Line 1455 of yacc.c  */
-#line 11419 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11431 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_TABLES;
@@ -33009,7 +33027,7 @@ yyreduce:
   case 1721:
 
 /* Line 1455 of yacc.c  */
-#line 11427 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11439 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_TRIGGERS;
@@ -33022,7 +33040,7 @@ yyreduce:
   case 1722:
 
 /* Line 1455 of yacc.c  */
-#line 11435 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11447 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_EVENTS;
@@ -33035,7 +33053,7 @@ yyreduce:
   case 1723:
 
 /* Line 1455 of yacc.c  */
-#line 11443 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11455 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_TABLE_STATUS;
@@ -33048,7 +33066,7 @@ yyreduce:
   case 1724:
 
 /* Line 1455 of yacc.c  */
-#line 11451 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11463 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_OPEN_TABLES;
@@ -33061,7 +33079,7 @@ yyreduce:
   case 1725:
 
 /* Line 1455 of yacc.c  */
-#line 11459 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11471 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_PLUGINS;
@@ -33073,21 +33091,21 @@ yyreduce:
   case 1726:
 
 /* Line 1455 of yacc.c  */
-#line 11466 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11478 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_info.db_type= (yyvsp[(2) - (3)].db_type); }
     break;
 
   case 1727:
 
 /* Line 1455 of yacc.c  */
-#line 11468 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11480 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_info.db_type= NULL; }
     break;
 
   case 1728:
 
 /* Line 1455 of yacc.c  */
-#line 11470 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11482 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_FIELDS;
@@ -33101,7 +33119,7 @@ yyreduce:
   case 1729:
 
 /* Line 1455 of yacc.c  */
-#line 11479 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11491 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_SHOW_BINLOGS;
           }
@@ -33110,7 +33128,7 @@ yyreduce:
   case 1730:
 
 /* Line 1455 of yacc.c  */
-#line 11483 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11495 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_SHOW_SLAVE_HOSTS;
           }
@@ -33119,7 +33137,7 @@ yyreduce:
   case 1731:
 
 /* Line 1455 of yacc.c  */
-#line 11487 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11499 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
@@ -33129,7 +33147,7 @@ yyreduce:
   case 1733:
 
 /* Line 1455 of yacc.c  */
-#line 11492 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11504 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_RELAYLOG_EVENTS;
@@ -33139,7 +33157,7 @@ yyreduce:
   case 1735:
 
 /* Line 1455 of yacc.c  */
-#line 11497 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11509 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_KEYS;
@@ -33153,7 +33171,7 @@ yyreduce:
   case 1736:
 
 /* Line 1455 of yacc.c  */
-#line 11506 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11518 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
@@ -33165,7 +33183,7 @@ yyreduce:
   case 1737:
 
 /* Line 1455 of yacc.c  */
-#line 11513 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11525 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SHOW_AUTHORS;
@@ -33179,7 +33197,7 @@ yyreduce:
   case 1738:
 
 /* Line 1455 of yacc.c  */
-#line 11522 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11534 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SHOW_CONTRIBUTORS;
@@ -33193,7 +33211,7 @@ yyreduce:
   case 1739:
 
 /* Line 1455 of yacc.c  */
-#line 11531 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11543 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SHOW_PRIVILEGES;
@@ -33203,42 +33221,42 @@ yyreduce:
   case 1740:
 
 /* Line 1455 of yacc.c  */
-#line 11536 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11548 "/home/buildbot/git/sql/sql_yacc.yy"
     { (void) create_select_for_variable("warning_count"); }
     break;
 
   case 1741:
 
 /* Line 1455 of yacc.c  */
-#line 11538 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11550 "/home/buildbot/git/sql/sql_yacc.yy"
     { (void) create_select_for_variable("error_count"); }
     break;
 
   case 1742:
 
 /* Line 1455 of yacc.c  */
-#line 11540 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11552 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command = SQLCOM_SHOW_WARNS;}
     break;
 
   case 1743:
 
 /* Line 1455 of yacc.c  */
-#line 11542 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11554 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command = SQLCOM_SHOW_ERRORS;}
     break;
 
   case 1744:
 
 /* Line 1455 of yacc.c  */
-#line 11544 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11556 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command = SQLCOM_SHOW_PROFILES; }
     break;
 
   case 1745:
 
 /* Line 1455 of yacc.c  */
-#line 11546 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11558 "/home/buildbot/git/sql/sql_yacc.yy"
     { 
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_PROFILE;
@@ -33250,7 +33268,7 @@ yyreduce:
   case 1746:
 
 /* Line 1455 of yacc.c  */
-#line 11553 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11565 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_STATUS;
@@ -33263,14 +33281,14 @@ yyreduce:
   case 1747:
 
 /* Line 1455 of yacc.c  */
-#line 11561 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11573 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
     break;
 
   case 1748:
 
 /* Line 1455 of yacc.c  */
-#line 11563 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11575 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_VARIABLES;
@@ -33283,7 +33301,7 @@ yyreduce:
   case 1749:
 
 /* Line 1455 of yacc.c  */
-#line 11571 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11583 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_CHARSETS;
@@ -33295,7 +33313,7 @@ yyreduce:
   case 1750:
 
 /* Line 1455 of yacc.c  */
-#line 11578 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11590 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_COLLATIONS;
@@ -33307,7 +33325,7 @@ yyreduce:
   case 1751:
 
 /* Line 1455 of yacc.c  */
-#line 11585 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11597 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SHOW_GRANTS;
@@ -33322,7 +33340,7 @@ yyreduce:
   case 1752:
 
 /* Line 1455 of yacc.c  */
-#line 11595 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11607 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SHOW_GRANTS;
@@ -33334,7 +33352,7 @@ yyreduce:
   case 1753:
 
 /* Line 1455 of yacc.c  */
-#line 11602 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11614 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command=SQLCOM_SHOW_CREATE_DB;
             Lex->create_info.options=(yyvsp[(3) - (4)].num);
@@ -33345,7 +33363,7 @@ yyreduce:
   case 1754:
 
 /* Line 1455 of yacc.c  */
-#line 11608 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11620 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command = SQLCOM_SHOW_CREATE;
@@ -33358,7 +33376,7 @@ yyreduce:
   case 1755:
 
 /* Line 1455 of yacc.c  */
-#line 11616 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11628 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command = SQLCOM_SHOW_CREATE;
@@ -33371,7 +33389,7 @@ yyreduce:
   case 1756:
 
 /* Line 1455 of yacc.c  */
-#line 11624 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11636 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_SHOW_MASTER_STAT;
           }
@@ -33380,7 +33398,7 @@ yyreduce:
   case 1757:
 
 /* Line 1455 of yacc.c  */
-#line 11628 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11640 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
           }
@@ -33389,7 +33407,7 @@ yyreduce:
   case 1758:
 
 /* Line 1455 of yacc.c  */
-#line 11632 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11644 "/home/buildbot/git/sql/sql_yacc.yy"
     {
            LEX *lex= Lex;
            lex->sql_command= SQLCOM_SHOW_CLIENT_STATS;
@@ -33401,7 +33419,7 @@ yyreduce:
   case 1759:
 
 /* Line 1455 of yacc.c  */
-#line 11639 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11651 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_USER_STATS;
@@ -33413,7 +33431,7 @@ yyreduce:
   case 1760:
 
 /* Line 1455 of yacc.c  */
-#line 11646 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11658 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_TABLE_STATS;
@@ -33425,7 +33443,7 @@ yyreduce:
   case 1761:
 
 /* Line 1455 of yacc.c  */
-#line 11653 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11665 "/home/buildbot/git/sql/sql_yacc.yy"
     {
              LEX *lex= Lex;
              lex->sql_command= SQLCOM_SHOW_INDEX_STATS;
@@ -33437,7 +33455,7 @@ yyreduce:
   case 1762:
 
 /* Line 1455 of yacc.c  */
-#line 11660 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11672 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
 
@@ -33449,7 +33467,7 @@ yyreduce:
   case 1763:
 
 /* Line 1455 of yacc.c  */
-#line 11667 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11679 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
 
@@ -33461,7 +33479,7 @@ yyreduce:
   case 1764:
 
 /* Line 1455 of yacc.c  */
-#line 11674 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11686 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_CREATE_TRIGGER;
@@ -33472,7 +33490,7 @@ yyreduce:
   case 1765:
 
 /* Line 1455 of yacc.c  */
-#line 11680 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11692 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_STATUS_PROC;
@@ -33484,7 +33502,7 @@ yyreduce:
   case 1766:
 
 /* Line 1455 of yacc.c  */
-#line 11687 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11699 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_SHOW_STATUS_FUNC;
@@ -33496,7 +33514,7 @@ yyreduce:
   case 1767:
 
 /* Line 1455 of yacc.c  */
-#line 11694 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11706 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command= SQLCOM_SHOW_PROC_CODE;
             Lex->spname= (yyvsp[(3) - (3)].spname);
@@ -33506,7 +33524,7 @@ yyreduce:
   case 1768:
 
 /* Line 1455 of yacc.c  */
-#line 11699 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11711 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command= SQLCOM_SHOW_FUNC_CODE;
             Lex->spname= (yyvsp[(3) - (3)].spname);
@@ -33516,7 +33534,7 @@ yyreduce:
   case 1769:
 
 /* Line 1455 of yacc.c  */
-#line 11704 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11716 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->spname= (yyvsp[(3) - (3)].spname);
             Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT;
@@ -33526,84 +33544,84 @@ yyreduce:
   case 1770:
 
 /* Line 1455 of yacc.c  */
-#line 11712 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11724 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command= SQLCOM_SHOW_ENGINE_STATUS; }
     break;
 
   case 1771:
 
 /* Line 1455 of yacc.c  */
-#line 11714 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11726 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command= SQLCOM_SHOW_ENGINE_MUTEX; }
     break;
 
   case 1772:
 
 /* Line 1455 of yacc.c  */
-#line 11716 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11728 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->sql_command= SQLCOM_SHOW_ENGINE_LOGS; }
     break;
 
   case 1777:
 
 /* Line 1455 of yacc.c  */
-#line 11730 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11742 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.simple_string)= 0; }
     break;
 
   case 1778:
 
 /* Line 1455 of yacc.c  */
-#line 11731 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11743 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.simple_string)= (yyvsp[(2) - (2)].lex_str).str; }
     break;
 
   case 1779:
 
 /* Line 1455 of yacc.c  */
-#line 11735 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11747 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->verbose=0; }
     break;
 
   case 1780:
 
 /* Line 1455 of yacc.c  */
-#line 11736 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11748 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->verbose=1; }
     break;
 
   case 1783:
 
 /* Line 1455 of yacc.c  */
-#line 11745 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11757 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->mi.log_file_name = 0; }
     break;
 
   case 1784:
 
 /* Line 1455 of yacc.c  */
-#line 11746 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11758 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->mi.log_file_name = (yyvsp[(2) - (2)].lex_str).str; }
     break;
 
   case 1785:
 
 /* Line 1455 of yacc.c  */
-#line 11750 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11762 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->mi.pos = 4; /* skip magic number */ }
     break;
 
   case 1786:
 
 /* Line 1455 of yacc.c  */
-#line 11751 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11763 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->mi.pos = (yyvsp[(2) - (2)].ulonglong_number); }
     break;
 
   case 1788:
 
 /* Line 1455 of yacc.c  */
-#line 11757 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11769 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->wild= new (thd->mem_root) String((yyvsp[(2) - (2)].lex_str).str, (yyvsp[(2) - (2)].lex_str).length,
                                                     system_charset_info);
@@ -33615,7 +33633,7 @@ yyreduce:
   case 1789:
 
 /* Line 1455 of yacc.c  */
-#line 11764 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11776 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Select->where= normalize_cond((yyvsp[(2) - (2)].item));
             if ((yyvsp[(2) - (2)].item))
@@ -33626,7 +33644,7 @@ yyreduce:
   case 1790:
 
 /* Line 1455 of yacc.c  */
-#line 11774 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11786 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             mysql_init_select(lex);
@@ -33642,7 +33660,7 @@ yyreduce:
   case 1791:
 
 /* Line 1455 of yacc.c  */
-#line 11785 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11797 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Select->parsing_place= NO_MATTER;
           }
@@ -33651,14 +33669,14 @@ yyreduce:
   case 1792:
 
 /* Line 1455 of yacc.c  */
-#line 11789 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11801 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->describe|= DESCRIBE_NORMAL; }
     break;
 
   case 1793:
 
 /* Line 1455 of yacc.c  */
-#line 11791 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11803 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->select_lex.options|= SELECT_DESCRIBE;
@@ -33668,42 +33686,42 @@ yyreduce:
   case 1796:
 
 /* Line 1455 of yacc.c  */
-#line 11803 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11815 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1797:
 
 /* Line 1455 of yacc.c  */
-#line 11804 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11816 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->describe|= DESCRIBE_EXTENDED; }
     break;
 
   case 1798:
 
 /* Line 1455 of yacc.c  */
-#line 11805 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11817 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->describe|= DESCRIBE_PARTITIONS; }
     break;
 
   case 1799:
 
 /* Line 1455 of yacc.c  */
-#line 11809 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11821 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1800:
 
 /* Line 1455 of yacc.c  */
-#line 11810 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11822 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->wild= (yyvsp[(1) - (1)].string); }
     break;
 
   case 1801:
 
 /* Line 1455 of yacc.c  */
-#line 11812 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11824 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->wild= new (thd->mem_root) String((const char*) (yyvsp[(1) - (1)].lex_str).str,
                                                     (yyvsp[(1) - (1)].lex_str).length,
@@ -33716,7 +33734,7 @@ yyreduce:
   case 1802:
 
 /* Line 1455 of yacc.c  */
-#line 11826 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11838 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_FLUSH;
@@ -33728,14 +33746,14 @@ yyreduce:
   case 1803:
 
 /* Line 1455 of yacc.c  */
-#line 11833 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11845 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1804:
 
 /* Line 1455 of yacc.c  */
-#line 11838 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11850 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->type|= REFRESH_TABLES;
             /*
@@ -33750,28 +33768,28 @@ yyreduce:
   case 1805:
 
 /* Line 1455 of yacc.c  */
-#line 11847 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11859 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1806:
 
 /* Line 1455 of yacc.c  */
-#line 11848 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11860 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1808:
 
 /* Line 1455 of yacc.c  */
-#line 11853 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11865 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1809:
 
 /* Line 1455 of yacc.c  */
-#line 11855 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11867 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             TABLE_LIST *tables= Lex->query_tables;
             Lex->type|= REFRESH_READ_LOCK | (yyvsp[(4) - (4)].num);
@@ -33787,91 +33805,91 @@ yyreduce:
   case 1811:
 
 /* Line 1455 of yacc.c  */
-#line 11870 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11882 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1812:
 
 /* Line 1455 of yacc.c  */
-#line 11875 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11887 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_ERROR_LOG; }
     break;
 
   case 1813:
 
 /* Line 1455 of yacc.c  */
-#line 11877 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11889 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_ENGINE_LOG; }
     break;
 
   case 1814:
 
 /* Line 1455 of yacc.c  */
-#line 11879 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11891 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_GENERAL_LOG; }
     break;
 
   case 1815:
 
 /* Line 1455 of yacc.c  */
-#line 11881 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11893 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_SLOW_LOG; }
     break;
 
   case 1816:
 
 /* Line 1455 of yacc.c  */
-#line 11883 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11895 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_BINARY_LOG; }
     break;
 
   case 1817:
 
 /* Line 1455 of yacc.c  */
-#line 11885 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11897 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_RELAY_LOG; }
     break;
 
   case 1818:
 
 /* Line 1455 of yacc.c  */
-#line 11887 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11899 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_QUERY_CACHE_FREE; }
     break;
 
   case 1819:
 
 /* Line 1455 of yacc.c  */
-#line 11889 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11901 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_HOSTS; }
     break;
 
   case 1820:
 
 /* Line 1455 of yacc.c  */
-#line 11891 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11903 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_GRANT; }
     break;
 
   case 1821:
 
 /* Line 1455 of yacc.c  */
-#line 11893 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11905 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_LOG; }
     break;
 
   case 1822:
 
 /* Line 1455 of yacc.c  */
-#line 11895 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11907 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_STATUS; }
     break;
 
   case 1823:
 
 /* Line 1455 of yacc.c  */
-#line 11897 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11909 "/home/buildbot/git/sql/sql_yacc.yy"
     { 
             Lex->type|= REFRESH_SLAVE;
             Lex->reset_slave_info.all= false;
@@ -33881,84 +33899,84 @@ yyreduce:
   case 1824:
 
 /* Line 1455 of yacc.c  */
-#line 11902 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11914 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_CLIENT_STATS; }
     break;
 
   case 1825:
 
 /* Line 1455 of yacc.c  */
-#line 11904 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11916 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_USER_STATS; }
     break;
 
   case 1826:
 
 /* Line 1455 of yacc.c  */
-#line 11906 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11918 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_TABLE_STATS; }
     break;
 
   case 1827:
 
 /* Line 1455 of yacc.c  */
-#line 11908 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11920 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_INDEX_STATS; }
     break;
 
   case 1828:
 
 /* Line 1455 of yacc.c  */
-#line 11910 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11922 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_MASTER; }
     break;
 
   case 1829:
 
 /* Line 1455 of yacc.c  */
-#line 11912 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11924 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_DES_KEY_FILE; }
     break;
 
   case 1830:
 
 /* Line 1455 of yacc.c  */
-#line 11914 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11926 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_USER_RESOURCES; }
     break;
 
   case 1831:
 
 /* Line 1455 of yacc.c  */
-#line 11918 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11930 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1832:
 
 /* Line 1455 of yacc.c  */
-#line 11919 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11931 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1833:
 
 /* Line 1455 of yacc.c  */
-#line 11923 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11935 "/home/buildbot/git/sql/sql_yacc.yy"
     {(yyval.num)= 0;}
     break;
 
   case 1834:
 
 /* Line 1455 of yacc.c  */
-#line 11924 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11936 "/home/buildbot/git/sql/sql_yacc.yy"
     {(yyval.num)= REFRESH_CHECKPOINT; }
     break;
 
   case 1835:
 
 /* Line 1455 of yacc.c  */
-#line 11928 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11940 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_RESET; lex->type=0;
@@ -33968,56 +33986,56 @@ yyreduce:
   case 1836:
 
 /* Line 1455 of yacc.c  */
-#line 11933 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11945 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1839:
 
 /* Line 1455 of yacc.c  */
-#line 11942 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11954 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_SLAVE; }
     break;
 
   case 1840:
 
 /* Line 1455 of yacc.c  */
-#line 11943 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11955 "/home/buildbot/git/sql/sql_yacc.yy"
     { }
     break;
 
   case 1841:
 
 /* Line 1455 of yacc.c  */
-#line 11944 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11956 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_MASTER; }
     break;
 
   case 1842:
 
 /* Line 1455 of yacc.c  */
-#line 11945 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11957 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->type|= REFRESH_QUERY_CACHE;}
     break;
 
   case 1843:
 
 /* Line 1455 of yacc.c  */
-#line 11949 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11961 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->reset_slave_info.all= false; }
     break;
 
   case 1844:
 
 /* Line 1455 of yacc.c  */
-#line 11950 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11962 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->reset_slave_info.all= true; }
     break;
 
   case 1845:
 
 /* Line 1455 of yacc.c  */
-#line 11955 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11967 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->type=0;
@@ -34028,14 +34046,14 @@ yyreduce:
   case 1846:
 
 /* Line 1455 of yacc.c  */
-#line 11961 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11973 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1848:
 
 /* Line 1455 of yacc.c  */
-#line 11970 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11982 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->to_log = (yyvsp[(2) - (2)].lex_str).str;
           }
@@ -34044,7 +34062,7 @@ yyreduce:
   case 1849:
 
 /* Line 1455 of yacc.c  */
-#line 11974 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11986 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->value_list.empty();
@@ -34056,7 +34074,7 @@ yyreduce:
   case 1850:
 
 /* Line 1455 of yacc.c  */
-#line 11986 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 11998 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->value_list.empty();
@@ -34068,7 +34086,7 @@ yyreduce:
   case 1851:
 
 /* Line 1455 of yacc.c  */
-#line 11993 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12005 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->kill_signal= (killed_state) ((yyvsp[(3) - (5)].num) | (yyvsp[(4) - (5)].num));
           }
@@ -34077,49 +34095,49 @@ yyreduce:
   case 1852:
 
 /* Line 1455 of yacc.c  */
-#line 11999 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12011 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= (int) KILL_HARD_BIT; }
     break;
 
   case 1853:
 
 /* Line 1455 of yacc.c  */
-#line 12000 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12012 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= (int) KILL_HARD_BIT; }
     break;
 
   case 1854:
 
 /* Line 1455 of yacc.c  */
-#line 12001 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12013 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 0; }
     break;
 
   case 1855:
 
 /* Line 1455 of yacc.c  */
-#line 12004 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12016 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= (int) KILL_CONNECTION; }
     break;
 
   case 1856:
 
 /* Line 1455 of yacc.c  */
-#line 12005 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12017 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= (int) KILL_CONNECTION; }
     break;
 
   case 1857:
 
 /* Line 1455 of yacc.c  */
-#line 12006 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12018 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= (int) KILL_QUERY; }
     break;
 
   case 1858:
 
 /* Line 1455 of yacc.c  */
-#line 12011 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12023 "/home/buildbot/git/sql/sql_yacc.yy"
     {
           Lex->value_list.push_front((yyval.item));
           Lex->kill_type= KILL_TYPE_ID;
@@ -34129,7 +34147,7 @@ yyreduce:
   case 1859:
 
 /* Line 1455 of yacc.c  */
-#line 12016 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12028 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->users_list.push_back((yyvsp[(2) - (2)].lex_user));
             Lex->kill_type= KILL_TYPE_USER;
@@ -34139,7 +34157,7 @@ yyreduce:
   case 1860:
 
 /* Line 1455 of yacc.c  */
-#line 12026 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12038 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command=SQLCOM_CHANGE_DB;
@@ -34150,7 +34168,7 @@ yyreduce:
   case 1861:
 
 /* Line 1455 of yacc.c  */
-#line 12037 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12049 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
 
@@ -34166,7 +34184,7 @@ yyreduce:
   case 1862:
 
 /* Line 1455 of yacc.c  */
-#line 12048 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12060 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_LOAD;
@@ -34181,7 +34199,7 @@ yyreduce:
   case 1863:
 
 /* Line 1455 of yacc.c  */
-#line 12058 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12070 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (!Select->add_table_to_list(thd, (yyvsp[(12) - (12)].table), NULL, TL_OPTION_UPDATING,
@@ -34196,56 +34214,56 @@ yyreduce:
   case 1864:
 
 /* Line 1455 of yacc.c  */
-#line 12068 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12080 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->exchange->cs= (yyvsp[(14) - (14)].charset); }
     break;
 
   case 1865:
 
 /* Line 1455 of yacc.c  */
-#line 12072 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12084 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1866:
 
 /* Line 1455 of yacc.c  */
-#line 12076 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12088 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.filetype)= FILETYPE_CSV; }
     break;
 
   case 1867:
 
 /* Line 1455 of yacc.c  */
-#line 12077 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12089 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.filetype)= FILETYPE_XML; }
     break;
 
   case 1868:
 
 /* Line 1455 of yacc.c  */
-#line 12081 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12093 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)=0;}
     break;
 
   case 1869:
 
 /* Line 1455 of yacc.c  */
-#line 12082 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12094 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)=1;}
     break;
 
   case 1870:
 
 /* Line 1455 of yacc.c  */
-#line 12086 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12098 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= TL_WRITE_DEFAULT; }
     break;
 
   case 1871:
 
 /* Line 1455 of yacc.c  */
-#line 12088 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12100 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             /*
               Ignore this option in SP to avoid problem with query cache and
@@ -34258,35 +34276,35 @@ yyreduce:
   case 1872:
 
 /* Line 1455 of yacc.c  */
-#line 12095 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12107 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lock_type)= TL_WRITE_LOW_PRIORITY; }
     break;
 
   case 1873:
 
 /* Line 1455 of yacc.c  */
-#line 12099 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12111 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->duplicates=DUP_ERROR; }
     break;
 
   case 1874:
 
 /* Line 1455 of yacc.c  */
-#line 12100 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12112 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->duplicates=DUP_REPLACE; }
     break;
 
   case 1875:
 
 /* Line 1455 of yacc.c  */
-#line 12101 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12113 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ignore= 1; }
     break;
 
   case 1880:
 
 /* Line 1455 of yacc.c  */
-#line 12116 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12128 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             DBUG_ASSERT(Lex->exchange != 0);
             Lex->exchange->field_term= (yyvsp[(3) - (3)].string);
@@ -34296,7 +34314,7 @@ yyreduce:
   case 1881:
 
 /* Line 1455 of yacc.c  */
-#line 12121 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12133 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             DBUG_ASSERT(lex->exchange != 0);
@@ -34308,7 +34326,7 @@ yyreduce:
   case 1882:
 
 /* Line 1455 of yacc.c  */
-#line 12128 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12140 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             DBUG_ASSERT(Lex->exchange != 0);
             Lex->exchange->enclosed= (yyvsp[(3) - (3)].string);
@@ -34318,7 +34336,7 @@ yyreduce:
   case 1883:
 
 /* Line 1455 of yacc.c  */
-#line 12133 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12145 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             DBUG_ASSERT(Lex->exchange != 0);
             Lex->exchange->escaped= (yyvsp[(3) - (3)].string);
@@ -34328,7 +34346,7 @@ yyreduce:
   case 1888:
 
 /* Line 1455 of yacc.c  */
-#line 12151 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12163 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             DBUG_ASSERT(Lex->exchange != 0);
             Lex->exchange->line_term= (yyvsp[(3) - (3)].string);
@@ -34338,7 +34356,7 @@ yyreduce:
   case 1889:
 
 /* Line 1455 of yacc.c  */
-#line 12156 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12168 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             DBUG_ASSERT(Lex->exchange != 0);
             Lex->exchange->line_start= (yyvsp[(3) - (3)].string);
@@ -34348,21 +34366,21 @@ yyreduce:
   case 1890:
 
 /* Line 1455 of yacc.c  */
-#line 12163 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12175 "/home/buildbot/git/sql/sql_yacc.yy"
     { }
     break;
 
   case 1891:
 
 /* Line 1455 of yacc.c  */
-#line 12165 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12177 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->exchange->line_term = (yyvsp[(4) - (4)].string); }
     break;
 
   case 1893:
 
 /* Line 1455 of yacc.c  */
-#line 12170 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12182 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             DBUG_ASSERT(Lex->exchange != 0);
             Lex->exchange->skip_lines= atol((yyvsp[(2) - (3)].lex_str).str);
@@ -34372,63 +34390,63 @@ yyreduce:
   case 1894:
 
 /* Line 1455 of yacc.c  */
-#line 12177 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12189 "/home/buildbot/git/sql/sql_yacc.yy"
     { }
     break;
 
   case 1895:
 
 /* Line 1455 of yacc.c  */
-#line 12179 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12191 "/home/buildbot/git/sql/sql_yacc.yy"
     { }
     break;
 
   case 1896:
 
 /* Line 1455 of yacc.c  */
-#line 12183 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12195 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1897:
 
 /* Line 1455 of yacc.c  */
-#line 12184 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12196 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1898:
 
 /* Line 1455 of yacc.c  */
-#line 12185 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12197 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1899:
 
 /* Line 1455 of yacc.c  */
-#line 12190 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12202 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->field_list.push_back((yyvsp[(3) - (3)].item)); }
     break;
 
   case 1900:
 
 /* Line 1455 of yacc.c  */
-#line 12192 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12204 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->field_list.push_back((yyvsp[(1) - (1)].item)); }
     break;
 
   case 1901:
 
 /* Line 1455 of yacc.c  */
-#line 12196 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12208 "/home/buildbot/git/sql/sql_yacc.yy"
     {(yyval.item)= (yyvsp[(1) - (1)].item);}
     break;
 
   case 1902:
 
 /* Line 1455 of yacc.c  */
-#line 12198 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12210 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)= new (thd->mem_root) Item_user_var_as_out_param((yyvsp[(2) - (2)].lex_str));
             if ((yyval.item) == NULL)
@@ -34439,21 +34457,21 @@ yyreduce:
   case 1903:
 
 /* Line 1455 of yacc.c  */
-#line 12206 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12218 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1904:
 
 /* Line 1455 of yacc.c  */
-#line 12207 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12219 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1907:
 
 /* Line 1455 of yacc.c  */
-#line 12217 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12229 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->update_list.push_back((yyvsp[(1) - (5)].item)) || 
@@ -34466,7 +34484,7 @@ yyreduce:
   case 1908:
 
 /* Line 1455 of yacc.c  */
-#line 12230 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12242 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX_STRING tmp;
             CHARSET_INFO *cs_con= thd->variables.collation_connection;
@@ -34494,7 +34512,7 @@ yyreduce:
   case 1909:
 
 /* Line 1455 of yacc.c  */
-#line 12253 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12265 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             uint repertoire= Lex->text_string_is_7bit ?
                              MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
@@ -34511,7 +34529,7 @@ yyreduce:
   case 1910:
 
 /* Line 1455 of yacc.c  */
-#line 12265 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12277 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item_string *str= new (thd->mem_root) Item_string((yyvsp[(2) - (2)].lex_str).str,
                                                                 (yyvsp[(2) - (2)].lex_str).length, (yyvsp[(1) - (2)].charset));
@@ -34527,7 +34545,7 @@ yyreduce:
   case 1911:
 
 /* Line 1455 of yacc.c  */
-#line 12276 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12288 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item_string* item= (Item_string*) (yyvsp[(1) - (2)].item);
             item->append((yyvsp[(2) - (2)].lex_str).str, (yyvsp[(2) - (2)].lex_str).length);
@@ -34548,7 +34566,7 @@ yyreduce:
   case 1912:
 
 /* Line 1455 of yacc.c  */
-#line 12295 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12307 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.string)= new (thd->mem_root) String((yyvsp[(1) - (1)].lex_str).str,
                                              (yyvsp[(1) - (1)].lex_str).length,
@@ -34561,7 +34579,7 @@ yyreduce:
   case 1913:
 
 /* Line 1455 of yacc.c  */
-#line 12303 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12315 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item *tmp= new (thd->mem_root) Item_hex_hybrid((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if (tmp == NULL)
@@ -34578,7 +34596,7 @@ yyreduce:
   case 1914:
 
 /* Line 1455 of yacc.c  */
-#line 12315 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12327 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item *tmp= new (thd->mem_root) Item_hex_string((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if (tmp == NULL)
@@ -34591,7 +34609,7 @@ yyreduce:
   case 1915:
 
 /* Line 1455 of yacc.c  */
-#line 12323 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12335 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item *tmp= new (thd->mem_root) Item_bin_string((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if (tmp == NULL)
@@ -34608,7 +34626,7 @@ yyreduce:
   case 1916:
 
 /* Line 1455 of yacc.c  */
-#line 12338 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12350 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -34630,21 +34648,21 @@ yyreduce:
   case 1917:
 
 /* Line 1455 of yacc.c  */
-#line 12357 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12369 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(1) - (1)].item); }
     break;
 
   case 1918:
 
 /* Line 1455 of yacc.c  */
-#line 12358 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12370 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(2) - (2)].item_num); }
     break;
 
   case 1919:
 
 /* Line 1455 of yacc.c  */
-#line 12360 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12372 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyvsp[(2) - (2)].item_num)->max_length++;
             (yyval.item)= (yyvsp[(2) - (2)].item_num)->neg();
@@ -34654,21 +34672,21 @@ yyreduce:
   case 1920:
 
 /* Line 1455 of yacc.c  */
-#line 12367 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12379 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(1) - (1)].item); }
     break;
 
   case 1921:
 
 /* Line 1455 of yacc.c  */
-#line 12368 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12380 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(1) - (1)].item_num); }
     break;
 
   case 1922:
 
 /* Line 1455 of yacc.c  */
-#line 12370 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12382 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item) = new (thd->mem_root) Item_null();
             if ((yyval.item) == NULL)
@@ -34680,7 +34698,7 @@ yyreduce:
   case 1923:
 
 /* Line 1455 of yacc.c  */
-#line 12377 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12389 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)= new (thd->mem_root) Item_int((char*) "FALSE",0,1);
             if ((yyval.item) == NULL)
@@ -34691,7 +34709,7 @@ yyreduce:
   case 1924:
 
 /* Line 1455 of yacc.c  */
-#line 12383 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12395 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)= new (thd->mem_root) Item_int((char*) "TRUE",1,1);
             if ((yyval.item) == NULL)
@@ -34702,7 +34720,7 @@ yyreduce:
   case 1925:
 
 /* Line 1455 of yacc.c  */
-#line 12389 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12401 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item) = new (thd->mem_root) Item_hex_hybrid((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if ((yyval.item) == NULL)
@@ -34713,7 +34731,7 @@ yyreduce:
   case 1926:
 
 /* Line 1455 of yacc.c  */
-#line 12395 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12407 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item) = new (thd->mem_root) Item_hex_string((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if ((yyval.item) == NULL)
@@ -34724,7 +34742,7 @@ yyreduce:
   case 1927:
 
 /* Line 1455 of yacc.c  */
-#line 12401 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12413 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)= new (thd->mem_root) Item_bin_string((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if ((yyval.item) == NULL)
@@ -34735,7 +34753,7 @@ yyreduce:
   case 1928:
 
 /* Line 1455 of yacc.c  */
-#line 12407 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12419 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item *tmp= new (thd->mem_root) Item_hex_string((yyvsp[(2) - (2)].lex_str).str, (yyvsp[(2) - (2)].lex_str).length);
             if (tmp == NULL)
@@ -34769,7 +34787,7 @@ yyreduce:
   case 1929:
 
 /* Line 1455 of yacc.c  */
-#line 12436 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12448 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item *tmp= new (thd->mem_root) Item_bin_string((yyvsp[(2) - (2)].lex_str).str, (yyvsp[(2) - (2)].lex_str).length);
             if (tmp == NULL)
@@ -34802,28 +34820,28 @@ yyreduce:
   case 1930:
 
 /* Line 1455 of yacc.c  */
-#line 12463 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12475 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(2) - (2)].item); }
     break;
 
   case 1931:
 
 /* Line 1455 of yacc.c  */
-#line 12464 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12476 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(2) - (2)].item); }
     break;
 
   case 1932:
 
 /* Line 1455 of yacc.c  */
-#line 12465 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12477 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item) = (yyvsp[(2) - (2)].item); }
     break;
 
   case 1933:
 
 /* Line 1455 of yacc.c  */
-#line 12470 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12482 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             int error;
             (yyval.item_num)= new (thd->mem_root)
@@ -34838,7 +34856,7 @@ yyreduce:
   case 1934:
 
 /* Line 1455 of yacc.c  */
-#line 12480 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12492 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             int error;
             (yyval.item_num)= new (thd->mem_root)
@@ -34853,7 +34871,7 @@ yyreduce:
   case 1935:
 
 /* Line 1455 of yacc.c  */
-#line 12490 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12502 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item_num)= new (thd->mem_root) Item_uint((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if ((yyval.item_num) == NULL)
@@ -34864,7 +34882,7 @@ yyreduce:
   case 1936:
 
 /* Line 1455 of yacc.c  */
-#line 12496 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12508 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item_num)= new (thd->mem_root) Item_decimal((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length,
                                                    thd->charset());
@@ -34878,7 +34896,7 @@ yyreduce:
   case 1937:
 
 /* Line 1455 of yacc.c  */
-#line 12505 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12517 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item_num)= new (thd->mem_root) Item_float((yyvsp[(1) - (1)].lex_str).str, (yyvsp[(1) - (1)].lex_str).length);
             if (((yyval.item_num) == NULL) || (thd->is_error()))
@@ -34891,21 +34909,21 @@ yyreduce:
   case 1938:
 
 /* Line 1455 of yacc.c  */
-#line 12519 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12531 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)=(yyvsp[(1) - (1)].item); }
     break;
 
   case 1939:
 
 /* Line 1455 of yacc.c  */
-#line 12520 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12532 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)=(yyvsp[(1) - (1)].item); }
     break;
 
   case 1940:
 
 /* Line 1455 of yacc.c  */
-#line 12525 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12537 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             SELECT_LEX *sel= Select;
             (yyval.item)= new (thd->mem_root) Item_field(Lex->current_context(),
@@ -34919,7 +34937,7 @@ yyreduce:
   case 1941:
 
 /* Line 1455 of yacc.c  */
-#line 12534 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12546 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             SELECT_LEX *sel= Select;
             const char* schema= thd->client_capabilities & CLIENT_NO_SCHEMA ?
@@ -34936,14 +34954,14 @@ yyreduce:
   case 1942:
 
 /* Line 1455 of yacc.c  */
-#line 12548 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12560 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)=(yyvsp[(1) - (1)].item); }
     break;
 
   case 1943:
 
 /* Line 1455 of yacc.c  */
-#line 12553 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12565 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -34994,14 +35012,14 @@ yyreduce:
   case 1944:
 
 /* Line 1455 of yacc.c  */
-#line 12598 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12610 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)= (yyvsp[(1) - (1)].item); }
     break;
 
   case 1945:
 
 /* Line 1455 of yacc.c  */
-#line 12603 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12615 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             SELECT_LEX *sel=Select;
             if ((sel->parsing_place != IN_HAVING) ||
@@ -35023,14 +35041,14 @@ yyreduce:
   case 1946:
 
 /* Line 1455 of yacc.c  */
-#line 12619 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12631 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)= (yyvsp[(1) - (1)].item); }
     break;
 
   case 1947:
 
 /* Line 1455 of yacc.c  */
-#line 12624 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12636 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
 
@@ -35113,7 +35131,7 @@ yyreduce:
   case 1948:
 
 /* Line 1455 of yacc.c  */
-#line 12702 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12714 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             SELECT_LEX *sel= lex->current_select;
@@ -35142,7 +35160,7 @@ yyreduce:
   case 1949:
 
 /* Line 1455 of yacc.c  */
-#line 12726 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12738 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             SELECT_LEX *sel= lex->current_select;
@@ -35174,14 +35192,14 @@ yyreduce:
   case 1950:
 
 /* Line 1455 of yacc.c  */
-#line 12755 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12767 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(1) - (1)].lex_str);}
     break;
 
   case 1951:
 
 /* Line 1455 of yacc.c  */
-#line 12757 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12769 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             TABLE_LIST *table= Select->table_list.first;
             if (my_strcasecmp(table_alias_charset, (yyvsp[(1) - (5)].lex_str).str, table->db))
@@ -35202,7 +35220,7 @@ yyreduce:
   case 1952:
 
 /* Line 1455 of yacc.c  */
-#line 12773 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12785 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             TABLE_LIST *table= Select->table_list.first;
             if (my_strcasecmp(table_alias_charset, (yyvsp[(1) - (3)].lex_str).str, table->alias))
@@ -35217,14 +35235,14 @@ yyreduce:
   case 1953:
 
 /* Line 1455 of yacc.c  */
-#line 12782 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12794 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(2) - (2)].lex_str);}
     break;
 
   case 1954:
 
 /* Line 1455 of yacc.c  */
-#line 12787 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12799 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.table)= new Table_ident((yyvsp[(1) - (1)].lex_str));
             if ((yyval.table) == NULL)
@@ -35235,7 +35253,7 @@ yyreduce:
   case 1955:
 
 /* Line 1455 of yacc.c  */
-#line 12793 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12805 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.table)= new Table_ident(thd, (yyvsp[(1) - (3)].lex_str),(yyvsp[(3) - (3)].lex_str),0);
             if ((yyval.table) == NULL)
@@ -35246,7 +35264,7 @@ yyreduce:
   case 1956:
 
 /* Line 1455 of yacc.c  */
-#line 12799 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12811 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             /* For Delphi */
             (yyval.table)= new Table_ident((yyvsp[(2) - (2)].lex_str));
@@ -35258,7 +35276,7 @@ yyreduce:
   case 1957:
 
 /* Line 1455 of yacc.c  */
-#line 12809 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12821 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.table)= new Table_ident((yyvsp[(1) - (2)].lex_str));
             if ((yyval.table) == NULL)
@@ -35269,7 +35287,7 @@ yyreduce:
   case 1958:
 
 /* Line 1455 of yacc.c  */
-#line 12815 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12827 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.table)= new Table_ident(thd, (yyvsp[(1) - (4)].lex_str),(yyvsp[(3) - (4)].lex_str),0);
             if ((yyval.table) == NULL)
@@ -35280,7 +35298,7 @@ yyreduce:
   case 1959:
 
 /* Line 1455 of yacc.c  */
-#line 12824 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12836 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX_STRING db={(char*) any_db,3};
             (yyval.table)= new Table_ident(thd, db,(yyvsp[(1) - (1)].lex_str),0);
@@ -35292,14 +35310,14 @@ yyreduce:
   case 1960:
 
 /* Line 1455 of yacc.c  */
-#line 12833 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12845 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)= (yyvsp[(1) - (1)].lex_str); }
     break;
 
   case 1961:
 
 /* Line 1455 of yacc.c  */
-#line 12835 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12847 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (thd->charset_is_system_charset)
             {
@@ -35329,7 +35347,7 @@ yyreduce:
   case 1962:
 
 /* Line 1455 of yacc.c  */
-#line 12863 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12875 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (thd->charset_is_system_charset)
               (yyval.lex_str)= (yyvsp[(1) - (1)].lex_str);
@@ -35345,7 +35363,7 @@ yyreduce:
   case 1963:
 
 /* Line 1455 of yacc.c  */
-#line 12877 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12889 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (thd->charset_is_collation_connection)
               (yyval.lex_str)= (yyvsp[(1) - (1)].lex_str);
@@ -35361,7 +35379,7 @@ yyreduce:
   case 1964:
 
 /* Line 1455 of yacc.c  */
-#line 12891 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12903 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (thd->charset_is_character_set_filesystem)
               (yyval.lex_str)= (yyvsp[(1) - (1)].lex_str);
@@ -35378,14 +35396,14 @@ yyreduce:
   case 1965:
 
 /* Line 1455 of yacc.c  */
-#line 12905 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12917 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(1) - (1)].lex_str); }
     break;
 
   case 1966:
 
 /* Line 1455 of yacc.c  */
-#line 12907 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12919 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.lex_str).str= thd->strmake((yyvsp[(1) - (1)].symbol).str, (yyvsp[(1) - (1)].symbol).length);
             if ((yyval.lex_str).str == NULL)
@@ -35397,14 +35415,14 @@ yyreduce:
   case 1967:
 
 /* Line 1455 of yacc.c  */
-#line 12916 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12928 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(1) - (1)].lex_str); }
     break;
 
   case 1968:
 
 /* Line 1455 of yacc.c  */
-#line 12918 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12930 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.lex_str).str= thd->strmake((yyvsp[(1) - (1)].symbol).str, (yyvsp[(1) - (1)].symbol).length);
             if ((yyval.lex_str).str == NULL)
@@ -35416,28 +35434,28 @@ yyreduce:
   case 1969:
 
 /* Line 1455 of yacc.c  */
-#line 12927 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12939 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(1) - (1)].lex_str);}
     break;
 
   case 1970:
 
 /* Line 1455 of yacc.c  */
-#line 12928 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12940 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(1) - (1)].lex_str);}
     break;
 
   case 1971:
 
 /* Line 1455 of yacc.c  */
-#line 12929 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12941 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_str)=(yyvsp[(1) - (1)].lex_str);}
     break;
 
   case 1972:
 
 /* Line 1455 of yacc.c  */
-#line 12934 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12946 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (!((yyval.lex_user)=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
               MYSQL_YYABORT;
@@ -35458,7 +35476,7 @@ yyreduce:
   case 1973:
 
 /* Line 1455 of yacc.c  */
-#line 12950 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12962 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (!((yyval.lex_user)=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
               MYSQL_YYABORT;
@@ -35484,7 +35502,7 @@ yyreduce:
   case 1974:
 
 /* Line 1455 of yacc.c  */
-#line 12971 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12983 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (!((yyval.lex_user)=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
               MYSQL_YYABORT;
@@ -35500,2471 +35518,2471 @@ yyreduce:
   case 1975:
 
 /* Line 1455 of yacc.c  */
-#line 12985 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12997 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1976:
 
 /* Line 1455 of yacc.c  */
-#line 12986 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12998 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1977:
 
 /* Line 1455 of yacc.c  */
-#line 12987 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 12999 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1978:
 
 /* Line 1455 of yacc.c  */
-#line 12988 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13000 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1979:
 
 /* Line 1455 of yacc.c  */
-#line 12989 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13001 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1980:
 
 /* Line 1455 of yacc.c  */
-#line 12990 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13002 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1981:
 
 /* Line 1455 of yacc.c  */
-#line 12991 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13003 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1982:
 
 /* Line 1455 of yacc.c  */
-#line 12992 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13004 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1983:
 
 /* Line 1455 of yacc.c  */
-#line 12993 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13005 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1984:
 
 /* Line 1455 of yacc.c  */
-#line 12994 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13006 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1985:
 
 /* Line 1455 of yacc.c  */
-#line 12995 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13007 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1986:
 
 /* Line 1455 of yacc.c  */
-#line 12996 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13008 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1987:
 
 /* Line 1455 of yacc.c  */
-#line 12997 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13009 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1988:
 
 /* Line 1455 of yacc.c  */
-#line 12998 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13010 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1989:
 
 /* Line 1455 of yacc.c  */
-#line 12999 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13011 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1990:
 
 /* Line 1455 of yacc.c  */
-#line 13000 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13012 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1991:
 
 /* Line 1455 of yacc.c  */
-#line 13001 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13013 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1992:
 
 /* Line 1455 of yacc.c  */
-#line 13002 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13014 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1993:
 
 /* Line 1455 of yacc.c  */
-#line 13003 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13015 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1994:
 
 /* Line 1455 of yacc.c  */
-#line 13004 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13016 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1995:
 
 /* Line 1455 of yacc.c  */
-#line 13005 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13017 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1996:
 
 /* Line 1455 of yacc.c  */
-#line 13006 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13018 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1997:
 
 /* Line 1455 of yacc.c  */
-#line 13007 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13019 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1998:
 
 /* Line 1455 of yacc.c  */
-#line 13008 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13020 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 1999:
 
 /* Line 1455 of yacc.c  */
-#line 13009 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13021 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2000:
 
 /* Line 1455 of yacc.c  */
-#line 13010 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13022 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2001:
 
 /* Line 1455 of yacc.c  */
-#line 13011 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13023 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2002:
 
 /* Line 1455 of yacc.c  */
-#line 13012 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13024 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2003:
 
 /* Line 1455 of yacc.c  */
-#line 13013 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13025 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2004:
 
 /* Line 1455 of yacc.c  */
-#line 13014 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13026 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2005:
 
 /* Line 1455 of yacc.c  */
-#line 13015 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13027 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2006:
 
 /* Line 1455 of yacc.c  */
-#line 13016 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13028 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2007:
 
 /* Line 1455 of yacc.c  */
-#line 13017 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13029 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2008:
 
 /* Line 1455 of yacc.c  */
-#line 13018 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13030 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2009:
 
 /* Line 1455 of yacc.c  */
-#line 13019 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13031 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2010:
 
 /* Line 1455 of yacc.c  */
-#line 13020 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13032 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2011:
 
 /* Line 1455 of yacc.c  */
-#line 13021 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13033 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2012:
 
 /* Line 1455 of yacc.c  */
-#line 13022 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13034 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2013:
 
 /* Line 1455 of yacc.c  */
-#line 13023 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13035 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2014:
 
 /* Line 1455 of yacc.c  */
-#line 13024 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13036 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2015:
 
 /* Line 1455 of yacc.c  */
-#line 13025 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13037 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2016:
 
 /* Line 1455 of yacc.c  */
-#line 13026 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13038 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2017:
 
 /* Line 1455 of yacc.c  */
-#line 13027 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13039 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2018:
 
 /* Line 1455 of yacc.c  */
-#line 13028 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13040 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2019:
 
 /* Line 1455 of yacc.c  */
-#line 13029 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13041 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2020:
 
 /* Line 1455 of yacc.c  */
-#line 13030 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13042 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2021:
 
 /* Line 1455 of yacc.c  */
-#line 13031 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13043 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2022:
 
 /* Line 1455 of yacc.c  */
-#line 13032 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13044 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2023:
 
 /* Line 1455 of yacc.c  */
-#line 13033 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13045 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2024:
 
 /* Line 1455 of yacc.c  */
-#line 13034 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13046 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2025:
 
 /* Line 1455 of yacc.c  */
-#line 13035 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13047 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2026:
 
 /* Line 1455 of yacc.c  */
-#line 13036 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13048 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2027:
 
 /* Line 1455 of yacc.c  */
-#line 13037 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13049 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2028:
 
 /* Line 1455 of yacc.c  */
-#line 13038 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13050 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2029:
 
 /* Line 1455 of yacc.c  */
-#line 13039 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13051 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2030:
 
 /* Line 1455 of yacc.c  */
-#line 13040 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13052 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2031:
 
 /* Line 1455 of yacc.c  */
-#line 13041 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13053 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2032:
 
 /* Line 1455 of yacc.c  */
-#line 13042 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13054 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2033:
 
 /* Line 1455 of yacc.c  */
-#line 13043 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13055 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2034:
 
 /* Line 1455 of yacc.c  */
-#line 13053 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13065 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2035:
 
 /* Line 1455 of yacc.c  */
-#line 13054 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13066 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2036:
 
 /* Line 1455 of yacc.c  */
-#line 13055 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13067 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2037:
 
 /* Line 1455 of yacc.c  */
-#line 13056 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13068 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2038:
 
 /* Line 1455 of yacc.c  */
-#line 13057 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13069 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2039:
 
 /* Line 1455 of yacc.c  */
-#line 13058 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13070 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2040:
 
 /* Line 1455 of yacc.c  */
-#line 13059 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13071 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2041:
 
 /* Line 1455 of yacc.c  */
-#line 13060 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13072 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2042:
 
 /* Line 1455 of yacc.c  */
-#line 13061 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13073 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2043:
 
 /* Line 1455 of yacc.c  */
-#line 13062 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13074 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2044:
 
 /* Line 1455 of yacc.c  */
-#line 13063 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13075 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2045:
 
 /* Line 1455 of yacc.c  */
-#line 13064 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13076 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2046:
 
 /* Line 1455 of yacc.c  */
-#line 13065 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13077 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2047:
 
 /* Line 1455 of yacc.c  */
-#line 13066 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13078 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2048:
 
 /* Line 1455 of yacc.c  */
-#line 13067 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13079 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2049:
 
 /* Line 1455 of yacc.c  */
-#line 13068 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13080 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2050:
 
 /* Line 1455 of yacc.c  */
-#line 13069 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13081 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2051:
 
 /* Line 1455 of yacc.c  */
-#line 13070 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13082 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2052:
 
 /* Line 1455 of yacc.c  */
-#line 13071 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13083 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2053:
 
 /* Line 1455 of yacc.c  */
-#line 13072 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13084 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2054:
 
 /* Line 1455 of yacc.c  */
-#line 13073 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13085 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2055:
 
 /* Line 1455 of yacc.c  */
-#line 13074 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13086 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2056:
 
 /* Line 1455 of yacc.c  */
-#line 13075 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13087 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2057:
 
 /* Line 1455 of yacc.c  */
-#line 13076 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13088 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2058:
 
 /* Line 1455 of yacc.c  */
-#line 13077 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13089 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2059:
 
 /* Line 1455 of yacc.c  */
-#line 13078 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13090 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2060:
 
 /* Line 1455 of yacc.c  */
-#line 13079 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13091 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2061:
 
 /* Line 1455 of yacc.c  */
-#line 13080 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13092 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2062:
 
 /* Line 1455 of yacc.c  */
-#line 13081 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13093 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2063:
 
 /* Line 1455 of yacc.c  */
-#line 13082 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13094 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2064:
 
 /* Line 1455 of yacc.c  */
-#line 13083 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13095 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2065:
 
 /* Line 1455 of yacc.c  */
-#line 13084 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13096 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2066:
 
 /* Line 1455 of yacc.c  */
-#line 13085 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13097 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2067:
 
 /* Line 1455 of yacc.c  */
-#line 13086 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13098 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2068:
 
 /* Line 1455 of yacc.c  */
-#line 13087 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13099 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2069:
 
 /* Line 1455 of yacc.c  */
-#line 13088 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13100 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2070:
 
 /* Line 1455 of yacc.c  */
-#line 13089 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13101 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2071:
 
 /* Line 1455 of yacc.c  */
-#line 13090 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13102 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2072:
 
 /* Line 1455 of yacc.c  */
-#line 13091 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13103 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2073:
 
 /* Line 1455 of yacc.c  */
-#line 13092 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13104 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2074:
 
 /* Line 1455 of yacc.c  */
-#line 13093 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13105 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2075:
 
 /* Line 1455 of yacc.c  */
-#line 13094 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13106 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2076:
 
 /* Line 1455 of yacc.c  */
-#line 13095 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13107 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2077:
 
 /* Line 1455 of yacc.c  */
-#line 13096 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13108 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2078:
 
 /* Line 1455 of yacc.c  */
-#line 13097 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13109 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2079:
 
 /* Line 1455 of yacc.c  */
-#line 13098 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13110 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2080:
 
 /* Line 1455 of yacc.c  */
-#line 13099 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13111 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2081:
 
 /* Line 1455 of yacc.c  */
-#line 13100 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13112 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2082:
 
 /* Line 1455 of yacc.c  */
-#line 13101 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13113 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2083:
 
 /* Line 1455 of yacc.c  */
-#line 13102 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13114 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2084:
 
 /* Line 1455 of yacc.c  */
-#line 13103 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13115 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2085:
 
 /* Line 1455 of yacc.c  */
-#line 13104 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13116 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2086:
 
 /* Line 1455 of yacc.c  */
-#line 13105 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13117 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2087:
 
 /* Line 1455 of yacc.c  */
-#line 13106 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13118 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2088:
 
 /* Line 1455 of yacc.c  */
-#line 13107 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13119 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2089:
 
 /* Line 1455 of yacc.c  */
-#line 13108 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13120 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2090:
 
 /* Line 1455 of yacc.c  */
-#line 13109 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13121 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2091:
 
 /* Line 1455 of yacc.c  */
-#line 13110 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13122 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2092:
 
 /* Line 1455 of yacc.c  */
-#line 13111 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13123 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2093:
 
 /* Line 1455 of yacc.c  */
-#line 13112 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13124 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2094:
 
 /* Line 1455 of yacc.c  */
-#line 13113 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13125 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2095:
 
 /* Line 1455 of yacc.c  */
-#line 13114 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13126 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2096:
 
 /* Line 1455 of yacc.c  */
-#line 13115 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13127 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2097:
 
 /* Line 1455 of yacc.c  */
-#line 13116 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13128 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2098:
 
 /* Line 1455 of yacc.c  */
-#line 13117 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13129 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2099:
 
 /* Line 1455 of yacc.c  */
-#line 13118 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13130 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2100:
 
 /* Line 1455 of yacc.c  */
-#line 13119 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13131 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2101:
 
 /* Line 1455 of yacc.c  */
-#line 13120 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13132 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2102:
 
 /* Line 1455 of yacc.c  */
-#line 13121 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13133 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2103:
 
 /* Line 1455 of yacc.c  */
-#line 13122 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13134 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2104:
 
 /* Line 1455 of yacc.c  */
-#line 13123 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13135 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2105:
 
 /* Line 1455 of yacc.c  */
-#line 13124 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13136 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2106:
 
 /* Line 1455 of yacc.c  */
-#line 13125 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13137 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2107:
 
 /* Line 1455 of yacc.c  */
-#line 13126 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13138 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2108:
 
 /* Line 1455 of yacc.c  */
-#line 13127 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13139 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2109:
 
 /* Line 1455 of yacc.c  */
-#line 13128 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13140 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2110:
 
 /* Line 1455 of yacc.c  */
-#line 13129 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13141 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2111:
 
 /* Line 1455 of yacc.c  */
-#line 13130 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13142 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2112:
 
 /* Line 1455 of yacc.c  */
-#line 13131 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13143 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2113:
 
 /* Line 1455 of yacc.c  */
-#line 13132 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13144 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2114:
 
 /* Line 1455 of yacc.c  */
-#line 13133 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13145 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2115:
 
 /* Line 1455 of yacc.c  */
-#line 13134 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13146 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2116:
 
 /* Line 1455 of yacc.c  */
-#line 13135 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13147 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2117:
 
 /* Line 1455 of yacc.c  */
-#line 13136 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13148 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2118:
 
 /* Line 1455 of yacc.c  */
-#line 13137 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13149 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2119:
 
 /* Line 1455 of yacc.c  */
-#line 13138 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13150 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2120:
 
 /* Line 1455 of yacc.c  */
-#line 13139 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13151 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2121:
 
 /* Line 1455 of yacc.c  */
-#line 13140 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13152 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2122:
 
 /* Line 1455 of yacc.c  */
-#line 13141 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13153 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2123:
 
 /* Line 1455 of yacc.c  */
-#line 13142 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13154 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2124:
 
 /* Line 1455 of yacc.c  */
-#line 13143 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13155 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2125:
 
 /* Line 1455 of yacc.c  */
-#line 13144 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13156 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2126:
 
 /* Line 1455 of yacc.c  */
-#line 13145 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13157 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2127:
 
 /* Line 1455 of yacc.c  */
-#line 13146 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13158 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2128:
 
 /* Line 1455 of yacc.c  */
-#line 13147 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13159 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2129:
 
 /* Line 1455 of yacc.c  */
-#line 13148 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13160 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2130:
 
 /* Line 1455 of yacc.c  */
-#line 13149 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13161 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2131:
 
 /* Line 1455 of yacc.c  */
-#line 13150 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13162 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2132:
 
 /* Line 1455 of yacc.c  */
-#line 13151 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13163 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2133:
 
 /* Line 1455 of yacc.c  */
-#line 13152 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13164 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2134:
 
 /* Line 1455 of yacc.c  */
-#line 13153 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13165 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2135:
 
 /* Line 1455 of yacc.c  */
-#line 13154 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13166 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2136:
 
 /* Line 1455 of yacc.c  */
-#line 13155 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13167 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2137:
 
 /* Line 1455 of yacc.c  */
-#line 13156 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13168 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2138:
 
 /* Line 1455 of yacc.c  */
-#line 13157 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13169 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2139:
 
 /* Line 1455 of yacc.c  */
-#line 13158 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13170 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2140:
 
 /* Line 1455 of yacc.c  */
-#line 13159 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13171 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2141:
 
 /* Line 1455 of yacc.c  */
-#line 13160 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13172 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2142:
 
 /* Line 1455 of yacc.c  */
-#line 13161 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13173 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2143:
 
 /* Line 1455 of yacc.c  */
-#line 13162 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13174 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2144:
 
 /* Line 1455 of yacc.c  */
-#line 13163 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13175 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2145:
 
 /* Line 1455 of yacc.c  */
-#line 13164 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13176 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2146:
 
 /* Line 1455 of yacc.c  */
-#line 13165 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13177 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2147:
 
 /* Line 1455 of yacc.c  */
-#line 13166 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13178 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2148:
 
 /* Line 1455 of yacc.c  */
-#line 13167 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13179 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2149:
 
 /* Line 1455 of yacc.c  */
-#line 13168 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13180 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2150:
 
 /* Line 1455 of yacc.c  */
-#line 13169 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13181 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2151:
 
 /* Line 1455 of yacc.c  */
-#line 13170 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13182 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2152:
 
 /* Line 1455 of yacc.c  */
-#line 13171 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13183 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2153:
 
 /* Line 1455 of yacc.c  */
-#line 13172 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13184 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2154:
 
 /* Line 1455 of yacc.c  */
-#line 13173 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13185 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2155:
 
 /* Line 1455 of yacc.c  */
-#line 13174 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13186 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2156:
 
 /* Line 1455 of yacc.c  */
-#line 13175 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13187 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2157:
 
 /* Line 1455 of yacc.c  */
-#line 13176 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13188 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2158:
 
 /* Line 1455 of yacc.c  */
-#line 13177 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13189 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2159:
 
 /* Line 1455 of yacc.c  */
-#line 13178 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13190 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2160:
 
 /* Line 1455 of yacc.c  */
-#line 13179 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13191 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2161:
 
 /* Line 1455 of yacc.c  */
-#line 13180 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13192 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2162:
 
 /* Line 1455 of yacc.c  */
-#line 13181 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13193 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2163:
 
 /* Line 1455 of yacc.c  */
-#line 13182 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13194 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2164:
 
 /* Line 1455 of yacc.c  */
-#line 13183 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13195 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2165:
 
 /* Line 1455 of yacc.c  */
-#line 13184 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13196 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2166:
 
 /* Line 1455 of yacc.c  */
-#line 13185 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13197 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2167:
 
 /* Line 1455 of yacc.c  */
-#line 13186 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13198 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2168:
 
 /* Line 1455 of yacc.c  */
-#line 13187 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13199 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2169:
 
 /* Line 1455 of yacc.c  */
-#line 13188 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13200 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2170:
 
 /* Line 1455 of yacc.c  */
-#line 13189 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13201 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2171:
 
 /* Line 1455 of yacc.c  */
-#line 13190 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13202 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2172:
 
 /* Line 1455 of yacc.c  */
-#line 13191 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13203 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2173:
 
 /* Line 1455 of yacc.c  */
-#line 13192 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13204 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2174:
 
 /* Line 1455 of yacc.c  */
-#line 13193 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13205 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2175:
 
 /* Line 1455 of yacc.c  */
-#line 13194 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13206 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2176:
 
 /* Line 1455 of yacc.c  */
-#line 13195 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13207 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2177:
 
 /* Line 1455 of yacc.c  */
-#line 13196 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13208 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2178:
 
 /* Line 1455 of yacc.c  */
-#line 13197 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13209 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2179:
 
 /* Line 1455 of yacc.c  */
-#line 13198 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13210 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2180:
 
 /* Line 1455 of yacc.c  */
-#line 13199 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13211 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2181:
 
 /* Line 1455 of yacc.c  */
-#line 13200 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13212 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2182:
 
 /* Line 1455 of yacc.c  */
-#line 13201 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13213 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2183:
 
 /* Line 1455 of yacc.c  */
-#line 13202 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13214 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2184:
 
 /* Line 1455 of yacc.c  */
-#line 13203 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13215 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2185:
 
 /* Line 1455 of yacc.c  */
-#line 13204 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13216 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2186:
 
 /* Line 1455 of yacc.c  */
-#line 13205 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13217 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2187:
 
 /* Line 1455 of yacc.c  */
-#line 13206 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13218 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2188:
 
 /* Line 1455 of yacc.c  */
-#line 13207 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13219 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2189:
 
 /* Line 1455 of yacc.c  */
-#line 13208 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13220 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2190:
 
 /* Line 1455 of yacc.c  */
-#line 13209 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13221 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2191:
 
 /* Line 1455 of yacc.c  */
-#line 13210 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13222 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2192:
 
 /* Line 1455 of yacc.c  */
-#line 13211 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13223 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2193:
 
 /* Line 1455 of yacc.c  */
-#line 13212 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13224 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2194:
 
 /* Line 1455 of yacc.c  */
-#line 13213 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13225 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2195:
 
 /* Line 1455 of yacc.c  */
-#line 13214 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13226 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2196:
 
 /* Line 1455 of yacc.c  */
-#line 13215 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13227 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2197:
 
 /* Line 1455 of yacc.c  */
-#line 13216 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13228 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2198:
 
 /* Line 1455 of yacc.c  */
-#line 13217 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13229 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2199:
 
 /* Line 1455 of yacc.c  */
-#line 13218 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13230 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2200:
 
 /* Line 1455 of yacc.c  */
-#line 13219 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13231 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2201:
 
 /* Line 1455 of yacc.c  */
-#line 13220 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13232 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2202:
 
 /* Line 1455 of yacc.c  */
-#line 13221 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13233 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2203:
 
 /* Line 1455 of yacc.c  */
-#line 13222 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13234 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2204:
 
 /* Line 1455 of yacc.c  */
-#line 13223 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13235 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2205:
 
 /* Line 1455 of yacc.c  */
-#line 13224 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13236 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2206:
 
 /* Line 1455 of yacc.c  */
-#line 13225 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13237 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2207:
 
 /* Line 1455 of yacc.c  */
-#line 13226 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13238 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2208:
 
 /* Line 1455 of yacc.c  */
-#line 13227 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13239 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2209:
 
 /* Line 1455 of yacc.c  */
-#line 13228 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13240 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2210:
 
 /* Line 1455 of yacc.c  */
-#line 13229 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13241 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2211:
 
 /* Line 1455 of yacc.c  */
-#line 13230 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13242 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2212:
 
 /* Line 1455 of yacc.c  */
-#line 13231 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13243 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2213:
 
 /* Line 1455 of yacc.c  */
-#line 13232 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13244 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2214:
 
 /* Line 1455 of yacc.c  */
-#line 13233 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13245 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2215:
 
 /* Line 1455 of yacc.c  */
-#line 13234 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13246 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2216:
 
 /* Line 1455 of yacc.c  */
-#line 13235 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13247 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2217:
 
 /* Line 1455 of yacc.c  */
-#line 13236 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13248 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2218:
 
 /* Line 1455 of yacc.c  */
-#line 13237 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13249 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2219:
 
 /* Line 1455 of yacc.c  */
-#line 13238 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13250 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2220:
 
 /* Line 1455 of yacc.c  */
-#line 13239 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13251 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2221:
 
 /* Line 1455 of yacc.c  */
-#line 13240 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13252 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2222:
 
 /* Line 1455 of yacc.c  */
-#line 13241 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13253 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2223:
 
 /* Line 1455 of yacc.c  */
-#line 13242 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13254 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2224:
 
 /* Line 1455 of yacc.c  */
-#line 13243 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13255 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2225:
 
 /* Line 1455 of yacc.c  */
-#line 13244 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13256 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2226:
 
 /* Line 1455 of yacc.c  */
-#line 13245 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13257 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2227:
 
 /* Line 1455 of yacc.c  */
-#line 13246 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13258 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2228:
 
 /* Line 1455 of yacc.c  */
-#line 13247 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13259 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2229:
 
 /* Line 1455 of yacc.c  */
-#line 13248 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13260 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2230:
 
 /* Line 1455 of yacc.c  */
-#line 13249 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13261 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2231:
 
 /* Line 1455 of yacc.c  */
-#line 13250 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13262 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2232:
 
 /* Line 1455 of yacc.c  */
-#line 13251 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13263 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2233:
 
 /* Line 1455 of yacc.c  */
-#line 13252 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13264 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2234:
 
 /* Line 1455 of yacc.c  */
-#line 13253 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13265 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2235:
 
 /* Line 1455 of yacc.c  */
-#line 13254 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13266 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2236:
 
 /* Line 1455 of yacc.c  */
-#line 13255 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13267 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2237:
 
 /* Line 1455 of yacc.c  */
-#line 13256 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13268 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2238:
 
 /* Line 1455 of yacc.c  */
-#line 13257 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13269 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2239:
 
 /* Line 1455 of yacc.c  */
-#line 13258 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13270 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2240:
 
 /* Line 1455 of yacc.c  */
-#line 13259 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13271 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2241:
 
 /* Line 1455 of yacc.c  */
-#line 13260 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13272 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2242:
 
 /* Line 1455 of yacc.c  */
-#line 13261 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13273 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2243:
 
 /* Line 1455 of yacc.c  */
-#line 13262 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13274 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2244:
 
 /* Line 1455 of yacc.c  */
-#line 13263 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13275 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2245:
 
 /* Line 1455 of yacc.c  */
-#line 13264 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13276 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2246:
 
 /* Line 1455 of yacc.c  */
-#line 13265 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13277 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2247:
 
 /* Line 1455 of yacc.c  */
-#line 13266 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13278 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2248:
 
 /* Line 1455 of yacc.c  */
-#line 13267 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13279 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2249:
 
 /* Line 1455 of yacc.c  */
-#line 13268 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13280 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2250:
 
 /* Line 1455 of yacc.c  */
-#line 13269 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13281 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2251:
 
 /* Line 1455 of yacc.c  */
-#line 13270 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13282 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2252:
 
 /* Line 1455 of yacc.c  */
-#line 13271 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13283 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2253:
 
 /* Line 1455 of yacc.c  */
-#line 13272 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13284 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2254:
 
 /* Line 1455 of yacc.c  */
-#line 13273 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13285 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2255:
 
 /* Line 1455 of yacc.c  */
-#line 13274 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13286 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2256:
 
 /* Line 1455 of yacc.c  */
-#line 13275 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13287 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2257:
 
 /* Line 1455 of yacc.c  */
-#line 13276 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13288 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2258:
 
 /* Line 1455 of yacc.c  */
-#line 13277 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13289 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2259:
 
 /* Line 1455 of yacc.c  */
-#line 13278 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13290 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2260:
 
 /* Line 1455 of yacc.c  */
-#line 13279 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13291 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2261:
 
 /* Line 1455 of yacc.c  */
-#line 13280 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13292 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2262:
 
 /* Line 1455 of yacc.c  */
-#line 13281 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13293 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2263:
 
 /* Line 1455 of yacc.c  */
-#line 13282 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13294 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2264:
 
 /* Line 1455 of yacc.c  */
-#line 13283 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13295 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2265:
 
 /* Line 1455 of yacc.c  */
-#line 13284 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13296 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2266:
 
 /* Line 1455 of yacc.c  */
-#line 13285 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13297 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2267:
 
 /* Line 1455 of yacc.c  */
-#line 13286 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13298 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2268:
 
 /* Line 1455 of yacc.c  */
-#line 13287 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13299 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2269:
 
 /* Line 1455 of yacc.c  */
-#line 13288 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13300 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2270:
 
 /* Line 1455 of yacc.c  */
-#line 13289 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13301 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2271:
 
 /* Line 1455 of yacc.c  */
-#line 13290 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13302 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2272:
 
 /* Line 1455 of yacc.c  */
-#line 13291 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13303 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2273:
 
 /* Line 1455 of yacc.c  */
-#line 13292 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13304 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2274:
 
 /* Line 1455 of yacc.c  */
-#line 13293 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13305 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2275:
 
 /* Line 1455 of yacc.c  */
-#line 13294 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13306 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2276:
 
 /* Line 1455 of yacc.c  */
-#line 13295 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13307 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2277:
 
 /* Line 1455 of yacc.c  */
-#line 13296 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13308 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2278:
 
 /* Line 1455 of yacc.c  */
-#line 13297 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13309 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2279:
 
 /* Line 1455 of yacc.c  */
-#line 13298 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13310 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2280:
 
 /* Line 1455 of yacc.c  */
-#line 13299 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13311 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2281:
 
 /* Line 1455 of yacc.c  */
-#line 13300 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13312 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2282:
 
 /* Line 1455 of yacc.c  */
-#line 13301 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13313 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2283:
 
 /* Line 1455 of yacc.c  */
-#line 13302 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13314 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2284:
 
 /* Line 1455 of yacc.c  */
-#line 13303 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13315 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2285:
 
 /* Line 1455 of yacc.c  */
-#line 13304 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13316 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2286:
 
 /* Line 1455 of yacc.c  */
-#line 13305 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13317 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2287:
 
 /* Line 1455 of yacc.c  */
-#line 13306 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13318 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2288:
 
 /* Line 1455 of yacc.c  */
-#line 13307 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13319 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2289:
 
 /* Line 1455 of yacc.c  */
-#line 13308 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13320 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2290:
 
 /* Line 1455 of yacc.c  */
-#line 13309 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13321 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2291:
 
 /* Line 1455 of yacc.c  */
-#line 13310 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13322 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2292:
 
 /* Line 1455 of yacc.c  */
-#line 13311 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13323 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2293:
 
 /* Line 1455 of yacc.c  */
-#line 13312 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13324 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2294:
 
 /* Line 1455 of yacc.c  */
-#line 13313 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13325 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2295:
 
 /* Line 1455 of yacc.c  */
-#line 13314 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13326 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2296:
 
 /* Line 1455 of yacc.c  */
-#line 13315 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13327 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2297:
 
 /* Line 1455 of yacc.c  */
-#line 13316 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13328 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2298:
 
 /* Line 1455 of yacc.c  */
-#line 13317 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13329 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2299:
 
 /* Line 1455 of yacc.c  */
-#line 13318 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13330 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2300:
 
 /* Line 1455 of yacc.c  */
-#line 13319 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13331 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2301:
 
 /* Line 1455 of yacc.c  */
-#line 13320 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13332 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2302:
 
 /* Line 1455 of yacc.c  */
-#line 13321 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13333 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2303:
 
 /* Line 1455 of yacc.c  */
-#line 13322 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13334 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2304:
 
 /* Line 1455 of yacc.c  */
-#line 13323 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13335 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2305:
 
 /* Line 1455 of yacc.c  */
-#line 13324 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13336 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2306:
 
 /* Line 1455 of yacc.c  */
-#line 13325 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13337 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2307:
 
 /* Line 1455 of yacc.c  */
-#line 13326 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13338 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2308:
 
 /* Line 1455 of yacc.c  */
-#line 13327 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13339 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2309:
 
 /* Line 1455 of yacc.c  */
-#line 13328 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13340 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2310:
 
 /* Line 1455 of yacc.c  */
-#line 13329 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13341 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2311:
 
 /* Line 1455 of yacc.c  */
-#line 13330 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13342 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2312:
 
 /* Line 1455 of yacc.c  */
-#line 13331 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13343 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2313:
 
 /* Line 1455 of yacc.c  */
-#line 13332 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13344 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2314:
 
 /* Line 1455 of yacc.c  */
-#line 13333 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13345 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2315:
 
 /* Line 1455 of yacc.c  */
-#line 13334 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13346 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2316:
 
 /* Line 1455 of yacc.c  */
-#line 13335 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13347 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2317:
 
 /* Line 1455 of yacc.c  */
-#line 13336 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13348 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2318:
 
 /* Line 1455 of yacc.c  */
-#line 13337 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13349 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2319:
 
 /* Line 1455 of yacc.c  */
-#line 13338 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13350 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2320:
 
 /* Line 1455 of yacc.c  */
-#line 13339 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13351 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2321:
 
 /* Line 1455 of yacc.c  */
-#line 13340 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13352 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2322:
 
 /* Line 1455 of yacc.c  */
-#line 13341 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13353 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2323:
 
 /* Line 1455 of yacc.c  */
-#line 13342 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13354 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2324:
 
 /* Line 1455 of yacc.c  */
-#line 13343 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13355 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2325:
 
 /* Line 1455 of yacc.c  */
-#line 13344 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13356 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2326:
 
 /* Line 1455 of yacc.c  */
-#line 13345 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13357 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2327:
 
 /* Line 1455 of yacc.c  */
-#line 13352 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13364 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SET_OPTION;
@@ -37979,28 +37997,28 @@ yyreduce:
   case 2328:
 
 /* Line 1455 of yacc.c  */
-#line 13362 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13374 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2329:
 
 /* Line 1455 of yacc.c  */
-#line 13366 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13378 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2330:
 
 /* Line 1455 of yacc.c  */
-#line 13367 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13379 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2333:
 
 /* Line 1455 of yacc.c  */
-#line 13376 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13388 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -38035,7 +38053,7 @@ yyreduce:
   case 2334:
 
 /* Line 1455 of yacc.c  */
-#line 13406 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13418 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -38088,105 +38106,105 @@ yyreduce:
   case 2335:
 
 /* Line 1455 of yacc.c  */
-#line 13456 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13468 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2336:
 
 /* Line 1455 of yacc.c  */
-#line 13457 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13469 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_GLOBAL; }
     break;
 
   case 2337:
 
 /* Line 1455 of yacc.c  */
-#line 13458 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13470 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2338:
 
 /* Line 1455 of yacc.c  */
-#line 13459 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13471 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2339:
 
 /* Line 1455 of yacc.c  */
-#line 13463 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13475 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= OPT_DEFAULT; }
     break;
 
   case 2340:
 
 /* Line 1455 of yacc.c  */
-#line 13464 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13476 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->one_shot_set= 1; (yyval.num)= OPT_SESSION; }
     break;
 
   case 2341:
 
 /* Line 1455 of yacc.c  */
-#line 13468 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13480 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2342:
 
 /* Line 1455 of yacc.c  */
-#line 13469 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13481 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_GLOBAL; }
     break;
 
   case 2343:
 
 /* Line 1455 of yacc.c  */
-#line 13470 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13482 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2344:
 
 /* Line 1455 of yacc.c  */
-#line 13471 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13483 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2345:
 
 /* Line 1455 of yacc.c  */
-#line 13475 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13487 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_DEFAULT; }
     break;
 
   case 2346:
 
 /* Line 1455 of yacc.c  */
-#line 13476 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13488 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_GLOBAL; }
     break;
 
   case 2347:
 
 /* Line 1455 of yacc.c  */
-#line 13477 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13489 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2348:
 
 /* Line 1455 of yacc.c  */
-#line 13478 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13490 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.var_type)=OPT_SESSION; }
     break;
 
   case 2351:
 
 /* Line 1455 of yacc.c  */
-#line 13488 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13500 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             LEX_STRING *name= &(yyvsp[(2) - (4)].variable).base_name;
@@ -38232,7 +38250,7 @@ yyreduce:
   case 2352:
 
 /* Line 1455 of yacc.c  */
-#line 13529 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13541 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->option_type= (yyvsp[(1) - (5)].var_type);
@@ -38252,7 +38270,7 @@ yyreduce:
   case 2353:
 
 /* Line 1455 of yacc.c  */
-#line 13547 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13559 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Item_func_set_user_var *item;
             item= new (thd->mem_root) Item_func_set_user_var((yyvsp[(2) - (4)].lex_str), (yyvsp[(4) - (4)].item));
@@ -38268,7 +38286,7 @@ yyreduce:
   case 2354:
 
 /* Line 1455 of yacc.c  */
-#line 13558 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13570 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             struct sys_var_with_base tmp= (yyvsp[(4) - (6)].variable);
             /* Lookup if necessary: must be a system variable. */
@@ -38285,7 +38303,7 @@ yyreduce:
   case 2355:
 
 /* Line 1455 of yacc.c  */
-#line 13570 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13582 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             CHARSET_INFO *cs2;
@@ -38303,7 +38321,7 @@ yyreduce:
   case 2356:
 
 /* Line 1455 of yacc.c  */
-#line 13583 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13595 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             sp_pcontext *spc= lex->spcont;
@@ -38323,7 +38341,7 @@ yyreduce:
   case 2357:
 
 /* Line 1455 of yacc.c  */
-#line 13598 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13610 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             CHARSET_INFO *cs2;
@@ -38347,7 +38365,7 @@ yyreduce:
   case 2358:
 
 /* Line 1455 of yacc.c  */
-#line 13617 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13629 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             LEX_USER *user;
@@ -38378,7 +38396,7 @@ yyreduce:
   case 2359:
 
 /* Line 1455 of yacc.c  */
-#line 13643 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13655 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             set_var_password *var= new set_var_password((yyvsp[(3) - (5)].lex_user),(yyvsp[(5) - (5)].simple_string));
             if (var == NULL)
@@ -38393,7 +38411,7 @@ yyreduce:
   case 2360:
 
 /* Line 1455 of yacc.c  */
-#line 13656 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13668 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             sp_pcontext *spc= thd->lex->spcont;
             sp_variable_t *spv;
@@ -38424,7 +38442,7 @@ yyreduce:
   case 2361:
 
 /* Line 1455 of yacc.c  */
-#line 13682 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13694 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (check_reserved_words(&(yyvsp[(1) - (3)].lex_str)))
@@ -38472,7 +38490,7 @@ yyreduce:
   case 2362:
 
 /* Line 1455 of yacc.c  */
-#line 13725 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13737 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             sys_var *tmp=find_sys_var(thd, (yyvsp[(3) - (3)].lex_str).str, (yyvsp[(3) - (3)].lex_str).length);
             if (!tmp)
@@ -38488,42 +38506,42 @@ yyreduce:
   case 2363:
 
 /* Line 1455 of yacc.c  */
-#line 13738 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13750 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.tx_isolation)= ISO_READ_UNCOMMITTED; }
     break;
 
   case 2364:
 
 /* Line 1455 of yacc.c  */
-#line 13739 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13751 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.tx_isolation)= ISO_READ_COMMITTED; }
     break;
 
   case 2365:
 
 /* Line 1455 of yacc.c  */
-#line 13740 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13752 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.tx_isolation)= ISO_REPEATABLE_READ; }
     break;
 
   case 2366:
 
 /* Line 1455 of yacc.c  */
-#line 13741 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13753 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.tx_isolation)= ISO_SERIALIZABLE; }
     break;
 
   case 2367:
 
 /* Line 1455 of yacc.c  */
-#line 13745 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13757 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.simple_string)=(yyvsp[(1) - (1)].lex_str).str;}
     break;
 
   case 2368:
 
 /* Line 1455 of yacc.c  */
-#line 13747 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13759 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.simple_string)= (yyvsp[(3) - (4)].lex_str).length ? thd->variables.old_passwords ?
               Item_func_old_password::alloc(thd, (yyvsp[(3) - (4)].lex_str).str, (yyvsp[(3) - (4)].lex_str).length) :
@@ -38537,7 +38555,7 @@ yyreduce:
   case 2369:
 
 /* Line 1455 of yacc.c  */
-#line 13756 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13768 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.simple_string)= (yyvsp[(3) - (4)].lex_str).length ? Item_func_old_password::alloc(thd, (yyvsp[(3) - (4)].lex_str).str,
                                                           (yyvsp[(3) - (4)].lex_str).length) :
@@ -38550,21 +38568,21 @@ yyreduce:
   case 2370:
 
 /* Line 1455 of yacc.c  */
-#line 13767 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13779 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)=(yyvsp[(1) - (1)].item); }
     break;
 
   case 2371:
 
 /* Line 1455 of yacc.c  */
-#line 13768 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13780 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.item)=0; }
     break;
 
   case 2372:
 
 /* Line 1455 of yacc.c  */
-#line 13770 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13782 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)=new (thd->mem_root) Item_string("ON",  2, system_charset_info);
             if ((yyval.item) == NULL)
@@ -38575,7 +38593,7 @@ yyreduce:
   case 2373:
 
 /* Line 1455 of yacc.c  */
-#line 13776 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13788 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)=new (thd->mem_root) Item_string("ALL", 3, system_charset_info);
             if ((yyval.item) == NULL)
@@ -38586,7 +38604,7 @@ yyreduce:
   case 2374:
 
 /* Line 1455 of yacc.c  */
-#line 13782 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13794 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.item)=new (thd->mem_root) Item_string("binary", 6, system_charset_info);
             if ((yyval.item) == NULL)
@@ -38597,7 +38615,7 @@ yyreduce:
   case 2375:
 
 /* Line 1455 of yacc.c  */
-#line 13793 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13805 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
 
@@ -38613,28 +38631,28 @@ yyreduce:
   case 2376:
 
 /* Line 1455 of yacc.c  */
-#line 13804 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13816 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2377:
 
 /* Line 1455 of yacc.c  */
-#line 13808 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13820 "/home/buildbot/git/sql/sql_yacc.yy"
     { }
     break;
 
   case 2378:
 
 /* Line 1455 of yacc.c  */
-#line 13809 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13821 "/home/buildbot/git/sql/sql_yacc.yy"
     { }
     break;
 
   case 2381:
 
 /* Line 1455 of yacc.c  */
-#line 13819 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13831 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             thr_lock_type lock_type= (thr_lock_type) (yyvsp[(3) - (3)].num);
             bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE);
@@ -38651,21 +38669,21 @@ yyreduce:
   case 2382:
 
 /* Line 1455 of yacc.c  */
-#line 13833 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13845 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= TL_READ_NO_INSERT; }
     break;
 
   case 2383:
 
 /* Line 1455 of yacc.c  */
-#line 13834 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13846 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= TL_WRITE_DEFAULT; }
     break;
 
   case 2384:
 
 /* Line 1455 of yacc.c  */
-#line 13836 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13848 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.num)= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT);
           }
@@ -38674,21 +38692,21 @@ yyreduce:
   case 2385:
 
 /* Line 1455 of yacc.c  */
-#line 13840 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13852 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= TL_WRITE_LOW_PRIORITY; }
     break;
 
   case 2386:
 
 /* Line 1455 of yacc.c  */
-#line 13841 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13853 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= TL_READ; }
     break;
 
   case 2387:
 
 /* Line 1455 of yacc.c  */
-#line 13846 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13858 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
 
@@ -38704,14 +38722,14 @@ yyreduce:
   case 2388:
 
 /* Line 1455 of yacc.c  */
-#line 13857 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13869 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2389:
 
 /* Line 1455 of yacc.c  */
-#line 13866 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13878 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->sphead)
@@ -38728,7 +38746,7 @@ yyreduce:
   case 2390:
 
 /* Line 1455 of yacc.c  */
-#line 13878 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13890 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->sphead)
@@ -38745,7 +38763,7 @@ yyreduce:
   case 2391:
 
 /* Line 1455 of yacc.c  */
-#line 13890 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13902 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->sphead)
@@ -38770,7 +38788,7 @@ yyreduce:
   case 2392:
 
 /* Line 1455 of yacc.c  */
-#line 13910 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13922 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->expr_allows_subselect= TRUE;
             /* Stored functions are not supported for HANDLER READ. */
@@ -38786,63 +38804,63 @@ yyreduce:
   case 2393:
 
 /* Line 1455 of yacc.c  */
-#line 13923 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13935 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ident= null_lex_str; }
     break;
 
   case 2394:
 
 /* Line 1455 of yacc.c  */
-#line 13924 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13936 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ident= (yyvsp[(1) - (2)].lex_str); }
     break;
 
   case 2395:
 
 /* Line 1455 of yacc.c  */
-#line 13928 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13940 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ha_read_mode = RFIRST; }
     break;
 
   case 2396:
 
 /* Line 1455 of yacc.c  */
-#line 13929 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13941 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ha_read_mode = RNEXT;  }
     break;
 
   case 2397:
 
 /* Line 1455 of yacc.c  */
-#line 13933 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13945 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ha_read_mode = RFIRST; }
     break;
 
   case 2398:
 
 /* Line 1455 of yacc.c  */
-#line 13934 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13946 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ha_read_mode = RNEXT;  }
     break;
 
   case 2399:
 
 /* Line 1455 of yacc.c  */
-#line 13935 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13947 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ha_read_mode = RPREV;  }
     break;
 
   case 2400:
 
 /* Line 1455 of yacc.c  */
-#line 13936 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13948 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->ha_read_mode = RLAST;  }
     break;
 
   case 2401:
 
 /* Line 1455 of yacc.c  */
-#line 13938 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13950 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->ha_read_mode = RKEY;
@@ -38855,56 +38873,56 @@ yyreduce:
   case 2402:
 
 /* Line 1455 of yacc.c  */
-#line 13946 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13958 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2403:
 
 /* Line 1455 of yacc.c  */
-#line 13950 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13962 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.ha_rkey_mode)=HA_READ_KEY_EXACT;   }
     break;
 
   case 2404:
 
 /* Line 1455 of yacc.c  */
-#line 13951 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13963 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.ha_rkey_mode)=HA_READ_KEY_OR_NEXT; }
     break;
 
   case 2405:
 
 /* Line 1455 of yacc.c  */
-#line 13952 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13964 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.ha_rkey_mode)=HA_READ_KEY_OR_PREV; }
     break;
 
   case 2406:
 
 /* Line 1455 of yacc.c  */
-#line 13953 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13965 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.ha_rkey_mode)=HA_READ_AFTER_KEY;   }
     break;
 
   case 2407:
 
 /* Line 1455 of yacc.c  */
-#line 13954 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13966 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.ha_rkey_mode)=HA_READ_BEFORE_KEY;  }
     break;
 
   case 2408:
 
 /* Line 1455 of yacc.c  */
-#line 13961 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13973 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2409:
 
 /* Line 1455 of yacc.c  */
-#line 13966 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13978 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_REVOKE;
@@ -38915,7 +38933,7 @@ yyreduce:
   case 2410:
 
 /* Line 1455 of yacc.c  */
-#line 13972 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13984 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->columns.elements)
@@ -38931,7 +38949,7 @@ yyreduce:
   case 2411:
 
 /* Line 1455 of yacc.c  */
-#line 13983 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 13995 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->columns.elements)
@@ -38947,7 +38965,7 @@ yyreduce:
   case 2412:
 
 /* Line 1455 of yacc.c  */
-#line 13994 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14006 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_REVOKE_ALL;
           }
@@ -38956,7 +38974,7 @@ yyreduce:
   case 2413:
 
 /* Line 1455 of yacc.c  */
-#line 13998 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14010 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->users_list.push_front ((yyvsp[(3) - (5)].lex_user));
@@ -38968,14 +38986,14 @@ yyreduce:
   case 2414:
 
 /* Line 1455 of yacc.c  */
-#line 14008 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14020 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2415:
 
 /* Line 1455 of yacc.c  */
-#line 14014 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14026 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_GRANT;
@@ -38986,7 +39004,7 @@ yyreduce:
   case 2416:
 
 /* Line 1455 of yacc.c  */
-#line 14021 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14033 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->columns.elements)
@@ -39002,7 +39020,7 @@ yyreduce:
   case 2417:
 
 /* Line 1455 of yacc.c  */
-#line 14033 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14045 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             if (lex->columns.elements)
@@ -39018,7 +39036,7 @@ yyreduce:
   case 2418:
 
 /* Line 1455 of yacc.c  */
-#line 14044 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14056 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->users_list.push_front ((yyvsp[(3) - (6)].lex_user));
@@ -39030,14 +39048,14 @@ yyreduce:
   case 2421:
 
 /* Line 1455 of yacc.c  */
-#line 14058 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14070 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2422:
 
 /* Line 1455 of yacc.c  */
-#line 14060 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14072 "/home/buildbot/git/sql/sql_yacc.yy"
     { 
             Lex->all_privileges= 1; 
             Lex->grant= GLOBAL_ACLS;
@@ -39047,259 +39065,259 @@ yyreduce:
   case 2427:
 
 /* Line 1455 of yacc.c  */
-#line 14078 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14090 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->which_columns = SELECT_ACL;}
     break;
 
   case 2428:
 
 /* Line 1455 of yacc.c  */
-#line 14079 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14091 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2429:
 
 /* Line 1455 of yacc.c  */
-#line 14081 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14093 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->which_columns = INSERT_ACL;}
     break;
 
   case 2430:
 
 /* Line 1455 of yacc.c  */
-#line 14082 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14094 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2431:
 
 /* Line 1455 of yacc.c  */
-#line 14084 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14096 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->which_columns = UPDATE_ACL; }
     break;
 
   case 2432:
 
 /* Line 1455 of yacc.c  */
-#line 14085 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14097 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2433:
 
 /* Line 1455 of yacc.c  */
-#line 14087 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14099 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->which_columns = REFERENCES_ACL;}
     break;
 
   case 2434:
 
 /* Line 1455 of yacc.c  */
-#line 14088 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14100 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2435:
 
 /* Line 1455 of yacc.c  */
-#line 14089 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14101 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= DELETE_ACL;}
     break;
 
   case 2436:
 
 /* Line 1455 of yacc.c  */
-#line 14090 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14102 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2437:
 
 /* Line 1455 of yacc.c  */
-#line 14091 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14103 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= INDEX_ACL;}
     break;
 
   case 2438:
 
 /* Line 1455 of yacc.c  */
-#line 14092 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14104 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= ALTER_ACL;}
     break;
 
   case 2439:
 
 /* Line 1455 of yacc.c  */
-#line 14093 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14105 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= CREATE_ACL;}
     break;
 
   case 2440:
 
 /* Line 1455 of yacc.c  */
-#line 14094 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14106 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= DROP_ACL;}
     break;
 
   case 2441:
 
 /* Line 1455 of yacc.c  */
-#line 14095 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14107 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= EXECUTE_ACL;}
     break;
 
   case 2442:
 
 /* Line 1455 of yacc.c  */
-#line 14096 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14108 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= RELOAD_ACL;}
     break;
 
   case 2443:
 
 /* Line 1455 of yacc.c  */
-#line 14097 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14109 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= SHUTDOWN_ACL;}
     break;
 
   case 2444:
 
 /* Line 1455 of yacc.c  */
-#line 14098 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14110 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= PROCESS_ACL;}
     break;
 
   case 2445:
 
 /* Line 1455 of yacc.c  */
-#line 14099 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14111 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= FILE_ACL;}
     break;
 
   case 2446:
 
 /* Line 1455 of yacc.c  */
-#line 14100 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14112 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= GRANT_ACL;}
     break;
 
   case 2447:
 
 /* Line 1455 of yacc.c  */
-#line 14101 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14113 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= SHOW_DB_ACL;}
     break;
 
   case 2448:
 
 /* Line 1455 of yacc.c  */
-#line 14102 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14114 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= SUPER_ACL;}
     break;
 
   case 2449:
 
 /* Line 1455 of yacc.c  */
-#line 14103 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14115 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= CREATE_TMP_ACL;}
     break;
 
   case 2450:
 
 /* Line 1455 of yacc.c  */
-#line 14104 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14116 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= LOCK_TABLES_ACL; }
     break;
 
   case 2451:
 
 /* Line 1455 of yacc.c  */
-#line 14105 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14117 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= REPL_SLAVE_ACL; }
     break;
 
   case 2452:
 
 /* Line 1455 of yacc.c  */
-#line 14106 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14118 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= REPL_CLIENT_ACL; }
     break;
 
   case 2453:
 
 /* Line 1455 of yacc.c  */
-#line 14107 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14119 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= CREATE_VIEW_ACL; }
     break;
 
   case 2454:
 
 /* Line 1455 of yacc.c  */
-#line 14108 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14120 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= SHOW_VIEW_ACL; }
     break;
 
   case 2455:
 
 /* Line 1455 of yacc.c  */
-#line 14109 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14121 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= CREATE_PROC_ACL; }
     break;
 
   case 2456:
 
 /* Line 1455 of yacc.c  */
-#line 14110 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14122 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= ALTER_PROC_ACL; }
     break;
 
   case 2457:
 
 /* Line 1455 of yacc.c  */
-#line 14111 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14123 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= CREATE_USER_ACL; }
     break;
 
   case 2458:
 
 /* Line 1455 of yacc.c  */
-#line 14112 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14124 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= EVENT_ACL;}
     break;
 
   case 2459:
 
 /* Line 1455 of yacc.c  */
-#line 14113 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14125 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= TRIGGER_ACL; }
     break;
 
   case 2460:
 
 /* Line 1455 of yacc.c  */
-#line 14114 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14126 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= CREATE_TABLESPACE_ACL; }
     break;
 
   case 2461:
 
 /* Line 1455 of yacc.c  */
-#line 14118 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14130 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2462:
 
 /* Line 1455 of yacc.c  */
-#line 14119 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14131 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2465:
 
 /* Line 1455 of yacc.c  */
-#line 14129 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14141 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->x509_subject)
@@ -39314,7 +39332,7 @@ yyreduce:
   case 2466:
 
 /* Line 1455 of yacc.c  */
-#line 14139 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14151 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->x509_issuer)
@@ -39329,7 +39347,7 @@ yyreduce:
   case 2467:
 
 /* Line 1455 of yacc.c  */
-#line 14149 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14161 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (lex->ssl_cipher)
@@ -39344,7 +39362,7 @@ yyreduce:
   case 2468:
 
 /* Line 1455 of yacc.c  */
-#line 14162 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14174 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             size_t dummy;
@@ -39364,7 +39382,7 @@ yyreduce:
   case 2469:
 
 /* Line 1455 of yacc.c  */
-#line 14177 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14189 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->current_select->db = (yyvsp[(1) - (3)].lex_str).str;
@@ -39382,7 +39400,7 @@ yyreduce:
   case 2470:
 
 /* Line 1455 of yacc.c  */
-#line 14190 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14202 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->current_select->db = NULL;
@@ -39400,7 +39418,7 @@ yyreduce:
   case 2471:
 
 /* Line 1455 of yacc.c  */
-#line 14203 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14215 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (!lex->current_select->add_table_to_list(lex->thd, (yyvsp[(1) - (1)].table),NULL,
@@ -39414,7 +39432,7 @@ yyreduce:
   case 2472:
 
 /* Line 1455 of yacc.c  */
-#line 14215 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14227 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (Lex->users_list.push_back((yyvsp[(1) - (1)].lex_user)))
               MYSQL_YYABORT;
@@ -39424,7 +39442,7 @@ yyreduce:
   case 2473:
 
 /* Line 1455 of yacc.c  */
-#line 14220 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14232 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (Lex->users_list.push_back((yyvsp[(3) - (3)].lex_user)))
               MYSQL_YYABORT;
@@ -39434,7 +39452,7 @@ yyreduce:
   case 2474:
 
 /* Line 1455 of yacc.c  */
-#line 14228 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14240 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (Lex->users_list.push_back((yyvsp[(1) - (1)].lex_user)))
               MYSQL_YYABORT;
@@ -39444,7 +39462,7 @@ yyreduce:
   case 2475:
 
 /* Line 1455 of yacc.c  */
-#line 14233 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14245 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (Lex->users_list.push_back((yyvsp[(3) - (3)].lex_user)))
               MYSQL_YYABORT;
@@ -39454,7 +39472,7 @@ yyreduce:
   case 2480:
 
 /* Line 1455 of yacc.c  */
-#line 14244 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14256 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.lex_user)=(yyvsp[(1) - (4)].lex_user); (yyvsp[(1) - (4)].lex_user)->password=(yyvsp[(4) - (4)].lex_str);
             if ((yyvsp[(4) - (4)].lex_str).length)
@@ -39486,7 +39504,7 @@ yyreduce:
   case 2481:
 
 /* Line 1455 of yacc.c  */
-#line 14271 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14283 "/home/buildbot/git/sql/sql_yacc.yy"
     { 
             (yyval.lex_user)= (yyvsp[(1) - (5)].lex_user); 
             (yyvsp[(1) - (5)].lex_user)->password= (yyvsp[(5) - (5)].lex_str); 
@@ -39496,7 +39514,7 @@ yyreduce:
   case 2482:
 
 /* Line 1455 of yacc.c  */
-#line 14276 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14288 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.lex_user)= (yyvsp[(1) - (4)].lex_user);
             (yyvsp[(1) - (4)].lex_user)->plugin= (yyvsp[(4) - (4)].lex_str);
@@ -39507,7 +39525,7 @@ yyreduce:
   case 2483:
 
 /* Line 1455 of yacc.c  */
-#line 14282 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14294 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.lex_user)= (yyvsp[(1) - (6)].lex_user);
             (yyvsp[(1) - (6)].lex_user)->plugin= (yyvsp[(4) - (6)].lex_str);
@@ -39518,14 +39536,14 @@ yyreduce:
   case 2484:
 
 /* Line 1455 of yacc.c  */
-#line 14288 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14300 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.lex_user)= (yyvsp[(1) - (1)].lex_user); (yyvsp[(1) - (1)].lex_user)->password= null_lex_str; }
     break;
 
   case 2485:
 
 /* Line 1455 of yacc.c  */
-#line 14293 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14305 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->grant |= lex->which_columns;
@@ -39535,7 +39553,7 @@ yyreduce:
   case 2489:
 
 /* Line 1455 of yacc.c  */
-#line 14307 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14319 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             String *new_str = new (thd->mem_root) String((const char*) (yyvsp[(1) - (1)].lex_str).str,(yyvsp[(1) - (1)].lex_str).length,system_charset_info);
             if (new_str == NULL)
@@ -39565,7 +39583,7 @@ yyreduce:
   case 2491:
 
 /* Line 1455 of yacc.c  */
-#line 14336 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14348 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->ssl_type=SSL_TYPE_SPECIFIED;
           }
@@ -39574,7 +39592,7 @@ yyreduce:
   case 2492:
 
 /* Line 1455 of yacc.c  */
-#line 14340 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14352 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->ssl_type=SSL_TYPE_ANY;
           }
@@ -39583,7 +39601,7 @@ yyreduce:
   case 2493:
 
 /* Line 1455 of yacc.c  */
-#line 14344 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14356 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->ssl_type=SSL_TYPE_X509;
           }
@@ -39592,7 +39610,7 @@ yyreduce:
   case 2494:
 
 /* Line 1455 of yacc.c  */
-#line 14348 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14360 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->ssl_type=SSL_TYPE_NONE;
           }
@@ -39601,49 +39619,49 @@ yyreduce:
   case 2495:
 
 /* Line 1455 of yacc.c  */
-#line 14354 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14366 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2497:
 
 /* Line 1455 of yacc.c  */
-#line 14359 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14371 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2498:
 
 /* Line 1455 of yacc.c  */
-#line 14360 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14372 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= GRANT_ACL;}
     break;
 
   case 2499:
 
 /* Line 1455 of yacc.c  */
-#line 14364 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14376 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2500:
 
 /* Line 1455 of yacc.c  */
-#line 14365 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14377 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2501:
 
 /* Line 1455 of yacc.c  */
-#line 14369 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14381 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->grant |= GRANT_ACL;}
     break;
 
   case 2502:
 
 /* Line 1455 of yacc.c  */
-#line 14371 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14383 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->mqh.questions=(yyvsp[(2) - (2)].ulong_num);
@@ -39654,7 +39672,7 @@ yyreduce:
   case 2503:
 
 /* Line 1455 of yacc.c  */
-#line 14377 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14389 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->mqh.updates=(yyvsp[(2) - (2)].ulong_num);
@@ -39665,7 +39683,7 @@ yyreduce:
   case 2504:
 
 /* Line 1455 of yacc.c  */
-#line 14383 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14395 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->mqh.conn_per_hour= (yyvsp[(2) - (2)].ulong_num);
@@ -39676,7 +39694,7 @@ yyreduce:
   case 2505:
 
 /* Line 1455 of yacc.c  */
-#line 14389 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14401 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->mqh.user_conn= (yyvsp[(2) - (2)].num);
@@ -39687,7 +39705,7 @@ yyreduce:
   case 2506:
 
 /* Line 1455 of yacc.c  */
-#line 14398 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14410 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command = SQLCOM_BEGIN;
@@ -39698,84 +39716,84 @@ yyreduce:
   case 2507:
 
 /* Line 1455 of yacc.c  */
-#line 14403 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14415 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2508:
 
 /* Line 1455 of yacc.c  */
-#line 14407 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14419 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2509:
 
 /* Line 1455 of yacc.c  */
-#line 14408 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14420 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2510:
 
 /* Line 1455 of yacc.c  */
-#line 14413 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14425 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.m_yes_no_unk)= TVL_UNKNOWN; }
     break;
 
   case 2511:
 
 /* Line 1455 of yacc.c  */
-#line 14414 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14426 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.m_yes_no_unk)= TVL_NO; }
     break;
 
   case 2512:
 
 /* Line 1455 of yacc.c  */
-#line 14415 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14427 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.m_yes_no_unk)= TVL_YES; }
     break;
 
   case 2513:
 
 /* Line 1455 of yacc.c  */
-#line 14420 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14432 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.m_yes_no_unk)= TVL_UNKNOWN; }
     break;
 
   case 2514:
 
 /* Line 1455 of yacc.c  */
-#line 14421 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14433 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.m_yes_no_unk)= TVL_YES; }
     break;
 
   case 2515:
 
 /* Line 1455 of yacc.c  */
-#line 14422 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14434 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.m_yes_no_unk)= TVL_NO; }
     break;
 
   case 2516:
 
 /* Line 1455 of yacc.c  */
-#line 14426 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14438 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2517:
 
 /* Line 1455 of yacc.c  */
-#line 14427 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14439 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2518:
 
 /* Line 1455 of yacc.c  */
-#line 14432 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14444 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_COMMIT;
@@ -39789,7 +39807,7 @@ yyreduce:
   case 2519:
 
 /* Line 1455 of yacc.c  */
-#line 14444 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14456 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_ROLLBACK;
@@ -39803,7 +39821,7 @@ yyreduce:
   case 2520:
 
 /* Line 1455 of yacc.c  */
-#line 14454 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14466 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_ROLLBACK_TO_SAVEPOINT;
@@ -39814,7 +39832,7 @@ yyreduce:
   case 2521:
 
 /* Line 1455 of yacc.c  */
-#line 14463 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14475 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_SAVEPOINT;
@@ -39825,7 +39843,7 @@ yyreduce:
   case 2522:
 
 /* Line 1455 of yacc.c  */
-#line 14472 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14484 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             lex->sql_command= SQLCOM_RELEASE_SAVEPOINT;
@@ -39836,14 +39854,14 @@ yyreduce:
   case 2523:
 
 /* Line 1455 of yacc.c  */
-#line 14485 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14497 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2525:
 
 /* Line 1455 of yacc.c  */
-#line 14491 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14503 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (add_select_to_union_list(Lex, (bool)(yyvsp[(2) - (2)].num), TRUE))
               MYSQL_YYABORT;
@@ -39853,7 +39871,7 @@ yyreduce:
   case 2526:
 
 /* Line 1455 of yacc.c  */
-#line 14496 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14508 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             /*
               Remove from the name resolution context stack the context of the
@@ -39866,42 +39884,42 @@ yyreduce:
   case 2527:
 
 /* Line 1455 of yacc.c  */
-#line 14506 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14518 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 0; }
     break;
 
   case 2528:
 
 /* Line 1455 of yacc.c  */
-#line 14507 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14519 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 1; }
     break;
 
   case 2529:
 
 /* Line 1455 of yacc.c  */
-#line 14508 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14520 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)= 1; }
     break;
 
   case 2530:
 
 /* Line 1455 of yacc.c  */
-#line 14512 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14524 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.is_not_empty)= false; }
     break;
 
   case 2531:
 
 /* Line 1455 of yacc.c  */
-#line 14513 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14525 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.is_not_empty)= true; }
     break;
 
   case 2532:
 
 /* Line 1455 of yacc.c  */
-#line 14517 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14529 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE);
@@ -39921,7 +39939,7 @@ yyreduce:
   case 2533:
 
 /* Line 1455 of yacc.c  */
-#line 14532 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14544 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             thd->lex->current_select->no_table_names_allowed= 0;
             thd->where= "";
@@ -39931,28 +39949,28 @@ yyreduce:
   case 2536:
 
 /* Line 1455 of yacc.c  */
-#line 14544 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14556 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)=1; }
     break;
 
   case 2537:
 
 /* Line 1455 of yacc.c  */
-#line 14545 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14557 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)=1; }
     break;
 
   case 2538:
 
 /* Line 1455 of yacc.c  */
-#line 14546 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14558 "/home/buildbot/git/sql/sql_yacc.yy"
     { (yyval.num)=0; }
     break;
 
   case 2539:
 
 /* Line 1455 of yacc.c  */
-#line 14551 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14563 "/home/buildbot/git/sql/sql_yacc.yy"
     { 
             (yyval.select_lex)= Lex->current_select->master_unit()->first_select();
           }
@@ -39961,7 +39979,7 @@ yyreduce:
   case 2540:
 
 /* Line 1455 of yacc.c  */
-#line 14555 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14567 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             (yyval.select_lex)= Lex->current_select->master_unit()->first_select();
           }
@@ -39970,7 +39988,7 @@ yyreduce:
   case 2542:
 
 /* Line 1455 of yacc.c  */
-#line 14564 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14576 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (add_select_to_union_list(Lex, (bool)(yyvsp[(3) - (3)].num), FALSE))
               MYSQL_YYABORT;
@@ -39980,7 +39998,7 @@ yyreduce:
   case 2543:
 
 /* Line 1455 of yacc.c  */
-#line 14570 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14582 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->pop_context();
             (yyval.select_lex)= (yyvsp[(1) - (6)].select_lex);
@@ -39990,7 +40008,7 @@ yyreduce:
   case 2544:
 
 /* Line 1455 of yacc.c  */
-#line 14579 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14591 "/home/buildbot/git/sql/sql_yacc.yy"
     { 
             (yyval.select_lex)= (yyvsp[(2) - (3)].select_lex);
           }
@@ -39999,7 +40017,7 @@ yyreduce:
   case 2545:
 
 /* Line 1455 of yacc.c  */
-#line 14585 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14597 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
             if (!lex->expr_allows_subselect ||
@@ -40023,7 +40041,7 @@ yyreduce:
   case 2546:
 
 /* Line 1455 of yacc.c  */
-#line 14606 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14618 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex=Lex;
 
@@ -40051,14 +40069,14 @@ yyreduce:
   case 2551:
 
 /* Line 1455 of yacc.c  */
-#line 14641 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14653 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->options|= SELECT_STRAIGHT_JOIN; }
     break;
 
   case 2552:
 
 /* Line 1455 of yacc.c  */
-#line 14643 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14655 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (check_simple_select())
               MYSQL_YYABORT;
@@ -40071,28 +40089,28 @@ yyreduce:
   case 2553:
 
 /* Line 1455 of yacc.c  */
-#line 14650 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14662 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->options|= SELECT_DISTINCT; }
     break;
 
   case 2554:
 
 /* Line 1455 of yacc.c  */
-#line 14651 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14663 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->options|= SELECT_SMALL_RESULT; }
     break;
 
   case 2555:
 
 /* Line 1455 of yacc.c  */
-#line 14652 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14664 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->options|= SELECT_BIG_RESULT; }
     break;
 
   case 2556:
 
 /* Line 1455 of yacc.c  */
-#line 14654 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14666 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (check_simple_select())
               MYSQL_YYABORT;
@@ -40103,7 +40121,7 @@ yyreduce:
   case 2557:
 
 /* Line 1455 of yacc.c  */
-#line 14660 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14672 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             if (check_simple_select())
               MYSQL_YYABORT;
@@ -40114,35 +40132,35 @@ yyreduce:
   case 2558:
 
 /* Line 1455 of yacc.c  */
-#line 14665 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14677 "/home/buildbot/git/sql/sql_yacc.yy"
     { Select->options|= SELECT_ALL; }
     break;
 
   case 2559:
 
 /* Line 1455 of yacc.c  */
-#line 14676 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14688 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2560:
 
 /* Line 1455 of yacc.c  */
-#line 14678 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14690 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2561:
 
 /* Line 1455 of yacc.c  */
-#line 14680 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14692 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2575:
 
 /* Line 1455 of yacc.c  */
-#line 14713 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14725 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             /*
               We have to distinguish missing DEFINER-clause from case when
@@ -40158,7 +40176,7 @@ yyreduce:
   case 2576:
 
 /* Line 1455 of yacc.c  */
-#line 14727 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14739 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             thd->lex->definer= get_current_user(thd, (yyvsp[(3) - (3)].lex_user));
           }
@@ -40167,77 +40185,77 @@ yyreduce:
   case 2577:
 
 /* Line 1455 of yacc.c  */
-#line 14740 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14752 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2578:
 
 /* Line 1455 of yacc.c  */
-#line 14742 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14754 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2579:
 
 /* Line 1455 of yacc.c  */
-#line 14744 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14756 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2580:
 
 /* Line 1455 of yacc.c  */
-#line 14749 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14761 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_mode= VIEW_CREATE_OR_REPLACE; }
     break;
 
   case 2581:
 
 /* Line 1455 of yacc.c  */
-#line 14754 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14766 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
     break;
 
   case 2582:
 
 /* Line 1455 of yacc.c  */
-#line 14756 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14768 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
     break;
 
   case 2583:
 
 /* Line 1455 of yacc.c  */
-#line 14758 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14770 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
     break;
 
   case 2584:
 
 /* Line 1455 of yacc.c  */
-#line 14763 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14775 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_suid= VIEW_SUID_DEFAULT; }
     break;
 
   case 2585:
 
 /* Line 1455 of yacc.c  */
-#line 14765 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14777 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_suid= VIEW_SUID_DEFINER; }
     break;
 
   case 2586:
 
 /* Line 1455 of yacc.c  */
-#line 14767 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14779 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_suid= VIEW_SUID_INVOKER; }
     break;
 
   case 2587:
 
 /* Line 1455 of yacc.c  */
-#line 14772 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14784 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             lex->sql_command= SQLCOM_CREATE_VIEW;
@@ -40254,14 +40272,14 @@ yyreduce:
   case 2589:
 
 /* Line 1455 of yacc.c  */
-#line 14788 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14800 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2591:
 
 /* Line 1455 of yacc.c  */
-#line 14794 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14806 "/home/buildbot/git/sql/sql_yacc.yy"
     {
               Lex->view_list.push_back((LEX_STRING*)
               sql_memdup(&(yyvsp[(1) - (1)].lex_str), sizeof(LEX_STRING)));
@@ -40271,7 +40289,7 @@ yyreduce:
   case 2592:
 
 /* Line 1455 of yacc.c  */
-#line 14799 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14811 "/home/buildbot/git/sql/sql_yacc.yy"
     {
               Lex->view_list.push_back((LEX_STRING*)
               sql_memdup(&(yyvsp[(3) - (3)].lex_str), sizeof(LEX_STRING)));
@@ -40281,7 +40299,7 @@ yyreduce:
   case 2593:
 
 /* Line 1455 of yacc.c  */
-#line 14806 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14818 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->parsing_options.allows_variable= FALSE;
@@ -40295,7 +40313,7 @@ yyreduce:
   case 2594:
 
 /* Line 1455 of yacc.c  */
-#line 14815 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14827 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             uint len= YYLIP->get_cpp_ptr() - lex->create_view_select.str;
@@ -40313,35 +40331,35 @@ yyreduce:
   case 2597:
 
 /* Line 1455 of yacc.c  */
-#line 14836 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14848 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_check= VIEW_CHECK_NONE; }
     break;
 
   case 2598:
 
 /* Line 1455 of yacc.c  */
-#line 14838 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14850 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_check= VIEW_CHECK_CASCADED; }
     break;
 
   case 2599:
 
 /* Line 1455 of yacc.c  */
-#line 14840 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14852 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_check= VIEW_CHECK_CASCADED; }
     break;
 
   case 2600:
 
 /* Line 1455 of yacc.c  */
-#line 14842 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14854 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->create_view_check= VIEW_CHECK_LOCAL; }
     break;
 
   case 2601:
 
 /* Line 1455 of yacc.c  */
-#line 14859 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14871 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $8 */
             Lex->raw_trg_on_table_name_begin= YYLIP->get_tok_start();
           }
@@ -40350,7 +40368,7 @@ yyreduce:
   case 2602:
 
 /* Line 1455 of yacc.c  */
-#line 14865 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14877 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $12 */
             Lex->raw_trg_on_table_name_end= YYLIP->get_tok_start();
           }
@@ -40359,7 +40377,7 @@ yyreduce:
   case 2603:
 
 /* Line 1455 of yacc.c  */
-#line 14870 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14882 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $15 */
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -40393,7 +40411,7 @@ yyreduce:
   case 2604:
 
 /* Line 1455 of yacc.c  */
-#line 14899 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14911 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $17 */
             LEX *lex= Lex;
             sp_head *sp= lex->sphead;
@@ -40422,7 +40440,7 @@ yyreduce:
   case 2605:
 
 /* Line 1455 of yacc.c  */
-#line 14933 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14945 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             if (is_native_function(thd, & (yyvsp[(4) - (8)].lex_str)))
@@ -40443,7 +40461,7 @@ yyreduce:
   case 2606:
 
 /* Line 1455 of yacc.c  */
-#line 14950 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14962 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             if (is_native_function(thd, & (yyvsp[(3) - (7)].lex_str)))
@@ -40464,7 +40482,7 @@ yyreduce:
   case 2607:
 
 /* Line 1455 of yacc.c  */
-#line 14972 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 14984 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $5 */
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -40499,7 +40517,7 @@ yyreduce:
   case 2608:
 
 /* Line 1455 of yacc.c  */
-#line 15003 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15015 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $8 */
             Lex->sphead->m_param_end= YYLIP->get_cpp_tok_start();
           }
@@ -40508,7 +40526,7 @@ yyreduce:
   case 2609:
 
 /* Line 1455 of yacc.c  */
-#line 15007 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15019 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $10 */
             LEX *lex= Lex;
             lex->charset= NULL;
@@ -40522,7 +40540,7 @@ yyreduce:
   case 2610:
 
 /* Line 1455 of yacc.c  */
-#line 15016 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15028 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $12 */
             LEX *lex= Lex;
             sp_head *sp= lex->sphead;
@@ -40550,7 +40568,7 @@ yyreduce:
   case 2611:
 
 /* Line 1455 of yacc.c  */
-#line 15039 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15051 "/home/buildbot/git/sql/sql_yacc.yy"
     { /* $14 */
             LEX *lex= thd->lex;
             Lex_input_stream *lip= YYLIP;
@@ -40563,7 +40581,7 @@ yyreduce:
   case 2612:
 
 /* Line 1455 of yacc.c  */
-#line 15047 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15059 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
             sp_head *sp= lex->sphead;
@@ -40620,7 +40638,7 @@ yyreduce:
   case 2613:
 
 /* Line 1455 of yacc.c  */
-#line 15102 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15114 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             sp_head *sp;
@@ -40649,7 +40667,7 @@ yyreduce:
   case 2614:
 
 /* Line 1455 of yacc.c  */
-#line 15126 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15138 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             const char* tmp_param_begin;
 
@@ -40662,7 +40680,7 @@ yyreduce:
   case 2615:
 
 /* Line 1455 of yacc.c  */
-#line 15135 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15147 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
 
@@ -40674,7 +40692,7 @@ yyreduce:
   case 2616:
 
 /* Line 1455 of yacc.c  */
-#line 15142 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15154 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= thd->lex;
 
@@ -40686,7 +40704,7 @@ yyreduce:
   case 2617:
 
 /* Line 1455 of yacc.c  */
-#line 15149 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15161 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             sp_head *sp= lex->sphead;
@@ -40700,7 +40718,7 @@ yyreduce:
   case 2618:
 
 /* Line 1455 of yacc.c  */
-#line 15163 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15175 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_XA_START;
           }
@@ -40709,7 +40727,7 @@ yyreduce:
   case 2619:
 
 /* Line 1455 of yacc.c  */
-#line 15167 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15179 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_XA_END;
           }
@@ -40718,7 +40736,7 @@ yyreduce:
   case 2620:
 
 /* Line 1455 of yacc.c  */
-#line 15171 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15183 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_XA_PREPARE;
           }
@@ -40727,7 +40745,7 @@ yyreduce:
   case 2621:
 
 /* Line 1455 of yacc.c  */
-#line 15175 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15187 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_XA_COMMIT;
           }
@@ -40736,7 +40754,7 @@ yyreduce:
   case 2622:
 
 /* Line 1455 of yacc.c  */
-#line 15179 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15191 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_XA_ROLLBACK;
           }
@@ -40745,7 +40763,7 @@ yyreduce:
   case 2623:
 
 /* Line 1455 of yacc.c  */
-#line 15183 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15195 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             Lex->sql_command = SQLCOM_XA_RECOVER;
           }
@@ -40754,7 +40772,7 @@ yyreduce:
   case 2624:
 
 /* Line 1455 of yacc.c  */
-#line 15190 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15202 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             MYSQL_YYABORT_UNLESS((yyvsp[(1) - (1)].string)->length() <= MAXGTRIDSIZE);
             if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))
@@ -40766,7 +40784,7 @@ yyreduce:
   case 2625:
 
 /* Line 1455 of yacc.c  */
-#line 15197 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15209 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             MYSQL_YYABORT_UNLESS((yyvsp[(1) - (3)].string)->length() <= MAXGTRIDSIZE && (yyvsp[(3) - (3)].string)->length() <= MAXBQUALSIZE);
             if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))
@@ -40778,7 +40796,7 @@ yyreduce:
   case 2626:
 
 /* Line 1455 of yacc.c  */
-#line 15204 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15216 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             MYSQL_YYABORT_UNLESS((yyvsp[(1) - (5)].string)->length() <= MAXGTRIDSIZE && (yyvsp[(3) - (5)].string)->length() <= MAXBQUALSIZE);
             if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID))))
@@ -40790,84 +40808,84 @@ yyreduce:
   case 2627:
 
 /* Line 1455 of yacc.c  */
-#line 15213 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15225 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2628:
 
 /* Line 1455 of yacc.c  */
-#line 15214 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15226 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2629:
 
 /* Line 1455 of yacc.c  */
-#line 15218 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15230 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_NONE;        }
     break;
 
   case 2630:
 
 /* Line 1455 of yacc.c  */
-#line 15219 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15231 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_JOIN;        }
     break;
 
   case 2631:
 
 /* Line 1455 of yacc.c  */
-#line 15220 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15232 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_RESUME;      }
     break;
 
   case 2632:
 
 /* Line 1455 of yacc.c  */
-#line 15224 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15236 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_NONE;        }
     break;
 
   case 2633:
 
 /* Line 1455 of yacc.c  */
-#line 15225 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15237 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_ONE_PHASE;   }
     break;
 
   case 2634:
 
 /* Line 1455 of yacc.c  */
-#line 15230 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15242 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_NONE;        }
     break;
 
   case 2635:
 
 /* Line 1455 of yacc.c  */
-#line 15232 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15244 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_SUSPEND;     }
     break;
 
   case 2637:
 
 /* Line 1455 of yacc.c  */
-#line 15237 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15249 "/home/buildbot/git/sql/sql_yacc.yy"
     {}
     break;
 
   case 2638:
 
 /* Line 1455 of yacc.c  */
-#line 15238 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15250 "/home/buildbot/git/sql/sql_yacc.yy"
     { Lex->xa_opt=XA_FOR_MIGRATE; }
     break;
 
   case 2639:
 
 /* Line 1455 of yacc.c  */
-#line 15243 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15255 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_INSTALL_PLUGIN;
@@ -40879,7 +40897,7 @@ yyreduce:
   case 2640:
 
 /* Line 1455 of yacc.c  */
-#line 15250 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15262 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_INSTALL_PLUGIN;
@@ -40891,7 +40909,7 @@ yyreduce:
   case 2641:
 
 /* Line 1455 of yacc.c  */
-#line 15260 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15272 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
@@ -40902,7 +40920,7 @@ yyreduce:
   case 2642:
 
 /* Line 1455 of yacc.c  */
-#line 15266 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15278 "/home/buildbot/git/sql/sql_yacc.yy"
     {
             LEX *lex= Lex;
             lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
@@ -40914,7 +40932,7 @@ yyreduce:
   case 2643:
 
 /* Line 1455 of yacc.c  */
-#line 15277 "/home/buildbot/git/sql/sql_yacc.yy"
+#line 15289 "/home/buildbot/git/sql/sql_yacc.yy"
     {
 	  YYERROR;
 	}
@@ -40923,7 +40941,7 @@ yyreduce:
 
 
 /* Line 1455 of yacc.c  */
-#line 40927 "/home/buildbot/git/mkdist/sql/sql_yacc.cc"
+#line 40945 "/home/buildbot/git/mkdist/sql/sql_yacc.cc"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index ec246ae..a49dea6 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -10612,8 +10612,20 @@ procedure_clause:
             if (add_proc_to_list(lex->thd, item))
               MYSQL_YYABORT;
             Lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+
+            /*
+              PROCEDURE CLAUSE cannot handle subquery as one of its parameter,
+              so set expr_allows_subselect as false to disallow any subqueries
+              further. Reset expr_allows_subselect back to true once the
+              parameters are reduced.
+            */
+            Lex->expr_allows_subselect= false;
           }
           '(' procedure_list ')'
+          {
+            /* Subqueries are allowed from now.*/
+            Lex->expr_allows_subselect= true;
+          }
         ;
 
 procedure_list:
diff --git a/sql/table.cc b/sql/table.cc
index e4dee77..f521056 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5194,7 +5194,7 @@ Item *Field_iterator_table::create_item(THD *thd)
   if (item && thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY &&
       !thd->lex->in_sum_func && select->cur_pos_in_select_list != UNDEF_POS)
   {
-    select->non_agg_fields.push_back(item);
+    select->join->non_agg_fields.push_back(item);
     item->marker= select->cur_pos_in_select_list;
     select->set_non_agg_field_used(true);
   }
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 861f2a9..cc494a7 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -89,6 +89,18 @@ IF(NOT CMAKE_CROSSCOMPILING)
   "#include<stdint.h>
   int main()
   {
+    unsigned char	c;
+
+    __atomic_test_and_set(&c, __ATOMIC_ACQUIRE);
+    __atomic_clear(&c, __ATOMIC_RELEASE);
+    return(0);
+  }"
+  HAVE_IB_GCC_ATOMIC_TEST_AND_SET
+  )
+  CHECK_C_SOURCE_RUNS(
+  "#include<stdint.h>
+  int main()
+  {
     __sync_synchronize();
     return(0);
   }"
@@ -110,6 +122,10 @@ IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
  ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
 ENDIF()
 
+IF(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
+ ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_TEST_AND_SET=1)
+ENDIF()
+
 IF(HAVE_IB_GCC_SYNC_SYNCHRONISE)
  ADD_DEFINITIONS(-DHAVE_IB_GCC_SYNC_SYNCHRONISE=1)
 ENDIF()
diff --git a/storage/innobase/btr/btr0cur.c b/storage/innobase/btr/btr0cur.c
index 51dcb49..3b53390 100644
--- a/storage/innobase/btr/btr0cur.c
+++ b/storage/innobase/btr/btr0cur.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -2085,6 +2085,7 @@ btr_cur_optimistic_update(
 	ulint		max_size;
 	ulint		new_rec_size;
 	ulint		old_rec_size;
+	ulint		max_ins_size = 0;
 	dtuple_t*	new_entry;
 	roll_ptr_t	roll_ptr;
 	trx_t*		trx;
@@ -2195,6 +2196,11 @@ any_extern:
 		: (old_rec_size
 		   + page_get_max_insert_size_after_reorganize(page, 1));
 
+	if (!page_zip) {
+		max_ins_size = page_get_max_insert_size_after_reorganize(
+					page, 1);
+	}
+
 	if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT)
 	       && (max_size >= new_rec_size))
 	      || (page_get_n_recs(page) <= 1))) {
@@ -2246,10 +2252,14 @@ any_extern:
 	rec = btr_cur_insert_if_possible(cursor, new_entry, 0/*n_ext*/, mtr);
 	ut_a(rec); /* <- We calculated above the insert would fit */
 
-	if (page_zip && !dict_index_is_clust(index)
+	if (!dict_index_is_clust(index)
 	    && page_is_leaf(page)) {
 		/* Update the free bits in the insert buffer. */
-		ibuf_update_free_bits_zip(block, mtr);
+		if (page_zip) {
+			ibuf_update_free_bits_zip(block, mtr);
+		} else {
+			ibuf_update_free_bits_low(block, max_ins_size, mtr);
+		}
 	}
 
 	/* Restore the old explicit lock state on the record */
@@ -2358,6 +2368,7 @@ btr_cur_pessimistic_update(
 	ulint		n_reserved;
 	ulint		n_ext;
 	ulint*		offsets		= NULL;
+	ulint		max_ins_size	= 0;
 
 	*big_rec = NULL;
 
@@ -2495,6 +2506,11 @@ make_external:
 		ut_ad(flags & BTR_KEEP_POS_FLAG);
 	}
 
+	if (!page_zip) {
+		max_ins_size = page_get_max_insert_size_after_reorganize(
+					page, 1);
+	}
+
 	/* Store state of explicit locks on rec on the page infimum record,
 	before deleting rec. The page infimum acts as a dummy carrier of the
 	locks, taking care also of lock releases, before we can move the locks
@@ -2540,10 +2556,15 @@ make_external:
 			big_rec_vec != NULL && (flags & BTR_KEEP_POS_FLAG),
 			mtr);
 
-		if (page_zip && !dict_index_is_clust(index)
+		if (!dict_index_is_clust(index)
 		    && page_is_leaf(page)) {
 			/* Update the free bits in the insert buffer. */
-			ibuf_update_free_bits_zip(block, mtr);
+			if (page_zip) {
+				ibuf_update_free_bits_zip(block, mtr);
+			} else {
+				ibuf_update_free_bits_low(block, max_ins_size,
+							  mtr);
+			}
 		}
 
 		err = DB_SUCCESS;
diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c
index ac8a1ea..dcbca49 100644
--- a/storage/innobase/dict/dict0crea.c
+++ b/storage/innobase/dict/dict0crea.c
@@ -1420,6 +1420,104 @@ dict_create_add_foreign_field_to_dictionary(
 }
 
 /********************************************************************//**
+Construct foreign key constraint defintion from data dictionary information.
+*/
+UNIV_INTERN
+char*
+dict_foreign_def_get(
+/*=================*/
+	dict_foreign_t*	foreign,/*!< in: foreign */
+	trx_t*		trx)	/*!< in: trx */
+{
+	char* fk_def = mem_heap_alloc(foreign->heap, 4*1024);
+	const char* tbname;
+	char tablebuf[MAX_TABLE_NAME_LEN + 1] = "";
+	int i;
+	char* bufend;
+
+	tbname = dict_remove_db_name(foreign->id);
+	bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN,
+				tbname, strlen(tbname), trx->mysql_thd, FALSE);
+	tablebuf[bufend - tablebuf] = '\0';
+
+	sprintf(fk_def,
+		(char *)"CONSTRAINT %s FOREIGN KEY (", (char *)tablebuf);
+
+	for(i = 0; i < foreign->n_fields; i++) {
+		char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+		innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->foreign_col_names[i],
+				strlen(foreign->foreign_col_names[i]),
+				trx->mysql_thd, FALSE);
+		strcat(fk_def, buf);
+		if (i < foreign->n_fields-1) {
+			strcat(fk_def, (char *)",");
+		}
+	}
+
+	strcat(fk_def,(char *)") REFERENCES ");
+
+	bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN,
+	        	        foreign->referenced_table_name,
+			        strlen(foreign->referenced_table_name),
+			        trx->mysql_thd, TRUE);
+	tablebuf[bufend - tablebuf] = '\0';
+
+	strcat(fk_def, tablebuf);
+	strcat(fk_def, " (");
+
+	for(i = 0; i < foreign->n_fields; i++) {
+		char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+		bufend = innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->referenced_col_names[i],
+				strlen(foreign->referenced_col_names[i]),
+				trx->mysql_thd, FALSE);
+		buf[bufend - buf] = '\0';
+		strcat(fk_def, buf);
+		if (i < foreign->n_fields-1) {
+			strcat(fk_def, (char *)",");
+		}
+	}
+	strcat(fk_def, (char *)")");
+
+	return fk_def;
+}
+
+/********************************************************************//**
+Convert foreign key column names from data dictionary to SQL-layer.
+*/
+static
+void
+dict_foreign_def_get_fields(
+/*========================*/
+	dict_foreign_t*	foreign,/*!< in: foreign */
+	trx_t*		trx,	/*!< in: trx */
+	char**		field,  /*!< out: foreign column */
+	char**		field2, /*!< out: referenced column */
+	int		col_no) /*!< in: column number */
+{
+	char* bufend;
+	char* fieldbuf = mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1);
+	char* fieldbuf2 = mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1);
+
+	bufend = innobase_convert_name(fieldbuf, MAX_TABLE_NAME_LEN,
+			foreign->foreign_col_names[col_no],
+			strlen(foreign->foreign_col_names[col_no]),
+			trx->mysql_thd, FALSE);
+
+	fieldbuf[bufend - fieldbuf] = '\0';
+
+	bufend = innobase_convert_name(fieldbuf2, MAX_TABLE_NAME_LEN,
+			foreign->referenced_col_names[col_no],
+			strlen(foreign->referenced_col_names[col_no]),
+			trx->mysql_thd, FALSE);
+
+	fieldbuf2[bufend - fieldbuf2] = '\0';
+	*field = fieldbuf;
+	*field2 = fieldbuf2;
+}
+
+/********************************************************************//**
 Add a single foreign key definition to the data dictionary tables in the
 database. We also generate names to constraints that were not named by the
 user. A generated constraint has a name of the format
@@ -1501,6 +1599,29 @@ dict_create_add_foreign_to_dictionary(
 
 	if (error != DB_SUCCESS) {
 
+		if (error == DB_DUPLICATE_KEY) {
+			char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+			char	tablename[MAX_TABLE_NAME_LEN + 1] = "";
+			char*	fk_def;
+
+			innobase_convert_name(tablename, MAX_TABLE_NAME_LEN,
+				table->name, strlen(table->name),
+				trx->mysql_thd, TRUE);
+
+			innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->id, strlen(foreign->id), trx->mysql_thd, FALSE);
+
+			fk_def = dict_foreign_def_get(foreign, trx);
+
+			ib_push_warning(trx, error,
+				"Create or Alter table %s with foreign key constraint"
+				" failed. Foreign key constraint %s"
+				" already exists on data dictionary."
+				" Foreign key constraint names need to be unique in database."
+				" Error in foreign key definition: %s.",
+				tablename, buf, fk_def);
+		}
+
 		return(error);
 	}
 
@@ -1509,6 +1630,26 @@ dict_create_add_foreign_to_dictionary(
 			i, table, foreign, trx);
 
 		if (error != DB_SUCCESS) {
+			char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+			char	tablename[MAX_TABLE_NAME_LEN + 1] = "";
+			char*	field=NULL;
+			char*	field2=NULL;
+			char*	fk_def;
+
+			innobase_convert_name(tablename, MAX_TABLE_NAME_LEN,
+				table->name, strlen(table->name),
+				trx->mysql_thd, TRUE);
+			innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->id, strlen(foreign->id), trx->mysql_thd, FALSE);
+			fk_def = dict_foreign_def_get(foreign, trx);
+			dict_foreign_def_get_fields(foreign, trx, &field, &field2, i);
+
+			ib_push_warning(trx, error,
+				"Create or Alter table %s with foreign key constraint"
+				" failed. Error adding foreign  key constraint name %s"
+				" fields %s or %s to the dictionary."
+				" Error in foreign key definition: %s.",
+				tablename, buf, i+1, fk_def);
 
 			return(error);
 		}
@@ -1593,7 +1734,7 @@ dict_create_add_foreigns_to_dictionary(
 	     foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) {
 
 		error = dict_create_add_foreign_to_dictionary(&number, table,
-							      foreign, trx);
+			foreign, trx);
 
 		if (error != DB_SUCCESS) {
 
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index cbb17fc..ad90038 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -2534,8 +2534,9 @@ dict_foreign_remove_from_cache(
 			const ib_rbt_node_t*	node
 				= rbt_lookup(rbt, foreign->id);
 
-			if (node) {
-				dict_foreign_t*	val = *(dict_foreign_t**) node->value;
+			if (node != NULL) {
+				dict_foreign_t*	val
+					= *(dict_foreign_t**) node->value;
 
 				if (val == foreign) {
 					rbt_delete(rbt, foreign->id);
@@ -2555,9 +2556,10 @@ dict_foreign_remove_from_cache(
 		if (rbt != NULL && foreign->id != NULL) {
 			const ib_rbt_node_t*	node
 				= rbt_lookup(rbt, foreign->id);
-			if (node) {
 
-				dict_foreign_t*	val = *(dict_foreign_t**) node->value;
+			if (node != NULL) {
+				dict_foreign_t*	val
+					= *(dict_foreign_t**) node->value;
 
 				if (val == foreign) {
 					rbt_delete(rbt, foreign->id);
@@ -2614,6 +2616,11 @@ dict_foreign_find(
 	DBUG_RETURN(NULL);
 }
 
+#define  DB_FOREIGN_KEY_IS_PREFIX_INDEX 200
+#define  DB_FOREIGN_KEY_COL_NOT_NULL    201
+#define  DB_FOREIGN_KEY_COLS_NOT_EQUAL  202
+#define  DB_FOREIGN_KEY_INDEX_NOT_FOUND 203
+
 /*********************************************************************//**
 Tries to find an index whose first fields are the columns in the array,
 in the same order and is not marked for deletion and is not the same
@@ -2631,12 +2638,21 @@ dict_foreign_find_index(
 	ibool		check_charsets,
 				/*!< in: whether to check charsets.
 				only has an effect if types_idx != NULL */
-	ulint		check_null)
+	ulint		check_null,
 				/*!< in: nonzero if none of the columns must
 				be declared NOT NULL */
+	ulint*		error,	/*!< out: error code */
+	ulint*		err_col_no,
+				/*!< out: column number where error happened */
+	dict_index_t**	err_index)
+			        /*!< out: index where error happened */
 {
 	dict_index_t*	index;
 
+	if (error) {
+		*error = DB_FOREIGN_KEY_INDEX_NOT_FOUND;
+	}
+
 	index = dict_table_get_first_index(table);
 
 	while (index != NULL) {
@@ -2662,6 +2678,12 @@ dict_foreign_find_index(
 					/* We do not accept column prefix
 					indexes here */
 
+					if (error && err_col_no && err_index) {
+						*error = DB_FOREIGN_KEY_IS_PREFIX_INDEX;
+						*err_col_no = i;
+						*err_index = index;
+					}
+
 					break;
 				}
 
@@ -2673,6 +2695,11 @@ dict_foreign_find_index(
 				if (check_null
 				    && (field->col->prtype & DATA_NOT_NULL)) {
 
+					if (error && err_col_no && err_index) {
+						*error = DB_FOREIGN_KEY_COL_NOT_NULL;
+						*err_col_no = i;
+						*err_index = index;
+					}
 					return(NULL);
 				}
 
@@ -2682,6 +2709,12 @@ dict_foreign_find_index(
 								   i),
 					    check_charsets)) {
 
+					if (error && err_col_no && err_index) {
+						*error = DB_FOREIGN_KEY_COLS_NOT_EQUAL;
+						*err_col_no = i;
+						*err_index = index;
+					}
+
 					break;
 				}
 			}
@@ -2689,6 +2722,10 @@ dict_foreign_find_index(
 			if (i == n_cols) {
 				/* We found a matching index */
 
+				if (error) {
+					*error = DB_SUCCESS;
+				}
+
 				return(index);
 			}
 		}
@@ -2720,7 +2757,7 @@ dict_foreign_find_equiv_index(
 		       foreign->foreign_table,
 		       foreign->foreign_col_names, foreign->n_fields,
 		       foreign->foreign_index, TRUE, /* check types */
-		       FALSE/* allow columns to be NULL */));
+		       FALSE/* allow columns to be NULL */, NULL, NULL, NULL));
 }
 
 #endif /* !UNIV_HOTBACKUP */
@@ -2883,11 +2920,15 @@ dict_foreign_add_to_cache(
 	}
 
 	if (for_in_cache->referenced_table == NULL && ref_table) {
+		ulint index_error;
+		ulint err_col;
+		dict_index_t *err_index=NULL;
+
 		index = dict_foreign_find_index(
 			ref_table,
 			for_in_cache->referenced_col_names,
 			for_in_cache->n_fields, for_in_cache->foreign_index,
-			check_charsets, FALSE);
+			check_charsets, FALSE, &index_error, &err_col, &err_index);
 
 		if (index == NULL
 		    && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) {
@@ -2919,6 +2960,9 @@ dict_foreign_add_to_cache(
 	}
 
 	if (for_in_cache->foreign_table == NULL && for_table) {
+		ulint index_error;
+		ulint err_col;
+		dict_index_t* err_index=NULL;
 
 		index = dict_foreign_find_index(
 			for_table,
@@ -2927,7 +2971,8 @@ dict_foreign_add_to_cache(
 			for_in_cache->referenced_index, check_charsets,
 			for_in_cache->type
 			& (DICT_FOREIGN_ON_DELETE_SET_NULL
-			   | DICT_FOREIGN_ON_UPDATE_SET_NULL));
+				| DICT_FOREIGN_ON_UPDATE_SET_NULL),
+			&index_error, &err_col, &err_index);
 
 		if (index == NULL
 		    && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) {
@@ -3538,6 +3583,8 @@ static
 void
 dict_foreign_report_syntax_err(
 /*===========================*/
+	const char*     fmt,		/*!< in: syntax err msg */
+	const char*	oper,		/*!< in: operation */
 	const char*	name,		/*!< in: table name */
 	const char*	start_of_latest_foreign,
 					/*!< in: start of the foreign key clause
@@ -3548,12 +3595,102 @@ dict_foreign_report_syntax_err(
 
 	mutex_enter(&dict_foreign_err_mutex);
 	dict_foreign_error_report_low(ef, name);
-	fprintf(ef, "%s:\nSyntax error close to:\n%s\n",
-		start_of_latest_foreign, ptr);
+	fprintf(ef, fmt, oper, name, start_of_latest_foreign, ptr);
 	mutex_exit(&dict_foreign_err_mutex);
 }
 
 /*********************************************************************//**
+Push warning message to SQL-layer based on foreign key constraint
+index match error. */
+static
+void
+dict_foreign_push_index_error(
+/*==========================*/
+	trx_t*		trx,		/*!< in: trx */
+	const char*	operation,	/*!< in: operation create or alter
+					*/
+	const char*	create_name,	/*!< in: table name in create or
+					alter table */
+	const char*	latest_foreign,	/*!< in: start of latest foreign key
+					constraint name */
+	const char**	columns,	/*!< in: foreign key columns */
+	ulint		index_error,	/*!< in: error code */
+	ulint		err_col,	/*!< in: column where error happened
+					*/
+	dict_index_t*	err_index,	/*!< in: index where error happened
+					*/
+	dict_table_t*	table,		/*!< in: table */
+	FILE*		ef)		/*!< in: output stream */
+{
+	switch (index_error) {
+	case DB_FOREIGN_KEY_INDEX_NOT_FOUND: {
+		fprintf(ef,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is no index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.\n",
+			operation, create_name, latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is no index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.",
+			operation, create_name, latest_foreign);
+		break;
+	}
+	case DB_FOREIGN_KEY_IS_PREFIX_INDEX: {
+		fprintf(ef,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is only prefix index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.\n",
+			operation, create_name, latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is only prefix index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.",
+			operation, create_name, latest_foreign);
+		break;
+	}
+	case DB_FOREIGN_KEY_COL_NOT_NULL: {
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. You have defined a SET NULL condition but "
+			"field %s on index is defined as NOT NULL close to %s\n",
+			operation, create_name, columns[err_col], latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. You have defined a SET NULL condition but "
+			"field %s on index is defined as NOT NULL close to %s",
+			operation, create_name, columns[err_col], latest_foreign);
+		break;
+	}
+	case DB_FOREIGN_KEY_COLS_NOT_EQUAL: {
+		dict_field_t*	field;
+		const char*	col_name;
+		field = dict_index_get_nth_field(err_index, err_col);
+
+		col_name = dict_table_get_col_name(
+			table, dict_col_get_no(field->col));
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Field type or character set for column %s "
+			"does not mach referenced column %s close to %s\n",
+			operation, create_name, columns[err_col], col_name, latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Field type or character set for column %s "
+			"does not mach referenced column %s close to %s",
+			operation, create_name, columns[err_col], col_name, latest_foreign);
+		break;
+	}
+	default:
+		ut_error;
+	}
+}
+
+/*********************************************************************//**
 Scans a table create SQL string and adds to the data dictionary the foreign
 key constraints declared in the string. This function should be called after
 the indexes for a table have been created. Each foreign key constraint must
@@ -3581,15 +3718,20 @@ dict_create_foreign_constraints_low(
 				DB_CANNOT_ADD_CONSTRAINT if any foreign
 				keys are found. */
 {
-	dict_table_t*	table;
-	dict_table_t*	referenced_table;
-	dict_table_t*	table_to_alter;
+	dict_table_t*	table			= NULL;
+	dict_table_t*	referenced_table	= NULL;
+	dict_table_t*	table_to_alter		= NULL;
+	dict_table_t*	table_to_create		= NULL;
 	ulint		highest_id_so_far	= 0;
-	dict_index_t*	index;
-	dict_foreign_t*	foreign;
+	dict_index_t*	index			= NULL;
+	dict_foreign_t*	foreign			= NULL;
 	const char*	ptr			= sql_string;
 	const char*	start_of_latest_foreign	= sql_string;
+	const char*	start_of_latest_set     = NULL;
 	FILE*		ef			= dict_foreign_err_file;
+	ulint		index_error		= DB_SUCCESS;
+	dict_index_t*	err_index		= NULL;
+	ulint		err_col;
 	const char*	constraint_name;
 	ibool		success;
 	ulint		error;
@@ -3602,29 +3744,68 @@ dict_create_foreign_constraints_low(
 	ulint		n_on_updates;
 	const dict_col_t*columns[500];
 	const char*	column_names[500];
+	const char*	ref_column_names[500];
 	const char*	referenced_table_name;
+	const char*	create_table_name;
+	const char*	orig;
+	char		create_name[MAX_TABLE_NAME_LEN + 1];
+	const char	operation[8];
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
 	table = dict_table_get_low(name, DICT_ERR_IGNORE_NONE);
+	/* First check if we are actually doing an ALTER TABLE, and in that
+	case look for the table being altered */
+	ptr = dict_accept(cs, ptr, "ALTER", &success);
+
+	strcpy((char *)operation, success ? "Alter " : "Create ");
+
+	if (!success) {
+		orig = ptr;
+		ptr = dict_scan_to(ptr, "CREATE");
+		ptr = dict_scan_to(ptr, "TABLE");
+		ptr = dict_accept(cs, ptr, "TABLE", &success);
+
+		if (success) {
+			ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
+					&success, heap, &create_table_name);
+		}
+
+		if (success) {
+			char *bufend;
+			bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+					create_table_name, strlen(create_table_name),
+					trx->mysql_thd, TRUE);
+			create_name[bufend-create_name]='\0';
+			ptr = orig;
+		} else {
+			char *bufend;
+			ptr = orig;
+			bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+					name, strlen(name), trx->mysql_thd, TRUE);
+			create_name[bufend-create_name]='\0';
+		}
+
+		goto loop;
+	}
 
 	if (table == NULL) {
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef,
-			"Cannot find the table in the internal"
-			" data dictionary of InnoDB.\n"
-			"Create table statement:\n%s\n", sql_string);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef, "%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.\n",
+			operation, create_name, create_name, start_of_latest_foreign);
 		mutex_exit(&dict_foreign_err_mutex);
-
+		ib_push_warning(trx, DB_ERROR,
+			"%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.",
+			operation, create_name, create_name, start_of_latest_foreign);
 		return(DB_ERROR);
 	}
 
-	/* First check if we are actually doing an ALTER TABLE, and in that
-	case look for the table being altered */
-
-	ptr = dict_accept(cs, ptr, "ALTER", &success);
-
+	/* If not alter table jump to loop */
 	if (!success) {
 
 		goto loop;
@@ -3639,13 +3820,40 @@ dict_create_foreign_constraints_low(
 
 	/* We are doing an ALTER TABLE: scan the table name we are altering */
 
+	orig = ptr;
 	ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
 				   &success, heap, &referenced_table_name);
+
+	if (table_to_alter) {
+		char *bufend;
+		bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+				table_to_alter->name, strlen(table_to_alter->name),
+				trx->mysql_thd, TRUE);
+		create_name[bufend-create_name]='\0';
+	} else {
+		char *bufend;
+		bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+				referenced_table_name, strlen(referenced_table_name),
+				trx->mysql_thd, TRUE);
+		create_name[bufend-create_name]='\0';
+
+	}
+
 	if (!success) {
-		fprintf(stderr,
-			"InnoDB: Error: could not find"
-			" the table being ALTERED in:\n%s\n",
-			sql_string);
+		mutex_enter(&dict_foreign_err_mutex);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.\n",
+			operation, create_name, create_name, orig);
+		mutex_exit(&dict_foreign_err_mutex);
+
+		ib_push_warning(trx, DB_ERROR,
+			"%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.",
+			operation, create_name, create_name, orig);
 
 		return(DB_ERROR);
 	}
@@ -3711,7 +3919,19 @@ loop:
 		if so, immediately reject the command if the table is a
 		temporary one. For now, this kludge will work. */
 		if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0)) {
+			mutex_enter(&dict_foreign_err_mutex);
+			dict_foreign_error_report_low(ef, create_name);
+			fprintf(ef, "%s table %s with foreign key constraint"
+				" failed. Temporary tables can't have foreign key constraints."
+				" Error close to %s.\n",
+				operation, create_name, start_of_latest_foreign);
+			mutex_exit(&dict_foreign_err_mutex);
 
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Temporary tables can't have foreign key constraints."
+				" Error close to %s.",
+				operation, create_name, start_of_latest_foreign);
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
@@ -3747,11 +3967,21 @@ loop:
 	if (!success) {
 		/* MySQL allows also an index id before the '('; we
 		skip it */
+		orig = ptr;
 		ptr = dict_skip_word(cs, ptr, &success);
 
 		if (!success) {
 			dict_foreign_report_syntax_err(
-				name, start_of_latest_foreign, ptr);
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.\n",
+				operation, create_name, start_of_latest_foreign, orig);
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.",
+				operation, create_name, start_of_latest_foreign, orig);
 
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
@@ -3771,15 +4001,26 @@ loop:
 	/* Scan the columns in the first list */
 col_loop1:
 	ut_a(i < (sizeof column_names) / sizeof *column_names);
+	orig = ptr;
 	ptr = dict_scan_col(cs, ptr, &success, table, columns + i,
 			    heap, column_names + i);
 	if (!success) {
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\nCannot resolve column name close to:\n%s\n",
-			start_of_latest_foreign, ptr);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		mutex_exit(&dict_foreign_err_mutex);
 
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3791,11 +4032,22 @@ col_loop1:
 		goto col_loop1;
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, ")", &success);
 
 	if (!success) {
 		dict_foreign_report_syntax_err(
-			name, start_of_latest_foreign, ptr);
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3803,27 +4055,41 @@ col_loop1:
 	as the first fields and in the right order */
 
 	index = dict_foreign_find_index(table, column_names, i,
-					NULL, TRUE, FALSE);
+		NULL, TRUE, FALSE, &index_error, &err_col, &err_index);
 
 	if (!index) {
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
+		dict_foreign_error_report_low(ef, create_name);
 		fputs("There is no index in table ", ef);
-		ut_print_name(ef, NULL, TRUE, name);
+		ut_print_name(ef, NULL, TRUE, create_name);
 		fprintf(ef, " where the columns appear\n"
 			"as the first columns. Constraint:\n%s\n"
 			"See " REFMAN "innodb-foreign-key-constraints.html\n"
 			"for correct foreign key definition.\n",
 			start_of_latest_foreign);
-		mutex_exit(&dict_foreign_err_mutex);
 
-		return(DB_CHILD_NO_INDEX);
+		dict_foreign_push_index_error(trx, operation, create_name, start_of_latest_foreign,
+			column_names, index_error, err_col, err_index, table, ef);
+
+		mutex_exit(&dict_foreign_err_mutex);
+		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
+
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "REFERENCES", &success);
 
 	if (!success || !my_isspace(cs, *ptr)) {
 		dict_foreign_report_syntax_err(
-			name, start_of_latest_foreign, ptr);
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3872,24 +4138,50 @@ col_loop1:
 	checking of foreign key constraints! */
 
 	if (!success || (!referenced_table && trx->check_foreigns)) {
+		char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+		char*	bufend;
+
+		bufend = innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				referenced_table_name, strlen(referenced_table_name),
+				trx->mysql_thd, TRUE);
+		buf[bufend - buf] = '\0';
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
+			"close to %s.",
+			operation, create_name, buf, start_of_latest_foreign);
+
 		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\nCannot resolve table name close to:\n"
-			"%s\n",
-			start_of_latest_foreign, ptr);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
+			"close to %s.\n",
+			operation, create_name, buf, start_of_latest_foreign);
+
 		mutex_exit(&dict_foreign_err_mutex);
 
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "(", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3897,20 +4189,29 @@ col_loop1:
 	i = 0;
 
 col_loop2:
+	orig = ptr;
 	ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i,
-			    heap, column_names + i);
+			    heap, ref_column_names + i);
 	i++;
 
 	if (!success) {
 		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\nCannot resolve column name close to:\n"
-			"%s\n",
-			start_of_latest_foreign, ptr);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		mutex_exit(&dict_foreign_err_mutex);
 
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3920,13 +4221,25 @@ col_loop2:
 		goto col_loop2;
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, ")", &success);
 
 	if (!success || foreign->n_fields != i) {
+
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s. Too few referenced columns.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s. Too few referenced columns, you have %d when you should have %d.",
+			operation, create_name, start_of_latest_foreign, orig, i, foreign->n_fields);
+
 		dict_foreign_free(foreign);
 
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3936,6 +4249,7 @@ col_loop2:
 scan_on_conditions:
 	/* Loop here as long as we can find ON ... conditions */
 
+	start_of_latest_set = ptr;
 	ptr = dict_accept(cs, ptr, "ON", &success);
 
 	if (!success) {
@@ -3946,13 +4260,24 @@ scan_on_conditions:
 	ptr = dict_accept(cs, ptr, "DELETE", &success);
 
 	if (!success) {
+		orig = ptr;
 		ptr = dict_accept(cs, ptr, "UPDATE", &success);
 
 		if (!success) {
 			dict_foreign_free(foreign);
 
 			dict_foreign_report_syntax_err(
-				name, start_of_latest_foreign, ptr);
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.\n",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
@@ -3984,12 +4309,22 @@ scan_on_conditions:
 	ptr = dict_accept(cs, ptr, "NO", &success);
 
 	if (success) {
+		orig = ptr;
 		ptr = dict_accept(cs, ptr, "ACTION", &success);
 
 		if (!success) {
 			dict_foreign_free(foreign);
 			dict_foreign_report_syntax_err(
-				name, start_of_latest_foreign, ptr);
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.\n",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
 
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
@@ -4003,42 +4338,73 @@ scan_on_conditions:
 		goto scan_on_conditions;
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "SET", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "NULL", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
 	for (j = 0; j < foreign->n_fields; j++) {
 		if ((dict_index_get_nth_col(foreign->foreign_index, j)->prtype)
 		    & DATA_NOT_NULL) {
+			const dict_col_t*	col
+				= dict_index_get_nth_col(foreign->foreign_index, j);
+			const char* col_name = dict_table_get_col_name(foreign->foreign_index->table,
+				dict_col_get_no(col));
 
 			/* It is not sensible to define SET NULL
 			if the column is not allowed to be NULL! */
 
-			dict_foreign_free(foreign);
-
 			mutex_enter(&dict_foreign_err_mutex);
-			dict_foreign_error_report_low(ef, name);
-			fprintf(ef, "%s:\n"
-				"You have defined a SET NULL condition"
-				" though some of the\n"
-				"columns are defined as NOT NULL.\n",
-				start_of_latest_foreign);
+			dict_foreign_error_report_low(ef, create_name);
+			fprintf(ef,
+				"%s table %s with foreign key constraint"
+				" failed. You have defined a SET NULL condition but column %s is defined as NOT NULL"
+				" in %s close to %s.\n",
+				operation, create_name, col_name, start_of_latest_foreign, start_of_latest_set);
 			mutex_exit(&dict_foreign_err_mutex);
 
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. You have defined a SET NULL condition but column %s is defined as NOT NULL"
+				" in %s close to %s.",
+				operation, create_name, col_name, start_of_latest_foreign, start_of_latest_set);
+
+			dict_foreign_free(foreign);
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 	}
@@ -4055,16 +4421,22 @@ try_find_index:
 	if (n_on_deletes > 1 || n_on_updates > 1) {
 		/* It is an error to define more than 1 action */
 
-		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\n"
-			"You have twice an ON DELETE clause"
-			" or twice an ON UPDATE clause.\n",
-			start_of_latest_foreign);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. You have more than one on delete or on update clause"
+			" in %s close to %s.\n",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
 		mutex_exit(&dict_foreign_err_mutex);
 
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. You have more than one on delete or on update clause"
+			" in %s close to %s.",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+		dict_foreign_free(foreign);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -4074,13 +4446,13 @@ try_find_index:
 
 	if (referenced_table) {
 		index = dict_foreign_find_index(referenced_table,
-						column_names, i,
-						foreign->foreign_index,
-						TRUE, FALSE);
+					ref_column_names, i,
+					foreign->foreign_index,
+					TRUE, FALSE, &index_error, &err_col, &err_index);
 		if (!index) {
 			dict_foreign_free(foreign);
 			mutex_enter(&dict_foreign_err_mutex);
-			dict_foreign_error_report_low(ef, name);
+			dict_foreign_error_report_low(ef, create_name);
 			fprintf(ef, "%s:\n"
 				"Cannot find an index in the"
 				" referenced table where the\n"
@@ -4098,9 +4470,13 @@ try_find_index:
 				"innodb-foreign-key-constraints.html\n"
 				"for correct foreign key definition.\n",
 				start_of_latest_foreign);
+
+			dict_foreign_push_index_error(trx, operation, create_name, start_of_latest_foreign,
+				column_names, index_error, err_col, err_index, referenced_table, ef);
+
 			mutex_exit(&dict_foreign_err_mutex);
 
-			return(DB_PARENT_NO_INDEX);
+			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 	} else {
 		ut_a(trx->check_foreigns == FALSE);
@@ -4118,7 +4494,7 @@ try_find_index:
 						       i * sizeof(void*));
 	for (i = 0; i < foreign->n_fields; i++) {
 		foreign->referenced_col_names[i]
-			= mem_heap_strdup(foreign->heap, column_names[i]);
+			= mem_heap_strdup(foreign->heap, ref_column_names[i]);
 	}
 
 	/* We found an ok constraint definition: add to the lists */
@@ -5251,7 +5627,8 @@ dict_table_replace_index_in_foreign_list(
 				foreign->referenced_table,
 				foreign->referenced_col_names,
 				foreign->n_fields, index,
-				/*check_charsets=*/TRUE, /*check_null=*/FALSE);
+				/*check_charsets=*/TRUE, /*check_null=*/FALSE,
+				NULL, NULL, NULL);
 			ut_ad(new_index || !trx->check_foreigns);
 			ut_ad(!new_index || new_index->table == index->table);
 
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 7c17f20..2bdbdf7 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1597,6 +1597,7 @@ check_trx_exists(
 
 	if (trx == NULL) {
 		trx = innobase_trx_allocate(thd);
+		thd_set_ha_data(thd, innodb_hton_ptr, trx);
 	} else if (UNIV_UNLIKELY(trx->magic_n != TRX_MAGIC_N)) {
 		mem_analyze_corruption(trx);
 		ut_error;
@@ -12303,3 +12304,29 @@ ib_warn_row_too_big(const dict_table_t*	table)
 		" ROW_FORMAT=COMPRESSED ": ""
 		, prefix ? DICT_MAX_FIXED_COL_LEN : 0);
 }
+
+/********************************************************************//**
+Helper function to push warnings from InnoDB internals to SQL-layer. */
+extern "C" UNIV_INTERN
+void
+ib_push_warning(
+	trx_t*		trx,	/*!< in: trx */
+	ulint		error,	/*!< in: error code to push as warning */
+	const char	*format,/*!< in: warning message */
+	...)
+{
+	va_list args;
+	THD *thd = (THD *)trx->mysql_thd;
+	char *buf;
+#define MAX_BUF_SIZE 4*1024
+
+	va_start(args, format);
+	buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME));
+	vsprintf(buf,format, args);
+
+	push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+		convert_error_code_to_mysql(error, 0, thd),
+		buf);
+	my_free(buf);
+	va_end(args);
+}
diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h
index 9faf580..a58bcb1 100644
--- a/storage/innobase/include/dict0crea.h
+++ b/storage/innobase/include/dict0crea.h
@@ -106,6 +106,17 @@ UNIV_INTERN
 ulint
 dict_create_or_check_foreign_constraint_tables(void);
 /*================================================*/
+
+/********************************************************************//**
+Construct foreign key constraint defintion from data dictionary information.
+*/
+UNIV_INTERN
+char*
+dict_foreign_def_get(
+/*=================*/
+	dict_foreign_t*	foreign,/*!< in: foreign */
+	trx_t*		trx);	/*!< in: trx */
+
 /********************************************************************//**
 Adds foreign key definitions to data dictionary tables in the database. We
 look at table->foreign_list, and also generate names to constraints that were
diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
index 3859b45..a69d3d1 100644
--- a/storage/innobase/include/ha_prototypes.h
+++ b/storage/innobase/include/ha_prototypes.h
@@ -326,5 +326,14 @@ innobase_convert_to_filename_charset(
 	const char*     from,   /* in: identifier to convert */
 	ulint           len);   /* in: length of 'to', in bytes */
 
+/********************************************************************//**
+Helper function to push warnings from InnoDB internals to SQL-layer. */
+UNIV_INTERN
+void
+ib_push_warning(
+	trx_t*		trx,	/*!< in: trx */
+	ulint		error,	/*!< in: error code to push as warning */
+	const char	*format,/*!< in: warning message */
+	...);
 
 #endif
diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h
index 7fd1fde..22b0fa4 100644
--- a/storage/innobase/include/os0sync.h
+++ b/storage/innobase/include/os0sync.h
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -37,6 +37,20 @@ Created 9/6/1995 Heikki Tuuri
 #include "univ.i"
 #include "ut0lst.h"
 
+#if defined __i386__ || defined __x86_64__ || defined _M_IX86 \
+    || defined _M_X64 || defined __WIN__
+
+#define IB_STRONG_MEMORY_MODEL
+
+#endif /* __i386__ || __x86_64__ || _M_IX86 || M_X64 || __WIN__ */
+
+#ifdef HAVE_WINDOWS_ATOMICS
+typedef LONG lock_word_t;	/*!< On Windows, InterlockedExchange operates
+				on LONG variable */
+#else
+typedef byte lock_word_t;
+#endif
+
 #ifdef __WIN__
 /** Native event (slow)*/
 typedef HANDLE			os_native_event_t;
@@ -321,31 +335,61 @@ amount of increment. */
 # define os_atomic_increment_ulint(ptr, amount) \
 	os_atomic_increment(ptr, amount)
 
-/**********************************************************//**
-Returns the old value of *ptr, atomically sets *ptr to new_val */
-
-#if defined(__powerpc__) || defined(__aarch64__)
-/*
-  os_atomic_test_and_set_byte_release() should imply a release barrier before
-  setting, and a full barrier after. But __sync_lock_test_and_set() is only
-  documented as an aquire barrier. So on PowerPC we need to add the full
-  barrier explicitly.  */
-# define os_atomic_test_and_set_byte_release(ptr, new_val) \
-        do { __sync_lock_release(ptr); \
-             __sync_synchronize(); } while (0)
-#else
-/*
-  On x86, __sync_lock_test_and_set() happens to be full barrier, due to
-  LOCK prefix.
-*/
-# define os_atomic_test_and_set_byte_release(ptr, new_val) \
-	__sync_lock_test_and_set(ptr, (byte) new_val)
-#endif
-/*
-  os_atomic_test_and_set_byte_acquire() is a full memory barrier on x86. But
-  in general, just an aquire barrier should be sufficient. */
-# define os_atomic_test_and_set_byte_acquire(ptr, new_val) \
-	__sync_lock_test_and_set(ptr, (byte) new_val)
+# if defined(HAVE_IB_GCC_ATOMIC_TEST_AND_SET)
+
+/** Do an atomic test-and-set.
+ at param[in,out]	ptr		Memory location to set to non-zero
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_test_and_set(volatile lock_word_t* ptr)
+{
+       return(__atomic_test_and_set(ptr, __ATOMIC_ACQUIRE));
+}
+
+/** Do an atomic clear.
+ at param[in,out]	ptr		Memory location to set to zero */
+static inline
+void
+os_atomic_clear(volatile lock_word_t* ptr)
+{
+	__atomic_clear(ptr, __ATOMIC_RELEASE);
+}
+
+# elif defined(IB_STRONG_MEMORY_MODEL)
+
+/** Do an atomic test and set.
+ at param[in,out]	ptr		Memory location to set to non-zero
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_test_and_set(volatile lock_word_t* ptr)
+{
+	return(__sync_lock_test_and_set(ptr, 1));
+}
+
+/** Do an atomic release.
+
+In theory __sync_lock_release should be used to release the lock.
+Unfortunately, it does not work properly alone. The workaround is
+that more conservative __sync_lock_test_and_set is used instead.
+
+Performance regression was observed at some conditions for Intel
+architecture. Disable release barrier on Intel architecture for now.
+ at param[in,out]	ptr		Memory location to write to
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_clear(volatile lock_word_t* ptr)
+{
+	return(__sync_lock_test_and_set(ptr, 0));
+}
+
+# else
+
+#  error "Unsupported platform"
+
+# endif /* HAVE_IB_GCC_ATOMIC_TEST_AND_SET */
 
 #elif defined(HAVE_IB_SOLARIS_ATOMICS)
 
@@ -394,13 +438,25 @@ amount of increment. */
 # define os_atomic_increment_ulint(ptr, amount) \
 	atomic_add_long_nv(ptr, amount)
 
-/**********************************************************//**
-Returns the old value of *ptr, atomically sets *ptr to new_val */
-
-# define os_atomic_test_and_set_byte_acquire(ptr, new_val) \
-	atomic_swap_uchar(ptr, new_val)
-# define os_atomic_test_and_set_byte_release(ptr, new_val) \
-	atomic_swap_uchar(ptr, new_val)
+/** Do an atomic xchg and set to non-zero.
+ at param[in,out]	ptr		Memory location to set to non-zero
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_test_and_set(volatile lock_word_t* ptr)
+{
+	return(atomic_swap_uchar(ptr, 1));
+}
+
+/** Do an atomic xchg and set to zero.
+ at param[in,out]	ptr		Memory location to set to zero
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_clear(volatile lock_word_t* ptr)
+{
+	return(atomic_swap_uchar(ptr, 0));
+}
 
 #elif defined(HAVE_WINDOWS_ATOMICS)
 
@@ -442,15 +498,27 @@ amount of increment. */
 # define os_atomic_increment_ulint(ptr, amount) \
 	((ulint) (win_xchg_and_add(ptr, amount) + amount))
 
-/**********************************************************//**
-Returns the old value of *ptr, atomically sets *ptr to new_val.
-InterlockedExchange() operates on LONG, and the LONG will be
-clobbered */
-
-# define os_atomic_test_and_set_byte_acquire(ptr, new_val) \
-	((byte) InterlockedExchange(ptr, new_val))
-# define os_atomic_test_and_set_byte_release(ptr, new_val) \
-	((byte) InterlockedExchange(ptr, new_val))
+/** Do an atomic test and set.
+InterlockedExchange() operates on LONG, and the LONG will be clobbered
+ at param[in,out]	ptr		Memory location to set to non-zero
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_test_and_set(volatile lock_word_t* ptr)
+{
+	return(InterlockedExchange(ptr, 1));
+}
+
+/** Do an atomic release.
+InterlockedExchange() operates on LONG, and the LONG will be clobbered
+ at param[in,out]	ptr		Memory location to set to zero
+ at return the previous value */
+static inline
+lock_word_t
+os_atomic_clear(volatile lock_word_t* ptr)
+{
+	return(InterlockedExchange(ptr, 0));
+}
 
 #else
 # define IB_ATOMICS_STARTUP_MSG \
diff --git a/storage/innobase/include/row0purge.h b/storage/innobase/include/row0purge.h
index fa9c929..9a638c8 100644
--- a/storage/innobase/include/row0purge.h
+++ b/storage/innobase/include/row0purge.h
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -111,6 +111,17 @@ struct purge_node_struct{
 				purge of a row */
 };
 
+#ifdef UNIV_DEBUG
+/***********************************************************//**
+Validate the persisent cursor in the purge node. The purge node has two
+references to the clustered index record - one via the ref member, and the
+other via the persistent cursor.  These two references must match each
+other if the found_clust flag is set.
+ at return true if the persistent cursor is consistent with the ref member.*/
+ibool
+row_purge_validate_pcur(purge_node_t* node);
+#endif /* UNIV_DEBUG */
+
 #ifndef UNIV_NONINL
 #include "row0purge.ic"
 #endif
diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h
index 78f5b8d..bc8d0d2 100644
--- a/storage/innobase/include/sync0sync.h
+++ b/storage/innobase/include/sync0sync.h
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -45,13 +45,6 @@ Created 9/5/1995 Heikki Tuuri
 extern my_bool	timed_mutexes;
 #endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
 
-#ifdef HAVE_WINDOWS_ATOMICS
-typedef LONG lock_word_t;	/*!< On Windows, InterlockedExchange operates
-				on LONG variable */
-#else
-typedef byte lock_word_t;
-#endif
-
 #if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
 /* There are mutexes/rwlocks that we want to exclude from
 instrumentation even if their corresponding performance schema
diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic
index 8cf3eb4..1120da8 100644
--- a/storage/innobase/include/sync0sync.ic
+++ b/storage/innobase/include/sync0sync.ic
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -80,7 +80,7 @@ mutex_test_and_set(
 	mutex_t*	mutex)	/*!< in: mutex */
 {
 #if defined(HAVE_ATOMIC_BUILTINS)
-	return(os_atomic_test_and_set_byte_acquire(&mutex->lock_word, 1));
+	return(os_atomic_test_and_set(&mutex->lock_word));
 #else
 	ibool	ret;
 
@@ -108,10 +108,7 @@ mutex_reset_lock_word(
 	mutex_t*	mutex)	/*!< in: mutex */
 {
 #if defined(HAVE_ATOMIC_BUILTINS)
-	/* In theory __sync_lock_release should be used to release the lock.
-	Unfortunately, it does not work properly alone. The workaround is
-	that more conservative __sync_lock_test_and_set is used instead. */
-	os_atomic_test_and_set_byte_release(&mutex->lock_word, 0);
+	os_atomic_clear(&mutex->lock_word);
 #else
 	mutex->lock_word = 0;
 
diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c
index e6ce074..559b368 100644
--- a/storage/innobase/lock/lock0lock.c
+++ b/storage/innobase/lock/lock0lock.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -2457,16 +2457,16 @@ lock_rec_inherit_to_gap(
 	/* If srv_locks_unsafe_for_binlog is TRUE or session is using
 	READ COMMITTED isolation level, we do not want locks set
 	by an UPDATE or a DELETE to be inherited as gap type locks. But we
-	DO want S-locks set by a consistency constraint to be inherited also
-	then. */
+	DO want S-locks/X-locks (taken for replace) set by a consistency
+	constraint to be inherited also then. */
 
 	while (lock != NULL) {
 		if (!lock_rec_get_insert_intention(lock)
 		    && !((srv_locks_unsafe_for_binlog
 			  || lock->trx->isolation_level
 			  <= TRX_ISO_READ_COMMITTED)
-			 && lock_get_mode(lock) == LOCK_X)) {
-
+			 && lock_get_mode(lock) ==
+			 (lock->trx->duplicates ? LOCK_S : LOCK_X))) {
 			lock_rec_add_to_queue(LOCK_REC | LOCK_GAP
 					      | lock_get_mode(lock),
 					      heir_block, heir_heap_no,
diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c
index 8fc22fb..d792e7a 100644
--- a/storage/innobase/os/os0file.c
+++ b/storage/innobase/os/os0file.c
@@ -1,6 +1,6 @@
 /***********************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2009, Percona Inc.
 
 Portions of this file contain modifications contributed and copyrighted
@@ -1276,16 +1276,19 @@ os_file_create_simple_no_error_handling_func(
 #else /* __WIN__ */
 	os_file_t	file;
 	int		create_flag;
+	const char*	mode_str	= NULL;
 
 	ut_a(name);
 
 	if (create_mode == OS_FILE_OPEN) {
+		mode_str = "OPEN";
 		if (access_type == OS_FILE_READ_ONLY) {
 			create_flag = O_RDONLY;
 		} else {
 			create_flag = O_RDWR;
 		}
 	} else if (create_mode == OS_FILE_CREATE) {
+		mode_str = "CREATE";
 		create_flag = O_RDWR | O_CREAT | O_EXCL;
 	} else {
 		create_flag = 0;
@@ -1310,6 +1313,14 @@ os_file_create_simple_no_error_handling_func(
 #endif
 	} else {
 		*success = TRUE;
+
+		/* This function is always called for data files, we should
+		disable OS caching (O_DIRECT) here as we do in
+		os_file_create_func(), so we open the same file in the same
+		mode, see man page of open(2). */
+		if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
+			os_file_set_nocache(file, name, mode_str);
+		}
 	}
 
 	return(file);
diff --git a/storage/innobase/row/row0purge.c b/storage/innobase/row/row0purge.c
index efcfdc3..9018582 100644
--- a/storage/innobase/row/row0purge.c
+++ b/storage/innobase/row/row0purge.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -43,6 +43,7 @@ Created 3/14/1997 Heikki Tuuri
 #include "row0vers.h"
 #include "row0mysql.h"
 #include "log0log.h"
+#include "rem0cmp.h"
 
 /*************************************************************************
 IMPORTANT NOTE: Any operation that generates redo MUST check that there
@@ -80,7 +81,7 @@ row_purge_node_create(
 
 /***********************************************************//**
 Repositions the pcur in the purge node on the clustered index record,
-if found.
+if found. If the record is not found, close pcur.
 @return	TRUE if the record was found */
 static
 ibool
@@ -90,23 +91,28 @@ row_purge_reposition_pcur(
 	purge_node_t*	node,	/*!< in: row purge node */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
-	ibool	found;
-
 	if (node->found_clust) {
-		found = btr_pcur_restore_position(mode, &(node->pcur), mtr);
+		ut_ad(row_purge_validate_pcur(node));
 
-		return(found);
-	}
+		node->found_clust = btr_pcur_restore_position(
+			mode, &(node->pcur), mtr);
+
+	} else {
+
+		node->found_clust = row_search_on_row_ref(
+			&(node->pcur), mode, node->table, node->ref, mtr);
 
-	found = row_search_on_row_ref(&(node->pcur), mode, node->table,
-				      node->ref, mtr);
-	node->found_clust = found;
+		if (node->found_clust) {
+			btr_pcur_store_position(&(node->pcur), mtr);
+		}
+	}
 
-	if (found) {
-		btr_pcur_store_position(&(node->pcur), mtr);
+	/* Close the current cursor if we fail to position it correctly. */
+	if (!node->found_clust) {
+		btr_pcur_close(&node->pcur);
 	}
 
-	return(found);
+	return(node->found_clust);
 }
 
 /***********************************************************//**
@@ -143,8 +149,8 @@ row_purge_remove_clust_if_poss_low(
 
 	if (!success) {
 		/* The record is already removed */
-
-		btr_pcur_commit_specify_mtr(pcur, &mtr);
+		/* Persistent cursor is closed if reposition fails. */
+		mtr_commit(&mtr);
 
 		return(TRUE);
 	}
@@ -258,7 +264,12 @@ row_purge_poss_sec(
 						 btr_pcur_get_rec(&node->pcur),
 						 &mtr, index, entry);
 
-	btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
+	/* Persistent cursor is closed if reposition fails. */
+	if (node->found_clust) {
+		btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
+	} else {
+		mtr_commit(&mtr);
+	}
 
 	return(can_delete);
 }
@@ -806,3 +817,53 @@ row_purge_step(
 
 	return(thr);
 }
+
+#ifdef UNIV_DEBUG
+/***********************************************************//**
+Validate the persisent cursor in the purge node. The purge node has two
+references to the clustered index record - one via the ref member, and the
+other via the persistent cursor.  These two references must match each
+other if the found_clust flag is set.
+ at return true if the stored copy of persistent cursor is consistent
+with the ref member.*/
+ibool
+row_purge_validate_pcur(
+	purge_node_t*	node)
+{
+	dict_index_t*	clust_index;
+	ulint*		offsets;
+	int		st;
+
+	if (!node->found_clust) {
+		return(TRUE);
+	}
+
+	if (node->index == NULL) {
+		return(TRUE);
+	}
+
+	if (node->pcur.old_stored != BTR_PCUR_OLD_STORED) {
+		return(TRUE);
+	}
+
+	clust_index = node->pcur.btr_cur.index;
+
+	offsets = rec_get_offsets(node->pcur.old_rec, clust_index, NULL,
+				  node->pcur.old_n_fields, &node->heap);
+
+	/* Here we are comparing the purge ref record and the stored initial
+	part in persistent cursor. Both cases we store n_uniq fields of the
+	cluster index and so it is fine to do the comparison. We note this
+	dependency here as pcur and ref belong to different modules. */
+	st = cmp_dtuple_rec(node->ref, node->pcur.old_rec, offsets);
+
+	if (st != 0) {
+		fprintf(stderr, "Purge node pcur validation failed\n");
+		dtuple_print(stderr, node->ref);
+		rec_print(stderr, node->pcur.old_rec, clust_index);
+		return(FALSE);
+	}
+
+	return(TRUE);
+}
+#endif /* UNIV_DEBUG */
diff --git a/storage/perfschema/pfs_timer.cc b/storage/perfschema/pfs_timer.cc
index 302548c..3191a05 100644
--- a/storage/perfschema/pfs_timer.cc
+++ b/storage/perfschema/pfs_timer.cc
@@ -1,5 +1,4 @@
-/* Copyright (c) 2008 MySQL AB, 2010 Sun Microsystems, Inc.
-   Use is subject to license terms.
+/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -89,6 +88,46 @@ void init_timers(void)
                                      (double)pfs_timer_info.ticks.frequency);
   else
     tick_to_pico= 0;
+
+  /*
+    Depending on the platform and build options, some timers may not be
+    available. Pick best replacements.
+  */
+
+  /*
+    For WAIT, the cycle timer is used by default. However, it is not available
+    on all architectures. Fall back to the nanosecond timer in this case. It is
+    unlikely that neither cycle nor nanosecond are available, but we continue
+    probing less resolution timers anyway for consistency with other events.
+  */
+  if (cycle_to_pico != 0)
+  {
+    /* Normal case. */
+    wait_timer= TIMER_NAME_CYCLE;
+  }
+  else if (nanosec_to_pico != 0)
+  {
+    /* Robustness, no known cases. */
+    wait_timer= TIMER_NAME_NANOSEC;
+  }
+  else if (microsec_to_pico != 0)
+  {
+    /* Robustness, no known cases. */
+    wait_timer= TIMER_NAME_MICROSEC;
+  }
+  else if (millisec_to_pico != 0)
+  {
+    /* Robustness, no known cases. */
+    wait_timer= TIMER_NAME_MILLISEC;
+  }
+  else
+  {
+    /*
+       Will never be reached on any architecture, but must provide a default if
+       no other timers are available.
+    */
+    wait_timer= TIMER_NAME_TICK;
+  }
 }
 
 ulonglong get_timer_value(enum_timer_name timer_name)
diff --git a/util/tests/sm-basic.cc b/storage/tokudb/ft-index/util/tests/sm-basic.cc
similarity index 100%
rename from util/tests/sm-basic.cc
rename to storage/tokudb/ft-index/util/tests/sm-basic.cc
diff --git a/util/tests/sm-crash-double-free.cc b/storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc
similarity index 100%
rename from util/tests/sm-crash-double-free.cc
rename to storage/tokudb/ft-index/util/tests/sm-crash-double-free.cc
diff --git a/mysql-test/suite/tokudb.bugs/r/db805.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db805.result
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/r/db805.result
rename to storage/tokudb/mysql-test/tokudb_bugs/r/db805.result
diff --git a/mysql-test/suite/tokudb.bugs/r/db806.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db806.result
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/r/db806.result
rename to storage/tokudb/mysql-test/tokudb_bugs/r/db806.result
diff --git a/mysql-test/suite/tokudb.bugs/r/db811.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db811.result
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/r/db811.result
rename to storage/tokudb/mysql-test/tokudb_bugs/r/db811.result
diff --git a/mysql-test/suite/tokudb.bugs/r/db811s.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/r/db811s.result
rename to storage/tokudb/mysql-test/tokudb_bugs/r/db811s.result
diff --git a/mysql-test/suite/tokudb.bugs/r/db823.result b/storage/tokudb/mysql-test/tokudb_bugs/r/db823.result
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/r/db823.result
rename to storage/tokudb/mysql-test/tokudb_bugs/r/db823.result
diff --git a/mysql-test/suite/tokudb.bugs/t/db805.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db805.test
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/t/db805.test
rename to storage/tokudb/mysql-test/tokudb_bugs/t/db805.test
diff --git a/mysql-test/suite/tokudb.bugs/t/db806.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db806.test
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/t/db806.test
rename to storage/tokudb/mysql-test/tokudb_bugs/t/db806.test
diff --git a/mysql-test/suite/tokudb.bugs/t/db811.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db811.test
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/t/db811.test
rename to storage/tokudb/mysql-test/tokudb_bugs/t/db811.test
diff --git a/mysql-test/suite/tokudb.bugs/t/db811s.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/t/db811s.test
rename to storage/tokudb/mysql-test/tokudb_bugs/t/db811s.test
diff --git a/mysql-test/suite/tokudb.bugs/t/db823.test b/storage/tokudb/mysql-test/tokudb_bugs/t/db823.test
similarity index 100%
rename from mysql-test/suite/tokudb.bugs/t/db823.test
rename to storage/tokudb/mysql-test/tokudb_bugs/t/db823.test
diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c
index f8966e9..6ef9ac0 100644
--- a/storage/xtradb/buf/buf0buf.c
+++ b/storage/xtradb/buf/buf0buf.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 
 Portions of this file contain modifications contributed and copyrighted by
@@ -1666,6 +1666,10 @@ buf_pool_watch_set(
 
 	/* buf_pool->watch is protected by zip_mutex for now */
 	mutex_enter(&buf_pool->zip_mutex);
+
+	/* The maximum number of purge threads should never exceed
+	BUF_POOL_WATCH_SIZE. So there is no way for purge thread
+	instance to hold a watch when setting another watch. */
 	for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) {
 		bpage = &buf_pool->watch[i];
 
diff --git a/storage/xtradb/dict/dict0crea.c b/storage/xtradb/dict/dict0crea.c
index c88979b..f7663b9 100644
--- a/storage/xtradb/dict/dict0crea.c
+++ b/storage/xtradb/dict/dict0crea.c
@@ -1627,6 +1627,104 @@ dict_create_add_foreign_field_to_dictionary(
 }
 
 /********************************************************************//**
+Construct foreign key constraint defintion from data dictionary information.
+*/
+UNIV_INTERN
+char*
+dict_foreign_def_get(
+/*=================*/
+	dict_foreign_t*	foreign,/*!< in: foreign */
+	trx_t*		trx)	/*!< in: trx */
+{
+	char* fk_def = mem_heap_alloc(foreign->heap, 4*1024);
+	const char* tbname;
+	char tablebuf[MAX_TABLE_NAME_LEN + 1] = "";
+	int i;
+	char* bufend;
+
+	tbname = dict_remove_db_name(foreign->id);
+	bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN,
+				tbname, strlen(tbname), trx->mysql_thd, FALSE);
+	tablebuf[bufend - tablebuf] = '\0';
+
+	sprintf(fk_def,
+		(char *)"CONSTRAINT %s FOREIGN KEY (", (char *)tablebuf);
+
+	for(i = 0; i < foreign->n_fields; i++) {
+		char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+		innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->foreign_col_names[i],
+				strlen(foreign->foreign_col_names[i]),
+				trx->mysql_thd, FALSE);
+		strcat(fk_def, buf);
+		if (i < foreign->n_fields-1) {
+			strcat(fk_def, (char *)",");
+		}
+	}
+
+	strcat(fk_def,(char *)") REFERENCES ");
+
+	bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN,
+	        	        foreign->referenced_table_name,
+			        strlen(foreign->referenced_table_name),
+			        trx->mysql_thd, TRUE);
+	tablebuf[bufend - tablebuf] = '\0';
+
+	strcat(fk_def, tablebuf);
+	strcat(fk_def, " (");
+
+	for(i = 0; i < foreign->n_fields; i++) {
+		char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+		bufend = innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->referenced_col_names[i],
+				strlen(foreign->referenced_col_names[i]),
+				trx->mysql_thd, FALSE);
+		buf[bufend - buf] = '\0';
+		strcat(fk_def, buf);
+		if (i < foreign->n_fields-1) {
+			strcat(fk_def, (char *)",");
+		}
+	}
+	strcat(fk_def, (char *)")");
+
+	return fk_def;
+}
+
+/********************************************************************//**
+Convert foreign key column names from data dictionary to SQL-layer.
+*/
+static
+void
+dict_foreign_def_get_fields(
+/*========================*/
+	dict_foreign_t*	foreign,/*!< in: foreign */
+	trx_t*		trx,	/*!< in: trx */
+	char**		field,  /*!< out: foreign column */
+	char**		field2, /*!< out: referenced column */
+	int		col_no) /*!< in: column number */
+{
+	char* bufend;
+	char* fieldbuf = mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1);
+	char* fieldbuf2 = mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1);
+
+	bufend = innobase_convert_name(fieldbuf, MAX_TABLE_NAME_LEN,
+			foreign->foreign_col_names[col_no],
+			strlen(foreign->foreign_col_names[col_no]),
+			trx->mysql_thd, FALSE);
+
+	fieldbuf[bufend - fieldbuf] = '\0';
+
+	bufend = innobase_convert_name(fieldbuf2, MAX_TABLE_NAME_LEN,
+			foreign->referenced_col_names[col_no],
+			strlen(foreign->referenced_col_names[col_no]),
+			trx->mysql_thd, FALSE);
+
+	fieldbuf2[bufend - fieldbuf2] = '\0';
+	*field = fieldbuf;
+	*field2 = fieldbuf2;
+}
+
+/********************************************************************//**
 Add a single foreign key definition to the data dictionary tables in the
 database. We also generate names to constraints that were not named by the
 user. A generated constraint has a name of the format
@@ -1708,6 +1806,29 @@ dict_create_add_foreign_to_dictionary(
 
 	if (error != DB_SUCCESS) {
 
+		if (error == DB_DUPLICATE_KEY) {
+			char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+			char	tablename[MAX_TABLE_NAME_LEN + 1] = "";
+			char*	fk_def;
+
+			innobase_convert_name(tablename, MAX_TABLE_NAME_LEN,
+				table->name, strlen(table->name),
+				trx->mysql_thd, TRUE);
+
+			innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->id, strlen(foreign->id), trx->mysql_thd, FALSE);
+
+			fk_def = dict_foreign_def_get(foreign, trx);
+
+			ib_push_warning(trx, error,
+				"Create or Alter table %s with foreign key constraint"
+				" failed. Foreign key constraint %s"
+				" already exists on data dictionary."
+				" Foreign key constraint names need to be unique in database."
+				" Error in foreign key definition: %s.",
+				tablename, buf, fk_def);
+		}
+
 		return(error);
 	}
 
@@ -1716,6 +1837,26 @@ dict_create_add_foreign_to_dictionary(
 			i, table, foreign, trx);
 
 		if (error != DB_SUCCESS) {
+			char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+			char	tablename[MAX_TABLE_NAME_LEN + 1] = "";
+			char*	field=NULL;
+			char*	field2=NULL;
+			char*	fk_def;
+
+			innobase_convert_name(tablename, MAX_TABLE_NAME_LEN,
+				table->name, strlen(table->name),
+				trx->mysql_thd, TRUE);
+			innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				foreign->id, strlen(foreign->id), trx->mysql_thd, FALSE);
+			fk_def = dict_foreign_def_get(foreign, trx);
+			dict_foreign_def_get_fields(foreign, trx, &field, &field2, i);
+
+			ib_push_warning(trx, error,
+				"Create or Alter table %s with foreign key constraint"
+				" failed. Error adding foreign  key constraint name %s"
+				" fields %s or %s to the dictionary."
+				" Error in foreign key definition: %s.",
+				tablename, buf, i+1, fk_def);
 
 			return(error);
 		}
@@ -1800,7 +1941,7 @@ dict_create_add_foreigns_to_dictionary(
 	     foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) {
 
 		error = dict_create_add_foreign_to_dictionary(&number, table,
-							      foreign, trx);
+			foreign, trx);
 
 		if (error != DB_SUCCESS) {
 
diff --git a/storage/xtradb/dict/dict0dict.c b/storage/xtradb/dict/dict0dict.c
index bd0fdf6..cd8e415 100644
--- a/storage/xtradb/dict/dict0dict.c
+++ b/storage/xtradb/dict/dict0dict.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -2663,12 +2663,14 @@ dict_foreign_remove_from_cache(
 			       foreign);
 
 		rbt = foreign->referenced_table->referenced_rbt;
+
 		if (rbt != NULL && foreign->id != NULL) {
 			const ib_rbt_node_t*	node
 				= rbt_lookup(rbt, foreign->id);
 
-			if (node) {
-				dict_foreign_t*	val = *(dict_foreign_t**) node->value;
+			if (node != NULL) {
+				dict_foreign_t*	val
+					= *(dict_foreign_t**) node->value;
 
 				if (val == foreign) {
 					rbt_delete(rbt, foreign->id);
@@ -2689,8 +2691,9 @@ dict_foreign_remove_from_cache(
 			const ib_rbt_node_t*	node
 				= rbt_lookup(rbt, foreign->id);
 
-			if (node) {
-				dict_foreign_t*	val = *(dict_foreign_t**) node->value;
+			if (node != NULL) {
+				dict_foreign_t*	val
+					= *(dict_foreign_t**) node->value;
 
 				if (val == foreign) {
 					rbt_delete(rbt, foreign->id);
@@ -2747,6 +2750,11 @@ dict_foreign_find(
 	DBUG_RETURN(NULL);
 }
 
+#define  DB_FOREIGN_KEY_IS_PREFIX_INDEX 200
+#define  DB_FOREIGN_KEY_COL_NOT_NULL    201
+#define  DB_FOREIGN_KEY_COLS_NOT_EQUAL  202
+#define  DB_FOREIGN_KEY_INDEX_NOT_FOUND 203
+
 /*********************************************************************//**
 Tries to find an index whose first fields are the columns in the array,
 in the same order and is not marked for deletion and is not the same
@@ -2764,12 +2772,21 @@ dict_foreign_find_index(
 	ibool		check_charsets,
 				/*!< in: whether to check charsets.
 				only has an effect if types_idx != NULL */
-	ulint		check_null)
+	ulint		check_null,
 				/*!< in: nonzero if none of the columns must
 				be declared NOT NULL */
+	ulint*		error,	/*!< out: error code */
+	ulint*		err_col_no,
+				/*!< out: column number where error happened */
+	dict_index_t**	err_index)
+			        /*!< out: index where error happened */
 {
 	dict_index_t*	index;
 
+	if (error) {
+		*error = DB_FOREIGN_KEY_INDEX_NOT_FOUND;
+	}
+
 	index = dict_table_get_first_index(table);
 
 	while (index != NULL) {
@@ -2795,6 +2812,12 @@ dict_foreign_find_index(
 					/* We do not accept column prefix
 					indexes here */
 
+					if (error && err_col_no && err_index) {
+						*error = DB_FOREIGN_KEY_IS_PREFIX_INDEX;
+						*err_col_no = i;
+						*err_index = index;
+					}
+
 					break;
 				}
 
@@ -2806,6 +2829,11 @@ dict_foreign_find_index(
 				if (check_null
 				    && (field->col->prtype & DATA_NOT_NULL)) {
 
+					if (error && err_col_no && err_index) {
+						*error = DB_FOREIGN_KEY_COL_NOT_NULL;
+						*err_col_no = i;
+						*err_index = index;
+					}
 					return(NULL);
 				}
 
@@ -2815,6 +2843,12 @@ dict_foreign_find_index(
 								   i),
 					    check_charsets)) {
 
+					if (error && err_col_no && err_index) {
+						*error = DB_FOREIGN_KEY_COLS_NOT_EQUAL;
+						*err_col_no = i;
+						*err_index = index;
+					}
+
 					break;
 				}
 			}
@@ -2822,6 +2856,10 @@ dict_foreign_find_index(
 			if (i == n_cols) {
 				/* We found a matching index */
 
+				if (error) {
+					*error = DB_SUCCESS;
+				}
+
 				return(index);
 			}
 		}
@@ -2853,7 +2891,7 @@ dict_foreign_find_equiv_index(
 		       foreign->foreign_table,
 		       foreign->foreign_col_names, foreign->n_fields,
 		       foreign->foreign_index, TRUE, /* check types */
-		       FALSE/* allow columns to be NULL */));
+		       FALSE/* allow columns to be NULL */, NULL, NULL, NULL));
 }
 
 #endif /* !UNIV_HOTBACKUP */
@@ -3016,11 +3054,15 @@ dict_foreign_add_to_cache(
 	}
 
 	if (for_in_cache->referenced_table == NULL && ref_table) {
+		ulint index_error;
+		ulint err_col;
+		dict_index_t *err_index=NULL;
+
 		index = dict_foreign_find_index(
 			ref_table,
 			for_in_cache->referenced_col_names,
 			for_in_cache->n_fields, for_in_cache->foreign_index,
-			check_charsets, FALSE);
+			check_charsets, FALSE, &index_error, &err_col, &err_index);
 
 		if (index == NULL
 		    && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) {
@@ -3052,6 +3094,9 @@ dict_foreign_add_to_cache(
 	}
 
 	if (for_in_cache->foreign_table == NULL && for_table) {
+		ulint index_error;
+		ulint err_col;
+		dict_index_t* err_index=NULL;
 
 		index = dict_foreign_find_index(
 			for_table,
@@ -3060,7 +3105,8 @@ dict_foreign_add_to_cache(
 			for_in_cache->referenced_index, check_charsets,
 			for_in_cache->type
 			& (DICT_FOREIGN_ON_DELETE_SET_NULL
-			   | DICT_FOREIGN_ON_UPDATE_SET_NULL));
+				| DICT_FOREIGN_ON_UPDATE_SET_NULL),
+			&index_error, &err_col, &err_index);
 
 		if (index == NULL
 		    && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) {
@@ -3671,6 +3717,8 @@ static
 void
 dict_foreign_report_syntax_err(
 /*===========================*/
+	const char*     fmt,		/*!< in: syntax err msg */
+	const char*	oper,		/*!< in: operation */
 	const char*	name,		/*!< in: table name */
 	const char*	start_of_latest_foreign,
 					/*!< in: start of the foreign key clause
@@ -3681,12 +3729,102 @@ dict_foreign_report_syntax_err(
 
 	mutex_enter(&dict_foreign_err_mutex);
 	dict_foreign_error_report_low(ef, name);
-	fprintf(ef, "%s:\nSyntax error close to:\n%s\n",
-		start_of_latest_foreign, ptr);
+	fprintf(ef, fmt, oper, name, start_of_latest_foreign, ptr);
 	mutex_exit(&dict_foreign_err_mutex);
 }
 
 /*********************************************************************//**
+Push warning message to SQL-layer based on foreign key constraint
+index match error. */
+static
+void
+dict_foreign_push_index_error(
+/*==========================*/
+	trx_t*		trx,		/*!< in: trx */
+	const char*	operation,	/*!< in: operation create or alter
+					*/
+	const char*	create_name,	/*!< in: table name in create or
+					alter table */
+	const char*	latest_foreign,	/*!< in: start of latest foreign key
+					constraint name */
+	const char**	columns,	/*!< in: foreign key columns */
+	ulint		index_error,	/*!< in: error code */
+	ulint		err_col,	/*!< in: column where error happened
+					*/
+	dict_index_t*	err_index,	/*!< in: index where error happened
+					*/
+	dict_table_t*	table,		/*!< in: table */
+	FILE*		ef)		/*!< in: output stream */
+{
+	switch (index_error) {
+	case DB_FOREIGN_KEY_INDEX_NOT_FOUND: {
+		fprintf(ef,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is no index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.\n",
+			operation, create_name, latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is no index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.",
+			operation, create_name, latest_foreign);
+		break;
+	}
+	case DB_FOREIGN_KEY_IS_PREFIX_INDEX: {
+		fprintf(ef,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is only prefix index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.\n",
+			operation, create_name, latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table '%s' with foreign key constraint"
+			" failed. There is only prefix index in the referenced"
+			" table where the referenced columns appear"
+			" as the first columns. Error close to %s.",
+			operation, create_name, latest_foreign);
+		break;
+	}
+	case DB_FOREIGN_KEY_COL_NOT_NULL: {
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. You have defined a SET NULL condition but "
+			"field %s on index is defined as NOT NULL close to %s\n",
+			operation, create_name, columns[err_col], latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. You have defined a SET NULL condition but "
+			"field %s on index is defined as NOT NULL close to %s",
+			operation, create_name, columns[err_col], latest_foreign);
+		break;
+	}
+	case DB_FOREIGN_KEY_COLS_NOT_EQUAL: {
+		dict_field_t*	field;
+		const char*	col_name;
+		field = dict_index_get_nth_field(err_index, err_col);
+
+		col_name = dict_table_get_col_name(
+			table, dict_col_get_no(field->col));
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Field type or character set for column %s "
+			"does not mach referenced column %s close to %s\n",
+			operation, create_name, columns[err_col], col_name, latest_foreign);
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Field type or character set for column %s "
+			"does not mach referenced column %s close to %s",
+			operation, create_name, columns[err_col], col_name, latest_foreign);
+		break;
+	}
+	default:
+		ut_error;
+	}
+}
+
+/*********************************************************************//**
 Scans a table create SQL string and adds to the data dictionary the foreign
 key constraints declared in the string. This function should be called after
 the indexes for a table have been created. Each foreign key constraint must
@@ -3714,15 +3852,20 @@ dict_create_foreign_constraints_low(
 				DB_CANNOT_ADD_CONSTRAINT if any foreign
 				keys are found. */
 {
-	dict_table_t*	table;
-	dict_table_t*	referenced_table;
-	dict_table_t*	table_to_alter;
+	dict_table_t*	table			= NULL;
+	dict_table_t*	referenced_table	= NULL;
+	dict_table_t*	table_to_alter		= NULL;
+	dict_table_t*	table_to_create		= NULL;
 	ulint		highest_id_so_far	= 0;
-	dict_index_t*	index;
-	dict_foreign_t*	foreign;
+	dict_index_t*	index			= NULL;
+	dict_foreign_t*	foreign			= NULL;
 	const char*	ptr			= sql_string;
 	const char*	start_of_latest_foreign	= sql_string;
+	const char*	start_of_latest_set     = NULL;
 	FILE*		ef			= dict_foreign_err_file;
+	ulint		index_error		= DB_SUCCESS;
+	dict_index_t*	err_index		= NULL;
+	ulint		err_col;
 	const char*	constraint_name;
 	ibool		success;
 	ulint		error;
@@ -3735,29 +3878,68 @@ dict_create_foreign_constraints_low(
 	ulint		n_on_updates;
 	const dict_col_t*columns[500];
 	const char*	column_names[500];
+	const char*	ref_column_names[500];
 	const char*	referenced_table_name;
+	const char*	create_table_name;
+	const char*	orig;
+	char		create_name[MAX_TABLE_NAME_LEN + 1];
+	const char	operation[8];
 
 	ut_ad(mutex_own(&(dict_sys->mutex)));
 
 	table = dict_table_get_low(name, DICT_ERR_IGNORE_NONE);
+	/* First check if we are actually doing an ALTER TABLE, and in that
+	case look for the table being altered */
+	ptr = dict_accept(cs, ptr, "ALTER", &success);
+
+	strcpy((char *)operation, success ? "Alter " : "Create ");
+
+	if (!success) {
+		orig = ptr;
+		ptr = dict_scan_to(ptr, "CREATE");
+		ptr = dict_scan_to(ptr, "TABLE");
+		ptr = dict_accept(cs, ptr, "TABLE", &success);
+
+		if (success) {
+			ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
+					&success, heap, &create_table_name);
+		}
+
+		if (success) {
+			char *bufend;
+			bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+					create_table_name, strlen(create_table_name),
+					trx->mysql_thd, TRUE);
+			create_name[bufend-create_name]='\0';
+			ptr = orig;
+		} else {
+			char *bufend;
+			ptr = orig;
+			bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+					name, strlen(name), trx->mysql_thd, TRUE);
+			create_name[bufend-create_name]='\0';
+		}
+
+		goto loop;
+	}
 
 	if (table == NULL) {
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef,
-			"Cannot find the table in the internal"
-			" data dictionary of InnoDB.\n"
-			"Create table statement:\n%s\n", sql_string);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef, "%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.\n",
+			operation, create_name, create_name, start_of_latest_foreign);
 		mutex_exit(&dict_foreign_err_mutex);
-
+		ib_push_warning(trx, DB_ERROR,
+			"%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.",
+			operation, create_name, create_name, start_of_latest_foreign);
 		return(DB_ERROR);
 	}
 
-	/* First check if we are actually doing an ALTER TABLE, and in that
-	case look for the table being altered */
-
-	ptr = dict_accept(cs, ptr, "ALTER", &success);
-
+	/* If not alter table jump to loop */
 	if (!success) {
 
 		goto loop;
@@ -3772,13 +3954,40 @@ dict_create_foreign_constraints_low(
 
 	/* We are doing an ALTER TABLE: scan the table name we are altering */
 
+	orig = ptr;
 	ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
 				   &success, heap, &referenced_table_name);
+
+	if (table_to_alter) {
+		char *bufend;
+		bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+				table_to_alter->name, strlen(table_to_alter->name),
+				trx->mysql_thd, TRUE);
+		create_name[bufend-create_name]='\0';
+	} else {
+		char *bufend;
+		bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
+				referenced_table_name, strlen(referenced_table_name),
+				trx->mysql_thd, TRUE);
+		create_name[bufend-create_name]='\0';
+
+	}
+
 	if (!success) {
-		fprintf(stderr,
-			"InnoDB: Error: could not find"
-			" the table being ALTERED in:\n%s\n",
-			sql_string);
+		mutex_enter(&dict_foreign_err_mutex);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.\n",
+			operation, create_name, create_name, orig);
+		mutex_exit(&dict_foreign_err_mutex);
+
+		ib_push_warning(trx, DB_ERROR,
+			"%s table %s with foreign key constraint"
+			" failed. Table %s not found from data dictionary."
+			" Error close to %s.",
+			operation, create_name, create_name, orig);
 
 		return(DB_ERROR);
 	}
@@ -3844,7 +4053,19 @@ loop:
 		if so, immediately reject the command if the table is a
 		temporary one. For now, this kludge will work. */
 		if (reject_fks && (UT_LIST_GET_LEN(table->foreign_list) > 0)) {
+			mutex_enter(&dict_foreign_err_mutex);
+			dict_foreign_error_report_low(ef, create_name);
+			fprintf(ef, "%s table %s with foreign key constraint"
+				" failed. Temporary tables can't have foreign key constraints."
+				" Error close to %s.\n",
+				operation, create_name, start_of_latest_foreign);
+			mutex_exit(&dict_foreign_err_mutex);
 
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Temporary tables can't have foreign key constraints."
+				" Error close to %s.",
+				operation, create_name, start_of_latest_foreign);
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
@@ -3880,11 +4101,21 @@ loop:
 	if (!success) {
 		/* MySQL allows also an index id before the '('; we
 		skip it */
+		orig = ptr;
 		ptr = dict_skip_word(cs, ptr, &success);
 
 		if (!success) {
 			dict_foreign_report_syntax_err(
-				name, start_of_latest_foreign, ptr);
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.\n",
+				operation, create_name, start_of_latest_foreign, orig);
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.",
+				operation, create_name, start_of_latest_foreign, orig);
 
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
@@ -3904,15 +4135,26 @@ loop:
 	/* Scan the columns in the first list */
 col_loop1:
 	ut_a(i < (sizeof column_names) / sizeof *column_names);
+	orig = ptr;
 	ptr = dict_scan_col(cs, ptr, &success, table, columns + i,
 			    heap, column_names + i);
 	if (!success) {
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\nCannot resolve column name close to:\n%s\n",
-			start_of_latest_foreign, ptr);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		mutex_exit(&dict_foreign_err_mutex);
 
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3924,11 +4166,22 @@ col_loop1:
 		goto col_loop1;
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, ")", &success);
 
 	if (!success) {
 		dict_foreign_report_syntax_err(
-			name, start_of_latest_foreign, ptr);
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -3936,27 +4189,41 @@ col_loop1:
 	as the first fields and in the right order */
 
 	index = dict_foreign_find_index(table, column_names, i,
-					NULL, TRUE, FALSE);
+		NULL, TRUE, FALSE, &index_error, &err_col, &err_index);
 
 	if (!index) {
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
+		dict_foreign_error_report_low(ef, create_name);
 		fputs("There is no index in table ", ef);
-		ut_print_name(ef, NULL, TRUE, name);
+		ut_print_name(ef, NULL, TRUE, create_name);
 		fprintf(ef, " where the columns appear\n"
 			"as the first columns. Constraint:\n%s\n"
 			"See " REFMAN "innodb-foreign-key-constraints.html\n"
 			"for correct foreign key definition.\n",
 			start_of_latest_foreign);
-		mutex_exit(&dict_foreign_err_mutex);
 
-		return(DB_CHILD_NO_INDEX);
+		dict_foreign_push_index_error(trx, operation, create_name, start_of_latest_foreign,
+			column_names, index_error, err_col, err_index, table, ef);
+
+		mutex_exit(&dict_foreign_err_mutex);
+		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
+
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "REFERENCES", &success);
 
 	if (!success || !my_isspace(cs, *ptr)) {
 		dict_foreign_report_syntax_err(
-			name, start_of_latest_foreign, ptr);
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -4005,24 +4272,50 @@ col_loop1:
 	checking of foreign key constraints! */
 
 	if (!success || (!referenced_table && trx->check_foreigns)) {
+		char	buf[MAX_TABLE_NAME_LEN + 1] = "";
+		char*	bufend;
+
+		bufend = innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
+				referenced_table_name, strlen(referenced_table_name),
+				trx->mysql_thd, TRUE);
+		buf[bufend - buf] = '\0';
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
+			"close to %s.",
+			operation, create_name, buf, start_of_latest_foreign);
+
 		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\nCannot resolve table name close to:\n"
-			"%s\n",
-			start_of_latest_foreign, ptr);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint failed. Referenced table %s not found in the data dictionary "
+			"close to %s.\n",
+			operation, create_name, buf, start_of_latest_foreign);
+
 		mutex_exit(&dict_foreign_err_mutex);
 
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "(", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -4030,20 +4323,29 @@ col_loop1:
 	i = 0;
 
 col_loop2:
+	orig = ptr;
 	ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i,
-			    heap, column_names + i);
+			    heap, ref_column_names + i);
 	i++;
 
 	if (!success) {
 		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\nCannot resolve column name close to:\n"
-			"%s\n",
-			start_of_latest_foreign, ptr);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
 		mutex_exit(&dict_foreign_err_mutex);
 
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, orig);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -4053,13 +4355,25 @@ col_loop2:
 		goto col_loop2;
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, ")", &success);
 
 	if (!success || foreign->n_fields != i) {
+
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s. Too few referenced columns\n",
+			operation, create_name, start_of_latest_foreign, orig);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s. Too few referenced columns, you have %d when you should have %d.",
+			operation, create_name, start_of_latest_foreign, orig, i, foreign->n_fields);
+
 		dict_foreign_free(foreign);
 
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -4069,6 +4383,7 @@ col_loop2:
 scan_on_conditions:
 	/* Loop here as long as we can find ON ... conditions */
 
+	start_of_latest_set = ptr;
 	ptr = dict_accept(cs, ptr, "ON", &success);
 
 	if (!success) {
@@ -4079,13 +4394,24 @@ scan_on_conditions:
 	ptr = dict_accept(cs, ptr, "DELETE", &success);
 
 	if (!success) {
+		orig = ptr;
 		ptr = dict_accept(cs, ptr, "UPDATE", &success);
 
 		if (!success) {
 			dict_foreign_free(foreign);
 
 			dict_foreign_report_syntax_err(
-				name, start_of_latest_foreign, ptr);
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.\n",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 
@@ -4117,12 +4443,22 @@ scan_on_conditions:
 	ptr = dict_accept(cs, ptr, "NO", &success);
 
 	if (success) {
+		orig = ptr;
 		ptr = dict_accept(cs, ptr, "ACTION", &success);
 
 		if (!success) {
 			dict_foreign_free(foreign);
 			dict_foreign_report_syntax_err(
-				name, start_of_latest_foreign, ptr);
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.\n",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. Foreign key constraint parse error in %s"
+				" close to %s.",
+				operation, create_name, start_of_latest_foreign, start_of_latest_set);
 
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
@@ -4136,42 +4472,73 @@ scan_on_conditions:
 		goto scan_on_conditions;
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "SET", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
+	orig = ptr;
 	ptr = dict_accept(cs, ptr, "NULL", &success);
 
 	if (!success) {
 		dict_foreign_free(foreign);
-		dict_foreign_report_syntax_err(name, start_of_latest_foreign,
-					       ptr);
+		dict_foreign_report_syntax_err(
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.\n",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. Foreign key constraint parse error in %s"
+			" close to %s.",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
 	for (j = 0; j < foreign->n_fields; j++) {
 		if ((dict_index_get_nth_col(foreign->foreign_index, j)->prtype)
 		    & DATA_NOT_NULL) {
+			const dict_col_t*	col
+				= dict_index_get_nth_col(foreign->foreign_index, j);
+			const char* col_name = dict_table_get_col_name(foreign->foreign_index->table,
+				dict_col_get_no(col));
 
 			/* It is not sensible to define SET NULL
 			if the column is not allowed to be NULL! */
 
-			dict_foreign_free(foreign);
-
 			mutex_enter(&dict_foreign_err_mutex);
-			dict_foreign_error_report_low(ef, name);
-			fprintf(ef, "%s:\n"
-				"You have defined a SET NULL condition"
-				" though some of the\n"
-				"columns are defined as NOT NULL.\n",
-				start_of_latest_foreign);
+			dict_foreign_error_report_low(ef, create_name);
+			fprintf(ef,
+				"%s table %s with foreign key constraint"
+				" failed. You have defined a SET NULL condition but column %s is defined as NOT NULL"
+				" in %s close to %s.\n",
+				operation, create_name, col_name, start_of_latest_foreign, start_of_latest_set);
 			mutex_exit(&dict_foreign_err_mutex);
 
+
+			ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+				"%s table %s with foreign key constraint"
+				" failed. You have defined a SET NULL condition but column %s is defined as NOT NULL"
+				" in %s close to %s.",
+				operation, create_name, col_name, start_of_latest_foreign, start_of_latest_set);
+
+			dict_foreign_free(foreign);
 			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 	}
@@ -4188,16 +4555,22 @@ try_find_index:
 	if (n_on_deletes > 1 || n_on_updates > 1) {
 		/* It is an error to define more than 1 action */
 
-		dict_foreign_free(foreign);
 
 		mutex_enter(&dict_foreign_err_mutex);
-		dict_foreign_error_report_low(ef, name);
-		fprintf(ef, "%s:\n"
-			"You have twice an ON DELETE clause"
-			" or twice an ON UPDATE clause.\n",
-			start_of_latest_foreign);
+		dict_foreign_error_report_low(ef, create_name);
+		fprintf(ef,
+			"%s table %s with foreign key constraint"
+			" failed. You have more than one on delete or on update clause"
+			" in %s close to %s.\n",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
 		mutex_exit(&dict_foreign_err_mutex);
 
+		ib_push_warning(trx, DB_CANNOT_ADD_CONSTRAINT,
+			"%s table %s with foreign key constraint"
+			" failed. You have more than one on delete or on update clause"
+			" in %s close to %s.",
+			operation, create_name, start_of_latest_foreign, start_of_latest_set);
+		dict_foreign_free(foreign);
 		return(DB_CANNOT_ADD_CONSTRAINT);
 	}
 
@@ -4207,13 +4580,13 @@ try_find_index:
 
 	if (referenced_table) {
 		index = dict_foreign_find_index(referenced_table,
-						column_names, i,
-						foreign->foreign_index,
-						TRUE, FALSE);
+					ref_column_names, i,
+					foreign->foreign_index,
+					TRUE, FALSE, &index_error, &err_col, &err_index);
 		if (!index) {
 			dict_foreign_free(foreign);
 			mutex_enter(&dict_foreign_err_mutex);
-			dict_foreign_error_report_low(ef, name);
+			dict_foreign_error_report_low(ef, create_name);
 			fprintf(ef, "%s:\n"
 				"Cannot find an index in the"
 				" referenced table where the\n"
@@ -4231,9 +4604,13 @@ try_find_index:
 				"innodb-foreign-key-constraints.html\n"
 				"for correct foreign key definition.\n",
 				start_of_latest_foreign);
+
+			dict_foreign_push_index_error(trx, operation, create_name, start_of_latest_foreign,
+				column_names, index_error, err_col, err_index, referenced_table, ef);
+
 			mutex_exit(&dict_foreign_err_mutex);
 
-			return(DB_PARENT_NO_INDEX);
+			return(DB_CANNOT_ADD_CONSTRAINT);
 		}
 	} else {
 		ut_a(trx->check_foreigns == FALSE);
@@ -4251,7 +4628,7 @@ try_find_index:
 						       i * sizeof(void*));
 	for (i = 0; i < foreign->n_fields; i++) {
 		foreign->referenced_col_names[i]
-			= mem_heap_strdup(foreign->heap, column_names[i]);
+			= mem_heap_strdup(foreign->heap, ref_column_names[i]);
 	}
 
 	/* We found an ok constraint definition: add to the lists */
@@ -5796,7 +6173,8 @@ dict_table_replace_index_in_foreign_list(
 				foreign->referenced_table,
 				foreign->referenced_col_names,
 				foreign->n_fields, index,
-				/*check_charsets=*/TRUE, /*check_null=*/FALSE);
+				/*check_charsets=*/TRUE, /*check_null=*/FALSE,
+				NULL, NULL, NULL);
 			ut_ad(new_index || !trx->check_foreigns);
 			ut_ad(!new_index || new_index->table == index->table);
 
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 5034e7e..37a029d 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 2000, 2014, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2000, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, 2009 Google Inc.
 Copyright (c) 2009, Percona Inc.
 
@@ -1853,6 +1853,7 @@ check_trx_exists(
 
 	if (trx == NULL) {
 		trx = innobase_trx_allocate(thd);
+		thd_set_ha_data(thd, innodb_hton_ptr, trx);
 	} else if (UNIV_UNLIKELY(trx->magic_n != TRX_MAGIC_N)) {
 		mem_analyze_corruption(trx);
 		ut_error;
@@ -9119,6 +9120,13 @@ ha_innobase::estimate_rows_upper_bound(void)
 	estimate = 2 * local_data_file_length /
 					 dict_index_calc_min_rec_len(index);
 
+        /* Set num_rows less than MERGEBUFF to simulate the case where we do
+        not have enough space to merge the externally sorted file blocks. */
+        DBUG_EXECUTE_IF("set_num_rows_lt_MERGEBUFF",
+                        estimate = 2;
+                        DBUG_SET("-d,set_num_rows_lt_MERGEBUFF");
+                       );
+
 	prebuilt->trx->op_info = (char*)"";
 
 	DBUG_RETURN((ha_rows) estimate);
@@ -9398,17 +9406,6 @@ ha_innobase::info_low(
 			prebuilt->trx->op_info = "returning various info to MySQL";
 		}
 
-		my_snprintf(path, sizeof(path), "%s/%s%s",
-				mysql_data_home, ib_table->name, reg_ext);
-
-		unpack_filename(path,path);
-
-		/* Note that we do not know the access time of the table,
-		nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
-
-		if (os_file_get_status(path,&stat_info)) {
-			stats.create_time = (ulong) stat_info.ctime;
-		}
 	}
 
 	if (flag & HA_STATUS_VARIABLE) {
@@ -9652,6 +9649,20 @@ ha_innobase::info_low(
 		}
 
 		dict_table_stats_unlock(ib_table, RW_S_LATCH);
+
+		my_snprintf(path, sizeof(path), "%s/%s%s",
+			    mysql_data_home,
+			    table->s->normalized_path.str,
+			    reg_ext);
+
+		unpack_filename(path,path);
+
+		/* Note that we do not know the access time of the table,
+		nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
+
+		if (os_file_get_status(path,&stat_info)) {
+			stats.create_time = (ulong) stat_info.ctime;
+		}
 	}
 
 	if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
@@ -14106,3 +14117,28 @@ ha_innobase::idx_cond_push(
 	DBUG_RETURN(NULL);
 }
 
+/********************************************************************//**
+Helper function to push warnings from InnoDB internals to SQL-layer. */
+extern "C" UNIV_INTERN
+void
+ib_push_warning(
+	trx_t*		trx,	/*!< in: trx */
+	ulint		error,	/*!< in: error code to push as warning */
+	const char	*format,/*!< in: warning message */
+	...)
+{
+	va_list args;
+	THD *thd = (THD *)trx->mysql_thd;
+	char *buf;
+#define MAX_BUF_SIZE 4*1024
+
+	va_start(args, format);
+	buf = (char *)my_malloc(MAX_BUF_SIZE, MYF(MY_WME));
+	vsprintf(buf,format, args);
+
+	push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+		convert_error_code_to_mysql(error, 0, thd),
+		buf);
+	my_free(buf);
+	va_end(args);
+}
diff --git a/storage/xtradb/include/dict0crea.h b/storage/xtradb/include/dict0crea.h
index 762ab54..c67910f 100644
--- a/storage/xtradb/include/dict0crea.h
+++ b/storage/xtradb/include/dict0crea.h
@@ -121,6 +121,17 @@ UNIV_INTERN
 ulint
 dict_create_or_check_foreign_constraint_tables(void);
 /*================================================*/
+
+/********************************************************************//**
+Construct foreign key constraint defintion from data dictionary information.
+*/
+UNIV_INTERN
+char*
+dict_foreign_def_get(
+/*=================*/
+	dict_foreign_t*	foreign,/*!< in: foreign */
+	trx_t*		trx);	/*!< in: trx */
+
 /********************************************************************//**
 Adds foreign key definitions to data dictionary tables in the database. We
 look at table->foreign_list, and also generate names to constraints that were
diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h
index ec2ba77..ad0abb8 100644
--- a/storage/xtradb/include/ha_prototypes.h
+++ b/storage/xtradb/include/ha_prototypes.h
@@ -353,5 +353,14 @@ innobase_convert_to_filename_charset(
 	const char*     from,   /* in: identifier to convert */
 	ulint           len);   /* in: length of 'to', in bytes */
 
+/********************************************************************//**
+Helper function to push warnings from InnoDB internals to SQL-layer. */
+UNIV_INTERN
+void
+ib_push_warning(
+	trx_t*		trx,	/*!< in: trx */
+	ulint		error,	/*!< in: error code to push as warning */
+	const char	*format,/*!< in: warning message */
+	...);
 
 #endif
diff --git a/storage/xtradb/include/row0purge.h b/storage/xtradb/include/row0purge.h
index fa9c929..64353bc 100644
--- a/storage/xtradb/include/row0purge.h
+++ b/storage/xtradb/include/row0purge.h
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
+Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -111,6 +111,18 @@ struct purge_node_struct{
 				purge of a row */
 };
 
+#ifdef UNIV_DEBUG
+/***********************************************************//**
+Validate the persisent cursor in the purge node. The purge node has two
+references to the clustered index record - one via the ref member, and the
+other via the persistent cursor.  These two references must match each
+other if the found_clust flag is set.
+ at return true if the persistent cursor is consistent with the ref member.*/
+UNIV_INTERN
+ibool
+row_purge_validate_pcur(purge_node_t* node);
+#endif /* UNIV_DEBUG */
+
 #ifndef UNIV_NONINL
 #include "row0purge.ic"
 #endif
diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h
index 181a58b..3b94247 100644
--- a/storage/xtradb/include/srv0srv.h
+++ b/storage/xtradb/include/srv0srv.h
@@ -270,7 +270,6 @@ extern ulong	srv_ibuf_active_contract;
 extern ulong	srv_ibuf_accel_rate;
 extern ulint	srv_checkpoint_age_target;
 extern ulong	srv_flush_neighbor_pages;
-extern ulint	srv_deprecated_enable_unsafe_group_commit;
 extern ulong	srv_read_ahead;
 extern ulong	srv_adaptive_flushing_method;
 
diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i
index c31a0f2..7c19ceb 100644
--- a/storage/xtradb/include/univ.i
+++ b/storage/xtradb/include/univ.i
@@ -64,10 +64,10 @@ component, i.e. we show M.N.P as M.N */
 	(INNODB_VERSION_MAJOR << 8 | INNODB_VERSION_MINOR)
 
 #ifndef PERCONA_INNODB_VERSION
-#define PERCONA_INNODB_VERSION 37.2
+#define PERCONA_INNODB_VERSION 37.4
 #endif
 
-#define INNODB_VERSION_STR	"5.5.43-MariaDB-" IB_TO_STR(PERCONA_INNODB_VERSION)
+#define INNODB_VERSION_STR	"5.5.45-MariaDB-" IB_TO_STR(PERCONA_INNODB_VERSION)
 
 #define REFMAN "http://dev.mysql.com/doc/refman/"	\
 	IB_TO_STR(MYSQL_MAJOR_VERSION) "."		\
diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c
index e33f086..3cec27f 100644
--- a/storage/xtradb/os/os0file.c
+++ b/storage/xtradb/os/os0file.c
@@ -1,6 +1,6 @@
 /***********************************************************************
 
-Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2009, Percona Inc.
 
 Portions of this file contain modifications contributed and copyrighted
@@ -1376,16 +1376,19 @@ os_file_create_simple_no_error_handling_func(
 #else /* __WIN__ */
 	os_file_t	file;
 	int		create_flag;
+	const char*	mode_str	= NULL;
 
 	ut_a(name);
 
 	if (create_mode == OS_FILE_OPEN) {
+		mode_str = "OPEN";
 		if (access_type == OS_FILE_READ_ONLY) {
 			create_flag = O_RDONLY;
 		} else {
 			create_flag = O_RDWR;
 		}
 	} else if (create_mode == OS_FILE_CREATE) {
+		mode_str = "CREATE";
 		create_flag = O_RDWR | O_CREAT | O_EXCL;
 	} else {
 		create_flag = 0;
@@ -1410,6 +1413,14 @@ os_file_create_simple_no_error_handling_func(
 #endif
 	} else {
 		*success = TRUE;
+
+		/* This function is always called for data files, we should
+		disable OS caching (O_DIRECT) here as we do in
+		os_file_create_func(), so we open the same file in the same
+		mode, see man page of open(2). */
+		if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
+			os_file_set_nocache(file, name, mode_str);
+		}
 	}
 
 	return(file);
diff --git a/storage/xtradb/row/row0purge.c b/storage/xtradb/row/row0purge.c
index efcfdc3..1e87016 100644
--- a/storage/xtradb/row/row0purge.c
+++ b/storage/xtradb/row/row0purge.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1997, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -43,6 +43,7 @@ Created 3/14/1997 Heikki Tuuri
 #include "row0vers.h"
 #include "row0mysql.h"
 #include "log0log.h"
+#include "rem0cmp.h"
 
 /*************************************************************************
 IMPORTANT NOTE: Any operation that generates redo MUST check that there
@@ -80,7 +81,7 @@ row_purge_node_create(
 
 /***********************************************************//**
 Repositions the pcur in the purge node on the clustered index record,
-if found.
+if found. If the record is not found, close pcur.
 @return	TRUE if the record was found */
 static
 ibool
@@ -90,23 +91,28 @@ row_purge_reposition_pcur(
 	purge_node_t*	node,	/*!< in: row purge node */
 	mtr_t*		mtr)	/*!< in: mtr */
 {
-	ibool	found;
-
 	if (node->found_clust) {
-		found = btr_pcur_restore_position(mode, &(node->pcur), mtr);
+		ut_ad(row_purge_validate_pcur(node));
 
-		return(found);
-	}
+		node->found_clust = btr_pcur_restore_position(
+			mode, &(node->pcur), mtr);
+
+	} else {
 
-	found = row_search_on_row_ref(&(node->pcur), mode, node->table,
-				      node->ref, mtr);
-	node->found_clust = found;
+		node->found_clust = row_search_on_row_ref(
+			&(node->pcur), mode, node->table, node->ref, mtr);
 
-	if (found) {
-		btr_pcur_store_position(&(node->pcur), mtr);
+		if (node->found_clust) {
+			btr_pcur_store_position(&(node->pcur), mtr);
+		}
 	}
 
-	return(found);
+	/* Close the current cursor if we fail to position it correctly. */
+	if (!node->found_clust) {
+		btr_pcur_close(&node->pcur);
+	}
+
+	return(node->found_clust);
 }
 
 /***********************************************************//**
@@ -143,8 +149,8 @@ row_purge_remove_clust_if_poss_low(
 
 	if (!success) {
 		/* The record is already removed */
-
-		btr_pcur_commit_specify_mtr(pcur, &mtr);
+		/* Persistent cursor is closed if reposition fails. */
+		mtr_commit(&mtr);
 
 		return(TRUE);
 	}
@@ -258,7 +264,12 @@ row_purge_poss_sec(
 						 btr_pcur_get_rec(&node->pcur),
 						 &mtr, index, entry);
 
-	btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
+	/* Persistent cursor is closed if reposition fails. */
+	if (node->found_clust) {
+		btr_pcur_commit_specify_mtr(&node->pcur, &mtr);
+	} else {
+		mtr_commit(&mtr);
+	}
 
 	return(can_delete);
 }
@@ -806,3 +817,54 @@ row_purge_step(
 
 	return(thr);
 }
+
+#ifdef UNIV_DEBUG
+/***********************************************************//**
+Validate the persisent cursor in the purge node. The purge node has two
+references to the clustered index record - one via the ref member, and the
+other via the persistent cursor.  These two references must match each
+other if the found_clust flag is set.
+ at return true if the stored copy of persistent cursor is consistent
+with the ref member.*/
+UNIV_INTERN
+ibool
+row_purge_validate_pcur(
+	purge_node_t*	node)
+{
+	dict_index_t*	clust_index;
+	ulint*		offsets;
+	int		st;
+
+	if (!node->found_clust) {
+		return(TRUE);
+	}
+
+	if (node->index == NULL) {
+		return(TRUE);
+	}
+
+	if (node->pcur.old_stored != BTR_PCUR_OLD_STORED) {
+		return(TRUE);
+	}
+
+	clust_index = node->pcur.btr_cur.index;
+
+	offsets = rec_get_offsets(node->pcur.old_rec, clust_index, NULL,
+				  node->pcur.old_n_fields, &node->heap);
+
+	/* Here we are comparing the purge ref record and the stored initial
+	part in persistent cursor. Both cases we store n_uniq fields of the
+	cluster index and so it is fine to do the comparison. We note this
+	dependency here as pcur and ref belong to different modules. */
+	st = cmp_dtuple_rec(node->ref, node->pcur.old_rec, offsets);
+
+	if (st != 0) {
+		fprintf(stderr, "Purge node pcur validation failed\n");
+		dtuple_print(stderr, node->ref);
+		rec_print(stderr, node->pcur.old_rec, clust_index);
+		return(FALSE);
+	}
+
+	return(TRUE);
+}
+#endif /* UNIV_DEBUG */
diff --git a/storage/xtradb/srv/srv0srv.c b/storage/xtradb/srv/srv0srv.c
index 55d08ce..5efb5d0 100644
--- a/storage/xtradb/srv/srv0srv.c
+++ b/storage/xtradb/srv/srv0srv.c
@@ -438,7 +438,6 @@ UNIV_INTERN ulong	srv_ibuf_accel_rate = 100;
 UNIV_INTERN ulint	srv_checkpoint_age_target = 0;
 UNIV_INTERN ulong	srv_flush_neighbor_pages = 1; /* 0:disable 1:area 2:contiguous */
 
-UNIV_INTERN ulint	srv_deprecated_enable_unsafe_group_commit = 0;
 UNIV_INTERN ulong	srv_read_ahead = 3; /* 1: random  2: linear  3: Both */
 UNIV_INTERN ulong	srv_adaptive_flushing_method = 0; /* 0: native  1: estimate  2: keep_average */
 
diff --git a/storage/xtradb/srv/srv0start.c b/storage/xtradb/srv/srv0start.c
index 39a6193..e4f4047 100644
--- a/storage/xtradb/srv/srv0start.c
+++ b/storage/xtradb/srv/srv0start.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
 Copyright (c) 2008, Google Inc.
 Copyright (c) 2009, Percona Inc.
 
@@ -2501,9 +2501,9 @@ innobase_shutdown_for_mysql(void)
 
 	ibuf_close();
 	log_shutdown();
-	lock_sys_close();
 	trx_sys_file_format_close();
 	trx_sys_close();
+	lock_sys_close();
 
 	mutex_free(&srv_monitor_file_mutex);
 	mutex_free(&srv_dict_tmpfile_mutex);
diff --git a/storage/xtradb/sync/sync0arr.c b/storage/xtradb/sync/sync0arr.c
index 73cd6ea..3bf5369 100644
--- a/storage/xtradb/sync/sync0arr.c
+++ b/storage/xtradb/sync/sync0arr.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
 Copyright (c) 2008, Google Inc.
 Copyright (c) 2013, 2014, MariaDB Corporation. All Rights Reserved.
 
@@ -1114,8 +1114,9 @@ sync_array_output_info(
 	os_thread_id_t  r;
 
 	fprintf(file,
-		"OS WAIT ARRAY INFO: reservation count %ld, signal count %ld\n",
-						(long) arr->res_count, (long) arr->sg_count);
+		"OS WAIT ARRAY INFO: reservation count " ULINTPF
+		", signal count " ULINTPF "\n",
+		arr->res_count, arr->sg_count);
 	i = 0;
 	count = 0;
 
diff --git a/storage/xtradb/trx/trx0trx.c b/storage/xtradb/trx/trx0trx.c
index bc51150..11b0de4 100644
--- a/storage/xtradb/trx/trx0trx.c
+++ b/storage/xtradb/trx/trx0trx.c
@@ -768,9 +768,9 @@ trx_lists_init_at_db_start(void)
 								" anyway.\n");
 
 							trx->state = TRX_ACTIVE;
-							trx_reserve_descriptor(
-								trx);
 						}
+
+						trx_reserve_descriptor(trx);
 					} else {
 						trx->state
 							= TRX_COMMITTED_IN_MEMORY;
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index aaeed44..5af4783 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -635,7 +635,7 @@ install -m 644 "%{malloc_lib_source}" \
 # Check local settings to support them.
 if [ -x %{_bindir}/my_print_defaults ]
 then
-  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | tail -1 | sed -n 's/--datadir=//p'`
   PID_FILE_PATT=`%{_bindir}/my_print_defaults server mysqld | grep '^--pid-file=' | sed -n 's/--pid-file=//p'`
 fi
 if [ -z "$mysql_datadir" ]
@@ -740,7 +740,7 @@ esac
 
 STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER
 
-if [ -f $STATUS_FILE ]; then
+if [ -f "$STATUS_FILE" ]; then
 	echo "Some previous upgrade was not finished:"
 	ls -ld $STATUS_FILE
 	echo "Please check its status, then do"
@@ -811,7 +811,7 @@ fi
 # Check local settings to support them.
 if [ -x %{_bindir}/my_print_defaults ]
 then
-  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | tail -1 | sed -n 's/--datadir=//p'`
 fi
 if [ -z "$mysql_datadir" ]
 then
@@ -824,8 +824,8 @@ STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER
 # ----------------------------------------------------------------------
 # Create data directory if needed, check whether upgrade or install
 # ----------------------------------------------------------------------
-if [ ! -d $mysql_datadir ] ; then mkdir -m 755 $mysql_datadir; fi
-if [ -f $STATUS_FILE ] ; then
+if [ ! -d "$mysql_datadir" ] ; then mkdir -m 755 "$mysql_datadir" ; fi
+if [ -f "$STATUS_FILE" ] ; then
 	SERVER_TO_START=`grep '^SERVER_TO_START=' $STATUS_FILE | cut -c17-`
 else
 	SERVER_TO_START=''
@@ -1003,7 +1003,7 @@ fi
 # Check local settings to support them.
 if [ -x %{_bindir}/my_print_defaults ]
 then
-  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
+  mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | tail -1 | sed -n 's/--datadir=//p'`
 fi
 if [ -z "$mysql_datadir" ]
 then
@@ -1014,7 +1014,7 @@ NEW_VERSION=%{mysql_version}-%{release}
 STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER-LAST  # Note the difference!
 STATUS_HISTORY=$mysql_datadir/RPM_UPGRADE_HISTORY
 
-if [ -f $STATUS_FILE ] ; then
+if [ -f "$STATUS_FILE" ] ; then
 	SERVER_TO_START=`grep '^SERVER_TO_START=' $STATUS_FILE | cut -c17-`
 else
 	# This should never happen, but let's be prepared
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 78916f8..c889b90 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -21,31 +21,42 @@
 static my_bool     ssl_algorithms_added    = FALSE;
 static my_bool     ssl_error_strings_loaded= FALSE;
 
-/* the function below was generated with "openssl dhparam -2 -C 1024" */
+/* the function below was generated with "openssl dhparam -2 -C 2048" */
 static
-DH *get_dh1024()
+DH *get_dh2048()
 {
-  static unsigned char dh1024_p[]={
-    0xEC,0x46,0x7E,0xF9,0x4E,0x10,0x29,0xDC,0x44,0x97,0x71,0xFD,
-    0x71,0xC6,0x9F,0x0D,0xD1,0x09,0xF6,0x58,0x6F,0xAD,0xCA,0xF4,
-    0x37,0xD5,0xC3,0xBD,0xC3,0x9A,0x51,0x66,0x2C,0x58,0xBD,0x02,
-    0xBD,0xBA,0xBA,0xFC,0xE7,0x0E,0x5A,0xE5,0x97,0x81,0xC3,0xF3,
-    0x28,0x2D,0xAD,0x00,0x91,0xEF,0xF8,0xF0,0x5D,0xE9,0xE7,0x18,
-    0xE2,0xAD,0xC4,0x70,0xC5,0x3C,0x12,0x8A,0x80,0x6A,0x9F,0x3B,
-    0x00,0xA2,0x8F,0xA9,0x26,0xB0,0x0E,0x7F,0xED,0xF6,0xC2,0x03,
-    0x81,0xB5,0xC5,0x41,0xD0,0x00,0x2B,0x21,0xD4,0x4B,0x74,0xA6,
-    0xD7,0x1A,0x0E,0x82,0xC8,0xEE,0xD4,0xB1,0x6F,0xB4,0x79,0x01,
-    0x8A,0xF1,0x12,0xD7,0x3C,0xFD,0xCB,0x9B,0xAE,0x1C,0xA9,0x0F,
-    0x3D,0x0F,0xF8,0xD6,0x7D,0xDE,0xD6,0x0B,
+  static unsigned char dh2048_p[]={
+    0xA1,0xBB,0x7C,0x20,0xC5,0x5B,0xC0,0x7B,0x21,0x8B,0xD6,0xA8,
+    0x15,0xFC,0x3B,0xBA,0xAB,0x9F,0xDF,0x68,0xC4,0x79,0x78,0x0D,
+    0xC1,0x12,0x64,0xE4,0x15,0xC9,0x66,0xDB,0xF6,0xCB,0xB3,0x39,
+    0x02,0x5B,0x78,0x62,0xFB,0x09,0xAE,0x09,0x6B,0xDD,0xD4,0x5D,
+    0x97,0xBC,0xDC,0x7F,0xE6,0xD6,0xF1,0xCB,0xF5,0xEB,0xDA,0xA7,
+    0x2E,0x5A,0x43,0x2B,0xE9,0x40,0xE2,0x85,0x00,0x1C,0xC0,0x0A,
+    0x98,0x77,0xA9,0x31,0xDE,0x0B,0x75,0x4D,0x1E,0x1F,0x16,0x83,
+    0xCA,0xDE,0xBD,0x21,0xFC,0xC1,0x82,0x37,0x36,0x33,0x0B,0x66,
+    0x06,0x3C,0xF3,0xAF,0x21,0x57,0x57,0x80,0xF6,0x94,0x1B,0xA9,
+    0xD4,0xF6,0x8F,0x18,0x62,0x0E,0xC4,0x22,0xF9,0x5B,0x62,0xCC,
+    0x3F,0x19,0x95,0xCF,0x4B,0x00,0xA6,0x6C,0x0B,0xAF,0x9F,0xD5,
+    0xFA,0x3D,0x6D,0xDA,0x30,0x83,0x07,0x91,0xAC,0x15,0xFF,0x8F,
+    0x59,0x54,0xEA,0x25,0xBC,0x4E,0xEB,0x6A,0x54,0xDF,0x75,0x09,
+    0x72,0x0F,0xEF,0x23,0x70,0xE0,0xA8,0x04,0xEA,0xFF,0x90,0x54,
+    0xCD,0x84,0x18,0xC0,0x75,0x91,0x99,0x0F,0xA1,0x78,0x0C,0x07,
+    0xB7,0xC5,0xDE,0x55,0x06,0x7B,0x95,0x68,0x2C,0x33,0x39,0xBC,
+    0x2C,0xD0,0x6D,0xDD,0xFA,0xDC,0xB5,0x8F,0x82,0x39,0xF8,0x67,
+    0x44,0xF1,0xD8,0xF7,0x78,0x11,0x9A,0x77,0x9B,0x53,0x47,0xD6,
+    0x2B,0x5D,0x67,0xB8,0xB7,0xBC,0xC1,0xD7,0x79,0x62,0x15,0xC2,
+    0xC5,0x83,0x97,0xA7,0xF8,0xB4,0x9C,0xF6,0x8F,0x9A,0xC7,0xDA,
+    0x1B,0xBB,0x87,0x07,0xA7,0x71,0xAD,0xB2,0x8A,0x50,0xF8,0x26,
+    0x12,0xB7,0x3E,0x0B,
   };
-  static unsigned char dh1024_g[]={
+  static unsigned char dh2048_g[]={
     0x02,
   };
   DH *dh;
 
   if ((dh=DH_new()) == NULL) return(NULL);
-  dh->p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),NULL);
-  dh->g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),NULL);
+  dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL);
+  dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL);
   if ((dh->p == NULL) || (dh->g == NULL))
   { DH_free(dh); return(NULL); }
   return(dh);
@@ -259,7 +270,7 @@ new_VioSSLFd(const char *key_file, const char *cert_file,
   }
 
   /* DH stuff */
-  dh=get_dh1024();
+  dh=get_dh2048();
   SSL_CTX_set_tmp_dh(ssl_fd->ssl_context, dh);
   DH_free(dh);
 
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp
index 17bfca1..3cb8520 100644
--- a/win/packaging/ca/CustomAction.cpp
+++ b/win/packaging/ca/CustomAction.cpp
@@ -17,6 +17,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 #define UNICODE
 #endif
 
+#undef NOMINMAX
+
 #include <winsock2.h>
 #include <windows.h>
 #include <winreg.h>

-- 
Alioth's hooks/post-receive on /srv/git.debian.org/git/pkg-mysql/mariadb-5.5.git



More information about the Pkg-mysql-commits mailing list