[Commits] 40341d34f7c: Merge 10.0 into 10.1

marko.makela at mariadb.com marko.makela at mariadb.com
Wed Mar 8 14:22:55 EET 2017


revision-id: 40341d34f7c61e79de7c07eeb0018982bb75ab69 (mariadb-10.1.21-54-g40341d34f7c)
parent(s): 19629ebf813ef7825eb86a46045ebccdfd484d9a 74fe0e03d554130b60bf734531d1763451e6ceff
author: Marko Mäkelä
committer: Marko Mäkelä
timestamp: 2017-03-08 14:20:17 +0200
message:

Merge 10.0 into 10.1

Also, implement MDEV-11027 a little differently from 5.5 and 10.0:

recv_apply_hashed_log_recs(): Change the return type back to void
(DB_SUCCESS was always returned).

Report progress also via systemd using sd_notifyf().


 CMakeLists.txt                                     |    3 +
 client/mysqldump.c                                 |    5 +-
 config.h.cmake                                     |    1 -
 include/my_sys.h                                   |   12 +-
 include/mysql/psi/mysql_file.h                     |   39 -
 include/mysql/psi/psi.h                            |    2 +-
 mysql-test/include/gap_lock_error_all.inc          |   27 +
 mysql-test/include/gap_lock_error_cleanup.inc      |    1 +
 mysql-test/include/gap_lock_error_init.inc         |   24 +
 mysql-test/include/gap_lock_error_select.inc       |   89 +
 mysql-test/include/gap_lock_error_update.inc       |   91 +
 mysql-test/r/derived.result                        |   23 +
 mysql-test/r/grant.result                          |   70 +-
 mysql-test/r/join_nested.result                    |   95 +
 mysql-test/r/join_nested_jcl6.result               |   95 +
 mysql-test/r/mysqldump.result                      |    1 +
 mysql-test/r/partition_innodb.result               |   91 +
 mysql-test/r/partition_myisam.result               |   16 +
 mysql-test/r/ps.result                             |   72 +
 mysql-test/r/range_vs_index_merge.result           |   46 +-
 mysql-test/r/range_vs_index_merge_innodb.result    |   48 +-
 mysql-test/r/subselect4.result                     |   34 +
 mysql-test/r/subselect_innodb.result               |   15 +
 mysql-test/r/symlink-aria-11902.result             |   39 +
 mysql-test/r/symlink-myisam-11902.result           |   38 +
 mysql-test/r/table_elim.result                     |    5 +-
 mysql-test/r/view.result                           |   83 +
 .../suite/federated/federated_bug_35333.test       |    1 +
 mysql-test/suite/innodb/r/log_file_size.result     |   12 +-
 mysql-test/suite/innodb/t/log_file_size.test       |   16 +-
 .../suite/parts/r/partition_bigint_innodb.result   |  121 ++
 .../suite/parts/r/partition_bigint_myisam.result   |  121 ++
 .../suite/parts/r/partition_double_innodb.result   |   82 +
 .../suite/parts/r/partition_double_myisam.result   |   82 +
 .../suite/parts/r/partition_float_innodb.result    |   82 -
 .../suite/parts/r/partition_float_myisam.result    |   82 -
 .../suite/parts/r/partition_int_innodb.result      |  448 -----
 .../suite/parts/r/partition_int_myisam.result      |  448 -----
 .../parts/r/partition_mediumint_innodb.result      |  109 +
 .../parts/r/partition_mediumint_myisam.result      |  109 +
 .../suite/parts/r/partition_smallint_innodb.result |  109 +
 .../suite/parts/r/partition_smallint_myisam.result |  109 +
 .../suite/parts/r/partition_tinyint_innodb.result  |  109 +
 .../suite/parts/r/partition_tinyint_myisam.result  |  109 +
 .../suite/parts/t/partition_bigint_innodb.test     |   46 +
 .../suite/parts/t/partition_bigint_myisam.test     |   46 +
 .../suite/parts/t/partition_double_innodb.test     |   46 +
 .../suite/parts/t/partition_double_myisam.test     |   46 +
 .../suite/parts/t/partition_float_innodb.test      |    7 +-
 .../suite/parts/t/partition_float_myisam.test      |    7 +-
 mysql-test/suite/parts/t/partition_int_innodb.test |   10 +-
 mysql-test/suite/parts/t/partition_int_myisam.test |   10 +-
 .../suite/parts/t/partition_mediumint_innodb.test  |   46 +
 .../suite/parts/t/partition_mediumint_myisam.test  |   46 +
 .../suite/parts/t/partition_smallint_innodb.test   |   46 +
 .../suite/parts/t/partition_smallint_myisam.test   |   46 +
 .../suite/parts/t/partition_tinyint_innodb.test    |   46 +
 .../suite/parts/t/partition_tinyint_myisam.test    |   46 +
 mysql-test/suite/rpl/r/rpl_heartbeat_basic.result  |    3 +-
 mysql-test/suite/rpl/t/rpl_heartbeat_basic.test    |   46 +-
 ...innodb_stats_include_delete_marked_basic.result |   25 +
 .../innodb_stats_include_delete_marked_basic.test  |   53 +
 mysql-test/suite/sys_vars/t/secure_file_priv.test  |    3 +
 mysql-test/suite/vcol/r/vcol_select_myisam.result  |  109 +
 mysql-test/suite/vcol/t/vcol_select_myisam.test    |   32 +
 mysql-test/t/derived.test                          |   23 +
 mysql-test/t/grant.test                            |   85 +-
 mysql-test/t/join_nested.test                      |   71 +-
 mysql-test/t/mysqldump.test                        |    9 +
 mysql-test/t/partition_innodb.test                 |   98 +
 mysql-test/t/partition_myisam.test                 |   22 +
 mysql-test/t/ps.test                               |   33 +
 mysql-test/t/range_vs_index_merge.test             |   41 +-
 mysql-test/t/repair_symlink-5543.test              |    4 +-
 mysql-test/t/subselect4.test                       |   19 +
 mysql-test/t/subselect_innodb.test                 |   59 +-
 mysql-test/t/symlink-aria-11902.test               |    6 +
 mysql-test/t/symlink-myisam-11902.test             |   60 +
 mysql-test/t/table_elim.test                       |    4 +-
 mysql-test/t/view.test                             |   60 +
 mysql-test/unstable-tests                          |  121 +-
 mysql-test/valgrind.supp                           |   11 +
 mysys/mf_format.c                                  |    7 +-
 mysys/my_create.c                                  |   20 +-
 mysys/my_delete.c                                  |   11 +-
 mysys/my_div.c                                     |    2 +-
 mysys/my_fopen.c                                   |   18 +-
 mysys/my_init.c                                    |    2 +-
 mysys/my_open.c                                    |   41 +-
 mysys/my_symlink.c                                 |   94 +-
 mysys/my_symlink2.c                                |   49 +-
 mysys/my_sync.c                                    |    2 +-
 mysys/my_thr_init.c                                |   13 +-
 mysys/mysys_priv.h                                 |   28 +
 pcre/AUTHORS                                       |    6 +-
 pcre/CMakeLists.txt                                |    1 +
 pcre/ChangeLog                                     |   47 +
 pcre/LICENCE                                       |    6 +-
 pcre/NEWS                                          |    6 +
 pcre/configure.ac                                  |   10 +-
 pcre/doc/html/pcrecompat.html                      |    2 +-
 pcre/doc/html/pcrepattern.html                     |   37 +-
 pcre/doc/pcre.txt                                  | 2109 ++++++++++----------
 pcre/doc/pcrecompat.3                              |    2 +-
 pcre/doc/pcrepattern.3                             |   37 +-
 pcre/pcre_compile.c                                |   80 +-
 pcre/pcre_jit_compile.c                            |    4 +-
 pcre/pcre_jit_test.c                               |    1 +
 pcre/pcregrep.c                                    |    6 +
 pcre/pcretest.c                                    |   20 +-
 pcre/testdata/testinput1                           |    6 +
 pcre/testdata/testinput16                          |   26 +
 pcre/testdata/testinput19                          |   17 +
 pcre/testdata/testinput2                           |    6 +
 pcre/testdata/testinput6                           |    6 +
 pcre/testdata/testinput7                           |    9 -
 pcre/testdata/testinput8                           |    4 +
 pcre/testdata/testoutput1                          |    8 +
 pcre/testdata/testoutput16                         |   52 +
 pcre/testdata/testoutput19                         |   26 +
 pcre/testdata/testoutput2                          |   37 +-
 pcre/testdata/testoutput6                          |    8 +
 pcre/testdata/testoutput7                          |   26 -
 pcre/testdata/testoutput8                          |   10 +
 plugin/server_audit/server_audit.c                 |   36 +-
 sql-common/client.c                                |   11 +-
 sql/ha_partition.cc                                |    1 +
 sql/handler.cc                                     |    4 +-
 sql/item_subselect.cc                              |    9 +-
 sql/item_subselect.h                               |    9 +
 sql/log_slow.h                                     |   33 +-
 sql/mysqld.cc                                      |    4 +-
 sql/opt_range.cc                                   |   14 +-
 sql/partition_info.cc                              |    2 +-
 sql/sql_acl.cc                                     |    6 +-
 sql/sql_db.cc                                      |    9 +-
 sql/sql_derived.cc                                 |    3 +
 sql/sql_join_cache.cc                              |    5 +
 sql/sql_parse.cc                                   |   66 +-
 sql/sql_parse.h                                    |    3 +-
 sql/sql_select.cc                                  |   79 +-
 sql/table.cc                                       |    2 +-
 storage/connect/CMakeLists.txt                     |   10 +-
 storage/connect/array.cpp                          |  108 +-
 storage/connect/array.h                            |    6 +-
 storage/connect/colblk.cpp                         |   16 +-
 storage/connect/connect.cc                         |   77 +-
 storage/connect/domdoc.cpp                         |   11 +-
 storage/connect/domdoc.h                           |    1 +
 storage/connect/filamap.cpp                        |   12 +-
 storage/connect/filamdbf.cpp                       |   27 +-
 storage/connect/filamgz.cpp                        |   12 +-
 storage/connect/filamgz.h                          |   12 +-
 storage/connect/filamzip.cpp                       |  561 +++++-
 storage/connect/filamzip.h                         |  164 +-
 storage/connect/ha_connect.cc                      |  343 ++--
 storage/connect/jdbconn.cpp                        |   24 +-
 storage/connect/json.cpp                           |   80 +-
 storage/connect/jsonudf.cpp                        |  109 +-
 storage/connect/mycat.cc                           |   15 +-
 storage/connect/myconn.cpp                         |   20 +-
 .../connect/mysql-test/connect/r/xml_zip.result    |   98 +
 storage/connect/mysql-test/connect/r/zip.result    |  240 +++
 .../connect/mysql-test/connect/std_data/bios.json  |  273 +++
 .../mysql-test/connect/std_data/xsample2.xml       |   47 +
 storage/connect/mysql-test/connect/t/have_zip.inc  |   19 +
 storage/connect/mysql-test/connect/t/xml_zip.test  |   41 +
 storage/connect/mysql-test/connect/t/zip.test      |  136 ++
 storage/connect/odbconn.cpp                        |   14 +-
 storage/connect/plgdbsem.h                         |   26 +-
 storage/connect/plgdbutl.cpp                       |   14 +-
 storage/connect/plgxml.cpp                         |    4 +-
 storage/connect/plgxml.h                           |    2 +-
 storage/connect/plugutil.c                         |    3 +
 storage/connect/reldef.cpp                         |    6 +-
 storage/connect/reldef.h                           |   18 +-
 storage/connect/tabdos.cpp                         |   40 +-
 storage/connect/tabdos.h                           |    8 +-
 storage/connect/tabext.cpp                         |  640 ++++++
 storage/connect/tabext.h                           |  200 ++
 storage/connect/tabfix.cpp                         |    4 +-
 storage/connect/tabfix.h                           |    2 +-
 storage/connect/tabfmt.cpp                         |   75 +-
 storage/connect/tabfmt.h                           |    5 +-
 storage/connect/tabjdbc.cpp                        |  555 +-----
 storage/connect/tabjdbc.h                          |  129 +-
 storage/connect/tabjson.cpp                        |   31 +-
 storage/connect/tabjson.h                          |    4 +-
 storage/connect/table.cpp                          |  249 ++-
 storage/connect/tabmac.cpp                         |    2 +-
 storage/connect/tabmac.h                           |    2 +-
 storage/connect/tabmul.cpp                         |   26 +-
 storage/connect/tabmul.h                           |   18 +-
 storage/connect/tabmysql.cpp                       |  183 +-
 storage/connect/tabmysql.h                         |   75 +-
 storage/connect/taboccur.cpp                       |    9 +-
 storage/connect/tabodbc.cpp                        |  321 +--
 storage/connect/tabodbc.h                          |  133 +-
 storage/connect/tabpivot.cpp                       |    7 +-
 storage/connect/tabpivot.h                         |    2 +-
 storage/connect/tabsys.cpp                         |    8 +-
 storage/connect/tabsys.h                           |    4 +-
 storage/connect/tabtbl.cpp                         |   23 +-
 storage/connect/tabutil.cpp                        |   23 +-
 storage/connect/tabutil.h                          |    8 +-
 storage/connect/tabvct.cpp                         |    6 +-
 storage/connect/tabvct.h                           |    2 +-
 storage/connect/tabvir.cpp                         |    2 +-
 storage/connect/tabwmi.cpp                         |   21 +-
 storage/connect/tabxcl.cpp                         |    8 +-
 storage/connect/tabxcl.h                           |    2 +-
 storage/connect/tabxml.cpp                         |   13 +-
 storage/connect/tabxml.h                           |    2 +-
 storage/connect/tabzip.cpp                         |   16 +-
 storage/connect/tabzip.h                           |    2 +-
 storage/connect/value.h                            |    2 +-
 storage/connect/xindex.cpp                         |    8 +-
 storage/connect/xindex.h                           |    4 +-
 storage/connect/xobject.h                          |    3 +-
 storage/connect/xtable.h                           |  211 +-
 storage/innobase/btr/btr0cur.cc                    |    7 -
 storage/innobase/dict/dict0dict.cc                 |    1 -
 storage/innobase/dyn/dyn0dyn.cc                    |    1 -
 storage/innobase/fsp/fsp0fsp.cc                    |    6 -
 storage/innobase/include/dict0dict.ic              |    7 -
 storage/innobase/include/dyn0dyn.ic                |    8 -
 storage/innobase/include/log0recv.h                |   35 +-
 storage/innobase/include/mach0data.ic              |   13 -
 storage/innobase/include/page0page.ic              |    1 -
 storage/innobase/log/log0log.cc                    |   17 +-
 storage/innobase/log/log0recv.cc                   |  218 +-
 storage/innobase/mtr/mtr0mtr.cc                    |    1 -
 storage/innobase/page/page0page.cc                 |    2 -
 storage/innobase/page/page0zip.cc                  |    2 -
 storage/innobase/row/row0merge.cc                  |    6 -
 storage/innobase/row/row0upd.cc                    |    4 -
 storage/innobase/srv/srv0start.cc                  |   10 +-
 storage/innobase/sync/sync0sync.cc                 |    2 +-
 storage/maria/ha_maria.cc                          |  234 ++-
 storage/maria/ma_check.c                           |    6 +-
 storage/maria/ma_create.c                          |   57 +-
 storage/maria/ma_delete_table.c                    |   20 +-
 storage/maria/ma_open.c                            |   71 +-
 storage/maria/ma_static.c                          |    6 -
 storage/maria/maria_chk.c                          |    2 +-
 storage/maria/maria_def.h                          |    3 +-
 storage/myisam/ha_myisam.cc                        |  223 ++-
 storage/myisam/mi_check.c                          |   17 +-
 storage/myisam/mi_create.c                         |   53 +-
 storage/myisam/mi_delete_table.c                   |   36 +-
 storage/myisam/mi_open.c                           |   71 +-
 storage/myisam/mi_static.c                         |    8 -
 storage/myisam/myisamchk.c                         |    2 +-
 storage/myisam/myisamdef.h                         |    3 +-
 storage/tokudb/CMakeLists.txt                      |    2 +-
 storage/tokudb/PerconaFT/ft/ft-ops.cc              |   23 +-
 storage/tokudb/PerconaFT/ft/ft-ops.h               |    5 +
 storage/tokudb/PerconaFT/ft/logger/recover.cc      |    3 +-
 storage/tokudb/PerconaFT/ft/node.cc                |   18 +-
 storage/tokudb/PerconaFT/ft/node.h                 |   54 +-
 .../PerconaFT/ft/serialize/ft_node-serialize.cc    |    3 +-
 storage/tokudb/PerconaFT/ft/txn/roll.cc            |    3 +-
 storage/tokudb/PerconaFT/util/dmt.h                |    5 -
 storage/tokudb/PerconaFT/util/omt.h                |    2 -
 storage/tokudb/ha_tokudb.cc                        |   81 +-
 storage/tokudb/ha_tokudb.h                         |    2 +
 .../dir_per_db_rename_to_nonexisting_schema.result |   46 +
 .../mysql-test/tokudb/r/gap_lock_error.result      |  469 +++++
 .../tokudb/r/percona_kill_idle_trx_tokudb.result   |   43 +
 .../t/dir_per_db_rename_to_nonexisting_schema.test |   64 +
 .../tokudb/mysql-test/tokudb/t/gap_lock_error.test |    5 +
 .../tokudb/t/percona_kill_idle_trx_tokudb.test     |    5 +
 .../tokudb/mysql-test/tokudb_backup/t/suite.opt    |    2 +-
 storage/xtradb/btr/btr0btr.cc                      |    2 -
 storage/xtradb/btr/btr0cur.cc                      |  116 +-
 storage/xtradb/buf/buf0buddy.cc                    |    1 -
 storage/xtradb/buf/buf0buf.cc                      |    9 -
 storage/xtradb/buf/buf0lru.cc                      |  142 +-
 storage/xtradb/dict/dict0dict.cc                   |    1 -
 storage/xtradb/dict/dict0stats.cc                  |   13 +-
 storage/xtradb/dyn/dyn0dyn.cc                      |    1 -
 storage/xtradb/fsp/fsp0fsp.cc                      |   12 +-
 storage/xtradb/fts/fts0opt.cc                      |    7 +-
 storage/xtradb/handler/ha_innodb.cc                |  103 +-
 storage/xtradb/handler/ha_innodb.h                 |    2 +
 storage/xtradb/handler/handler0alter.cc            |   79 +-
 storage/xtradb/handler/i_s.cc                      |   24 +-
 storage/xtradb/include/btr0cur.h                   |   18 +-
 storage/xtradb/include/btr0sea.h                   |    7 +-
 storage/xtradb/include/btr0sea.ic                  |    4 -
 storage/xtradb/include/buf0buddy.ic                |    2 +-
 storage/xtradb/include/buf0buf.h                   |    5 +-
 storage/xtradb/include/dict0dict.h                 |   19 +-
 storage/xtradb/include/dict0dict.ic                |    7 -
 storage/xtradb/include/dyn0dyn.h                   |   18 +-
 storage/xtradb/include/dyn0dyn.ic                  |   10 +-
 storage/xtradb/include/log0online.h                |   20 +-
 storage/xtradb/include/log0recv.h                  |   35 +-
 storage/xtradb/include/mach0data.h                 |   16 +-
 storage/xtradb/include/mach0data.ic                |   13 -
 storage/xtradb/include/mtr0mtr.h                   |    5 +-
 storage/xtradb/include/os0file.h                   |    5 +-
 storage/xtradb/include/os0thread.h                 |    8 +-
 storage/xtradb/include/page0page.h                 |   20 +-
 storage/xtradb/include/page0page.ic                |    1 -
 storage/xtradb/include/page0zip.h                  |    7 +-
 storage/xtradb/include/rem0rec.h                   |    3 +-
 storage/xtradb/include/row0upd.h                   |    5 +-
 storage/xtradb/include/srv0srv.h                   |    9 +
 storage/xtradb/include/trx0trx.h                   |    2 +-
 storage/xtradb/include/univ.i                      |    4 +-
 storage/xtradb/log/log0log.cc                      |   17 +-
 storage/xtradb/log/log0online.cc                   |  177 +-
 storage/xtradb/log/log0recv.cc                     |  214 +-
 storage/xtradb/mach/mach0data.cc                   |   44 +-
 storage/xtradb/mtr/mtr0mtr.cc                      |    1 -
 storage/xtradb/os/os0file.cc                       |   53 +-
 storage/xtradb/os/os0thread.cc                     |   28 +-
 storage/xtradb/page/page0page.cc                   |    2 -
 storage/xtradb/page/page0zip.cc                    |    2 -
 storage/xtradb/rem/rem0rec.cc                      |    2 +-
 storage/xtradb/row/row0merge.cc                    |   10 +-
 storage/xtradb/row/row0mysql.cc                    |    2 +
 storage/xtradb/row/row0purge.cc                    |    2 +-
 storage/xtradb/row/row0upd.cc                      |    4 -
 storage/xtradb/srv/srv0srv.cc                      |   96 +-
 storage/xtradb/srv/srv0start.cc                    |   40 +-
 storage/xtradb/sync/sync0sync.cc                   |    2 +-
 storage/xtradb/trx/trx0sys.cc                      |   66 +-
 support-files/build-tags                           |    4 +-
 support-files/rpm/server-postin.sh                 |   33 +-
 tests/mysql_client_test.c                          |   50 +-
 332 files changed, 11264 insertions(+), 5868 deletions(-)

diff --cc include/my_sys.h
index 2b1698ca2bc,4e129cc6dc1..d30c3ee78d3
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@@ -66,9 -64,9 +66,10 @@@ typedef struct my_aio_result 
  #define MY_FAE		8	/* Fatal if any error */
  #define MY_WME		16	/* Write message on error */
  #define MY_WAIT_IF_FULL 32	/* Wait and try again if disk full error */
- #define MY_IGNORE_BADFD 32      /* my_sync: ignore 'bad descriptor' errors */
+ #define MY_IGNORE_BADFD 32      /* my_sync(): ignore 'bad descriptor' errors */
 +#define MY_ENCRYPT      64      /* Encrypt IO_CACHE temporary files */
- #define MY_FULL_IO     512      /* For my_read - loop intil I/O is complete */
+ #define MY_NOSYMLINKS  512      /* my_open(): don't follow symlinks */
+ #define MY_FULL_IO     512      /* my_read(): loop intil I/O is complete */
  #define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
  #define MY_LINK_WARNING 32	/* my_redel() gives warning if links */
  #define MY_COPYTIME	64	/* my_redel() copys time */
@@@ -611,10 -560,14 +612,11 @@@ static inline size_t my_b_bytes_in_cach
  int      my_b_copy_to_file(IO_CACHE *cache, FILE *file);
  my_off_t my_b_append_tell(IO_CACHE* info);
  my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
 -
 -#define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \
 -					  *(info)->current_pos)
 +int my_b_pread(IO_CACHE *info, uchar *Buffer, size_t Count, my_off_t pos);
  
  typedef uint32 ha_checksum;
 -extern ulong my_crc_dbug_check;
  
+ extern int (*mysys_test_invalid_symlink)(const char *filename);
  #include <my_alloc.h>
  
  	/* Prototypes for mysys and my_func functions */
diff --cc mysql-test/r/derived.result
index 2f6662e0132,ce94fe49f5c..c8736b557de
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@@ -1013,49 -1014,27 +1013,72 @@@ David	Yes	21
  Edward	Yes	150
  DROP TABLE example1463;
  set sql_mode= @save_sql_mode;
+ #
+ # MDEV-9028: SELECT DISTINCT constant column of  derived  table
+ #            used as the second operand of LEFT JOIN
+ #
+ create table t1 (id int, data varchar(255));
+ insert into t1 values (1,'yes'),(2,'yes');
+ select distinct t1.id, tt.id, tt.data
+ from t1
+ left join
+ (select t1.id, 'yes' as data from t1) as tt
+ on t1.id = tt.id;
+ id	id	data
+ 1	1	yes
+ 2	2	yes
+ select distinct t1.id, tt.id, tt.data
+ from t1
+ left join
+ (select t1.id, 'yes' as data from t1 where id > 1) as tt
+ on t1.id = tt.id;
+ id	id	data
+ 2	2	yes
+ 1	NULL	NULL
+ drop table t1;
  # end of 5.5
 +#
 +# Start of 10.1 tests
 +#
 +#
 +# MDEV-8747 Wrong result for SELECT..WHERE derived_table_column='a' AND derived_table_column<>_latin1'A' COLLATE latin1_bin
 +#
 +CREATE TABLE t1 (a VARCHAR(10));
 +INSERT INTO t1 VALUES ('a'),('A');
 +SELECT * FROM t1 WHERE a='a' AND a <> _latin1'A' COLLATE latin1_bin;
 +a
 +a
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='a' AND a <> _latin1'A' COLLATE latin1_bin;
 +a
 +a
 +DROP TABLE t1;
 +CREATE TABLE t1 (a ENUM('5','6'));
 +INSERT INTO t1 VALUES ('5'),('6');
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5';
 +a
 +5
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a=1;
 +a
 +5
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5' AND a=1;
 +a
 +5
 +DROP TABLE t1;
 +#
 +# MDEV-8749 Wrong result for SELECT..WHERE derived_table_enum_column='number' AND derived_table_enum_column OP number2
 +#
 +CREATE TABLE t1 (a ENUM('5','6'));
 +INSERT INTO t1 VALUES ('5'),('6');
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5';
 +a
 +5
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a=1;
 +a
 +5
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5' AND a=1;
 +a
 +5
 +DROP TABLE t1;
 +#
 +# End of 10.1 tests
 +#
diff --cc mysql-test/r/grant.result
index 3020c7deba7,0b17e82e5a9..826d1f6c6b2
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@@ -2560,26 -2600,3 +2608,4 @@@ ERROR 42000: Access denied for user 'un
  # Connection default
  DROP USER untrusted at localhost;
  DROP DATABASE secret;
- #
- # BUG#11759114 - '51401: GRANT TREATS NONEXISTENT FUNCTIONS/PRIVILEGES
- #                 DIFFERENTLY'.
- #
- drop database if exists mysqltest_db1;
- create database mysqltest_db1;
- create user mysqltest_u1;
- # Both GRANT statements below should fail with the same error.
- grant execute on function mysqltest_db1.f1 to mysqltest_u1;
- ERROR 42000: FUNCTION or PROCEDURE f1 does not exist
- grant execute on procedure mysqltest_db1.p1 to mysqltest_u1;
- ERROR 42000: FUNCTION or PROCEDURE p1 does not exist
- # Let us show that GRANT behaviour for routines is consistent
- # with GRANT behaviour for tables. Attempt to grant privilege
- # on non-existent table also results in an error.
- grant select on mysqltest_db1.t1 to mysqltest_u1;
- ERROR 42S02: Table 'mysqltest_db1.t1' doesn't exist
- show grants for mysqltest_u1;
- Grants for mysqltest_u1@%
- GRANT USAGE ON *.* TO 'mysqltest_u1'@'%'
- drop database mysqltest_db1;
- drop user mysqltest_u1;
 +set GLOBAL sql_mode=default;
diff --cc mysql-test/r/mysqldump.result
index ce786c2ede8,6bf8759de98..f46fecb69cd
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@@ -5342,176 -5340,4 +5342,177 @@@ DELIMITER 
  /*!50003 SET collation_connection  = @saved_col_connection */ ;
  ALTER DATABASE `a\"'``b` CHARACTER SET utf8 COLLATE utf8_general_ci ;
  DROP DATABASE `a\"'``b`;
 +use test;
 +#
 +# Test mysqldump with --disable-query-logs
 +#
 +create table t1 (a int);
 +insert into t1 values (1);
 +drop table t1;
 +select * from t1;
 +a
 +1
 +drop table t1;
 +#
 +# MDEV-9124 mysqldump does not dump data if table name is same as view earlier on
 +#
 +CREATE DATABASE db1 CHARSET=utf8;
 +CREATE DATABASE db2 CHARSET=utf8;
 +USE db2;
 +CREATE TABLE nonunique_table_name (i1 serial) ENGINE=MEMORY;
 +INSERT INTO nonunique_table_name VALUES (1),(2);
 +CREATE TABLE nonunique_table_view_name (i2 int) ENGINE=InnoDB;
 +INSERT INTO nonunique_table_view_name VALUES (3),(4);
 +use db1;
 +CREATE TABLE basetable (id smallint) ENGINE=MyISAM;
 +CREATE TABLE nonunique_table_name (i3 smallint) ENGINE=MERGE UNION (basetable) INSERT_METHOD=LAST;
 +INSERT INTO nonunique_table_name VALUES (5),(6);
 +CREATE VIEW nonunique_table_view_name AS SELECT 1;
 +
 +##################################################
 +# --compact --databases db1 db2
 +
 +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db1` /*!40100 DEFAULT CHARACTER SET utf8 */;
 +
 +USE `db1`;
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `basetable` (
 +  `id` smallint(6) DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `basetable` VALUES (5),(6);
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_name` (
 +  `i3` smallint(6) DEFAULT NULL
 +) ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 INSERT_METHOD=LAST UNION=(`basetable`);
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +SET @saved_cs_client     = @@character_set_client;
 +SET character_set_client = utf8;
 +/*!50001 CREATE TABLE `nonunique_table_view_name` (
 +  `1` tinyint NOT NULL
 +) ENGINE=MyISAM */;
 +SET character_set_client = @saved_cs_client;
 +
 +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db2` /*!40100 DEFAULT CHARACTER SET utf8 */;
 +
 +USE `db2`;
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_name` (
 +  `i1` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
 +  UNIQUE KEY `i1` (`i1`)
 +) ENGINE=MEMORY AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `nonunique_table_name` VALUES (1),(2);
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_view_name` (
 +  `i2` int(11) DEFAULT NULL
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `nonunique_table_view_name` VALUES (3),(4);
 +
 +USE `db1`;
 +/*!50001 DROP TABLE IF EXISTS `nonunique_table_view_name`*/;
 +/*!50001 SET @saved_cs_client          = @@character_set_client */;
 +/*!50001 SET @saved_cs_results         = @@character_set_results */;
 +/*!50001 SET @saved_col_connection     = @@collation_connection */;
 +/*!50001 SET character_set_client      = utf8 */;
 +/*!50001 SET character_set_results     = utf8 */;
 +/*!50001 SET collation_connection      = utf8_general_ci */;
 +/*!50001 CREATE ALGORITHM=UNDEFINED */
 +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
 +/*!50001 VIEW `nonunique_table_view_name` AS select 1 AS `1` */;
 +/*!50001 SET character_set_client      = @saved_cs_client */;
 +/*!50001 SET character_set_results     = @saved_cs_results */;
 +/*!50001 SET collation_connection      = @saved_col_connection */;
 +
 +USE `db2`;
 +
 +##################################################
 +# --compact db2
 +
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_name` (
 +  `i1` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
 +  UNIQUE KEY `i1` (`i1`)
 +) ENGINE=MEMORY AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `nonunique_table_name` VALUES (1),(2);
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_view_name` (
 +  `i2` int(11) DEFAULT NULL
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `nonunique_table_view_name` VALUES (3),(4);
 +
 +##################################################
 +# --compact --delayed-insert --no-data-med=0 --databases db2 db1
 +
 +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db2` /*!40100 DEFAULT CHARACTER SET utf8 */;
 +
 +USE `db2`;
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_name` (
 +  `i1` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
 +  UNIQUE KEY `i1` (`i1`)
 +) ENGINE=MEMORY AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT  DELAYED INTO `nonunique_table_name` VALUES (1),(2);
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_view_name` (
 +  `i2` int(11) DEFAULT NULL
 +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `nonunique_table_view_name` VALUES (3),(4);
 +
 +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db1` /*!40100 DEFAULT CHARACTER SET utf8 */;
 +
 +USE `db1`;
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `basetable` (
 +  `id` smallint(6) DEFAULT NULL
 +) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT  DELAYED INTO `basetable` VALUES (5),(6);
 +/*!40101 SET @saved_cs_client     = @@character_set_client */;
 +/*!40101 SET character_set_client = utf8 */;
 +CREATE TABLE `nonunique_table_name` (
 +  `i3` smallint(6) DEFAULT NULL
 +) ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 INSERT_METHOD=LAST UNION=(`basetable`);
 +/*!40101 SET character_set_client = @saved_cs_client */;
 +INSERT INTO `nonunique_table_name` VALUES (5),(6);
 +SET @saved_cs_client     = @@character_set_client;
 +SET character_set_client = utf8;
 +/*!50001 CREATE TABLE `nonunique_table_view_name` (
 +  `1` tinyint NOT NULL
 +) ENGINE=MyISAM */;
 +SET character_set_client = @saved_cs_client;
 +
 +USE `db2`;
 +
 +USE `db1`;
 +/*!50001 DROP TABLE IF EXISTS `nonunique_table_view_name`*/;
 +/*!50001 SET @saved_cs_client          = @@character_set_client */;
 +/*!50001 SET @saved_cs_results         = @@character_set_results */;
 +/*!50001 SET @saved_col_connection     = @@collation_connection */;
 +/*!50001 SET character_set_client      = utf8 */;
 +/*!50001 SET character_set_results     = utf8 */;
 +/*!50001 SET collation_connection      = utf8_general_ci */;
 +/*!50001 CREATE ALGORITHM=UNDEFINED */
 +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
 +/*!50001 VIEW `nonunique_table_view_name` AS select 1 AS `1` */;
 +/*!50001 SET character_set_client      = @saved_cs_client */;
 +/*!50001 SET character_set_results     = @saved_cs_results */;
 +/*!50001 SET collation_connection      = @saved_col_connection */;
 +
 +DROP DATABASE db1;
 +DROP DATABASE db2;
+ FOUND /Database: mysql/ in bug11505.sql
diff --cc mysql-test/r/subselect4.result
index 3783ba12db2,9188f3bfd28..b1c1855a789
--- a/mysql-test/r/subselect4.result
+++ b/mysql-test/r/subselect4.result
@@@ -2440,17 -2436,39 +2440,51 @@@ EXECUTE stmt
  i
  6
  drop table t1, t2, t3;
+ #
+ # MDEV-11078: NULL NOT IN (non-empty subquery) should never return results
+ #
+ create table t1(a int,b int);
+ create table t2(a int,b int);
+ insert into t1 value (1,2);
+ select (NULL)  in (select 1 from t1);
+ (NULL)  in (select 1 from t1)
+ NULL
+ select (null)  in (select 1 from t2);
+ (null)  in (select 1 from t2)
+ 0
+ select 1 in (select 1 from t1);
+ 1 in (select 1 from t1)
+ 1
+ select 1 in (select 1 from t2);
+ 1 in (select 1 from t2)
+ 0
+ select 1 from dual where null in (select 1 from t1);
+ 1
+ select 1 from dual where null in (select 1 from t2);
+ 1
+ select (null,null) in (select * from t1);
+ (null,null) in (select * from t1)
+ NULL
+ select (null,null) in (select * from t2);
+ (null,null) in (select * from t2)
+ 0
+ select 1 from dual where null not in (select 1 from t1);
+ 1
+ select 1 from dual where null not in (select 1 from t2);
+ 1
+ 1
+ drop table t1,t2;
  SET optimizer_switch= @@global.optimizer_switch;
  set @@tmp_table_size= @@global.tmp_table_size;
 +#
 +# MDEV-10232 Scalar result of subquery changes after adding an outer select stmt
 +#
 +create table t1(c1 int, c2 int, primary key(c2));
 +insert into t1 values(2,1),(1,2);
 +select (select c1 from t1 group by c1,c2 order by c1 limit 1) as x;
 +x
 +1
 +(select c1 from t1 group by c1,c2 order by c1 limit 1);
 +c1
 +1
 +drop table t1;
diff --cc mysql-test/t/derived.test
index 28781ad6fdb,28e48bf03c0..d881430a060
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@@ -875,38 -875,27 +875,61 @@@ SELECT Customer, Success, SUM(OrderSize
  DROP TABLE example1463;
  set sql_mode= @save_sql_mode;
  
+ --echo #
+ --echo # MDEV-9028: SELECT DISTINCT constant column of  derived  table
+ --echo #            used as the second operand of LEFT JOIN
+ --echo #
+ 
+ create table t1 (id int, data varchar(255));
+ insert into t1 values (1,'yes'),(2,'yes');
+ 
+ select distinct t1.id, tt.id, tt.data
+   from t1
+        left join
+        (select t1.id, 'yes' as data from t1) as tt
+        on t1.id = tt.id;
+ 
+ select distinct t1.id, tt.id, tt.data
+   from t1
+        left join
+        (select t1.id, 'yes' as data from t1 where id > 1) as tt
+        on t1.id = tt.id;
+ 
+ drop table t1;
+ 
+ 
  --echo # end of 5.5
 +
 +--echo #
 +--echo # Start of 10.1 tests
 +--echo #
 +
 +--echo #
 +--echo # MDEV-8747 Wrong result for SELECT..WHERE derived_table_column='a' AND derived_table_column<>_latin1'A' COLLATE latin1_bin
 +--echo #
 +CREATE TABLE t1 (a VARCHAR(10));
 +INSERT INTO t1 VALUES ('a'),('A');
 +SELECT * FROM t1 WHERE a='a' AND a <> _latin1'A' COLLATE latin1_bin;
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='a' AND a <> _latin1'A' COLLATE latin1_bin;
 +DROP TABLE t1;
 +
 +CREATE TABLE t1 (a ENUM('5','6'));
 +INSERT INTO t1 VALUES ('5'),('6');
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5';
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a=1;
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5' AND a=1;
 +DROP TABLE t1;
 +
 +--echo #
 +--echo # MDEV-8749 Wrong result for SELECT..WHERE derived_table_enum_column='number' AND derived_table_enum_column OP number2
 +--echo #
 +CREATE TABLE t1 (a ENUM('5','6'));
 +INSERT INTO t1 VALUES ('5'),('6');
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5';
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a=1;
 +SELECT * FROM (SELECT * FROM t1) AS table1 WHERE a='5' AND a=1;
 +DROP TABLE t1;
 +
 +--echo #
 +--echo # End of 10.1 tests
 +--echo #
diff --cc mysql-test/t/grant.test
index 1d828cd8693,0be4c254269..a8ddf350b73
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@@ -2210,29 -2270,5 +2272,6 @@@ disconnect con1
  DROP USER untrusted at localhost;
  DROP DATABASE secret;
  
- --echo #
- --echo # BUG#11759114 - '51401: GRANT TREATS NONEXISTENT FUNCTIONS/PRIVILEGES
- --echo #                 DIFFERENTLY'.
- --echo #
- --disable_warnings
- drop database if exists mysqltest_db1;
- --enable_warnings
- create database mysqltest_db1;
- create user mysqltest_u1;
- --echo # Both GRANT statements below should fail with the same error.
- --error ER_SP_DOES_NOT_EXIST
- grant execute on function mysqltest_db1.f1 to mysqltest_u1;
- --error ER_SP_DOES_NOT_EXIST
- grant execute on procedure mysqltest_db1.p1 to mysqltest_u1;
- --echo # Let us show that GRANT behaviour for routines is consistent
- --echo # with GRANT behaviour for tables. Attempt to grant privilege
- --echo # on non-existent table also results in an error.
- --error ER_NO_SUCH_TABLE
- grant select on mysqltest_db1.t1 to mysqltest_u1;
- show grants for mysqltest_u1;
- drop database mysqltest_db1;
- drop user mysqltest_u1;
- 
 +set GLOBAL sql_mode=default;
  # Wait till we reached the initial number of concurrent sessions
  --source include/wait_until_count_sessions.inc
diff --cc mysql-test/t/mysqldump.test
index 9cde1f93a4a,708ed25f89c..87091d549d1
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@@ -2513,58 -2512,11 +2513,67 @@@ if (`select convert(@@version_compile_o
  }
  --exec $MYSQL_DUMP --routines --compact $shell_ready_db_name
  DROP DATABASE `a\"'``b`;
+ 
  #"
 +use test;
 +
 +--echo #
 +--echo # Test mysqldump with --disable-query-logs
 +--echo #
 +
 +create table t1 (a int);
 +insert into t1 values (1);
 +
 +--exec $MYSQL_DUMP --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1
 +--exec $MYSQL_DUMP --disable-log-queries --skip-comments test t1 >$MYSQLTEST_VARDIR/tmp/mysqldump-test.out
 +drop table t1;
 +
 +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump-test.out
 +select * from t1;
 +drop table t1;
 +--remove_file $MYSQLTEST_VARDIR/tmp/mysqldump-test.out
 +#select * from mysql.user;
 +#checksum table mysql.user;
 +
 +--echo #
 +--echo # MDEV-9124 mysqldump does not dump data if table name is same as view earlier on
 +--echo #
 +
 +CREATE DATABASE db1 CHARSET=utf8;
 +CREATE DATABASE db2 CHARSET=utf8;
 +USE db2;
 +CREATE TABLE nonunique_table_name (i1 serial) ENGINE=MEMORY;
 +INSERT INTO nonunique_table_name VALUES (1),(2);
 +CREATE TABLE nonunique_table_view_name (i2 int) ENGINE=InnoDB;
 +INSERT INTO nonunique_table_view_name VALUES (3),(4);
 +use db1;
 +CREATE TABLE basetable (id smallint) ENGINE=MyISAM;
 +CREATE TABLE nonunique_table_name (i3 smallint) ENGINE=MERGE UNION (basetable) INSERT_METHOD=LAST;
 +INSERT INTO nonunique_table_name VALUES (5),(6);
 +CREATE VIEW nonunique_table_view_name AS SELECT 1;
 +
 +--echo 
 +--echo ##################################################
 +--echo # --compact --databases db1 db2
 +--exec $MYSQL_DUMP --compact --databases db1 db2
 +--echo 
 +--echo ##################################################
 +--echo # --compact db2
 +--echo
 +--exec $MYSQL_DUMP --compact db2
 +--echo 
 +--echo ##################################################
 +--echo # --compact --delayed-insert --no-data-med=0 --databases db2 db1
 +--exec $MYSQL_DUMP --compact --delayed-insert --no-data-med=0 --databases db2 db1
 +--echo 
 +
 +DROP DATABASE db1;
 +DROP DATABASE db2;
++
++#"
+ # MDEV-11505 wrong databasename in mysqldump comment
+ #
+ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/bug11505.sql;
+ let SEARCH_PATTERN=Database: mysql;
+ exec $MYSQL_DUMP mysql func  > $SEARCH_FILE;
+ source include/search_pattern_in_file.inc;
diff --cc mysql-test/t/subselect4.test
index 253160c46ac,76b4df47a6a..e75a22a08f4
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@@ -1997,15 -1997,24 +1997,34 @@@ EXECUTE stmt
  
  drop table t1, t2, t3;
  
+ --echo #
+ --echo # MDEV-11078: NULL NOT IN (non-empty subquery) should never return results
+ --echo #
+ 
+ create table t1(a int,b int);
+ create table t2(a int,b int);
+ insert into t1 value (1,2);
+ select (NULL)  in (select 1 from t1);
+ select (null)  in (select 1 from t2);
+ select 1 in (select 1 from t1);
+ select 1 in (select 1 from t2);
+ select 1 from dual where null in (select 1 from t1);
+ select 1 from dual where null in (select 1 from t2);
+ select (null,null) in (select * from t1);
+ select (null,null) in (select * from t2);
+ select 1 from dual where null not in (select 1 from t1);
+ select 1 from dual where null not in (select 1 from t2);
+ drop table t1,t2;
+ 
  SET optimizer_switch= @@global.optimizer_switch;
  set @@tmp_table_size= @@global.tmp_table_size;
 +
 +--echo #
 +--echo # MDEV-10232 Scalar result of subquery changes after adding an outer select stmt
 +--echo #
 +
 +create table t1(c1 int, c2 int, primary key(c2));
 +insert into t1 values(2,1),(1,2);
 +select (select c1 from t1 group by c1,c2 order by c1 limit 1) as x;
 +(select c1 from t1 group by c1,c2 order by c1 limit 1);
 +drop table t1;
diff --cc mysql-test/unstable-tests
index 42985e1d66d,6c84d8d3ba6..8030c99877c
--- a/mysql-test/unstable-tests
+++ b/mysql-test/unstable-tests
@@@ -23,78 -23,41 +23,94 @@@
  #
  ##############################################################################
  
 -main.alter_table                   : Modified in 10.0.30
 +main.alter_table                   : Modified in 10.1.21
 +main.alter_table_trans             : MDEV-11805 - timeout
 +main.analyze_stmt_slow_query_log   : Modified in 10.1.21
 +main.cast                          : Modified in 10.1.21
+ main.count_distinct2               : MDEV-11768 - timeout
 +main.create                        : Modified in 10.1.21
  main.create_delayed                : MDEV-10605 - failed with timeout
 +main.create_drop_binlog            : Uses binlog_start_pos.inc modified in 10.1.20
 +main.ctype_ucs                     : Modified in 10.1.21
 +main.ctype_ucs2_def                : Modified in 10.1.21
 +main.ctype_ucs2_query_cache        : Modified in 10.1.21
 +main.ctype_utf16                   : Modified in 10.1.21
 +main.ctype_utf16_def               : Modified in 10.1.21
 +main.ctype_utf16le                 : MDEV-10675: timeout or extra warnings
 +main.ctype_utf32                   : Modified in 10.1.21
 +main.ctype_utf8                    : Modified in 10.1.20
 +main.ctype_utf8mb4                 : Modified in 10.1.20
 +main.default                       : Modified in 10.1.20
+ main.debug_sync                    : MDEV-10607 - internal error
 -main.derived                       : Modified in 10.0.30
 +main.derived                       : Modified in 10.1.20
+ main.derived_opt                   : MDEV-11768 - timeout
 +main.derived_view                  : Modified in 10.1.20
- main.events_restart                : MDEV-11221: assertion failure
+ main.events_restart                : MDEV-11221 - assertion failure
 -main.grant                         : Modified in 10.0.30
 +main.events_slowlog                : Added in 10.1.21
 +main.fulltext_charsets             : Added in 10.1.20
 +main.func_time                     : Modified in 10.1.21
++main.grant                         : Modified in 10.1.22
 +main.group_by                      : Modified in 10.1.20
 +main.group_by_innodb               : Modified in 10.1.20
  main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown
  main.index_intersect_innodb        : MDEV-10643 - failed with timeout
 -main.index_merge_innodb            : MDEV-7142 - wrong result
 +main.index_merge_innodb            : MDEV-7142 - Wrong execution plan, also modified in 10.1.21
 +main.information_schema_part       : Modified in 10.1.21
  main.innodb_mysql_lock             : MDEV-7861 - sporadic lock detection failure
 -main.join_nested                   : Modified in 10.0.30
 +main.join_cache                    : Modified in 10.1.21
++main.join_nested                   : Modified in 10.1.22
 +main.kill_processlist-6619         : MDEV-10793 - wrong result in processlist
 +main.loaddata                      : Modified in 10.1.21
 +main.log_slow                      : Modified in 10.1.21
 +main.lowercase_fs_on               : Uses search_pattern_in_file.inc modified in 10.1.20
  main.mdev-504                      : MDEV-10607 - sporadic "can't connect"
  main.mdev375                       : MDEV-10607 - sporadic "can't connect"
  main.merge                         : MDEV-10607 - sporadic "can't connect"
 -main.mysqldump                     : Modified in 10.0.30
 +main.mysqlbinlog                   : Uses binlog_start_pos.inc modified in 10.1.20
++main.mysqldump                     : Modified in 10.1.22
 +main.mysqldump-max                 : Uses binlog_start_pos.inc modified in 10.1.20
 +main.mysqlslap                     : MDEV-11801 - timeout
+ main.mysqlhotcopy_myisam           : MDEV-10995 - test hangs on debug build
  main.mysqltest                     : MDEV-9269 - fails on Alpha
 -main.partition_innodb              : Modified in 10.0.30
 -main.partition_myisam              : Modified in 10.0.30
 +main.named_pipe                    : Uses search_pattern_in_file.inc modified in 10.1.20
 +main.order_by                      : Modified in 10.1.21
 +main.order_by_optimizer_innodb     : MDEV-10683 - wrong execution plan
 +main.parser                        : Modified in 10.1.20
++main.partition_innodb              : Modified in 10.1.22
++main.partition_myisam              : Modified in 10.1.22
 +main.pool_of_threads               : Modified in 10.1.21
  main.ps                            : MDEV-11017 - sporadic wrong Prepared_stmt_count
 -main.range_vs_index_merge          : Modified in 10.0.30
 -main.repair_symlink-5543           : Modified in 10.0.30
++main.range_vs_index_merge          : Modified in 10.1.22
++main.repair_symlink-5543           : Modified in 10.1.22
 +main.selectivity                   : Modified in 10.1.20
- main.show_explain                  : MDEV-10674 - sporadic failure
- main.signal_demo3                  : MDEV-11720 - Thread stack overrun on labrador
+ main.show_explain                  : MDEV-10674 - wrong result
+ main.signal_demo3                  : MDEV-11720 - Thread stack overrun on Solaris
 -main.sp                            : Modified in 10.0.30
 +main.sp                            : Modified in 10.1.21
+ main.sp_notembedded                : MDEV-10607 - internal error
 +main.sp-prelocking                 : Modified in 10.1.21
  main.sp-security                   : MDEV-10607 - sporadic "can't connect"
 +main.stat_tables_par_innodb        : MDEV-10515 - sporadic wrong results
 +main.statistics                    : Modified in 10.1.20
 +main.status                        : MDEV-8510 - sporadic wrong result
 +main.subselect                     : Modified in 10.1.21
 +main.subselect2                    : Modified in 10.1.21
 +main.subselect4                    : Modified in 10.1.21
  main.subselect_innodb              : MDEV-10614 - sporadic wrong results
 +main.subselect_no_exists_to_in     : Uses subselect.test modified in 10.1.21
 +main.subselect_no_mat              : Uses subselect.test modified in 10.1.21
 +main.subselect_no_opts             : Uses subselect.test modified in 10.1.21
 +main.subselect_no_scache           : Uses subselect.test modified in 10.1.21
 +main.subselect_no_semijoin         : Uses subselect.test modified in 10.1.21
+ main.symlink-aria-11902            : Added in 10.0.30
+ main.symlink-myisam-11902          : Added in 10.0.30
 -main.table_elim                    : Modified in 10.0.30
 -main.view                          : Modified in 10.0.30
++main.table_elim                    : Modified in 10.1.22
 +main.trigger_null-8605             : Modified in 10.1.21
 +main.type_datetime_hires           : MDEV-10687 - timeout
 +main.type_decimal                  : Modified in 10.1.20
 +main.union                         : Modified in 10.1.21
 +main.view                          : Modified in 10.1.21
 +main.wait_timeout_not_windows      : Uses search_pattern_in_file.inc modified in 10.1.20
+ main.xa                            : MDEV-11769 - lock wait timeout
  
  #----------------------------------------------------------------
  
@@@ -104,23 -70,15 +123,25 @@@ archive.mysqlhotcopy_archive : MDEV-109
  #----------------------------------------------------------------
  
  binlog.binlog_commit_wait                 : MDEV-10150 - Error: too much time elapsed
 +binlog.binlog_incident                    : Uses binlog_start_pos.inc modified in 10.1.20
 +binlog.binlog_killed                      : Uses binlog_start_pos.inc modified in 10.1.20
 +binlog.binlog_killed_simulate             : Uses binlog_start_pos.inc modified in 10.1.20
+ binlog.binlog_max_binlog_stmt_cache_size  : Added in 10.0.30
 +binlog.binlog_mysqlbinlog2                : Uses binlog_start_pos.inc modified in 10.1.20
 +binlog.mix_innodb_myisam_binlog           : Uses binlog_start_pos.inc modified in 10.1.20
 +binlog.binlog_row_annotate                : Uses binlog_start_pos.inc modified in 10.1.20
  binlog.binlog_xa_recover                  : MDEV-8517 - Extra checkpoint
  
  #----------------------------------------------------------------
  
 +binlog_encryption.*                : Added in 10.1.20
 +
 +#----------------------------------------------------------------
 +
- connect.jdbc            : Modified in 10.1.21
- connect.jdbc_new        : Modified in 10.1.21
  connect.tbl             : MDEV-9844, MDEV-10179 - sporadic crashes, valgrind warnings, wrong results
+ connect.xml             : Uses xsample2.xml modified in 10.0.30
+ connect.xml_zip         : Added in 10.0.30
+ connect.zip             : Added in 10.0.30
  
  #----------------------------------------------------------------
  
@@@ -166,59 -94,29 +188,72 @@@ federated.federated_transactions : MDEV
  
  #----------------------------------------------------------------
  
 -funcs_1.memory_views       : MDEV-11773 - timeout
 -funcs_1.processlist_val_ps : MDEV-12175 - Wrong result
++funcs_1.memory_views             : MDEV-11773 - timeout
 +funcs_1.processlist_val_no_prot  : MDEV-11223 - Wrong result
++funcs_1.processlist_val_ps       : MDEV-12175 - Wrong result
+ 
 -funcs_2/charset.*          : MDEV-10999 - test not maintained
++funcs_2/charset.*                : MDEV-10999 - test not maintained
 +
 +funcs_2.innodb_charset           : Modified in 10.1.21
 +funcs_2.memory_charset           : MDEV-10290 - Timeout
 +funcs_2.myisam_charset           : MDEV-11535 - Timeout
  
  #----------------------------------------------------------------
  
 -innodb.alter_key_block_size-11757            : Added in 10.0.30
 -innodb.binlog_consistent                     : MDEV-10618 - Server fails to start 
 +galera.galera_var_cluster_address : Modified in 10.1.21
 +galera.galera_var_dirty_reads : Modified in 10.1.21
 +galera.MW-284                 : Modified in 10.1.21
 +galera.rpl_row_annotate       : Uses binlog_start_pos.inc modified in 10.1.20
 +galera_split_brain            : Modified in 10.1.21
 +
 +galera_3nodes.*               : MDEV-11490 - Warnings not suppressed
 +
 +#----------------------------------------------------------------
 +
 +innodb.101_compatibility              : Added in 10.1.21
++innodb.alter_key_block_size-11757     : Added in 10.0.30
 +innodb.binlog_consistent              : MDEV-10618 - Server fails to start; also uses binlog_start_pos.inc modified in 10.1.20
 +innodb.doublewrite                    : Added in 10.1.21
 +innodb.group_commit_binlog_pos        : Uses binlog_start_pos.inc modified in 10.1.20
 +innodb.group_commit_binlog_pos_no_optimize_thread : Uses binlog_start_pos.inc modified in 10.1.20
 +innodb.group_commit_crash             : Modified in 10.1.21
- innodb.group_commit_crash_no_optimize_thread : Modified in 10.1.21
+ innodb.group_commit_crash_no_optimize_thread : MDEV-11770 - checksum mismatch
 -innodb.innodb-alter-table                    : MDEV-10619 - Testcase timeout
 -innodb.innodb_blob_unrecoverable_crash       : Modified in 10.0.30
 -innodb.innodb_bug14676111                    : Modified in 10.0.30
 -innodb.innodb_bug30423                       : MDEV-7311 - Wrong number of rows in the plan
 -innodb.innodb_bug59641                       : Modified in 10.0.30
 -innodb.innodb-get-fk                         : Modified in 10.0.30
 -innodb.innodb_monitor                        : MDEV-10939 - Testcase timeout
 -innodb.log_file_size                         : Added in 10.0.30
 -innodb.read_only_recovery                    : Added in 10.0.30
 -innodb.xa_recovery                           : Modified in 10.0.30
 -
 -innodb_fts.create                            : Added in 10.0.30
 -innodb_fts.innodb_fts_stopword_charset       : MDEV-12052 - Crash on shutdown
 +innodb.innodb-alter-table             : MDEV-10619 - Testcase timeout
++innodb.innodb_blob_unrecoverable_crash : Modified in 10.0.30
 +innodb.innodb-bug-14068765            : MDEV-9105 - valgrind warnings, assertion failures
 +innodb.innodb-bug-14084530            : MDEV-9105 - valgrind warnings, assertion failures
 +innodb.innodb_bug14147491             : MDEV-11808, also modified in 10.1.21
 +innodb.innodb_bug14676111             : MDEV-11802 - wrong result
 +innodb.innodb_bug30423                : MDEV-7311 - Wrong number of rows in the plan
++innodb.innodb_bug59641                : Modified in 10.0.30
 +innodb.innodb-change-buffer-recovery  : Modified in 10.1.21
 +innodb.innodb_defragment_fill_factor  : Modified in 10.1.20
++innodb.innodb-get-fk                  : Modified in 10.0.30
 +innodb.innodb-lock-schedule-algorithm : Modified in 10.1.20
 +innodb.innodb-page_compression_zip    : MDEV-10641 - mutex problem
 +innodb.innodb_stats                   : MDEV-10682 - wrong result
 +innodb.innodb_sys_semaphore_waits     : MDEV-10331 - wrong result
 +innodb.innodb-wl5522                  : MDEV-9105 - valgrind warnings, assertion failures
 +innodb.innodb-wl5522-1                : MDEV-9105 - valgrind warnings, assertion failures
 +innodb.innodb-wl5522-debug-zip        : Modified in 10.1.21
++innodb.innodb_monitor                 : MDEV-10939 - Testcase timeout
++innodb.read_only_recovery             : Added in 10.0.30
++innodb.xa_recovery                    : Modified in 10.0.30
 +innodb.log_data_file_size             : Added in 10.1.21
++innodb.log_file_size                  : Added in 10.0.30
 +innodb.table_index_statistics         : Added in 10.1.20
 +innodb.trigger                        : Modified in 10.1.20
 +innodb.xa_recovery                    : Modified in 10.1.21
 +
 +#----------------------------------------------------------------
 +
 +innodb_fts.create                     : Added in 10.1.20
++innodb_fts.innodb_fts_stopword_charset : MDEV-12052 - Crash on shutdown
 +
 +#----------------------------------------------------------------
 +
 +maria.collations        : Added in 10.1.20
 +maria.maria-connect     : Uses binlog_start_pos.inc modified in 10.1.20
  
  #----------------------------------------------------------------
  
@@@ -233,26 -129,45 +268,47 @@@ mroonga/storage.repair_table_no_index_f
  
  #----------------------------------------------------------------
  
- multi_source.gtid        : MDEV-10620, MDEV-10417 - Timeout in wait condition, fails on Mips
+ multi_source.gtid        : MDEV-10417 - Fails on Mips
 -multi_source.multisource : MDEV-10417 - Fails on Mips
 -multi_source.simple      : MDEV-4633 - Wrong slave status output
 +multi_source.info_logs   : MDEV-10042 - wrong result
 +multi_source.multisource : MDEV-10417 - Fails on Mips; also uses binlog_start_pos.inc modified in 10.1.20
 +multi_source.reset_slave : MDEV-10690 - wrong result; also uses binlog_start_pos.inc modified in 10.1.20
 +multi_source.simple      : MDEV-4633 - Wrong slave status output; also uses binlog_start_pos.inc modified in 10.1.20
  multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_received_heartbeats
  
+ 
+ #----------------------------------------------------------------
+ 
+ oqgraph.regression_mdev6282 : Modified in 10.0.30
+ oqgraph.regression_mdev6345 : Modified in 10.0.30
+ 
  #----------------------------------------------------------------
  
- parts.partition_float_myisam : MDEV-10621 - Testcase timeout
- parts.partition_int_myisam   : MDEV-10621 - Testcase timeout
+ parts.partition_bigint_innodb    : Added in 10.0.30
+ parts.partition_bigint_myisam    : Added in 10.0.30
+ parts.partition_double_innodb    : Added in 10.0.30
+ parts.partition_double_myisam    : Added in 10.0.30
+ parts.partition_exch_qa_10       : MDEV-11765 - wrong result
+ parts.partition_float_innodb     : Modified in 10.0.30
+ parts.partition_float_myisam     : Modified in 10.0.30
+ parts.partition_int_innodb       : Modified in 10.0.30
+ parts.partition_int_myisam       : Modified in 10.0.30
+ parts.partition_mediumint_innodb : Added in 10.0.30
+ parts.partition_mediumint_myisam : Added in 10.0.30
+ parts.partition_smallint_innodb  : Added in 10.0.30
+ parts.partition_smallint_myisam  : Added in 10.0.30
+ parts.partition_tinyint_innodb   : Added in 10.0.30
+ parts.partition_tinyint_myisam   : Added in 10.0.30
  
  #----------------------------------------------------------------
  
  perfschema.func_file_io                      : MDEV-5708 - fails for s390x
  perfschema.func_mutex                        : MDEV-5708 - fails for s390x
+ perfschema.hostcache_ipv6_ssl                : MDEV-10696 - crash on shutdown
 +perfschema.setup_actors                      : MDEV-10679 - rare crash
  perfschema.socket_summary_by_event_name_func : MDEV-10622 - Socket summary tables do not match
 +perfschema.stage_mdl_global                  : MDEV-11803 - wrong result on slow builders
- perfschema.threads_mysql                     : MDEV-10677 - sporadic wrong result
+ perfschema.stage_mdl_procedure               : MDEV-11545 - Wrong result
 -perfschema.threads_mysql                     : MDEV-12177 - Wrong result
 -
 -perfschema_stress.* : MDEV-10996 - tests not maintained
++perfschema.threads_mysql                     : MDEV-10677, MDEV-12177 - Wrong result
  
  #----------------------------------------------------------------
  
@@@ -264,8 -177,7 +320,6 @@@ plugins.two_password_validations : MDEV
  
  #----------------------------------------------------------------
  
- roles.role_case_sensitive-10744  : Added in 10.1.20
- roles.create_and_drop_role       : Modified in 10.1.20
 -roles.create_and_grant_role           : MDEV-11772 - wrong result
  
  #----------------------------------------------------------------
  
@@@ -275,52 -186,32 +328,46 @@@ rpl.rpl_auto_increment                
  rpl.rpl_auto_increment_bug45679       : MDEV-10417 - Fails on Mips
  rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log
  rpl.rpl_binlog_index                  : MDEV-9501 - Warning: failed registering on master
 +rpl.rpl_checksum                      : Uses search_pattern_in_file.inc modified in 10.1.20
- rpl.rpl_checksum_cache                : MDEV-10626 - Testcase timeout
- rpl.rpl_circular_for_4_hosts          : MDEV-10627 - Testcase timeout
+ rpl.rpl_checksum_cache                : MDEV-12173 - InnoDB error
  rpl.rpl_ddl                           : MDEV-10417 - Fails on Mips
 +rpl.rpl_domain_id_filter_restart      : MDEV-10684 - Wrong result
 +rpl.rpl_gtid_basic                    : MDEV-10681 - server startup problem
  rpl.rpl_gtid_crash                    : MDEV-9501 - Warning: failed registering on master
 +rpl.rpl_gtid_errorlog                 : Uses search_pattern_in_file.inc modified in 10.1.20
- rpl.rpl_gtid_master_promote           : MDEV-10628 - Timeout in sync_with_master
 +rpl.rpl_gtid_mdev9033                 : MDEV-10680 - warnings
  rpl.rpl_gtid_stop_start               : MDEV-10629 - Crash on shutdown
  rpl.rpl_gtid_until                    : MDEV-10625 - warnings in error log
- rpl.rpl_heartbeat_basic               : MDEV-11668 - wrong result
+ rpl.rpl_heartbeat_basic               : Modified in 10.0.30
  rpl.rpl_innodb_bug30888               : MDEV-10417 - Fails on Mips
  rpl.rpl_insert                        : MDEV-9329 - Fails on Ubuntu/s390x
  rpl.rpl_insert_delayed                : MDEV-9329 - Fails on Ubuntu/s390x
  rpl.rpl_invoked_features              : MDEV-10417 - Fails on Mips
 +rpl.rpl_mariadb_slave_capability      : MDEV-11018 - sporadic wrong events in binlog
- rpl.rpl_mdev10863                     : Added in 10.1.20
  rpl.rpl_mdev6020                      : MDEV-10630, MDEV-10417 - Timeouts, fails on Mips
- rpl.rpl_mdev6386                      : MDEV-10631 - Wrong result on slave
+ rpl.rpl_mdev6386                      : Modified in 10.0.30
 -rpl.rpl_parallel                      : MDEV-10653 - Timeouts
 +rpl.rpl_parallel                      : MDEV-10632, MDEV-10653 - Failures to sync, timeouts
 +rpl.rpl_parallel_optimistic           : MDEV-10511 - timeout
 +rpl.rpl_parallel_retry                : MDEV-11119 - Server crash
  rpl.rpl_parallel_temptable            : MDEV-10356 - Crash in close_thread_tables
  rpl.rpl_partition_innodb              : MDEV-10417 - Fails on Mips
 +rpl.rpl_row_annotate                  : Uses binlog_start_pos.inc modified in 10.1.20
 +rpl.rpl_password_boundaries           : MDEV-11534 - Slave IO warnings
- rpl.rpl_row_drop_create_temp_table    : MDEV-10626 - Testcase timeout
+ rpl.rpl_row_basic_11bugs              : MDEV-12171 - Server failed to start
 +rpl.rpl_row_flsh_tbls                 : Uses binlog_start_pos.inc modified in 10.1.20
 +rpl.rpl_row_log_innodb                : MDEV-10688 - Wrong result
- rpl.rpl_row_mysqlbinlog               : Modified in 10.1.21
  rpl.rpl_row_sp001                     : MDEV-9329 - Fails on Ubuntu/s390x
  rpl.rpl_semi_sync                     : MDEV-11220 - Wrong result
 +rpl.rpl_semi_sync_event_after_sync    : MDEV-11806 - warnings
  rpl.rpl_semi_sync_uninstall_plugin    : MDEV-7140 - Wrong plugin status
 -rpl.rpl_show_slave_hosts              : MDEV-12171 - Server failed to start
 +rpl.rpl_semi_sync_wait_point          : MDEV-11807 - timeout in wait condition
- rpl.rpl_show_slave_hosts              : MDEV-10681 - server startup problem
++rpl.rpl_show_slave_hosts              : MDEV-10681, MDEV-12171 - server startup problem
 +rpl.rpl_skip_replication              : MDEV-9268 - Fails with timeout in sync_slave_with_master on Alpha
  rpl.rpl_slave_grp_exec                : MDEV-10514 - Unexpected deadlock
- rpl.rpl_special_charset               : Modified in 10.1.21
 +rpl.rpl_stm_flsh_tbls                 : Uses binlog_start_pos.inc modified in 10.1.20
 +rpl.rpl_stop_slave_error              : Uses search_pattern_in_file.inc modified in 10.1.20
  rpl.rpl_sync                          : MDEV-10633 - Database page corruption
  rpl.rpl_temporary_error2              : MDEV-10634 - Wrong number of retries
- rpl.sec_behind_master-5114            : Modified in 10.1.21
 -rpl.rpl_skip_replication              : MDEV-9268 - Fails with timeout in sync_slave_with_master on Alpha
 -
 -rpl/extra/rpl_tests.*                 : MDEV-10994 - tests not maintained
  
  #----------------------------------------------------------------
  
@@@ -349,36 -236,33 +396,41 @@@ stress.ddl_innodb : MDEV-10635 - Testca
  
  #----------------------------------------------------------------
  
 -sys_vars.autocommit_func2                  : MDEV-9329 - Fails on Ubuntu/s390x
 -sys_vars.innodb_buffer_pool_dump_pct_basic : MDEV-10651 - sporadic failure on file_exists
 +sys_vars.autocommit_func2                      : MDEV-9329 - Fails on Ubuntu/s390x
 +sys_vars.keep_files_on_create_basic            : MDEV-10676 - timeout
 +sys_vars.innodb_buffer_pool_dump_pct_basic     : MDEV-10651 - sporadic failure on file_exists
 +sys_vars.innodb_fatal_semaphore_wait_threshold : MDEV-10513 - crashes
- sys_vars.replicate_do_db_basic                 : Modified in 10.1.20
- sys_vars.replicate_do_table_basic              : Modified in 10.1.20
- sys_vars.replicate_ignore_db_basic             : Modified in 10.1.20
- sys_vars.replicate_ignore_table_basic          : Modified in 10.1.20
- sys_vars.replicate_wild_do_table_basic         : Modified in 10.1.20
- sys_vars.replicate_wild_ignore_table_basic     : Modified in 10.1.20
+ sys_vars.innodb_force_recovery_crash_basic : Modified in 10.0.30
+ sys_vars.innodb_stats_include_delete_marked_basic : Added in 10.0.30
+ sys_vars.innodb_status_output_basic        : MDEV-12174 - Timeout
 +sys_vars.rpl_init_slave_func                   : MDEV-10149 - wrong results
 +sys_vars.sysvars_innodb                        : MDEV-6958 - error-prone rdiffs
 +sys_vars.sysvars_server_embedded               : MDEV-6958 - error-prone rdiffs
 +sys_vars.table_open_cache_instances_basic      : Modified in 10.1.20
+ sys_vars.secure_file_priv                  : Modified in 10.0.30
+ sys_vars.thread_cache_size_func            : MDEV-11775 - wrong result
  
  #----------------------------------------------------------------
  
 +tokudb.cluster_filter                : MDEV-10678 - Wrong execution plan
 +tokudb.cluster_filter_hidden         : MDEV-10678 - Wrong execution plan
  tokudb.cluster_filter_unpack_varchar : MDEV-10636 - Wrong execution plan
 -tokudb.dir_per_db                    : MDEV-11537 - wrong result
 +tokudb.dir_per_db                    : MDEV-11537 - Wrong result
+ tokudb.dir_per_db_rename_to_nonexisting_schema : Added in 10.0.30
+ tokudb.gap_lock_error                : Added in 10.0.30
+ tokudb.locks-select-update-3         : Modified in 10.0.30
+ tokudb.percona_kill_idle_trx_tokudb  : Added in 10.0.30
 +tokudb.table_index_statistics        : Added in 10.1.20
  
 -tokudb_backup.*                      : MDEV-11001 - tests don't work
  tokudb_bugs.checkpoint_lock          : MDEV-10637 - Wrong processlist output
  tokudb_bugs.checkpoint_lock_3        : MDEV-10637 - Wrong processlist output
  tokudb_bugs.xa                       : MDEV-11804 - Lock wait timeout
  
 -tokudb_rpl.*                         : MDEV-11001 - tests don't work
 -tokudb_sys_vars.*                    : MDEV-11001 - tests don't work
 +tokudb_rpl.rpl_parallel_optimistic   : Added in 10.1.20
 +tokudb_rpl.rpl_tokudb_rfr_partition_table : Added in 10.1.20
  
+ rpl-tokudb.rpl_extra_col_slave_tokudb : Result file modified in 10.0.30
+ 
  #----------------------------------------------------------------
  
  unit.ma_test_loghandler : MDEV-10638 - record read not ok
@@@ -387,11 -272,10 +439,16 @@@
  
  vcol.not_supported    : MDEV-10639 - Testcase timeout
  vcol.vcol_keys_innodb : MDEV-10639 - Testcase timeout
+ vcol.vcol_misc              : Modified in 10.0.30
+ vcol.vcol_select_myisam     : Modified in 10.0.30
+ vcol.vcol_trigger_sp_innodb : Include file modified in 10.0.30
+ vcol.vcol_trigger_sp_myisam : Include file modified in 10.0.30
+ vcol.wrong_arena            : Added in 10.0.30
  
  #----------------------------------------------------------------
 +
 +wsrep.binlog_format : MDEV-11532 - WSREP has not yet prepared node
 +
 +#----------------------------------------------------------------
 +
 +wsrep_info.plugin     : MDEV-11530 - Warnings; also modified in 10.1.20
diff --cc mysys/my_open.c
index b6d8f08bfc1,b1327a316e9..3999810eb2e
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@@ -45,10 -50,11 +50,11 @@@ File my_open(const char *FileName, int 
      MyFlags|= my_global_flags;
  #if defined(_WIN32)
    fd= my_win_open(FileName, Flags);
- #elif !defined(NO_OPEN_3)
-   fd = open(FileName, Flags | O_CLOEXEC, my_umask);     /* Normal unix */
  #else
-   fd = open((char *) FileName, Flags | O_CLOEXEC);
+   if (MyFlags & MY_NOSYMLINKS)
 -    fd = open_nosymlinks(FileName, Flags, my_umask);
++    fd = open_nosymlinks(FileName, Flags | O_CLOEXEC, my_umask);
+   else
 -    fd = open(FileName, Flags, my_umask);
++    fd = open(FileName, Flags | O_CLOEXEC, my_umask);
  #endif
  
    fd= my_register_filename(fd, FileName, FILE_BY_OPEN,
diff --cc sql/item_subselect.cc
index 3157d666e9b,e87db62bd98..6330165702e
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@@ -2104,7 -2048,8 +2104,8 @@@ Item_in_subselect::create_single_in_to_
          We can encounter "NULL IN (SELECT ...)". Wrap the added condition
          within a trig_cond.
        */
+       disable_cond_guard_for_const_null_left_expr(0);
 -      item= new Item_func_trig_cond(item, get_cond_guard(0));
 +      item= new (thd->mem_root) Item_func_trig_cond(thd, item, get_cond_guard(0));
      }
  
      if (!join_having)
@@@ -2122,14 -2067,15 +2123,15 @@@
        Item *having= item;
        Item *orig_item= item;
         
 -      item= func->create(expr, item);
 +      item= func->create(thd, expr, item);
        if (!abort_on_null && orig_item->maybe_null)
        {
 -	having= new Item_is_not_null_test(this, having);
 +	having= new (thd->mem_root) Item_is_not_null_test(thd, this, having);
          if (left_expr->maybe_null)
          {
+           disable_cond_guard_for_const_null_left_expr(0);
 -          if (!(having= new Item_func_trig_cond(having,
 -                                                get_cond_guard(0))))
 +          if (!(having= new (thd->mem_root) Item_func_trig_cond(thd, having,
 +                                                            get_cond_guard(0))))
              DBUG_RETURN(true);
          }
          having->name= (char*) in_having_cond;
@@@ -2146,8 -2092,8 +2148,9 @@@
        */
        if (!abort_on_null && left_expr->maybe_null)
        {
+         disable_cond_guard_for_const_null_left_expr(0);
 -        if (!(item= new Item_func_trig_cond(item, get_cond_guard(0))))
 +        if (!(item= new (thd->mem_root) Item_func_trig_cond(thd, item,
 +                                                            get_cond_guard(0))))
            DBUG_RETURN(true);
        }
  
@@@ -2166,17 -2112,16 +2169,18 @@@
        if (select_lex->master_unit()->is_union())
        {
          Item *new_having=
 -          func->create(expr,
 -                       new Item_ref_null_helper(&select_lex->context, this,
 -                                            select_lex->ref_pointer_array,
 -                                            (char *)"<no matter>",
 -                                            (char *)"<result>"));
 +          func->create(thd, expr,
 +                       new (thd->mem_root) Item_ref_null_helper(thd,
 +                                                  &select_lex->context,
 +                                                  this,
 +                                                  select_lex->ref_pointer_array,
 +                                                  (char *)"<no matter>",
 +                                                  (char *)"<result>"));
          if (!abort_on_null && left_expr->maybe_null)
          {
+           disable_cond_guard_for_const_null_left_expr(0);
 -          if (!(new_having= new Item_func_trig_cond(new_having,
 -                                                    get_cond_guard(0))))
 +          if (!(new_having= new (thd->mem_root) Item_func_trig_cond(thd, new_having,
 +                                                            get_cond_guard(0))))
              DBUG_RETURN(true);
          }
  
@@@ -2350,56 -2295,50 +2354,58 @@@ Item_in_subselect::create_row_in_to_exi
            check_cols(left_expr->element_index(i)->cols()))
          DBUG_RETURN(true);
        Item *item_eq=
 -        new Item_func_eq(new
 -                         Item_direct_ref(&select_lex->context,
 -                                         (*optimizer->get_cache())->
 -                                         addr(i),
 -                                         (char *)"<no matter>",
 -                                         (char *)in_left_expr_name),
 -                         new
 -                         Item_ref(&select_lex->context,
 -                                  select_lex->ref_pointer_array + i,
 +        new (thd->mem_root)
 +        Item_func_eq(thd, new (thd->mem_root)
 +                     Item_direct_ref(thd, &select_lex->context,
 +                                     (*optimizer->get_cache())->
 +                                     addr(i),
 +                                     (char *)"<no matter>",
 +                                     (char *)in_left_expr_name),
 +                     new (thd->mem_root)
 +                     Item_ref(thd, &select_lex->context,
 +                              select_lex->ref_pointer_array + i,
 +                              (char *)"<no matter>",
 +                              (char *)"<list ref>"));
 +      Item *item_isnull=
 +        new (thd->mem_root)
 +        Item_func_isnull(thd,
 +                         new (thd->mem_root)
 +                         Item_ref(thd, &select_lex->context,
 +                                  select_lex->ref_pointer_array+i,
                                    (char *)"<no matter>",
                                    (char *)"<list ref>"));
 -      Item *item_isnull=
 -        new Item_func_isnull(new
 -                             Item_ref(&select_lex->context,
 -                                      select_lex->ref_pointer_array+i,
 -                                      (char *)"<no matter>",
 -                                      (char *)"<list ref>"));
 -      Item *col_item= new Item_cond_or(item_eq, item_isnull);
 +      Item *col_item= new (thd->mem_root)
 +        Item_cond_or(thd, item_eq, item_isnull);
        if (!abort_on_null && left_expr->element_index(i)->maybe_null)
        {
+         disable_cond_guard_for_const_null_left_expr(i);
 -        if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i))))
 +        if (!(col_item= new (thd->mem_root)
 +              Item_func_trig_cond(thd, col_item, get_cond_guard(i))))
            DBUG_RETURN(true);
        }
 -      *having_item= and_items(*having_item, col_item);
 +      *having_item= and_items(thd, *having_item, col_item);
  
        Item *item_nnull_test= 
 -         new Item_is_not_null_test(this,
 -                                   new Item_ref(&select_lex->context,
 -                                                select_lex->
 -                                                ref_pointer_array + i,
 -                                                (char *)"<no matter>",
 -                                                (char *)"<list ref>"));
 +         new (thd->mem_root)
 +        Item_is_not_null_test(thd, this,
 +                              new (thd->mem_root)
 +                              Item_ref(thd, &select_lex->context,
 +                                       select_lex->
 +                                       ref_pointer_array + i,
 +                                       (char *)"<no matter>",
 +                                       (char *)"<list ref>"));
        if (!abort_on_null && left_expr->element_index(i)->maybe_null)
        {
+         disable_cond_guard_for_const_null_left_expr(i);
          if (!(item_nnull_test= 
 -              new Item_func_trig_cond(item_nnull_test, get_cond_guard(i))))
 +              new (thd->mem_root)
 +              Item_func_trig_cond(thd, item_nnull_test, get_cond_guard(i))))
            DBUG_RETURN(true);
        }
 -      item_having_part2= and_items(item_having_part2, item_nnull_test);
 +      item_having_part2= and_items(thd, item_having_part2, item_nnull_test);
        item_having_part2->top_level_item();
      }
 -    *having_item= and_items(*having_item, item_having_part2);
 +    *having_item= and_items(thd, *having_item, item_having_part2);
    }
    else
    {
@@@ -2448,17 -2384,17 +2454,18 @@@
                                             ref_pointer_array+i,
                                             (char *)"<no matter>",
                                             (char *)"<list ref>"));
 -        item= new Item_cond_or(item, item_isnull);
 +        item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
          if (left_expr->element_index(i)->maybe_null)
          {
+           disable_cond_guard_for_const_null_left_expr(i);
 -          if (!(item= new Item_func_trig_cond(item, get_cond_guard(i))))
 +          if (!(item= new (thd->mem_root)
 +                Item_func_trig_cond(thd, item, get_cond_guard(i))))
              DBUG_RETURN(true);
 -          if (!(having_col_item= 
 -                  new Item_func_trig_cond(having_col_item, get_cond_guard(i))))
 +          if (!(having_col_item= new (thd->mem_root)
 +                Item_func_trig_cond(thd, having_col_item, get_cond_guard(i))))
              DBUG_RETURN(true);
          }
 -        *having_item= and_items(*having_item, having_col_item);
 +        *having_item= and_items(thd, *having_item, having_col_item);
        }
        if (!abort_on_null && left_expr->element_index(i)->maybe_null)
        {
diff --cc sql/mysqld.cc
index 2607307ceee,79966f6f5e6..4f83e19f905
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@@ -8612,9 -8113,9 +8612,9 @@@ static int mysql_init_variables(void
    mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
  #if defined(HAVE_REALPATH) && !defined(HAVE_valgrind) && !defined(HAVE_BROKEN_REALPATH)
    /*  We can only test for sub paths if my_symlink.c is using realpath */
-   myisam_test_invalid_symlink= test_if_data_home_dir;
+   mysys_test_invalid_symlink= path_starts_from_data_home_dir;
  #endif
 -  opt_log= opt_slow_log= 0;
 +  opt_log= 0;
    opt_bin_log= opt_bin_log_used= 0;
    opt_disable_networking= opt_skip_show_db=0;
    opt_skip_name_resolve= 0;
diff --cc sql/sql_derived.cc
index 493f231bb39,af5b016df9d..d9457ba6624
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@@ -446,7 -446,10 +446,10 @@@ bool mysql_derived_merge(THD *thd, LEX 
    if (derived->get_unit()->prepared)
    {
      Item *expr= derived->on_expr;
 -    expr= and_conds(expr, dt_select->join ? dt_select->join->conds : 0);
 +    expr= and_conds(thd, expr, dt_select->join ? dt_select->join->conds : 0);
+     if (expr)
+       expr->top_level_item();
 -    
++
      if (expr && (derived->prep_on_expr || expr != derived->on_expr))
      {
        derived->on_expr= expr;
diff --cc sql/sql_parse.cc
index 45815fe7a02,a6574479e8d..7af299f3f06
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@@ -2123,12 -1909,12 +2123,12 @@@ int prepare_schema_table(THD *thd, LEX 
  #endif
    case SCH_COLUMNS:
    case SCH_STATISTICS:
-   {
  #ifdef DONT_ALLOW_SHOW_COMMANDS
      my_message(ER_NOT_ALLOWED_COMMAND,
 -               ER(ER_NOT_ALLOWED_COMMAND), MYF(0)); /* purecov: inspected */
 +               ER_THD(thd, ER_NOT_ALLOWED_COMMAND), MYF(0));
      DBUG_RETURN(1);
  #else
+   {
      DBUG_ASSERT(table_ident);
      TABLE_LIST **query_tables_last= lex->query_tables_last;
      schema_select_lex= new SELECT_LEX();
@@@ -7143,112 -6485,9 +7143,112 @@@ void mysql_init_multi_delete(LEX *lex
    lex->query_tables_last= &lex->query_tables;
  }
  
 +static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
 +                              Parser_state *parser_state)
 +{
 +#ifdef WITH_WSREP
 +  bool is_autocommit=
 +    !thd->in_multi_stmt_transaction_mode()                  &&
 +    thd->wsrep_conflict_state == NO_CONFLICT                &&
 +    !thd->wsrep_applier;
 +
 +  do
 +  {
 +    if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT)
 +    {
 +      thd->wsrep_conflict_state= NO_CONFLICT;
 +      /* Performance Schema Interface instrumentation, begin */
 +      thd->m_statement_psi= MYSQL_REFINE_STATEMENT(thd->m_statement_psi,
 +	      com_statement_info[thd->get_command()].m_key);
 +      MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(),
 +	                       thd->query_length());
 +    }
 +    mysql_parse(thd, rawbuf, length, parser_state);
 +
 +    if (WSREP(thd)) {
 +      /* wsrep BF abort in query exec phase */
 +      mysql_mutex_lock(&thd->LOCK_wsrep_thd);
 +      if (thd->wsrep_conflict_state == MUST_ABORT) {
 +        wsrep_client_rollback(thd);
 +
 +        WSREP_DEBUG("abort in exec query state, avoiding autocommit");
 +      }
 +
 +      if (thd->wsrep_conflict_state == MUST_REPLAY)
 +      {
 +        wsrep_replay_transaction(thd);
 +      }
 +
 +      /* setting error code for BF aborted trxs */
 +      if (thd->wsrep_conflict_state == ABORTED ||
 +          thd->wsrep_conflict_state == CERT_FAILURE)
 +      {
 +        thd->reset_for_next_command();
 +        thd->killed= NOT_KILLED;
 +        if (is_autocommit                           &&
 +            thd->lex->sql_command != SQLCOM_SELECT  &&
 +            (thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit))
 +        {
 +          WSREP_DEBUG("wsrep retrying AC query: %s", 
 +                      (thd->query()) ? thd->query() : "void");
 +
 +	  /* Performance Schema Interface instrumentation, end */
 +	  MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
 +	  thd->m_statement_psi= NULL;
 +          thd->m_digest= NULL;
 +          close_thread_tables(thd);
 +
 +          thd->wsrep_conflict_state= RETRY_AUTOCOMMIT;
 +          thd->wsrep_retry_counter++;            // grow
 +          wsrep_copy_query(thd);
 +          thd->set_time();
 +          parser_state->reset(rawbuf, length);
 +        }
 +        else
 +        {
 +          WSREP_DEBUG("%s, thd: %lu is_AC: %d, retry: %lu - %lu SQL: %s", 
 +                      (thd->wsrep_conflict_state == ABORTED) ? 
 +                      "BF Aborted" : "cert failure",
 +                      thd->thread_id, is_autocommit, thd->wsrep_retry_counter, 
 +                      thd->variables.wsrep_retry_autocommit, thd->query());
 +          my_error(ER_LOCK_DEADLOCK, MYF(0), "wsrep aborted transaction");
 +          thd->killed= NOT_KILLED;
 +          thd->wsrep_conflict_state= NO_CONFLICT;
 +          if (thd->wsrep_conflict_state != REPLAYING)
 +            thd->wsrep_retry_counter= 0;             //  reset
 +        }
 +      }
 +      else
 +      {
 +        set_if_smaller(thd->wsrep_retry_counter, 0); // reset; eventually ok
 +      }
 +      mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
 +    }
 +
 +    /* If retry is requested clean up explain structure */
 +    if (thd->wsrep_conflict_state == RETRY_AUTOCOMMIT && thd->lex->explain)
 +        delete_explain_query(thd->lex);
 +
 +  }  while (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT);
 +
 +  if (thd->wsrep_retry_query)
 +  {
 +    WSREP_DEBUG("releasing retry_query: conf %d sent %d kill %d  errno %d SQL %s",
 +                thd->wsrep_conflict_state,
 +	    thd->get_stmt_da()->is_sent(),
 +                thd->killed,
 +	    thd->get_stmt_da()->is_error() ? thd->get_stmt_da()->sql_errno() : 0,
 +                thd->wsrep_retry_query);
 +    my_free(thd->wsrep_retry_query);
 +    thd->wsrep_retry_query      = NULL;
 +    thd->wsrep_retry_query_len  = 0;
 +    thd->wsrep_retry_command    = COM_CONNECT;
 +  }
 +#endif /* WITH_WSREP */
 +}
  
  /*
-   When you modify mysql_parse(), you may need to mofify
+   When you modify mysql_parse(), you may need to modify
    mysql_test_parse_for_slave() in this same file.
  */
  
diff --cc sql/sql_select.cc
index cc07067bc8d,c9ad3f48d9d..cb39cb3a8b8
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@@ -10347,14 -10144,14 +10344,14 @@@ void JOIN::drop_unused_derived_keys(
         tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS))
    {
      
 -    TABLE *table=tab->table;
 -    if (!table)
 +    TABLE *tmp_tbl= tab->table;
 +    if (!tmp_tbl)
        continue;
 -    if (!table->pos_in_table_list->is_materialized_derived())
 +    if (!tmp_tbl->pos_in_table_list->is_materialized_derived())
        continue;
-     if (tmp_tbl->max_keys > 1)
 -    if (table->max_keys > 1 && !tab->is_ref_for_hash_join())
 -      table->use_index(tab->ref.key);
 -    if (table->s->keys)
++    if (tmp_tbl->max_keys > 1 && !tab->is_ref_for_hash_join())
 +      tmp_tbl->use_index(tab->ref.key);
 +    if (tmp_tbl->s->keys)
      {
        if (tab->ref.key >= 0)
          tab->ref.key= 0;
@@@ -15890,41 -15506,10 +15887,43 @@@ Field *Item::create_tmp_field(bool grou
    }
    if (new_field)
      new_field->init(table);
 +  return new_field;
 +}
 +
 +
 +
 +/**
 +  Create field for temporary table using type of given item.
 +
 +  @param thd                   Thread handler
 +  @param item                  Item to create a field for
 +  @param table                 Temporary table
 +  @param copy_func             If set and item is a function, store copy of
 +                               item in this array
 +  @param modify_item           1 if item->result_field should point to new
 +                               item. This is relevent for how fill_record()
 +                               is going to work:
 +                               If modify_item is 1 then fill_record() will
 +                               update the record in the original table.
 +                               If modify_item is 0 then fill_record() will
 +                               update the temporary table
 +
 +  @retval
 +    0  on error
 +  @retval
 +    new_created field
 +*/
 +
 +static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
 +                                         Item ***copy_func, bool modify_item)
 +{
 +  Field *UNINIT_VAR(new_field);
 +  DBUG_ASSERT(thd == table->in_use);
 +  new_field= item->Item::create_tmp_field(false, table);
      
-   if (copy_func && item->real_item()->is_result_field())
+   if (copy_func &&
+       (item->is_result_field() || 
+        (item->real_item()->is_result_field())))
      *((*copy_func)++) = item;			// Save for copy_funcs
    if (modify_item)
      item->set_result_field(new_field);
diff --cc storage/innobase/log/log0log.cc
index 624ee0bb35d,b94a6d30c7d..704e88ff646
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@@ -2,7 -2,7 +2,7 @@@
  
  Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
  Copyright (c) 2009, Google Inc.
- Copyright (c) 2014, 2017, MariaDB Corporation. All Rights Reserved.
 -Copyright (c) 2017, MariaDB Corporation.
++Copyright (c) 2014, 2017, MariaDB Corporation.
  
  Portions of this file contain modifications contributed and copyrighted by
  Google, Inc. Those modifications are gratefully acknowledged and are described
@@@ -38,6 -38,6 +38,10 @@@ Created 12/9/1995 Heikki Tuur
  #endif
  
  #ifndef UNIV_HOTBACKUP
++#if MYSQL_VERSION_ID < 100200
++# include <my_systemd.h> /* sd_notifyf() */
++#endif
++
  #include "mem0mem.h"
  #include "buf0buf.h"
  #include "buf0flu.h"
@@@ -2374,6 -2336,11 +2378,13 @@@ loop
  	start_lsn += len;
  	buf += len;
  
+ 	if (recv_sys->report(ut_time())) {
+ 		ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF,
+ 			start_lsn);
++		sd_notifyf(0, "STATUS=Read redo log up to LSN=" LSN_PF,
++			   start_lsn);
+ 	}
+ 
  	if (start_lsn != end_lsn) {
  
  		goto loop;
diff --cc storage/innobase/log/log0recv.cc
index 104b5b6b421,a90041aaa90..d088ae9f3df
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@@ -2,7 -2,7 +2,7 @@@
  
  Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
  Copyright (c) 2012, Facebook Inc.
- Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
 -Copyright (c) 2017, MariaDB Corporation.
++Copyright (c) 2013, 2017, 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
@@@ -435,26 -423,25 +431,13 @@@ recv_sys_init
  	mutex_exit(&(recv_sys->mutex));
  }
  
--/********************************************************//**
- Empties the hash table when it has been fully processed.
- @return DB_SUCCESS when successfull or DB_ERROR when fails. */
 -Empties the hash table when it has been fully processed. */
++/** Empty a fully processed hash table. */
  static
- dberr_t
- recv_sys_empty_hash(void)
- /*=====================*/
+ void
 -recv_sys_empty_hash(void)
 -/*=====================*/
++recv_sys_empty_hash()
  {
  	ut_ad(mutex_own(&(recv_sys->mutex)));
--
--	if (recv_sys->n_addrs != 0) {
--		fprintf(stderr,
--			"InnoDB: Error: %lu pages with log records"
--			" were left unprocessed!\n"
--			"InnoDB: Maximum page number with"
--			" log records on it %lu\n",
--			(ulong) recv_sys->n_addrs,
--			(ulong) recv_max_parsed_page_no);
- 		return DB_ERROR;
 -		ut_error;
--	}
++	ut_a(recv_sys->n_addrs == 0);
  
  	hash_table_free(recv_sys->addr_hash);
  	mem_heap_empty(recv_sys->heap);
@@@ -1716,7 -1759,9 +1697,9 @@@ recv_recover_page_func
  
  	mtr_commit(&mtr);
  
- 	mutex_enter(&(recv_sys->mutex));
 -	time = ut_time();
++	ib_time_t time = ut_time();
+ 
 -	mutex_enter(&(recv_sys->mutex));
++	mutex_enter(&recv_sys->mutex);
  
  	if (recv_max_page_lsn < page_lsn) {
  		recv_max_page_lsn = page_lsn;
@@@ -1724,11 -1769,16 +1707,17 @@@
  
  	recv_addr->state = RECV_PROCESSED;
  
- 	ut_a(recv_sys->n_addrs);
- 	recv_sys->n_addrs--;
- 
- 	mutex_exit(&(recv_sys->mutex));
+ 	ut_a(recv_sys->n_addrs > 0);
 -	if (--recv_sys->n_addrs && recv_sys->progress_time - time >= 15) {
 -		recv_sys->progress_time = time;
 -		ut_print_timestamp(stderr);
 -		fprintf(stderr,
 -			"  InnoDB: To recover: " ULINTPF " pages from log\n",
 -			recv_sys->n_addrs);
++	if (ulint n = --recv_sys->n_addrs) {
++		if (recv_sys->report(time)) {
++			ib_logf(IB_LOG_LEVEL_INFO,
++				"To recover: " ULINTPF " pages from log", n);
++			sd_notifyf(0, "STATUS=To recover: " ULINTPF
++				   " pages from log", n);
++		}
+ 	}
  
+ 	mutex_exit(&recv_sys->mutex);
  }
  
  #ifndef UNIV_HOTBACKUP
@@@ -1822,6 -1851,14 +1790,16 @@@ recv_apply_hashed_log_recs(bool last_ba
  		recv_no_ibuf_operations = TRUE;
  	}
  
+ 	if (ulint n = recv_sys->n_addrs) {
+ 		const char* msg = last_batch
+ 			? "Starting final batch to recover "
+ 			: "Starting a batch to recover ";
+ 		ib_logf(IB_LOG_LEVEL_INFO,
+ 			"%s" ULINTPF " pages from redo log", msg, n);
++		sd_notifyf(0, "STATUS=%s" ULINTPF " pages from redo log",
++			   msg, n);
+ 	}
+ 
  	recv_sys->apply_log_recs = TRUE;
  	recv_sys->apply_batch_on = TRUE;
  
@@@ -2087,18 -2082,7 +2023,8 @@@ recv_apply_log_recs_for_backup(void
  skip_this_recv_addr:
  			recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
  		}
- 
- 		if ((100 * i) / n_hash_cells
- 		    != (100 * (i + 1)) / n_hash_cells) {
- 			fprintf(stderr, "%lu ",
- 				(ulong) ((100 * i) / n_hash_cells));
- 			fflush(stderr);
- 			sd_notifyf(0, "STATUS=Applying batch of log records for"
- 				   " backup InnoDB: Progress %lu",
- 				   (ulong) (100 * i) / n_hash_cells);
- 		}
  	}
 +	sd_notify(0, "STATUS=InnoDB: Apply batch for backup completed");
  
  	recv_sys_empty_hash();
  }
diff --cc storage/innobase/srv/srv0start.cc
index 79cd3aebdd0,127ccb34f52..58117859de8
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@@ -2483,30 -2458,7 +2483,26 @@@ files_checked
  			return(err);
  		}
  
- 		/* This must precede recv_apply_hashed_log_recs(TRUE). */
++		/* This must precede recv_apply_hashed_log_recs(true). */
 +		ib_bh = trx_sys_init_at_db_start();
 +
 +		if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
 +			/* Apply the hashed log records to the
 +			respective file pages, for the last batch of
 +			recv_group_scan_log_recs(). */
 +
- 			err = recv_apply_hashed_log_recs(TRUE);
++			recv_apply_hashed_log_recs(true);
 +			DBUG_PRINT("ib_log", ("apply completed"));
- 
- 			if (err != DB_SUCCESS) {
- 				return(err);
- 			}
 +		}
 +
  		if (!srv_read_only_mode) {
 +			const ulint flags = FSP_FLAGS_PAGE_SSIZE();
 +			for (ulint id = 0; id <= srv_undo_tablespaces; id++) {
 +				if (fil_space_get(id)) {
 +					fsp_flags_try_adjust(id, flags);
 +				}
 +			}
 +
  			if (sum_of_new_sizes > 0) {
  				/* New data file(s) were added */
  				mtr_start(&mtr);
diff --cc storage/maria/ma_create.c
index 0680b5d568e,14809636616..5f7ac333d5d
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@@ -1248,12 -1205,12 +1250,13 @@@ err_no_lock
    case 1:
      mysql_file_close(file, MYF(0));
      if (! (flags & HA_DONT_TOUCH_DATA))
-       mysql_file_delete_with_symlink(key_file_kfile,
-                                      fn_format(filename,name,"",MARIA_NAME_IEXT,
-                                        MY_UNPACK_FILENAME | MY_APPEND_EXT),
- 			     sync_dir);
+     {
+       mysql_file_delete(key_file_kfile, kfilename, MYF(sync_dir));
+       if (klinkname_ptr)
+         mysql_file_delete(key_file_kfile, klinkname_ptr, MYF(sync_dir));
+     }
    }
 +  ma_crypt_free(&share);
    my_free(log_data);
    my_free(rec_per_key_part);
    DBUG_RETURN(my_errno=save_errno);		/* return the fatal errno */
diff --cc storage/maria/ma_delete_table.c
index ec68902485b,a9ab8e596cc..970ac792623
--- a/storage/maria/ma_delete_table.c
+++ b/storage/maria/ma_delete_table.c
@@@ -82,27 -82,15 +82,17 @@@ int maria_delete_table(const char *name
  }
  
  
 -int maria_delete_table_files(const char *name, myf sync_dir)
 +int maria_delete_table_files(const char *name, my_bool temporary, myf sync_dir)
  {
-   char from[FN_REFLEN];
    DBUG_ENTER("maria_delete_table_files");
  
-   fn_format(from,name,"",MARIA_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
-   if (mysql_file_delete_with_symlink(key_file_kfile, from,
-                                      MYF(MY_WME | sync_dir)))
-     DBUG_RETURN(my_errno);
-   fn_format(from,name,"",MARIA_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
-   if (mysql_file_delete_with_symlink(key_file_dfile, from,
-                                      MYF(MY_WME | sync_dir)))
+   if (my_handler_delete_with_symlink(key_file_kfile, name, MARIA_NAME_IEXT, MYF(MY_WME | sync_dir)) ||
+       my_handler_delete_with_symlink(key_file_dfile, name, MARIA_NAME_DEXT, MYF(MY_WME | sync_dir)))
      DBUG_RETURN(my_errno);
  
-   // optional files from maria_pack:
-   if (!temporary)
-   {
-     fn_format(from,name,"",".TMD",MY_UNPACK_FILENAME|MY_APPEND_EXT);
-     mysql_file_delete_with_symlink(key_file_dfile, from, MYF(0));
-     fn_format(from,name,"",".OLD",MY_UNPACK_FILENAME|MY_APPEND_EXT);
-     mysql_file_delete_with_symlink(key_file_dfile, from, MYF(0));
 -  my_handler_delete_with_symlink(key_file_dfile, name, ".TMD", MYF(0));
 -  my_handler_delete_with_symlink(key_file_dfile, name, ".OLD", MYF(0));
++  if (!temporary) {
++    my_handler_delete_with_symlink(key_file_dfile, name, ".TMD", MYF(0));
++    my_handler_delete_with_symlink(key_file_dfile, name, ".OLD", MYF(0));
 +  }
    DBUG_RETURN(0);
  }
diff --cc storage/myisam/ha_myisam.cc
index 60764bfd696,2cfaa5ebdcc..e363fb1da2b
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@@ -1000,30 -1002,29 +1000,30 @@@ int ha_myisam::analyze(THD *thd, HA_CHE
  int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
  {
    int error;
-   HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
+   HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
    ha_rows start_records;
  
-   if (!file || !&param) return HA_ADMIN_INTERNAL_ERROR;
+   if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
  
-   myisamchk_init(&param);
-   param.thd = thd;
-   param.op_name=  "repair";
-   param.testflag= ((check_opt->flags & ~(T_EXTEND)) |
+   myisamchk_init(param);
+   param->thd = thd;
+   param->op_name=  "repair";
+   param->testflag= ((check_opt->flags & ~(T_EXTEND)) |
                     T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM |
                     (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
-   param.tmpfile_createflag= O_RDWR | O_TRUNC;
-   param.sort_buffer_length=  THDVAR(thd, sort_buffer_size);
-   param.backup_time= check_opt->start_time;
++  param->tmpfile_createflag= O_RDWR | O_TRUNC;
+   param->sort_buffer_length=  THDVAR(thd, sort_buffer_size);
+   param->backup_time= check_opt->start_time;
    start_records=file->state->records;
-   while ((error=repair(thd,param,0)) && param.retry_repair)
+   while ((error=repair(thd,*param,0)) && param->retry_repair)
    {
-     param.retry_repair=0;
-     if (test_all_bits(param.testflag,
+     param->retry_repair=0;
+     if (test_all_bits(param->testflag,
  		      (uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
      {
-       param.testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
+       param->testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
        /* Ensure we don't loose any rows when retrying without quick */
-       param.testflag|= T_SAFE_REPAIR;
+       param->testflag|= T_SAFE_REPAIR;
        sql_print_information("Retrying repair of: '%s' including modifying data file",
                              table->s->path.str);
        continue;
@@@ -1053,23 -1054,22 +1053,23 @@@
  int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
  {
    int error;
-   HA_CHECK &param= *(HA_CHECK*) thd->alloc(sizeof(param));
+   HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
  
-   if (!file || !&param) return HA_ADMIN_INTERNAL_ERROR;
+   if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
  
-   myisamchk_init(&param);
-   param.thd = thd;
-   param.op_name= "optimize";
-   param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
+   myisamchk_init(param);
+   param->thd = thd;
+   param->op_name= "optimize";
+   param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
                     T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
-   param.tmpfile_createflag= O_RDWR | O_TRUNC;
-   param.sort_buffer_length=  THDVAR(thd, sort_buffer_size);
-   if ((error= repair(thd,param,1)) && param.retry_repair)
++  param->tmpfile_createflag= O_RDWR | O_TRUNC;
+   param->sort_buffer_length=  THDVAR(thd, sort_buffer_size);
+   if ((error= repair(thd,*param,1)) && param->retry_repair)
    {
      sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying",
-                       my_errno, param.db_name, param.table_name);
-     param.testflag&= ~T_REP_BY_SORT;
-     error= repair(thd,param,1);
+                       my_errno, param->db_name, param->table_name);
+     param->testflag&= ~T_REP_BY_SORT;
+     error= repair(thd,*param,1);
    }
    return error;
  }
diff --cc storage/myisam/mi_check.c
index bab0ad2b6a4,bbe45aa3c26..3d6e6297d3b
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@@ -68,14 -69,18 +68,14 @@@ static int sort_get_next_record(MI_SORT
  static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,const void *b);
  static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a);
  static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a);
 -static my_off_t get_record_for_key(MI_INFO *info,MI_KEYDEF *keyinfo,
 -				uchar *key);
 -static int sort_insert_key(MI_SORT_PARAM  *sort_param,
 -                           reg1 SORT_KEY_BLOCKS *key_block,
 -			   uchar *key, my_off_t prev_block);
 +static my_off_t get_record_for_key(MI_INFO *, MI_KEYDEF *, uchar *);
 +static int sort_insert_key(MI_SORT_PARAM  *, SORT_KEY_BLOCKS *, uchar *, my_off_t);
  static int sort_delete_record(MI_SORT_PARAM *sort_param);
  /*static int flush_pending_blocks(HA_CHECK *param);*/
 -static SORT_KEY_BLOCKS	*alloc_key_blocks(HA_CHECK *param, uint blocks,
 -					  uint buffer_length);
 +static SORT_KEY_BLOCKS	*alloc_key_blocks(HA_CHECK *, uint, uint);
  static ha_checksum mi_byte_checksum(const uchar *buf, uint length);
  static void set_data_file_type(MI_SORT_INFO *sort_info, MYISAM_SHARE *share);
- static int replace_data_file(HA_CHECK *, MI_INFO *, const char *, File);
+ static int replace_data_file(HA_CHECK *param, MI_INFO *info, File new_file);
  
  void myisamchk_init(HA_CHECK *param)
  {
diff --cc storage/xtradb/handler/handler0alter.cc
index 740f15c2bd5,cfae2725b05..aede923d22f
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@@ -4271,18 -4224,9 +4284,16 @@@ oom
  		break;
  	case DB_INDEX_CORRUPT:
  		my_error(ER_INDEX_CORRUPT, MYF(0),
- 			 (prebuilt->trx->error_key_num == ULINT_UNDEFINED)
- 			 ? FTS_DOC_ID_INDEX_NAME
- 			 : ha_alter_info->key_info_buffer[
- 				 prebuilt->trx->error_key_num].name);
+ 			 get_error_key_name(prebuilt->trx->error_key_num,
+ 					    ha_alter_info, prebuilt->table));
  		break;
 +	case DB_DECRYPTION_FAILED: {
 +		String str;
 +		const char* engine= table_type();
 +		get_error_message(HA_ERR_DECRYPTION_FAILED, &str);
 +		my_error(ER_GET_ERRMSG, MYF(0), HA_ERR_DECRYPTION_FAILED, str.c_ptr(), engine);
 +		break;
 +	}
  	default:
  		my_error_innodb(error,
  				table_share->table_name.str,
diff --cc storage/xtradb/include/os0file.h
index f590c5f16ce,60a9c3475e7..d6f0ecfb69c
--- a/storage/xtradb/include/os0file.h
+++ b/storage/xtradb/include/os0file.h
@@@ -552,14 -550,13 +552,15 @@@ os_file_create_simple_no_error_handling
  				program reading the file), or
  				OS_FILE_READ_WRITE_CACHED (disable O_DIRECT
  				if it would be enabled otherwise) */
 -	ibool*		success)/*!< out: TRUE if succeed, FALSE if error */
 -	MY_ATTRIBUTE((nonnull, warn_unused_result));
 +	ibool*		success,/*!< out: TRUE if succeed, FALSE if error */
 +	ulint		atomic_writes)/*!< in: atomic writes table option
 +				      value */
 +	__attribute__((nonnull, warn_unused_result));
  /****************************************************************//**
- Tries to disable OS caching on an opened file descriptor. */
+ Tries to disable OS caching on an opened file descriptor.
+ @return true if operation is success and false otherwise */
  UNIV_INTERN
- void
+ bool
  os_file_set_nocache(
  /*================*/
  	os_file_t	fd,		/*!< in: file descriptor to alter */
diff --cc storage/xtradb/include/srv0srv.h
index 8713322a008,0923c9a88d7..a2ea6509852
--- a/storage/xtradb/include/srv0srv.h
+++ b/storage/xtradb/include/srv0srv.h
@@@ -1312,13 -1147,12 +1313,21 @@@ struct srv_slot_t
  # define srv_file_per_table			1
  #endif /* !UNIV_HOTBACKUP */
  
 +#ifdef WITH_WSREP
 +UNIV_INTERN
 +void
 +wsrep_srv_conc_cancel_wait(
 +/*==================*/
 +	trx_t*	trx);	/*!< in: transaction object associated with the
 +			thread */
 +#endif /* WITH_WSREP */
 +
+ #ifndef DBUG_OFF
+ /** false before InnoDB monitor has been printed at least once, true
+ afterwards */
+ extern bool	srv_debug_monitor_printed;
+ #else
+ #define	srv_debug_monitor_printed	false
+ #endif
+ 
  #endif
diff --cc storage/xtradb/log/log0log.cc
index e0259ef80a6,3627d85da63..4c654f5272d
--- a/storage/xtradb/log/log0log.cc
+++ b/storage/xtradb/log/log0log.cc
@@@ -2,7 -2,7 +2,7 @@@
  
  Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
  Copyright (c) 2009, Google Inc.
- Copyright (c) 2014, 2017, MariaDB Corporation. All Rights Reserved.
 -Copyright (c) 2017, MariaDB Corporation.
++Copyright (c) 2014, 2017, MariaDB Corporation.
  
  Portions of this file contain modifications contributed and copyrighted by
  Google, Inc. Those modifications are gratefully acknowledged and are described
@@@ -48,6 -45,6 +48,10 @@@ Created 12/9/1995 Heikki Tuur
  #endif
  
  #ifndef UNIV_HOTBACKUP
++#if MYSQL_VERSION_ID < 100200
++# include <my_systemd.h> /* sd_notifyf() */
++#endif
++
  #include "mem0mem.h"
  #include "buf0buf.h"
  #include "buf0flu.h"
@@@ -2625,6 -2568,11 +2629,13 @@@ loop
  	start_lsn += len;
  	buf += len;
  
+ 	if (recv_sys->report(ut_time())) {
+ 		ib_logf(IB_LOG_LEVEL_INFO, "Read redo log up to LSN=" LSN_PF,
+ 			start_lsn);
++		sd_notifyf(0, "STATUS=Read redo log up to LSN=" LSN_PF,
++			   start_lsn);
+ 	}
+ 
  	if (start_lsn != end_lsn) {
  
  		if (release_mutex) {
diff --cc storage/xtradb/log/log0recv.cc
index 6405a87a2bd,afb8b7f00b8..a20cb8dec4d
--- a/storage/xtradb/log/log0recv.cc
+++ b/storage/xtradb/log/log0recv.cc
@@@ -2,7 -2,7 +2,7 @@@
  
  Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
  Copyright (c) 2012, Facebook Inc.
- Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved.
 -Copyright (c) 2017, MariaDB Corporation.
++Copyright (c) 2013, 2017, 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
@@@ -431,26 -422,25 +427,13 @@@ recv_sys_init
  	mutex_exit(&(recv_sys->mutex));
  }
  
--/********************************************************//**
- Empties the hash table when it has been fully processed.
- @return DB_SUCCESS when successfull or DB_ERROR when fails. */
 -Empties the hash table when it has been fully processed. */
++/** Empty a fully processed hash table. */
  static
- dberr_t
- recv_sys_empty_hash(void)
- /*=====================*/
+ void
 -recv_sys_empty_hash(void)
 -/*=====================*/
++recv_sys_empty_hash()
  {
  	ut_ad(mutex_own(&(recv_sys->mutex)));
--
--	if (recv_sys->n_addrs != 0) {
--		fprintf(stderr,
--			"InnoDB: Error: %lu pages with log records"
--			" were left unprocessed!\n"
--			"InnoDB: Maximum page number with"
--			" log records on it %lu\n",
--			(ulong) recv_sys->n_addrs,
--			(ulong) recv_max_parsed_page_no);
- 		return DB_ERROR;
 -		ut_error;
--	}
++	ut_a(recv_sys->n_addrs == 0);
  
  	hash_table_free(recv_sys->addr_hash);
  	mem_heap_empty(recv_sys->heap);
@@@ -1804,6 -1849,8 +1785,8 @@@ recv_recover_page_func
  
  	mtr_commit(&mtr);
  
 -	time = ut_time();
++	ib_time_t time = ut_time();
+ 
  	mutex_enter(&(recv_sys->mutex));
  
  	if (recv_max_page_lsn < page_lsn) {
@@@ -1812,11 -1859,16 +1795,17 @@@
  
  	recv_addr->state = RECV_PROCESSED;
  
- 	ut_a(recv_sys->n_addrs);
- 	recv_sys->n_addrs--;
- 
- 	mutex_exit(&(recv_sys->mutex));
+ 	ut_a(recv_sys->n_addrs > 0);
 -	if (--recv_sys->n_addrs && recv_sys->progress_time - time >= 15) {
 -		recv_sys->progress_time = time;
 -		ut_print_timestamp(stderr);
 -		fprintf(stderr,
 -			"  InnoDB: To recover: " ULINTPF " pages from log\n",
 -			recv_sys->n_addrs);
++	if (ulint n = --recv_sys->n_addrs) {
++		if (recv_sys->report(time)) {
++			ib_logf(IB_LOG_LEVEL_INFO,
++				"To recover: " ULINTPF " pages from log", n);
++			sd_notifyf(0, "STATUS=To recover: " ULINTPF
++				   " pages from log", n);
++		}
+ 	}
  
+ 	mutex_exit(&recv_sys->mutex);
  }
  
  #ifndef UNIV_HOTBACKUP
@@@ -1910,6 -1941,14 +1878,16 @@@ recv_apply_hashed_log_recs(bool last_ba
  		recv_no_ibuf_operations = TRUE;
  	}
  
+ 	if (ulint n = recv_sys->n_addrs) {
+ 		const char* msg = last_batch
+ 			? "Starting final batch to recover "
+ 			: "Starting a batch to recover ";
+ 		ib_logf(IB_LOG_LEVEL_INFO,
+ 			"%s" ULINTPF " pages from redo log", msg, n);
++		sd_notifyf(0, "STATUS=%s" ULINTPF " pages from redo log",
++			   msg, n);
+ 	}
+ 
  	recv_sys->apply_log_recs = TRUE;
  	recv_sys->apply_batch_on = TRUE;
  
@@@ -2177,18 -2172,7 +2113,8 @@@ recv_apply_log_recs_for_backup(void
  skip_this_recv_addr:
  			recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
  		}
- 
- 		if ((100 * i) / n_hash_cells
- 		    != (100 * (i + 1)) / n_hash_cells) {
- 			fprintf(stderr, "%lu ",
- 				(ulong) ((100 * i) / n_hash_cells));
- 			fflush(stderr);
- 			sd_notifyf(0, "STATUS=Applying batch of log records for"
- 				   " backup InnoDB: Progress %lu",
- 				   (ulong) (100 * i) / n_hash_cells);
- 		}
  	}
 +	sd_notify(0, "STATUS=InnoDB: Apply batch for backup completed");
  
  	recv_sys_empty_hash();
  }
diff --cc storage/xtradb/os/os0file.cc
index c5be6d45c0e,a30b688ad74..cdc3df5e851
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@@ -1598,16 -1424,19 +1563,20 @@@ os_file_set_nocache_if_needed(os_file_
  			      const char *mode_str, ulint type,
  			      ulint access_type)
  {
 -	if (srv_read_only_mode || access_type == OS_FILE_READ_WRITE_CACHED)
 +	if (srv_read_only_mode || access_type == OS_FILE_READ_WRITE_CACHED) {
  		return;
 +	}
  
  	if (srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT
 -	    || (type != OS_LOG_FILE
 +	    || (type == OS_DATA_FILE
  		&& (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT
- 		    || (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT_NO_FSYNC)))) {
- 		os_file_set_nocache(file, name, mode_str);
- 	}
+ 		    || (srv_unix_file_flush_method
+ 			== SRV_UNIX_O_DIRECT_NO_FSYNC))))
+ 		/* Do fsync() on log files when setting O_DIRECT fails.
+ 		See log_io_complete() */
+ 		if (!os_file_set_nocache(file, name, mode_str)
+ 		    && srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT)
+ 			srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
  }
  
  /****************************************************************//**
diff --cc storage/xtradb/srv/srv0srv.cc
index 3865332efbe,72ea6c0d7d5..5389b7e9bc4
--- a/storage/xtradb/srv/srv0srv.cc
+++ b/storage/xtradb/srv/srv0srv.cc
@@@ -70,21 -70,10 +70,15 @@@ Created 10/8/1995 Heikki Tuur
  #include "srv0mon.h"
  #include "ut0crc32.h"
  #include "os0file.h"
 -
 +#include "btr0defragment.h"
  #include "mysql/plugin.h"
  #include "mysql/service_thd_wait.h"
 +#include "fil0fil.h"
 +#include "fil0crypt.h"
 +#include "fil0pagecompress.h"
 +#include <my_rdtsc.h>
 +#include "btr0scrub.h"
  
- /* prototypes of new functions added to ha_innodb.cc for kill_idle_transaction */
- ibool		innobase_thd_is_idle(const void* thd);
- ib_int64_t	innobase_thd_get_start_time(const void* thd);
- void		innobase_thd_kill(ulong thd_id);
- ulong		innobase_thd_get_thread_id(const void* thd);
- 
  /* prototypes for new functions added to ha_innodb.cc */
  ibool	innobase_get_slow_log();
  
diff --cc storage/xtradb/srv/srv0start.cc
index 679913959c9,d94dfe87783..5b6ca38951e
--- a/storage/xtradb/srv/srv0start.cc
+++ b/storage/xtradb/srv/srv0start.cc
@@@ -2513,6 -2488,22 +2514,23 @@@ files_checked
  		and there must be no page in the buf_flush list. */
  		buf_pool_invalidate();
  
+ 		/* Start monitor thread early enough so that e.g. crash
+ 		recovery failing to find free pages in the buffer pool is
+ 		diagnosed. */
+ 		if (!srv_read_only_mode)
+ 		{
+ 			/* Create the thread which prints InnoDB monitor
+ 			info */
++			srv_monitor_active = true;
+ 			thread_handles[4 + SRV_MAX_N_IO_THREADS] =
+ 				os_thread_create(
+ 					srv_monitor_thread,
+ 					NULL,
+ 					thread_ids + 4 + SRV_MAX_N_IO_THREADS);
+ 
+ 			thread_started[4 + SRV_MAX_N_IO_THREADS] = true;
+ 		}
+ 
  		/* We always try to do a recovery, even if the database had
  		been shut down normally: this is the normal startup path */
  
@@@ -2533,30 -2524,7 +2551,26 @@@
  			return(err);
  		}
  
- 		/* This must precede recv_apply_hashed_log_recs(TRUE). */
++		/* This must precede recv_apply_hashed_log_recs(true). */
 +		ib_bh = trx_sys_init_at_db_start();
 +
 +		if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
 +			/* Apply the hashed log records to the
 +			respective file pages, for the last batch of
 +			recv_group_scan_log_recs(). */
 +
- 			err = recv_apply_hashed_log_recs(TRUE);
++			recv_apply_hashed_log_recs(true);
 +			DBUG_PRINT("ib_log", ("apply completed"));
- 
- 			if (err != DB_SUCCESS) {
- 				return(err);
- 			}
 +		}
 +
  		if (!srv_read_only_mode) {
 +			const ulint flags = FSP_FLAGS_PAGE_SSIZE();
 +			for (ulint id = 0; id <= srv_undo_tablespaces; id++) {
 +				if (fil_space_get(id)) {
 +					fsp_flags_try_adjust(id, flags);
 +				}
 +			}
 +
  			if (sum_of_new_sizes > 0) {
  				/* New data file(s) were added */
  				mtr_start(&mtr);
@@@ -2860,11 -2838,13 +2874,14 @@@
  		thread_started[3 + SRV_MAX_N_IO_THREADS] = true;
  
  		/* Create the thread which prints InnoDB monitor info */
- 		srv_monitor_active = true;
- 		thread_handles[4 + SRV_MAX_N_IO_THREADS] = os_thread_create(
- 			srv_monitor_thread,
- 			NULL, thread_ids + 4 + SRV_MAX_N_IO_THREADS);
- 		thread_started[4 + SRV_MAX_N_IO_THREADS] = true;
+ 		if (!thread_started[4 + SRV_MAX_N_IO_THREADS]) {
+ 			/* srv_monitor_thread not yet started */
++			srv_monitor_active = true;
+ 			thread_handles[4 + SRV_MAX_N_IO_THREADS] = os_thread_create(
+ 				srv_monitor_thread,
+ 				NULL, thread_ids + 4 + SRV_MAX_N_IO_THREADS);
+ 			thread_started[4 + SRV_MAX_N_IO_THREADS] = true;
+ 		}
  	}
  
  	/* Create the SYS_FOREIGN and SYS_FOREIGN_COLS system tables */
diff --cc support-files/rpm/server-postin.sh
index f6b7a9ba8b6,daf68f00c0c..08b046dc272
--- a/support-files/rpm/server-postin.sh
+++ b/support-files/rpm/server-postin.sh
@@@ -74,36 -60,9 +74,9 @@@ f
  SETARGETDIR=/etc/selinux/targeted/src/policy
  SEDOMPROG=$SETARGETDIR/domains/program
  SECONPROG=$SETARGETDIR/file_contexts/program
- if [ -f /etc/redhat-release ] ; then 
-    if grep '\(Red Hat Enterprise Linux ..\|CentOS\) release 4' \
-      /etc/redhat-release >/dev/null 2>&1; then
-      echo
-      echo
-      echo 'Notes regarding SELinux on this platform:'
-      echo '========================================='
-      echo
-      echo 'The default policy might cause server startup to fail because it is '
-      echo 'not allowed to access critical files. In this case, please update '
-      echo 'your installation. '
-      echo
-      echo 'The default policy might also cause inavailability of SSL related '
-      echo 'features because the server is not allowed to access /dev/random '
-      echo 'and /dev/urandom. If this is a problem, please do the following: '
-      echo 
-      echo '  1) install selinux-policy-targeted-sources from your OS vendor'
-      echo '  2) add the following two lines to '$SEDOMPROG/mysqld.te':'
-      echo '       allow mysqld_t random_device_t:chr_file read;'
-      echo '       allow mysqld_t urandom_device_t:chr_file read;'
-      echo '  3) cd to '$SETARGETDIR' and issue the following command:'
-      echo '       make load'
-      echo
-      echo
-    fi
-    if grep 'CentOS release 6' /etc/redhat-release >/dev/null 2>&1; then
-      if [ -x /usr/sbin/semodule ] ; then
-        /usr/sbin/semodule -i /usr/share/mysql/policy/selinux/mariadb.pp
-      fi
-    fi
+ 
+ if [ -x /usr/sbin/semodule ] ; then
 -  /usr/sbin/semodule -i /usr/share/mysql/SELinux/mariadb.pp
++  /usr/sbin/semodule -i /usr/share/mysql/policy/selinux/mariadb.pp
  fi
  
  if [ -x sbin/restorecon ] ; then


More information about the commits mailing list