[Commits] 8cbb14ef5d1: Merge branch '10.1' into 10.2

Oleksandr Byelkin sanja at mariadb.com
Sat May 4 18:05:07 EEST 2019


revision-id: 8cbb14ef5d180687f131bc44a4e8fc84083d033c (mariadb-10.2.23-113-g8cbb14ef5d1)
parent(s): 4345868382ca3525de5eb432302b6b9b957b47c1 b85aa20065504bdda4bc03c2bd7eb7de38865c5d
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2019-05-04 17:04:55 +0200
message:

Merge branch '10.1' into 10.2


 client/mysql_plugin.c                              |   8 +-
 client/mysqldump.c                                 |  63 +++++-----
 debian/autobake-deb.sh                             |   3 +-
 ...41_scripts__mysql_install_db.sh__no_test.dpatch |  21 ++--
 include/my_tree.h                                  |   2 +-
 mysql-test/include/ctype_like_escape.inc           |   6 +
 mysql-test/lib/generate-ssl-certs.sh               |   2 +-
 mysql-test/mysql-test-run.pl                       |   4 +
 mysql-test/r/create_drop_binlog.result             |   4 +
 mysql-test/r/create_drop_event.result              |   5 +
 mysql-test/r/ctype_big5.result                     |  12 ++
 mysql-test/r/ctype_euckr.result                    |  12 ++
 mysql-test/r/ctype_gb2312.result                   |  12 ++
 mysql-test/r/ctype_gbk.result                      |  12 ++
 mysql-test/r/ctype_latin1.result                   |  12 ++
 mysql-test/r/ctype_sjis.result                     |  12 ++
 mysql-test/r/ctype_tis620.result                   |  12 ++
 mysql-test/r/ctype_uca.result                      |   6 +
 mysql-test/r/ctype_ucs.result                      |  12 ++
 mysql-test/r/ctype_ujis.result                     |  12 ++
 mysql-test/r/ctype_utf16.result                    |  12 ++
 mysql-test/r/ctype_utf16_uca.result                |   6 +
 mysql-test/r/ctype_utf16le.result                  |  12 ++
 mysql-test/r/ctype_utf32.result                    |  12 ++
 mysql-test/r/ctype_utf32_uca.result                |   6 +
 mysql-test/r/ctype_utf8.result                     |  12 ++
 mysql-test/r/ctype_utf8mb4.result                  |  12 ++
 mysql-test/r/ctype_utf8mb4_heap.result             |  12 ++
 mysql-test/r/ctype_utf8mb4_innodb.result           |  12 ++
 mysql-test/r/ctype_utf8mb4_myisam.result           |  12 ++
 mysql-test/r/ddl_i18n_koi8r.result                 |   8 ++
 mysql-test/r/ddl_i18n_utf8.result                  |   8 ++
 mysql-test/r/events_1.result                       |  68 +++++++++++
 mysql-test/r/events_2.result                       |  30 +++++
 mysql-test/r/events_bugs.result                    |  54 ++++++++
 mysql-test/r/events_grant.result                   |  10 ++
 mysql-test/r/events_restart.result                 |  26 ++--
 mysql-test/r/events_trans.result                   |   9 ++
 mysql-test/r/flush_read_lock.result                |   2 +
 mysql-test/r/func_gconcat.result                   |  30 ++++-
 mysql-test/r/func_hybrid_type.result               |  40 +++++-
 mysql-test/r/func_str.result                       |  38 ++++++
 mysql-test/r/gis.result                            |  38 ++++++
 mysql-test/r/gis2.result                           |  38 ------
 mysql-test/r/gis_notembedded.result                |  45 +++++++
 mysql-test/r/grant4.result                         |  21 ++++
 mysql-test/r/information_schema_prepare.result     |   4 +
 mysql-test/r/lock_sync.result                      |   4 +
 mysql-test/r/mdev_19276.result                     |  11 ++
 mysql-test/r/multi_update.result                   |  23 ++++
 ...ulti_update2.result => multi_update_big.result} |   0
 mysql-test/r/mysqldump-compat.result               |   4 +
 mysql-test/r/mysqldump.result                      |  16 +++
 mysql-test/r/partition_innodb.result               |  42 +++++++
 mysql-test/r/ps.result                             |  23 ++++
 mysql-test/r/show_check.result                     |   4 +
 mysql-test/r/sp_notembedded.result                 |   2 +
 mysql-test/r/ssl_verify_ip.result                  |   4 +
 mysql-test/r/stat_tables.result                    |  18 +++
 mysql-test/r/stat_tables_innodb.result             |  18 +++
 mysql-test/r/statistics.result                     |  14 +++
 mysql-test/r/status2.result                        |   4 +-
 mysql-test/r/timezone2.result                      |  33 +++++
 mysql-test/r/type_bit.result                       |   7 ++
 mysql-test/r/view_grant.result                     |   4 +
 mysql-test/std_data/serversan-cert.pem             | 110 ++++++++---------
 mysql-test/std_data/serversan-key.pem              |  52 ++++----
 mysql-test/suite.pm                                |   5 +
 mysql-test/suite/binlog/r/binlog_mdev717.result    |   2 +
 mysql-test/suite/binlog/r/binlog_sql_mode.result   |   2 +
 .../suite/funcs_1/r/is_routines_embedded.result    |  12 ++
 mysql-test/suite/galera/r/galera_events.result     |   2 +
 mysql-test/suite/innodb/r/innodb-index.result      |  27 ++++
 mysql-test/suite/innodb/r/innodb-truncate.result   |  13 ++
 mysql-test/suite/innodb/r/xa_debug.result          |   1 +
 mysql-test/suite/innodb/t/innodb-index.test        |  20 +++
 mysql-test/suite/innodb/t/innodb-truncate.test     |  19 +++
 mysql-test/suite/innodb/t/xa_debug.test            |   1 +
 .../suite/perfschema/r/pfs_upgrade_event.result    |   2 +
 mysql-test/suite/plugins/r/pam.result              |  20 +++
 mysql-test/suite/plugins/t/pam.test                |  24 +++-
 mysql-test/suite/rpl/r/kill_race_condition.result  |  18 +++
 .../suite/rpl/r/rpl_create_drop_event.result       |   4 +
 mysql-test/suite/rpl/r/rpl_current_user.result     |   2 +
 mysql-test/suite/rpl/r/rpl_events.result           |   6 +
 mysql-test/suite/rpl/r/rpl_heartbeat_basic.result  |   2 +
 mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result |   2 +
 mysql-test/suite/rpl/r/rpl_invoked_features.result |   4 +
 mysql-test/suite/rpl/r/rpl_killed_ddl.result       |   2 +
 .../rpl/r/rpl_mixed_implicit_commit_binlog.result  |   2 +
 .../rpl/r/rpl_row_implicit_commit_binlog.result    |   2 +
 .../rpl/r/rpl_stm_implicit_commit_binlog.result    |   2 +
 .../suite/rpl/r/rpl_tmp_table_and_DDL.result       |   4 +
 mysql-test/suite/rpl/t/kill_race_condition.test    |  28 +++++
 .../r/sysvars_innodb,32bit,xtradb.rdiff-disabled   |   4 +-
 .../r/sysvars_innodb,xtradb.rdiff-disabled         |   4 +-
 .../t/transaction_prealloc_size_bug27322.test      |   9 +-
 mysql-test/t/bootstrap.test                        |   9 ++
 mysql-test/t/events_stress.test                    |   1 +
 mysql-test/t/func_gconcat.test                     |  33 ++++-
 mysql-test/t/func_hybrid_type.test                 |  20 +++
 mysql-test/t/func_str.test                         |  36 ++++++
 mysql-test/t/gis.test                              |  47 +++++++
 mysql-test/t/gis2.test                             |  45 -------
 mysql-test/t/gis_notembedded.test                  |  24 ++++
 mysql-test/t/grant4.test                           |  31 ++++-
 mysql-test/t/information_schema_prepare.test       |   7 ++
 mysql-test/t/mdev_19276.test                       |  17 +++
 mysql-test/t/multi_update.test                     |  31 +++++
 ...lti_update2-master.opt => multi_update_big.opt} |   0
 .../{multi_update2.test => multi_update_big.test}  |   0
 mysql-test/t/mysqldump-compat.test                 |  13 ++
 mysql-test/t/partition_innodb.test                 |  25 ++++
 mysql-test/t/ps.test                               |  16 +++
 mysql-test/t/ssl_verify_ip.opt                     |   3 +
 mysql-test/t/ssl_verify_ip.test                    |   3 +
 mysql-test/t/stat_tables.test                      |  21 ++++
 mysql-test/t/statistics.test                       |  15 +++
 mysql-test/t/status2.test                          |   4 +-
 mysql-test/t/timezone2.test                        |  31 +++++
 mysql-test/t/type_bit.test                         |   9 ++
 mysql-test/t/view_grant.test                       |   5 +
 mysys/tree.c                                       |  48 ++++----
 pcre/AUTHORS                                       |   6 +-
 pcre/ChangeLog                                     |  43 +++++++
 pcre/LICENCE                                       |  10 +-
 pcre/NEWS                                          |  10 ++
 pcre/configure.ac                                  |  10 +-
 pcre/pcre_compile.c                                |  18 ++-
 pcre/pcre_jit_compile.c                            |   2 +-
 pcre/pcrecpp.cc                                    |  64 +++++++++-
 pcre/pcrecpp_unittest.cc                           |  34 +++++-
 pcre/pcregrep.c                                    |   4 +-
 pcre/testdata/testinput1                           |  15 +++
 pcre/testdata/testinput2                           |   3 +
 pcre/testdata/testinput4                           |   3 +
 pcre/testdata/testoutput1                          |  24 ++++
 pcre/testdata/testoutput2                          |   4 +
 pcre/testdata/testoutput4                          |   4 +
 plugin/auth_pam/auth_pam.c                         |  10 +-
 scripts/maria_add_gis_sp.sql.in                    |   4 +-
 scripts/mysql_install_db.sh                        |   8 +-
 sql-common/client.c                                |   6 +-
 sql/events.cc                                      |   6 +
 sql/field.cc                                       |   2 +-
 sql/gen_win_tzname_data.ps1                        |  11 ++
 sql/ha_partition.cc                                |  11 +-
 sql/handler.h                                      |   5 +-
 sql/item_func.cc                                   |   6 +-
 sql/item_sum.cc                                    |  93 +++++++++++++-
 sql/item_sum.h                                     |   9 +-
 sql/log_event.cc                                   |  23 ++--
 sql/log_event_old.cc                               |  19 ++-
 sql/mysqld.cc                                      |  48 ++++++--
 sql/share/errmsg-utf8.txt                          |   4 +-
 sql/sql_acl.cc                                     |  33 ++++-
 sql/sql_base.cc                                    |  95 +++++++-------
 sql/sql_base.h                                     |  17 ++-
 sql/sql_class.cc                                   |   1 +
 sql/sql_class.h                                    |   1 +
 sql/sql_db.cc                                      |  20 +--
 sql/sql_db.h                                       |   2 +-
 sql/sql_lex.h                                      |   4 +-
 sql/sql_parse.cc                                   |  16 ++-
 sql/sql_select.cc                                  |  18 +--
 sql/sql_show.cc                                    |  10 +-
 sql/sql_statistics.cc                              |  20 ++-
 sql/sql_string.cc                                  |  21 ++++
 sql/sql_truncate.cc                                |  14 +--
 sql/sql_update.cc                                  |  36 +++++-
 sql/sql_view.cc                                    |   3 +-
 sql/sql_yacc.yy                                    |  37 +++---
 sql/table.cc                                       |   3 +-
 sql/table.h                                        |   1 +
 sql/win_tzname_data.h                              | 136 +++++++++++++++++++++
 storage/connect/filter.h                           |   1 +
 storage/connect/ha_connect.cc                      |  81 ++++++------
 storage/connect/ha_connect.h                       |   3 +-
 storage/connect/jmgoconn.cpp                       |   4 +-
 storage/connect/tabdos.cpp                         |  42 ++++---
 storage/connect/tabfmt.cpp                         |  13 +-
 storage/connect/user_connect.cc                    |   3 +-
 storage/connect/value.cpp                          |  97 +++++++--------
 storage/connect/value.h                            |  16 +--
 storage/innobase/dict/dict0stats.cc                |   4 +-
 storage/innobase/handler/handler0alter.cc          |  21 +++-
 storage/innobase/include/handler0alter.h           |  11 +-
 storage/tokudb/.clang-format                       |  40 ++++++
 storage/tokudb/ha_tokudb.cc                        |  28 +++--
 storage/tokudb/ha_tokudb.h                         |   2 +-
 storage/tokudb/ha_tokudb_mrr_mysql.cc              |   1 +
 .../mysql-test/rpl/r/rpl_tokudb_mixed_dml.result   |   2 +
 .../tokudb/mysql-test/tokudb_bugs/r/PS-5158.result |   6 +
 .../tokudb/mysql-test/tokudb_bugs/r/PS-5163.result |   5 +
 .../mysql-test/tokudb_bugs/t/PS-5158-master.opt    |   2 +
 .../tokudb/mysql-test/tokudb_bugs/t/PS-5158.test   |  27 ++++
 .../tokudb/mysql-test/tokudb_bugs/t/PS-5163.test   |  11 ++
 storage/xtradb/dict/dict0stats.cc                  |   5 +-
 storage/xtradb/handler/ha_innodb.cc                |   4 +-
 storage/xtradb/handler/handler0alter.cc            |  21 +++-
 storage/xtradb/include/handler0alter.h             |  11 +-
 storage/xtradb/include/univ.i                      |   4 +-
 support-files/rpm/server-postin.sh                 |   7 +-
 support-files/rpm/server-posttrans.sh              |   7 +-
 support-files/rpm/server-preun.sh                  |  18 +--
 205 files changed, 2788 insertions(+), 657 deletions(-)

diff --cc debian/autobake-deb.sh
index 1a43c064468,98071ba6d03..687f2356153
--- a/debian/autobake-deb.sh
+++ b/debian/autobake-deb.sh
@@@ -6,137 -7,71 +6,138 @@@
  # Exit immediately on any error
  set -e
  
 -# Debug script and command lines
 -#set -x
 -
 -# Don't run the mysql-test-run test suite as part of build.
 +# On Buildbot, don't run the mysql-test-run test suite as part of build.
  # It takes a lot of time, and we will do a better test anyway in
  # Buildbot, running the test suite from installed .debs on a clean VM.
 -export DEB_BUILD_OPTIONS="nocheck"
 +# On Travis-CI we want to simulate the full build, including tests.
 +# Also on Travis-CI it is useful not to override the DEB_BUILD_OPTIONS
 +# at this stage at all.
 +if [[ ! $TRAVIS ]]
 +then
 +  export DEB_BUILD_OPTIONS="nocheck"
 +fi
  
 -export MARIADB_OPTIONAL_DEBS=""
 +# Travis-CI optimizations
 +if [[ $TRAVIS ]]
 +then
 +  # On Travis-CI, the log must stay under 4MB so make the build less verbose
 +  sed -i -e '/Add support for verbose builds/,+2d' debian/rules
 +
 +  # Don't include test suite package on Travis-CI to make the build time shorter
 +  sed '/Package: mariadb-test-data/,/^$/d' -i debian/control
 +  sed '/Package: mariadb-test/,/^$/d' -i debian/control
 +fi
  
 -# Find major.minor version.
 +
 +# Look up distro-version specific stuff
  #
 -source ./VERSION
 -UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}"
 -RELEASE_EXTRA=""
 +# Always keep the actual packaging as up-to-date as possible following the latest
 +# Debian policy and targetting Debian Sid. Then case-by-case run in autobake-deb.sh
 +# tests for backwards compatibility and strip away parts on older builders.
  
 -RELEASE_NAME=""
 -PATCHLEVEL="+maria"
 -LOGSTRING="MariaDB build"
 +# If iproute2 is not available (before Debian Jessie and Ubuntu Trusty)
 +# fall back to the old iproute package.
 +if ! apt-cache madison iproute2 | grep 'iproute2 *|' >/dev/null 2>&1
 +then
 + sed 's/iproute2/iproute/' -i debian/control
 +fi
  
 -# Look up distro-version specific stuff.
 +# If libcrack2 (>= 2.9.0) is not available (before Debian Jessie and Ubuntu Trusty)
 +# clean away the cracklib stanzas so the package can build without them.
 +if ! apt-cache madison libcrack2-dev | grep 'libcrack2-dev *| *2\.9' >/dev/null 2>&1
 +then
 +  sed '/libcrack2-dev/d' -i debian/control
 +  sed '/Package: mariadb-plugin-cracklib/,/^$/d' -i debian/control
 +fi
  
 -CODENAME="$(lsb_release -sc)"
 -VERNUM="$(lsb_release -sr)"
 +# If libpcre3-dev (>= 2:8.35-3.2~) is not available (before Debian Jessie or Ubuntu Wily)
 +# clean away the PCRE3 stanzas so the package can build without them.
 +# Update check when version 2:8.40 or newer is available.
 +if ! apt-cache madison libpcre3-dev | grep 'libpcre3-dev *| *2:8\.3[2-9]' >/dev/null 2>&1
 +then
 +  sed '/libpcre3-dev/d' -i debian/control
 +fi
  
 -# add libcrack2 (>= 2.9.0) as a build dependency
 -# but only where the distribution can possibly satisfy it
 -if apt-cache madison cracklib2|grep 'cracklib2 *| *2\.[0-8]\.' >/dev/null 2>&1
 +# If libsystemd-dev is not available (before Debian Jessie or Ubuntu Wily)
 +# clean away the systemd stanzas so the package can build without them.
 +if ! apt-cache madison libsystemd-dev | grep 'libsystemd-dev' >/dev/null 2>&1
  then
 -  # Anything in MARIADB_OPTIONAL_DEBS is omitted from the resulting
 -  # packages by snipped in rules file
 -  MARIADB_OPTIONAL_DEBS="${MARIADB_OPTIONAL_DEBS} cracklib-password-check-10.1"
 -  sed -i -e "/\\\${MAYBE_LIBCRACK}/d" debian/control
 -else
 -  MAYBE_LIBCRACK='libcrack2-dev (>= 2.9.0),'
 -  sed -i -e "s/\\\${MAYBE_LIBCRACK}/${MAYBE_LIBCRACK}/g" debian/control
 +  sed '/dh-systemd/d' -i debian/control
 +  sed '/libsystemd-dev/d' -i debian/control
 +  sed 's/ --with systemd//' -i debian/rules
 +  sed '/systemd/d' -i debian/rules
 +  sed '/\.service/d' -i debian/rules
 +  sed '/galera_new_cluster/d' -i debian/mariadb-server-10.2.install
 +  sed '/galera_recovery/d' -i debian/mariadb-server-10.2.install
 +  sed '/mariadb-service-convert/d' -i debian/mariadb-server-10.2.install
  fi
  
 -# same for OpenSSL. Use the correct dependency
 -if apt-cache madison libssl-dev|grep 'libssl-dev  *| *1\.1\.' >/dev/null 2>&1
 +# Convert gcc version to numberical value. Format is Mmmpp where M is Major
 +# version, mm is minor version and p is patch.
 +# -dumpfullversion & -dumpversion to make it uniform across old and new (>=7)
 +GCCVERSION=$(gcc -dumpfullversion -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' \
 +                                                     -e 's/\.\([0-9]\)/0\1/g'     \
 +						     -e 's/^[0-9]\{3,4\}$/&00/')
 +# Don't build rocksdb package if gcc version is less than 4.8 or we are running on
 +# x86 32 bit.
 +if [[ $GCCVERSION -lt 40800 ]] || [[ $(arch) =~ i[346]86 ]]
  then
 -  LIBSSL='libssl1.0-dev'
 -else
 -  LIBSSL='libssl-dev'
 +  sed '/Package: mariadb-plugin-rocksdb/,/^$/d' -i debian/control
  fi
 -sed -i -e "s/\\\${LIBSSL}/${LIBSSL}/g" debian/control
  
 -# Adjust changelog, add new version.
 -#
 +# Always remove aws plugin, see -DNOT_FOR_DISTRIBUTION in CMakeLists.txt
 +sed '/Package: mariadb-plugin-aws-key-management-10.2/,/^$/d' -i debian/control
 +
 +# Don't build cassandra package if thrift is not installed
 +if [[ ! -f /usr/local/include/thrift/Thrift.h && ! -f /usr/include/thrift/Thrift.h ]]
 +then
 +  sed '/Package: mariadb-plugin-cassandra/,/^$/d' -i debian/control
 +fi
 +
 +# Adjust changelog, add new version
  echo "Incrementing changelog and starting build scripts"
  
 +# Find major.minor version
 +source ./VERSION
 +UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}"
 +PATCHLEVEL="+maria"
 +LOGSTRING="MariaDB build"
 +CODENAME="$(lsb_release -sc)"
- if [[ "$CODENAME" == bionic ]]; then
++VERNUM="$(lsb_release -sr)"
+ if [[ "${VERNUM%.*}" -ge 18 ]]; then
    EPOCH="1:"
  fi
 -dch -b -D ${CODENAME} -v "${EPOCH}${UPSTREAM}${PATCHLEVEL}-${RELEASE_NAME}${RELEASE_EXTRA:+-${RELEASE_EXTRA}}1~${CODENAME}" "Automatic build with ${LOGSTRING}."
  
 -echo "Creating package version ${EPOCH}${UPSTREAM}${PATCHLEVEL}-${RELEASE_NAME}${RELEASE_EXTRA:+-${RELEASE_EXTRA}}1~${CODENAME} ... "
 +dch -b -D ${CODENAME} -v "${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME}" "Automatic build with ${LOGSTRING}."
 +
 +echo "Creating package version ${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME} ... "
 +
 +# On Travis CI, use -b to build binary only packages as there is no need to
 +# waste time on generating the source package.
 +if [[ $TRAVIS ]]
 +then
 +  BUILDPACKAGE_FLAGS="-b"
 +fi
  
 -# Build the package.
 +# Build the package
  # Pass -I so that .git and other unnecessary temporary and source control files
 -# will be ignored by dpkg-source when createing the tar.gz source package
 -fakeroot dpkg-buildpackage -us -uc -I
 +# will be ignored by dpkg-source when creating the tar.gz source package.
 +fakeroot dpkg-buildpackage -us -uc -I $BUILDPACKAGE_FLAGS
  
 -[ -e debian/autorm-file ] && rm -vf `cat debian/autorm-file`
 +# If the step above fails due to missing dependencies, you can manually run
 +#   sudo mk-build-deps debian/control -r -i
  
 -echo "Build complete"
 +# Don't log package contents on Travis-CI to save time and log size
 +if [[ ! $TRAVIS ]]
 +then
 +  echo "List package contents ..."
 +  cd ..
 +  for package in `ls *.deb`
 +  do
 +    echo $package | cut -d '_' -f 1
 +    dpkg-deb -c $package | awk '{print $1 " " $2 " " $6}' | sort -k 3
 +    echo "------------------------------------------------"
 +  done
 +fi
  
 -# end of autobake script
 +echo "Build complete"
diff --cc mysql-test/lib/generate-ssl-certs.sh
index 0894be3a299,4b333854c08..7df1c2d8279
--- a/mysql-test/lib/generate-ssl-certs.sh
+++ b/mysql-test/lib/generate-ssl-certs.sh
@@@ -34,25 -31,9 +34,25 @@@ openssl ca -keyfile cakey.pem -days 730
  
  # with SubjectAltName, only for OpenSSL 1.0.2+
  cat > demoCA/sanext.conf <<EOF
- subjectAltName=DNS:localhost
+ subjectAltName=IP:127.0.0.1, DNS:localhost
  EOF
 -openssl req -newkey rsa:1024 -keyout serversan-key.pem -out demoCA/serversan-req.pem -days 7300 -nodes -subj '/CN=server/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
 -openssl ca -keyfile cakey.pem -extfile demoCA/sanext.conf -days 7300 -batch -cert cacert.pem -policy policy_anything -out serversan-cert.pem -infiles demoCA/serversan-req.pem
 +openssl req -newkey rsa:2048 -keyout serversan-key.pem -out demoCA/serversan-req.pem -days 7300 -nodes -subj '/CN=server/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
 +openssl ca -keyfile cakey.pem -extfile demoCA/sanext.conf -days 7300 -batch -cert cacert.pem -policy policy_anything -out serversan-cert.pem -in demoCA/serversan-req.pem
 +
 +# client cert
 +openssl req -newkey rsa:2048 -keyout client-key.pem -out demoCA/client-req.pem -days 7300 -nodes -subj '/CN=client/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'
 +openssl rsa -in client-key.pem -out client-key.pem
 +openssl ca -keyfile cakey.pem -days 7300 -batch -cert cacert.pem -policy policy_anything -out client-cert.pem -in demoCA/client-req.pem
 +
 +# generate crls
 +openssl ca -revoke server-cert.pem -keyfile cakey.pem -batch -cert cacert.pem
 +openssl ca -gencrl -keyfile cakey.pem -crldays 7300 -batch -cert cacert.pem -out server-cert.crl
 +# we only want to have one certificate per CRL. Un-revoke server-cert.crl
 +cp demoCA/index.txt.old demoCA/index.txt
 +openssl ca -revoke client-cert.pem -keyfile cakey.pem -batch -cert cacert.pem
 +openssl ca -gencrl -keyfile cakey.pem -crldays 7300 -batch -cert cacert.pem -out client-cert.crl
 +
 +rm -fv crldir/*
 +cp -v client-cert.crl crldir/`openssl x509 -in client-cert.pem -noout -issuer_hash`.r0
  
  rm -rf demoCA
diff --cc mysql-test/r/ctype_latin1.result
index db4054401d2,db9ce63fb78..d17323fb827
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@@ -636,21 -627,12 +642,27 @@@ select c1 as c2h from t1 where c1 like 
  c2h
  ab_def
  drop table t1;
+ SELECT @@collation_connection;
+ @@collation_connection
+ latin1_bin
+ SELECT '\%b' LIKE '%\%';
+ '\%b' LIKE '%\%'
+ 0
 +SELECT strcmp('a','a '),   strcmp('a ','a');
 +strcmp('a','a ')	strcmp('a ','a')
 +0	0
 +SELECT strcmp('a\0','a' ), strcmp('a','a\0');
 +strcmp('a\0','a' )	strcmp('a','a\0')
 +-1	1
 +SELECT strcmp('a\0','a '), strcmp('a ','a\0');
 +strcmp('a\0','a ')	strcmp('a ','a\0')
 +-1	1
 +SELECT strcmp('a\t','a' ), strcmp('a', 'a\t');
 +strcmp('a\t','a' )	strcmp('a', 'a\t')
 +-1	1
 +SELECT strcmp('a\t','a '), strcmp('a ', 'a\t');
 +strcmp('a\t','a ')	strcmp('a ', 'a\t')
 +-1	1
  CREATE TABLE „a (a int);
  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 '„a (a int)' at line 1
  SELECT '„a' as str;
diff --cc mysql-test/r/events_1.result
index 6f3ad654810,8ea45fa8f2b..26611abb880
--- a/mysql-test/r/events_1.result
+++ b/mysql-test/r/events_1.result
@@@ -11,10 -11,12 +11,14 @@@ CREATE DATABASE db_x
  GRANT EVENT ON db_x.* TO pauline at localhost;
  USE db_x;
  CREATE TABLE x_table(a int);
 +connect  priv_conn,localhost,pauline,,db_x;
  CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 +connection default;
  SHOW DATABASES LIKE 'db_x';
  Database (db_x)
  db_x
diff --cc mysql-test/r/events_2.result
index 6d2ebda03d0,280ca6c8d98..6dd1a9e5dc6
--- a/mysql-test/r/events_2.result
+++ b/mysql-test/r/events_2.result
@@@ -377,9 -401,11 +401,11 @@@ create event event_35981 on schedule ev
  on completion not preserve
  do
  select 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00'
    ends '1999-01-02 00:00:00';
 -ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future.
 +ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future
  drop event event_35981;
  create event event_35981 on schedule every 1 hour starts current_timestamp
  on completion not preserve
diff --cc mysql-test/r/events_bugs.result
index 3e770451735,a873a28faed..008d4db7dae
--- a/mysql-test/r/events_bugs.result
+++ b/mysql-test/r/events_bugs.result
@@@ -203,8 -209,9 +209,10 @@@ drop database if exists mysqltest_db1
  create user mysqltest_user1 at localhost;
  create database mysqltest_db1;
  grant event on events_test.* to mysqltest_user1 at localhost;
 +connect  conn2,localhost,mysqltest_user1,,events_test;
  create event mysqltest_user1 on schedule every 10 second do select 42;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  alter event mysqltest_user1 rename to mysqltest_db1.mysqltest_user1;
  ERROR 42000: Access denied for user 'mysqltest_user1'@'localhost' to database 'mysqltest_db1'
  "Let's test now rename when there is no select DB"
@@@ -371,8 -384,9 +389,10 @@@ SELECT event_name, definer FROM INFORMA
  event_name	definer
  e1	mysqltest_u1 at localhost
  DROP EVENT e1;
 +connect  conn1, localhost, mysqltest_u1, , events_test;
  CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS;
  event_name	definer
  e1	mysqltest_u1 at localhost
@@@ -660,9 -693,13 +700,11 @@@ ERROR HY000: The MariaDB server is runn
  DROP EVENT e1;
  ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
  
 -#
 -# Connection: root_con (root at localhost/events_test).
 -#
 +connect root_con,localhost,root,,events_test;
  
  CREATE EVENT e1 ON SCHEDULE AT '2020-01-01 00:00:00' DO SET @a = 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  
  ALTER EVENT e1 COMMENT 'comment';
  
@@@ -670,10 -707,16 +712,14 @@@ DROP EVENT e1
  
  SET GLOBAL READ_ONLY = 0;
  
 -#
 -# Connection: u1_con (mysqltest_u1 at localhost/test).
 -#
 +connection u1_con;
  
  CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  
  SELECT
  event_name,
diff --cc mysql-test/r/events_grant.result
index a054e58494b,446ede09b5a..c691f44aa2e
--- a/mysql-test/r/events_grant.result
+++ b/mysql-test/r/events_grant.result
@@@ -53,12 -58,11 +59,14 @@@ events_test	two_event	ev_test at localhos
  "This should show us no events:";
  SHOW EVENTS FROM test LIKE '%';
  Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
 +connection default;
  GRANT EVENT ON events_test2.* TO ev_test at localhost;
 +connection ev_con1;
  USE events_test2;
  CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 +connection default;
  USE events_test;
  "We should see 4 events : one_event, two_event, three_event & four_event"
  SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
@@@ -78,7 -81,8 +86,9 @@@ connection default
  CREATE DATABASE events_test2;
  USE events_test2;
  CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 +connection ev_con1;
  "Should see 4 events - one, two, three & five"
  SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
  EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
diff --cc mysql-test/r/flush_read_lock.result
index 55c31ae8d12,da53d2f6d2e..47c46da05f1
--- a/mysql-test/r/flush_read_lock.result
+++ b/mysql-test/r/flush_read_lock.result
@@@ -85,10 -85,8 +85,12 @@@ insert into t1_temp values (1)
  return 0;
  end|
  create event e1 on schedule every 1 minute do begin end;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 +connect  con1,localhost,root,,;
 +connect  con2,localhost,root,,;
 +connect  con3,localhost,root,,;
 +connection default;
  #
  # Test compatibility of FLUSH TABLES WITH READ LOCK 
  # with various statements.
diff --cc mysql-test/r/func_gconcat.result
index 0c3d649a6bb,2147040ddb5..992f935b14e
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@@ -1200,57 -1199,30 +1199,86 @@@ Warning	1260	Row 3 was cut by GROUP_CON
  Warning	1260	Row 5 was cut by GROUP_CONCAT()
  DROP TABLE t1;
  SET group_concat_max_len= DEFAULT;
++set session group_concat_max_len=1024;
+ set max_session_mem_used=16*1024*1024;
+ SELECT GROUP_CONCAT(concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1) ORDER BY 2,1,3,4,6,5,8,7) AS c
+ FROM seq_1_to_200000;
+ c
+ 0.90910.90910.90910.90910.90910.90910.90910.9091,1.81821.81821.81821.81821.81821.81821.81821.8182,10.000010.000010.000010.000010.000010.000010.000010.0000,10.909110.909110.909110.909110.909110.909110.909110.9091,100.0000100.0000100.0000100.0000100.0000100.0000100.0000100.0000,100.9091100.9091100.9091100.9091100.9091100.9091100.9091100.9091,1000.00001000.00001000.00001000.00001000.00001000.00001000.00001000.0000,1000.90911000.90911000.90911000.90911000.90911000.90911000.90911000.9091,10000.000010000.000010000.000010000.000010000.000010000.000010000.000010000.0000,10000.909110000.909110000.909110000.909110000.909110000.909110000.909110000.9091,100000.0000100000.0000100000.0000100000.0000100000.0000100000.0000100000.0000100000.0000,100000.9091100000.9091100000.9091100000.9091100000.9091100000.9091100000.9091100000.9091,100001.8182100001.8182100001.8182100001.8182100001.8182100001.8182100001.8182100001.8182,100002.7273100002.7273100002.7273100002.7273100002.7273100002.727310000
 2.7273100002.7273,100003.6364100003.
+ Warnings:
+ Warning	1260	Row 15 was cut by GROUP_CONCAT()
+ set max_session_mem_used=default;
++set session group_concat_max_len=default;
+ SET group_concat_max_len= 8;
+ CREATE TABLE t1 (a INT);
+ INSERT t1 VALUES (1),(2);
+ CREATE TABLE t2 (b DATE, c INT);
+ INSERT t2 VALUES ('2019-12-04',1),('2020-03-28',2);
+ CREATE TABLE t3 (d INT);
+ INSERT t3 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14);
+ CREATE TABLE t4 (e INT);
+ INSERT t4 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15);
+ SELECT (SELECT MAX(a) FROM t1 WHERE t2_sq.c > 0) AS f,
+ GROUP_CONCAT(t2_sq.b ORDER BY 1) AS gc
+ FROM (SELECT t2_a.* FROM t2 AS t2_a, t2 AS t2_b) AS t2_sq, t3, t4
+ GROUP BY f;
+ f	gc
+ 2	2019-12-
+ Warnings:
+ Warning	1260	Row 1 was cut by GROUP_CONCAT()
+ DROP TABLE t1, t2, t3, t4;
+ SET group_concat_max_len= default;
 +#
 +# Start of 10.2 tests
 +#
 +#
 +# MDEV-10124 Incorrect usage of CUBE/ROLLUP and ORDER BY with GROUP_CONCAT(a ORDER BY a)
 +#
 +CREATE TABLE t1 (a INT);
 +INSERT INTO t1 VALUES (10),(20),(30);
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP;
 +a	GROUP_CONCAT(a ORDER BY a)
 +10	10
 +20	20
 +30	30
 +NULL	10,20,30
 +CREATE VIEW v1 AS
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP;
 +SELECT * FROM v1;
 +a	GROUP_CONCAT(a ORDER BY a)
 +10	10
 +20	20
 +30	30
 +NULL	10,20,30
 +DROP VIEW v1;
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30';
 +a	GROUP_CONCAT(a ORDER BY a)
 +NULL	10,20,30
 +CREATE VIEW v1 AS
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30';
 +SELECT * FROM v1;
 +a	GROUP_CONCAT(a ORDER BY a)
 +NULL	10,20,30
 +DROP VIEW v1;
 +SELECT * FROM (SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30') t1;
 +a	GROUP_CONCAT(a ORDER BY a)
 +NULL	10,20,30
 +CREATE VIEW v1 AS
 +SELECT * FROM (SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30') t1;
 +SELECT * FROM v1;
 +a	GROUP_CONCAT(a ORDER BY a)
 +NULL	10,20,30
 +DROP VIEW v1;
 +SELECT (SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30');
 +(SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30')
 +10,20,30
 +CREATE VIEW v1 AS
 +SELECT (SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30');
 +SELECT * FROM v1;
 +Name_exp_1
 +10,20,30
 +DROP VIEW v1;
 +DROP TABLE t1;
 +#
 +# End of 10.2 tests
 +#
diff --cc mysql-test/r/gis.result
index f97f588d888,76524311f01..828fbd9d0e7
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@@ -1875,375 -1877,17 +1875,413 @@@ t2	CREATE TABLE `t2` 
    `w2` int(1) DEFAULT NULL
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1
  DROP TABLE t1,t2;
+ CREATE TABLE t1 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ point_data POINT NOT NULL,
+ PRIMARY KEY (id),
+ KEY idx_point_data(point_data)
+ ) ENGINE=MyISAM;
+ INSERT t1 (point_data) VALUES
+ (GeomFromText('Point(37.0248492 23.8512726)')),
+ (GeomFromText('Point(38.0248492 23.8512726)'));
+ SELECT id FROM t1
+ WHERE ST_Contains(point_data, GeomFromText('Point(38.0248492 23.8512726)'));
+ id
+ 2
+ DROP TABLE t1;
 +#
 +# Start of 10.2 tests
 +#
 +create view v1 as select AsWKT(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))));
 +show create view v1;
 +View	Create View	character_set_client	collation_connection
 +v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select st_astext(geometrycollection(point(44,6),geometrycollection(point(3,6),point(7,9)))) AS `Name_exp_1`	latin1	latin1_swedish_ci
 +select * from v1;
 +Name_exp_1
 +GEOMETRYCOLLECTION(POINT(44 6),GEOMETRYCOLLECTION(POINT(3 6),POINT(7 9)))
 +drop view v1;
 +#
 +# MDEV-10134 Add full support for DEFAULT
 +#
 +CREATE TABLE t1 (a POINT, x DOUBLE DEFAULT x(a), y DOUBLE DEFAULT y(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` point DEFAULT NULL,
 +  `x` double DEFAULT st_x(`a`),
 +  `y` double DEFAULT st_y(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (Point(1,2));
 +SELECT x,y FROM t1;
 +x	y
 +1	2
 +DROP TABLE t1;
 +CREATE TABLE t1 (g GEOMETRY, area DOUBLE DEFAULT ST_AREA(g));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `g` geometry DEFAULT NULL,
 +  `area` double DEFAULT st_area(`g`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (g) VALUES (GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'));
 +SELECT area FROM t1;
 +area
 +400
 +DROP TABLE t1;
 +CREATE TABLE t1 (g GEOMETRY, length DOUBLE DEFAULT ST_LENGTH(g));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `g` geometry DEFAULT NULL,
 +  `length` double DEFAULT st_length(`g`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (g) VALUES (GeomFromText('LINESTRING(0 0,20 0,20 20,0 20,0 0)'));
 +SELECT length FROM t1;
 +length
 +80
 +DROP TABLE t1;
 +CREATE TABLE t1 (g POINT, distance DOUBLE DEFAULT ST_DISTANCE(g, POINT(0,0)));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `g` point DEFAULT NULL,
 +  `distance` double DEFAULT st_distance(`g`,point(0,0))
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (g) VALUES (Point(1,0));
 +SELECT distance FROM t1;
 +distance
 +1
 +DROP TABLE t1;
 +CREATE TABLE t1 (a TEXT, g GEOMETRY DEFAULT GeomFromText(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` text DEFAULT NULL,
 +  `g` geometry DEFAULT st_geometryfromtext(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES ('point(1 1)');
 +SELECT AsText(g) FROM t1;
 +AsText(g)
 +POINT(1 1)
 +DROP TABLE t1;
 +CREATE TABLE t1 (x INT, y INT, g GEOMETRY DEFAULT POINT(x,y));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `x` int(11) DEFAULT NULL,
 +  `y` int(11) DEFAULT NULL,
 +  `g` geometry DEFAULT point(`x`,`y`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (x,y) VALUES (10,20);
 +SELECT AsText(g) FROM t1;
 +AsText(g)
 +POINT(10 20)
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT PointN(a,2));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_pointn(`a`,2)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(1 1,2 2,3 3)'));
 +SELECT AsText(b) FROM t1;
 +AsText(b)
 +POINT(2 2)
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT StartPoint(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_startpoint(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(1 1,2 2,3 3)'));
 +SELECT AsText(b) FROM t1;
 +AsText(b)
 +POINT(1 1)
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c GEOMETRY DEFAULT GeometryCollection(a,b));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT NULL,
 +  `c` geometry DEFAULT geometrycollection(`a`,`b`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a,b) VALUES (Point(1,1), Point(2,2));
 +SELECT AsText(c) FROM t1;
 +AsText(c)
 +GEOMETRYCOLLECTION(POINT(1 1),POINT(2 2))
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT GeomFromWKB(AsBinary(a),20));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_geometryfromwkb(st_aswkb(`a`),20)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('POINT(1 1)', 10));
 +SELECT AsText(a), SRID(a), AsText(b), SRID(b) FROM t1;
 +AsText(a)	SRID(a)	AsText(b)	SRID(b)
 +POINT(1 1)	10	POINT(1 1)	20
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT BOUNDARY(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_boundary(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT AsText(b) FROM t1;
 +AsText(b)
 +LINESTRING(10 10,10 20,20 20,20 10,10 10)
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT BUFFER(a,10));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_buffer(`a`,10)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT GeometryType(b) FROM t1;
 +GeometryType(b)
 +POLYGON
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT CENTROID(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_centroid(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT AsText(b) FROM t1;
 +AsText(b)
 +POINT(15 15)
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT ENVELOPE(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_envelope(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(1 1,4 4)'));
 +SELECT AsText(b) FROM t1;
 +AsText(b)
 +POLYGON((1 1,4 1,4 4,1 4,1 1))
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT PointOnSurface(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT st_pointonsurface(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT GeometryType(b) FROM t1;
 +GeometryType(b)
 +POINT
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT Point(1,1), c GEOMETRY DEFAULT ST_UNION(a,b));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT point(1,1),
 +  `c` geometry DEFAULT st_union(`a`,`b`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (Point(0,0));
 +SELECT AsText(c) FROM t1;
 +AsText(c)
 +MULTIPOINT(0 0,1 1)
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b VARCHAR(20) DEFAULT GeometryType(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` varchar(20) DEFAULT st_geometrytype(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (Point(0, 0));
 +SELECT b FROM t1;
 +b
 +POINT
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsSimple(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_issimple(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (Point(0, 0));
 +SELECT b FROM t1;
 +b
 +1
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsEmpty(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_isempty(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (Point(0, 0));
 +SELECT b FROM t1;
 +b
 +0
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsRing(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_isring(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(0 0,0 1,1 1,1 0,0 0)'));
 +SELECT b FROM t1;
 +b
 +1
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsClosed(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_isclosed(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(0 0,0 1,1 1,1 0,0 0)'));
 +SELECT b FROM t1;
 +b
 +1
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT Dimension(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_dimension(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (Buffer(Point(1,1),1));
 +SELECT b FROM t1;
 +b
 +2
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT NumGeometries(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_numgeometries(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (ST_UNION(Point(1,1),Point(0,0)));
 +SELECT b FROM t1;
 +b
 +2
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT NumInteriorRings(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_numinteriorrings(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'));
 +SELECT b FROM t1;
 +b
 +1
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT NumPoints(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT st_numpoints(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (LineString(Point(1,1),Point(0,0)));
 +SELECT b FROM t1;
 +b
 +2
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT SRID(a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` int(11) DEFAULT srid(`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (GeomFromText('Point(1 1)', 100));
 +SELECT b FROM t1;
 +b
 +100
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c INT DEFAULT MBRDisjoint(a,b));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT NULL,
 +  `c` int(11) DEFAULT mbrdisjoint(`a`,`b`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a,b) VALUES (Point(1,1),Point(1,1));
 +SELECT c FROM t1;
 +c
 +0
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c INT DEFAULT ST_Disjoint(a,b));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT NULL,
 +  `c` int(11) DEFAULT st_disjoint(`a`,`b`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a,b) VALUES (Point(1,1),Point(1,1));
 +SELECT c FROM t1;
 +c
 +0
 +DROP TABLE t1;
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c INT DEFAULT ST_Relate(a,b,'T*F**FFF*'));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` geometry DEFAULT NULL,
 +  `b` geometry DEFAULT NULL,
 +  `c` int(11) DEFAULT st_relate(`a`,`b`,'T*F**FFF*')
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a,b) VALUES (Point(1,1),Point(1,1));
 +SELECT c FROM t1;
 +c
 +1
 +DROP TABLE t1;
++create table t1 (p point default "qwer");
++ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
++create table t1 (p point default 0);
++ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
++create table t1 (p point not null default st_geometryfromtext('point 0)'));
++ERROR 42000: Invalid default value for 'p'
++create table t1 (p point not null default st_geometryfromtext('point(0 0)'));
++insert into t1 values(default);
++select st_astext(p) from t1;
++st_astext(p)
++POINT(0 0)
++drop table t1;
++create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
++set timestamp=10;
++insert into t1 values(default);
++ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
++drop table t1;
++SET timestamp=default;
++create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
++set timestamp=10;
++alter table t1 add column i int;
++ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
++drop table t1;
++SET timestamp=default;
 +#
 +# End of 10.2 tests
 +#
diff --cc mysql-test/r/gis_notembedded.result
index 00000000000,eb1e2b98917..64e90572bf0
mode 000000,100644..100644
--- a/mysql-test/r/gis_notembedded.result
+++ b/mysql-test/r/gis_notembedded.result
@@@ -1,0 -1,42 +1,45 @@@
+ show create procedure mysql.AddGeometryColumn;
+ Procedure	sql_mode	Create Procedure	character_set_client	collation_connection	Database Collation
+ AddGeometryColumn		CREATE DEFINER=`root`@`localhost` PROCEDURE `AddGeometryColumn`(catalog varchar(64), t_schema varchar(64),
+    t_name varchar(64), geometry_column varchar(64), t_srid int)
+     SQL SECURITY INVOKER
+ begin
+   set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	latin1	latin1_swedish_ci	latin1_swedish_ci
+ show create procedure mysql.DropGeometryColumn;
+ Procedure	sql_mode	Create Procedure	character_set_client	collation_connection	Database Collation
+ DropGeometryColumn		CREATE DEFINER=`root`@`localhost` PROCEDURE `DropGeometryColumn`(catalog varchar(64), t_schema varchar(64),
+    t_name varchar(64), geometry_column varchar(64))
+     SQL SECURITY INVOKER
+ begin
+   set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	latin1	latin1_swedish_ci	latin1_swedish_ci
+ create table t1 (a int, b int);
+ call mysql.AddGeometryColumn('', 'test', 't1', 'c', 10);
+ show create table t1;
+ Table	Create Table
+ t1	CREATE TABLE `t1` (
+   `a` int(11) DEFAULT NULL,
+   `b` int(11) DEFAULT NULL,
+   `c` geometry DEFAULT NULL
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ call mysql.DropGeometryColumn('', 'test', 't1', 'c');
+ show create table t1;
+ Table	Create Table
+ t1	CREATE TABLE `t1` (
+   `a` int(11) DEFAULT NULL,
+   `b` int(11) DEFAULT NULL
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ call mysql.DropGeometryColumn('', 'test', 't1', 'b');
+ show create table t1;
+ Table	Create Table
+ t1	CREATE TABLE `t1` (
+   `a` int(11) DEFAULT NULL
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1
+ drop table t1;
+ create user foo at localhost;
+ grant execute on mysql.* to foo at localhost;
++connect  foo, localhost, foo;
+ call mysql.AddGeometryColumn('', 'mysql', 'proc', 'c', 10);
+ ERROR 42000: ALTER command denied to user 'foo'@'localhost' for table 'proc'
++disconnect foo;
++connection default;
+ drop user foo at localhost;
diff --cc mysql-test/r/grant4.result
index c3db2e03e3e,88fad6edf49..cb26148dbd1
--- a/mysql-test/r/grant4.result
+++ b/mysql-test/r/grant4.result
@@@ -125,10 -121,28 +125,30 @@@ ERROR 42000: SELECT command denied to u
  SHOW CREATE VIEW v3;
  View	Create View	character_set_client	collation_connection
  v3	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t_select_priv`.`a` AS `a`,`t_select_priv`.`b` AS `b` from `t_select_priv`	latin1	latin1_swedish_ci
 +connection default;
 +disconnect con1;
  drop database mysqltest_db1;
  drop user mysqltest_u1 at localhost;
+ call mtr.add_suppression("Table 'mysql.user' doesn't exist");
+ call mtr.add_suppression("'mysql.user' is not TABLE");
+ rename table mysql.user to mysql.user1;
+ create view mysql.user as select * from mysql.user1;
+ flush privileges;
+ ERROR HY000: 'mysql.user' is not TABLE
+ drop view mysql.user;
+ create temporary table mysql.user select * from mysql.user1 limit 0;
+ flush privileges;
+ ERROR 42S02: Table 'mysql.user' doesn't exist
+ drop temporary table mysql.user;
+ rename table mysql.user1 to mysql.user;
+ call mtr.add_suppression('mysql.user table is damaged');
+ rename table mysql.user to mysql.user1;
+ create table mysql.user (Host char(100), User char(100));
+ flush privileges;
+ ERROR HY000: Unknown error
+ drop table mysql.user;
+ rename table mysql.user1 to mysql.user;
+ End of 5.5 tests
  #
  # Additional coverage for refactoring which is made as part
  # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege
diff --cc mysql-test/r/lock_sync.result
index 7b61c5994b6,f8f511b3e3d..d017cf90cb8
--- a/mysql-test/r/lock_sync.result
+++ b/mysql-test/r/lock_sync.result
@@@ -729,8 -725,12 +729,12 @@@ disconnect con2
  # Bug#51391 Deadlock involving events during rqg_info_schema test
  #
  CREATE EVENT e1 ON SCHEDULE EVERY 5 HOUR DO SELECT 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  CREATE EVENT e2 ON SCHEDULE EVERY 5 HOUR DO SELECT 2;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 -# Connection con1
 +connect con1, localhost, root;
  SET DEBUG_SYNC="before_lock_tables_takes_lock SIGNAL drop WAIT_FOR query";
  # Sending:
  DROP EVENT e1;;
diff --cc mysql-test/r/mdev_19276.result
index 00000000000,09d51561427..c1b822de6bf
mode 000000,100644..100644
--- a/mysql-test/r/mdev_19276.result
+++ b/mysql-test/r/mdev_19276.result
@@@ -1,0 -1,9 +1,11 @@@
+ CREATE DATABASE db1;
+ CREATE USER u at localhost IDENTIFIED BY 'pw';
+ set global log_warnings=2;
+ connect(localhost,u,pw,db1,MASTER_PORT,MASTER_SOCKET);
++connect con1,localhost,u,pw,db1;
+ ERROR 42000: Access denied for user 'u'@'localhost' to database 'db1'
 -FOUND /Access denied for user 'u'@'localhost' to database 'db1'/ in mysqld.1.err
++connection default;
++FOUND 1 /Access denied for user 'u'@'localhost' to database 'db1'/ in mysqld.1.err
+ set global log_warnings=@@log_warnings;
+ DROP DATABASE db1;
+ DROP USER u at localhost;
diff --cc mysql-test/r/multi_update.result
index 634b3897ba0,f614ea1e497..11823941e56
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@@ -1001,4 -1018,79 +1001,27 @@@ execute stmt1
  deallocate prepare stmt1;
  drop view v3,v2,v1;
  drop table t1,t2,t3;
+ create table t1 (id int not null, v1 varchar(10) not null);
+ insert into t1 values (1,1),(2,2);
+ create table t2 (log varchar(10) not null);
+ create trigger t1_after_update after update on t1
+ for each row insert into t2 values ('triggered');
+ create user foo;
+ grant select, insert, update, delete, create, drop, reload, index, alter, show databases, create temporary tables, lock tables, execute, create view, show view, create routine, alter routine, trigger on *.* to 'foo'@'%';
+ set global read_only=1;
++connect a, localhost, foo;
+ create temporary table temp_t1 (id int not null, update_me varchar(10));
+ insert into temp_t1 values (1,1),(2,2),(3,3);
+ update temp_t1 left join t1 on temp_t1.id = t1.id set temp_t1.update_me = 'hello';
++connection default;
+ set global read_only = 0;
+ create table t3 (id int not null);
+ insert t3 values (2);
+ update t1 left join t3 on t1.id = t3.id set t1.v1 = 'hello';
+ select * from t2;
+ log
+ triggered
+ triggered
+ drop table t1,t2, t3;
+ drop user foo;
  end of 5.5 tests
 -
 -# Bug mdev-5970
 -# Bug#13256831 - ERROR 1032 (HY000): CAN'T FIND RECORD
 -
 -CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
 -CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
 -INSERT INTO t1 VALUES (5, 7);
 -INSERT INTO t2 VALUES (6, 97);
 -CREATE ALGORITHM = MERGE VIEW v1 AS 
 -SELECT a2.f1 AS f1, a2.f2 AS f2
 -FROM t1 AS a1 JOIN t2 AS a2 ON a1.f2 > a2.f1 
 -WITH LOCAL CHECK OPTION;
 -SELECT * FROM v1;
 -f1	f2
 -6	97
 -UPDATE v1 SET f1 = 1;
 -SELECT * FROM v1;
 -f1	f2
 -1	97
 -DROP TABLE t1, t2;
 -DROP VIEW v1;
 -#
 -# MDEV-5973: MySQL  Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0
 -# FROM STORAGE ENGINE) WITH MULTI-TABLE UPDATE
 -#
 -CREATE TABLE table_11757486 (field1 tinyint) ENGINE=INNODB;
 -INSERT INTO table_11757486 VALUES (0),(0);
 -SET SESSION SQL_MODE='STRICT_ALL_TABLES';
 -UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
 -Warnings:
 -Warning	1264	Out of range value for column 'field1' at row 1
 -Warning	1264	Out of range value for column 'field1' at row 2
 -UPDATE IGNORE table_11757486 SET field1=128;
 -Warnings:
 -Warning	1264	Out of range value for column 'field1' at row 1
 -Warning	1264	Out of range value for column 'field1' at row 2
 -Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave.
 -UPDATE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
 -ERROR 22003: Out of range value for column 'field1' at row 1
 -UPDATE table_11757486 SET field1=128;
 -ERROR 22003: Out of range value for column 'field1' at row 1
 -SET SESSION SQL_MODE='';
 -UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
 -Warnings:
 -Warning	1264	Out of range value for column 'field1' at row 1
 -Warning	1264	Out of range value for column 'field1' at row 2
 -UPDATE IGNORE table_11757486 SET field1=128;
 -Warnings:
 -Warning	1264	Out of range value for column 'field1' at row 1
 -Warning	1264	Out of range value for column 'field1' at row 2
 -Note	1592	Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. UPDATE IGNORE is unsafe because the order in which rows are updated determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave.
 -DROP TABLE table_11757486;
 -SET SESSION SQL_MODE=default;
 -end of 10.0 tests
diff --cc mysql-test/r/partition_innodb.result
index 0a58883bb34,5deab4d84fc..8c0950e3643
--- a/mysql-test/r/partition_innodb.result
+++ b/mysql-test/r/partition_innodb.result
@@@ -928,48 -918,45 +928,90 @@@ ERROR 44000: CHECK OPTION failed `test`
  SET GLOBAL innodb_stats_persistent= @save_isp;
  DROP view v;
  DROP TABLE t;
 +set sql_mode= @save_sql_mode;
  #
+ # Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT
+ #
+ CREATE TABLE t (a VARCHAR(10) NOT NULL,b INT,PRIMARY KEY (b)) ENGINE=INNODB
+ PARTITION BY RANGE (b)
+ (PARTITION pa VALUES LESS THAN (2),
+ PARTITION pb VALUES LESS THAN (20),
+ PARTITION pc VALUES LESS THAN (30),
+ PARTITION pd VALUES LESS THAN (40));
+ INSERT INTO t
+ VALUES('A',0),('B',1),('C',2),('D',3),('E',4),('F',5),('G',25),('H',35);
+ CREATE TABLE t_copy LIKE t;
+ INSERT INTO t_copy SELECT * FROM t;
+ ALTER TABLE t ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ ADD UNIQUE KEY (r,b);
+ affected rows: 0
+ info: Records: 0  Duplicates: 0  Warnings: 0
+ ALTER TABLE t_copy ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ ADD UNIQUE KEY (r,b), ALGORITHM=COPY;
+ affected rows: 8
+ info: Records: 8  Duplicates: 0  Warnings: 0
+ SELECT * FROM t;
+ a	b	r
+ A	0	1
+ B	1	2
+ C	2	3
+ D	3	4
+ E	4	5
+ F	5	6
+ G	25	7
+ H	35	8
+ SELECT * FROM t_copy;
+ a	b	r
+ A	0	1
+ B	1	2
+ C	2	3
+ D	3	4
+ E	4	5
+ F	5	6
+ G	25	7
+ H	35	8
+ DROP TABLE t,t_copy;
++#
 +# Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE
 +#              MYSQL.INNODB_TABLE_STATS
 +#
 +CREATE DATABASE test_jfg;
 +CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY
 +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1;
 +CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY
 +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
 +PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000)
 +ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE =
 +InnoDB);
 +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
 +database_name = 'test_jfg';
 +database_name	table_name
 +test_jfg	test_jfg1
 +test_jfg	test_jfg2#P#p1000
 +test_jfg	test_jfg2#P#pmax
 +RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11;
 +RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12;
 +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
 +database_name = 'test_jfg';
 +database_name	table_name
 +test_jfg	test_jfg11
 +test_jfg	test_jfg12#P#p1000
 +test_jfg	test_jfg12#P#pmax
 +DROP DATABASE test_jfg;
 +create table t1 (a int) engine=innodb;
 +create table t2 (
 +b int,
 +c int,
 +d bit not null default 0,
 +v bit as (d) virtual,
 +key (b,v)
 +) engine=innodb partition by hash (b);
 +insert into t1 values (1),(2);
 +insert into t2 (b,c,d) values (1,1,0),(2,2,0);
 +explain select t1.* from t1 join t2 on (v = a);
 +id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 +1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	
 +1	SIMPLE	t2	index	NULL	b	7	NULL	2	Using where; Using index; Using join buffer (flat, BNL join)
 +select t1.* from t1 join t2 on (v = a);
 +a
 +drop table t1, t2;
diff --cc mysql-test/r/ps.result
index e4d2ce83db1,0d305b37bd3..e8bea47e28c
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@@ -4404,888 -4397,22 +4410,905 @@@ END
  1
  1
  #
+ # MDEV-14572: Assertion `! is_set()' failed in
+ # Diagnostics_area::set_eof_status upon EXPLAIN UPDATE in PS
+ #
+ CREATE TABLE t1 (a INT);
+ CREATE TABLE t2 (b INT);
+ PREPARE stmt FROM 'EXPLAIN UPDATE t1, t2 SET a = 1';
+ EXECUTE stmt;
+ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+ 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	0	const row not found
+ 1	SIMPLE	t2	system	NULL	NULL	NULL	NULL	0	const row not found
+ EXECUTE stmt;
+ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+ 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	0	const row not found
+ 1	SIMPLE	t2	system	NULL	NULL	NULL	NULL	0	const row not found
+ deallocate prepare stmt;
+ DROP TABLE t1, t2;
+ #
  # End of 10.1 tests
  #
 +#
 +# MDEV-10709 Expressions as parameters to Dynamic SQL
 +#
 +#
 +# Using a simple expressions as an EXECUTE parameter
 +#
 +PREPARE stmt FROM 'SELECT ? FROM DUAL';
 +EXECUTE stmt USING 10;
 +?
 +10
 +DEALLOCATE PREPARE stmt;
 +PREPARE stmt FROM 'SELECT ? FROM DUAL';
 +EXECUTE stmt USING TO_BASE64('xxx');
 +?
 +eHh4
 +DEALLOCATE PREPARE stmt;
 +PREPARE stmt FROM 'SELECT ?+? FROM DUAL';
 +EXECUTE stmt USING 10, 10 + 10;
 +?+?
 +30
 +DEALLOCATE PREPARE stmt;
 +PREPARE stmt FROM 'SELECT CONCAT(?,?) FROM DUAL';
 +EXECUTE stmt USING 'xxx', CONCAT('yyy','zzz');
 +CONCAT(?,?)
 +xxxyyyzzz
 +DEALLOCATE PREPARE stmt;
 +#
 +# Testing disallowed expressions in USING
 +#
 +PREPARE stmt FROM 'SELECT ? FROM DUAL';
 +EXECUTE stmt USING (SELECT 1);
 +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
 +DEALLOCATE PREPARE stmt;
 +CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test';
 +PREPARE stmt FROM 'SELECT ? FROM DUAL';
 +EXECUTE stmt USING f1();
 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
 +DEALLOCATE PREPARE stmt;
 +DROP FUNCTION f1;
 +#
 +# Testing erroneous expressions in USING
 +#
 +PREPARE stmt FROM 'SELECT ?';
 +EXECUTE stmt USING _latin1'a'=_latin2'a';
 +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '='
 +DEALLOCATE PREPARE stmt;
 +PREPARE stmt FROM 'SELECT ?';
 +EXECUTE stmt USING ROW(1,2);
 +ERROR 21000: Operand should contain 1 column(s)
 +DEALLOCATE PREPARE stmt;
 +#
 +# Creating tables from EXECUTE parameters
 +#
 +PREPARE stmt FROM 'CREATE TABLE t1 AS SELECT ? AS c1 FROM DUAL';
 +EXECUTE stmt USING 10;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` bigint(21) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING 10.123;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` decimal(5,3) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING 10.123e0;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` double NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_DATE;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` date NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_TIMESTAMP;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` datetime NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_TIMESTAMP(3);
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` datetime(3) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_TIMESTAMP(6);
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` datetime(6) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_TIME;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` time NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_TIME(3);
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` time(3) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE stmt USING CURRENT_TIME(6);
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `c1` time(6) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +DEALLOCATE PREPARE stmt;
 +#
 +# Using a user variable as an EXECUTE..USING out parameter
 +#
 +CREATE PROCEDURE p1(OUT a INT)
 +BEGIN
 +SET a:= 10;
 +END;
 +/
 +SET @a=1;
 +CALL p1(@a);
 +SELECT @a;
 + at a
 +10
 +SET @a=2;
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING @a;
 +SELECT @a;
 + at a
 +10
 +DROP PROCEDURE p1;
 +#
 +# Using an SP variable as an EXECUTE..USING out parameter
 +#
 +CREATE PROCEDURE p1 (OUT a INT)
 +BEGIN
 +SET a=10;
 +END;
 +/
 +CREATE PROCEDURE p2 (OUT a INT)
 +BEGIN
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING a;
 +END;
 +/
 +SET @a= 1;
 +CALL p2(@a);
 +SELECT @a;
 + at a
 +10
 +DROP PROCEDURE p2;
 +DROP PROCEDURE p1;
 +#
 +# Testing re-prepare on a table metadata update between PREPARE and EXECUTE
 +#
 +CREATE TABLE t1 (a INT);
 +CREATE PROCEDURE p1(a INT)
 +BEGIN
 +INSERT INTO t1 VALUES (a);
 +END;
 +/
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING 10;
 +SELECT * FROM t1;
 +a
 +10
 +CREATE TRIGGER tr1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.a=NEW.a+1;
 +EXECUTE stmt USING 20;
 +SELECT * FROM t1;
 +a
 +10
 +21
 +DEALLOCATE PREPARE stmt;
 +DROP PROCEDURE p1;
 +DROP TABLE t1;
 +#
 +# End of MDEV-10709 Expressions as parameters to Dynamic SQL
 +#
 +#
 +# MDEV-10585 EXECUTE IMMEDIATE statement
 +#
 +EXECUTE IMMEDIATE 'SELECT 1 AS a';
 +a
 +1
 +SET @a=10;
 +EXECUTE IMMEDIATE 'SELECT ? AS a' USING @a;
 +a
 +10
 +EXECUTE IMMEDIATE 'SELECT ? AS a' USING 20;
 +a
 +20
 +#
 +# Erroneous queries
 +#
 +EXECUTE IMMEDIATE 'xxx';
 +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 'xxx' at line 1
 +EXECUTE IMMEDIATE 'SELECT 1' USING @a;
 +ERROR HY000: Incorrect arguments to EXECUTE
 +EXECUTE IMMEDIATE 'SELECT ?';
 +ERROR HY000: Incorrect arguments to EXECUTE
 +EXECUTE IMMEDIATE 'EXECUTE IMMEDIATE "SELECT 1"';
 +ERROR HY000: This command is not supported in the prepared statement protocol yet
 +EXECUTE IMMEDIATE 'PREPARE stmt FROM "SELECT 1"';
 +ERROR HY000: This command is not supported in the prepared statement protocol yet
 +EXECUTE IMMEDIATE 'EXECUTE stmt';
 +ERROR HY000: This command is not supported in the prepared statement protocol yet
 +EXECUTE IMMEDIATE 'DEALLOCATE PREPARE stmt';
 +ERROR HY000: This command is not supported in the prepared statement protocol yet
 +EXECUTE IMMEDIATE 'SELECT ?' USING _latin1'a'=_latin2'a';
 +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '='
 +EXECUTE IMMEDIATE 'SELECT ?' USING ROW(1,2);
 +ERROR 21000: Operand should contain 1 column(s)
 +#
 +# Testing disallowed expressions in USING
 +#
 +EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING (SELECT 1);
 +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
 +CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test';
 +EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING f1();
 +ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
 +DROP FUNCTION f1;
 +#
 +# DDL
 +#
 +EXECUTE IMMEDIATE 'CREATE TABLE t1 (a INT)';
 +EXECUTE IMMEDIATE 'SHOW CREATE TABLE t1';
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` int(11) DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +EXECUTE IMMEDIATE 'DROP TABLE t1';
 +SET @stmt= 'CREATE TABLE t1 (a INT)';
 +EXECUTE IMMEDIATE @stmt;
 +SET @stmt= 'SHOW CREATE TABLE t1';
 +EXECUTE IMMEDIATE @stmt;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` int(11) DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +SET @stmt= 'DROP TABLE t1';
 +EXECUTE IMMEDIATE @stmt;
 +#
 +# DDL with parameters
 +#
 +SET @a= 10, @b= 10.1, @c= 10e0, @d='str';
 +EXECUTE IMMEDIATE
 +'CREATE TABLE t1 AS SELECT ? AS a,? AS b,? AS c,? AS d'
 +  USING @a, at b, at c, at d;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` bigint(21) NOT NULL,
 +  `b` decimal(3,1) NOT NULL,
 +  `c` double NOT NULL,
 +  `d` varchar(3) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE IMMEDIATE
 +'CREATE TABLE t1 AS SELECT ? AS a,? AS b,? AS c,? AS d'
 +  USING 10, 10.1, 10e0, 'str';
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` bigint(21) NOT NULL,
 +  `b` decimal(3,1) NOT NULL,
 +  `c` double NOT NULL,
 +  `d` varchar(3) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +EXECUTE IMMEDIATE
 +'CREATE TABLE t1 AS SELECT ? AS t1,? AS t2, ? AS d1,? AS dt1, ? AS dt2'
 +  USING TIME'10:20:30',
 +TIME'10:20:30.123',
 +DATE'2001-01-01',
 +TIMESTAMP'2001-01-01 10:20:30',
 +TIMESTAMP'2001-01-01 10:20:30.123';
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `t1` time NOT NULL,
 +  `t2` time(3) NOT NULL,
 +  `d1` date NOT NULL,
 +  `dt1` datetime NOT NULL,
 +  `dt2` datetime(3) NOT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +#
 +# Using a user variable as an EXECUTE IMMEDIATE..USING out parameter
 +#
 +CREATE PROCEDURE p1(OUT a INT)
 +BEGIN
 +SET a:= 10;
 +END;
 +/
 +SET @a=1;
 +CALL p1(@a);
 +SELECT @a;
 + at a
 +10
 +SET @a=2;
 +EXECUTE IMMEDIATE 'CALL p1(?)' USING @a;
 +SELECT @a;
 + at a
 +10
 +DROP PROCEDURE p1;
 +#
 +# Using an SP variable as an EXECUTE IMMEDIATE..USING out parameter
 +#
 +CREATE PROCEDURE p1 (OUT a INT)
 +BEGIN
 +SET a=10;
 +END;
 +/
 +CREATE PROCEDURE p2 (OUT a INT)
 +BEGIN
 +EXECUTE IMMEDIATE 'CALL p1(?)' USING a;
 +END;
 +/
 +SET @a= 1;
 +CALL p2(@a);
 +SELECT @a;
 + at a
 +10
 +DROP PROCEDURE p2;
 +DROP PROCEDURE p1;
 +#
 +# Changing user variables
 +#
 +SET @a=10;
 +EXECUTE IMMEDIATE 'SET @a=@a+1';
 +SELECT @a;
 + at a
 +11
 +#
 +# SET STATEMENT
 +#
 +SET @@max_sort_length=1024;
 +EXECUTE IMMEDIATE 'SET STATEMENT max_sort_length=1025 FOR SELECT @@max_sort_length';
 +@@max_sort_length
 +1025
 +SELECT @@max_sort_length;
 +@@max_sort_length
 +1024
 +SET @@max_sort_length=DEFAULT;
 +#
 +# Similar to prepared EXECUTE, IMMEDIATE is not allowed in stored functions
 +#
 +CREATE FUNCTION f1() RETURNS INT
 +BEGIN
 +EXECUTE IMMEDIATE 'DO 1';
 +RETURN 1;
 +END;
 +$$
 +ERROR 0A000: Dynamic SQL is not allowed in stored function or trigger
 +#
 +# Status variables
 +#
 +CREATE FUNCTION get_status_var(name TEXT) RETURNS INT
 +RETURN (SELECT CAST(VARIABLE_VALUE AS INT)
 +FROM INFORMATION_SCHEMA.SESSION_STATUS
 +WHERE VARIABLE_NAME=name);
 +CREATE PROCEDURE test_status_var(name TEXT)
 +BEGIN
 +SET @cnt0=get_status_var(name);
 +EXECUTE IMMEDIATE 'DO 1';
 +SET @cnt1=get_status_var(name);
 +SELECT @cnt1- at cnt0 AS increment;
 +END;
 +$$
 +# Note, EXECUTE IMMEDIATE does not increment COM_EXECUTE_SQL
 +# It increments COM_EXECUTE_IMMEDIATE instead.
 +CALL test_status_var('COM_EXECUTE_SQL');
 +increment
 +0
 +CALL test_status_var('COM_EXECUTE_IMMEDIATE');
 +increment
 +1
 +CALL test_status_var('COM_STMT_PREPARE');
 +increment
 +1
 +CALL test_status_var('COM_STMT_EXECUTE');
 +increment
 +1
 +CALL test_status_var('COM_STMT_CLOSE');
 +increment
 +1
 +DROP PROCEDURE test_status_var;
 +DROP FUNCTION get_status_var;
 +#
 +# End of MDEV-10585 EXECUTE IMMEDIATE statement
 +#
 +#
 +# MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
 +#
 +#
 +# Testing erroneous and diallowed prepare source
 +#
 +EXECUTE IMMEDIATE CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL');
 +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
 +PREPARE stmt FROM CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL');
 +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
 +EXECUTE IMMEDIATE (SELECT 'SELECT 1');
 +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 'SELECT 1')' at line 1
 +PREPARE stmt FROM (SELECT 'SELECT 1');
 +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 'SELECT 1')' at line 1
 +EXECUTE IMMEDIATE a;
 +ERROR 42S22: Unknown column 'a' in 'field list'
 +PREPARE stmt FROM a;
 +ERROR 42S22: Unknown column 'a' in 'field list'
 +EXECUTE IMMEDIATE NULL;
 +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 'NULL' at line 1
 +PREPARE stmt FROM NULL;
 +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 'NULL' at line 1
 +EXECUTE IMMEDIATE CONCAT(NULL);
 +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 'NULL' at line 1
 +PREPARE stmt FROM CONCAT(NULL);
 +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 'NULL' at line 1
 +EXECUTE IMMEDIATE ? USING 'SELECT 1';
 +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 '? USING 'SELECT 1'' at line 1
 +EXECUTE IMMEDIATE 10;
 +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 '10' at line 1
 +EXECUTE IMMEDIATE TIME'10:20:30';
 +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 '10:20:30' at line 1
 +EXECUTE IMMEDIATE ROW('SELECT 1','SELECT 2');
 +ERROR 21000: Operand should contain 1 column(s)
 +EXECUTE IMMEDIATE MAX('SELECT 1 AS c');
 +ERROR HY000: Invalid use of group function
 +EXECUTE IMMEDIATE DEFAULT(a);
 +ERROR 42S22: Unknown column 'a' in 'field list'
 +EXECUTE IMMEDIATE VALUES(a);
 +ERROR 42S22: Unknown column 'a' in 'field list'
 +CREATE FUNCTION f1() RETURNS VARCHAR(64) RETURN 't1';
 +EXECUTE IMMEDIATE f1();
 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
 +PREPARE stmt FROM f1();
 +ERROR 42000: PREPARE..FROM does not support subqueries or stored functions
 +DROP FUNCTION f1;
 +EXECUTE IMMEDIATE non_existent();
 +ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
 +#
 +# Testing literals in prepare source
 +#
 +EXECUTE IMMEDIATE N'SELECT 1 AS c';
 +c
 +1
 +EXECUTE IMMEDIATE _latin1'SELECT 1 AS c';
 +c
 +1
 +EXECUTE IMMEDIATE 'SELECT '  '1'  ' AS c'  ' FROM '  'DUAL';
 +c
 +1
 +EXECUTE IMMEDIATE 0x53454C4543542031 /*This is 'SELECT 1'*/;
 +1
 +1
 +#
 +# Testing user variables in prepare source
 +#
 +SET @stmt='SELECT 1 AS c FROM DUAL';
 +EXECUTE IMMEDIATE @stmt;
 +c
 +1
 +PREPARE stmt FROM @stmt;
 +EXECUTE stmt;
 +c
 +1
 +DEALLOCATE PREPARE stmt;
 +SET @table_name='DUAL';
 +EXECUTE IMMEDIATE CONCAT('SELECT 1 AS a FROM ', @table_name);
 +a
 +1
 +PREPARE stmt FROM CONCAT('SELECT 1 AS a FROM ', @table_name);
 +EXECUTE stmt;
 +a
 +1
 +DEALLOCATE PREPARE stmt;
 +#
 +# Testing SP parameters and variables in prepare source
 +#
 +CREATE PROCEDURE p1(table_name VARCHAR(64))
 +BEGIN
 +EXECUTE IMMEDIATE CONCAT('SELECT 1 AS c FROM ', table_name);
 +END;
 +$$
 +CALL p1('DUAL');
 +c
 +1
 +DROP PROCEDURE p1;
 +CREATE PROCEDURE p1()
 +BEGIN
 +DECLARE table_name VARCHAR(64) DEFAULT 'DUAL';
 +EXECUTE IMMEDIATE CONCAT('SELECT 1 AS c FROM ', table_name);
 +END;
 +$$
 +CALL p1();
 +c
 +1
 +DROP PROCEDURE p1;
 +#
 +# Testing complex expressions
 +#
 +EXECUTE IMMEDIATE CONVERT('SELECT 1 AS c' USING utf8);
 +c
 +1
 +EXECUTE IMMEDIATE CAST('SELECT 1 AS c' AS CHAR);
 +c
 +1
 +EXECUTE IMMEDIATE _latin1'SELECT 1 AS c' COLLATE latin1_bin;
 +c
 +1
 +EXECUTE IMMEDIATE (((('SELECT 1 AS c'))));
 +c
 +1
 +EXECUTE IMMEDIATE CASE WHEN 1>2 THEN 'SELECT 1 AS c' ELSE 'SELECT 2 AS c' END;
 +c
 +2
 +EXECUTE IMMEDIATE TRIM('SELECT 1 AS c');
 +c
 +1
 +EXECUTE IMMEDIATE SUBSTRING('SELECT 1 AS c' FROM 1);
 +c
 +1
 +EXECUTE IMMEDIATE COALESCE(NULL, 'SELECT 1 AS c');
 +c
 +1
 +#
 +# Testing SET STATEMENT and system variables
 +#
 +CREATE TABLE t1 (a INT);
 +SET STATEMENT max_sort_length=1025 FOR EXECUTE IMMEDIATE CONCAT('INSERT INTO t1 VALUES (', @@max_sort_length, ')');
 +SELECT * FROM t1;
 +a
 +1025
 +DROP TABLE t1;
 +#
 +# End of MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
 +#
 +#
 +# MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter
 +#
 +CREATE TABLE t1 (a INT DEFAULT 10, b INT DEFAULT NULL);
 +EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (?,?)' USING DEFAULT, DEFAULT;
 +SELECT * FROM t1;
 +a	b
 +10	NULL
 +UPDATE t1 SET a=20, b=30;
 +SELECT * FROM t1;
 +a	b
 +20	30
 +EXECUTE IMMEDIATE 'UPDATE t1 SET a=?,b=?' USING DEFAULT, DEFAULT;
 +SELECT * FROM t1;
 +a	b
 +10	NULL
 +DROP TABLE t1;
 +CREATE TABLE t1 (a INT DEFAULT 10);
 +EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (?+1)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES (CONCAT(?,?))' USING DEFAULT, 'test';
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +DROP TABLE t1;
 +CREATE TABLE t1 (a INT DEFAULT 10);
 +INSERT INTO t1 VALUES (20);
 +EXECUTE IMMEDIATE 'UPDATE t1 SET a=?+1' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'UPDATE t1 SET a=CONCAT(?,?)' USING DEFAULT, 'test';
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +DROP TABLE t1;
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS SIGNED)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS DOUBLE)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS CHAR)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS DECIMAL(10,1))' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS TIME)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS DATE)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CAST(? AS DATETIME)' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT ?+1' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT CONCAT(?,?)' USING DEFAULT,'test';
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +EXECUTE IMMEDIATE 'SELECT 1 LIMIT ?' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +CREATE TABLE t1 (a INT DEFAULT 10);
 +INSERT INTO t1 VALUES (1),(2),(3);
 +EXECUTE IMMEDIATE 'SELECT * FROM t1 LIMIT ?' USING DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +DROP TABLE t1;
 +# The output of this query in 'Note' is a syntactically incorrect query.
 +# But as it's never logged, it's ok. It should be human readable only.
 +EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT ?' USING DEFAULT;
 +id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 +1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 +Warnings:
 +Note	1003	select default AS `?`
 +CREATE TABLE t1 (a INT);
 +INSERT INTO t1 VALUES (1),(2),(3);
 +EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>?+a' USING DEFAULT,DEFAULT;
 +ERROR HY000: Default/ignore value is not supported for such parameter usage
 +DROP TABLE t1;
 +#
 +# MDEV-11780 Crash with PREPARE + SP out parameter + literal
 +#
 +CREATE OR REPLACE PROCEDURE p1(OUT a INT)
 +BEGIN
 +SET a=10;
 +END;
 +$$
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING 10;
 +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
 +EXECUTE stmt USING DEFAULT;
 +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
 +EXECUTE stmt USING IGNORE;
 +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
 +DEALLOCATE PREPARE stmt;
 +EXECUTE IMMEDIATE 'CALL p1(?)' USING 10;
 +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
 +EXECUTE IMMEDIATE 'CALL p1(?)' USING DEFAULT;
 +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
 +EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE;
 +ERROR 42000: OUT or INOUT argument 1 for routine test.p1 is not a variable or NEW pseudo-variable in BEFORE trigger
 +DROP PROCEDURE p1;
 +#
 +# MDEV-14434 Wrong result for CHARSET(CONCAT(?,const))
 +#
 +SET NAMES utf8;
 +EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(5,_latin1'a'))";
 +CHARSET(CONCAT(5,_latin1'a'))
 +latin1
 +EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5;
 +CHARSET(CONCAT(?,_latin1'a'))
 +latin1
 +EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5.5;
 +CHARSET(CONCAT(?,_latin1'a'))
 +latin1
 +EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING 5.5e0;
 +CHARSET(CONCAT(?,_latin1'a'))
 +latin1
 +EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING TIME'10:20:30';
 +CHARSET(CONCAT(?,_latin1'a'))
 +latin1
 +EXECUTE IMMEDIATE "SELECT CHARSET(CONCAT(?,_latin1'a'))" USING TIMESTAMP'2001-01-01 10:20:30';
 +CHARSET(CONCAT(?,_latin1'a'))
 +latin1
 +EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5;
 +COERCIBILITY(?)
 +5
 +EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5.5;
 +COERCIBILITY(?)
 +5
 +EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING 5.5e0;
 +COERCIBILITY(?)
 +5
 +EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING TIME'10:20:30';
 +COERCIBILITY(?)
 +5
 +EXECUTE IMMEDIATE "SELECT COERCIBILITY(?)" USING TIMESTAMP'2001-01-01 10:20:30';
 +COERCIBILITY(?)
 +5
 +#
 +# MDEV-14435 Different UNSIGNED flag of out user variable for YEAR parameter for direct vs prepared CALL
 +#
 +CREATE PROCEDURE p1(OUT v INT UNSIGNED) SET v = 2010;
 +CALL p1(@a);
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING @b;
 +DEALLOCATE PREPARE stmt;
 +CREATE TABLE t1 AS SELECT @a AS a, @b AS b;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` bigint(20) unsigned DEFAULT NULL,
 +  `b` bigint(20) unsigned DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +DROP PROCEDURE p1;
 +CREATE PROCEDURE p1(OUT v YEAR) SET v = 2010;
 +CALL p1(@a);
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING @b;
 +DEALLOCATE PREPARE stmt;
 +CREATE TABLE t1 AS SELECT @a AS a, @b AS b;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` bigint(20) unsigned DEFAULT NULL,
 +  `b` bigint(20) unsigned DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +DROP PROCEDURE p1;
 +CREATE PROCEDURE p1(OUT v BIT(16)) SET v = 2010;
 +CALL p1(@a);
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt USING @b;
 +DEALLOCATE PREPARE stmt;
 +CREATE TABLE t1 AS SELECT @a AS a, @b AS b;
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` bigint(20) unsigned DEFAULT NULL,
 +  `b` bigint(20) unsigned DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +DROP TABLE t1;
 +DROP PROCEDURE p1;
 +#
 +# MDEV-14426 Assertion in Diagnostics_area::set_error_status when using a bad datetime with PS and SP
 +#
 +CREATE PROCEDURE p1(OUT a VARCHAR(20))
 +BEGIN
 +SET a=10;
 +END;
 +$$
 +BEGIN NOT ATOMIC
 +DECLARE a DATETIME;
 +CALL p1(a);
 +END;
 +$$
 +ERROR 22007: Incorrect datetime value: '10' for column ``.``.`a` at row 1
 +BEGIN NOT ATOMIC
 +DECLARE a DATETIME;
 +EXECUTE IMMEDIATE 'CALL p1(?)' USING a;
 +END;
 +$$
 +ERROR 22007: Incorrect datetime value: '10' for column ``.``.`a` at row 1
 +BEGIN NOT ATOMIC
 +DECLARE a DATETIME;
 +PREPARE stmt FROM 'CALL p1(?)';
 +EXECUTE stmt  USING a;
 +DEALLOCATE PREPARE stmt;
 +END;
 +$$
 +ERROR 22007: Incorrect datetime value: '10' for column ``.``.`a` at row 1
 +DROP PROCEDURE p1;
 +#
 +# MDEV-14603 signal 11 with short stacktrace
 +#
 +SET NAMES utf8;
 +CREATE TABLE t1(i INT);
 +CREATE PROCEDURE p1(tn VARCHAR(32))
 +EXECUTE IMMEDIATE CONCAT('ANALYZE TABLE ',tn);
 +CALL p1('t1');
 +Table	Op	Msg_type	Msg_text
 +test.t1	analyze	status	Table is already up to date
 +DROP PROCEDURE p1;
 +DROP TABLE t1;
 +SET NAMES utf8;
 +CREATE PROCEDURE p1()
 +EXECUTE IMMEDIATE CONCAT('SELECT ',CONVERT(RAND() USING latin1));
 +CALL p1();
 +DROP PROCEDURE p1;
 +SET NAMES utf8;
 +CREATE PROCEDURE p1()
 +BEGIN
 +PREPARE stmt FROM CONCAT('SELECT ',CONVERT(RAND() USING latin1));
 +EXECUTE stmt;
 +DEALLOCATE PREPARE stmt;
 +END;
 +$$
 +CALL p1();
 +DROP PROCEDURE p1;
 +SET NAMES utf8;
 +CREATE PROCEDURE p1(a VARCHAR(10) CHARACTER SET utf8)
 +EXECUTE IMMEDIATE 'SELECT ?' USING CONCAT(a, CONVERT(RAND() USING latin1));
 +CALL p1('x');
 +DROP PROCEDURE p1;
 +SET NAMES utf8;
 +CREATE PROCEDURE p1(a VARCHAR(10) CHARACTER SET utf8)
 +BEGIN
 +PREPARE stmt FROM 'SELECT ?';
 +EXECUTE stmt USING CONCAT(a, CONVERT(RAND() USING latin1));
 +DEALLOCATE PREPARE stmt;
 +END;
 +$$
 +CALL p1('x');
 +DROP PROCEDURE p1;
 +create table t1 (b blob default '');
 +prepare stmt from "alter table t1 force";
 +execute stmt;
 +execute stmt;
 +execute stmt;
 +set names latin1;
 +prepare stmt from "alter table t1 modify b text character set utf8 default 'a'";
 +execute stmt;
 +execute stmt;
 +execute stmt;
 +drop table t1;
 +#
 +# MDEV-12060 Crash in EXECUTE IMMEDIATE with an expression returning a GRANT command
 +#
 +CREATE ROLE testrole;
 +CREATE OR REPLACE PROCEDURE p1() 
 +BEGIN
 +END;
 +/
 +CREATE PROCEDURE p2 (wgrp VARCHAR(10))
 +BEGIN
 +EXECUTE IMMEDIATE concat('GRANT EXECUTE ON PROCEDURE p1 TO ',wgrp);
 +END;
 +/
 +CALL p2('testrole');
 +DROP PROCEDURE p2;
 +CREATE PROCEDURE p2 ()
 +BEGIN
 +EXECUTE IMMEDIATE concat(_utf8'GRANT EXECUTE ON PROCEDURE p1 TO ',_latin1'testrole');
 +END;
 +/
 +CALL p2();
 +DROP PROCEDURE p2;
 +CREATE PROCEDURE p2 ()
 +BEGIN
 +PREPARE stmt FROM concat(_utf8'GRANT EXECUTE ON PROCEDURE p1 TO ',_latin1' testrole');
 +EXECUTE stmt;
 +DEALLOCATE PREPARE stmt;
 +END;
 +/
 +CALL p2();
 +DROP PROCEDURE p2;
 +DROP PROCEDURE p1;
 +DROP ROLE testrole;
 +#
 +# MDEV-16992: prepare of CREATE TABLE, CREATE VIEW, DO, SET, CALL
 +#             statements with CTE containing materialized derived
 +# (the bug is reproducible on 10.4)        
 +#
 +prepare stmt from 
 +"CREATE TABLE  t1  AS 
 + WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
 +execute stmt;
 +select * from t1;
 +a
 +1
 +prepare stmt from
 +"CREATE VIEW  v1  AS 
 + WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
 +execute stmt;
 +select * from v1;
 +a
 +1
 +prepare stmt from 
 +"DO (SELECT 1 
 +     FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
 +           SELECT * FROM cte) AS tt);";
 +execute stmt;
 +prepare stmt from 
 +"SET @a = (SELECT 1
 +           FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
 +           SELECT * FROM cte) AS t);";
 +execute stmt;
 +create procedure p (i int) insert into t1 values(i);
 +prepare stmt from 
 +"CALL p       
 + ((SELECT 1
 +   FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
 +         SELECT * FROM cte) AS tt));";
 +execute stmt;
 +select * from t1;
 +a
 +1
 +1
 +drop procedure p;
 +drop view v1;
 +drop table t1;
 +#
 +# End of 10.2 tests
 +#
diff --cc mysql-test/r/stat_tables.result
index 7fd0b5902ec,0a53a5ae99d..f001c78bc11
--- a/mysql-test/r/stat_tables.result
+++ b/mysql-test/r/stat_tables.result
@@@ -692,63 -692,23 +692,81 @@@ USE test
  delete from mysql.table_stats;
  delete from mysql.column_stats;
  delete from mysql.index_stats;
+ #
+ # MDEV-19352: Server crash in alloc_histograms_for_table_share upon query from information schema
+ #
+ use test;
+ set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+ set @@optimizer_use_condition_selectivity= 4;
+ set use_stat_tables='preferably';
+ CREATE TABLE t1 (a INT);
+ CREATE TABLE t2 (b INT);
+ CREATE VIEW v AS SELECT * FROM t1 JOIN t2;
+ INSERT INTO t2 SELECT * FROM x;
+ ERROR 42S02: Table 'test.x' doesn't exist
+ select * from information_schema.tables where table_name='v';
+ TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	VERSION	ROW_FORMAT	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	AUTO_INCREMENT	CREATE_TIME	UPDATE_TIME	CHECK_TIME	TABLE_COLLATION	CHECKSUM	CREATE_OPTIONS	TABLE_COMMENT
+ def	test	v	VIEW	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	VIEW
+ drop table t1,t2;
+ drop view v;
+ set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
  set @save_optimizer_switch=@@optimizer_switch;
  set use_stat_tables=@save_use_stat_tables;
 +#
 +# MDEV-18899: Server crashes in Field::set_warning_truncated_wrong_value
 +#
 +set names utf8;
 +set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
 +set optimizer_use_condition_selectivity=4;
 +set use_stat_tables=preferably;
 +set @save_histogram_size= @@histogram_size;
 +set histogram_size=255;
 +create table t1 ( a varchar(255) character set utf8);
 +insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255));
 +analyze table t1;
 +Table	Op	Msg_type	Msg_text
 +test.t1	analyze	status	Engine-independent statistics collected
 +test.t1	analyze	status	OK
 +select HEX(RIGHT(min_value, 1)), length(min_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +HEX(RIGHT(min_value, 1))	length(min_value)
 +A7	254
 +select HEX(RIGHT(max_value, 1)), length(max_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +HEX(RIGHT(max_value, 1))	length(max_value)
 +A5	254
 +analyze select * from t1 where a  >= 'ӥ';
 +id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
 +1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	2.00	50.00	50.00	Using where
 +set @save_sql_mode= @@sql_mode;
 +set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 +update mysql.column_stats set min_value= REPEAT('ӥ',255) where db_name='test' and table_name='t1';
 +Warnings:
 +Warning	1265	Data truncated for column 'min_value' at row 1
 +select HEX(RIGHT(min_value, 1)), length(min_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +HEX(RIGHT(min_value, 1))	length(min_value)
 +D3	255
 +analyze select * from t1 where a  >= 'ӥ';
 +id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
 +1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	2.00	50.00	50.00	Using where
 +set names latin1;
 +drop table t1;
 +CREATE TABLE t1 (col1 date);
 +INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
 +INSERT INTO t1 VALUES('0000-10-31');
 +analyze table t1;
 +Table	Op	Msg_type	Msg_text
 +test.t1	analyze	status	Engine-independent statistics collected
 +test.t1	analyze	status	OK
 +update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1';
 +select min_value from mysql.column_stats where db_name='test' and table_name='t1';
 +min_value
 +2004-0-31123
 +select * from t1;
 +col1
 +2004-01-01
 +2004-02-29
 +0000-10-31
 +drop table t1;
 +set @@sql_mode= @save_sql_mode;
 +set use_stat_tables=@save_use_stat_tables;
 +set @@histogram_size= @save_histogram_size;
 +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
diff --cc mysql-test/r/stat_tables_innodb.result
index 2bc69c24104,9a93b479664..1107e349582
--- a/mysql-test/r/stat_tables_innodb.result
+++ b/mysql-test/r/stat_tables_innodb.result
@@@ -719,65 -719,25 +719,83 @@@ USE test
  delete from mysql.table_stats;
  delete from mysql.column_stats;
  delete from mysql.index_stats;
+ #
+ # MDEV-19352: Server crash in alloc_histograms_for_table_share upon query from information schema
+ #
+ use test;
+ set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+ set @@optimizer_use_condition_selectivity= 4;
+ set use_stat_tables='preferably';
+ CREATE TABLE t1 (a INT);
+ CREATE TABLE t2 (b INT);
+ CREATE VIEW v AS SELECT * FROM t1 JOIN t2;
+ INSERT INTO t2 SELECT * FROM x;
+ ERROR 42S02: Table 'test.x' doesn't exist
+ select * from information_schema.tables where table_name='v';
+ TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	VERSION	ROW_FORMAT	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	AUTO_INCREMENT	CREATE_TIME	UPDATE_TIME	CHECK_TIME	TABLE_COLLATION	CHECKSUM	CREATE_OPTIONS	TABLE_COMMENT
+ def	test	v	VIEW	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	VIEW
+ drop table t1,t2;
+ drop view v;
+ set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
  set @save_optimizer_switch=@@optimizer_switch;
  set use_stat_tables=@save_use_stat_tables;
 +#
 +# MDEV-18899: Server crashes in Field::set_warning_truncated_wrong_value
 +#
 +set names utf8;
 +set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
 +set optimizer_use_condition_selectivity=4;
 +set use_stat_tables=preferably;
 +set @save_histogram_size= @@histogram_size;
 +set histogram_size=255;
 +create table t1 ( a varchar(255) character set utf8);
 +insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255));
 +analyze table t1;
 +Table	Op	Msg_type	Msg_text
 +test.t1	analyze	status	Engine-independent statistics collected
 +test.t1	analyze	status	OK
 +select HEX(RIGHT(min_value, 1)), length(min_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +HEX(RIGHT(min_value, 1))	length(min_value)
 +A7	254
 +select HEX(RIGHT(max_value, 1)), length(max_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +HEX(RIGHT(max_value, 1))	length(max_value)
 +A5	254
 +analyze select * from t1 where a  >= 'ӥ';
 +id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
 +1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	2.00	50.00	50.00	Using where
 +set @save_sql_mode= @@sql_mode;
 +set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 +update mysql.column_stats set min_value= REPEAT('ӥ',255) where db_name='test' and table_name='t1';
 +Warnings:
 +Warning	1265	Data truncated for column 'min_value' at row 1
 +select HEX(RIGHT(min_value, 1)), length(min_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +HEX(RIGHT(min_value, 1))	length(min_value)
 +D3	255
 +analyze select * from t1 where a  >= 'ӥ';
 +id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
 +1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	2.00	50.00	50.00	Using where
 +set names latin1;
 +drop table t1;
 +CREATE TABLE t1 (col1 date);
 +INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
 +INSERT INTO t1 VALUES('0000-10-31');
 +analyze table t1;
 +Table	Op	Msg_type	Msg_text
 +test.t1	analyze	status	Engine-independent statistics collected
 +test.t1	analyze	status	OK
 +update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1';
 +select min_value from mysql.column_stats where db_name='test' and table_name='t1';
 +min_value
 +2004-0-31123
 +select * from t1;
 +col1
 +2004-01-01
 +2004-02-29
 +0000-10-31
 +drop table t1;
 +set @@sql_mode= @save_sql_mode;
 +set use_stat_tables=@save_use_stat_tables;
 +set @@histogram_size= @save_histogram_size;
 +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
  set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
  SET SESSION STORAGE_ENGINE=DEFAULT;
diff --cc mysql-test/r/statistics.result
index 34a17cf049c,135a0806bc3..267d9da965e
--- a/mysql-test/r/statistics.result
+++ b/mysql-test/r/statistics.result
@@@ -1735,25 -1735,18 +1735,39 @@@ rename table t1 to t2, t3 to t4
  ERROR 42S02: Table 'test.t3' doesn't exist
  drop table t1, mysql.table_stats;
  rename table test.table_stats to mysql.table_stats;
+ #
+ # MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.
+ #
+ create temporary table t1(a int);
+ insert into t1 values (1),(2),(3);
+ set use_stat_tables=preferably;
+ set @optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+ set optimizer_use_condition_selectivity=4;
+ select * from t1 where a >= 2;
+ a
+ 2
+ 3
+ drop table t1;
+ set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
  set use_stat_tables=@save_use_stat_tables;
 +#
 +# Start of 10.2 tests
 +#
 +#
 +# MDEV-10134 Add full support for DEFAULT
 +#
 +CREATE TABLE t1 (a BLOB, b TEXT DEFAULT DECODE_HISTOGRAM('SINGLE_PREC_HB',a));
 +SHOW CREATE TABLE t1;
 +Table	Create Table
 +t1	CREATE TABLE `t1` (
 +  `a` blob DEFAULT NULL,
 +  `b` text DEFAULT decode_histogram('SINGLE_PREC_HB',`a`)
 +) ENGINE=MyISAM DEFAULT CHARSET=latin1
 +INSERT INTO t1 (a) VALUES (0x0000000000000000000000000101010101010101010202020303030304040404050505050606070707080809090A0A0B0C0D0D0E0E0F10111213131415161718191B1C1E202224292A2E33373B4850575F6A76818C9AA7B9C4CFDADFE5EBF0F4F8FAFCFF);
 +SELECT b FROM t1;
 +b
 +0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.004,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.004,0.000,0.000,0.004,0.000,0.000,0.000,0.004,0.000,0.000,0.000,0.004,0.000,0.000,0.000,0.004,0.000,0.004,0.000,0.000,0.004,0.000,0.004,0.000,0.004,0.000,0.004,0.004,0.004,0.000,0.004,0.000,0.004,0.004,0.004,0.004,0.004,0.000,0.004,0.004,0.004,0.004,0.004,0.004,0.008,0.004,0.008,0.008,0.008,0.008,0.020,0.004,0.016,0.020,0.016,0.016,0.051,0.031,0.027,0.031,0.043,0.047,0.043,0.043,0.055,0.051,0.071,0.043,0.043,0.043,0.020,0.024,0.024,0.020,0.016,0.016,0.008,0.008,0.012,0.000
 +DROP TABLE t1;
 +#
 +# End of 10.2 tests
 +#
diff --cc mysql-test/r/type_bit.result
index eeedc501dc4,f460d05e2a9..7eaba70d7fa
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@@ -831,21 -831,9 +831,28 @@@ COALESCE(val, 1
  0
  DROP TABLE t1;
  #
+ # MDEV-18452 ASAN unknown-crash in Field::set_default upon SET bit_column = DEFAULT
+ #
+ CREATE TABLE t1 (b BIT(20)) ENGINE=MyISAM;
+ INSERT INTO t1 VALUES (0);
+ UPDATE t1 SET b = DEFAULT;
+ DROP TABLE t1;
++#
 +# End of 10.1 tests
 +#
 +#
 +# Start of 10.2 tests
 +#
 +#
 +# MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result
 +#
 +CREATE TABLE t1 (a DECIMAL(30,0));
 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED));
 +ALTER TABLE t1 MODIFY a BIT(64);
 +SELECT a+0 FROM t1;
 +a+0
 +18446744073709551615
 +DROP TABLE IF EXISTS t1;
 +#
 +# End of 10.2 tests
 +#
diff --cc mysql-test/r/view_grant.result
index 04ad19c5ddc,a1eb6e8bdb6..838ed7d5fd2
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@@ -204,8 -185,8 +206,9 @@@ create view mysqltest.v3 (a,c) as selec
  create user mysqltest_1 at localhost;
  grant update (a) on mysqltest.v2 to mysqltest_1 at localhost;
  grant update on mysqltest.v1 to mysqltest_1 at localhost;
+ grant update on mysqltest.t3 to mysqltest_1 at localhost;
  grant select on mysqltest.* to mysqltest_1 at localhost;
 +connection user1;
  use mysqltest;
  update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.c;
  select * from t1;
diff --cc mysql-test/std_data/serversan-cert.pem
index d40127365ca,b6494c29b00..41d5241a389
--- a/mysql-test/std_data/serversan-cert.pem
+++ b/mysql-test/std_data/serversan-cert.pem
@@@ -1,72 -1,60 +1,72 @@@
  Certificate:
      Data:
          Version: 3 (0x2)
--        Serial Number: 4 (0x4)
--    Signature Algorithm: sha256WithRSAEncryption
++        Serial Number: 1 (0x1)
++        Signature Algorithm: sha256WithRSAEncryption
          Issuer: CN=cacert, C=FI, ST=Helsinki, L=Helsinki, O=MariaDB
          Validity
-             Not Before: Jan 27 10:11:15 2019 GMT
-             Not After : Jan 22 10:11:15 2039 GMT
 -            Not Before: Apr 24 14:29:50 2019 GMT
 -            Not After : Apr 19 14:29:50 2039 GMT
++            Not Before: May  2 14:29:07 2019 GMT
++            Not After : Apr 27 14:29:07 2039 GMT
          Subject: C=FI, ST=Helsinki, L=Helsinki, O=MariaDB, CN=server
          Subject Public Key Info:
              Public Key Algorithm: rsaEncryption
-                 Public-Key: (2048 bit)
 -                Public-Key: (1024 bit)
++                RSA Public-Key: (2048 bit)
                  Modulus:
-                     00:be:e7:9b:da:e1:bf:fe:e6:a4:6d:c2:20:8a:1f:
-                     ea:8e:1a:a6:3f:57:93:75:d8:3b:80:55:bd:f3:fe:
-                     c3:1e:50:0f:e9:66:0e:bf:98:98:5f:06:95:fc:4a:
-                     9a:b2:fc:7f:b1:e0:d9:ef:df:6c:28:d0:12:98:bf:
-                     78:b6:f4:1a:94:83:a0:3e:bc:d3:b3:02:4f:4a:96:
-                     d9:30:b5:7c:5a:82:dd:ff:96:72:1c:f5:ad:80:bd:
-                     ec:f7:fa:9c:40:e2:37:f5:86:b7:c6:b0:bb:6a:69:
-                     77:77:e1:2a:b1:03:bb:1e:bb:e8:b3:7a:2c:bf:a6:
-                     c5:6b:4d:99:fb:f3:84:ec:ac:a9:2a:f3:f5:09:4e:
-                     5b:75:18:9c:68:f7:c9:2b:59:0b:41:33:60:23:fa:
-                     d4:f8:64:e2:51:59:37:29:f2:bb:68:f5:6a:47:69:
-                     58:ed:a8:bb:11:9d:6b:d1:77:75:01:da:57:5d:3e:
-                     8e:bf:f7:b1:7b:69:df:53:22:5f:7d:c5:ac:b0:80:
-                     0c:20:ea:9d:f7:c4:52:d8:31:03:07:b8:84:a9:74:
-                     e3:2e:4a:68:bf:a1:84:c6:38:32:c1:11:ef:f9:4b:
-                     e6:79:f4:7b:7f:52:f3:36:4b:a6:d8:a5:ad:d2:02:
-                     40:89:42:ed:ba:d6:ea:74:d0:6e:c1:bc:02:33:9f:
-                     0b:ab
 -                    00:c4:ca:f5:53:66:e9:f7:48:39:dc:8c:d7:06:f4:
 -                    03:3b:87:11:8e:8f:4d:a1:2b:b7:2a:38:37:6c:a2:
 -                    34:2f:d4:9d:84:78:99:7f:6b:ec:c3:63:ea:e8:9c:
 -                    57:af:a4:78:cf:59:5f:79:6b:29:11:2c:be:16:56:
 -                    8f:7b:76:57:c9:36:d5:7f:58:10:f3:d1:c2:dc:09:
 -                    17:f2:7b:fa:2d:71:c2:50:15:92:af:a0:58:32:f0:
 -                    64:60:d3:9a:c6:3c:8a:31:e0:b6:b2:9f:29:7d:97:
 -                    87:3c:62:bf:e6:8e:e7:2f:4a:ac:f7:fe:93:38:bc:
 -                    86:d4:87:91:38:2d:ed:e2:0d
++                    00:b1:17:08:8f:43:a3:00:01:98:3b:52:8f:0b:b0:
++                    13:4c:eb:df:37:0d:a3:2c:5b:38:8d:28:88:94:33:
++                    f3:04:0a:b2:1c:98:27:ec:76:9f:a2:f7:35:79:48:
++                    cc:55:1e:68:b4:a7:4d:40:0e:bd:d5:86:c0:e5:cc:
++                    cc:fa:41:5a:55:3f:79:59:28:6b:a2:ca:55:77:c9:
++                    3f:5e:c4:96:e1:8c:64:cc:c7:95:29:48:81:bf:a8:
++                    c0:d2:3a:6f:6d:a7:14:b5:ec:d8:b6:c1:d8:86:7f:
++                    7a:e9:83:c0:83:c3:e1:5a:30:dd:29:ec:85:68:d9:
++                    09:9a:75:eb:ab:5f:3d:b1:a3:4f:e2:de:54:35:56:
++                    9c:7d:8f:2a:4a:18:8d:34:05:05:b4:3b:5b:9e:df:
++                    40:20:ad:87:a3:6b:c1:f2:da:a3:65:ef:c4:cb:3c:
++                    24:68:43:23:e8:14:a7:c0:11:b7:5f:e9:e3:09:24:
++                    af:dd:ac:97:75:22:9e:15:b7:20:b0:82:b0:e1:0f:
++                    0f:41:fc:da:3b:76:0c:6b:f8:42:06:e2:9e:70:9a:
++                    ed:a1:73:23:58:5c:f1:98:18:42:42:d4:0f:2e:35:
++                    41:00:50:1d:15:e7:65:30:b5:db:72:7d:88:da:be:
++                    93:72:e3:65:14:fa:0d:23:98:d6:5c:a5:fc:bb:8a:
++                    8f:f9
                  Exponent: 65537 (0x10001)
          X509v3 extensions:
              X509v3 Subject Alternative Name: 
-                 DNS:localhost
+                 IP Address:127.0.0.1, DNS:localhost
      Signature Algorithm: sha256WithRSAEncryption
-          73:fa:07:e9:05:65:28:2e:72:91:29:f8:6b:a6:11:2e:e3:e2:
-          14:6c:4d:7e:69:16:01:47:55:df:88:8d:be:82:37:bd:95:4e:
-          cc:9c:71:98:fa:3b:0d:ad:13:53:e7:04:e7:6f:38:97:ce:12:
-          c1:f1:c2:48:bc:3f:a9:61:b5:22:48:e1:8c:64:1f:58:14:e9:
-          dd:5d:9f:e3:e7:78:5f:7d:43:6a:89:21:38:9d:65:e8:71:c1:
-          62:d9:62:c7:e6:b3:bd:cb:de:f1:7c:46:10:53:28:8c:47:02:
-          22:91:ad:78:c0:21:10:28:a8:2c:23:a3:f2:c0:2c:c9:71:0d:
-          b4:a0:ca:37:ac:36:b3:1c:75:6a:74:85:a5:ba:c2:19:de:e4:
-          3e:c2:3c:a4:cc:dc:8e:a7:08:36:f4:e9:81:32:ac:49:f4:34:
-          89:84:e7:61:54:29:7b:c0:54:53:b9:73:37:58:21:32:56:01:
-          7f:97:d3:a1:06:5b:06:14:19:6a:42:5d:45:5a:ba:8e:14:d7:
-          df:49:46:f2:83:7a:f0:d6:25:52:37:39:ae:37:ea:67:5f:7f:
-          7b:6d:f1:42:c9:0f:44:4d:f7:39:2d:39:78:12:93:42:1b:4a:
-          6d:f8:76:48:78:41:e9:a1:0b:78:fd:ad:29:f1:28:62:b8:9f:
-          f7:22:39:3b
 -         c5:83:b2:bb:a3:3b:a9:42:df:de:30:db:09:90:e1:3e:7a:19:
 -         09:4b:82:a3:1d:e8:23:3f:61:46:b7:98:b3:2e:90:61:7f:c5:
 -         a1:36:a6:3e:b0:5b:3f:a1:23:70:7d:0f:71:5b:13:0f:be:73:
 -         1b:31:1a:b3:ce:f7:59:aa:b4:18:8d:37:e1:8c:07:af:10:18:
 -         4e:37:16:b2:67:73:5b:79:c6:30:16:ab:62:c5:c2:3e:72:06:
 -         fd:b2:2a:f5:92:99:32:7e:ed:65:7e:bd:b2:74:9d:38:d4:d5:
 -         35:f8:06:dd:ac:85:75:e7:c2:6b:16:e8:2f:0f:c4:d3:b7:e7:
 -         be:b6:cd:61:7b:29:e6:3a:c2:7c:38:46:fb:2c:a3:da:fe:84:
 -         5f:79:99:2f:80:3e:ec:09:88:f4:31:cd:5c:d1:32:a1:9f:1f:
 -         55:f2:9b:c6:4e:b2:26:04:9b:ee:04:42:d2:40:88:0e:c8:cf:
 -         e0:6e:06:a1:6a:c8:1a:62:d0:7a:a4:19:4d:9c:e4:b6:57:e2:
 -         1d:19:57:54:58:1b:cc:bf:b8:29:e2:15:1e:f1:96:be:30:9e:
 -         4c:05:f9:90:e3:a1:7b:d7:e0:63:a6:d1:25:b1:80:81:f3:1b:
 -         55:4f:c1:64:9f:a1:06:01:8c:9a:15:64:b9:12:96:a8:22:4b:
 -         4a:d9:e3:04
++         7e:97:8a:e9:81:e7:c9:44:0d:a6:45:7c:f6:ae:12:f9:c3:3c:
++         2c:1f:de:aa:6b:1b:1a:09:ce:9d:d2:d7:5c:ab:32:98:91:1e:
++         f8:7d:63:7a:c0:d3:34:eb:3a:55:b2:cd:f5:99:5f:95:bb:3e:
++         52:1d:05:2d:06:26:08:d1:e8:59:09:61:64:67:70:6d:5b:94:
++         2b:b4:0c:59:88:bf:56:c8:fe:73:7f:47:e9:b0:e5:46:71:26:
++         73:5f:d2:a0:81:4a:67:43:7a:18:2a:81:5b:2a:90:a9:3e:7b:
++         73:6e:83:b5:55:06:75:d1:8c:d1:d8:ad:7c:6a:ce:48:00:dd:
++         c2:1d:b9:40:cd:91:2f:43:c4:d6:f4:79:5e:5c:83:23:87:a7:
++         38:3c:d8:49:81:d2:eb:49:c7:f0:5f:3d:6e:a0:38:75:ca:92:
++         ce:d5:a7:54:fc:0e:7e:f4:14:66:77:79:93:bb:92:56:ab:f3:
++         1b:3c:75:57:4f:2d:12:6d:99:5b:d0:b5:62:b7:1d:e3:5b:a9:
++         70:cd:58:41:77:a6:2c:6d:34:bd:11:13:7d:ca:51:3e:06:f5:
++         cb:d4:d5:11:64:b0:cc:30:2f:a5:62:d0:dd:2c:8c:66:3f:df:
++         2a:df:4d:56:99:5c:12:af:ee:92:e1:02:f6:ce:12:be:99:fa:
++         cc:0c:5c:af
  -----BEGIN CERTIFICATE-----
- MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQsFADBWMQ8wDQYDVQQDDAZjYWNl
 -MIICwTCCAamgAwIBAgIBBDANBgkqhkiG9w0BAQsFADBWMQ8wDQYDVQQDDAZjYWNl
++MIIDRTCCAi2gAwIBAgIBATANBgkqhkiG9w0BAQsFADBWMQ8wDQYDVQQDDAZjYWNl
  cnQxCzAJBgNVBAYTAkZJMREwDwYDVQQIDAhIZWxzaW5raTERMA8GA1UEBwwISGVs
- c2lua2kxEDAOBgNVBAoMB01hcmlhREIwHhcNMTkwMTI3MTAxMTE1WhcNMzkwMTIy
- MTAxMTE1WjBWMQswCQYDVQQGEwJGSTERMA8GA1UECAwISGVsc2lua2kxETAPBgNV
 -c2lua2kxEDAOBgNVBAoMB01hcmlhREIwHhcNMTkwNDI0MTQyOTUwWhcNMzkwNDE5
 -MTQyOTUwWjBWMQswCQYDVQQGEwJGSTERMA8GA1UECAwISGVsc2lua2kxETAPBgNV
++c2lua2kxEDAOBgNVBAoMB01hcmlhREIwHhcNMTkwNTAyMTQyOTA3WhcNMzkwNDI3
++MTQyOTA3WjBWMQswCQYDVQQGEwJGSTERMA8GA1UECAwISGVsc2lua2kxETAPBgNV
  BAcMCEhlbHNpbmtpMRAwDgYDVQQKDAdNYXJpYURCMQ8wDQYDVQQDDAZzZXJ2ZXIw
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+55va4b/+5qRtwiCKH+qO
- GqY/V5N12DuAVb3z/sMeUA/pZg6/mJhfBpX8Spqy/H+x4Nnv32wo0BKYv3i29BqU
- g6A+vNOzAk9KltkwtXxagt3/lnIc9a2Avez3+pxA4jf1hrfGsLtqaXd34SqxA7se
- u+izeiy/psVrTZn784TsrKkq8/UJTlt1GJxo98krWQtBM2Aj+tT4ZOJRWTcp8rto
- 9WpHaVjtqLsRnWvRd3UB2lddPo6/97F7ad9TIl99xaywgAwg6p33xFLYMQMHuISp
- dOMuSmi/oYTGODLBEe/5S+Z59Ht/UvM2S6bYpa3SAkCJQu261up00G7BvAIznwur
- AgMBAAGjGDAWMBQGA1UdEQQNMAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsFAAOC
- AQEAc/oH6QVlKC5ykSn4a6YRLuPiFGxNfmkWAUdV34iNvoI3vZVOzJxxmPo7Da0T
- U+cE5284l84SwfHCSLw/qWG1IkjhjGQfWBTp3V2f4+d4X31DaokhOJ1l6HHBYtli
- x+azvcve8XxGEFMojEcCIpGteMAhECioLCOj8sAsyXENtKDKN6w2sxx1anSFpbrC
- Gd7kPsI8pMzcjqcINvTpgTKsSfQ0iYTnYVQpe8BUU7lzN1ghMlYBf5fToQZbBhQZ
- akJdRVq6jhTX30lG8oN68NYlUjc5rjfqZ19/e23xQskPRE33OS05eBKTQhtKbfh2
- SHhB6aELeP2tKfEoYrif9yI5Ow==
 -gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMTK9VNm6fdIOdyM1wb0AzuHEY6P
 -TaErtyo4N2yiNC/UnYR4mX9r7MNj6uicV6+keM9ZX3lrKREsvhZWj3t2V8k21X9Y
 -EPPRwtwJF/J7+i1xwlAVkq+gWDLwZGDTmsY8ijHgtrKfKX2Xhzxiv+aO5y9KrPf+
 -kzi8htSHkTgt7eINAgMBAAGjHjAcMBoGA1UdEQQTMBGHBH8AAAGCCWxvY2FsaG9z
 -dDANBgkqhkiG9w0BAQsFAAOCAQEAxYOyu6M7qULf3jDbCZDhPnoZCUuCox3oIz9h
 -RreYsy6QYX/FoTamPrBbP6EjcH0PcVsTD75zGzEas873Waq0GI034YwHrxAYTjcW
 -smdzW3nGMBarYsXCPnIG/bIq9ZKZMn7tZX69snSdONTVNfgG3ayFdefCaxboLw/E
 -07fnvrbNYXsp5jrCfDhG+yyj2v6EX3mZL4A+7AmI9DHNXNEyoZ8fVfKbxk6yJgSb
 -7gRC0kCIDsjP4G4GoWrIGmLQeqQZTZzktlfiHRlXVFgbzL+4KeIVHvGWvjCeTAX5
 -kOOhe9fgY6bRJbGAgfMbVU/BZJ+hBgGMmhVkuRKWqCJLStnjBA==
++ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCxFwiPQ6MAAZg7Uo8LsBNM
++6983DaMsWziNKIiUM/MECrIcmCfsdp+i9zV5SMxVHmi0p01ADr3VhsDlzMz6QVpV
++P3lZKGuiylV3yT9exJbhjGTMx5UpSIG/qMDSOm9tpxS17Ni2wdiGf3rpg8CDw+Fa
++MN0p7IVo2QmadeurXz2xo0/i3lQ1Vpx9jypKGI00BQW0O1ue30AgrYeja8Hy2qNl
++78TLPCRoQyPoFKfAEbdf6eMJJK/drJd1Ip4VtyCwgrDhDw9B/No7dgxr+EIG4p5w
++mu2hcyNYXPGYGEJC1A8uNUEAUB0V52UwtdtyfYjavpNy42UU+g0jmNZcpfy7io/5
++AgMBAAGjHjAcMBoGA1UdEQQTMBGHBH8AAAGCCWxvY2FsaG9zdDANBgkqhkiG9w0B
++AQsFAAOCAQEAfpeK6YHnyUQNpkV89q4S+cM8LB/eqmsbGgnOndLXXKsymJEe+H1j
++esDTNOs6VbLN9Zlflbs+Uh0FLQYmCNHoWQlhZGdwbVuUK7QMWYi/Vsj+c39H6bDl
++RnEmc1/SoIFKZ0N6GCqBWyqQqT57c26DtVUGddGM0ditfGrOSADdwh25QM2RL0PE
++1vR5XlyDI4enODzYSYHS60nH8F89bqA4dcqSztWnVPwOfvQUZnd5k7uSVqvzGzx1
++V08tEm2ZW9C1Yrcd41upcM1YQXemLG00vRETfcpRPgb1y9TVEWSwzDAvpWLQ3SyM
++Zj/fKt9NVplcEq/ukuEC9s4Svpn6zAxcrw==
  -----END CERTIFICATE-----
diff --cc mysql-test/std_data/serversan-key.pem
index 84c34d63b0f,0fcb42b4f63..22387b3af7d
--- a/mysql-test/std_data/serversan-key.pem
+++ b/mysql-test/std_data/serversan-key.pem
@@@ -1,28 -1,16 +1,28 @@@
  -----BEGIN PRIVATE KEY-----
- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+55va4b/+5qRt
- wiCKH+qOGqY/V5N12DuAVb3z/sMeUA/pZg6/mJhfBpX8Spqy/H+x4Nnv32wo0BKY
- v3i29BqUg6A+vNOzAk9KltkwtXxagt3/lnIc9a2Avez3+pxA4jf1hrfGsLtqaXd3
- 4SqxA7seu+izeiy/psVrTZn784TsrKkq8/UJTlt1GJxo98krWQtBM2Aj+tT4ZOJR
- WTcp8rto9WpHaVjtqLsRnWvRd3UB2lddPo6/97F7ad9TIl99xaywgAwg6p33xFLY
- MQMHuISpdOMuSmi/oYTGODLBEe/5S+Z59Ht/UvM2S6bYpa3SAkCJQu261up00G7B
- vAIznwurAgMBAAECggEATXOwMuyWNbejjHhPNVrfkcnUGyzPweb5tQaUa5K33OuE
- mR/z6d3iK+ODJHmsK+Pvdt6P7RcLTb+lW92K/0coJYsFj46SoTTVsKBk+7MWAa7I
- nLKQF5nBS9NCehVuIZDmPTHsC6uWTgT+GF/9LxYha8W3EmIGF7d0ryUrzSGuk0qA
- yVj4V2JbEbox5jjRUvRvCfbQnZYhT1Aa1/kN4fxYp00sQTkCQ1QZiC+SbN245nrv
- UHumVBy0dPL+vmYxKc+L9qwYhHKsspx6+RUTgW+7YbHs6LEd8HmXb0hIp1Xb4yUS
- ADVI7TgTGEGGRt1gQYkfcwl1YoVQeyBK8Yvfz88tgQKBgQD9PeBEXM+y7z8jcXAB
- f/JpmMmm+S8JhPyKOMDZRL5jPKgm93Xm0pAReo8xM/quKH2jAoMxmburnYTTskyo
- HBATcWDTBUiNkjCJORdWKwP6kvtYt8ZZsC9vrWkx4pPqTXQaXUNmrfZ1cuh5U/BK
- 5aAzN5Drx0tKie+/+2gvevoZawKBgQDA++qDlRAiNft7fEZhjA3ovOSq9kIf1hnE
- psh4SRB21QZ443gifQKRRFIhMWRX0QkTyw2PbeVJvPjab08NmcumJWK5NCxPy3C0
- /ihQV2Ip49GVYA2qlgVzOMuxJJlG6SyKvCiBmadHY/ex4Ya1YPcfhjKsNr4ObIV8
- OCvQruQmwQKBgB+jp21jGyAD/CN1fMTzM1o2GJuf7lyGHPc3+AAtMow7e9bCfByG
- mjFU2qcPE3bG4EuJeNKtnmDmoT3BvQoT135WX/59Xn8xkJbUZzIA1dJsorKG42U5
- OfP9+nKdGFXhr2vL0yv0+CHcZWcjMZZp8gX0H0sV7zY03Zti0bV869pZAoGBALDg
- c+IkJoRkm9ljXxKbDkiJkMBNMvABCN8fyk/ND8UKnIMCYaKil07Tor7/iSuf0MUO
- b6BNJkE+bYuvR3J8ypW+YEzFT/PWz7dj10lDvhoMz5QsVHpMRDSGEtOKat3+ay/B
- IxMd5J7fNjAYN6JYfEetdRY4mluYBYSD60y6byxBAoGBALDoRoub5TUMdgr66fNp
- p7tc9ERH8/htPEq5g2SrzQex7lUIp8+wmvprx0i4a2SgDYCkj6gmjG8rP2O65tsn
- dkrKXnUOjIgjHGesbZoKgE+7Gl4c+eyoDsNVHH+ZFKN26fcO9i6wrbeGKjTTMcfu
- nEXqAq0CccdZ0lXxQTS/ttbU
 -MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMTK9VNm6fdIOdyM
 -1wb0AzuHEY6PTaErtyo4N2yiNC/UnYR4mX9r7MNj6uicV6+keM9ZX3lrKREsvhZW
 -j3t2V8k21X9YEPPRwtwJF/J7+i1xwlAVkq+gWDLwZGDTmsY8ijHgtrKfKX2Xhzxi
 -v+aO5y9KrPf+kzi8htSHkTgt7eINAgMBAAECgYAKFt29COm1494TkKT1lk0UIDim
 -NnKkcLlTUM6Go0pJqXzp7cTw43egDN9eTaWxO512A/8BGp1gZAra2lVA3zBg6Yqb
 -QYJwT2s/DsCwFU0msw1sUr5ynJ4A/jQCwR6RzaP2xoJTPaczpoE+RiOmgvQ14GF4
 -sJEfAIJCw5OglICTgQJBAOK3yeiMSF6ic8OORkOHy8LdQAFGOsKwliQltxzvRXYZ
 -dWlHHAX+9l6rVC+o0rbooO4QEfJHn9ojjROr5+iIn2cCQQDeNbljgN+6K36r9Qmh
 -fuBy2Ot+wRO30T4ASFelgJ0aHYEngSGSRneMmbbgDFx7v7Y9k6yY9RPiSqYX+vCQ
 -425rAkAjfkpp0axyxFQDRX7Si6vmseSXTntch3C57/2e1ga12n57INrORYAkigYA
 -ABoc8IZhPrrQh04LRI2Nitgfm2P5AkBmqEFGk/JIKvHxdVoGrvv4cviQ7ZgzcsqH
 -DOTZBAsQVpMlcgXVcxKl9RnEdlF/pjkGR6QUYhzWjZAgQgFDnp6TAkBqIXYMvyp7
 -JRfbnhze+UBgjeCoE/wTv/DiXL1yi4uVVVm8luToFv9DPAyvms/guJ7Ade5HDHye
 -M/LZbE37/NYP
++MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCxFwiPQ6MAAZg7
++Uo8LsBNM6983DaMsWziNKIiUM/MECrIcmCfsdp+i9zV5SMxVHmi0p01ADr3VhsDl
++zMz6QVpVP3lZKGuiylV3yT9exJbhjGTMx5UpSIG/qMDSOm9tpxS17Ni2wdiGf3rp
++g8CDw+FaMN0p7IVo2QmadeurXz2xo0/i3lQ1Vpx9jypKGI00BQW0O1ue30AgrYej
++a8Hy2qNl78TLPCRoQyPoFKfAEbdf6eMJJK/drJd1Ip4VtyCwgrDhDw9B/No7dgxr
+++EIG4p5wmu2hcyNYXPGYGEJC1A8uNUEAUB0V52UwtdtyfYjavpNy42UU+g0jmNZc
++pfy7io/5AgMBAAECggEAP6QHb3TfHyFzk94Xihu80+fwT9iWy1n8+L2YV6pTqyAs
++4hnMPy5iMC6nCO8gf3ZuKn31RRAHKLVEnVD8WPMjg39MHL5p8BbGoEWygFwl3OiX
++UQBomm10M2xx3xsg8EcbKkXzm7oOFke55DF0/eVnFwJ4eJiHWSamTNwT1YJkqXFt
++kbYxxcpvjzFKuIOFXMTbS6OHGLHjuuyWffxEkbvM/bU13IFmDOzahLFPihcz7rFu
++CaFN9JSSj4jENPkYOiw+zTtJhgOMCoclAcNc4c5Gs95wk6pTxoj9kHJaaYqinVgI
++owUTgIXRhuixjWJd1dylgY3YvrRFENZlMe39cVKwAQKBgQDppB7Qf2FmejMYtJkA
++WmlDSy+LZnYAAYjTqIeSAlRXI91iDa9HqrdPucQkv6nPvL6yndZYIrq50BLNGiL+
++v/3Ok/9v3H8jAiCzwIuqAYoA2gHh4d4ZV9Vxoqu6CcX/2xOUL7CSOV5NkK+3Yrs7
++n47X4ILGihIKzz5GoSTHyb6zRwKBgQDCCX1jwSEnIDhPCuid4+6g1vjTvVtgVIf9
++87sds02duE8K5Uwjio7g3BlV1YzLv0jKNkUK+HuG/c7n9r0IVrs4of6t/bJjl7vJ
++RLl6ZkSybzzS2x2nYk23VZlInYWUdJS9kHlic+mXfJvJvBBwyz8WX7t2wQaTqlDu
++QCpuV+HCvwKBgDz4/q2swG9s7o7A+rjT32qXYXYArES+IcYS0iZxgy8mhezD431R
++ePtOYHiyqA81k5KrjDd+ALrjKTTrYDyZQBQ8HUpFAczSDlS6p/ga5LfqLNmVB1AX
++0vUP3b70M/7cXlSqyWqvnAOkAadbFb+umSmPRrGncKPvh7II9b9J0AGbAoGAMyD3
++BnMcfkfSLpnMQ9aMyZr7xCeQTWjY0MUJmEDoAdhQE6nqDy9yiLPWhTSZPhLwZkA4
++nzRssFxuydbNZsYb3UdqaYSBHhccZ2ORkDwke/Qtzc3pGXMg0V9f3a+MRFsX2n+Y
++TKYIdl9iWZ0Ro/cab5XYOumQBxcI7k7AH4VOutcCgYEA3JgQiYoiPohS9A49bPiF
++eDX1Ck3lgaEF72us6BfvLHTrbA/qYhVUlrbrU2P/gAy1uKDRYq5RAoNGDLdwatvE
++0hPYj1hc1DuPAAGG83/tSh2jfFVbZBw5xEDjLerkpQyop59dfTS0E/oSu6ebxIIg
++dHEwqlmDrrJv7WwUJUzuUJU=
  -----END PRIVATE KEY-----
diff --cc mysql-test/suite.pm
index 3849e4ef886,f90679e6f1f..fe68295340c
--- a/mysql-test/suite.pm
+++ b/mysql-test/suite.pm
@@@ -70,10 -68,11 +70,11 @@@ sub skip_combinations 
    }
    $skip{'include/check_ipv6.inc'} = 'No IPv6' unless ipv6_ok();
  
 -  $skip{'t/openssl_6975.test'} = 'no or too old openssl'
 +  $skip{'t/openssl_6975.test'} = 'no or wrong openssl version'
      unless $::mysqld_variables{'version-ssl-library'} =~ /OpenSSL (\S+)/
 -       and $1 ge "1.0.1d";
 +       and $1 ge "1.0.1d" and $1 lt "1.1.1";
  
+ 
    $skip{'t/ssl_7937.combinations'} = [ 'x509v3' ]
      unless $::mysqld_variables{'version-ssl-library'} =~ /OpenSSL (\S+)/
         and $1 ge "1.0.2";
diff --cc mysql-test/suite/binlog/r/binlog_mdev717.result
index 5fe80be651a,594032e7dd4..f9ec3a32845
--- a/mysql-test/suite/binlog/r/binlog_mdev717.result
+++ b/mysql-test/suite/binlog/r/binlog_mdev717.result
@@@ -18,12 -13,12 +18,14 @@@ SET DEBUG_SYNC= "now WAIT_FOR locked"
  SET DEBUG_SYNC= "before_wait_locked_pname SIGNAL release";
  CREATE EVENT mysqltest.e1 ON SCHEDULE EVERY 15 MINUTE DO BEGIN END;
  ERROR 42000: Unknown database 'mysqltest'
 +connection default;
  CREATE DATABASE mysqltest;
  CREATE EVENT mysqltest.e1 ON SCHEDULE EVERY 15 MINUTE DO BEGIN END;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  SET DEBUG_SYNC= "after_wait_locked_schema_name SIGNAL locked WAIT_FOR release";
  DROP DATABASE mysqltest;;
 +connection con1;
  SET DEBUG_SYNC= "now WAIT_FOR locked";
  SET DEBUG_SYNC= "before_wait_locked_pname SIGNAL release";
  ALTER EVENT mysqltest.e1 ON SCHEDULE EVERY 20 MINUTE DO BEGIN END;
diff --cc mysql-test/suite/funcs_1/r/is_routines_embedded.result
index 1fc9f90ae49,e5f476367e2..193265433aa
--- a/mysql-test/suite/funcs_1/r/is_routines_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_routines_embedded.result
@@@ -187,46 -159,34 +187,58 @@@ GRANT EXECUTE ON PROCEDURE db_datadict_
  TO 'testuser2'@'localhost';
  GRANT EXECUTE ON db_datadict_2.* TO 'testuser2'@'localhost';
  FLUSH PRIVILEGES;
 -# Establish connection testuser1 (user=testuser1)
 +connect  testuser1, localhost, testuser1, , db_datadict;
  SELECT * FROM information_schema.routines;
 -SPECIFIC_NAME	ROUTINE_CATALOG	ROUTINE_SCHEMA	ROUTINE_NAME	ROUTINE_TYPE	DTD_IDENTIFIER	ROUTINE_BODY	ROUTINE_DEFINITION	EXTERNAL_NAME	EXTERNAL_LANGUAGE	PARAMETER_STYLE	IS_DETERMINISTIC	SQL_DATA_ACCESS	SQL_PATH	SECURITY_TYPE	CREATED	LAST_ALTERED	SQL_MODE	ROUTINE_COMMENT	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
 -sp_6_408002_1	NULL	db_datadict	sp_6_408002_1	PROCEDURE	NULL	SQL	BEGIN
 +SPECIFIC_NAME	ROUTINE_CATALOG	ROUTINE_SCHEMA	ROUTINE_NAME	ROUTINE_TYPE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	DATETIME_PRECISION	CHARACTER_SET_NAME	COLLATION_NAME	DTD_IDENTIFIER	ROUTINE_BODY	ROUTINE_DEFINITION	EXTERNAL_NAME	EXTERNAL_LANGUAGE	PARAMETER_STYLE	IS_DETERMINISTIC	SQL_DATA_ACCESS	SQL_PATH	SECURITY_TYPE	CREATED	LAST_ALTERED	SQL_MODE	ROUTINE_COMMENT	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
 +sp_6_408002_1	def	db_datadict	sp_6_408002_1	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN
  SELECT * FROM db_datadict.res_6_408002_1;
  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 -sp_6_408002_2	NULL	db_datadict_2	sp_6_408002_2	PROCEDURE	NULL	SQL	BEGIN
 +sp_6_408002_2	def	db_datadict_2	sp_6_408002_2	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN
  SELECT * FROM db_datadict_2.res_6_408002_2;
  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 -# Establish connection testuser2 (user=testuser2)
 +add_suppression	def	mtr	add_suppression	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN   INSERT INTO test_suppressions (pattern) VALUES (pattern);   FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions; END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
 +check_testcase	def	mtr	check_testcase	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN    SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES     WHERE variable_name NOT IN ('timestamp', 'innodb_file_format_max')      AND variable_name not like "Last_IO_Err*"      AND variable_name != 'INNODB_IBUF_MAX_SIZE'      AND variable_name != 'INNODB_USE_NATIVE_AIO'      AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP'      AND variable_name not like 'GTID%POS'      AND variable_name != 'GTID_BINLOG_STATE'    ORDER BY variable_name;    SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;    SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema');    SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES     WHERE table_schema='test';    SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql     FROM INFORMATION_SCHEMA.TABLES       WHERE table_schema='mysql'         ORDER BY tables_in_mysql;   SELECT CONCAT(
 table_schema, '.', table_name) AS columns_in_mysql,   	 column_name, ordinal_position, column_default, is_nullable,          data_type, character_maximum_length, character_octet_length,          numeric_precision, numeric_scale, character_set_name,          collation_name, column_type, column_key, extra, column_comment     FROM INFORMATION_SCHEMA.COLUMNS       WHERE table_schema='mysql'         ORDER BY columns_in_mysql;    SELECT * FROM INFORMATION_SCHEMA.EVENTS;   SELECT * FROM INFORMATION_SCHEMA.TRIGGERS          WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert');   SELECT * FROM INFORMATION_SCHEMA.ROUTINES;    SHOW STATUS LIKE 'slave_open_temp_tables';    checksum table     mysql.columns_priv,     mysql.db,     mysql.func,     mysql.help_category,     mysql.help_keyword,     mysql.help_relation,     mysql.host,     mysql.plugin,     mysql.proc,     mysql.procs_priv,     mysql.roles_mapping,     mysql.tables_priv,     mysql.time_zone,     mysql.time_zone_leap_second,   
   mysql.time_zone_name,     mysql.time_zone_transition,     mysql.time_zone_transition_type,     mysql.user;    SELECT * FROM INFORMATION_SCHEMA.PLUGINS;    select * from information_schema.session_variables     where variable_name = 'debug_sync';  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
 +check_warnings	def	mtr	check_warnings	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN   DECLARE `pos` bigint unsigned;    SET SQL_LOG_BIN=0;    UPDATE error_log el, global_suppressions gs     SET suspicious=0       WHERE el.suspicious=1 AND el.line REGEXP gs.pattern;    UPDATE error_log el, test_suppressions ts     SET suspicious=0       WHERE el.suspicious=1 AND el.line REGEXP ts.pattern;    SELECT COUNT(*) INTO @num_warnings FROM error_log     WHERE suspicious=1;    IF @num_warnings > 0 THEN     SELECT line         FROM error_log WHERE suspicious=1;     SELECT 2 INTO result;   ELSE     SELECT 0 INTO RESULT;   END IF;    TRUNCATE test_suppressions;   DROP TABLE error_log;  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
++AddGeometryColumn	def	mysql	AddGeometryColumn	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	begin
++  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	INVOKER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
++DropGeometryColumn	def	mysql	DropGeometryColumn	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	begin
++  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	INVOKER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 +connect  testuser2, localhost, testuser2, , db_datadict;
  SELECT * FROM information_schema.routines;
 -SPECIFIC_NAME	ROUTINE_CATALOG	ROUTINE_SCHEMA	ROUTINE_NAME	ROUTINE_TYPE	DTD_IDENTIFIER	ROUTINE_BODY	ROUTINE_DEFINITION	EXTERNAL_NAME	EXTERNAL_LANGUAGE	PARAMETER_STYLE	IS_DETERMINISTIC	SQL_DATA_ACCESS	SQL_PATH	SECURITY_TYPE	CREATED	LAST_ALTERED	SQL_MODE	ROUTINE_COMMENT	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
 -sp_6_408002_1	NULL	db_datadict	sp_6_408002_1	PROCEDURE	NULL	SQL	BEGIN
 +SPECIFIC_NAME	ROUTINE_CATALOG	ROUTINE_SCHEMA	ROUTINE_NAME	ROUTINE_TYPE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	DATETIME_PRECISION	CHARACTER_SET_NAME	COLLATION_NAME	DTD_IDENTIFIER	ROUTINE_BODY	ROUTINE_DEFINITION	EXTERNAL_NAME	EXTERNAL_LANGUAGE	PARAMETER_STYLE	IS_DETERMINISTIC	SQL_DATA_ACCESS	SQL_PATH	SECURITY_TYPE	CREATED	LAST_ALTERED	SQL_MODE	ROUTINE_COMMENT	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
 +sp_6_408002_1	def	db_datadict	sp_6_408002_1	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN
  SELECT * FROM db_datadict.res_6_408002_1;
  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 -sp_6_408002_2	NULL	db_datadict_2	sp_6_408002_2	PROCEDURE	NULL	SQL	BEGIN
 +sp_6_408002_2	def	db_datadict_2	sp_6_408002_2	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN
  SELECT * FROM db_datadict_2.res_6_408002_2;
  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 -# Establish connection testuser3 (user=testuser3)
 +add_suppression	def	mtr	add_suppression	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN   INSERT INTO test_suppressions (pattern) VALUES (pattern);   FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions; END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
 +check_testcase	def	mtr	check_testcase	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN    SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES     WHERE variable_name NOT IN ('timestamp', 'innodb_file_format_max')      AND variable_name not like "Last_IO_Err*"      AND variable_name != 'INNODB_IBUF_MAX_SIZE'      AND variable_name != 'INNODB_USE_NATIVE_AIO'      AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP'      AND variable_name not like 'GTID%POS'      AND variable_name != 'GTID_BINLOG_STATE'    ORDER BY variable_name;    SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;    SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema');    SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES     WHERE table_schema='test';    SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql     FROM INFORMATION_SCHEMA.TABLES       WHERE table_schema='mysql'         ORDER BY tables_in_mysql;   SELECT CONCAT(
 table_schema, '.', table_name) AS columns_in_mysql,   	 column_name, ordinal_position, column_default, is_nullable,          data_type, character_maximum_length, character_octet_length,          numeric_precision, numeric_scale, character_set_name,          collation_name, column_type, column_key, extra, column_comment     FROM INFORMATION_SCHEMA.COLUMNS       WHERE table_schema='mysql'         ORDER BY columns_in_mysql;    SELECT * FROM INFORMATION_SCHEMA.EVENTS;   SELECT * FROM INFORMATION_SCHEMA.TRIGGERS          WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert');   SELECT * FROM INFORMATION_SCHEMA.ROUTINES;    SHOW STATUS LIKE 'slave_open_temp_tables';    checksum table     mysql.columns_priv,     mysql.db,     mysql.func,     mysql.help_category,     mysql.help_keyword,     mysql.help_relation,     mysql.host,     mysql.plugin,     mysql.proc,     mysql.procs_priv,     mysql.roles_mapping,     mysql.tables_priv,     mysql.time_zone,     mysql.time_zone_leap_second,   
   mysql.time_zone_name,     mysql.time_zone_transition,     mysql.time_zone_transition_type,     mysql.user;    SELECT * FROM INFORMATION_SCHEMA.PLUGINS;    select * from information_schema.session_variables     where variable_name = 'debug_sync';  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
 +check_warnings	def	mtr	check_warnings	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN   DECLARE `pos` bigint unsigned;    SET SQL_LOG_BIN=0;    UPDATE error_log el, global_suppressions gs     SET suspicious=0       WHERE el.suspicious=1 AND el.line REGEXP gs.pattern;    UPDATE error_log el, test_suppressions ts     SET suspicious=0       WHERE el.suspicious=1 AND el.line REGEXP ts.pattern;    SELECT COUNT(*) INTO @num_warnings FROM error_log     WHERE suspicious=1;    IF @num_warnings > 0 THEN     SELECT line         FROM error_log WHERE suspicious=1;     SELECT 2 INTO result;   ELSE     SELECT 0 INTO RESULT;   END IF;    TRUNCATE test_suppressions;   DROP TABLE error_log;  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
++AddGeometryColumn	def	mysql	AddGeometryColumn	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	begin
++  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	INVOKER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
++DropGeometryColumn	def	mysql	DropGeometryColumn	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	begin
++  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	INVOKER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 +connect  testuser3, localhost, testuser3, , test;
  SELECT * FROM information_schema.routines;
 -SPECIFIC_NAME	ROUTINE_CATALOG	ROUTINE_SCHEMA	ROUTINE_NAME	ROUTINE_TYPE	DTD_IDENTIFIER	ROUTINE_BODY	ROUTINE_DEFINITION	EXTERNAL_NAME	EXTERNAL_LANGUAGE	PARAMETER_STYLE	IS_DETERMINISTIC	SQL_DATA_ACCESS	SQL_PATH	SECURITY_TYPE	CREATED	LAST_ALTERED	SQL_MODE	ROUTINE_COMMENT	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
 -sp_6_408002_1	NULL	db_datadict	sp_6_408002_1	PROCEDURE	NULL	SQL	BEGIN
 +SPECIFIC_NAME	ROUTINE_CATALOG	ROUTINE_SCHEMA	ROUTINE_NAME	ROUTINE_TYPE	DATA_TYPE	CHARACTER_MAXIMUM_LENGTH	CHARACTER_OCTET_LENGTH	NUMERIC_PRECISION	NUMERIC_SCALE	DATETIME_PRECISION	CHARACTER_SET_NAME	COLLATION_NAME	DTD_IDENTIFIER	ROUTINE_BODY	ROUTINE_DEFINITION	EXTERNAL_NAME	EXTERNAL_LANGUAGE	PARAMETER_STYLE	IS_DETERMINISTIC	SQL_DATA_ACCESS	SQL_PATH	SECURITY_TYPE	CREATED	LAST_ALTERED	SQL_MODE	ROUTINE_COMMENT	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
 +sp_6_408002_1	def	db_datadict	sp_6_408002_1	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN
  SELECT * FROM db_datadict.res_6_408002_1;
  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 -sp_6_408002_2	NULL	db_datadict_2	sp_6_408002_2	PROCEDURE	NULL	SQL	BEGIN
 +sp_6_408002_2	def	db_datadict_2	sp_6_408002_2	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN
  SELECT * FROM db_datadict_2.res_6_408002_2;
  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 -# Switch to connection default and close connections testuser1,testuser2,testuser3
 +add_suppression	def	mtr	add_suppression	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN   INSERT INTO test_suppressions (pattern) VALUES (pattern);   FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions; END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
 +check_testcase	def	mtr	check_testcase	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN    SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES     WHERE variable_name NOT IN ('timestamp', 'innodb_file_format_max')      AND variable_name not like "Last_IO_Err*"      AND variable_name != 'INNODB_IBUF_MAX_SIZE'      AND variable_name != 'INNODB_USE_NATIVE_AIO'      AND variable_name != 'INNODB_BUFFER_POOL_LOAD_AT_STARTUP'      AND variable_name not like 'GTID%POS'      AND variable_name != 'GTID_BINLOG_STATE'    ORDER BY variable_name;    SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;    SELECT * FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('mtr_wsrep_notify', 'wsrep_schema');    SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES     WHERE table_schema='test';    SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql     FROM INFORMATION_SCHEMA.TABLES       WHERE table_schema='mysql'         ORDER BY tables_in_mysql;   SELECT CONCAT(
 table_schema, '.', table_name) AS columns_in_mysql,   	 column_name, ordinal_position, column_default, is_nullable,          data_type, character_maximum_length, character_octet_length,          numeric_precision, numeric_scale, character_set_name,          collation_name, column_type, column_key, extra, column_comment     FROM INFORMATION_SCHEMA.COLUMNS       WHERE table_schema='mysql'         ORDER BY columns_in_mysql;    SELECT * FROM INFORMATION_SCHEMA.EVENTS;   SELECT * FROM INFORMATION_SCHEMA.TRIGGERS          WHERE TRIGGER_NAME NOT IN ('gs_insert', 'ts_insert');   SELECT * FROM INFORMATION_SCHEMA.ROUTINES;    SHOW STATUS LIKE 'slave_open_temp_tables';    checksum table     mysql.columns_priv,     mysql.db,     mysql.func,     mysql.help_category,     mysql.help_keyword,     mysql.help_relation,     mysql.host,     mysql.plugin,     mysql.proc,     mysql.procs_priv,     mysql.roles_mapping,     mysql.tables_priv,     mysql.time_zone,     mysql.time_zone_leap_second,   
   mysql.time_zone_name,     mysql.time_zone_transition,     mysql.time_zone_transition_type,     mysql.user;    SELECT * FROM INFORMATION_SCHEMA.PLUGINS;    select * from information_schema.session_variables     where variable_name = 'debug_sync';  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
 +check_warnings	def	mtr	check_warnings	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	BEGIN   DECLARE `pos` bigint unsigned;    SET SQL_LOG_BIN=0;    UPDATE error_log el, global_suppressions gs     SET suspicious=0       WHERE el.suspicious=1 AND el.line REGEXP gs.pattern;    UPDATE error_log el, test_suppressions ts     SET suspicious=0       WHERE el.suspicious=1 AND el.line REGEXP ts.pattern;    SELECT COUNT(*) INTO @num_warnings FROM error_log     WHERE suspicious=1;    IF @num_warnings > 0 THEN     SELECT line         FROM error_log WHERE suspicious=1;     SELECT 2 INTO result;   ELSE     SELECT 0 INTO RESULT;   END IF;    TRUNCATE test_suppressions;   DROP TABLE error_log;  END	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	DEFINER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	utf8	utf8_general_ci	latin1_swedish_ci
++AddGeometryColumn	def	mysql	AddGeometryColumn	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	begin
++  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	INVOKER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
++DropGeometryColumn	def	mysql	DropGeometryColumn	PROCEDURE		NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	SQL	begin
++  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end	NULL	NULL	SQL	NO	CONTAINS SQL	NULL	INVOKER	YYYY-MM-DD hh:mm:ss	YYYY-MM-DD hh:mm:ss			root at localhost	latin1	latin1_swedish_ci	latin1_swedish_ci
 +connection default;
 +disconnect testuser1;
 +disconnect testuser2;
 +disconnect testuser3;
  DROP USER 'testuser1'@'localhost';
  DROP USER 'testuser2'@'localhost';
  DROP USER 'testuser3'@'localhost';
diff --cc mysql-test/suite/galera/r/galera_events.result
index f01627aba70,80631442e08..e925e62cb91
--- a/mysql-test/suite/galera/r/galera_events.result
+++ b/mysql-test/suite/galera/r/galera_events.result
@@@ -1,6 -1,6 +1,8 @@@
 +connection node_1;
  CREATE EVENT event1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO SELECT 1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 +connection node_2;
  SELECT DEFINER= 'root at localhost', ORIGINATOR = 1, STATUS = 'SLAVESIDE_DISABLED', EVENT_TYPE = 'ONE TIME', ON_COMPLETION = 'NOT PRESERVE' FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME = 'event1';
  DEFINER= 'root at localhost'	ORIGINATOR = 1	STATUS = 'SLAVESIDE_DISABLED'	EVENT_TYPE = 'ONE TIME'	ON_COMPLETION = 'NOT PRESERVE'
  1	1	1	1	1
diff --cc mysql-test/suite/innodb/r/innodb-index.result
index b64fd27fb35,64c5586173e..bdc16ad7692
--- a/mysql-test/suite/innodb/r/innodb-index.result
+++ b/mysql-test/suite/innodb/r/innodb-index.result
@@@ -1211,701 -1211,32 +1211,728 @@@ CHECK TABLE t1
  Table	Op	Msg_type	Msg_text
  test.t1	check	status	OK
  DROP TABLE t1;
 -SET GLOBAL innodb_file_format=@save_format;
 -SET GLOBAL innodb_large_prefix=@save_prefix;
  #
+ # Bug#19811005 ALTER TABLE ADD INDEX DOES NOT UPDATE INDEX_LENGTH
+ # IN I_S TABLES
+ #
+ CREATE TABLE t1(a INT, b INT) ENGINE=INNODB, STATS_PERSISTENT=1;
+ SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
+ cast(INDEX_LENGTH/@@innodb_page_size as int) I
+ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
+ D	I
+ 1	0
+ ALTER TABLE t1 ADD INDEX (a);
+ affected rows: 0
+ info: Records: 0  Duplicates: 0  Warnings: 0
+ SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
+ cast(INDEX_LENGTH/@@innodb_page_size as int) I
+ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
+ D	I
+ 1	1
+ ALTER TABLE t1 ADD INDEX (b);
+ affected rows: 0
+ info: Records: 0  Duplicates: 0  Warnings: 0
+ SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
+ cast(INDEX_LENGTH/@@innodb_page_size as int) I
+ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
+ D	I
+ 1	2
+ DROP TABLE t1;
++#
 +# Bug #17657223	EXCESSIVE TEMPORARY FILE USAGE IN ALTER TABLE
 +#
 +SET GLOBAL innodb_monitor_enable = module_ddl;
 +create table t1(f1 int not null, f2 blob)engine=innodb;
 +insert into t1 values(1, repeat('a',20000));
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 force;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +drop table t1;
 +create table t1(f1 int not null, f2 int not null,
 +primary key(f1))engine=innodb;
 +insert into t1 values(1,2), (3,4);
 +# Add Secondary index.
 +# Skip temp file usage due to small table size
 +alter table t1 add key(f2);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +drop table t1;
 +create table t480(a serial)engine=innodb;
 +insert into t480
 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),
 +(),(),(),(),(),(),(),();
 +insert into t480 select 0 from t480;
 +insert into t480 select 0 from t480;
 +insert into t480 select 0 from t480;
 +insert into t480 select 0 from t480;
 +create table t1(f1 int auto_increment not null,
 +f2 char(200) not null, f3 char(200) not null,
 +f4 char(200) not null,primary key(f1))engine=innodb;
 +insert into t1 select NULL,'aaa','bbb','ccc' from t480;
 +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480;
 +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480;
 +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480;
 +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480;
 +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480;
 +select count(*) from t1;
 +count(*)
 +2880
 +# Skip sort
 +# Change PK from (f1) to (f1,f2,f3,f4)
 +alter table t1 drop primary key, add primary key(f1,f2,f3,f4);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Change PK from (f1,f2,f3,f4) to (f1,f2,added_columns)
 +alter table t1 drop primary key,add column f5 int not null,
 +add column f6 int not null,add primary key(f1,f2,f5,f6);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Change PK from (f1,f2,f5,f6) to (f1,f2,f5)
 +alter table t1 drop column f6;
 +ERROR 42000: Key column 'f6' doesn't exist in table
 +alter table t1 drop column f6, drop primary key, add primary key(f1,f2,f5);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same PK
 +alter table t1 add column f6 int;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 drop column f6;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Must sort
 +# Change PK from (f1,f2,f5) to (f1,f5)
 +alter table t1 drop column f2;
 +ERROR 42000: Key column 'f2' doesn't exist in table
 +alter table t1 drop column f2, drop primary key, add primary key(f1,f5);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +ddl_sort_file_alter_table	2
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 add column f2n int after f1, drop primary key, add
 +primary key (f1,f5,f2n);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 change f5 f2n int not null,change f2n f5 int not null,
 +add column f8 int not null;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Change PK from (f1,f4,f2n) to (f1,f4,added_column,f2n)
 +alter table t1 add column f7 int, drop primary key,
 +add primary key (f1,f5,f7,f2n);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +ddl_sort_file_alter_table	2
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 force;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 row_format=compact;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Reusing the same pk
 +alter table t1 engine=innodb;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Optimize table
 +optimize table t1;
 +Table	Op	Msg_type	Msg_text
 +test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
 +test.t1	optimize	status	OK
 +affected rows: 2
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Sort files used for adding secondary index
 +alter table t1 drop primary key, add primary key(f1,f5,f7), add index
 +i(f3);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# No sort files used for dropping secondary index
 +alter table t1 drop primary key, add primary key(f1,f5),drop index i;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Change PK(f1,f5) to (f1,added_columns) and drop f5
 +alter table t1 drop primary key, add primary key(f1,f12),
 +drop column f5, add column f12 int not null;
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Must sort
 +# Change PK(f1,f12) to (f1,existing_columns)
 +alter table t1 drop primary key, add primary key(f1,f3);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +ddl_sort_file_alter_table	2
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort
 +# Change PK(f1,f3) to (f1,added_column,f3,added_column)
 +alter table t1 drop primary key, add column f3n int,
 +add column f4n int, add primary key(f1,f3n,f3,f4n);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Adding Secondary index alone.
 +alter table t1 add key(f1);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Must sort
 +# Change PK(f1,f3) to (existing_column,f1)
 +alter table t1 drop primary key, add primary key(f4,f1);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +ddl_sort_file_alter_table	3
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort for PK.
 +# Change PK(f4,f1) to (added_columns,f4,f1)
 +# Secondary index rebuild happens
 +alter table t1 drop primary key, add column f5n int,
 +add column f6n int, add primary key(f5n,f6n,f4,f1);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +# Skip sort for PK.
 +# Change PK(f5n,f6n,f4,f1) to
 +# (added_columns,f5n,added_column,f6n,f4,f1)
 +# Secondary index rebuild happens
 +alter table t1 drop primary key, add column f7n int,
 +add column f8n int, add primary key(f7n,f5n,f8n,f6n,f4,f1);
 +affected rows: 0
 +info: Records: 0  Duplicates: 0  Warnings: 0
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +name	count_reset
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +SET GLOBAL innodb_monitor_disable = module_ddl;
 +select count(*) from t1;
 +count(*)
 +2880
 +drop table t1;
 +SET GLOBAL innodb_monitor_reset = default;
 +SET GLOBAL innodb_monitor_enable = default;
 +SET GLOBAL innodb_monitor_disable = default;
 +# Bug#19163915 INNODB: DUPLICATE RECORDS COULD EXIST
 +# WHEN SKIPPING SORT FOR CLUSTER INDEX
 +SELECT @@innodb_sort_buffer_size;
 +@@innodb_sort_buffer_size
 +1048576
 +create table t1(f1 int auto_increment not null,
 +f2 char(200) not null, f3 char(200) not null,
 +f4 char(200) not null,primary key(f1,f2,f3,f4));
 +insert into t1 select NULL,'aaa','bbb','ccc' from t480;
 +insert into t1 values(106, 'aaa','bbb','cccc');
 +select count(*) from t1;
 +count(*)
 +481
 +# Skip sort
 +# Change PK from (f1,f2,f3,f4) to (f1,f2,f3)
 +alter table t1 drop primary key, add primary key(f1,f2,f3);
 +ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '106-aaa-bbb' for key 'PRIMARY'
 +select count(*) from t1;
 +count(*)
 +481
 +drop table t1;
 +create table t1(f1 int auto_increment not null,
 +f2 char(200) not null, f3 char(200) not null,
 +f4 char(200) not null,primary key(f1,f2,f3,f4));
 +insert into t1 select NULL,'aaa','bbb','ccc' from t480;
 +insert into t1 values(108,'aaa','bbb','cccc');
 +select count(*) from t1;
 +count(*)
 +481
 +alter table t1 drop primary key, add primary key(f1,f2,f3);
 +ERROR 23000: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '108-aaa-bbb' for key 'PRIMARY'
 +select count(*) from t1;
 +count(*)
 +481
 +drop table t1, t480;
 +#
 +# Bug #19896922	SORTING SKIPPED WHEN PREFIX LENGTH OF THE PK
 +#		FIELD IS CHANGED
 +#
 +create table t1(a int not null, b varchar(30) not null,
 +primary key (b(10), a)) engine = innodb;
 +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UxW8L');
 +select * from t1;
 +a	b
 +0	khdHps6UxW8Lwaoxa604oK6zkb
 +1	khdHps6UxW8L
 +alter table t1 drop primary key, add primary key (b(18),a);
 +select * from t1;
 +a	b
 +1	khdHps6UxW8L
 +0	khdHps6UxW8Lwaoxa604oK6zkb
 +drop table t1;
 +create table t1(a int not null, b varchar(30) not null,
 +primary key (b(10), a)) engine = innodb;
 +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UtW8L');
 +select * from t1;
 +a	b
 +1	khdHps6UtW8L
 +0	khdHps6UxW8Lwaoxa604oK6zkb
 +alter table t1 drop primary key, add primary key (b(8),a);
 +select * from t1;
 +a	b
 +0	khdHps6UxW8Lwaoxa604oK6zkb
 +1	khdHps6UtW8L
 +drop table t1;
 +#
 +# Bug #21103101	SORTING SKIPPED WHEN DROPPING THE SINGLE
 +#			COLUMN PRIMARY KEY
 +#
 +create table t1(f1 int not null, f2 int not null,
 +primary key (f1), unique key(f1, f2))engine=innodb;
 +insert into t1 values(1,3), (2,2);
 +alter table t1 drop column f1;
 +ERROR 42000: Key column 'f1' doesn't exist in table
 +alter table t1 drop column f1, drop primary key;
 +ERROR 42000: Key column 'f1' doesn't exist in table
 +alter table t1 drop column f1, drop key f1;
 +drop table t1;
 +create table t1(f1 int not null, f2 int not null,
 +primary key (f1), unique key(f1, f2))engine=innodb;
 +insert into t1 values(1,3), (2,2);
 +alter table t1 drop primary key, lock=none;
 +alter table t1 drop index f1, lock=none;
 +ERROR 0A000: LOCK=NONE is not supported. Reason: Dropping a primary key is not allowed without also adding a new primary key. Try LOCK=SHARED
 +drop table t1;
 +#
 +#  BUG#21612714 ALTER TABLE SORTING SKIPPED WHEN CHANGE PK AND DROP
 +#		LAST COLUMN OF OLD PK
 +#
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3), drop o2, lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop o1, drop o2, add primary key(o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 add column n1 int not null, drop primary key, add primary key(n1,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 add column n1 int not null, drop primary key, add primary key(o3,n1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2, o1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o2,o1)) engine = innodb;
 +insert into t1 values(1,1,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o3,o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop o1, lock=none;
 +ERROR 42000: Key column 'o1' doesn't exist in table
 +alter table t1 drop o1, drop primary key, add primary key(o2,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop o2, lock=none;
 +ERROR 42000: Key column 'o2' doesn't exist in table
 +alter table t1 drop o2, drop primary key, add primary key(o1,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop o1, drop o2, lock=none;
 +ERROR 42000: Key column 'o2' doesn't exist in table
 +alter table t1 drop o1, drop o2,drop primary key,add primary key(o3),lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1(3), o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1, o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1(3), o3), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1, o3), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abc', 2, 1), ('abd', 1, 2);
 +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abc', 2, 1), ('abd', 1, 2);
 +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abc', 2, 2), ('abd', 1, 1);
 +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abc', 2, 2), ('abd', 1, 1);
 +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb;
 +insert into t1 values(1, 'abd', 1), (1, 'abc', 2);
 +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb;
 +insert into t1 values(1, 'abd', 1), (1, 'abc', 2);
 +alter table t1 drop primary key, add primary key(o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb;
 +insert into t1 values('abc', 'acd'), ('abd', 'abd');
 +alter table t1 drop primary key, add primary key(o1(2),o2(3)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb;
 +insert into t1 values('abc', 'acd'), ('abd', 'abd');
 +alter table t1 drop primary key, add primary key(o1(2),o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o2(3),o1(3)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o2,o1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb;
 +insert into t1 values('abd'), ('acd');
 +alter table t1 drop primary key, add primary key(o1(3)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb;
 +insert into t1 values('abd'), ('acd');
 +alter table t1 drop primary key, add primary key(o1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb;
 +insert into t1 values('abd'), ('acd');
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), n1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), primary key(o1(2))) engine = innodb;
 +insert into t1 values('abd'), ('acd');
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1, n1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3), o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int not null, primary key(o1(2))) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1, o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), primary key(o1(3))) engine = innodb;
 +insert into t1 values('abd'), ('acd');
 +alter table t1 drop primary key, add primary key(o1(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), primary key(o1)) engine = innodb;
 +insert into t1 values('abd'), ('acd');
 +alter table t1 drop primary key, add primary key(o1(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 drop primary key, add primary key(o1(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 drop primary key, add primary key(o1(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1(2),n1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1(3),n1), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abd', 1), ('acd', 2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(3))) engine = innodb;
 +insert into t1 values(1,'abd'), (2,'acd');
 +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,'abd'), (2,'acd');
 +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb;
 +insert into t1 values(1, 'abd'), (2, 'acd');
 +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), primary key(o1,o2(2))) engine = innodb;
 +insert into t1 values(1, 'abd'), (2, 'acd');
 +alter table t1 drop primary key, add primary key(o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(3),o3)) engine = innodb;
 +insert into t1 values(1, 'abd', 1), (2, 'acd', 2);
 +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1, 'abd', 1), (2, 'acd', 2);
 +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o1(3),o2(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o1,o2(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(2))) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o1(3),o2(3)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2(2))) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(2))) engine = innodb;
 +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd');
 +alter table t1 drop primary key, add primary key(o1(3),o2,o3(3)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(2))) engine = innodb;
 +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd');
 +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1(3),o2,o3(3))) engine = innodb;
 +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd');
 +alter table t1 drop primary key, add primary key(o1(3),o2,o3(2)), lock=none;
 +drop table t1;
 +create table t1(o1 varchar(10), o2 int, o3 varchar(10), primary key(o1,o2,o3(3))) engine = innodb;
 +insert into t1 values('abd', 1, 'acd'), ('acd', 2, 'abd');
 +alter table t1 drop primary key, add primary key(o1,o2,o3(2)), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 drop primary key, add primary key(o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,o1,n2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(n1,n2,o1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, add n2 int not null, drop primary key, add primary key(o1,n1,n2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1),(2,2);
 +alter table t1 add n1 int not null, drop primary key, add primary key(n1,o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 drop primary key, add primary key(o1,o2,o3), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int not null, o3 int not null, primary key(o1)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 drop primary key, add primary key(o1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, o4 int not null, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2,2),(2,2,1,1);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,o3,o4), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,o2,n1), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 add n1 int not null, drop primary key, add primary key(o1,n1,o2), lock=none;
 +drop table t1;
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 drop primary key, add primary key(o1), lock=none;
 +drop table t1;
 +#
 +# MDEV-15325 Incomplete validation of missing tablespace during recovery
 +#
 +CREATE TABLE t1(f1 INT PRIMARY KEY)ENGINE=InnoDB;
 +CREATE TABLE t2(f1 INT PRIMARY KEY)ENGINE=InnoDB;
 +# Kill the server
 +# Wrong space_id in a dirty file and a missing file
 +SELECT * FROM INFORMATION_SCHEMA.ENGINES
 +WHERE engine = 'innodb'
 +AND support IN ('YES', 'DEFAULT', 'ENABLED');
 +ENGINE	SUPPORT	COMMENT	TRANSACTIONS	XA	SAVEPOINTS
 +# Restore t1 and t2
 +SELECT * FROM t1;
 +f1
 +SELECT * FROM t2;
 +f1
 +DROP TABLE t1, t2;
 +#
 +#  MDEV-18186 assertion failure on missing InnoDB index
 +#
 +CREATE TABLE t (a INT, INDEX i1 (a)) ENGINE=INNODB;
 +DROP TABLE t;
 +CREATE TABLE t (a INT) ENGINE=INNODB;
 +SHOW CREATE TABLE t;
 +Table	Create Table
 +t	CREATE TABLE `t` (
 +  `a` int(11) DEFAULT NULL,
 +  KEY `i1` (`a`)
 +) ENGINE=InnoDB DEFAULT CHARSET=latin1
 +Warnings:
 +Warning	1082	InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB 
 +Warning	1082	InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB 
 +DROP TABLE t;
diff --cc mysql-test/suite/innodb/r/innodb-truncate.result
index a606868ae52,37ed19fa3fc..8610a892cc6
--- a/mysql-test/suite/innodb/r/innodb-truncate.result
+++ b/mysql-test/suite/innodb/r/innodb-truncate.result
@@@ -78,3 -66,16 +78,16 @@@
  1
  2
  DROP TABLE t1;
 -call mtr.add_suppression('InnoDB: Error: in RENAME TABLE table `test`.`t3`');
++call mtr.add_suppression('InnoDB: in RENAME TABLE table `test`.`t3`');
+ SET FOREIGN_KEY_CHECKS= OFF;
+ CREATE TABLE t1 (f2 INT, f4 INT, KEY(f2), FOREIGN KEY (f4) REFERENCES t3 (f4)) ENGINE=InnoDB;
+ SET FOREIGN_KEY_CHECKS= ON;
+ CREATE TABLE t2 (f2 INT, FOREIGN KEY(f2) REFERENCES t1 (f2)) ENGINE=InnoDB;
+ CREATE TABLE t3 (a INT) ENGINE=InnoDB;
+ ERROR HY000: Can't create table `test`.`t3` (errno: 150 "Foreign key constraint is incorrectly formed")
+ ALTER TABLE t1 RENAME TO t3;
+ ERROR HY000: Error on rename of './test/t1' to './test/t3' (errno: 150 "Foreign key constraint is incorrectly formed")
+ ALTER TABLE t1 FORCE;
+ TRUNCATE TABLE t1;
+ ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `test`.`t3` (`f2`))
+ DROP TABLE t2, t1;
diff --cc mysql-test/suite/innodb/r/xa_debug.result
index 902166f51c8,f1fd3f14220..7c2bd9f92c2
--- a/mysql-test/suite/innodb/r/xa_debug.result
+++ b/mysql-test/suite/innodb/r/xa_debug.result
@@@ -251,7 -201,7 +251,8 @@@ xa start 'test1'
  insert into t1 values(1);
  xa end 'test1';
  xa prepare 'test1';
 +connection default;
+ FLUSH TABLES;
  xa recover;
  formatID	gtrid_length	bqual_length	data
  1	5	0	test1
diff --cc mysql-test/suite/innodb/t/innodb-index.test
index 8bd3919af91,86ac1a8123e..474b0e08935
--- a/mysql-test/suite/innodb/t/innodb-index.test
+++ b/mysql-test/suite/innodb/t/innodb-index.test
@@@ -568,615 -591,25 +568,635 @@@ ALTER TABLE t1 ROW_FORMAT=REDUNDANT, al
  SELECT COUNT(*) FROM t1;
  CHECK TABLE t1;
  DROP TABLE t1;
 -SET GLOBAL innodb_file_format=@save_format;
 -SET GLOBAL innodb_large_prefix=@save_prefix;
  
+ --echo #
+ --echo # Bug#19811005 ALTER TABLE ADD INDEX DOES NOT UPDATE INDEX_LENGTH
+ --echo # IN I_S TABLES
+ --echo #
+ let $i_s_query=SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
+ cast(INDEX_LENGTH/@@innodb_page_size as int) I
+ FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
+ 
+ CREATE TABLE t1(a INT, b INT) ENGINE=INNODB, STATS_PERSISTENT=1;
+ eval $i_s_query;
+ --enable_info
+ ALTER TABLE t1 ADD INDEX (a);
+ --disable_info
+ eval $i_s_query;
+ --enable_info
+ ALTER TABLE t1 ADD INDEX (b);
+ --disable_info
+ eval $i_s_query;
+ DROP TABLE t1;
++
 +--echo #
 +--echo # Bug #17657223	EXCESSIVE TEMPORARY FILE USAGE IN ALTER TABLE
 +--echo #
 +
 +SET GLOBAL innodb_monitor_enable = module_ddl;
 +let $innodb_metrics_select=
 +SELECT name, count_reset FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE
 +subsystem = 'ddl' and count_reset > 0;
 +
 +# Table with Blob data.
 +create table t1(f1 int not null, f2 blob)engine=innodb;
 +insert into t1 values(1, repeat('a',20000));
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 force;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +drop table t1;
 +
 +# Table with small data.
 +create table t1(f1 int not null, f2 int not null,
 +primary key(f1))engine=innodb;
 +insert into t1 values(1,2), (3,4);
 +--echo # Add Secondary index.
 +--echo # Skip temp file usage due to small table size
 +--enable_info
 +alter table t1 add key(f2);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +drop table t1;
 +
 +# Table with large data which is greater than sort buffer
 +create table t480(a serial)engine=innodb;
 +insert into t480
 +values(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),
 +(),(),(),(),(),(),(),();
 +insert into t480 select 0 from t480;
 +insert into t480 select 0 from t480;
 +insert into t480 select 0 from t480;
 +insert into t480 select 0 from t480;
 +create table t1(f1 int auto_increment not null,
 +		f2 char(200) not null, f3 char(200) not null,
 +		f4 char(200) not null,primary key(f1))engine=innodb;
 +insert into t1 select NULL,'aaa','bbb','ccc' from t480;
 +insert into t1 select NULL,'aaaa','bbbb','cccc' from t480;
 +insert into t1 select NULL,'aaaaa','bbbbb','ccccc' from t480;
 +insert into t1 select NULL,'aaaaaa','bbbbbb','cccccc' from t480;
 +insert into t1 select NULL,'aaaaaaa','bbbbbbb','ccccccc' from t480;
 +insert into t1 select NULL,'aaaaaaaa','bbbbbbbb','cccccccc' from t480;
 +select count(*) from t1;
 +
 +--echo # Skip sort
 +--echo # Change PK from (f1) to (f1,f2,f3,f4)
 +--enable_info
 +alter table t1 drop primary key, add primary key(f1,f2,f3,f4);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +
 +# Temp file not used during clustered index rebuild
 +# for the following alter table commands.
 +
 +--echo # Skip sort
 +--echo # Change PK from (f1,f2,f3,f4) to (f1,f2,added_columns)
 +--enable_info
 +alter table t1 drop primary key,add column f5 int not null,
 +add column f6 int not null,add primary key(f1,f2,f5,f6);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Change PK from (f1,f2,f5,f6) to (f1,f2,f5)
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop column f6;
 +--enable_info
 +alter table t1 drop column f6, drop primary key, add primary key(f1,f2,f5);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same PK
 +--enable_info
 +alter table t1 add column f6 int;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 drop column f6;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Must sort
 +--echo # Change PK from (f1,f2,f5) to (f1,f5)
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop column f2;
 +--enable_info
 +alter table t1 drop column f2, drop primary key, add primary key(f1,f5);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 add column f2n int after f1, drop primary key, add
 +primary key (f1,f5,f2n);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 change f5 f2n int not null,change f2n f5 int not null,
 +add column f8 int not null;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Change PK from (f1,f4,f2n) to (f1,f4,added_column,f2n)
 +--enable_info
 +alter table t1 add column f7 int, drop primary key,
 +add primary key (f1,f5,f7,f2n);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 force;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 row_format=compact;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Reusing the same pk
 +--enable_info
 +alter table t1 engine=innodb;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Optimize table
 +--enable_info
 +optimize table t1;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Sort files used for adding secondary index
 +--enable_info
 +alter table t1 drop primary key, add primary key(f1,f5,f7), add index
 +i(f3);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # No sort files used for dropping secondary index
 +--enable_info
 +alter table t1 drop primary key, add primary key(f1,f5),drop index i;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Change PK(f1,f5) to (f1,added_columns) and drop f5
 +--enable_info
 +alter table t1 drop primary key, add primary key(f1,f12),
 +drop column f5, add column f12 int not null;
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Must sort
 +--echo # Change PK(f1,f12) to (f1,existing_columns)
 +--enable_info
 +alter table t1 drop primary key, add primary key(f1,f3);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort
 +--echo # Change PK(f1,f3) to (f1,added_column,f3,added_column)
 +--enable_info
 +alter table t1 drop primary key, add column f3n int,
 +add column f4n int, add primary key(f1,f3n,f3,f4n);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Adding Secondary index alone.
 +--enable_info
 +alter table t1 add key(f1);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Must sort
 +--echo # Change PK(f1,f3) to (existing_column,f1)
 +--enable_info
 +alter table t1 drop primary key, add primary key(f4,f1);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort for PK.
 +--echo # Change PK(f4,f1) to (added_columns,f4,f1)
 +--echo # Secondary index rebuild happens
 +--enable_info
 +alter table t1 drop primary key, add column f5n int,
 +add column f6n int, add primary key(f5n,f6n,f4,f1);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +--echo # Skip sort for PK.
 +--echo # Change PK(f5n,f6n,f4,f1) to
 +--echo # (added_columns,f5n,added_column,f6n,f4,f1)
 +--echo # Secondary index rebuild happens
 +--enable_info
 +alter table t1 drop primary key, add column f7n int,
 +add column f8n int, add primary key(f7n,f5n,f8n,f6n,f4,f1);
 +--disable_info
 +eval $innodb_metrics_select;
 +SET GLOBAL innodb_monitor_reset = module_ddl;
 +
 +SET GLOBAL innodb_monitor_disable = module_ddl;
 +select count(*) from t1;
 +drop table t1;
 +--disable_warnings
 +SET GLOBAL innodb_monitor_reset = default;
 +SET GLOBAL innodb_monitor_enable = default;
 +SET GLOBAL innodb_monitor_disable = default;
 +--enable_warnings
 +
 +--echo # Bug#19163915 INNODB: DUPLICATE RECORDS COULD EXIST
 +--echo # WHEN SKIPPING SORT FOR CLUSTER INDEX
 +
 +# last mtuple in previous buffer and first mtuple in next buffer
 +#	are equal.
 +SELECT @@innodb_sort_buffer_size;
 +create table t1(f1 int auto_increment not null,
 +		f2 char(200) not null, f3 char(200) not null,
 +		f4 char(200) not null,primary key(f1,f2,f3,f4));
 +insert into t1 select NULL,'aaa','bbb','ccc' from t480;
 +insert into t1 values(106, 'aaa','bbb','cccc');
 +select count(*) from t1;
 +--echo # Skip sort
 +--echo # Change PK from (f1,f2,f3,f4) to (f1,f2,f3)
 +--error ER_DUP_ENTRY
 +alter table t1 drop primary key, add primary key(f1,f2,f3);
 +select count(*) from t1;
 +drop table t1;
 +
 +# Duplicates exist with in the buffer
 +create table t1(f1 int auto_increment not null,
 +		f2 char(200) not null, f3 char(200) not null,
 +		f4 char(200) not null,primary key(f1,f2,f3,f4));
 +insert into t1 select NULL,'aaa','bbb','ccc' from t480;
 +insert into t1 values(108,'aaa','bbb','cccc');
 +select count(*) from t1;
 +--error ER_DUP_ENTRY
 +alter table t1 drop primary key, add primary key(f1,f2,f3);
 +select count(*) from t1;
 +drop table t1, t480;
 +
 +--echo #
 +--echo # Bug #19896922	SORTING SKIPPED WHEN PREFIX LENGTH OF THE PK
 +--echo #		FIELD IS CHANGED
 +--echo #
 +
 +# Prefix length changes for the varchar column.
 +create table t1(a int not null, b varchar(30) not null,
 +		primary key (b(10), a)) engine = innodb;
 +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UxW8L');
 +select * from t1;
 +alter table t1 drop primary key, add primary key (b(18),a);
 +select * from t1;
 +drop table t1;
 +
 +create table t1(a int not null, b varchar(30) not null,
 +		primary key (b(10), a)) engine = innodb;
 +insert into t1 values(0,'khdHps6UxW8Lwaoxa604oK6zkb'),(1,'khdHps6UtW8L');
 +select * from t1;
 +alter table t1 drop primary key, add primary key (b(8),a);
 +select * from t1;
 +drop table t1;
 +
 +
 +--echo #
 +--echo # Bug #21103101	SORTING SKIPPED WHEN DROPPING THE SINGLE
 +--echo #			COLUMN PRIMARY KEY
 +--echo #
 +
 +# Drop primary key column.
 +create table t1(f1 int not null, f2 int not null,
 +		primary key (f1), unique key(f1, f2))engine=innodb;
 +insert into t1 values(1,3), (2,2);
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop column f1;
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop column f1, drop primary key;
 +# DROP PRIMARY KEY is implied for a single-column PRIMARY KEY
 +alter table t1 drop column f1, drop key f1;
 +drop table t1;
 +
 +# Drop Primary key when lock is none.
 +create table t1(f1 int not null, f2 int not null,
 +		primary key (f1), unique key(f1, f2))engine=innodb;
 +insert into t1 values(1,3), (2,2);
 +alter table t1 drop primary key, lock=none;
 +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
 +alter table t1 drop index f1, lock=none;
 +drop table t1;
 +
 +--echo #
 +--echo #  BUG#21612714 ALTER TABLE SORTING SKIPPED WHEN CHANGE PK AND DROP
 +--echo #		LAST COLUMN OF OLD PK
 +--echo #
 +
 +# no skip sort cases
 +# pk(o1,o2) to pk(o1,o3), drop o2
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3), drop o2, lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o3), drop o1, o2
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop o1, drop o2, add primary key(o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o1,o3)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o3)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(n1,o3)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 add column n1 int not null, drop primary key, add primary key(n1,o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o3,n1)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(2,2,1);
 +alter table t1 add column n1 int not null, drop primary key, add primary key(o3,n1), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o2,o1)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2, o1), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o2)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o2,o3)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2,o3), lock=none;
 +drop table t1;
 +
 +# pk(o2,o1) to pk(o2,o3)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o2,o1)) engine = innodb;
 +insert into t1 values(1,1,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o2,o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o1,o3,o2)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3,o2), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o3,o1,o2)
 +create table t1(o1 int, o2 int, o3 int not null, primary key(o1,o2)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +alter table t1 drop primary key, add primary key(o3,o1,o2), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2,o3) to pk(o1,o3)
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +alter table t1 drop primary key, add primary key(o1,o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2,o3) to pk(o2,o3) by drop o1
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop o1, lock=none;
 +alter table t1 drop o1, drop primary key, add primary key(o2,o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2,o3) to pk(o1,o3) by drop o2
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,1,2),(1,2,1);
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop o2, lock=none;
 +alter table t1 drop o2, drop primary key, add primary key(o1,o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2,o3) to pk(o3) by drop o1,o2
 +create table t1(o1 int, o2 int, o3 int, primary key(o1,o2,o3)) engine = innodb;
 +insert into t1 values(1,2,2),(2,1,1);
 +--error ER_KEY_COLUMN_DOES_NOT_EXITS
 +alter table t1 drop o1, drop o2, lock=none;
 +alter table t1 drop o1, drop o2,drop primary key,add primary key(o3),lock=none;
 +drop table t1;
 +
 +# no skip sort for prefix change
 +# pk(o1(2),o2) to pk(o1(3),o2)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1(3), o2), lock=none;
 +drop table t1;
 +
 +# pk(o1(2),o2) to pk(o1,o2)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1, o2), lock=none;
 +drop table t1;
 +
 +# pk(o1(2),o2) to pk(o1(3),o3)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1(3), o3), lock=none;
 +drop table t1;
 +
 +# pk(o1(2),o2) to pk(o1,o3)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(2), o2)) engine = innodb;
 +insert into t1 values('abd', 1, 1), ('abc', 2, 2);
 +alter table t1 drop primary key, add primary key(o1, o3), lock=none;
 +drop table t1;
 +
 +# pk(o1(3),o2) to pk(o1(2),o2)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abc', 2, 1), ('abd', 1, 2);
 +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o1(2),o2)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abc', 2, 1), ('abd', 1, 2);
 +alter table t1 drop primary key, add primary key(o1(2), o2), lock=none;
 +drop table t1;
 +
 +# pk(o1(3),o2) to pk(o1(2),o3)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1(3), o2)) engine = innodb;
 +insert into t1 values('abc', 2, 2), ('abd', 1, 1);
 +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o1(2),o3)
 +create table t1(o1 varchar(10), o2 int, o3 int not null, primary key(o1, o2)) engine = innodb;
 +insert into t1 values('abc', 2, 2), ('abd', 1, 1);
 +alter table t1 drop primary key, add primary key(o1(2), o3), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2(2),o3) to pk(o1,o2(3))
 +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb;
 +insert into t1 values(1, 'abd', 1), (1, 'abc', 2);
 +alter table t1 drop primary key, add primary key(o1,o2(3)), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2(2),o3) to pk(o1,o2)
 +create table t1(o1 int, o2 varchar(10), o3 int, primary key(o1,o2(2),o3)) engine = innodb;
 +insert into t1 values(1, 'abd', 1), (1, 'abc', 2);
 +alter table t1 drop primary key, add primary key(o1,o2), lock=none;
 +drop table t1;
 +
 +# pk(o1(3),o2(3)) to pk(o1(2),o2(3))
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb;
 +insert into t1 values('abc', 'acd'), ('abd', 'abd');
 +alter table t1 drop primary key, add primary key(o1(2),o2(3)), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o1(2),o2)
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb;
 +insert into t1 values('abc', 'acd'), ('abd', 'abd');
 +alter table t1 drop primary key, add primary key(o1(2),o2), lock=none;
 +drop table t1;
 +
 +# pk(o1(3),o2(3)) to pk(o2(3),o1(3))
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1(3),o2(3))) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o2(3),o1(3)), lock=none;
 +drop table t1;
 +
 +# pk(o1,o2) to pk(o2,o1)
 +create table t1(o1 varchar(10), o2 varchar(10), primary key(o1,o2)) engine = innodb;
 +insert into t1 values('abd', 'acd'), ('acd', 'abd');
 +alter table t1 drop primary key, add primary key(o2,o1), lock=none;
 +drop table t1;
 +
 +# no skip sort cases
 +--source suite/innodb/include/alter_table_pk_no_sort.inc
 +
 +--echo #
 +--echo # MDEV-15325 Incomplete validation of missing tablespace during recovery
 +--echo #
 +
 +--source include/no_checkpoint_start.inc
 +if ($have_debug) {
 +SET GLOBAL DEBUG_DBUG='+d,fil_names_write_bogus';
 +}
 +CREATE TABLE t1(f1 INT PRIMARY KEY)ENGINE=InnoDB;
 +
 +CREATE TABLE t2(f1 INT PRIMARY KEY)ENGINE=InnoDB;
 +
 +--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1, t2;
 +--source include/no_checkpoint_end.inc
 +
 +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
 +let $check_no_innodb=SELECT * FROM INFORMATION_SCHEMA.ENGINES
 +WHERE engine = 'innodb'
 +AND support IN ('YES', 'DEFAULT', 'ENABLED');
 +
 +--echo # Wrong space_id in a dirty file and a missing file
 +
 +--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t0.ibd
 +--move_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd
 +
 +--source include/start_mysqld.inc
 +--eval $check_no_innodb
 +--source include/shutdown_mysqld.inc
 +
 +--echo # Restore t1 and t2
 +
 +--move_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
 +--move_file $MYSQLD_DATADIR/test/t0.ibd $MYSQLD_DATADIR/test/t1.ibd
 +
 +--source include/start_mysqld.inc
 +if ($have_debug) {
 +# Initiate shutdown in order to issue a redo log checkpoint and to discard
 +# the redo log record that was emitted due to '+d,fil_names_write_bogus'.
 +--source include/restart_mysqld.inc
 +}
 +
 +SELECT * FROM t1;
 +SELECT * FROM t2;
 +
 +DROP TABLE t1, t2;
 +
 +--echo #
 +--echo #  MDEV-18186 assertion failure on missing InnoDB index
 +--echo #
 +
 +--disable_query_log
 +call mtr.add_suppression("Cannot find index i1 in InnoDB index dictionary");
 +call mtr.add_suppression("InnoDB indexes are inconsistent with what defined");
 +call mtr.add_suppression("Table test/t contains 0 indexes");
 +call mtr.add_suppression("InnoDB could not find key no");
 +--enable_query_log
 +
 +# Test an attempt to rename a nonexistent index inside InnoDB
 +-- let $MYSQL_DATA_DIR = `SELECT @@datadir`
 +CREATE TABLE t (a INT, INDEX i1 (a)) ENGINE=INNODB;
 +-- copy_file $MYSQL_DATA_DIR/test/t.frm $MYSQL_DATA_DIR/test/t.fr_
 +DROP TABLE t;
 +CREATE TABLE t (a INT) ENGINE=INNODB;
 +-- remove_file $MYSQL_DATA_DIR/test/t.frm
 +-- move_file $MYSQL_DATA_DIR/test/t.fr_ $MYSQL_DATA_DIR/test/t.frm
 +--enable_prepare_warnings
 +SHOW CREATE TABLE t;
 +--disable_prepare_warnings
 +DROP TABLE t;
 +
 +--disable_query_log
 +
 +call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*t[12].ibd.");
 +call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace");
 +call mtr.add_suppression("InnoDB: Plugin initialization aborted");
 +call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
 +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
 +
 +--enable_query_log
diff --cc mysql-test/suite/innodb/t/innodb-truncate.test
index 8f9b1f1f0e9,a5b500a4ea5..71c0fcfea8b
--- a/mysql-test/suite/innodb/t/innodb-truncate.test
+++ b/mysql-test/suite/innodb/t/innodb-truncate.test
@@@ -52,24 -53,30 +53,42 @@@ SET @@SESSION.foreign_key_checks = @old
  --echo # Test that TRUNCATE resets auto-increment.
  --echo #
  
 -CREATE TABLE t1 (a INT PRIMARY KEY NOT NULL AUTO_INCREMENT);
 -INSERT INTO t1 VALUES (NULL), (NULL);
 +CREATE TABLE t1 (a INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
 + b INT, c INT, d INT, e INT, f INT, g INT, h INT, i INT, j INT, k INT,
 + l INT, m INT, n INT, o INT, p INT, q INT, r INT, s INT, t INT, u INT,
 + KEY(b),KEY(c),KEY(d),KEY(e),KEY(f),KEY(g),KEY(h),KEY(i),KEY(j),KEY(k),
 + KEY(l),KEY(m),KEY(n),KEY(o),KEY(p),KEY(q),KEY(r),KEY(s),KEY(t),KEY(u),
 + KEY(c,b),KEY(d,b),KEY(e,b),KEY(f,b),KEY(g,b),KEY(h,b),KEY(i,b),KEY(j,b),
 + KEY(k,b),KEY(l,b),KEY(m,b),KEY(n,b),KEY(o,b),KEY(p,b),KEY(q,b),KEY(r,b),
 + KEY(s,b),KEY(t,b),KEY(u,b),
 + KEY(d,c),KEY(e,c),KEY(f,c),KEY(g,c),KEY(h,c),KEY(i,c),KEY(j,c),
 + KEY(k,c),KEY(l,c),KEY(m,c),KEY(n,c),KEY(o,c),KEY(p,c),KEY(q,c),KEY(r,c),
 + KEY(s,c),KEY(t,c),KEY(u,c),
 + KEY(e,d),KEY(f,d),KEY(g,d),KEY(h,d),KEY(i,d),KEY(j,d)
 +) ENGINE=InnoDB;
 +INSERT INTO t1 () VALUES (), ();
  SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't1';
 -SELECT * FROM t1 ORDER BY a;
 +SELECT a FROM t1 ORDER BY a;
  TRUNCATE TABLE t1;
  SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 't1';
 -INSERT INTO t1 VALUES (NULL), (NULL);
 -SELECT * FROM t1 ORDER BY a;
 +INSERT INTO t1 () VALUES (), ();
 +SELECT a FROM t1 ORDER BY a;
  DROP TABLE t1;
+ 
+ #
+ # MDEV-18923 Assertion `!lex_string_cmp(system_charset_info, fk_info->referenced_table, &table->s->table_name)' failed in fk_truncate_illegal_if_parent
+ #
 -call mtr.add_suppression('InnoDB: Error: in RENAME TABLE table `test`.`t3`');
++call mtr.add_suppression('InnoDB: in RENAME TABLE table `test`.`t3`');
+ SET FOREIGN_KEY_CHECKS= OFF;
+ CREATE TABLE t1 (f2 INT, f4 INT, KEY(f2), FOREIGN KEY (f4) REFERENCES t3 (f4)) ENGINE=InnoDB;
+ SET FOREIGN_KEY_CHECKS= ON;
+ CREATE TABLE t2 (f2 INT, FOREIGN KEY(f2) REFERENCES t1 (f2)) ENGINE=InnoDB;
+ --error ER_CANT_CREATE_TABLE
+ CREATE TABLE t3 (a INT) ENGINE=InnoDB;
+ --replace_result $datadir ./
+ --error ER_ERROR_ON_RENAME
+ ALTER TABLE t1 RENAME TO t3;
+ ALTER TABLE t1 FORCE;
+ --error ER_TRUNCATE_ILLEGAL_FK
+ TRUNCATE TABLE t1;
+ DROP TABLE t2, t1;
diff --cc mysql-test/suite/rpl/r/kill_race_condition.result
index 00000000000,e4e347dc786..87ee3214b8e
mode 000000,100644..100644
--- a/mysql-test/suite/rpl/r/kill_race_condition.result
+++ b/mysql-test/suite/rpl/r/kill_race_condition.result
@@@ -1,0 -1,13 +1,18 @@@
+ include/master-slave.inc
+ [connection master]
++connection slave;
+ set global debug_dbug='d,rows_log_event_before_open_table';
+ set debug_sync='now WAIT_FOR before_open_table';
++connection master;
+ create table t1 (a int);
+ insert t1 values (1),(2),(3);
++connection slave;
+ kill slave_sql_thread;
+ set debug_sync='now SIGNAL go_ahead_sql';
+ set global debug_dbug='';
+ set debug_sync='RESET';
++connection master;
+ drop table t1;
++connection slave;
+ start slave;
+ include/rpl_end.inc
diff --cc mysql-test/suite/rpl/r/rpl_current_user.result
index ba5269bef22,3e8d6883c0b..efb036023e9
--- a/mysql-test/suite/rpl/r/rpl_current_user.result
+++ b/mysql-test/suite/rpl/r/rpl_current_user.result
@@@ -88,8 -82,9 +88,10 @@@ include/rpl_sync.in
  include/diff_tables.inc [server_1:v_user, server_2:v_user, server_3:v_user]
  
  # Verify 'ALTER EVENT...' statement
 +connection master;
  CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT * FROM t1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  # Explicitly assign CURRENT_USER() to definer
  ALTER DEFINER=CURRENT_USER() EVENT e1 ENABLE;
  include/rpl_sync.inc
diff --cc mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
index 4ffa8fc9883,d7638942f85..1db69ea4b83
--- a/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
@@@ -237,7 -216,8 +237,9 @@@ D
  BEGIN
  UPDATE test.t1 SET a = a + 1 WHERE a < 10;
  END|
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 +connection slave;
  RESET SLAVE;
  CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
  include/start_slave.inc
diff --cc mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
index 00b50df4a68,3726760f498..dce79837700
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
@@@ -679,6 -678,9 +679,8 @@@ DROP TRIGGER tr1
  GRANT EVENT ON *.* TO 'root'@'localhost';
  INSERT INTO t1 VALUES(1, 'test1');
  CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 -==========MASTER==========
  SHOW EVENTS;
  Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
  test_rpl	e1	root at localhost	SYSTEM	RECURRING	NULL	1	#	#	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
diff --cc mysql-test/suite/rpl/r/rpl_killed_ddl.result
index 66309432efe,a0520783168..2c0f27a3218
--- a/mysql-test/suite/rpl/r/rpl_killed_ddl.result
+++ b/mysql-test/suite/rpl/r/rpl_killed_ddl.result
@@@ -32,11 -32,13 +32,13 @@@ CREATE DATABASE d1
  CREATE EVENT e1
  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
  DO INSERT INTO test.t1 VALUES (1);
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
  CREATE FUNCTION f1 () RETURNS INT DETERMINISTIC
  RETURN 1;
 -CREATE PROCEDURE p1 (OUT rows INT)
 +CREATE PROCEDURE p1 (OUT rows_cnt INT)
  BEGIN
 -SELECT COUNT(*) INTO rows FROM t1;
 +SELECT COUNT(*) INTO rows_cnt FROM t1;
  END;
  //
  CREATE SERVER s1
diff --cc mysql-test/t/func_gconcat.test
index abc86476a6b,57da0f3c6fc..e752d9fcd50
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@@ -874,44 -872,29 +872,73 @@@ SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY 
  DROP TABLE t1;
  SET group_concat_max_len= DEFAULT;
  
+ #
+ # MDEV-9531 GROUP_CONCAT with ORDER BY inside takes a lot of memory while it's executed
+ #
++set session group_concat_max_len=1024;
+ set max_session_mem_used=16*1024*1024; # 8M..32M
+ SELECT GROUP_CONCAT(concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1), concat(seq/1.1) ORDER BY 2,1,3,4,6,5,8,7) AS c
+ FROM seq_1_to_200000;
+ set max_session_mem_used=default;
++set session group_concat_max_len=default;
+ 
+ #
+ # MDEV-19350 Server crashes in delete_tree_element / ... / Item_func_group_concat::repack_tree
+ #
+ SET group_concat_max_len= 8;
+ CREATE TABLE t1 (a INT);
+ INSERT t1 VALUES (1),(2);
+ CREATE TABLE t2 (b DATE, c INT);
+ INSERT t2 VALUES ('2019-12-04',1),('2020-03-28',2);
+ CREATE TABLE t3 (d INT);
+ INSERT t3 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14);
+ CREATE TABLE t4 (e INT);
+ INSERT t4 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15);
+ SELECT (SELECT MAX(a) FROM t1 WHERE t2_sq.c > 0) AS f,
+        GROUP_CONCAT(t2_sq.b ORDER BY 1) AS gc
+ FROM (SELECT t2_a.* FROM t2 AS t2_a, t2 AS t2_b) AS t2_sq, t3, t4
+ GROUP BY f;
+ DROP TABLE t1, t2, t3, t4;
+ SET group_concat_max_len= default;
++
 +
 +--echo #
 +--echo # Start of 10.2 tests
 +--echo #
 +
 +--echo #
 +--echo # MDEV-10124 Incorrect usage of CUBE/ROLLUP and ORDER BY with GROUP_CONCAT(a ORDER BY a)
 +--echo #
 +
 +CREATE TABLE t1 (a INT);
 +INSERT INTO t1 VALUES (10),(20),(30);
 +
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP;
 +CREATE VIEW v1 AS
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP;
 +SELECT * FROM v1;
 +DROP VIEW v1;
 +
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30';
 +CREATE VIEW v1 AS
 +SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30';
 +SELECT * FROM v1;
 +DROP VIEW v1;
 +
 +SELECT * FROM (SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30') t1;
 +CREATE VIEW v1 AS
 +SELECT * FROM (SELECT a,GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30') t1;
 +SELECT * FROM v1;
 +DROP VIEW v1;
 +
 +SELECT (SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30');
 +CREATE VIEW v1 AS
 +SELECT (SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP HAVING GROUP_CONCAT(a ORDER BY a)='10,20,30');
 +SELECT * FROM v1;
 +DROP VIEW v1;
 +
 +DROP TABLE t1;
 +
 +--echo #
 +--echo # End of 10.2 tests
 +--echo #
diff --cc mysql-test/t/gis.test
index ebcea63b083,db3ab00fb03..f630a6dc8bf
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@@ -1568,196 -1569,19 +1568,243 @@@ CREATE TABLE t2 AS SELECT WITHIN(g1,g1
  SHOW CREATE TABLE t2;
  DROP TABLE t1,t2;
  
++
+ #
+ # MDEV-3934 Assertion `((keypart_map+1) & keypart_map) == 0' failed in _mi_pack_key with an index on a POINT column
+ #
+ 
+ CREATE TABLE t1 (
+       id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+       point_data POINT NOT NULL,
+       PRIMARY KEY (id),
+       KEY idx_point_data(point_data)
+ ) ENGINE=MyISAM;
+ INSERT t1 (point_data) VALUES
+     (GeomFromText('Point(37.0248492 23.8512726)')),
+     (GeomFromText('Point(38.0248492 23.8512726)'));
+ SELECT id FROM t1
+ WHERE ST_Contains(point_data, GeomFromText('Point(38.0248492 23.8512726)'));
+ DROP TABLE t1;
++
++
 +--echo #
 +--echo # Start of 10.2 tests
 +--echo #
 +
 +#
 +# Item_func_spatial_collection::print()
 +#
 +create view v1 as select AsWKT(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))));
 +show create view v1;
 +select * from v1;
 +drop view v1;
 +
 +--echo #
 +--echo # MDEV-10134 Add full support for DEFAULT
 +--echo #
 +
 +CREATE TABLE t1 (a POINT, x DOUBLE DEFAULT x(a), y DOUBLE DEFAULT y(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (Point(1,2));
 +SELECT x,y FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (g GEOMETRY, area DOUBLE DEFAULT ST_AREA(g));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (g) VALUES (GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'));
 +SELECT area FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (g GEOMETRY, length DOUBLE DEFAULT ST_LENGTH(g));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (g) VALUES (GeomFromText('LINESTRING(0 0,20 0,20 20,0 20,0 0)'));
 +SELECT length FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (g POINT, distance DOUBLE DEFAULT ST_DISTANCE(g, POINT(0,0)));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (g) VALUES (Point(1,0));
 +SELECT distance FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a TEXT, g GEOMETRY DEFAULT GeomFromText(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES ('point(1 1)');
 +SELECT AsText(g) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (x INT, y INT, g GEOMETRY DEFAULT POINT(x,y));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (x,y) VALUES (10,20);
 +SELECT AsText(g) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT PointN(a,2));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(1 1,2 2,3 3)'));
 +SELECT AsText(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT StartPoint(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(1 1,2 2,3 3)'));
 +SELECT AsText(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c GEOMETRY DEFAULT GeometryCollection(a,b));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a,b) VALUES (Point(1,1), Point(2,2));
 +SELECT AsText(c) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT GeomFromWKB(AsBinary(a),20));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('POINT(1 1)', 10));
 +SELECT AsText(a), SRID(a), AsText(b), SRID(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT BOUNDARY(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT AsText(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT BUFFER(a,10));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT GeometryType(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT CENTROID(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT AsText(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT ENVELOPE(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(1 1,4 4)'));
 +SELECT AsText(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT PointOnSurface(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('POLYGON((10 10, 10 20, 20 20, 20 10, 10 10))'));
 +SELECT GeometryType(b) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY DEFAULT Point(1,1), c GEOMETRY DEFAULT ST_UNION(a,b));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (Point(0,0));
 +SELECT AsText(c) FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b VARCHAR(20) DEFAULT GeometryType(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (Point(0, 0));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsSimple(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (Point(0, 0));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsEmpty(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (Point(0, 0));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsRing(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(0 0,0 1,1 1,1 0,0 0)'));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT IsClosed(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('LineString(0 0,0 1,1 1,1 0,0 0)'));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT Dimension(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (Buffer(Point(1,1),1));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT NumGeometries(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (ST_UNION(Point(1,1),Point(0,0)));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT NumInteriorRings(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1))'));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT NumPoints(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (LineString(Point(1,1),Point(0,0)));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b INT DEFAULT SRID(a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (GeomFromText('Point(1 1)', 100));
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c INT DEFAULT MBRDisjoint(a,b));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a,b) VALUES (Point(1,1),Point(1,1));
 +SELECT c FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c INT DEFAULT ST_Disjoint(a,b));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a,b) VALUES (Point(1,1),Point(1,1));
 +SELECT c FROM t1;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a GEOMETRY, b GEOMETRY, c INT DEFAULT ST_Relate(a,b,'T*F**FFF*'));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a,b) VALUES (Point(1,1),Point(1,1));
 +SELECT c FROM t1;
 +DROP TABLE t1;
 +
++#
++# MDEV-13923 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon altering table with geometry field
++#
++--error ER_CANT_CREATE_GEOMETRY_OBJECT
++create table t1 (p point default "qwer");
++--error ER_CANT_CREATE_GEOMETRY_OBJECT
++create table t1 (p point default 0);
++--error ER_INVALID_DEFAULT
++create table t1 (p point not null default st_geometryfromtext('point 0)'));
++create table t1 (p point not null default st_geometryfromtext('point(0 0)'));
++insert into t1 values(default);
++select st_astext(p) from t1;
++drop table t1;
++
++create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
++set timestamp=10;
++--error ER_CANT_CREATE_GEOMETRY_OBJECT
++insert into t1 values(default);
++drop table t1;
++SET timestamp=default;
++
++create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
++set timestamp=10;
++--error ER_CANT_CREATE_GEOMETRY_OBJECT
++alter table t1 add column i int;
++drop table t1;
++SET timestamp=default;
++
 +--echo #
 +--echo # End of 10.2 tests
 +--echo #
diff --cc mysql-test/t/multi_update.test
index 64e61f7c0b5,8399c465562..900d0bd4283
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@@ -983,4 -1056,86 +983,35 @@@ deallocate prepare stmt1
  
  drop view v3,v2,v1;
  drop table t1,t2,t3;
+ 
+ #
+ # MDEV-18507 can't update temporary table when joined with table with triggers on read-only
+ #
+ create table t1 (id int not null, v1 varchar(10) not null);
+ insert into t1 values (1,1),(2,2);
+ create table t2 (log varchar(10) not null);
+ create trigger t1_after_update after update on t1
+ 	for each row insert into t2 values ('triggered');
+ 
+ create user foo;
+ grant select, insert, update, delete, create, drop, reload, index, alter, show databases, create temporary tables, lock tables, execute, create view, show view, create routine, alter routine, trigger on *.* to 'foo'@'%';
+ 
+ set global read_only=1;
+ connect a, localhost, foo;
+ 
+ create temporary table temp_t1 (id int not null, update_me varchar(10));
+ insert into temp_t1 values (1,1),(2,2),(3,3);
+ update temp_t1 left join t1 on temp_t1.id = t1.id set temp_t1.update_me = 'hello';
+ 
+ connection default;
+ set global read_only = 0;
+ 
+ create table t3 (id int not null);
+ insert t3 values (2);
+ update t1 left join t3 on t1.id = t3.id set t1.v1 = 'hello';
+ select * from t2;
+ 
+ drop table t1,t2, t3;
+ drop user foo;
+ 
  --echo end of 5.5 tests
 -
 -
 ---source include/have_xtradb.inc
 -
 ---echo
 ---echo # Bug mdev-5970
 ---echo # Bug#13256831 - ERROR 1032 (HY000): CAN'T FIND RECORD
 ---echo
 -
 -CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
 -CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT) ENGINE=InnoDB;
 -INSERT INTO t1 VALUES (5, 7);
 -INSERT INTO t2 VALUES (6, 97);
 -
 -CREATE ALGORITHM = MERGE VIEW v1 AS 
 -SELECT a2.f1 AS f1, a2.f2 AS f2
 -FROM t1 AS a1 JOIN t2 AS a2 ON a1.f2 > a2.f1 
 -WITH LOCAL CHECK OPTION; 
 -
 -SELECT * FROM v1;
 -UPDATE v1 SET f1 = 1;
 -SELECT * FROM v1;
 -
 -DROP TABLE t1, t2;
 -DROP VIEW v1;
 -
 ---echo #
 ---echo # MDEV-5973: MySQL  Bug#11757486:49539: NON-DESCRIPTIVE ERR (ERROR 0
 ---echo # FROM STORAGE ENGINE) WITH MULTI-TABLE UPDATE
 ---echo #
 -
 -CREATE TABLE table_11757486 (field1 tinyint) ENGINE=INNODB;
 -INSERT INTO table_11757486 VALUES (0),(0);
 -SET SESSION SQL_MODE='STRICT_ALL_TABLES';
 -UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
 -UPDATE IGNORE table_11757486 SET field1=128;
 -
 ---error ER_WARN_DATA_OUT_OF_RANGE
 -UPDATE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
 ---error ER_WARN_DATA_OUT_OF_RANGE
 -UPDATE table_11757486 SET field1=128;
 -
 -SET SESSION SQL_MODE='';
 -UPDATE IGNORE (SELECT 128 as col1) x, table_11757486 SET field1=x.col1;
 -UPDATE IGNORE table_11757486 SET field1=128;
 -
 -DROP TABLE table_11757486;
 -
 -SET SESSION SQL_MODE=default;
 -
 ---echo end of 10.0 tests
diff --cc mysql-test/t/partition_innodb.test
index 590e2fc7f07,15c9625770b..8c644103046
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@@ -1022,49 -1027,28 +1022,74 @@@ UPDATE v SET f2 = NULL
  SET GLOBAL innodb_stats_persistent= @save_isp;
  DROP view v;
  DROP TABLE t;
 +set sql_mode= @save_sql_mode;
  
+ --echo #
+ --echo # Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT
+ --echo #
+ CREATE TABLE t (a VARCHAR(10) NOT NULL,b INT,PRIMARY KEY (b)) ENGINE=INNODB
+ PARTITION BY RANGE (b)
+ (PARTITION pa VALUES LESS THAN (2),
+  PARTITION pb VALUES LESS THAN (20),
+  PARTITION pc VALUES LESS THAN (30),
+  PARTITION pd VALUES LESS THAN (40));
+ 
+ INSERT INTO t
+ VALUES('A',0),('B',1),('C',2),('D',3),('E',4),('F',5),('G',25),('H',35);
+ CREATE TABLE t_copy LIKE t;
+ INSERT INTO t_copy SELECT * FROM t;
+ 
+ --enable_info
+ ALTER TABLE t ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ ADD UNIQUE KEY (r,b);
+ ALTER TABLE t_copy ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ ADD UNIQUE KEY (r,b), ALGORITHM=COPY;
+ --disable_info
+ SELECT * FROM t;
+ SELECT * FROM t_copy;
+ DROP TABLE t,t_copy;
++
 +--echo #
 +--echo # Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE
 +--echo #              MYSQL.INNODB_TABLE_STATS
 +--echo #
 +
 +CREATE DATABASE test_jfg;
 +
 +CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY
 +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1;
 +CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY
 +KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
 +PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000)
 +ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE =
 +InnoDB);
 +
 +--replace_result #p# #P#
 +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
 +database_name = 'test_jfg';
 +
 +RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11;
 +RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12;
 +
 +--replace_result #p# #P#
 +SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
 +database_name = 'test_jfg';
 +
 +DROP DATABASE test_jfg;
 +
 +#
 +# MDEV-17755 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' failed in Field_bit::val_int upon SELECT with JOIN, partitions, indexed virtual column
 +#
 +create table t1 (a int) engine=innodb;
 +create table t2 (
 +  b int,
 +  c int,
 +  d bit not null default 0,
 +  v bit as (d) virtual,
 +  key (b,v)
 +) engine=innodb partition by hash (b);
 +insert into t1 values (1),(2);
 +insert into t2 (b,c,d) values (1,1,0),(2,2,0);
 +explain select t1.* from t1 join t2 on (v = a);
 +select t1.* from t1 join t2 on (v = a);
 +drop table t1, t2;
diff --cc mysql-test/t/stat_tables.test
index 93caa47ce79,2727f8d8bb1..ddf881c69ae
--- a/mysql-test/t/stat_tables.test
+++ b/mysql-test/t/stat_tables.test
@@@ -453,47 -453,27 +453,68 @@@ delete from mysql.table_stats
  delete from mysql.column_stats;
  delete from mysql.index_stats;
  
+ --echo #
+ --echo # MDEV-19352: Server crash in alloc_histograms_for_table_share upon query from information schema
+ --echo #
+ 
+ use test;
+ set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+ set @@optimizer_use_condition_selectivity= 4;
+ set use_stat_tables='preferably';
+ 
+ CREATE TABLE t1 (a INT);
+ CREATE TABLE t2 (b INT);
+ CREATE VIEW v AS SELECT * FROM t1 JOIN t2;
+ --error ER_NO_SUCH_TABLE
+ INSERT INTO t2 SELECT * FROM x;
+ 
+ select * from information_schema.tables where table_name='v';
+ 
+ drop table t1,t2;
+ drop view v;
+ set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+ 
  set @save_optimizer_switch=@@optimizer_switch;
 +set use_stat_tables=@save_use_stat_tables;
 +
 +--echo #
 +--echo # MDEV-18899: Server crashes in Field::set_warning_truncated_wrong_value
 +--echo #
  
 +set names utf8;
 +set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
 +set optimizer_use_condition_selectivity=4;
 +set use_stat_tables=preferably;
 +set @save_histogram_size= @@histogram_size;
 +set histogram_size=255;
 +
 +create table t1 ( a varchar(255) character set utf8);
 +insert into t1 values (REPEAT('ӥ',255)), (REPEAT('ç',255));
 +
 +analyze table t1;
 +select HEX(RIGHT(min_value, 1)), length(min_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +select HEX(RIGHT(max_value, 1)), length(max_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +analyze select * from t1 where a  >= 'ӥ';
 +
 +set @save_sql_mode= @@sql_mode;
 +set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 +update mysql.column_stats set min_value= REPEAT('ӥ',255) where db_name='test' and table_name='t1';
 +select HEX(RIGHT(min_value, 1)), length(min_value) from mysql.column_stats where db_name='test' and table_name='t1';
 +analyze select * from t1 where a  >= 'ӥ';
 +
 +set names latin1;
 +drop table t1;
 +
 +CREATE TABLE t1 (col1 date);
 +INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
 +INSERT INTO t1 VALUES('0000-10-31');
 +analyze table t1;
 +update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1';
 +select min_value from mysql.column_stats where db_name='test' and table_name='t1';
 +select * from t1;
 +drop table t1;
 +
 +set @@sql_mode= @save_sql_mode;
  set use_stat_tables=@save_use_stat_tables;
 +set @@histogram_size= @save_histogram_size;
 +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
diff --cc mysql-test/t/statistics.test
index b2e544064b0,7d2e7e898d3..4c45b4f38b8
--- a/mysql-test/t/statistics.test
+++ b/mysql-test/t/statistics.test
@@@ -879,22 -809,19 +879,37 @@@ rename table t1 to t2, t3 to t4
  drop table t1, mysql.table_stats;
  rename table test.table_stats to mysql.table_stats;
  
+ --echo #
+ --echo # MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.
+ --echo #
+ 
+ create temporary table t1(a int);
+ insert into t1 values (1),(2),(3);
+  
+ set use_stat_tables=preferably;
+ set @optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+ set optimizer_use_condition_selectivity=4;
+  
+ select * from t1 where a >= 2;
+ drop table t1;
+ set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+ 
  set use_stat_tables=@save_use_stat_tables;
 +
 +--echo #
 +--echo # Start of 10.2 tests
 +--echo #
 +
 +--echo #
 +--echo # MDEV-10134 Add full support for DEFAULT
 +--echo #
 +
 +CREATE TABLE t1 (a BLOB, b TEXT DEFAULT DECODE_HISTOGRAM('SINGLE_PREC_HB',a));
 +SHOW CREATE TABLE t1;
 +INSERT INTO t1 (a) VALUES (0x0000000000000000000000000101010101010101010202020303030304040404050505050606070707080809090A0A0B0C0D0D0E0E0F10111213131415161718191B1C1E202224292A2E33373B4850575F6A76818C9AA7B9C4CFDADFE5EBF0F4F8FAFCFF);
 +SELECT b FROM t1;
 +DROP TABLE t1;
 +
 +--echo #
 +--echo # End of 10.2 tests
 +--echo #
diff --cc mysql-test/t/type_bit.test
index 04db1511833,4df6d72ce9a..012fa2236d7
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@@ -459,27 -459,12 +459,36 @@@ SELECT COALESCE(val, 1) FROM t1
  --disable_metadata
  DROP TABLE t1;
  
 -
+ --echo #
+ --echo # MDEV-18452 ASAN unknown-crash in Field::set_default upon SET bit_column = DEFAULT
+ --echo #
+ 
+ CREATE TABLE t1 (b BIT(20)) ENGINE=MyISAM;
+ INSERT INTO t1 VALUES (0);
+ UPDATE t1 SET b = DEFAULT;
+ DROP TABLE t1;
++
 +--echo #
 +--echo # End of 10.1 tests
 +--echo #
 +
 +
 +--echo #
 +--echo # Start of 10.2 tests
 +--echo #
 +
 +--echo #
 +--echo # MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result
 +--echo #
 +
 +CREATE TABLE t1 (a DECIMAL(30,0));
 +INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED));
 +ALTER TABLE t1 MODIFY a BIT(64);
 +SELECT a+0 FROM t1;
 +DROP TABLE IF EXISTS t1;
 +
 +
 +--echo #
 +--echo # End of 10.2 tests
 +--echo #
 +
diff --cc pcre/pcregrep.c
index 79d9e286c75,5982406862b..1f3b12f2a03
--- a/pcre/pcregrep.c
+++ b/pcre/pcregrep.c
@@@ -2249,10 -2249,10 +2249,10 @@@ if (isdirectory(pathname)
      while ((nextfile = readdirectory(dir)) != NULL)
        {
        int frc;
 -      int fnlength = strlen(pathname) + strlen(nextfile) + 2;
 +      size_t fnlength = strlen(pathname) + strlen(nextfile) + 2;
        if (fnlength > 2048)
          {
-         fprintf(stderr, "pcre2grep: recursive filename is too long\n");
+         fprintf(stderr, "pcregrep: recursive filename is too long\n");
          rc = 2;
          break;
          }
diff --cc scripts/mysql_install_db.sh
index 8bad8c4000b,43b7d7a52f6..2c132cccf2a
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@@ -499,7 -495,7 +501,7 @@@ SET @auth_root_socket=NULL;" ;
  SET @skip_auth_root_nopasswd=1;
  SET @auth_root_socket='$auth_root_socket_user';" ;;
  esac
- if { echo "use mysql;$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
 -if { echo "$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
++if { echo "$install_params"; cat "$create_system_tables" "$create_system_tables2" "$fill_system_tables" "$fill_help_tables" "$maria_add_gis_sp"; } | eval "$filter_cmd_line" | mysqld_install_cmd_line > /dev/null
  then
    s_echo "OK"
  else
diff --cc sql/field.cc
index 0621015c0e4,a4308a378b3..30eed286512
--- a/sql/field.cc
+++ b/sql/field.cc
@@@ -2415,26 -2283,6 +2415,26 @@@ Field *Field::clone(MEM_ROOT *root, my_
    return tmp;
  }
  
 +int Field::set_default()
 +{
 +  if (default_value)
 +  {
 +    Query_arena backup_arena;
 +    table->in_use->set_n_backup_active_arena(table->expr_arena, &backup_arena);
 +    int rc= default_value->expr->save_in_field(this, 0);
 +    table->in_use->restore_active_arena(table->expr_arena, &backup_arena);
 +    return rc;
 +  }
 +  /* Copy constant value stored in s->default_values */
 +  my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->s->default_values -
 +                                        table->record[0]);
-   memcpy(ptr, ptr + l_offset, pack_length());
++  memcpy(ptr, ptr + l_offset, pack_length_in_rec());
 +  if (maybe_null_in_table())
 +    *null_ptr= ((*null_ptr & (uchar) ~null_bit) |
 +                (null_ptr[l_offset] & null_bit));
 +  return 0;
 +}
 +
  
  /****************************************************************************
    Field_null, a field that always return NULL
diff --cc sql/item_sum.cc
index 4405477b6a1,71f07706d22..b1b22d0877f
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@@ -3451,6 -3304,62 +3455,62 @@@ void Item_func_group_concat::clear(
    /* No need to reset the table as we never call write_row */
  }
  
+ struct st_repack_tree {
+   TREE tree;
+   TABLE *table;
+   size_t len, maxlen;
+ };
+ 
+ extern "C"
+ int copy_to_tree(void* key, element_count count __attribute__((unused)),
+                  void* arg)
+ {
+   struct st_repack_tree *st= (struct st_repack_tree*)arg;
+   TABLE *table= st->table;
+   Field* field= table->field[0];
+   const uchar *ptr= field->ptr_in_record((uchar*)key - table->s->null_bytes);
 -  size_t len= field->val_int(ptr);
++  size_t len= (size_t)field->val_int(ptr);
+ 
+   DBUG_ASSERT(count == 1);
+   if (!tree_insert(&st->tree, key, 0, st->tree.custom_arg))
+     return 1;
+ 
+   st->len += len;
+   return st->len > st->maxlen;
+ }
+ 
+ bool Item_func_group_concat::repack_tree(THD *thd)
+ {
+   struct st_repack_tree st;
+ 
 -  init_tree(&st.tree, MY_MIN(thd->variables.max_heap_table_size,
 -                              thd->variables.sortbuff_size/16), 0,
++  init_tree(&st.tree, (size_t) MY_MIN(thd->variables.max_heap_table_size,
++                                      thd->variables.sortbuff_size/16), 0,
+             tree->size_of_element, group_concat_key_cmp_with_order, NULL,
+             (void*) this, MYF(MY_THREAD_SPECIFIC));
+   st.table= table;
+   st.len= 0;
 -  st.maxlen= thd->variables.group_concat_max_len;
++  st.maxlen= (size_t)thd->variables.group_concat_max_len;
+   tree_walk(tree, &copy_to_tree, &st, left_root_right);
+   if (st.len <= st.maxlen) // Copying aborted. Must be OOM
+   {
+     delete_tree(&st.tree);
+     return 1;
+   }
+   delete_tree(tree);
+   *tree= st.tree;
+   tree_len= st.len;
+   return 0;
+ }
+ 
+ /*
+   Repacking the tree is expensive. But it keeps the tree small, and
+   inserting into an unnecessary large tree is also waste of time.
+ 
+   The following number is best-by-test. Test execution time slowly
+   decreases up to N=10 (that is, factor=1024) and then starts to increase,
+   again, very slowly.
+ */
+ #define GCONCAT_REPACK_FACTOR (1 << 10)
  
  bool Item_func_group_concat::add()
  {
@@@ -3486,6 -3403,12 +3554,12 @@@
    TREE_ELEMENT *el= 0;                          // Only for safety
    if (row_eligible && tree)
    {
+     THD *thd= table->in_use;
 -    table->field[0]->store(row_str_len);
++    table->field[0]->store(row_str_len, FALSE);
+     if (tree_len > thd->variables.group_concat_max_len * GCONCAT_REPACK_FACTOR
+         && tree->elements_in_tree > 1)
+       if (repack_tree(thd))
+         return 1;
      el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0,
                      tree->custom_arg);
      /* check if there was enough memory to insert the row */
@@@ -3620,9 -3543,17 +3695,17 @@@ bool Item_func_group_concat::setup(THD 
      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))
 +    if (setup_order(thd, Ref_ptr_array(ref_pointer_array, n_elems),
 +                    context->table_list, list,  all_fields, *order))
        DBUG_RETURN(TRUE);
+     /*
+       Prepend the field to store the length of the string representation
+       of this row. Used to detect when the tree goes over group_concat_max_len
+     */
+     Item *item= new (thd->mem_root)
 -                    Item_int(thd, thd->variables.group_concat_max_len);
++                    Item_uint(thd, thd->variables.group_concat_max_len);
+     if (!item || all_fields.push_front(item, thd->mem_root))
+       DBUG_RETURN(TRUE);
    }
  
    count_field_types(select_lex, tmp_table_param, all_fields, 0);
@@@ -3685,11 -3617,12 +3769,12 @@@
        syntax of this function). If there is no ORDER BY clause, we don't
        create this tree.
      */
 -    init_tree(tree, MY_MIN(thd->variables.max_heap_table_size,
 -                           thd->variables.sortbuff_size/16), 0,
 -              tree_key_length, 
 +    init_tree(tree, (size_t)MY_MIN(thd->variables.max_heap_table_size,
-                                thd->variables.sortbuff_size/16), 0,
-               tree_key_length, 
++                                   thd->variables.sortbuff_size/16), 0,
++              tree_key_length,
                group_concat_key_cmp_with_order, NULL, (void*) this,
                MYF(MY_THREAD_SPECIFIC));
+     tree_len= 0;
    }
  
    if (distinct)
diff --cc sql/item_sum.h
index 5c8ff520259,001d1d13fe4..c1373f6c1fc
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@@ -1629,8 -1468,8 +1630,10 @@@ class Item_func_group_concat : public I
    friend int dump_leaf_key(void* key_arg,
                             element_count count __attribute__((unused)),
  			   void* item_arg);
 +protected:
-   virtual Field *make_string_field(TABLE *table);
++  Field *make_string_field(TABLE *table);
+ 
+   bool repack_tree(THD *thd);
  
  public:
    Item_func_group_concat(THD *thd, Name_resolution_context *context_arg,
@@@ -1686,11 -1525,9 +1689,11 @@@
    String* val_str(String* str);
    Item *copy_or_same(THD* thd);
    void no_rows_in_result() {}
-   virtual void print(String *str, enum_query_type query_type);
-   virtual bool change_context_processor(void *cntx)
+   void print(String *str, enum_query_type query_type);
 -  bool change_context_processor(uchar *cntx)
++  bool change_context_processor(void *cntx)
      { context= (Name_resolution_context *)cntx; return FALSE; }
 +  Item *get_copy(THD *thd, MEM_ROOT *mem_root)
 +  { return get_item_copy<Item_func_group_concat>(thd, mem_root, this); }
  };
  
  #endif /* ITEM_SUM_INCLUDED */
diff --cc sql/mysqld.cc
index 2d872afaeb8,cf76a6a4c5c..cf96318f34c
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@@ -4146,24 -4077,18 +4179,26 @@@ static int init_common_variables(
    if (!global_rpl_filter || !binlog_filter)
    {
      sql_perror("Could not allocate replication and binlog filters");
 -    return 1;
 +    exit(1);
    }
  
 -  if (init_thread_environment() ||
 -      mysql_init_variables())
 -    return 1;
 +#ifdef HAVE_OPENSSL
 +  if (check_openssl_compatibility())
 +  {
 +    sql_print_error("Incompatible OpenSSL version. Cannot continue...");
 +    exit(1);
 +  }
 +#endif
 +
 +  if (init_thread_environment() || mysql_init_variables())
 +    exit(1);
  
    if (ignore_db_dirs_init())
 -    return 1;
 +    exit(1);
 +
- #ifdef HAVE_TZNAME
+ #ifdef _WIN32
+   get_win_tzname(system_time_zone, sizeof(system_time_zone));
+ #elif defined(HAVE_TZNAME)
    struct tm tm_tmp;
    localtime_r(&server_start_time,&tm_tmp);
    const char *tz_name=  tzname[tm_tmp.tm_isdst != 0 ? 1 : 0];
diff --cc sql/sql_acl.cc
index 871744c6b36,6448f65a2cd..d5ef3c38b7b
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@@ -782,641 -786,30 +782,640 @@@ static const int Table_procs_priv= 1 <
  static const int Table_proxies_priv= 1 << PROXIES_PRIV_TABLE;
  static const int Table_roles_mapping= 1 << ROLES_MAPPING_TABLE;
  
 -static int open_grant_tables(THD *, TABLE_LIST *, enum thr_lock_type, int);
 +/**
 +  Base class representing a generic grant table from the mysql database.
 +
 +  The potential tables that this class can represent are:
 +  user, db, columns_priv, tables_priv, host, procs_priv, proxies_priv,
 +  roles_mapping
 +
 +  Objects belonging to this parent class can only be constructed by the
 +  Grants_table class. This ensures the correct initialization of the objects.
 +*/
 +class Grant_table_base
 +{
 + public:
 +  /* Number of fields for this Grant Table. */
 +  uint num_fields() const { return tl.table->s->fields; }
 +  /* Check if the table exists after an attempt to open it was made.
 +     Some tables, such as the host table in MySQL 5.6.7+ are missing. */
 +  bool table_exists() const { return tl.table; };
 +  /* Initializes the READ_RECORD structure provided as a parameter
 +     to read through the whole table, with all columns available. Cleaning up
 +     is the caller's job. */
 +  bool init_read_record(READ_RECORD* info, THD* thd) const
 +  {
 +    DBUG_ASSERT(tl.table);
 +    bool result= ::init_read_record(info, thd, tl.table, NULL, NULL, 1,
 +                                    true, false);
 +    if (!result)
 +      tl.table->use_all_columns();
 +    return result;
 +  }
 +
 +  /* Return the number of privilege columns for this table. */
 +  uint num_privileges() const { return num_privilege_cols; }
 +  /* Return a privilege column by index. */
 +  Field* priv_field(uint privilege_idx) const
 +  {
 +    DBUG_ASSERT(privilege_idx < num_privileges());
 +    return tl.table->field[start_privilege_column + privilege_idx];
 +  }
 +
 +  /* Fetch the privileges from the table as a set of bits. The first column
 +     is represented by the first bit in the result, the second column by the
 +     second bit, etc. */
 +  ulong get_access() const
 +  {
 +    return get_access(start_privilege_column,
 +                      start_privilege_column + num_privileges() - 1);
 +  }
 +
 +  /* Return the underlying TABLE handle. */
 +  TABLE* table() const
 +  {
 +    return tl.table;
 +  }
 +
 +  /** Check if the table was opened, issue an error otherwise. */
 +  int no_such_table() const
 +  {
 +    if (table_exists())
 +      return 0;
 +
 +    my_error(ER_NO_SUCH_TABLE, MYF(0), tl.db, tl.alias);
 +    return 1;
 +  }
 +
 +
 + protected:
 +  friend class Grant_tables;
 +
 +  Grant_table_base() : start_privilege_column(0), num_privilege_cols(0)
 +  {
 +    tl.reset();
 +  };
 +
 +  /* Initialization sequence common for all grant tables. This should be called
 +     after all table-specific initialization is performed. */
 +  void init(enum thr_lock_type lock_type, bool is_optional)
 +  {
 +    tl.open_type= OT_BASE_ONLY;
-     if (lock_type >= TL_WRITE_ALLOW_WRITE)
-       tl.updating= 1;
++    tl.i_s_requested_object= OPEN_TABLE_ONLY;
 +    if (is_optional)
 +      tl.open_strategy= TABLE_LIST::OPEN_IF_EXISTS;
 +  }
 +
 +  /*
 +    Get all access bits from table between start_field and end_field indices.
 +
 +    IMPLEMENTATION
 +    The record should be already read in table->record[0]. All privileges
 +    are specified as an ENUM(Y,N).
 +
 +    SYNOPSIS
 +      get_access()
 +      start_field_idx   The field index at which the first privilege
 +                        specification begins.
 +      end_field_idx     The field index at which the last privilege
 +                        specification is located.
 +
 +    RETURN VALUE
 +      privilege mask
 +  */
 +  ulong get_access(uint start_field_idx, uint end_field_idx) const
 +  {
 +    ulong access_bits= 0, bit= 1;
 +    for (uint i = start_field_idx; i <= end_field_idx; i++, bit<<=1)
 +    {
 +      if (get_YN_as_bool(tl.table->field[i]))
 +        access_bits|= bit;
 +    }
 +    return access_bits;
 +  }
 +
 +  /* Compute how many privilege columns this table has. This method
 +     can only be called after the table has been opened.
 +
 +     IMPLEMENTATION
 +     A privilege column is of type enum('Y', 'N'). Privilege columns are
 +     expected to be one after another.
 +  */
 +  void compute_num_privilege_cols()
 +  {
 +    if (!table_exists()) // Table does not exist or not opened.
 +      return;
 +
 +    num_privilege_cols= 0;
 +    for (uint i= 0; i < num_fields(); i++)
 +    {
 +      Field *field= tl.table->field[i];
 +      if (num_privilege_cols > 0 && field->real_type() != MYSQL_TYPE_ENUM)
 +        return;
 +      if (field->real_type() == MYSQL_TYPE_ENUM &&
 +          static_cast<Field_enum*>(field)->typelib->count == 2)
 +      {
 +        num_privilege_cols++;
 +        if (num_privilege_cols == 1)
 +          start_privilege_column= i;
 +      }
 +    }
 +  }
 +
 +  /* The index at which privilege columns start. */
 +  uint start_privilege_column;
 +  /* The number of privilege columns in the table. */
 +  uint num_privilege_cols;
 +
 +  TABLE_LIST tl;
 +};
 +
 +class User_table: public Grant_table_base
 +{
 + public:
 +  /* Field getters return NULL if the column is not present in the table.
 +     This is consistent only if the table is in a supported version. We do
 +     not guard against corrupt tables. (yet) */
 +  Field* host() const
 +  { return get_field(0); }
 +  Field* user() const
 +  { return get_field(1); }
 +  Field* password() const
 +  { return have_password() ? NULL : tl.table->field[2]; }
 +  /* Columns after privilege columns. */
 +  Field* ssl_type() const
 +  { return get_field(start_privilege_column + num_privileges()); }
 +  Field* ssl_cipher() const
 +  { return get_field(start_privilege_column + num_privileges() + 1); }
 +  Field* x509_issuer() const
 +  { return get_field(start_privilege_column + num_privileges() + 2); }
 +  Field* x509_subject() const
 +  { return get_field(start_privilege_column + num_privileges() + 3); }
 +  Field* max_questions() const
 +  { return get_field(start_privilege_column + num_privileges() + 4); }
 +  Field* max_updates() const
 +  { return get_field(start_privilege_column + num_privileges() + 5); }
 +  Field* max_connections() const
 +  { return get_field(start_privilege_column + num_privileges() + 6); }
 +  Field* max_user_connections() const
 +  { return get_field(start_privilege_column + num_privileges() + 7); }
 +  Field* plugin() const
 +  { return get_field(start_privilege_column + num_privileges() + 8); }
 +  Field* authentication_string() const
 +  { return get_field(start_privilege_column + num_privileges() + 9); }
 +  Field* password_expired() const
 +  { return get_field(start_privilege_column + num_privileges() + 10); }
 +  Field* is_role() const
 +  { return get_field(start_privilege_column + num_privileges() + 11); }
 +  Field* default_role() const
 +  { return get_field(start_privilege_column + num_privileges() + 12); }
 +  Field* max_statement_time() const
 +  { return get_field(start_privilege_column + num_privileges() + 13); }
 +
 +  /*
 +    Check if a user entry in the user table is marked as being a role entry
 +
 +    IMPLEMENTATION
 +    Access the coresponding column and check the coresponding ENUM of the form
 +    ENUM('N', 'Y')
 +
 +    SYNOPSIS
 +      check_is_role()
 +      form      an open table to read the entry from.
 +                The record should be already read in table->record[0]
 +
 +    RETURN VALUE
 +      TRUE      if the user is marked as a role
 +      FALSE     otherwise
 +  */
 +  bool check_is_role() const
 +  {
 +    /* Table version does not support roles */
 +    if (!is_role())
 +      return false;
 +
 +    return get_YN_as_bool(is_role());
 +  }
 +
  
 -const LEX_STRING acl_table_names[]=     //  matches enum_acl_tables
 + private:
 +  friend class Grant_tables;
 +
 +  /* Only Grant_tables can instantiate this class. */
 +  User_table() {};
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("user"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, false);
 +  }
 +
 +  /* The user table is a bit different compared to the other Grant tables.
 +     Usually, we only add columns to the grant tables when adding functionality.
 +     This makes it easy to test which version of the table we are using, by
 +     just looking at the number of fields present in the table.
 +
 +     In MySQL 5.7.6 the Password column was removed. We need to guard for that.
 +     The field-fetching methods for the User table return NULL if the field
 +     doesn't exist. This simplifies checking of table "version", as we don't
 +     have to make use of num_fields() any more.
 +  */
 +  inline Field* get_field(uint field_num) const
 +  {
 +    if (field_num >= num_fields())
 +      return NULL;
 +
 +    return tl.table->field[field_num];
 +  }
 +
 +  /* Normally password column is the third column in the table. If privileges
 +     start on the third column instead, we are missing the password column.
 +     This means we are using a MySQL 5.7.6+ data directory. */
 +  bool have_password() const { return start_privilege_column == 2; }
 +
 +};
 +
 +class Db_table: public Grant_table_base
  {
 -  { C_STRING_WITH_LEN("user") },
 -  { C_STRING_WITH_LEN("db") },
 -  { C_STRING_WITH_LEN("tables_priv") },
 -  { C_STRING_WITH_LEN("columns_priv") },
 -  { C_STRING_WITH_LEN("host") },
 -  { C_STRING_WITH_LEN("procs_priv") },
 -  { C_STRING_WITH_LEN("proxies_priv") },
 -  { C_STRING_WITH_LEN("roles_mapping") }
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* db() const { return tl.table->field[1]; }
 +  Field* user() const { return tl.table->field[2]; }
 +
 + private:
 +  friend class Grant_tables;
 +
 +  Db_table() {};
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("db"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, false);
 +  }
  };
  
 -/** check if the table was opened, issue an error otherwise */
 -static int no_such_table(TABLE_LIST *tl)
 +class Tables_priv_table: public Grant_table_base
  {
 -  if (tl->table)
 -    return 0;
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* db() const { return tl.table->field[1]; }
 +  Field* user() const { return tl.table->field[2]; }
 +  Field* table_name() const { return tl.table->field[3]; }
 +  Field* grantor() const { return tl.table->field[4]; }
 +  Field* timestamp() const { return tl.table->field[5]; }
 +  Field* table_priv() const { return tl.table->field[6]; }
 +  Field* column_priv() const { return tl.table->field[7]; }
  
 -  my_error(ER_NO_SUCH_TABLE, MYF(0), tl->db, tl->alias);
 -  return 1;
 + private:
 +  friend class Grant_tables;
 +
 +  Tables_priv_table() {};
 +
 +  void init(enum thr_lock_type lock_type, Grant_table_base *next_table= NULL)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("tables_priv"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, false);
 +  }
 +};
 +
 +class Columns_priv_table: public Grant_table_base
 +{
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* db() const { return tl.table->field[1]; }
 +  Field* user() const { return tl.table->field[2]; }
 +  Field* table_name() const { return tl.table->field[3]; }
 +  Field* column_name() const { return tl.table->field[4]; }
 +  Field* timestamp() const { return tl.table->field[5]; }
 +  Field* column_priv() const { return tl.table->field[6]; }
 +
 + private:
 +  friend class Grant_tables;
 +
 +  Columns_priv_table() {};
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("columns_priv"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, false);
 +  }
 +};
 +
 +class Host_table: public Grant_table_base
 +{
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* db() const { return tl.table->field[1]; }
 +
 + private:
 +  friend class Grant_tables;
 +
 +  Host_table() {}
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("host"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, true);
 +  }
 +};
 +
 +class Procs_priv_table: public Grant_table_base
 +{
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* db() const { return tl.table->field[1]; }
 +  Field* user() const { return tl.table->field[2]; }
 +  Field* routine_name() const { return tl.table->field[3]; }
 +  Field* routine_type() const { return tl.table->field[4]; }
 +  Field* grantor() const { return tl.table->field[5]; }
 +  Field* proc_priv() const { return tl.table->field[6]; }
 +  Field* timestamp() const { return tl.table->field[7]; }
 +
 + private:
 +  friend class Grant_tables;
 +
 +  Procs_priv_table() {}
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("procs_priv"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, true);
 +  }
 +};
 +
 +class Proxies_priv_table: public Grant_table_base
 +{
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* user() const { return tl.table->field[1]; }
 +  Field* proxied_host() const { return tl.table->field[2]; }
 +  Field* proxied_user() const { return tl.table->field[3]; }
 +  Field* with_grant() const { return tl.table->field[4]; }
 +  Field* grantor() const { return tl.table->field[5]; }
 +  Field* timestamp() const { return tl.table->field[6]; }
 +
 + private:
 +  friend class Grant_tables;
 +
 +  Proxies_priv_table() {}
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("proxies_priv"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, true);
 +  }
 +};
 +
 +class Roles_mapping_table: public Grant_table_base
 +{
 + public:
 +  Field* host() const { return tl.table->field[0]; }
 +  Field* user() const { return tl.table->field[1]; }
 +  Field* role() const { return tl.table->field[2]; }
 +  Field* admin_option() const { return tl.table->field[3]; }
 +
 + private:
 +  friend class Grant_tables;
 +
 +  Roles_mapping_table() {}
 +
 +  void init(enum thr_lock_type lock_type)
 +  {
 +    /* We are relying on init_one_table zeroing out the TABLE_LIST structure. */
 +    tl.init_one_table(C_STRING_WITH_LEN("mysql"),
 +                      C_STRING_WITH_LEN("roles_mapping"),
 +                      NULL, lock_type);
 +    Grant_table_base::init(lock_type, true);
 +  }
 +};
 +
 +/**
 +  Class that represents a collection of grant tables.
 +*/
 +class Grant_tables
 +{
 + public:
 +  /* When constructing the Grant_tables object, we initialize only
 +     the tables which are going to be opened.
 +     @param which_tables   Bitmap of which tables to open.
 +     @param lock_type      Lock type to use when opening tables.
 +  */
 +  Grant_tables(int which_tables, enum thr_lock_type lock_type)
 +  {
 +    DBUG_ENTER("Grant_tables::Grant_tables");
 +    DBUG_PRINT("info", ("which_tables: %x, lock_type: %u",
 +                        which_tables, lock_type));
 +    DBUG_ASSERT(which_tables); /* At least one table must be opened. */
 +    Grant_table_base* prev= NULL;
 +    /* We start from the last table, Table_roles_mapping, such that
 +       the first one in the linked list is Table_user. */
 +    if (which_tables & Table_roles_mapping)
 +    {
 +      m_roles_mapping_table.init(lock_type);
 +      prev= &m_roles_mapping_table;
 +    }
 +    if (which_tables & Table_proxies_priv)
 +    {
 +      m_proxies_priv_table.init(lock_type);
 +      link_tables(&m_proxies_priv_table, prev);
 +      prev= &m_proxies_priv_table;
 +    }
 +    if (which_tables & Table_procs_priv)
 +    {
 +      m_procs_priv_table.init(lock_type);
 +      link_tables(&m_procs_priv_table, prev);
 +      prev= &m_procs_priv_table;
 +    }
 +    if (which_tables & Table_host)
 +    {
 +      m_host_table.init(lock_type);
 +      link_tables(&m_host_table, prev);
 +      prev= &m_host_table;
 +    }
 +    if (which_tables & Table_columns_priv)
 +    {
 +      m_columns_priv_table.init(lock_type);
 +      link_tables(&m_columns_priv_table, prev);
 +      prev= &m_columns_priv_table;
 +    }
 +    if (which_tables & Table_tables_priv)
 +    {
 +      m_tables_priv_table.init(lock_type);
 +      link_tables(&m_tables_priv_table, prev);
 +      prev= &m_tables_priv_table;
 +    }
 +    if (which_tables & Table_db)
 +    {
 +      m_db_table.init(lock_type);
 +      link_tables(&m_db_table, prev);
 +      prev= &m_db_table;
 +    }
 +    if (which_tables & Table_user)
 +    {
 +      m_user_table.init(lock_type);
 +      link_tables(&m_user_table, prev);
 +      prev= &m_user_table;
 +    }
 +
 +    first_table_in_list= prev;
 +    DBUG_VOID_RETURN;
 +  }
 +
 +  /* Before any operation is possible on grant tables, they must be opened.
 +     This opens the tables according to the lock type specified during
 +     construction.
 +
 +     @retval  1 replication filters matched. Abort the operation,
 +                but return OK (!)
 +     @retval  0 tables were opened successfully
 +     @retval -1 error, tables could not be opened
 +  */
 +  int open_and_lock(THD *thd)
 +  {
 +    DBUG_ENTER("Grant_tables::open_and_lock");
 +    DBUG_ASSERT(first_table_in_list);
 +#ifdef HAVE_REPLICATION
 +    if (first_table_in_list->tl.lock_type >= TL_WRITE_ALLOW_WRITE &&
 +        thd->slave_thread && !thd->spcont)
 +    {
 +      /*
 +        GRANT and REVOKE are applied the slave in/exclusion rules as they are
 +        some kind of updates to the mysql.% tables.
 +      */
 +      Rpl_filter *rpl_filter= thd->system_thread_info.rpl_sql_info->rpl_filter;
 +      if (rpl_filter->is_on() &&
 +          !rpl_filter->tables_ok(0, &first_table_in_list->tl))
 +        DBUG_RETURN(1);
 +    }
 +#endif
 +    if (open_and_lock_tables(thd, &first_table_in_list->tl, FALSE,
 +                             MYSQL_LOCK_IGNORE_TIMEOUT))
 +      DBUG_RETURN(-1);
 +
 +    /*
 +       We can read privilege tables even when !initialized.
 +       This can be acl_load() - server startup or FLUSH PRIVILEGES
 +       */
 +    if (first_table_in_list->tl.lock_type >= TL_WRITE_ALLOW_WRITE &&
 +        !initialized)
 +    {
 +      my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables");
 +      DBUG_RETURN(-1);
 +    }
 +
 +    /* The privilge columns vary based on MariaDB version. Figure out
 +       how many we have after we've opened the table. */
 +    m_user_table.compute_num_privilege_cols();
 +    m_db_table.compute_num_privilege_cols();
 +    m_tables_priv_table.compute_num_privilege_cols();
 +    m_columns_priv_table.compute_num_privilege_cols();
 +    m_host_table.compute_num_privilege_cols();
 +    m_procs_priv_table.compute_num_privilege_cols();
 +    m_proxies_priv_table.compute_num_privilege_cols();
 +    m_roles_mapping_table.compute_num_privilege_cols();
 +    DBUG_RETURN(0);
 +  }
 +
 +  inline const User_table& user_table() const
 +  {
 +    return m_user_table;
 +  }
 +
 +  inline const Db_table& db_table() const
 +  {
 +    return m_db_table;
 +  }
 +
 +
 +  inline const Tables_priv_table& tables_priv_table() const
 +  {
 +    return m_tables_priv_table;
 +  }
 +
 +  inline const Columns_priv_table& columns_priv_table() const
 +  {
 +    return m_columns_priv_table;
 +  }
 +
 +  inline const Host_table& host_table() const
 +  {
 +    return m_host_table;
 +  }
 +
 +  inline const Procs_priv_table& procs_priv_table() const
 +  {
 +    return m_procs_priv_table;
 +  }
 +
 +  inline const Proxies_priv_table& proxies_priv_table() const
 +  {
 +    return m_proxies_priv_table;
 +  }
 +
 +  inline const Roles_mapping_table& roles_mapping_table() const
 +  {
 +    return m_roles_mapping_table;
 +  }
 +
 + private:
 +  User_table m_user_table;
 +  Db_table m_db_table;
 +  Tables_priv_table m_tables_priv_table;
 +  Columns_priv_table m_columns_priv_table;
 +  Host_table m_host_table;
 +  Procs_priv_table m_procs_priv_table;
 +  Proxies_priv_table m_proxies_priv_table;
 +  Roles_mapping_table m_roles_mapping_table;
 +
 +  /* The grant tables are set-up in a linked list. We keep the head of it. */
 +  Grant_table_base *first_table_in_list;
 +  /**
 +    Chain two grant tables' TABLE_LIST members.
 +  */
 +  static void link_tables(Grant_table_base *from, Grant_table_base *to)
 +  {
 +    DBUG_ASSERT(from);
 +    if (to)
 +      from->tl.next_local= from->tl.next_global= &to->tl;
 +    else
 +      from->tl.next_local= from->tl.next_global= NULL;
 +  }
 +};
 +
 +
 +void ACL_PROXY_USER::init(const Proxies_priv_table& proxies_priv_table,
 +                          MEM_ROOT *mem)
 +{
 +  init(get_field(mem, proxies_priv_table.host()),
 +       get_field(mem, proxies_priv_table.user()),
 +       get_field(mem, proxies_priv_table.proxied_host()),
 +       get_field(mem, proxies_priv_table.proxied_user()),
 +       proxies_priv_table.with_grant()->val_int() != 0);
  }
  
 +
 +
  /*
   Enumeration of various ACL's and Hashes used in handle_grant_struct()
  */
@@@ -1871,56 -1266,61 +1870,62 @@@ static bool acl_load(THD *thd, const Gr
    }
    freeze_size(&acl_hosts);
  
 -  if (init_read_record(&read_record_info, thd, table=tables[USER_TABLE].table,
 -                       NULL, 1, 1, FALSE))
 -    goto end;
 -  table->use_all_columns();
 +  const User_table& user_table= tables.user_table();
 +  if (user_table.init_read_record(&read_record_info, thd))
 +    DBUG_RETURN(true);
  
 -  if (table->s->fields < 13) // number of columns in 3.21
++  if (user_table.num_fields() < 13) // number of columns in 3.21
+   {
+     sql_print_error("Fatal error: mysql.user table is damaged or in "
+                     "unsupported 3.20 format.");
 -    goto end;
++    DBUG_RETURN(true);
+   }
 -
 -  username_char_length= MY_MIN(table->field[1]->char_length(),
 +  username_char_length= MY_MIN(user_table.user()->char_length(),
                                 USERNAME_CHAR_LENGTH);
 -  password_length= table->field[2]->field_length /
 -    table->field[2]->charset()->mbmaxlen;
 -  if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323)
 +  if (user_table.password()) // Password column might be missing. (MySQL 5.7.6+)
    {
 -    sql_print_error("Fatal error: mysql.user table is damaged or in "
 -                    "unsupported 3.20 format.");
 -    goto end;
 -  }
 +    password_length= user_table.password()->field_length /
 +                     user_table.password()->charset()->mbmaxlen;
 +    if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323)
 +    {
 +      sql_print_error("Fatal error: mysql.user table is damaged or in "
 +                      "unsupported 3.20 format.");
 +      DBUG_RETURN(TRUE);
 +    }
  
 -  DBUG_PRINT("info",("user table fields: %d, password length: %d",
 -		     table->s->fields, password_length));
 +    DBUG_PRINT("info",("user table fields: %d, password length: %d",
 +                       user_table.num_fields(), password_length));
  
 -  mysql_mutex_lock(&LOCK_global_system_variables);
 -  if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH)
 -  {
 -    if (opt_secure_auth)
 +    mysql_mutex_lock(&LOCK_global_system_variables);
 +    if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH)
      {
 -      mysql_mutex_unlock(&LOCK_global_system_variables);
 -      sql_print_error("Fatal error: mysql.user table is in old format, "
 -                      "but server started with --secure-auth option.");
 -      goto end;
 +      if (opt_secure_auth)
 +      {
 +        mysql_mutex_unlock(&LOCK_global_system_variables);
 +        sql_print_error("Fatal error: mysql.user table is in old format, "
 +                        "but server started with --secure-auth option.");
 +        DBUG_RETURN(TRUE);
 +      }
 +      mysql_user_table_is_in_short_password_format= true;
 +      if (global_system_variables.old_passwords)
 +        mysql_mutex_unlock(&LOCK_global_system_variables);
 +      else
 +      {
 +        extern sys_var *Sys_old_passwords_ptr;
 +        Sys_old_passwords_ptr->value_origin= sys_var::AUTO;
 +        global_system_variables.old_passwords= 1;
 +        mysql_mutex_unlock(&LOCK_global_system_variables);
 +        sql_print_warning("mysql.user table is not updated to new password format; "
 +                          "Disabling new password usage until "
 +                          "mysql_fix_privilege_tables is run");
 +      }
 +      thd->variables.old_passwords= 1;
      }
 -    mysql_user_table_is_in_short_password_format= true;
 -    if (global_system_variables.old_passwords)
 -      mysql_mutex_unlock(&LOCK_global_system_variables);
      else
      {
 -      extern sys_var *Sys_old_passwords_ptr;
 -      Sys_old_passwords_ptr->value_origin= sys_var::AUTO;
 -      global_system_variables.old_passwords= 1;
 +      mysql_user_table_is_in_short_password_format= false;
        mysql_mutex_unlock(&LOCK_global_system_variables);
 -      sql_print_warning("mysql.user table is not updated to new password format; "
 -                        "Disabling new password usage until "
 -                        "mysql_fix_privilege_tables is run");
      }
 -    thd->variables.old_passwords= 1;
 -  }
 -  else
 -  {
 -    mysql_user_table_is_in_short_password_format= false;
 -    mysql_mutex_unlock(&LOCK_global_system_variables);
    }
  
    allow_all_hosts=0;
diff --cc sql/sql_class.cc
index 1c29e3d18a7,6fa8c100894..142088faea4
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@@ -840,11 -983,10 +840,12 @@@ THD::THD(my_thread_id id, bool is_wsrep
    memset(&invoker_host, 0, sizeof(invoker_host));
    prepare_derived_at_open= FALSE;
    create_tmp_table_for_derived= FALSE;
+   force_read_stats= FALSE;
    save_prep_leaf_list= FALSE;
 +  org_charset= 0;
    /* Restore THR_THD */
    set_current_thd(old_THR_THD);
 +  inc_thread_count();
  }
  
  
diff --cc sql/sql_class.h
index 38e55f9c4a9,c0dc42deefe..9c968abf25c
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@@ -37,7 -36,7 +37,8 @@@
  #include "violite.h"        /* vio_is_connected */
  #include "thr_lock.h"       /* thr_lock_type, THR_LOCK_DATA, THR_LOCK_INFO */
  #include "thr_timer.h"
 +#include "thr_malloc.h"
+ #include <my_tree.h>
  
  #include "sql_digest_stream.h"            // sql_digest_state
  
diff --cc sql/sql_db.cc
index 0e554e29380,7b83332ea62..ebc04decbb3
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@@ -1616,10 -1610,7 +1616,10 @@@ uint mysql_change_db(THD *thd, const LE
  
    mysql_change_db_impl(thd, &new_db_file_name, db_access, db_default_cl);
  
 +done:
 +  SESSION_TRACKER_CHANGED(thd, CURRENT_SCHEMA_TRACKER, NULL);
 +  SESSION_TRACKER_CHANGED(thd, SESSION_STATE_CHANGE_TRACKER, NULL);
-   DBUG_RETURN(FALSE);
+   DBUG_RETURN(0);
  }
  
  
diff --cc sql/sql_lex.h
index 2af1d527cd3,845e1242eb7..a880b6e4283
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@@ -547,21 -543,8 +547,21 @@@ public
  					List<Index_hint> *hints= 0,
                                          List<String> *partition_names= 0,
                                          LEX_STRING *option= 0);
-   virtual void set_lock_for_tables(thr_lock_type lock_type) {}
+   virtual void set_lock_for_tables(thr_lock_type lock_type, bool for_update) {}
 -
 +  void set_slave(st_select_lex_node *slave_arg) { slave= slave_arg; }
 +  void move_node(st_select_lex_node *where_to_move)
 +  {
 +    if (where_to_move == this)
 +      return;
 +    if (next)
 +      next->prev= prev;
 +    *prev= next;
 +    *where_to_move->prev= this;
 +    next= where_to_move;
 +  }
 +  st_select_lex_node *insert_chain_before(st_select_lex_node **ptr_pos_to_insert,
 +                                          st_select_lex_node *end_chain_node);
 +  void move_as_slave(st_select_lex_node *new_master);
    friend class st_select_lex_unit;
    friend bool mysql_new_select(LEX *lex, bool move_down);
    friend bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
diff --cc sql/sql_select.cc
index bcbe4597aff,eb9e0492dc7..5e0472b4224
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@@ -16486,15 -16301,7 +16493,8 @@@ Field *create_tmp_field(THD *thd, TABL
    case Item::NULL_ITEM:
    case Item::VARBIN_ITEM:
    case Item::CACHE_ITEM:
 +  case Item::WINDOW_FUNC_ITEM: // psergey-winfunc:
-   case Item::EXPR_CACHE_ITEM:
    case Item::PARAM_ITEM:
-     if (make_copy_field)
-     {
-       DBUG_ASSERT(((Item_result_field*)item)->result_field);
-       *from_field= ((Item_result_field*)item)->result_field;
-     }
      return create_tmp_field_from_item(thd, item, table,
                                        (make_copy_field ? 0 : copy_func),
                                         modify_item);
diff --cc sql/sql_show.cc
index c84ac5f4977,d8b35eda089..56103d8b654
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@@ -4398,19 -4272,15 +4398,16 @@@ fill_schema_table_by_open(THD *thd, boo
      SQLCOM_SHOW_FIELDS is used because it satisfies
      'only_view_structure()'.
    */
-   lex->sql_command= SQLCOM_SHOW_FIELDS;
    thd->force_read_stats= get_schema_table_idx(schema_table) == SCH_STATISTICS;
+   lex->sql_command= SQLCOM_SHOW_FIELDS;
 -  result= (open_temporary_tables(thd, table_list) ||
 +  result= (thd->open_temporary_tables(table_list) ||
             open_normal_and_derived_tables(thd, table_list,
                                            (MYSQL_OPEN_IGNORE_FLUSH |
                                             MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL |
                                             (can_deadlock ?
                                              MYSQL_OPEN_FAIL_ON_MDL_CONFLICT : 0)),
 -                                          DT_PREPARE | DT_CREATE));
 +					  DT_INIT | DT_PREPARE | DT_CREATE));
 +
-   (void) read_statistics_for_tables_if_needed(thd, table_list);
-   thd->force_read_stats= false;
- 
    /*
      Restore old value of sql_command back as it is being looked at in
      process_table() function.
diff --cc storage/innobase/dict/dict0stats.cc
index d6d7845b2c3,06364689173..6dd3c9c930f
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@@ -1,7 -1,7 +1,7 @@@
  /*****************************************************************************
  
- Copyright (c) 2009, 2018, Oracle and/or its affiliates. All Rights Reserved.
+ Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved.
 -Copyright (c) 2015, 2017, MariaDB Corporation.
 +Copyright (c) 2015, 2018, MariaDB Corporation.
  
  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
diff --cc storage/innobase/handler/handler0alter.cc
index 005c0fd5adf,0d0982fa498..f470ac3ca4c
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@@ -104,170 -98,10 +104,187 @@@ static const Alter_inplace_info::HA_ALT
  	| INNOBASE_FOREIGN_OPERATIONS
  	| Alter_inplace_info::DROP_INDEX
  	| Alter_inplace_info::DROP_UNIQUE_INDEX
 -	| Alter_inplace_info::ALTER_COLUMN_NAME;
 +	| Alter_inplace_info::ALTER_COLUMN_NAME
 +	| Alter_inplace_info::ALTER_COLUMN_EQUAL_PACK_LENGTH
 +	//| Alter_inplace_info::ALTER_INDEX_COMMENT
 +	| Alter_inplace_info::ADD_VIRTUAL_COLUMN
 +	| Alter_inplace_info::DROP_VIRTUAL_COLUMN
 +	| Alter_inplace_info::ALTER_VIRTUAL_COLUMN_ORDER;
 +
 +struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
 +{
 +	/** Dummy query graph */
 +	que_thr_t*	thr;
 +	/** The prebuilt struct of the creating instance */
 +	row_prebuilt_t*&	prebuilt;
 +	/** InnoDB indexes being created */
 +	dict_index_t**	add_index;
 +	/** MySQL key numbers for the InnoDB indexes that are being created */
 +	const ulint*	add_key_numbers;
 +	/** number of InnoDB indexes being created */
 +	ulint		num_to_add_index;
 +	/** InnoDB indexes being dropped */
 +	dict_index_t**	drop_index;
 +	/** number of InnoDB indexes being dropped */
 +	const ulint	num_to_drop_index;
 +	/** InnoDB indexes being renamed */
 +	dict_index_t**	rename;
 +	/** number of InnoDB indexes being renamed */
 +	const ulint	num_to_rename;
 +	/** InnoDB foreign key constraints being dropped */
 +	dict_foreign_t** drop_fk;
 +	/** number of InnoDB foreign key constraints being dropped */
 +	const ulint	num_to_drop_fk;
 +	/** InnoDB foreign key constraints being added */
 +	dict_foreign_t** add_fk;
 +	/** number of InnoDB foreign key constraints being dropped */
 +	const ulint	num_to_add_fk;
 +	/** whether to create the indexes online */
 +	bool		online;
 +	/** memory heap */
 +	mem_heap_t*	heap;
 +	/** dictionary transaction */
 +	trx_t*		trx;
 +	/** original table (if rebuilt, differs from indexed_table) */
 +	dict_table_t*	old_table;
 +	/** table where the indexes are being created or dropped */
 +	dict_table_t*	new_table;
 +	/** mapping of old column numbers to new ones, or NULL */
 +	const ulint*	col_map;
 +	/** new column names, or NULL if nothing was renamed */
 +	const char**	col_names;
 +	/** added AUTO_INCREMENT column position, or ULINT_UNDEFINED */
 +	const ulint	add_autoinc;
 +	/** default values of ADD COLUMN, or NULL */
 +	const dtuple_t*	add_cols;
 +	/** autoinc sequence to use */
 +	ib_sequence_t	sequence;
 +	/** temporary table name to use for old table when renaming tables */
 +	const char*	tmp_name;
 +	/** whether the order of the clustered index is unchanged */
 +	bool		skip_pk_sort;
 +	/** number of virtual columns to be added */
 +	ulint		num_to_add_vcol;
 +	/** virtual columns to be added */
 +	dict_v_col_t*	add_vcol;
 +	const char**	add_vcol_name;
 +	/** number of virtual columns to be dropped */
 +	ulint		num_to_drop_vcol;
 +	/** virtual columns to be dropped */
 +	dict_v_col_t*	drop_vcol;
 +	const char**	drop_vcol_name;
 +	/** ALTER TABLE stage progress recorder */
 +	ut_stage_alter_t* m_stage;
 +
 +	ha_innobase_inplace_ctx(row_prebuilt_t*& prebuilt_arg,
 +				dict_index_t** drop_arg,
 +				ulint num_to_drop_arg,
 +				dict_index_t** rename_arg,
 +				ulint num_to_rename_arg,
 +				dict_foreign_t** drop_fk_arg,
 +				ulint num_to_drop_fk_arg,
 +				dict_foreign_t** add_fk_arg,
 +				ulint num_to_add_fk_arg,
 +				bool online_arg,
 +				mem_heap_t* heap_arg,
 +				dict_table_t* new_table_arg,
 +				const char** col_names_arg,
 +				ulint add_autoinc_arg,
 +				ulonglong autoinc_col_min_value_arg,
 +				ulonglong autoinc_col_max_value_arg,
 +				ulint num_to_drop_vcol_arg) :
 +		inplace_alter_handler_ctx(),
 +		prebuilt (prebuilt_arg),
 +		add_index (0), add_key_numbers (0), num_to_add_index (0),
 +		drop_index (drop_arg), num_to_drop_index (num_to_drop_arg),
 +		rename (rename_arg), num_to_rename (num_to_rename_arg),
 +		drop_fk (drop_fk_arg), num_to_drop_fk (num_to_drop_fk_arg),
 +		add_fk (add_fk_arg), num_to_add_fk (num_to_add_fk_arg),
 +		online (online_arg), heap (heap_arg), trx (0),
 +		old_table (prebuilt_arg->table),
 +		new_table (new_table_arg),
 +		col_map (0), col_names (col_names_arg),
 +		add_autoinc (add_autoinc_arg),
 +		add_cols (0),
 +		sequence(prebuilt->trx->mysql_thd,
 +			 autoinc_col_min_value_arg, autoinc_col_max_value_arg),
 +		tmp_name (0),
 +		skip_pk_sort(false),
 +		num_to_add_vcol(0),
 +		add_vcol(0),
 +		add_vcol_name(0),
 +		num_to_drop_vcol(0),
 +		drop_vcol(0),
 +		drop_vcol_name(0),
 +		m_stage(NULL)
 +	{
 +#ifdef UNIV_DEBUG
 +		for (ulint i = 0; i < num_to_add_index; i++) {
 +			ut_ad(!add_index[i]->to_be_dropped);
 +		}
 +		for (ulint i = 0; i < num_to_drop_index; i++) {
 +			ut_ad(drop_index[i]->to_be_dropped);
 +		}
 +#endif /* UNIV_DEBUG */
 +
 +		thr = pars_complete_graph_for_exec(NULL, prebuilt->trx, heap,
 +			prebuilt);
 +	}
 +
 +	~ha_innobase_inplace_ctx()
 +	{
 +		UT_DELETE(m_stage);
 +		mem_heap_free(heap);
 +	}
 +
 +	/** Determine if the table will be rebuilt.
 +	@return whether the table will be rebuilt */
 +	bool need_rebuild () const { return(old_table != new_table); }
 +
 +	/** Clear uncommmitted added indexes after a failed operation. */
 +	void clear_added_indexes()
 +	{
 +		for (ulint i = 0; i < num_to_add_index; i++) {
 +			if (!add_index[i]->is_committed()) {
 +				add_index[i]->detach_columns();
 +			}
 +		}
 +	}
 +
++	/** Share context between partitions.
++	@param[in] ctx	context from another partition of the table */
++	void set_shared_data(const inplace_alter_handler_ctx& ctx)
++	{
++		if (add_autoinc != ULINT_UNDEFINED) {
++			const ha_innobase_inplace_ctx& ha_ctx =
++				static_cast<const ha_innobase_inplace_ctx&>
++				(ctx);
++			/* When adding an AUTO_INCREMENT column to a
++			partitioned InnoDB table, we must share the
++			sequence for all partitions. */
++			ut_ad(ha_ctx.add_autoinc == add_autoinc);
++			ut_ad(ha_ctx.sequence.last());
++			sequence = ha_ctx.sequence;
++		}
++	}
++
 +private:
 +	// Disable copying
 +	ha_innobase_inplace_ctx(const ha_innobase_inplace_ctx&);
 +	ha_innobase_inplace_ctx& operator=(const ha_innobase_inplace_ctx&);
 +};
 +
 +/********************************************************************//**
 +Get the upper limit of the MySQL integral and floating-point type.
 + at return maximum allowed value for the field */
 +UNIV_INTERN
 +ulonglong
 +innobase_get_int_col_max_value(
 +/*===========================*/
 +	const Field*	field);	/*!< in: MySQL field */
  
  /* Report an InnoDB error to the client by invoking my_error(). */
 -static UNIV_COLD MY_ATTRIBUTE((nonnull))
 +static ATTRIBUTE_COLD __attribute__((nonnull))
  void
  my_error_innodb(
  /*============*/
diff --cc storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result
index 65057791b48,c71dcadc32f..5f41fd328c9
--- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result
+++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_mixed_dml.result
@@@ -682,6 -681,9 +682,8 @@@ DROP TRIGGER tr1
  GRANT EVENT ON *.* TO 'root'@'localhost';
  INSERT INTO t1 VALUES(1, 'test1');
  CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1;
+ Warnings:
+ Warning	1105	Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
 -==========MASTER==========
  SHOW EVENTS;
  Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
  test_rpl	e1	root at localhost	SYSTEM	RECURRING	NULL	1	#	#	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
diff --cc storage/tokudb/mysql-test/tokudb_bugs/r/PS-5163.result
index 00000000000,a203787f11d..27e19150945
mode 000000,100644..100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/PS-5163.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/PS-5163.result
@@@ -1,0 -1,5 +1,5 @@@
 -CREATE TABLE t1(c1 INT,c2 INT,c3 CHAR(10),c4 CHAR(10),c5 CHAR(10),PRIMARY KEY(c1),INDEX(c3,c4(1),c5(1)),INDEX(c2)) ENGINE=TokuDB;
++CREATE TABLE t1(c1 INT default 0,c2 INT,c3 CHAR(10),c4 CHAR(10),c5 CHAR(10),PRIMARY KEY(c1),INDEX(c3,c4(1),c5(1)),INDEX(c2)) ENGINE=TokuDB;
+ INSERT INTO t1 VALUES(),(),(),(),();
+ ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+ UPDATE t1 SET c1=1 WHERE c1=1 OR c2=1;
+ DROP TABLE t1;
diff --cc storage/tokudb/mysql-test/tokudb_bugs/t/PS-5163.test
index 00000000000,5fc01bb5f0e..d370bab6517
mode 000000,100644..100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/t/PS-5163.test
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/PS-5163.test
@@@ -1,0 -1,11 +1,11 @@@
+ --source include/have_tokudb.inc
+ 
 -CREATE TABLE t1(c1 INT,c2 INT,c3 CHAR(10),c4 CHAR(10),c5 CHAR(10),PRIMARY KEY(c1),INDEX(c3,c4(1),c5(1)),INDEX(c2)) ENGINE=TokuDB;
++CREATE TABLE t1(c1 INT default 0,c2 INT,c3 CHAR(10),c4 CHAR(10),c5 CHAR(10),PRIMARY KEY(c1),INDEX(c3,c4(1),c5(1)),INDEX(c2)) ENGINE=TokuDB;
+ --error ER_DUP_ENTRY
+ INSERT INTO t1 VALUES(),(),(),(),();
+ 
+ # 8.0 asserts here down in data dictionary because ha_tokudb::ds_mrr did not
+ # properly call ds_mrr.init(this, table)
+ UPDATE t1 SET c1=1 WHERE c1=1 OR c2=1;
+ 
+ DROP TABLE t1;
diff --cc support-files/rpm/server-posttrans.sh
index 0d242596185,00000000000..1406c78a5f5
mode 100644,000000..100644
--- a/support-files/rpm/server-posttrans.sh
+++ b/support-files/rpm/server-posttrans.sh
@@@ -1,11 -1,0 +1,10 @@@
 +if [ -r %{restart_flag} ] ; then
 +  rm %{restart_flag}
 +  if [ -x /usr/bin/systemctl ] ; then
 +    /usr/bin/systemctl daemon-reload > /dev/null 2>&1
-   fi
- 
-   # only restart the server if it was alredy running
-   if %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then
++    /usr/bin/systemctl try-restart mariadb.service > /dev/null 2>&1
++  elif %{_sysconfdir}/init.d/mysql status > /dev/null 2>&1; then
++    # only restart the server if it was alredy running
 +    %{_sysconfdir}/init.d/mysql restart
 +  fi
 +fi


More information about the commits mailing list