summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt3
-rw-r--r--client/mysqldump.c5
-rw-r--r--config.h.cmake1
-rw-r--r--include/my_sys.h13
-rw-r--r--include/mysql/psi/mysql_file.h39
-rw-r--r--include/mysql/psi/psi.h2
-rw-r--r--mysql-test/r/derived.result23
-rw-r--r--mysql-test/r/grant.result70
-rw-r--r--mysql-test/r/join_nested.result95
-rw-r--r--mysql-test/r/join_nested_jcl6.result95
-rw-r--r--mysql-test/r/myisam-system.result2
-rw-r--r--mysql-test/r/mysqldump.result1
-rw-r--r--mysql-test/r/partition_innodb.result91
-rw-r--r--mysql-test/r/partition_myisam.result16
-rw-r--r--mysql-test/r/ps.result72
-rw-r--r--mysql-test/r/range_vs_index_merge.result46
-rw-r--r--mysql-test/r/range_vs_index_merge_innodb.result48
-rw-r--r--mysql-test/r/symlink-aria-11902.result39
-rw-r--r--mysql-test/r/symlink-myisam-11902.result38
-rw-r--r--mysql-test/r/table_elim.result5
-rw-r--r--mysql-test/r/view.result83
-rw-r--r--mysql-test/suite/federated/federated_bug_35333.result4
-rw-r--r--mysql-test/suite/federated/federated_bug_35333.test1
-rw-r--r--mysql-test/suite/parts/r/partition_bigint_innodb.result121
-rw-r--r--mysql-test/suite/parts/r/partition_bigint_myisam.result121
-rw-r--r--mysql-test/suite/parts/r/partition_double_innodb.result82
-rw-r--r--mysql-test/suite/parts/r/partition_double_myisam.result82
-rw-r--r--mysql-test/suite/parts/r/partition_float_innodb.result82
-rw-r--r--mysql-test/suite/parts/r/partition_float_myisam.result82
-rw-r--r--mysql-test/suite/parts/r/partition_int_innodb.result448
-rw-r--r--mysql-test/suite/parts/r/partition_int_myisam.result448
-rw-r--r--mysql-test/suite/parts/r/partition_mediumint_innodb.result109
-rw-r--r--mysql-test/suite/parts/r/partition_mediumint_myisam.result109
-rw-r--r--mysql-test/suite/parts/r/partition_smallint_innodb.result109
-rw-r--r--mysql-test/suite/parts/r/partition_smallint_myisam.result109
-rw-r--r--mysql-test/suite/parts/r/partition_tinyint_innodb.result109
-rw-r--r--mysql-test/suite/parts/r/partition_tinyint_myisam.result109
-rw-r--r--mysql-test/suite/parts/t/partition_bigint_innodb.test46
-rw-r--r--mysql-test/suite/parts/t/partition_bigint_myisam.test46
-rw-r--r--mysql-test/suite/parts/t/partition_double_innodb.test46
-rw-r--r--mysql-test/suite/parts/t/partition_double_myisam.test46
-rw-r--r--mysql-test/suite/parts/t/partition_float_innodb.test7
-rw-r--r--mysql-test/suite/parts/t/partition_float_myisam.test7
-rw-r--r--mysql-test/suite/parts/t/partition_int_innodb.test10
-rw-r--r--mysql-test/suite/parts/t/partition_int_myisam.test10
-rw-r--r--mysql-test/suite/parts/t/partition_mediumint_innodb.test46
-rw-r--r--mysql-test/suite/parts/t/partition_mediumint_myisam.test46
-rw-r--r--mysql-test/suite/parts/t/partition_smallint_innodb.test46
-rw-r--r--mysql-test/suite/parts/t/partition_smallint_myisam.test46
-rw-r--r--mysql-test/suite/parts/t/partition_tinyint_innodb.test46
-rw-r--r--mysql-test/suite/parts/t/partition_tinyint_myisam.test46
-rw-r--r--mysql-test/suite/rpl/r/rpl_heartbeat_basic.result3
-rw-r--r--mysql-test/suite/rpl/t/rpl_heartbeat_basic.test46
-rw-r--r--mysql-test/suite/sys_vars/t/secure_file_priv.test3
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_myisam.result109
-rw-r--r--mysql-test/suite/vcol/t/vcol_select_myisam.test32
-rw-r--r--mysql-test/t/derived.test23
-rw-r--r--mysql-test/t/grant.test85
-rw-r--r--mysql-test/t/join_nested.test71
-rw-r--r--mysql-test/t/mysqldump.test8
-rw-r--r--mysql-test/t/partition_innodb.test98
-rw-r--r--mysql-test/t/partition_myisam.test22
-rw-r--r--mysql-test/t/ps.test33
-rw-r--r--mysql-test/t/range_vs_index_merge.test41
-rw-r--r--mysql-test/t/repair_symlink-5543.test4
-rw-r--r--mysql-test/t/symlink-aria-11902.test6
-rw-r--r--mysql-test/t/symlink-myisam-11902.test60
-rw-r--r--mysql-test/t/table_elim.test4
-rw-r--r--mysql-test/t/view.test60
-rw-r--r--mysql-test/valgrind.supp11
-rw-r--r--mysys/mf_format.c7
-rw-r--r--mysys/my_create.c20
-rw-r--r--mysys/my_delete.c11
-rw-r--r--mysys/my_div.c2
-rw-r--r--mysys/my_fopen.c18
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_open.c41
-rw-r--r--mysys/my_symlink.c84
-rw-r--r--mysys/my_symlink2.c49
-rw-r--r--mysys/my_sync.c2
-rw-r--r--mysys/my_thr_init.c13
-rw-r--r--mysys/mysys_priv.h28
-rw-r--r--plugin/server_audit/server_audit.c34
-rw-r--r--sql-common/client.c11
-rw-r--r--sql/ha_partition.cc1
-rw-r--r--sql/handler.cc4
-rw-r--r--sql/item_subselect.cc2
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/opt_range.cc25
-rw-r--r--sql/partition_info.cc2
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_db.cc9
-rw-r--r--sql/sql_derived.cc3
-rw-r--r--sql/sql_join_cache.cc5
-rw-r--r--sql/sql_parse.cc66
-rw-r--r--sql/sql_parse.h3
-rw-r--r--sql/sql_select.cc77
-rw-r--r--sql/table.cc2
-rw-r--r--storage/innobase/btr/btr0cur.cc8
-rw-r--r--storage/innobase/dict/dict0dict.cc1
-rw-r--r--storage/innobase/dyn/dyn0dyn.cc1
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc6
-rw-r--r--storage/innobase/include/dict0dict.ic7
-rw-r--r--storage/innobase/include/dict0mem.h2
-rw-r--r--storage/innobase/include/dyn0dyn.ic8
-rw-r--r--storage/innobase/include/fsp0fsp.h2
-rw-r--r--storage/innobase/include/mach0data.ic13
-rw-r--r--storage/innobase/include/page0page.ic1
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc1
-rw-r--r--storage/innobase/page/page0page.cc2
-rw-r--r--storage/innobase/page/page0zip.cc2
-rw-r--r--storage/innobase/row/row0merge.cc6
-rw-r--r--storage/innobase/row/row0upd.cc4
-rw-r--r--storage/maria/ha_maria.cc4
-rw-r--r--storage/maria/ma_check.c6
-rw-r--r--storage/maria/ma_create.c57
-rw-r--r--storage/maria/ma_delete_table.c17
-rw-r--r--storage/maria/ma_open.c66
-rw-r--r--storage/maria/ma_static.c6
-rw-r--r--storage/maria/maria_chk.c2
-rw-r--r--storage/maria/maria_def.h3
-rw-r--r--storage/myisam/ha_myisam.cc15
-rw-r--r--storage/myisam/mi_check.c18
-rw-r--r--storage/myisam/mi_create.c53
-rw-r--r--storage/myisam/mi_delete_table.c36
-rw-r--r--storage/myisam/mi_open.c66
-rw-r--r--storage/myisam/mi_static.c8
-rw-r--r--storage/myisam/myisamchk.c2
-rw-r--r--storage/myisam/myisamdef.h3
-rw-r--r--storage/xtradb/btr/btr0btr.cc2
-rw-r--r--storage/xtradb/btr/btr0cur.cc8
-rw-r--r--storage/xtradb/buf/buf0buddy.cc1
-rw-r--r--storage/xtradb/buf/buf0buf.cc9
-rw-r--r--storage/xtradb/dict/dict0dict.cc1
-rw-r--r--storage/xtradb/dyn/dyn0dyn.cc1
-rw-r--r--storage/xtradb/fsp/fsp0fsp.cc6
-rw-r--r--storage/xtradb/include/btr0sea.ic4
-rw-r--r--storage/xtradb/include/dict0dict.ic7
-rw-r--r--storage/xtradb/include/dict0mem.h2
-rw-r--r--storage/xtradb/include/dyn0dyn.ic8
-rw-r--r--storage/xtradb/include/fsp0fsp.h2
-rw-r--r--storage/xtradb/include/mach0data.ic13
-rw-r--r--storage/xtradb/include/page0page.ic1
-rw-r--r--storage/xtradb/mtr/mtr0mtr.cc1
-rw-r--r--storage/xtradb/page/page0page.cc2
-rw-r--r--storage/xtradb/page/page0zip.cc2
-rw-r--r--storage/xtradb/row/row0merge.cc6
-rw-r--r--storage/xtradb/row/row0upd.cc4
-rw-r--r--support-files/SELinux/CMakeLists.txt4
-rw-r--r--support-files/SELinux/mariadb.te (renamed from support-files/SELinux/centos6-mariadb.te)0
-rwxr-xr-xsupport-files/build-tags17
-rw-r--r--support-files/rpm/server-postin.sh33
-rw-r--r--tests/mysql_client_test.c50
154 files changed, 3475 insertions, 1793 deletions
diff --git a/.gitignore b/.gitignore
index 191dbe23fad..f1c300a89c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -214,7 +214,7 @@ support-files/mysql.spec
support-files/mysqld_multi.server
support-files/wsrep.cnf
support-files/wsrep_notify
-support-files/SELinux/centos6-mariadb.pp
+support-files/SELinux/mariadb.pp
tags
tests/async_queries
tests/bug25714
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6ffedabd14..81ae6bc735e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -348,6 +348,9 @@ SET(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# Common defines and includes
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+IF(_FILE_OFFSET_BITS)
+ ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
+ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
# Add bundled or system zlib.
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 64ed21ac7fc..27aeea5a7b3 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -698,8 +698,9 @@ static void write_header(FILE *sql_file, char *db_name)
"-- MySQL dump %s Distrib %s, for %s (%s)\n--\n",
DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE,
MACHINE_TYPE);
- print_comment(sql_file, 0, "-- Host: %s Database: %s\n",
- fix_for_comment(current_host ? current_host : "localhost"),
+ print_comment(sql_file, 0, "-- Host: %s ",
+ fix_for_comment(current_host ? current_host : "localhost"));
+ print_comment(sql_file, 0, "Database: %s\n",
fix_for_comment(db_name ? db_name : ""));
print_comment(sql_file, 0,
"-- ------------------------------------------------------\n"
diff --git a/config.h.cmake b/config.h.cmake
index 1fd1341f1d1..8618d9e6d02 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -484,7 +484,6 @@
#cmakedefine _LARGE_FILES 1
#cmakedefine _LARGEFILE_SOURCE 1
#cmakedefine _LARGEFILE64_SOURCE 1
-#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
#cmakedefine TIME_WITH_SYS_TIME 1
diff --git a/include/my_sys.h b/include/my_sys.h
index 5e1f6baac77..4e129cc6dc1 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -64,9 +64,9 @@ 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_UNUSED 64 /* Unused (was support for RAID) */
-#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
+#define MY_IGNORE_BADFD 32 /* my_sync(): ignore 'bad descriptor' errors */
+#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 */
@@ -253,7 +253,7 @@ extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
extern ulong my_file_total_opened;
extern ulong my_sync_count;
extern uint mysys_usage_id;
-extern my_bool my_init_done;
+extern my_bool my_init_done, my_thr_key_mysys_exists;
extern my_bool my_assert_on_error;
extern myf my_global_flags; /* Set to MY_WME for more error messages */
/* Point to current my_message() */
@@ -567,6 +567,7 @@ my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
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 */
@@ -594,9 +595,11 @@ extern int my_realpath(char *to, const char *filename, myf MyFlags);
extern File my_create_with_symlink(const char *linkname, const char *filename,
int createflags, int access_flags,
myf MyFlags);
-extern int my_delete_with_symlink(const char *name, myf MyFlags);
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
+extern int my_handler_delete_with_symlink(PSI_file_key key, const char *name,
+ const char *ext, myf sync_dir);
+
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset,
myf MyFlags);
diff --git a/include/mysql/psi/mysql_file.h b/include/mysql/psi/mysql_file.h
index c839b2b019b..aca66bd4974 100644
--- a/include/mysql/psi/mysql_file.h
+++ b/include/mysql/psi/mysql_file.h
@@ -442,20 +442,6 @@
#endif
/**
- @def mysql_file_delete_with_symlink(K, P1, P2)
- Instrumented delete with symbolic link.
- @c mysql_file_delete_with_symlink is a replacement
- for @c my_delete_with_symlink.
-*/
-#ifdef HAVE_PSI_FILE_INTERFACE
- #define mysql_file_delete_with_symlink(K, P1, P2) \
- inline_mysql_file_delete_with_symlink(K, __FILE__, __LINE__, P1, P2)
-#else
- #define mysql_file_delete_with_symlink(K, P1, P2) \
- inline_mysql_file_delete_with_symlink(P1, P2)
-#endif
-
-/**
@def mysql_file_rename_with_symlink(K, P1, P2, P3)
Instrumented rename with symbolic link.
@c mysql_file_rename_with_symlink is a replacement
@@ -1337,31 +1323,6 @@ inline_mysql_file_create_with_symlink(
return file;
}
-static inline int
-inline_mysql_file_delete_with_symlink(
-#ifdef HAVE_PSI_FILE_INTERFACE
- PSI_file_key key, const char *src_file, uint src_line,
-#endif
- const char *name, myf flags)
-{
- int result;
-#ifdef HAVE_PSI_FILE_INTERFACE
- struct PSI_file_locker *locker;
- PSI_file_locker_state state;
- locker= PSI_FILE_CALL(get_thread_file_name_locker)
- (&state, key, PSI_FILE_DELETE, name, &locker);
- if (likely(locker != NULL))
- {
- PSI_FILE_CALL(start_file_close_wait)(locker, src_file, src_line);
- result= my_delete_with_symlink(name, flags);
- PSI_FILE_CALL(end_file_close_wait)(locker, result);
- return result;
- }
-#endif
-
- result= my_delete_with_symlink(name, flags);
- return result;
-}
static inline int
inline_mysql_file_rename_with_symlink(
diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h
index 7fcff89c8b6..3f43445e08a 100644
--- a/include/mysql/psi/psi.h
+++ b/include/mysql/psi/psi.h
@@ -417,7 +417,7 @@ enum PSI_file_operation
PSI_FILE_FSTAT= 12,
/** File chsize, as in @c my_chsize(). */
PSI_FILE_CHSIZE= 13,
- /** File delete, such as @c my_delete() or @c my_delete_with_symlink(). */
+ /** File delete, such as @c my_delete() or @c my_handler_delete_with_symlink(). */
PSI_FILE_DELETE= 14,
/** File rename, such as @c my_rename() or @c my_rename_with_symlink(). */
PSI_FILE_RENAME= 15,
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 0b392305bbf..ce94fe49f5c 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -1014,4 +1014,27 @@ David Yes 210
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
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 3194573e2ef..0b17e82e5a9 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -2527,6 +2527,54 @@ DROP USER mysqltest_u1@localhost;
# End of Bug#38347.
#
+# 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;
+#
+# Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY -
+# REQUIRES FLUSH PRIVILEGES
+#
+CREATE USER foo@'127.0.0.1';
+GRANT ALL ON *.* TO foo@'127.0.0.1';
+# First attempt, should connect successfully
+SELECT user(), current_user();
+user() current_user()
+foo@localhost foo@127.0.0.1
+# Rename the user
+RENAME USER foo@'127.0.0.1' to foo@'127.0.0.0/255.0.0.0';
+# Second attempt, should connect successfully as its valid mask
+# This was failing without fix
+SELECT user(), current_user();
+user() current_user()
+foo@localhost foo@127.0.0.0/255.0.0.0
+# Rename the user back to original
+RENAME USER foo@'127.0.0.0/255.0.0.0' to foo@'127.0.0.1';
+# Third attempt, should connect successfully
+SELECT user(), current_user();
+user() current_user()
+foo@localhost foo@127.0.0.1
+# Clean-up
+DROP USER foo@'127.0.0.1';
+# End of Bug#12766319
+#
# Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS
# DATABASE SECURITY
#
@@ -2552,25 +2600,3 @@ ERROR 42000: Access denied for user 'untrusted'@'localhost' to database 'secret'
# Connection default
DROP USER untrusted@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;
diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result
index 84b6ff640e9..6ddd39cbfec 100644
--- a/mysql-test/r/join_nested.result
+++ b/mysql-test/r/join_nested.result
@@ -1870,4 +1870,99 @@ f4
NULL
NULL
DROP TABLE t1,t2,t3,t4,t5;
+#
+# MDEV-7992: Nested left joins + 'not exists' optimization
+#
+CREATE TABLE t1(
+K1 INT PRIMARY KEY,
+Name VARCHAR(15)
+);
+INSERT INTO t1 VALUES
+(1,'T1Row1'), (2,'T1Row2');
+CREATE TABLE t2(
+K2 INT PRIMARY KEY,
+K1r INT,
+rowTimestamp DATETIME,
+Event VARCHAR(15)
+);
+INSERT INTO t2 VALUES
+(1, 1, '2015-04-13 10:42:11' ,'T1Row1Event1'),
+(2, 1, '2015-04-13 10:42:12' ,'T1Row1Event2'),
+(3, 1, '2015-04-13 10:42:12' ,'T1Row1Event3');
+SELECT t1a.*, t2a.*,
+t2i.K2 AS K2B, t2i.K1r AS K1rB,
+t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB
+FROM
+t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1)
+ON (t1i.K1 = 1) AND
+(((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR
+(t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2))
+OR (t2i.K2 IS NULL))
+WHERE
+t2a.K1r = 1 AND t2i.K2 IS NULL;
+K1 Name K2 K1r rowTimestamp Event K2B K1rB rowTimestampB EventB
+1 T1Row1 3 1 2015-04-13 10:42:12 T1Row1Event3 NULL NULL NULL NULL
+EXPLAIN EXTENDED SELECT t1a.*, t2a.*,
+t2i.K2 AS K2B, t2i.K1r AS K1rB,
+t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB
+FROM
+t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1)
+ON (t1i.K1 = 1) AND
+(((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR
+(t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2))
+OR (t2i.K2 IS NULL))
+WHERE
+t2a.K1r = 1 AND t2i.K2 IS NULL;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1a const PRIMARY PRIMARY 4 const 1 100.00
+1 SIMPLE t2a ALL NULL NULL NULL NULL 3 100.00 Using where
+1 SIMPLE t1i const PRIMARY PRIMARY 4 const 1 100.00 Using index
+1 SIMPLE t2i ALL NULL NULL NULL NULL 3 100.00 Using where; Not exists
+Warnings:
+Note 1003 select 1 AS `K1`,'T1Row1' AS `Name`,`test`.`t2a`.`K2` AS `K2`,`test`.`t2a`.`K1r` AS `K1r`,`test`.`t2a`.`rowTimestamp` AS `rowTimestamp`,`test`.`t2a`.`Event` AS `Event`,`test`.`t2i`.`K2` AS `K2B`,`test`.`t2i`.`K1r` AS `K1rB`,`test`.`t2i`.`rowTimestamp` AS `rowTimestampB`,`test`.`t2i`.`Event` AS `EventB` from `test`.`t1` `t1a` join `test`.`t2` `t2a` left join (`test`.`t1` `t1i` left join `test`.`t2` `t2i` on((`test`.`t2i`.`K1r` = 1))) on(((`test`.`t1i`.`K1` = 1) and (((`test`.`t2i`.`K1r` = 1) and (`test`.`t2i`.`rowTimestamp` > `test`.`t2a`.`rowTimestamp`)) or ((`test`.`t2i`.`rowTimestamp` = `test`.`t2a`.`rowTimestamp`) and (`test`.`t2i`.`K2` > `test`.`t2a`.`K2`)) or isnull(`test`.`t2i`.`K2`)))) where ((`test`.`t2a`.`K1r` = 1) and isnull(`test`.`t2i`.`K2`))
+CREATE VIEW v1 AS
+SELECT t2i.*
+FROM t1 as t1i LEFT JOIN t2 as t2i ON t2i.K1r = t1i.K1
+WHERE t1i.K1 = 1 ;
+SELECT
+t1a.*, t2a.*, t2b.K2 as K2B, t2b.K1r as K1rB,
+t2b.rowTimestamp as rowTimestampB, t2b.Event as EventB
+FROM
+t1 as t1a JOIN t2 as t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+v1 as t2b
+ON ((t2b.K1r = t1a.K1 AND t2b.rowTimestamp > t2a.rowTimestamp) OR
+(t2b.rowTimestamp = t2a.rowTimestamp AND t2b.K2 > t2a.K2))
+OR (t2b.K2 IS NULL)
+WHERE
+t1a.K1 = 1 AND
+t2b.K2 IS NULL;
+K1 Name K2 K1r rowTimestamp Event K2B K1rB rowTimestampB EventB
+1 T1Row1 3 1 2015-04-13 10:42:12 T1Row1Event3 NULL NULL NULL NULL
+EXPLAIN EXTENDED SELECT
+t1a.*, t2a.*, t2b.K2 as K2B, t2b.K1r as K1rB,
+t2b.rowTimestamp as rowTimestampB, t2b.Event as EventB
+FROM
+t1 as t1a JOIN t2 as t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+v1 as t2b
+ON ((t2b.K1r = t1a.K1 AND t2b.rowTimestamp > t2a.rowTimestamp) OR
+(t2b.rowTimestamp = t2a.rowTimestamp AND t2b.K2 > t2a.K2))
+OR (t2b.K2 IS NULL)
+WHERE
+t1a.K1 = 1 AND
+t2b.K2 IS NULL;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1a const PRIMARY PRIMARY 4 const 1 100.00
+1 SIMPLE t2a ALL NULL NULL NULL NULL 3 100.00 Using where
+1 SIMPLE t1i const PRIMARY PRIMARY 4 const 1 100.00 Using index
+1 SIMPLE t2i ALL NULL NULL NULL NULL 3 100.00 Using where; Not exists
+Warnings:
+Note 1003 select 1 AS `K1`,'T1Row1' AS `Name`,`t2a`.`K2` AS `K2`,`t2a`.`K1r` AS `K1r`,`t2a`.`rowTimestamp` AS `rowTimestamp`,`t2a`.`Event` AS `Event`,`test`.`t2i`.`K2` AS `K2B`,`test`.`t2i`.`K1r` AS `K1rB`,`test`.`t2i`.`rowTimestamp` AS `rowTimestampB`,`test`.`t2i`.`Event` AS `EventB` from `test`.`t1` `t1a` join `test`.`t2` `t2a` left join (`test`.`t1` `t1i` left join `test`.`t2` `t2i` on((`test`.`t2i`.`K1r` = 1))) on(((`test`.`t1i`.`K1` = 1) and (((`test`.`t2i`.`K1r` = 1) and (`test`.`t2i`.`rowTimestamp` > `t2a`.`rowTimestamp`)) or ((`test`.`t2i`.`rowTimestamp` = `t2a`.`rowTimestamp`) and (`test`.`t2i`.`K2` > `t2a`.`K2`)) or isnull(`test`.`t2i`.`K2`)))) where ((`t2a`.`K1r` = 1) and isnull(`test`.`t2i`.`K2`))
+DROP VIEW v1;
+DROP TABLE t1,t2;
set optimizer_search_depth= @tmp_mdev621;
diff --git a/mysql-test/r/join_nested_jcl6.result b/mysql-test/r/join_nested_jcl6.result
index 3b47645ca79..bac8e1cb7db 100644
--- a/mysql-test/r/join_nested_jcl6.result
+++ b/mysql-test/r/join_nested_jcl6.result
@@ -1881,6 +1881,101 @@ f4
NULL
NULL
DROP TABLE t1,t2,t3,t4,t5;
+#
+# MDEV-7992: Nested left joins + 'not exists' optimization
+#
+CREATE TABLE t1(
+K1 INT PRIMARY KEY,
+Name VARCHAR(15)
+);
+INSERT INTO t1 VALUES
+(1,'T1Row1'), (2,'T1Row2');
+CREATE TABLE t2(
+K2 INT PRIMARY KEY,
+K1r INT,
+rowTimestamp DATETIME,
+Event VARCHAR(15)
+);
+INSERT INTO t2 VALUES
+(1, 1, '2015-04-13 10:42:11' ,'T1Row1Event1'),
+(2, 1, '2015-04-13 10:42:12' ,'T1Row1Event2'),
+(3, 1, '2015-04-13 10:42:12' ,'T1Row1Event3');
+SELECT t1a.*, t2a.*,
+t2i.K2 AS K2B, t2i.K1r AS K1rB,
+t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB
+FROM
+t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1)
+ON (t1i.K1 = 1) AND
+(((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR
+(t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2))
+OR (t2i.K2 IS NULL))
+WHERE
+t2a.K1r = 1 AND t2i.K2 IS NULL;
+K1 Name K2 K1r rowTimestamp Event K2B K1rB rowTimestampB EventB
+1 T1Row1 3 1 2015-04-13 10:42:12 T1Row1Event3 NULL NULL NULL NULL
+EXPLAIN EXTENDED SELECT t1a.*, t2a.*,
+t2i.K2 AS K2B, t2i.K1r AS K1rB,
+t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB
+FROM
+t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1)
+ON (t1i.K1 = 1) AND
+(((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR
+(t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2))
+OR (t2i.K2 IS NULL))
+WHERE
+t2a.K1r = 1 AND t2i.K2 IS NULL;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1a const PRIMARY PRIMARY 4 const 1 100.00
+1 SIMPLE t2a ALL NULL NULL NULL NULL 3 100.00 Using where
+1 SIMPLE t1i const PRIMARY PRIMARY 4 const 1 100.00 Using index
+1 SIMPLE t2i ALL NULL NULL NULL NULL 3 100.00 Using where; Not exists
+Warnings:
+Note 1003 select 1 AS `K1`,'T1Row1' AS `Name`,`test`.`t2a`.`K2` AS `K2`,`test`.`t2a`.`K1r` AS `K1r`,`test`.`t2a`.`rowTimestamp` AS `rowTimestamp`,`test`.`t2a`.`Event` AS `Event`,`test`.`t2i`.`K2` AS `K2B`,`test`.`t2i`.`K1r` AS `K1rB`,`test`.`t2i`.`rowTimestamp` AS `rowTimestampB`,`test`.`t2i`.`Event` AS `EventB` from `test`.`t1` `t1a` join `test`.`t2` `t2a` left join (`test`.`t1` `t1i` left join `test`.`t2` `t2i` on((`test`.`t2i`.`K1r` = 1))) on(((`test`.`t1i`.`K1` = 1) and (((`test`.`t2i`.`K1r` = 1) and (`test`.`t2i`.`rowTimestamp` > `test`.`t2a`.`rowTimestamp`)) or ((`test`.`t2i`.`rowTimestamp` = `test`.`t2a`.`rowTimestamp`) and (`test`.`t2i`.`K2` > `test`.`t2a`.`K2`)) or isnull(`test`.`t2i`.`K2`)))) where ((`test`.`t2a`.`K1r` = 1) and isnull(`test`.`t2i`.`K2`))
+CREATE VIEW v1 AS
+SELECT t2i.*
+FROM t1 as t1i LEFT JOIN t2 as t2i ON t2i.K1r = t1i.K1
+WHERE t1i.K1 = 1 ;
+SELECT
+t1a.*, t2a.*, t2b.K2 as K2B, t2b.K1r as K1rB,
+t2b.rowTimestamp as rowTimestampB, t2b.Event as EventB
+FROM
+t1 as t1a JOIN t2 as t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+v1 as t2b
+ON ((t2b.K1r = t1a.K1 AND t2b.rowTimestamp > t2a.rowTimestamp) OR
+(t2b.rowTimestamp = t2a.rowTimestamp AND t2b.K2 > t2a.K2))
+OR (t2b.K2 IS NULL)
+WHERE
+t1a.K1 = 1 AND
+t2b.K2 IS NULL;
+K1 Name K2 K1r rowTimestamp Event K2B K1rB rowTimestampB EventB
+1 T1Row1 3 1 2015-04-13 10:42:12 T1Row1Event3 NULL NULL NULL NULL
+EXPLAIN EXTENDED SELECT
+t1a.*, t2a.*, t2b.K2 as K2B, t2b.K1r as K1rB,
+t2b.rowTimestamp as rowTimestampB, t2b.Event as EventB
+FROM
+t1 as t1a JOIN t2 as t2a ON t2a.K1r = t1a.K1
+LEFT JOIN
+v1 as t2b
+ON ((t2b.K1r = t1a.K1 AND t2b.rowTimestamp > t2a.rowTimestamp) OR
+(t2b.rowTimestamp = t2a.rowTimestamp AND t2b.K2 > t2a.K2))
+OR (t2b.K2 IS NULL)
+WHERE
+t1a.K1 = 1 AND
+t2b.K2 IS NULL;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1a const PRIMARY PRIMARY 4 const 1 100.00
+1 SIMPLE t2a ALL NULL NULL NULL NULL 3 100.00 Using where
+1 SIMPLE t1i const PRIMARY PRIMARY 4 const 1 100.00 Using index
+1 SIMPLE t2i ALL NULL NULL NULL NULL 3 100.00 Using where; Not exists
+Warnings:
+Note 1003 select 1 AS `K1`,'T1Row1' AS `Name`,`t2a`.`K2` AS `K2`,`t2a`.`K1r` AS `K1r`,`t2a`.`rowTimestamp` AS `rowTimestamp`,`t2a`.`Event` AS `Event`,`test`.`t2i`.`K2` AS `K2B`,`test`.`t2i`.`K1r` AS `K1rB`,`test`.`t2i`.`rowTimestamp` AS `rowTimestampB`,`test`.`t2i`.`Event` AS `EventB` from `test`.`t1` `t1a` join `test`.`t2` `t2a` left join (`test`.`t1` `t1i` left join `test`.`t2` `t2i` on((`test`.`t2i`.`K1r` = 1))) on(((`test`.`t1i`.`K1` = 1) and (((`test`.`t2i`.`K1r` = 1) and (`test`.`t2i`.`rowTimestamp` > `t2a`.`rowTimestamp`)) or ((`test`.`t2i`.`rowTimestamp` = `t2a`.`rowTimestamp`) and (`test`.`t2i`.`K2` > `t2a`.`K2`)) or isnull(`test`.`t2i`.`K2`)))) where ((`t2a`.`K1r` = 1) and isnull(`test`.`t2i`.`K2`))
+DROP VIEW v1;
+DROP TABLE t1,t2;
set optimizer_search_depth= @tmp_mdev621;
CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b));
CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b));
diff --git a/mysql-test/r/myisam-system.result b/mysql-test/r/myisam-system.result
index af5de8f2749..65684a3c07b 100644
--- a/mysql-test/r/myisam-system.result
+++ b/mysql-test/r/myisam-system.result
@@ -5,7 +5,7 @@ Warnings:
Warning 2 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
create table t1 (a int) engine=myisam;
select * from t1;
-ERROR HY000: Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
+ERROR HY000: Can't find file: './test/t1.MYI' (errno: 20 "Not a directory")
drop table t1;
Warnings:
Warning 2 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index cb3c28f42cd..6bf8759de98 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -5340,3 +5340,4 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
ALTER DATABASE `a\"'``b` CHARACTER SET utf8 COLLATE utf8_general_ci ;
DROP DATABASE `a\"'``b`;
+FOUND /Database: mysql/ in bug11505.sql
diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result
index e1bc075f14a..f863ec5522a 100644
--- a/mysql-test/r/partition_innodb.result
+++ b/mysql-test/r/partition_innodb.result
@@ -732,6 +732,97 @@ SELECT * FROM t1 WHERE d = '1991-01-01';
d
1991-01-01
DROP TABLE t1;
+set global default_storage_engine=default;
+#
+# MDEV-9455: [ERROR] mysqld got signal 11
+#
+CREATE TABLE `t1` (
+`DIARY_TOTAL_DAY_SEQ` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+`IMORY_ID` bigint(20) NOT NULL,
+`NAME` varchar(75) DEFAULT NULL,
+`DATETIME` varchar(10) NOT NULL DEFAULT '',
+`DAILY_CALL_CNT` int(11) DEFAULT NULL,
+`DAILY_SMS_CNT` int(11) DEFAULT NULL,
+`NUMBER` varchar(64) DEFAULT NULL,
+`DURATION` varchar(16) DEFAULT NULL,
+PRIMARY KEY (`DIARY_TOTAL_DAY_SEQ`,`DATETIME`),
+KEY `IDX_t1_01` (`IMORY_ID`,`DATETIME`)
+) AUTO_INCREMENT=328702514 DEFAULT CHARSET=utf8mb4
+PARTITION BY RANGE COLUMNS(`DATETIME`)
+(PARTITION p0 VALUES LESS THAN ('2015-10-01') ENGINE = InnoDB,
+PARTITION p1 VALUES LESS THAN ('2015-11-01') ENGINE = InnoDB,
+PARTITION p2 VALUES LESS THAN ('2015-12-01') ENGINE = InnoDB,
+PARTITION p3 VALUES LESS THAN ('2016-01-01') ENGINE = InnoDB,
+PARTITION p4 VALUES LESS THAN ('2016-02-01') ENGINE = InnoDB,
+PARTITION p5 VALUES LESS THAN ('2016-03-01') ENGINE = InnoDB,
+PARTITION p6 VALUES LESS THAN ('2016-04-01') ENGINE = InnoDB,
+PARTITION p7 VALUES LESS THAN ('2016-05-01') ENGINE = InnoDB,
+PARTITION p8 VALUES LESS THAN ('2016-06-01') ENGINE = InnoDB,
+PARTITION p9 VALUES LESS THAN ('2016-07-01') ENGINE = InnoDB,
+PARTITION p10 VALUES LESS THAN ('2016-08-01') ENGINE = InnoDB)
+;
+CREATE TABLE `t2` (
+`DIARY_SEQ` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+`IMORY_ID` bigint(20) NOT NULL,
+`CALL_TYPE` varchar(1) DEFAULT NULL,
+`DATA_TYPE` varchar(1) DEFAULT NULL,
+`FEATURES` varchar(1) DEFAULT NULL,
+`NAME` varchar(75) DEFAULT NULL,
+`NUMBER` varchar(64) DEFAULT NULL,
+`DATETIME` datetime NOT NULL,
+`REG_DATE` datetime NOT NULL,
+`TITLE` varchar(50) DEFAULT NULL,
+`BODY` varchar(4200) DEFAULT NULL,
+`MIME_TYPE` varchar(32) DEFAULT NULL,
+`DURATION` varchar(16) DEFAULT NULL,
+`DEVICE_ID` varchar(64) DEFAULT NULL,
+`DEVICE_NAME` varchar(32) DEFAULT NULL,
+PRIMARY KEY (`DIARY_SEQ`,`DATETIME`,`REG_DATE`),
+KEY `IDX_TB_DIARY_01` (`IMORY_ID`,`DATETIME`,`CALL_TYPE`,`NUMBER`),
+KEY `IDX_TB_DIARY_02` (`REG_DATE`)
+) AUTO_INCREMENT=688799006 DEFAULT CHARSET=utf8mb4
+PARTITION BY RANGE COLUMNS(REG_DATE)
+(PARTITION p0 VALUES LESS THAN ('2015-10-01') ENGINE = InnoDB,
+PARTITION p1 VALUES LESS THAN ('2015-11-01') ENGINE = InnoDB,
+PARTITION p2 VALUES LESS THAN ('2015-12-01') ENGINE = InnoDB,
+PARTITION p3 VALUES LESS THAN ('2016-01-01') ENGINE = InnoDB,
+PARTITION p4 VALUES LESS THAN ('2016-02-01') ENGINE = InnoDB,
+PARTITION p5 VALUES LESS THAN ('2016-03-01') ENGINE = InnoDB,
+PARTITION p6 VALUES LESS THAN ('2016-04-01') ENGINE = InnoDB,
+PARTITION p7 VALUES LESS THAN ('2016-05-01') ENGINE = InnoDB,
+PARTITION p8 VALUES LESS THAN ('2016-06-01') ENGINE = InnoDB,
+PARTITION p9 VALUES LESS THAN ('2016-07-01') ENGINE = InnoDB,
+PARTITION p10 VALUES LESS THAN ('2016-08-01') ENGINE = InnoDB)
+;
+SELECT
+A.IMORY_ID,
+A.NUMBER,
+A.NAME,
+DATE_FORMAT(A.DATETIME, '%Y-%m-%d') AS TARGET_DATE,
+SUM( CASE WHEN A.DATA_TYPE='1' THEN 1 ELSE 0 END) AS CALL_CNT,
+SUM( CASE WHEN A.DATA_TYPE IN ('2', '3') THEN 1 ELSE 0 END) AS SMS_CNT,
+SUM(CAST(A.DURATION AS INT)) AS DURATION,
+( SELECT COUNT(*)
+FROM t1
+WHERE IMORY_ID=A.IMORY_ID
+AND NUMBER=A.NUMBER
+AND NAME=A.NAME
+AND DATETIME = DATE_FORMAT(A.DATETIME, '%Y-%m-%d')
+) STATS_COUNT
+FROM t2 A
+WHERE A.IMORY_ID = 55094102
+AND A.DATETIME LIKE (
+SELECT CONCAT (DATE_FORMAT(DATETIME, '%Y-%m-%d') ,'%')
+FROM t2
+WHERE IMORY_ID=55094102
+AND DIARY_SEQ IN ( 608351221, 608351225, 608351229 )
+group by DATE_FORMAT(DATETIME, '%Y-%m-%d')
+)
+GROUP BY A.IMORY_ID, A.NUMBER, A.NAME, DATE_FORMAT(A.DATETIME, '%Y-%m-%d')
+;
+IMORY_ID NUMBER NAME TARGET_DATE CALL_CNT SMS_CNT DURATION STATS_COUNT
+drop table t2, t1;
+set global default_storage_engine='innodb';
#
# MDEV-5963: InnoDB: Assertion failure in file row0sel.cc line 2503,
# Failing assertion: 0 with "key ptr now exceeds key end by 762 bytes"
diff --git a/mysql-test/r/partition_myisam.result b/mysql-test/r/partition_myisam.result
index bb1a7b19a9d..08a5bf72f64 100644
--- a/mysql-test/r/partition_myisam.result
+++ b/mysql-test/r/partition_myisam.result
@@ -230,6 +230,22 @@ PARTITION pMax VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (1, "Partition p1, first row");
DROP TABLE t1;
#
+# MDEV-10418 Assertion `m_extra_cache' failed
+# in ha_partition::late_extra_cache(uint)
+#
+CREATE TABLE t1 (f1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (f2 INT) ENGINE=MyISAM PARTITION BY RANGE(f2) (PARTITION pmax VALUES LESS THAN MAXVALUE);
+INSERT INTO t2 VALUES (8);
+CREATE ALGORITHM = MERGE VIEW v AS SELECT f2 FROM t2, t1;
+UPDATE v SET f2 = 1;
+SELECT * FROM t2;
+f2
+1
+DROP VIEW v;
+DROP TABLE t2;
+DROP TABLE t1;
+#
# bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED
# TABLE CORRUPTS MYISAM
DROP TABLE if exists `t1`;
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index eb5c8ca9377..c8fa17a4e9e 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -4107,4 +4107,76 @@ NULL
NULL
deallocate prepare stmt;
drop table t1,t2,t3,t4;
+#
+# MDEV-11859: the plans for the first and the second executions
+# of PS are not the same
+#
+create table t1 (id int, c varchar(3), key idx(c))engine=myisam;
+insert into t1 values (3,'bar'), (1,'xxx'), (2,'foo'), (5,'yyy');
+prepare stmt1 from
+"explain extended
+ select * from t1 where (1, 2) in ( select 3, 4 ) or c = 'foo'";
+execute stmt1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ref idx idx 6 const 1 100.00 Using index condition
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` = 'foo')
+execute stmt1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ref idx idx 6 const 1 100.00 Using index condition
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`c` = 'foo')
+deallocate prepare stmt1;
+prepare stmt1 from
+"select * from t1 where (1, 2) in ( select 3, 4 ) or c = 'foo'";
+flush status;
+execute stmt1;
+id c
+2 foo
+show status like '%Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 1
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+flush status;
+execute stmt1;
+id c
+2 foo
+show status like '%Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 1
+Handler_read_last 0
+Handler_read_next 1
+Handler_read_prev 0
+Handler_read_retry 0
+Handler_read_rnd 0
+Handler_read_rnd_deleted 0
+Handler_read_rnd_next 0
+deallocate prepare stmt1;
+prepare stmt2 from
+"explain extended
+ select * from t1 where (1, 2) in ( select 3, 4 )";
+execute stmt2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`c` AS `c` from `test`.`t1` where 0
+execute stmt2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`c` AS `c` from `test`.`t1` where 0
+deallocate prepare stmt2;
+drop table t1;
# End of 5.5 tests
diff --git a/mysql-test/r/range_vs_index_merge.result b/mysql-test/r/range_vs_index_merge.result
index 9af359a55f3..6813c40a5cf 100644
--- a/mysql-test/r/range_vs_index_merge.result
+++ b/mysql-test/r/range_vs_index_merge.result
@@ -60,11 +60,11 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City
WHERE Population > 100000 AND Name LIKE 'Aba%' OR
-Country IN ('CAN', 'ARG') AND ID < 3800 OR
-Country < 'U' AND Name LIKE 'Zhu%' OR
-ID BETWEEN 3800 AND 3810;
+Country IN ('CAN', 'ARG') AND ID BETWEEN 120 AND 130 OR
+Country <= 'ALB' AND Name LIKE 'L%' OR
+ID BETWEEN 3807 AND 3810;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,PRIMARY 35,3,4 NULL 132 Using sort_union(Name,Country,PRIMARY); Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,PRIMARY,Country 35,4,3 NULL 31 Using sort_union(Name,PRIMARY,Country); Using where
EXPLAIN
SELECT * FROM City
WHERE (Population > 101000 AND Population < 115000);
@@ -1769,4 +1769,42 @@ a b
167 9999
168 10000
DROP TABLE t1;
+#
+# MDEV-8603: Wrong result OR/AND condition over index fields
+#
+CREATE TABLE t1 (
+id INT NOT NULL,
+state VARCHAR(64),
+capital VARCHAR(64),
+UNIQUE KEY (id),
+KEY state (state,id),
+KEY capital (capital, id)
+);
+INSERT INTO t1 VALUES
+(1,'Arizona','Phoenix'),
+(2,'Hawaii','Honolulu'),
+(3,'Georgia','Atlanta'),
+(4,'Florida','Tallahassee'),
+(5,'Alaska','Juneau'),
+(6,'Michigan','Lansing'),
+(7,'Pennsylvania','Harrisburg'),
+(8,'Virginia','Richmond')
+;
+EXPLAIN
+SELECT * FROM t1 FORCE KEY (state,capital)
+WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
+OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range state,capital state 71 NULL 12 Using index condition; Using where
+SELECT * FROM t1 FORCE KEY (state,capital)
+WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
+OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
+id state capital
+4 Florida Tallahassee
+3 Georgia Atlanta
+2 Hawaii Honolulu
+6 Michigan Lansing
+7 Pennsylvania Harrisburg
+8 Virginia Richmond
+DROP TABLE t1;
set session optimizer_switch='index_merge_sort_intersection=default';
diff --git a/mysql-test/r/range_vs_index_merge_innodb.result b/mysql-test/r/range_vs_index_merge_innodb.result
index 601ae9b7613..13fbc0ac3ef 100644
--- a/mysql-test/r/range_vs_index_merge_innodb.result
+++ b/mysql-test/r/range_vs_index_merge_innodb.result
@@ -61,11 +61,11 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City
WHERE Population > 100000 AND Name LIKE 'Aba%' OR
-Country IN ('CAN', 'ARG') AND ID < 3800 OR
-Country < 'U' AND Name LIKE 'Zhu%' OR
-ID BETWEEN 3800 AND 3810;
+Country IN ('CAN', 'ARG') AND ID BETWEEN 120 AND 130 OR
+Country <= 'ALB' AND Name LIKE 'L%' OR
+ID BETWEEN 3807 AND 3810;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,PRIMARY 35,7,4 NULL 123 Using sort_union(Name,Country,PRIMARY); Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Country,PRIMARY 35,3,4 NULL 33 Using sort_union(Name,Country,PRIMARY); Using where
EXPLAIN
SELECT * FROM City
WHERE (Population > 101000 AND Population < 115000);
@@ -369,7 +369,7 @@ WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
OR ((ID BETWEEN 100 AND 200) AND
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE City range PRIMARY,Population,Country,Name PRIMARY 4 NULL 200 Using where
+1 SIMPLE City index_merge PRIMARY,Population,Country,Name Name,Population,PRIMARY 39,4,4 NULL 305 Using sort_union(Name,Population,PRIMARY); Using where
SELECT * FROM City USE INDEX ()
WHERE ((ID < 10) AND (Name LIKE 'H%' OR (Country > 'A' AND Country < 'ARG')))
OR ((ID BETWEEN 100 AND 110) AND
@@ -1770,5 +1770,43 @@ a b
167 9999
168 10000
DROP TABLE t1;
+#
+# MDEV-8603: Wrong result OR/AND condition over index fields
+#
+CREATE TABLE t1 (
+id INT NOT NULL,
+state VARCHAR(64),
+capital VARCHAR(64),
+UNIQUE KEY (id),
+KEY state (state,id),
+KEY capital (capital, id)
+);
+INSERT INTO t1 VALUES
+(1,'Arizona','Phoenix'),
+(2,'Hawaii','Honolulu'),
+(3,'Georgia','Atlanta'),
+(4,'Florida','Tallahassee'),
+(5,'Alaska','Juneau'),
+(6,'Michigan','Lansing'),
+(7,'Pennsylvania','Harrisburg'),
+(8,'Virginia','Richmond')
+;
+EXPLAIN
+SELECT * FROM t1 FORCE KEY (state,capital)
+WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
+OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range state,capital state 71 NULL 10 Using index condition; Using where
+SELECT * FROM t1 FORCE KEY (state,capital)
+WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
+OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
+id state capital
+4 Florida Tallahassee
+3 Georgia Atlanta
+2 Hawaii Honolulu
+6 Michigan Lansing
+7 Pennsylvania Harrisburg
+8 Virginia Richmond
+DROP TABLE t1;
set session optimizer_switch='index_merge_sort_intersection=default';
SET SESSION STORAGE_ENGINE=DEFAULT;
diff --git a/mysql-test/r/symlink-aria-11902.result b/mysql-test/r/symlink-aria-11902.result
new file mode 100644
index 00000000000..66405b1c25f
--- /dev/null
+++ b/mysql-test/r/symlink-aria-11902.result
@@ -0,0 +1,39 @@
+set default_storage_engine=Aria;
+call mtr.add_suppression("File.*t1.* not found");
+create table mysql.t1 (a int, b char(16), index(a));
+insert mysql.t1 values (100, 'test'),(101,'test');
+create table t1 (a int, b char(16), index(a))
+data directory="MYSQLTEST_VARDIR/tmp/foo";
+insert t1 values (200, 'some'),(201,'some');
+select * from t1;
+a b
+200 some
+201 some
+flush tables;
+set debug_sync='mi_open_datafile SIGNAL ok WAIT_FOR go';
+select * from t1;
+set debug_sync='now WAIT_FOR ok';
+set debug_sync='now SIGNAL go';
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/foo/t1.MAD' not found (Errcode: 20 "Not a directory")
+flush tables;
+drop table if exists t1;
+create table t1 (a int, b char(16), index (a))
+index directory="MYSQLTEST_VARDIR/tmp/foo";
+insert t1 values (200, 'some'),(201,'some');
+explain select a from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL 2 Using index
+select a from t1;
+a
+200
+201
+flush tables;
+set debug_sync='mi_open_kfile SIGNAL waiting WAIT_FOR run';
+select a from t1;
+set debug_sync='now WAIT_FOR waiting';
+set debug_sync='now SIGNAL run';
+ERROR HY000: Can't find file: './test/t1.MAI' (errno: 20 "Not a directory")
+flush tables;
+drop table if exists t1;
+drop table mysql.t1;
+set debug_sync='RESET';
diff --git a/mysql-test/r/symlink-myisam-11902.result b/mysql-test/r/symlink-myisam-11902.result
new file mode 100644
index 00000000000..4b07aa3f4a7
--- /dev/null
+++ b/mysql-test/r/symlink-myisam-11902.result
@@ -0,0 +1,38 @@
+call mtr.add_suppression("File.*t1.* not found");
+create table mysql.t1 (a int, b char(16), index(a));
+insert mysql.t1 values (100, 'test'),(101,'test');
+create table t1 (a int, b char(16), index(a))
+data directory="MYSQLTEST_VARDIR/tmp/foo";
+insert t1 values (200, 'some'),(201,'some');
+select * from t1;
+a b
+200 some
+201 some
+flush tables;
+set debug_sync='mi_open_datafile SIGNAL ok WAIT_FOR go';
+select * from t1;
+set debug_sync='now WAIT_FOR ok';
+set debug_sync='now SIGNAL go';
+ERROR HY000: File 'MYSQLTEST_VARDIR/tmp/foo/t1.MYD' not found (Errcode: 20 "Not a directory")
+flush tables;
+drop table if exists t1;
+create table t1 (a int, b char(16), index (a))
+index directory="MYSQLTEST_VARDIR/tmp/foo";
+insert t1 values (200, 'some'),(201,'some');
+explain select a from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL 2 Using index
+select a from t1;
+a
+200
+201
+flush tables;
+set debug_sync='mi_open_kfile SIGNAL waiting WAIT_FOR run';
+select a from t1;
+set debug_sync='now WAIT_FOR waiting';
+set debug_sync='now SIGNAL run';
+ERROR HY000: Can't find file: './test/t1.MYI' (errno: 20 "Not a directory")
+flush tables;
+drop table if exists t1;
+drop table mysql.t1;
+set debug_sync='RESET';
diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result
index c633261bcd3..3e68a877f02 100644
--- a/mysql-test/r/table_elim.result
+++ b/mysql-test/r/table_elim.result
@@ -597,7 +597,8 @@ CREATE TABLE t1 (a int(11), b varchar(1)) ;
INSERT IGNORE INTO t1 VALUES (0,'g');
CREATE TABLE t3 ( a varchar(1)) ;
INSERT IGNORE INTO t3 VALUES ('g');
-CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a)) ;
+CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a));
+INSERT INTO t2 VALUES (9), (10);
create view v1 as SELECT t1.* FROM t1 LEFT JOIN t2 ON ( t1.a = t2.a ) WHERE t2.a <> 0;
SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
a b
@@ -606,7 +607,7 @@ EXPLAIN SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 system NULL NULL NULL NULL 1
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
drop view v1;
DROP TABLE t1,t2,t3;
#
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 6530fd10a6a..3c6eb235a57 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -5536,6 +5536,89 @@ Warnings:
Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
drop view v1;
drop table t1,t2;
+#
+# MDEV-12099: usage of mergeable view with LEFT JOIN
+# that can be converted to INNER JOIN
+#
+create table t1 (a int, b int, key(a)) engine=myisam;
+insert into t1 values
+(3,20), (7,10), (2,10), (4,30), (8,70),
+(7,70), (9,100), (9,60), (8,80), (7,60);
+create table t2 (c int, d int, key (c)) engine=myisam;
+insert into t2 values
+(50,100), (20, 200), (10,300),
+(150,100), (120, 200), (110,300),
+(250,100), (220, 200), (210,300);
+create table t3(e int, f int not null, key(e), unique (f)) engine=myisam;
+insert into t3 values
+(100, 3), (300, 5), (400, 4), (300,7),
+(300,2), (600, 13), (800, 15), (700, 14),
+(600, 23), (800, 25), (700, 24);
+create view v1 as
+select * from t2 left join t3 on t3.e=t2.d where t3.f is not null;
+select *
+from t1 left join v1 on v1.c=t1.b
+where t1.a < 5;
+a b c d e f
+2 10 10 300 300 5
+2 10 10 300 300 7
+2 10 10 300 300 2
+3 20 NULL NULL NULL NULL
+4 30 NULL NULL NULL NULL
+select *
+from t1 left join ( t2 left join t3 on t3.e=t2.d )
+on t2.c=t1.b and t3.f is not null
+where t1.a < 5;
+a b c d e f
+2 10 10 300 300 5
+2 10 10 300 300 7
+2 10 10 300 300 2
+3 20 NULL NULL NULL NULL
+4 30 NULL NULL NULL NULL
+explain extended
+select *
+from t1 left join v1 on v1.c=t1.b
+where t1.a < 5;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition
+1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where
+1 SIMPLE t3 ref f,e e 5 test.t2.d 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`e` = `test`.`t2`.`d`) and (`test`.`t3`.`f` is not null) and (`test`.`t1`.`b` is not null) and (`test`.`t2`.`d` is not null))) where (`test`.`t1`.`a` < 5)
+explain extended
+select *
+from t1 left join ( t2 left join t3 on t3.e=t2.d )
+on t2.c=t1.b and t3.f is not null
+where t1.a < 5;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition
+1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where
+1 SIMPLE t3 ref f,e e 5 test.t2.d 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`e` = `test`.`t2`.`d`) and (`test`.`t3`.`f` is not null) and (`test`.`t1`.`b` is not null) and (`test`.`t2`.`d` is not null))) where (`test`.`t1`.`a` < 5)
+explain extended
+select *
+from t1 left join v1 on v1.c=t1.b and v1.f=t1.a
+where t1.a < 5;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition
+1 SIMPLE t3 eq_ref f,e f 4 test.t1.a 1 100.00 Using where
+1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`f` = `test`.`t1`.`a`) and (`test`.`t2`.`d` = `test`.`t3`.`e`) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`b` is not null))) where (`test`.`t1`.`a` < 5)
+explain extended
+select *
+from t1 left join ( t2 left join t3 on t3.e=t2.d )
+on t2.c=t1.b and t3.f=t1.a and t3.f is not null
+where t1.a < 5;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 range a a 5 NULL 3 100.00 Using index condition
+1 SIMPLE t3 eq_ref f,e f 4 test.t1.a 1 100.00 Using where
+1 SIMPLE t2 ref c c 5 test.t1.b 2 100.00 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`f` = `test`.`t1`.`a`) and (`test`.`t2`.`d` = `test`.`t3`.`e`) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`b` is not null))) where (`test`.`t1`.`a` < 5)
+drop view v1;
+drop table t1,t2,t3;
# -----------------------------------------------------------------
# -- End of 5.5 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/suite/federated/federated_bug_35333.result b/mysql-test/suite/federated/federated_bug_35333.result
index 05e4bab8ec5..3660be258db 100644
--- a/mysql-test/suite/federated/federated_bug_35333.result
+++ b/mysql-test/suite/federated/federated_bug_35333.result
@@ -24,9 +24,9 @@ CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_ROWS DATA_LENGTH TABLE_COMMENT
-test t1 BASE TABLE NULL NULL NULL NULL Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
+test t1 BASE TABLE NULL NULL NULL NULL Can't find file: './test/t1.MYI' (errno: 2 "Not a directory")
Warnings:
-Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
+Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "Not a directory")
DROP TABLE t1;
Warnings:
Warning 2 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory")
diff --git a/mysql-test/suite/federated/federated_bug_35333.test b/mysql-test/suite/federated/federated_bug_35333.test
index 47feefd75a1..d43f4e930f8 100644
--- a/mysql-test/suite/federated/federated_bug_35333.test
+++ b/mysql-test/suite/federated/federated_bug_35333.test
@@ -61,6 +61,7 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
--echo # Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query
--echo #
+--replace_result 20 2
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
diff --git a/mysql-test/suite/parts/r/partition_bigint_innodb.result b/mysql-test/suite/parts/r/partition_bigint_innodb.result
new file mode 100644
index 00000000000..bb0f08d9356
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_bigint_innodb.result
@@ -0,0 +1,121 @@
+create table t1 (a bigint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
+insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612), (1), (2), (65535);
+select * from t1;
+a
+1
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+2
+65535
+select * from t1 where a=-2;
+a
+delete from t1 where a=-2;
+select * from t1;
+a
+1
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+2
+65535
+select * from t1 where a=18446744073709551615;
+a
+18446744073709551615
+delete from t1 where a=18446744073709551615;
+select * from t1;
+a
+1
+18446744073709551612
+18446744073709551613
+18446744073709551614
+2
+65535
+drop table t1;
+create table t2 (a bigint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` bigint(20) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
+select * from t2;
+a
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+select * from t2 where a=18446744073709551615;
+a
+18446744073709551615
+delete from t2 where a=18446744073709551615;
+select * from t2;
+a
+18446744073709551612
+18446744073709551613
+18446744073709551614
+delete from t2;
+1024 inserts;
+select count(*) from t2;
+count(*)
+1024
+drop table t2;
+create table t3 (a bigint not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` bigint(20) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0);
+select * from t3;
+a
+-1
+-9223372036854775807
+-9223372036854775808
+0
+1
+9223372036854775804
+9223372036854775805
+9223372036854775806
+9223372036854775807
+select * from t3 where a=9223372036854775806;
+a
+9223372036854775806
+delete from t3 where a=9223372036854775806;
+select * from t3;
+a
+-1
+-9223372036854775807
+-9223372036854775808
+0
+1
+9223372036854775804
+9223372036854775805
+9223372036854775807
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_bigint_myisam.result b/mysql-test/suite/parts/r/partition_bigint_myisam.result
new file mode 100644
index 00000000000..5938bcaf7d8
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_bigint_myisam.result
@@ -0,0 +1,121 @@
+create table t1 (a bigint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(20) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
+insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612), (1), (2), (65535);
+select * from t1;
+a
+1
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+2
+65535
+select * from t1 where a=-2;
+a
+delete from t1 where a=-2;
+select * from t1;
+a
+1
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+2
+65535
+select * from t1 where a=18446744073709551615;
+a
+18446744073709551615
+delete from t1 where a=18446744073709551615;
+select * from t1;
+a
+1
+18446744073709551612
+18446744073709551613
+18446744073709551614
+2
+65535
+drop table t1;
+create table t2 (a bigint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` bigint(20) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
+select * from t2;
+a
+18446744073709551612
+18446744073709551613
+18446744073709551614
+18446744073709551615
+select * from t2 where a=18446744073709551615;
+a
+18446744073709551615
+delete from t2 where a=18446744073709551615;
+select * from t2;
+a
+18446744073709551612
+18446744073709551613
+18446744073709551614
+delete from t2;
+65535 inserts;
+select count(*) from t2;
+count(*)
+65535
+drop table t2;
+create table t3 (a bigint not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` bigint(20) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0);
+select * from t3;
+a
+-1
+-9223372036854775807
+-9223372036854775808
+0
+1
+9223372036854775804
+9223372036854775805
+9223372036854775806
+9223372036854775807
+select * from t3 where a=9223372036854775806;
+a
+9223372036854775806
+delete from t3 where a=9223372036854775806;
+select * from t3;
+a
+-1
+-9223372036854775807
+-9223372036854775808
+0
+1
+9223372036854775804
+9223372036854775805
+9223372036854775807
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_double_innodb.result b/mysql-test/suite/parts/r/partition_double_innodb.result
new file mode 100644
index 00000000000..8c0daf929dd
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_double_innodb.result
@@ -0,0 +1,82 @@
+create table t1 (a double not null, primary key(a)) engine='InnoDB'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` double NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
+insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
+select * from t1;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1.5
+1234.567
+2.2250738585072016e208
+select * from t1 where a=1.5;
+a
+1.5
+delete from t1 where a=1.5;
+select * from t1;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1234.567
+2.2250738585072016e208
+drop table t1;
+create table t2 (a double not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 10;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` double NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 10 */
+insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
+select * from t2;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1.5
+1234.567
+2.2250738585072016e208
+select * from t2 where a=1234.567;
+a
+1234.567
+delete from t2 where a=1234.567;
+select * from t2;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1.5
+2.2250738585072016e208
+delete from t2;
+1024*3 inserts;
+select count(*) from t2;
+count(*)
+3072
+drop table t2;
diff --git a/mysql-test/suite/parts/r/partition_double_myisam.result b/mysql-test/suite/parts/r/partition_double_myisam.result
new file mode 100644
index 00000000000..045763e5ef9
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_double_myisam.result
@@ -0,0 +1,82 @@
+create table t1 (a double not null, primary key(a)) engine='MYISAM'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` double NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
+insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
+select * from t1;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1.5
+1234.567
+2.2250738585072016e208
+select * from t1 where a=1.5;
+a
+1.5
+delete from t1 where a=1.5;
+select * from t1;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1234.567
+2.2250738585072016e208
+drop table t1;
+create table t2 (a double not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 10;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` double NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 10 */
+insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
+select * from t2;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1.5
+1234.567
+2.2250738585072016e208
+select * from t2 where a=1234.567;
+a
+1234.567
+delete from t2 where a=1234.567;
+select * from t2;
+a
+-2.2250738585072016e208
+-1.5
+-1
+-2.2250738585072014e-208
+0
+1.5
+2.2250738585072016e208
+delete from t2;
+16384*3 inserts;
+select count(*) from t2;
+count(*)
+49152
+drop table t2;
diff --git a/mysql-test/suite/parts/r/partition_float_innodb.result b/mysql-test/suite/parts/r/partition_float_innodb.result
index d2f04a68629..b0870992c41 100644
--- a/mysql-test/suite/parts/r/partition_float_innodb.result
+++ b/mysql-test/suite/parts/r/partition_float_innodb.result
@@ -88,85 +88,3 @@ select count(*) from t2;
count(*)
3072
drop table t2;
-create table t1 (a double not null, primary key(a)) engine='InnoDB'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` double NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
-insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
-select * from t1;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1.5
-1234.567
-2.2250738585072016e208
-select * from t1 where a=1.5;
-a
-1.5
-delete from t1 where a=1.5;
-select * from t1;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1234.567
-2.2250738585072016e208
-drop table t1;
-create table t2 (a double not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 10;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` double NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 10 */
-insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
-select * from t2;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1.5
-1234.567
-2.2250738585072016e208
-select * from t2 where a=1234.567;
-a
-1234.567
-delete from t2 where a=1234.567;
-select * from t2;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1.5
-2.2250738585072016e208
-delete from t2;
-1024*3 inserts;
-select count(*) from t2;
-count(*)
-3072
-drop table t2;
diff --git a/mysql-test/suite/parts/r/partition_float_myisam.result b/mysql-test/suite/parts/r/partition_float_myisam.result
index 2d52d095989..931c4ef0394 100644
--- a/mysql-test/suite/parts/r/partition_float_myisam.result
+++ b/mysql-test/suite/parts/r/partition_float_myisam.result
@@ -88,85 +88,3 @@ select count(*) from t2;
count(*)
49152
drop table t2;
-create table t1 (a double not null, primary key(a)) engine='MYISAM'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` double NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
-insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
-select * from t1;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1.5
-1234.567
-2.2250738585072016e208
-select * from t1 where a=1.5;
-a
-1.5
-delete from t1 where a=1.5;
-select * from t1;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1234.567
-2.2250738585072016e208
-drop table t1;
-create table t2 (a double not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 10;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` double NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 10 */
-insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
-select * from t2;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1.5
-1234.567
-2.2250738585072016e208
-select * from t2 where a=1234.567;
-a
-1234.567
-delete from t2 where a=1234.567;
-select * from t2;
-a
--2.2250738585072016e208
--1.5
--1
--2.2250738585072014e-208
-0
-1.5
-2.2250738585072016e208
-delete from t2;
-16384*3 inserts;
-select count(*) from t2;
-count(*)
-49152
-drop table t2;
diff --git a/mysql-test/suite/parts/r/partition_int_innodb.result b/mysql-test/suite/parts/r/partition_int_innodb.result
index 7a51b80d5d7..c1798e5f711 100644
--- a/mysql-test/suite/parts/r/partition_int_innodb.result
+++ b/mysql-test/suite/parts/r/partition_int_innodb.result
@@ -1,221 +1,3 @@
-create table t1 (a tinyint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` tinyint(3) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
-insert into t1 values (255), (254), (253), (252), (1), (2), (128);
-select * from t1;
-a
-1
-128
-2
-252
-253
-254
-255
-select * from t1 where a=253;
-a
-253
-delete from t1 where a=253;
-select * from t1;
-a
-1
-128
-2
-252
-254
-255
-drop table t1;
-create table t2 (a tinyint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` tinyint(3) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (255), (254), (253), (252);
-select * from t2;
-a
-252
-253
-254
-255
-select * from t2 where a=253;
-a
-253
-delete from t2 where a=253;
-select * from t2;
-a
-252
-254
-255
-delete from t2;
-255 inserts;
-select count(*) from t2;
-count(*)
-255
-drop table t2;
-create table t3 (a tinyint not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` tinyint(4) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0);
-select * from t3;
-a
--1
--127
--128
-0
-1
-124
-125
-126
-127
-select * from t3 where a=125;
-a
-125
-delete from t3 where a=125;
-select * from t3;
-a
--1
--127
--128
-0
-1
-124
-126
-127
-drop table t3;
-create table t1 (a smallint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` smallint(5) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
-insert into t1 values (65535), (65534), (65533), (65532), (1), (2), (256);
-select * from t1;
-a
-1
-2
-256
-65532
-65533
-65534
-65535
-select * from t1 where a=65533;
-a
-65533
-delete from t1 where a=65533;
-select * from t1;
-a
-1
-2
-256
-65532
-65534
-65535
-drop table t1;
-create table t2 (a smallint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` smallint(5) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (65535), (65534), (65533), (65532);
-select * from t2;
-a
-65532
-65533
-65534
-65535
-select * from t2 where a=65533;
-a
-65533
-delete from t2 where a=65533;
-select * from t2;
-a
-65532
-65534
-65535
-delete from t2;
-1024 inserts;
-select count(*) from t2;
-count(*)
-1024
-drop table t2;
-create table t3 (a smallint not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` smallint(6) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0);
-select * from t3;
-a
--1
--32767
--32768
-0
-1
-32764
-32765
-32766
-32767
-select * from t3 where a=32765;
-a
-32765
-delete from t3 where a=32765;
-select * from t3;
-a
--1
--32767
--32768
-0
-1
-32764
-32766
-32767
-drop table t3;
create table t1 (a int unsigned not null, primary key(a)) engine='InnoDB'
partition by key (a) (
partition pa1 max_rows=20 min_rows=2,
@@ -325,233 +107,3 @@ a
2147483646
2147483647
drop table t3;
-create table t1 (a mediumint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` mediumint(8) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
-insert into t1 values (16777215), (16777214), (16777213), (16777212), (1), (2), (65535);
-select * from t1;
-a
-1
-16777212
-16777213
-16777214
-16777215
-2
-65535
-select * from t1 where a=16777213;
-a
-16777213
-delete from t1 where a=16777213;
-select * from t1;
-a
-1
-16777212
-16777214
-16777215
-2
-65535
-drop table t1;
-create table t2 (a mediumint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` mediumint(8) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (16777215), (16777214), (16777213), (16777212);
-select * from t2;
-a
-16777212
-16777213
-16777214
-16777215
-select * from t2 where a=16777213;
-a
-16777213
-delete from t2 where a=16777213;
-select * from t2;
-a
-16777212
-16777214
-16777215
-delete from t2;
-1024 inserts;
-select count(*) from t2;
-count(*)
-1024
-drop table t2;
-create table t3 (a mediumint not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` mediumint(9) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0);
-select * from t3;
-a
--1
--8388607
--8388608
-0
-1
-8388604
-8388605
-8388606
-8388607
-select * from t3 where a=8388605;
-a
-8388605
-delete from t3 where a=8388605;
-select * from t3;
-a
--1
--8388607
--8388608
-0
-1
-8388604
-8388606
-8388607
-drop table t3;
-create table t1 (a bigint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` bigint(20) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
-insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612), (1), (2), (65535);
-select * from t1;
-a
-1
-18446744073709551612
-18446744073709551613
-18446744073709551614
-18446744073709551615
-2
-65535
-select * from t1 where a=-2;
-a
-delete from t1 where a=-2;
-select * from t1;
-a
-1
-18446744073709551612
-18446744073709551613
-18446744073709551614
-18446744073709551615
-2
-65535
-select * from t1 where a=18446744073709551615;
-a
-18446744073709551615
-delete from t1 where a=18446744073709551615;
-select * from t1;
-a
-1
-18446744073709551612
-18446744073709551613
-18446744073709551614
-2
-65535
-drop table t1;
-create table t2 (a bigint unsigned not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` bigint(20) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
-select * from t2;
-a
-18446744073709551612
-18446744073709551613
-18446744073709551614
-18446744073709551615
-select * from t2 where a=18446744073709551615;
-a
-18446744073709551615
-delete from t2 where a=18446744073709551615;
-select * from t2;
-a
-18446744073709551612
-18446744073709551613
-18446744073709551614
-delete from t2;
-1024 inserts;
-select count(*) from t2;
-count(*)
-1024
-drop table t2;
-create table t3 (a bigint not null, primary key(a)) engine='InnoDB'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` bigint(20) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0);
-select * from t3;
-a
--1
--9223372036854775807
--9223372036854775808
-0
-1
-9223372036854775804
-9223372036854775805
-9223372036854775806
-9223372036854775807
-select * from t3 where a=9223372036854775806;
-a
-9223372036854775806
-delete from t3 where a=9223372036854775806;
-select * from t3;
-a
--1
--9223372036854775807
--9223372036854775808
-0
-1
-9223372036854775804
-9223372036854775805
-9223372036854775807
-drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_int_myisam.result b/mysql-test/suite/parts/r/partition_int_myisam.result
index 4387bbfdd78..8b8352ebc38 100644
--- a/mysql-test/suite/parts/r/partition_int_myisam.result
+++ b/mysql-test/suite/parts/r/partition_int_myisam.result
@@ -1,221 +1,3 @@
-create table t1 (a tinyint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` tinyint(3) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
-insert into t1 values (255), (254), (253), (252), (1), (2), (128);
-select * from t1;
-a
-1
-128
-2
-252
-253
-254
-255
-select * from t1 where a=253;
-a
-253
-delete from t1 where a=253;
-select * from t1;
-a
-1
-128
-2
-252
-254
-255
-drop table t1;
-create table t2 (a tinyint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` tinyint(3) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (255), (254), (253), (252);
-select * from t2;
-a
-252
-253
-254
-255
-select * from t2 where a=253;
-a
-253
-delete from t2 where a=253;
-select * from t2;
-a
-252
-254
-255
-delete from t2;
-255 inserts;
-select count(*) from t2;
-count(*)
-255
-drop table t2;
-create table t3 (a tinyint not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` tinyint(4) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0);
-select * from t3;
-a
--1
--127
--128
-0
-1
-124
-125
-126
-127
-select * from t3 where a=125;
-a
-125
-delete from t3 where a=125;
-select * from t3;
-a
--1
--127
--128
-0
-1
-124
-126
-127
-drop table t3;
-create table t1 (a smallint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` smallint(5) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
-insert into t1 values (65535), (65534), (65533), (65532), (1), (2), (256);
-select * from t1;
-a
-1
-2
-256
-65532
-65533
-65534
-65535
-select * from t1 where a=65533;
-a
-65533
-delete from t1 where a=65533;
-select * from t1;
-a
-1
-2
-256
-65532
-65534
-65535
-drop table t1;
-create table t2 (a smallint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` smallint(5) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (65535), (65534), (65533), (65532);
-select * from t2;
-a
-65532
-65533
-65534
-65535
-select * from t2 where a=65533;
-a
-65533
-delete from t2 where a=65533;
-select * from t2;
-a
-65532
-65534
-65535
-delete from t2;
-65535 inserts;
-select count(*) from t2;
-count(*)
-65535
-drop table t2;
-create table t3 (a smallint not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` smallint(6) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0);
-select * from t3;
-a
--1
--32767
--32768
-0
-1
-32764
-32765
-32766
-32767
-select * from t3 where a=32765;
-a
-32765
-delete from t3 where a=32765;
-select * from t3;
-a
--1
--32767
--32768
-0
-1
-32764
-32766
-32767
-drop table t3;
create table t1 (a int unsigned not null, primary key(a)) engine='MYISAM'
partition by key (a) (
partition pa1 max_rows=20 min_rows=2,
@@ -325,233 +107,3 @@ a
2147483646
2147483647
drop table t3;
-create table t1 (a mediumint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` mediumint(8) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
-insert into t1 values (16777215), (16777214), (16777213), (16777212), (1), (2), (65535);
-select * from t1;
-a
-1
-16777212
-16777213
-16777214
-16777215
-2
-65535
-select * from t1 where a=16777213;
-a
-16777213
-delete from t1 where a=16777213;
-select * from t1;
-a
-1
-16777212
-16777214
-16777215
-2
-65535
-drop table t1;
-create table t2 (a mediumint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` mediumint(8) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (16777215), (16777214), (16777213), (16777212);
-select * from t2;
-a
-16777212
-16777213
-16777214
-16777215
-select * from t2 where a=16777213;
-a
-16777213
-delete from t2 where a=16777213;
-select * from t2;
-a
-16777212
-16777214
-16777215
-delete from t2;
-65535 inserts;
-select count(*) from t2;
-count(*)
-65535
-drop table t2;
-create table t3 (a mediumint not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` mediumint(9) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0);
-select * from t3;
-a
--1
--8388607
--8388608
-0
-1
-8388604
-8388605
-8388606
-8388607
-select * from t3 where a=8388605;
-a
-8388605
-delete from t3 where a=8388605;
-select * from t3;
-a
--1
--8388607
--8388608
-0
-1
-8388604
-8388606
-8388607
-drop table t3;
-create table t1 (a bigint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) (
-partition pa1 max_rows=20 min_rows=2,
-partition pa2 max_rows=30 min_rows=3,
-partition pa3 max_rows=30 min_rows=4,
-partition pa4 max_rows=40 min_rows=2);
-show create table t1;
-Table Create Table
-t1 CREATE TABLE `t1` (
- `a` bigint(20) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
- PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
- PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
- PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
-insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612), (1), (2), (65535);
-select * from t1;
-a
-1
-18446744073709551612
-18446744073709551613
-18446744073709551614
-18446744073709551615
-2
-65535
-select * from t1 where a=-2;
-a
-delete from t1 where a=-2;
-select * from t1;
-a
-1
-18446744073709551612
-18446744073709551613
-18446744073709551614
-18446744073709551615
-2
-65535
-select * from t1 where a=18446744073709551615;
-a
-18446744073709551615
-delete from t1 where a=18446744073709551615;
-select * from t1;
-a
-1
-18446744073709551612
-18446744073709551613
-18446744073709551614
-2
-65535
-drop table t1;
-create table t2 (a bigint unsigned not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 8;
-show create table t2;
-Table Create Table
-t2 CREATE TABLE `t2` (
- `a` bigint(20) unsigned NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 8 */
-insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
-select * from t2;
-a
-18446744073709551612
-18446744073709551613
-18446744073709551614
-18446744073709551615
-select * from t2 where a=18446744073709551615;
-a
-18446744073709551615
-delete from t2 where a=18446744073709551615;
-select * from t2;
-a
-18446744073709551612
-18446744073709551613
-18446744073709551614
-delete from t2;
-65535 inserts;
-select count(*) from t2;
-count(*)
-65535
-drop table t2;
-create table t3 (a bigint not null, primary key(a)) engine='MYISAM'
-partition by key (a) partitions 7;
-show create table t3;
-Table Create Table
-t3 CREATE TABLE `t3` (
- `a` bigint(20) NOT NULL,
- PRIMARY KEY (`a`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY KEY (a)
-PARTITIONS 7 */
-insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0);
-select * from t3;
-a
--1
--9223372036854775807
--9223372036854775808
-0
-1
-9223372036854775804
-9223372036854775805
-9223372036854775806
-9223372036854775807
-select * from t3 where a=9223372036854775806;
-a
-9223372036854775806
-delete from t3 where a=9223372036854775806;
-select * from t3;
-a
--1
--9223372036854775807
--9223372036854775808
-0
-1
-9223372036854775804
-9223372036854775805
-9223372036854775807
-drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_mediumint_innodb.result b/mysql-test/suite/parts/r/partition_mediumint_innodb.result
new file mode 100644
index 00000000000..8e3e5543ddc
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_mediumint_innodb.result
@@ -0,0 +1,109 @@
+create table t1 (a mediumint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` mediumint(8) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
+insert into t1 values (16777215), (16777214), (16777213), (16777212), (1), (2), (65535);
+select * from t1;
+a
+1
+16777212
+16777213
+16777214
+16777215
+2
+65535
+select * from t1 where a=16777213;
+a
+16777213
+delete from t1 where a=16777213;
+select * from t1;
+a
+1
+16777212
+16777214
+16777215
+2
+65535
+drop table t1;
+create table t2 (a mediumint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` mediumint(8) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (16777215), (16777214), (16777213), (16777212);
+select * from t2;
+a
+16777212
+16777213
+16777214
+16777215
+select * from t2 where a=16777213;
+a
+16777213
+delete from t2 where a=16777213;
+select * from t2;
+a
+16777212
+16777214
+16777215
+delete from t2;
+1024 inserts;
+select count(*) from t2;
+count(*)
+1024
+drop table t2;
+create table t3 (a mediumint not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` mediumint(9) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0);
+select * from t3;
+a
+-1
+-8388607
+-8388608
+0
+1
+8388604
+8388605
+8388606
+8388607
+select * from t3 where a=8388605;
+a
+8388605
+delete from t3 where a=8388605;
+select * from t3;
+a
+-1
+-8388607
+-8388608
+0
+1
+8388604
+8388606
+8388607
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_mediumint_myisam.result b/mysql-test/suite/parts/r/partition_mediumint_myisam.result
new file mode 100644
index 00000000000..4853680610b
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_mediumint_myisam.result
@@ -0,0 +1,109 @@
+create table t1 (a mediumint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` mediumint(8) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
+insert into t1 values (16777215), (16777214), (16777213), (16777212), (1), (2), (65535);
+select * from t1;
+a
+1
+16777212
+16777213
+16777214
+16777215
+2
+65535
+select * from t1 where a=16777213;
+a
+16777213
+delete from t1 where a=16777213;
+select * from t1;
+a
+1
+16777212
+16777214
+16777215
+2
+65535
+drop table t1;
+create table t2 (a mediumint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` mediumint(8) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (16777215), (16777214), (16777213), (16777212);
+select * from t2;
+a
+16777212
+16777213
+16777214
+16777215
+select * from t2 where a=16777213;
+a
+16777213
+delete from t2 where a=16777213;
+select * from t2;
+a
+16777212
+16777214
+16777215
+delete from t2;
+65535 inserts;
+select count(*) from t2;
+count(*)
+65535
+drop table t2;
+create table t3 (a mediumint not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` mediumint(9) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0);
+select * from t3;
+a
+-1
+-8388607
+-8388608
+0
+1
+8388604
+8388605
+8388606
+8388607
+select * from t3 where a=8388605;
+a
+8388605
+delete from t3 where a=8388605;
+select * from t3;
+a
+-1
+-8388607
+-8388608
+0
+1
+8388604
+8388606
+8388607
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_smallint_innodb.result b/mysql-test/suite/parts/r/partition_smallint_innodb.result
new file mode 100644
index 00000000000..fbf23fe582c
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_smallint_innodb.result
@@ -0,0 +1,109 @@
+create table t1 (a smallint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` smallint(5) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
+insert into t1 values (65535), (65534), (65533), (65532), (1), (2), (256);
+select * from t1;
+a
+1
+2
+256
+65532
+65533
+65534
+65535
+select * from t1 where a=65533;
+a
+65533
+delete from t1 where a=65533;
+select * from t1;
+a
+1
+2
+256
+65532
+65534
+65535
+drop table t1;
+create table t2 (a smallint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` smallint(5) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (65535), (65534), (65533), (65532);
+select * from t2;
+a
+65532
+65533
+65534
+65535
+select * from t2 where a=65533;
+a
+65533
+delete from t2 where a=65533;
+select * from t2;
+a
+65532
+65534
+65535
+delete from t2;
+1024 inserts;
+select count(*) from t2;
+count(*)
+1024
+drop table t2;
+create table t3 (a smallint not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` smallint(6) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0);
+select * from t3;
+a
+-1
+-32767
+-32768
+0
+1
+32764
+32765
+32766
+32767
+select * from t3 where a=32765;
+a
+32765
+delete from t3 where a=32765;
+select * from t3;
+a
+-1
+-32767
+-32768
+0
+1
+32764
+32766
+32767
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_smallint_myisam.result b/mysql-test/suite/parts/r/partition_smallint_myisam.result
new file mode 100644
index 00000000000..a405d025919
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_smallint_myisam.result
@@ -0,0 +1,109 @@
+create table t1 (a smallint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` smallint(5) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
+insert into t1 values (65535), (65534), (65533), (65532), (1), (2), (256);
+select * from t1;
+a
+1
+2
+256
+65532
+65533
+65534
+65535
+select * from t1 where a=65533;
+a
+65533
+delete from t1 where a=65533;
+select * from t1;
+a
+1
+2
+256
+65532
+65534
+65535
+drop table t1;
+create table t2 (a smallint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` smallint(5) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (65535), (65534), (65533), (65532);
+select * from t2;
+a
+65532
+65533
+65534
+65535
+select * from t2 where a=65533;
+a
+65533
+delete from t2 where a=65533;
+select * from t2;
+a
+65532
+65534
+65535
+delete from t2;
+65535 inserts;
+select count(*) from t2;
+count(*)
+65535
+drop table t2;
+create table t3 (a smallint not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` smallint(6) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0);
+select * from t3;
+a
+-1
+-32767
+-32768
+0
+1
+32764
+32765
+32766
+32767
+select * from t3 where a=32765;
+a
+32765
+delete from t3 where a=32765;
+select * from t3;
+a
+-1
+-32767
+-32768
+0
+1
+32764
+32766
+32767
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_tinyint_innodb.result b/mysql-test/suite/parts/r/partition_tinyint_innodb.result
new file mode 100644
index 00000000000..d7138539b78
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_tinyint_innodb.result
@@ -0,0 +1,109 @@
+create table t1 (a tinyint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` tinyint(3) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
+insert into t1 values (255), (254), (253), (252), (1), (2), (128);
+select * from t1;
+a
+1
+128
+2
+252
+253
+254
+255
+select * from t1 where a=253;
+a
+253
+delete from t1 where a=253;
+select * from t1;
+a
+1
+128
+2
+252
+254
+255
+drop table t1;
+create table t2 (a tinyint unsigned not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` tinyint(3) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (255), (254), (253), (252);
+select * from t2;
+a
+252
+253
+254
+255
+select * from t2 where a=253;
+a
+253
+delete from t2 where a=253;
+select * from t2;
+a
+252
+254
+255
+delete from t2;
+255 inserts;
+select count(*) from t2;
+count(*)
+255
+drop table t2;
+create table t3 (a tinyint not null, primary key(a)) engine='InnoDB'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` tinyint(4) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0);
+select * from t3;
+a
+-1
+-127
+-128
+0
+1
+124
+125
+126
+127
+select * from t3 where a=125;
+a
+125
+delete from t3 where a=125;
+select * from t3;
+a
+-1
+-127
+-128
+0
+1
+124
+126
+127
+drop table t3;
diff --git a/mysql-test/suite/parts/r/partition_tinyint_myisam.result b/mysql-test/suite/parts/r/partition_tinyint_myisam.result
new file mode 100644
index 00000000000..08a688e8f36
--- /dev/null
+++ b/mysql-test/suite/parts/r/partition_tinyint_myisam.result
@@ -0,0 +1,109 @@
+create table t1 (a tinyint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) (
+partition pa1 max_rows=20 min_rows=2,
+partition pa2 max_rows=30 min_rows=3,
+partition pa3 max_rows=30 min_rows=4,
+partition pa4 max_rows=40 min_rows=2);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` tinyint(3) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+(PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = MyISAM,
+ PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = MyISAM,
+ PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = MyISAM,
+ PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = MyISAM) */
+insert into t1 values (255), (254), (253), (252), (1), (2), (128);
+select * from t1;
+a
+1
+128
+2
+252
+253
+254
+255
+select * from t1 where a=253;
+a
+253
+delete from t1 where a=253;
+select * from t1;
+a
+1
+128
+2
+252
+254
+255
+drop table t1;
+create table t2 (a tinyint unsigned not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 8;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` tinyint(3) unsigned NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 8 */
+insert into t2 values (255), (254), (253), (252);
+select * from t2;
+a
+252
+253
+254
+255
+select * from t2 where a=253;
+a
+253
+delete from t2 where a=253;
+select * from t2;
+a
+252
+254
+255
+delete from t2;
+255 inserts;
+select count(*) from t2;
+count(*)
+255
+drop table t2;
+create table t3 (a tinyint not null, primary key(a)) engine='MYISAM'
+partition by key (a) partitions 7;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` tinyint(4) NOT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY KEY (a)
+PARTITIONS 7 */
+insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0);
+select * from t3;
+a
+-1
+-127
+-128
+0
+1
+124
+125
+126
+127
+select * from t3 where a=125;
+a
+125
+delete from t3 where a=125;
+select * from t3;
+a
+-1
+-127
+-128
+0
+1
+124
+126
+127
+drop table t3;
diff --git a/mysql-test/suite/parts/t/partition_bigint_innodb.test b/mysql-test/suite/parts/t/partition_bigint_innodb.test
new file mode 100644
index 00000000000..348ee0add05
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_bigint_innodb.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_bigint_innodb.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# INNODB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_innodb #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+--source include/have_innodb.inc
+let $engine= 'InnoDB';
+
+##### max rows to be inserted
+let $maxrows=1024;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_bigint.inc
diff --git a/mysql-test/suite/parts/t/partition_bigint_myisam.test b/mysql-test/suite/parts/t/partition_bigint_myisam.test
new file mode 100644
index 00000000000..f427ffce08d
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_bigint_myisam.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_bigint_myisam.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_myisam #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+--source include/long_test.inc
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+let $engine= 'MYISAM';
+##### number of rows to be inserted
+let $maxrows=65535;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_bigint.inc
diff --git a/mysql-test/suite/parts/t/partition_double_innodb.test b/mysql-test/suite/parts/t/partition_double_innodb.test
new file mode 100644
index 00000000000..e31f7049502
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_double_innodb.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_double_innodb.test #
+# #
+# Purpose: #
+# Tests around float type #
+# INNODB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_float_innodb #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+--source include/have_innodb.inc
+let $engine= 'InnoDB';
+
+##### Number of row to be inserted.
+let $maxrows=1024;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_double.inc
diff --git a/mysql-test/suite/parts/t/partition_double_myisam.test b/mysql-test/suite/parts/t/partition_double_myisam.test
new file mode 100644
index 00000000000..6228d657c48
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_double_myisam.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_double_myisam.test #
+# #
+# Purpose: #
+# Tests around float type #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_float_myisam #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+--source include/long_test.inc
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+let $engine= 'MYISAM';
+##### Number of row to be inserted.
+let $maxrows=16384;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_double.inc
diff --git a/mysql-test/suite/parts/t/partition_float_innodb.test b/mysql-test/suite/parts/t/partition_float_innodb.test
index 2f1fe723dad..8d96eafbb06 100644
--- a/mysql-test/suite/parts/t/partition_float_innodb.test
+++ b/mysql-test/suite/parts/t/partition_float_innodb.test
@@ -8,9 +8,9 @@
#------------------------------------------------------------------------------#
# Original Author: HH #
# Original Date: 2006-08-01 #
-# Change Author: #
-# Change Date: #
-# Change: #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test for double type has been spawned into a separate test file #
################################################################################
#
@@ -44,4 +44,3 @@ let $maxrows=1024;
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_float.inc
---source suite/parts/inc/partition_double.inc
diff --git a/mysql-test/suite/parts/t/partition_float_myisam.test b/mysql-test/suite/parts/t/partition_float_myisam.test
index f15e6ad3636..bdc0edd41bb 100644
--- a/mysql-test/suite/parts/t/partition_float_myisam.test
+++ b/mysql-test/suite/parts/t/partition_float_myisam.test
@@ -8,9 +8,9 @@
#------------------------------------------------------------------------------#
# Original Author: HH #
# Original Date: 2006-08-01 #
-# Change Author: #
-# Change Date: #
-# Change: #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test for double type has been spawned into a separate test file #
################################################################################
#
@@ -44,4 +44,3 @@ let $maxrows=16384;
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_float.inc
---source suite/parts/inc/partition_double.inc
diff --git a/mysql-test/suite/parts/t/partition_int_innodb.test b/mysql-test/suite/parts/t/partition_int_innodb.test
index 698a2c93c22..fd00e6a0d80 100644
--- a/mysql-test/suite/parts/t/partition_int_innodb.test
+++ b/mysql-test/suite/parts/t/partition_int_innodb.test
@@ -8,9 +8,9 @@
#------------------------------------------------------------------------------#
# Original Author: HH #
# Original Date: 2006-08-01 #
-# Change Author: #
-# Change Date: #
-# Change: #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: Int subtypes (tinyint etc.) have been spawned into separate tests #
################################################################################
#
@@ -43,8 +43,4 @@ let $maxrows=1024;
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
---source suite/parts/inc/partition_tinyint.inc
---source suite/parts/inc/partition_smallint.inc
--source suite/parts/inc/partition_int.inc
---source suite/parts/inc/partition_mediumint.inc
---source suite/parts/inc/partition_bigint.inc
diff --git a/mysql-test/suite/parts/t/partition_int_myisam.test b/mysql-test/suite/parts/t/partition_int_myisam.test
index 5f29b575244..e8de09f1bf3 100644
--- a/mysql-test/suite/parts/t/partition_int_myisam.test
+++ b/mysql-test/suite/parts/t/partition_int_myisam.test
@@ -8,9 +8,9 @@
#------------------------------------------------------------------------------#
# Original Author: HH #
# Original Date: 2006-08-01 #
-# Change Author: #
-# Change Date: #
-# Change: #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: Int subtypes (tinyint etc.) have been spawned into separate tests #
################################################################################
#
@@ -43,8 +43,4 @@ let $maxrows=65535;
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
---source suite/parts/inc/partition_tinyint.inc
---source suite/parts/inc/partition_smallint.inc
--source suite/parts/inc/partition_int.inc
---source suite/parts/inc/partition_mediumint.inc
---source suite/parts/inc/partition_bigint.inc
diff --git a/mysql-test/suite/parts/t/partition_mediumint_innodb.test b/mysql-test/suite/parts/t/partition_mediumint_innodb.test
new file mode 100644
index 00000000000..9218b55fa78
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_mediumint_innodb.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_mediumint_innodb.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# INNODB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_innodb #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+--source include/have_innodb.inc
+let $engine= 'InnoDB';
+
+##### max rows to be inserted
+let $maxrows=1024;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_mediumint.inc
diff --git a/mysql-test/suite/parts/t/partition_mediumint_myisam.test b/mysql-test/suite/parts/t/partition_mediumint_myisam.test
new file mode 100644
index 00000000000..bbf1775ba97
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_mediumint_myisam.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_mediumint_myisam.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_myisam #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+--source include/long_test.inc
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+let $engine= 'MYISAM';
+##### number of rows to be inserted
+let $maxrows=65535;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_mediumint.inc
diff --git a/mysql-test/suite/parts/t/partition_smallint_innodb.test b/mysql-test/suite/parts/t/partition_smallint_innodb.test
new file mode 100644
index 00000000000..22d16cf9d55
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_smallint_innodb.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_smallint_innodb.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# INNODB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_innodb #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+--source include/have_innodb.inc
+let $engine= 'InnoDB';
+
+##### max rows to be inserted
+let $maxrows=1024;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_smallint.inc
diff --git a/mysql-test/suite/parts/t/partition_smallint_myisam.test b/mysql-test/suite/parts/t/partition_smallint_myisam.test
new file mode 100644
index 00000000000..f473a6772f8
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_smallint_myisam.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_smallint_myisam.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_myisam #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+--source include/long_test.inc
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+let $engine= 'MYISAM';
+##### number of rows to be inserted
+let $maxrows=65535;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_smallint.inc
diff --git a/mysql-test/suite/parts/t/partition_tinyint_innodb.test b/mysql-test/suite/parts/t/partition_tinyint_innodb.test
new file mode 100644
index 00000000000..aec10c1aea5
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_tinyint_innodb.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_tinyint_innodb.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# INNODB branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_innodb #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+--source include/have_innodb.inc
+let $engine= 'InnoDB';
+
+##### max rows to be inserted
+let $maxrows=1024;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_tinyint.inc
diff --git a/mysql-test/suite/parts/t/partition_tinyint_myisam.test b/mysql-test/suite/parts/t/partition_tinyint_myisam.test
new file mode 100644
index 00000000000..9807bffb1da
--- /dev/null
+++ b/mysql-test/suite/parts/t/partition_tinyint_myisam.test
@@ -0,0 +1,46 @@
+################################################################################
+# t/partition_tinyint_myisam.test #
+# #
+# Purpose: #
+# Tests around integer type #
+# MyISAM branch #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-08-01 #
+# Change Author: Elena Stepanova #
+# Change Date: 2017-02-18 #
+# Change: The test file is spawned from the mega-test partition_int_myisam #
+################################################################################
+
+#
+# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
+# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
+# THE SOURCED FILES ONLY.
+#
+# Please read the README at the end of inc/partition.pre before changing
+# any of the variables.
+#
+
+--source include/long_test.inc
+
+#------------------------------------------------------------------------------#
+# General not engine specific settings and requirements
+
+##### Options, for debugging support #####
+let $debug= 0;
+
+# The server must support partitioning.
+--source include/have_partition.inc
+
+#------------------------------------------------------------------------------#
+# Engine specific settings and requirements
+
+##### Storage engine to be tested
+let $engine= 'MYISAM';
+##### number of rows to be inserted
+let $maxrows=65535;
+
+#------------------------------------------------------------------------------#
+# Execute the tests to be applied to all storage engines
+--source suite/parts/inc/partition_tinyint.inc
diff --git a/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
index 91ed6d7a0cb..0cb1aed9905 100644
--- a/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
+++ b/mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
@@ -7,7 +7,6 @@ RESET SLAVE;
SET @restore_slave_net_timeout=@@global.slave_net_timeout;
RESET MASTER;
SET @restore_slave_net_timeout=@@global.slave_net_timeout;
-SET @restore_event_scheduler=@@global.event_scheduler;
*** Default value ***
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root';
@@ -221,7 +220,7 @@ RESET SLAVE;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_PORT, MASTER_USER='root', MASTER_CONNECT_RETRY=20, MASTER_HEARTBEAT_PERIOD=5;
include/start_slave.inc
SET @@global.event_scheduler=1;
-Number of received heartbeat events: 0
+Received heartbeats meet expectations: TRUE
DELETE FROM t1;
DROP EVENT e1;
diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
index 5b55f11da85..4c8d3a1fedb 100644
--- a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
+++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
@@ -34,7 +34,6 @@ eval SET @restore_slave_heartbeat_timeout=$slave_heartbeat_timeout;
--connection master
RESET MASTER;
SET @restore_slave_net_timeout=@@global.slave_net_timeout;
-SET @restore_event_scheduler=@@global.event_scheduler;
--echo
#
@@ -352,21 +351,54 @@ eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT, MASTE
--connection master
# Enable scheduler
SET @@global.event_scheduler=1;
+
--sync_slave_with_master
let $rcvd_heartbeats_before= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
-# Wait some updates for table t1 from master
-let $wait_condition= SELECT COUNT(*)=1 FROM t1 WHERE a > 5;
---source include/wait_condition.inc
+
+--connection master
+
+# Whether or not to send a heartbeat is decided on the master, based on
+# whether the binlog was updated during the period or not.
+# Even with the 1-second event, we cannot make the master to write binary
+# logs (or execute SQL) in a timely manner. We can only check that they
+# were executed in a timely manner, and if they were not, neutralize the
+# heartbeat check on the slave.
+# We will wait for 5 events, and keep checking 'Binlog_commits' on master.
+# Time interval between consequent events will be measured.
+# We can only expect that no heartbeats have been sent if the interval
+# between events never exceeded MASTER_HEARTBEAT_PERIOD.
+# If it has exceeded the value at least once, the slave can legitimately
+# receive a heartbeat (but we cannot require it, because the delay
+# could have occurred somewhere else, e.g. upon checking the status).
+# So, if the delay is detected, we will signal slave to ignore possible
+# heartbeats.
+
+let $possible_heartbeats= 0;
+let $commits_to_wait= 5;
+while ($commits_to_wait)
+{
+ let $tm= `SELECT UNIX_TIMESTAMP(NOW(3))`;
+ let $binlog_commits= query_get_value(SHOW STATUS LIKE 'Binlog_commits', Value, 1);
+ let $wait_condition= SELECT VARIABLE_VALUE > $binlog_commits FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME= 'BINLOG_COMMITS';
+ --source include/wait_condition.inc
+ dec $commits_to_wait;
+ if (`SELECT UNIX_TIMESTAMP(NOW(3)) > $tm + 5`)
+ {
+ let $possible_heartbeats= 1;
+ let $commits_to_wait= 0;
+ }
+}
+
+--connection slave
let $rcvd_heartbeats_after= query_get_value(SHOW STATUS LIKE 'slave_received_heartbeats', Value, 1);
-let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_before) > 0 AS Result, Result, 1);
---echo Number of received heartbeat events: $result
+let $result= `SELECT CASE WHEN $possible_heartbeats THEN 'TRUE' WHEN $rcvd_heartbeats_after - $rcvd_heartbeats_before > 0 THEN 'FALSE' ELSE 'TRUE' END`;
+--echo Received heartbeats meet expectations: $result
--connection master
DELETE FROM t1;
DROP EVENT e1;
--sync_slave_with_master
--echo
-
# Check received heartbeat events while logs flushed on slave
--echo *** Flush logs on slave ***
STOP SLAVE;
diff --git a/mysql-test/suite/sys_vars/t/secure_file_priv.test b/mysql-test/suite/sys_vars/t/secure_file_priv.test
index 5c53da58275..a5a465d8c98 100644
--- a/mysql-test/suite/sys_vars/t/secure_file_priv.test
+++ b/mysql-test/suite/sys_vars/t/secure_file_priv.test
@@ -21,6 +21,9 @@ SHOW VARIABLES LIKE 'secure_file_priv';
--perl
use File::Basename;
my $protected_file= dirname($ENV{MYSQLTEST_VARDIR}).'/bug50373.txt';
+# Ensure bug50373.txt does not exist (e.g. leftover from previous
+# test runs).
+unlink $protected_file;
open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/bug50373.inc") or die;
print FILE "SELECT * FROM t1 INTO OUTFILE '".$protected_file."';\n";
print FILE "DELETE FROM t1;\n";
diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result
index 934d047f6bf..6dee132b3e5 100644
--- a/mysql-test/suite/vcol/r/vcol_select_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result
@@ -295,3 +295,112 @@ Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1`
SELECT * FROM t1 NATURAL JOIN t2;
b a
DROP TABLE t1,t2;
+create table t1 (
+pk integer auto_increment,
+bi integer not null,
+vi integer generated always as (bi) persistent,
+bc varchar(1) not null,
+vc varchar(2) generated always as (concat(bc, bc)) persistent,
+primary key (pk),
+key (vi, vc));
+insert t1 (bi, bc) values (0, 'x'), (0, 'n'), (1, 'w'), (7, 's'), (0, 'a'), (4, 'd'), (1, 'w'), (1, 'j'), (1, 'm'), (4, 'k'), (7, 't'), (4, 'k'), (2, 'e'), (0, 'i'), (1, 't'), (6, 'z'), (3, 'c'), (6, 'i'), (8, 'v');
+create table t2 (
+pk integer auto_increment,
+bi integer not null,
+vi integer generated always as (bi) persistent,
+bc varchar(257) not null,
+vc varchar(2) generated always as (concat(bc, bc)) persistent,
+primary key (pk),
+key (vi, vc));
+insert t2 (bi, bc) values (1, 'c'), (8, 'm'), (9, 'd'), (6, 'y'), (1, 't'), (6, 'd'), (2, 's'), (4, 'r'), (8, 'm'), (4, 'b'), (4, 'x'), (7, 'g'), (4, 'p'), (1, 'q'), (9, 'w'), (4, 'd'), (8, 'e'), (4, 'b'), (8, 'y');
+explain # should be using join buffer
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL vi 10 NULL 19 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 19 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 index NULL PRIMARY 4 NULL 19 Using where; Using index; Using join buffer (incremental, BNL join)
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+vi
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+2
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+4
+6
+6
+6
+6
+7
+7
+8
+8
+8
+8
+9
+9
+drop table t2,t1;
diff --git a/mysql-test/suite/vcol/t/vcol_select_myisam.test b/mysql-test/suite/vcol/t/vcol_select_myisam.test
index c14faba576d..b392b74c2d9 100644
--- a/mysql-test/suite/vcol/t/vcol_select_myisam.test
+++ b/mysql-test/suite/vcol/t/vcol_select_myisam.test
@@ -68,3 +68,35 @@ SELECT * FROM t1 NATURAL JOIN t2;
SELECT * FROM t1 NATURAL JOIN t2;
DROP TABLE t1,t2;
+
+#
+# MDEV-11525 Assertion `cp + len <= buff + buff_size' failed in JOIN_CACHE::write_record_data
+#
+
+create table t1 (
+ pk integer auto_increment,
+ bi integer not null,
+ vi integer generated always as (bi) persistent,
+ bc varchar(1) not null,
+ vc varchar(2) generated always as (concat(bc, bc)) persistent,
+ primary key (pk),
+ key (vi, vc));
+insert t1 (bi, bc) values (0, 'x'), (0, 'n'), (1, 'w'), (7, 's'), (0, 'a'), (4, 'd'), (1, 'w'), (1, 'j'), (1, 'm'), (4, 'k'), (7, 't'), (4, 'k'), (2, 'e'), (0, 'i'), (1, 't'), (6, 'z'), (3, 'c'), (6, 'i'), (8, 'v');
+create table t2 (
+ pk integer auto_increment,
+ bi integer not null,
+ vi integer generated always as (bi) persistent,
+ bc varchar(257) not null,
+ vc varchar(2) generated always as (concat(bc, bc)) persistent,
+ primary key (pk),
+ key (vi, vc));
+insert t2 (bi, bc) values (1, 'c'), (8, 'm'), (9, 'd'), (6, 'y'), (1, 't'), (6, 'd'), (2, 's'), (4, 'r'), (8, 'm'), (4, 'b'), (4, 'x'), (7, 'g'), (4, 'p'), (1, 'q'), (9, 'w'), (4, 'd'), (8, 'e'), (4, 'b'), (8, 'y');
+explain # should be using join buffer
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+--sorted_result
+select t2.vi from (t2 as t3 right join (t2 left join t1 on (t1.bi = t2.vi)) on (t1.vc = t2.vc));
+drop table t2,t1;
+
+#
+# End of 5.5 tests
+#
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index b517dfd29d1..28e48bf03c0 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -875,4 +875,27 @@ 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
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 548fd0f810e..0be4c254269 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -2176,6 +2176,68 @@ DROP USER mysqltest_u1@localhost;
--echo # End of Bug#38347.
--echo
+
+--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;
+
+
+--echo #
+--echo # Bug#12766319 - 61865: RENAME USER DOES NOT WORK CORRECTLY -
+--echo # REQUIRES FLUSH PRIVILEGES
+--echo #
+
+CREATE USER foo@'127.0.0.1';
+GRANT ALL ON *.* TO foo@'127.0.0.1';
+
+--echo # First attempt, should connect successfully
+connect (conn1, '127.0.0.1', foo,,test);
+SELECT user(), current_user();
+
+--echo # Rename the user
+RENAME USER foo@'127.0.0.1' to foo@'127.0.0.0/255.0.0.0';
+
+--echo # Second attempt, should connect successfully as its valid mask
+--echo # This was failing without fix
+connect (conn2, '127.0.0.1', foo,,test);
+SELECT user(), current_user();
+
+--echo # Rename the user back to original
+RENAME USER foo@'127.0.0.0/255.0.0.0' to foo@'127.0.0.1';
+
+--echo # Third attempt, should connect successfully
+connect (conn3, '127.0.0.1', foo,,test);
+SELECT user(), current_user();
+
+--echo # Clean-up
+connection default;
+disconnect conn1;
+disconnect conn2;
+disconnect conn3;
+DROP USER foo@'127.0.0.1';
+
+--echo # End of Bug#12766319
+
+
--echo #
--echo # Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS
--echo # DATABASE SECURITY
@@ -2210,26 +2272,3 @@ DROP DATABASE secret;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
-
---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;
diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test
index 7b7d9236835..e60b7827f75 100644
--- a/mysql-test/t/join_nested.test
+++ b/mysql-test/t/join_nested.test
@@ -1309,5 +1309,74 @@ LEFT JOIN t4 AS alias5
JOIN t5 ON alias5.f5
ON alias2.f3 ON alias1.f2;
DROP TABLE t1,t2,t3,t4,t5;
-set optimizer_search_depth= @tmp_mdev621;
+--echo #
+--echo # MDEV-7992: Nested left joins + 'not exists' optimization
+--echo #
+
+CREATE TABLE t1(
+ K1 INT PRIMARY KEY,
+ Name VARCHAR(15)
+);
+
+INSERT INTO t1 VALUES
+ (1,'T1Row1'), (2,'T1Row2');
+
+
+CREATE TABLE t2(
+ K2 INT PRIMARY KEY,
+ K1r INT,
+ rowTimestamp DATETIME,
+ Event VARCHAR(15)
+);
+
+INSERT INTO t2 VALUES
+ (1, 1, '2015-04-13 10:42:11' ,'T1Row1Event1'),
+ (2, 1, '2015-04-13 10:42:12' ,'T1Row1Event2'),
+ (3, 1, '2015-04-13 10:42:12' ,'T1Row1Event3');
+
+let $q1=
+SELECT t1a.*, t2a.*,
+ t2i.K2 AS K2B, t2i.K1r AS K1rB,
+ t2i.rowTimestamp AS rowTimestampB, t2i.Event AS EventB
+FROM
+ t1 t1a JOIN t2 t2a ON t2a.K1r = t1a.K1
+ LEFT JOIN
+ ( t1 t1i LEFT JOIN t2 t2i ON t2i.K1r = t1i.K1)
+ ON (t1i.K1 = 1) AND
+ (((t2i.K1r = t1a.K1 AND t2i.rowTimestamp > t2a.rowTimestamp ) OR
+ (t2i.rowTimestamp = t2a.rowTimestamp AND t2i.K2 > t2a.K2))
+ OR (t2i.K2 IS NULL))
+WHERE
+t2a.K1r = 1 AND t2i.K2 IS NULL;
+
+eval $q1;
+eval EXPLAIN EXTENDED $q1;
+
+CREATE VIEW v1 AS
+ SELECT t2i.*
+ FROM t1 as t1i LEFT JOIN t2 as t2i ON t2i.K1r = t1i.K1
+ WHERE t1i.K1 = 1 ;
+
+let $q2=
+SELECT
+ t1a.*, t2a.*, t2b.K2 as K2B, t2b.K1r as K1rB,
+ t2b.rowTimestamp as rowTimestampB, t2b.Event as EventB
+FROM
+ t1 as t1a JOIN t2 as t2a ON t2a.K1r = t1a.K1
+ LEFT JOIN
+ v1 as t2b
+ ON ((t2b.K1r = t1a.K1 AND t2b.rowTimestamp > t2a.rowTimestamp) OR
+ (t2b.rowTimestamp = t2a.rowTimestamp AND t2b.K2 > t2a.K2))
+ OR (t2b.K2 IS NULL)
+WHERE
+ t1a.K1 = 1 AND
+ t2b.K2 IS NULL;
+
+eval $q2;
+eval EXPLAIN EXTENDED $q2;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
+set optimizer_search_depth= @tmp_mdev621;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index fd50896b71f..708ed25f89c 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -2512,3 +2512,11 @@ if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Wind
}
--exec $MYSQL_DUMP --routines --compact $shell_ready_db_name
DROP DATABASE `a\"'``b`;
+
+#"
+# 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 --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index 6845cca10fb..f6faa4cb0e6 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -820,6 +820,104 @@ INSERT INTO t1 (d) VALUES ('1991-01-01');
SELECT * FROM t1 WHERE d = '1991-01-01';
DROP TABLE t1;
+set global default_storage_engine=default;
+
+--echo #
+--echo # MDEV-9455: [ERROR] mysqld got signal 11
+--echo #
+
+CREATE TABLE `t1` (
+ `DIARY_TOTAL_DAY_SEQ` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `IMORY_ID` bigint(20) NOT NULL,
+ `NAME` varchar(75) DEFAULT NULL,
+ `DATETIME` varchar(10) NOT NULL DEFAULT '',
+ `DAILY_CALL_CNT` int(11) DEFAULT NULL,
+ `DAILY_SMS_CNT` int(11) DEFAULT NULL,
+ `NUMBER` varchar(64) DEFAULT NULL,
+ `DURATION` varchar(16) DEFAULT NULL,
+ PRIMARY KEY (`DIARY_TOTAL_DAY_SEQ`,`DATETIME`),
+ KEY `IDX_t1_01` (`IMORY_ID`,`DATETIME`)
+) AUTO_INCREMENT=328702514 DEFAULT CHARSET=utf8mb4
+PARTITION BY RANGE COLUMNS(`DATETIME`)
+(PARTITION p0 VALUES LESS THAN ('2015-10-01') ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN ('2015-11-01') ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN ('2015-12-01') ENGINE = InnoDB,
+ PARTITION p3 VALUES LESS THAN ('2016-01-01') ENGINE = InnoDB,
+ PARTITION p4 VALUES LESS THAN ('2016-02-01') ENGINE = InnoDB,
+ PARTITION p5 VALUES LESS THAN ('2016-03-01') ENGINE = InnoDB,
+ PARTITION p6 VALUES LESS THAN ('2016-04-01') ENGINE = InnoDB,
+ PARTITION p7 VALUES LESS THAN ('2016-05-01') ENGINE = InnoDB,
+ PARTITION p8 VALUES LESS THAN ('2016-06-01') ENGINE = InnoDB,
+ PARTITION p9 VALUES LESS THAN ('2016-07-01') ENGINE = InnoDB,
+ PARTITION p10 VALUES LESS THAN ('2016-08-01') ENGINE = InnoDB)
+;
+
+CREATE TABLE `t2` (
+ `DIARY_SEQ` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `IMORY_ID` bigint(20) NOT NULL,
+ `CALL_TYPE` varchar(1) DEFAULT NULL,
+ `DATA_TYPE` varchar(1) DEFAULT NULL,
+ `FEATURES` varchar(1) DEFAULT NULL,
+ `NAME` varchar(75) DEFAULT NULL,
+ `NUMBER` varchar(64) DEFAULT NULL,
+ `DATETIME` datetime NOT NULL,
+ `REG_DATE` datetime NOT NULL,
+ `TITLE` varchar(50) DEFAULT NULL,
+ `BODY` varchar(4200) DEFAULT NULL,
+ `MIME_TYPE` varchar(32) DEFAULT NULL,
+ `DURATION` varchar(16) DEFAULT NULL,
+ `DEVICE_ID` varchar(64) DEFAULT NULL,
+ `DEVICE_NAME` varchar(32) DEFAULT NULL,
+ PRIMARY KEY (`DIARY_SEQ`,`DATETIME`,`REG_DATE`),
+ KEY `IDX_TB_DIARY_01` (`IMORY_ID`,`DATETIME`,`CALL_TYPE`,`NUMBER`),
+ KEY `IDX_TB_DIARY_02` (`REG_DATE`)
+) AUTO_INCREMENT=688799006 DEFAULT CHARSET=utf8mb4
+PARTITION BY RANGE COLUMNS(REG_DATE)
+(PARTITION p0 VALUES LESS THAN ('2015-10-01') ENGINE = InnoDB,
+ PARTITION p1 VALUES LESS THAN ('2015-11-01') ENGINE = InnoDB,
+ PARTITION p2 VALUES LESS THAN ('2015-12-01') ENGINE = InnoDB,
+ PARTITION p3 VALUES LESS THAN ('2016-01-01') ENGINE = InnoDB,
+ PARTITION p4 VALUES LESS THAN ('2016-02-01') ENGINE = InnoDB,
+ PARTITION p5 VALUES LESS THAN ('2016-03-01') ENGINE = InnoDB,
+ PARTITION p6 VALUES LESS THAN ('2016-04-01') ENGINE = InnoDB,
+ PARTITION p7 VALUES LESS THAN ('2016-05-01') ENGINE = InnoDB,
+ PARTITION p8 VALUES LESS THAN ('2016-06-01') ENGINE = InnoDB,
+ PARTITION p9 VALUES LESS THAN ('2016-07-01') ENGINE = InnoDB,
+ PARTITION p10 VALUES LESS THAN ('2016-08-01') ENGINE = InnoDB)
+;
+
+SELECT
+ A.IMORY_ID,
+ A.NUMBER,
+ A.NAME,
+ DATE_FORMAT(A.DATETIME, '%Y-%m-%d') AS TARGET_DATE,
+ SUM( CASE WHEN A.DATA_TYPE='1' THEN 1 ELSE 0 END) AS CALL_CNT,
+ SUM( CASE WHEN A.DATA_TYPE IN ('2', '3') THEN 1 ELSE 0 END) AS SMS_CNT,
+ SUM(CAST(A.DURATION AS INT)) AS DURATION,
+ ( SELECT COUNT(*)
+ FROM t1
+ WHERE IMORY_ID=A.IMORY_ID
+ AND NUMBER=A.NUMBER
+ AND NAME=A.NAME
+ AND DATETIME = DATE_FORMAT(A.DATETIME, '%Y-%m-%d')
+ ) STATS_COUNT
+FROM t2 A
+WHERE A.IMORY_ID = 55094102
+ AND A.DATETIME LIKE (
+ SELECT CONCAT (DATE_FORMAT(DATETIME, '%Y-%m-%d') ,'%')
+ FROM t2
+ WHERE IMORY_ID=55094102
+ AND DIARY_SEQ IN ( 608351221, 608351225, 608351229 )
+ group by DATE_FORMAT(DATETIME, '%Y-%m-%d')
+ )
+GROUP BY A.IMORY_ID, A.NUMBER, A.NAME, DATE_FORMAT(A.DATETIME, '%Y-%m-%d')
+;
+
+drop table t2, t1;
+
+
+set global default_storage_engine='innodb';
+
--echo #
--echo # MDEV-5963: InnoDB: Assertion failure in file row0sel.cc line 2503,
--echo # Failing assertion: 0 with "key ptr now exceeds key end by 762 bytes"
diff --git a/mysql-test/t/partition_myisam.test b/mysql-test/t/partition_myisam.test
index d07637057e0..4d083c37b68 100644
--- a/mysql-test/t/partition_myisam.test
+++ b/mysql-test/t/partition_myisam.test
@@ -216,6 +216,28 @@ PARTITION BY RANGE (a)
PARTITION pMax VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (1, "Partition p1, first row");
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-10418 Assertion `m_extra_cache' failed
+--echo # in ha_partition::late_extra_cache(uint)
+--echo #
+
+CREATE TABLE t1 (f1 INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2 (f2 INT) ENGINE=MyISAM PARTITION BY RANGE(f2) (PARTITION pmax VALUES LESS THAN MAXVALUE);
+INSERT INTO t2 VALUES (8);
+
+CREATE ALGORITHM = MERGE VIEW v AS SELECT f2 FROM t2, t1;
+
+UPDATE v SET f2 = 1;
+
+SELECT * FROM t2;
+
+DROP VIEW v;
+DROP TABLE t2;
+DROP TABLE t1;
+
--echo #
--echo # bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED
--echo # TABLE CORRUPTS MYISAM
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index a6b238b84c6..d7ca29083b5 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -3680,5 +3680,38 @@ EXECUTE stmt;
deallocate prepare stmt;
drop table t1,t2,t3,t4;
+--echo #
+--echo # MDEV-11859: the plans for the first and the second executions
+--echo # of PS are not the same
+--echo #
+
+create table t1 (id int, c varchar(3), key idx(c))engine=myisam;
+insert into t1 values (3,'bar'), (1,'xxx'), (2,'foo'), (5,'yyy');
+
+prepare stmt1 from
+"explain extended
+ select * from t1 where (1, 2) in ( select 3, 4 ) or c = 'foo'";
+execute stmt1;
+execute stmt1;
+deallocate prepare stmt1;
+
+prepare stmt1 from
+"select * from t1 where (1, 2) in ( select 3, 4 ) or c = 'foo'";
+flush status;
+execute stmt1;
+show status like '%Handler_read%';
+flush status;
+execute stmt1;
+show status like '%Handler_read%';
+deallocate prepare stmt1;
+
+prepare stmt2 from
+"explain extended
+ select * from t1 where (1, 2) in ( select 3, 4 )";
+execute stmt2;
+execute stmt2;
+deallocate prepare stmt2;
+
+drop table t1;
--echo # End of 5.5 tests
diff --git a/mysql-test/t/range_vs_index_merge.test b/mysql-test/t/range_vs_index_merge.test
index 7ecca454f4c..5d12d46c9e9 100644
--- a/mysql-test/t/range_vs_index_merge.test
+++ b/mysql-test/t/range_vs_index_merge.test
@@ -57,9 +57,9 @@ SELECT * FROM City
EXPLAIN
SELECT * FROM City
WHERE Population > 100000 AND Name LIKE 'Aba%' OR
- Country IN ('CAN', 'ARG') AND ID < 3800 OR
- Country < 'U' AND Name LIKE 'Zhu%' OR
- ID BETWEEN 3800 AND 3810;
+ Country IN ('CAN', 'ARG') AND ID BETWEEN 120 AND 130 OR
+ Country <= 'ALB' AND Name LIKE 'L%' OR
+ ID BETWEEN 3807 AND 3810;
# The output of the next 3 commands tells us about selectivities
# of the conditions utilized in 2 queries following after them
@@ -1206,6 +1206,41 @@ SELECT * FROM t1
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-8603: Wrong result OR/AND condition over index fields
+--echo #
+
+CREATE TABLE t1 (
+ id INT NOT NULL,
+ state VARCHAR(64),
+ capital VARCHAR(64),
+ UNIQUE KEY (id),
+ KEY state (state,id),
+ KEY capital (capital, id)
+);
+
+INSERT INTO t1 VALUES
+ (1,'Arizona','Phoenix'),
+ (2,'Hawaii','Honolulu'),
+ (3,'Georgia','Atlanta'),
+ (4,'Florida','Tallahassee'),
+ (5,'Alaska','Juneau'),
+ (6,'Michigan','Lansing'),
+ (7,'Pennsylvania','Harrisburg'),
+ (8,'Virginia','Richmond')
+;
+
+EXPLAIN
+SELECT * FROM t1 FORCE KEY (state,capital)
+WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
+ OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
+SELECT * FROM t1 FORCE KEY (state,capital)
+WHERE ( state = 'Alabama' OR state >= 'Colorado' ) AND id != 9
+ OR ( capital >= 'Topeka' OR state = 'Kansas' ) AND state != 'Texas';
+
+DROP TABLE t1;
+
#the following command must be the last one in the file
set session optimizer_switch='index_merge_sort_intersection=default';
diff --git a/mysql-test/t/repair_symlink-5543.test b/mysql-test/t/repair_symlink-5543.test
index bad65a4175a..6bdf72b4d40 100644
--- a/mysql-test/t/repair_symlink-5543.test
+++ b/mysql-test/t/repair_symlink-5543.test
@@ -9,7 +9,7 @@
eval create table t1 (a int) engine=myisam data directory='$MYSQL_TMP_DIR';
insert t1 values (1);
--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t1.TMD
---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+--replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/
repair table t1;
drop table t1;
@@ -17,7 +17,7 @@ drop table t1;
eval create table t2 (a int) engine=aria data directory='$MYSQL_TMP_DIR';
insert t2 values (1);
--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t2.TMD
---replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
+--replace_regex / '.*\/t2/ 'MYSQL_TMP_DIR\/t2/
repair table t2;
drop table t2;
diff --git a/mysql-test/t/symlink-aria-11902.test b/mysql-test/t/symlink-aria-11902.test
new file mode 100644
index 00000000000..a2a266cbb25
--- /dev/null
+++ b/mysql-test/t/symlink-aria-11902.test
@@ -0,0 +1,6 @@
+#
+# MDEV-11902 mi_open race condition
+#
+source include/have_maria.inc;
+set default_storage_engine=Aria;
+source symlink-myisam-11902.test;
diff --git a/mysql-test/t/symlink-myisam-11902.test b/mysql-test/t/symlink-myisam-11902.test
new file mode 100644
index 00000000000..7e35ad117d0
--- /dev/null
+++ b/mysql-test/t/symlink-myisam-11902.test
@@ -0,0 +1,60 @@
+#
+# MDEV-11902 mi_open race condition
+#
+source include/have_debug_sync.inc;
+source include/have_symlink.inc;
+source include/not_windows.inc;
+call mtr.add_suppression("File.*t1.* not found");
+
+create table mysql.t1 (a int, b char(16), index(a));
+insert mysql.t1 values (100, 'test'),(101,'test');
+let $datadir=`select @@datadir`;
+
+exec mkdir $MYSQLTEST_VARDIR/tmp/foo;
+replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR;
+eval create table t1 (a int, b char(16), index(a))
+ data directory="$MYSQLTEST_VARDIR/tmp/foo";
+insert t1 values (200, 'some'),(201,'some');
+select * from t1;
+flush tables;
+set debug_sync='mi_open_datafile SIGNAL ok WAIT_FOR go';
+send select * from t1;
+connect con1, localhost, root;
+set debug_sync='now WAIT_FOR ok';
+exec rm -r $MYSQLTEST_VARDIR/tmp/foo;
+exec ln -s $datadir/mysql $MYSQLTEST_VARDIR/tmp/foo;
+set debug_sync='now SIGNAL go';
+connection default;
+replace_regex / '.*\/tmp\// 'MYSQLTEST_VARDIR\/tmp\// /31/20/;
+error 29;
+reap;
+flush tables;
+drop table if exists t1;
+exec rm -r $MYSQLTEST_VARDIR/tmp/foo;
+
+# same with INDEX DIRECTORY
+exec mkdir $MYSQLTEST_VARDIR/tmp/foo;
+replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR;
+eval create table t1 (a int, b char(16), index (a))
+ index directory="$MYSQLTEST_VARDIR/tmp/foo";
+insert t1 values (200, 'some'),(201,'some');
+explain select a from t1;
+select a from t1;
+flush tables;
+set debug_sync='mi_open_kfile SIGNAL waiting WAIT_FOR run';
+send select a from t1;
+connection con1;
+set debug_sync='now WAIT_FOR waiting';
+exec rm -r $MYSQLTEST_VARDIR/tmp/foo;
+exec ln -s $datadir/mysql $MYSQLTEST_VARDIR/tmp/foo;
+set debug_sync='now SIGNAL run';
+connection default;
+replace_regex / '.*\/tmp\// 'MYSQLTEST_VARDIR\/tmp\// /31/20/;
+error ER_FILE_NOT_FOUND;
+reap;
+flush tables;
+drop table if exists t1;
+exec rm -r $MYSQLTEST_VARDIR/tmp/foo;
+
+drop table mysql.t1;
+set debug_sync='RESET';
diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test
index 24f48206013..717aecb42e2 100644
--- a/mysql-test/t/table_elim.test
+++ b/mysql-test/t/table_elim.test
@@ -534,12 +534,12 @@ INSERT IGNORE INTO t1 VALUES (0,'g');
CREATE TABLE t3 ( a varchar(1)) ;
INSERT IGNORE INTO t3 VALUES ('g');
-CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a)) ;
+CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a));
+INSERT INTO t2 VALUES (9), (10);
create view v1 as SELECT t1.* FROM t1 LEFT JOIN t2 ON ( t1.a = t2.a ) WHERE t2.a <> 0;
SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
EXPLAIN SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
-
drop view v1;
DROP TABLE t1,t2,t3;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 5ea97f6465e..630c247e85b 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -5505,6 +5505,66 @@ SHOW CREATE VIEW v1;
drop view v1;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-12099: usage of mergeable view with LEFT JOIN
+--echo # that can be converted to INNER JOIN
+--echo #
+
+create table t1 (a int, b int, key(a)) engine=myisam;
+insert into t1 values
+ (3,20), (7,10), (2,10), (4,30), (8,70),
+ (7,70), (9,100), (9,60), (8,80), (7,60);
+
+create table t2 (c int, d int, key (c)) engine=myisam;
+insert into t2 values
+ (50,100), (20, 200), (10,300),
+ (150,100), (120, 200), (110,300),
+ (250,100), (220, 200), (210,300);
+
+create table t3(e int, f int not null, key(e), unique (f)) engine=myisam;
+insert into t3 values
+ (100, 3), (300, 5), (400, 4), (300,7),
+ (300,2), (600, 13), (800, 15), (700, 14),
+ (600, 23), (800, 25), (700, 24);
+
+create view v1 as
+ select * from t2 left join t3 on t3.e=t2.d where t3.f is not null;
+
+select *
+ from t1 left join v1 on v1.c=t1.b
+ where t1.a < 5;
+
+select *
+ from t1 left join ( t2 left join t3 on t3.e=t2.d )
+ on t2.c=t1.b and t3.f is not null
+ where t1.a < 5;
+
+explain extended
+select *
+ from t1 left join v1 on v1.c=t1.b
+ where t1.a < 5;
+
+explain extended
+select *
+ from t1 left join ( t2 left join t3 on t3.e=t2.d )
+ on t2.c=t1.b and t3.f is not null
+ where t1.a < 5;
+
+explain extended
+select *
+ from t1 left join v1 on v1.c=t1.b and v1.f=t1.a
+ where t1.a < 5;
+
+explain extended
+select *
+ from t1 left join ( t2 left join t3 on t3.e=t2.d )
+ on t2.c=t1.b and t3.f=t1.a and t3.f is not null
+ where t1.a < 5;
+
+drop view v1;
+drop table t1,t2,t3;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests.
--echo # -----------------------------------------------------------------
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index cbc9493e385..e6aa030859f 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -1144,6 +1144,17 @@
...
fun:pthread_create*
}
+<<<<<<< HEAD
+
+{
+ Memory Leak in loader and valgrind malloc
+ Memcheck:Leak
+ match-leak-kinds:reachable
+ obj:*/vgpreload_memcheck*.so
+ ...
+ obj:*/ld-*.so
+ ...
+}
{
ConnectSE: unixODBC SQLAllocEnv leaves some "still reachable" pointers
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index 91354db0b64..6672a4386e4 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -97,13 +97,8 @@ char * fn_format(char * to, const char *name, const char *dir,
pos=strmake(strmov(to,dev),name,length);
(void) strmov(pos,ext); /* Don't convert extension */
}
- /*
- If MY_RETURN_REAL_PATH and MY_RESOLVE_SYMLINK is given, only do
- realpath if the file is a symbolic link
- */
if (flag & MY_RETURN_REAL_PATH)
- (void) my_realpath(to, to, MYF(flag & MY_RESOLVE_SYMLINKS ?
- MY_RESOLVE_LINK: 0));
+ (void) my_realpath(to, to, MYF(0));
else if (flag & MY_RESOLVE_SYMLINKS)
{
strmov(buff,to);
diff --git a/mysys/my_create.c b/mysys/my_create.c
index 51de343d4a1..32ad3d44a7a 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -36,7 +36,7 @@
File my_create(const char *FileName, int CreateFlags, int access_flags,
myf MyFlags)
{
- int fd, rc;
+ int fd;
DBUG_ENTER("my_create");
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %lu",
FileName, CreateFlags, access_flags, MyFlags));
@@ -54,21 +54,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
fd= -1;
}
- rc= my_register_filename(fd, FileName, FILE_BY_CREATE,
+ fd= my_register_filename(fd, FileName, FILE_BY_CREATE,
EE_CANTCREATEFILE, MyFlags);
- /*
- my_register_filename() may fail on some platforms even if the call to
- *open() above succeeds. In this case, don't leave the stale file because
- callers assume the file to not exist if my_create() fails, so they don't
- do any cleanups.
- */
- if (unlikely(fd >= 0 && rc < 0))
- {
- int tmp= my_errno;
- my_close(fd, MyFlags);
- my_delete(FileName, MyFlags);
- my_errno= tmp;
- }
-
- DBUG_RETURN(rc);
+ DBUG_RETURN(fd);
} /* my_create */
diff --git a/mysys/my_delete.c b/mysys/my_delete.c
index 3dfe290dabe..0faf6079d98 100644
--- a/mysys/my_delete.c
+++ b/mysys/my_delete.c
@@ -21,6 +21,12 @@
static int my_win_unlink(const char *name);
#endif
+CREATE_NOSYMLINK_FUNCTION(
+ unlink_nosymlinks(const char *pathname),
+ unlinkat(dfd, filename, 0),
+ unlink(pathname)
+);
+
int my_delete(const char *name, myf MyFlags)
{
int err;
@@ -30,7 +36,10 @@ int my_delete(const char *name, myf MyFlags)
#ifdef _WIN32
err = my_win_unlink(name);
#else
- err = unlink(name);
+ if (MyFlags & MY_NOSYMLINKS)
+ err= unlink_nosymlinks(name);
+ else
+ err= unlink(name);
#endif
if(err)
diff --git a/mysys/my_div.c b/mysys/my_div.c
index 660b87e5ab4..44eb5392421 100644
--- a/mysys/my_div.c
+++ b/mysys/my_div.c
@@ -27,7 +27,7 @@
char * my_filename(File fd)
{
DBUG_ENTER("my_filename");
- if ((uint) fd >= (uint) my_file_limit)
+ if ((uint) fd >= (uint) my_file_limit || !my_file_info[fd].name)
DBUG_RETURN((char*) "UNKNOWN");
if (fd >= 0 && my_file_info[fd].type != UNOPEN)
{
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index b6027a99c90..4f14bc5aaef 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -69,19 +69,13 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
DBUG_RETURN(fd); /* safeguard */
}
mysql_mutex_lock(&THR_LOCK_open);
- if ((my_file_info[filedesc].name= (char*)
- my_strdup(filename,MyFlags)))
- {
- my_stream_opened++;
- my_file_total_opened++;
- my_file_info[filedesc].type= STREAM_BY_FOPEN;
- mysql_mutex_unlock(&THR_LOCK_open);
- DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
- DBUG_RETURN(fd);
- }
+ my_file_info[filedesc].name= (char*) my_strdup(filename,MyFlags);
+ my_stream_opened++;
+ my_file_total_opened++;
+ my_file_info[filedesc].type= STREAM_BY_FOPEN;
mysql_mutex_unlock(&THR_LOCK_open);
- (void) my_fclose(fd,MyFlags);
- my_errno=ENOMEM;
+ DBUG_PRINT("exit",("stream: 0x%lx", (long) fd));
+ DBUG_RETURN(fd);
}
else
my_errno=errno;
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 2c06425f6fb..dee41e1202a 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -227,7 +227,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n",
/* At very last, delete mysys key, it is used everywhere including DBUG */
pthread_key_delete(THR_KEY_mysys);
- my_init_done=0;
+ my_init_done= my_thr_key_mysys_exists= 0;
} /* my_end */
#ifndef DBUG_OFF
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 5263ba4b5c8..b1327a316e9 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -15,9 +15,14 @@
#include "mysys_priv.h"
#include "mysys_err.h"
-#include <my_dir.h>
+#include <m_string.h>
#include <errno.h>
+CREATE_NOSYMLINK_FUNCTION(
+ open_nosymlinks(const char *pathname, int flags, int mode),
+ openat(dfd, filename, O_NOFOLLOW | flags, mode),
+ open(pathname, O_NOFOLLOW | flags, mode)
+);
/*
Open a file
@@ -45,10 +50,11 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
MyFlags|= my_global_flags;
#if defined(_WIN32)
fd= my_win_open(FileName, Flags);
-#elif !defined(NO_OPEN_3)
- fd = open(FileName, Flags, my_umask); /* Normal unix */
#else
- fd = open((char *) FileName, Flags);
+ if (MyFlags & MY_NOSYMLINKS)
+ fd = open_nosymlinks(FileName, Flags, my_umask);
+ else
+ fd = open(FileName, Flags, my_umask);
#endif
fd= my_register_filename(fd, FileName, FILE_BY_OPEN,
@@ -131,25 +137,16 @@ File my_register_filename(File fd, const char *FileName, enum file_type
thread_safe_increment(my_file_opened,&THR_LOCK_open);
DBUG_RETURN(fd); /* safeguard */
}
- else
- {
- mysql_mutex_lock(&THR_LOCK_open);
- if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags)))
- {
- my_file_opened++;
- my_file_total_opened++;
- my_file_info[fd].type = type_of_file;
- mysql_mutex_unlock(&THR_LOCK_open);
- DBUG_PRINT("exit",("fd: %d",fd));
- DBUG_RETURN(fd);
- }
- mysql_mutex_unlock(&THR_LOCK_open);
- my_errno= ENOMEM;
- }
- (void) my_close(fd, MyFlags);
+ mysql_mutex_lock(&THR_LOCK_open);
+ my_file_info[fd].name = (char*) my_strdup(FileName, MyFlags);
+ my_file_opened++;
+ my_file_total_opened++;
+ my_file_info[fd].type = type_of_file;
+ mysql_mutex_unlock(&THR_LOCK_open);
+ DBUG_PRINT("exit",("fd: %d",fd));
+ DBUG_RETURN(fd);
}
- else
- my_errno= errno;
+ my_errno= errno;
DBUG_PRINT("error",("Got error %d on open", my_errno));
if (MyFlags & (MY_FFNF | MY_FAE | MY_WME))
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index b0e910f7ba0..ed35fff41e9 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2001, 2011, Oracle and/or its affiliates
+ Copyright (c) 2010, 2017, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,6 +24,14 @@
#include <sys/stat.h>
#endif
+static int always_valid(const char *filename __attribute__((unused)))
+{
+ return 0;
+}
+
+int (*mysys_test_invalid_symlink)(const char *filename)= always_valid;
+
+
/*
Reads the content of a symbolic link
If the file is not a symbolic link, return the original file name in to.
@@ -168,3 +177,78 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
#endif
return 0;
}
+
+#ifdef HAVE_OPEN_PARENT_DIR_NOSYMLINKS
+/** opens the parent dir. walks the path, and does not resolve symlinks
+
+ returns the pointer to the file name (basename) within the pathname
+ or NULL in case of an error
+
+ stores the parent dir (dirname) file descriptor in pdfd.
+ It can be -1 even if there was no error!
+
+ This is used for symlinked tables for DATA/INDEX DIRECTORY.
+ The paths there have been realpath()-ed. So, we can assume here that
+
+ * `pathname` is an absolute path
+ * no '.', '..', and '//' in the path
+ * file exists
+*/
+
+const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd)
+{
+ char buf[PATH_MAX+1];
+ char *s= buf, *e= buf+1, *end= strnmov(buf, pathname, sizeof(buf));
+ int fd, dfd= -1;
+
+ if (*end)
+ {
+ errno= ENAMETOOLONG;
+ return NULL;
+ }
+
+ if (*s != '/') /* not an absolute path */
+ {
+ errno= ENOENT;
+ return NULL;
+ }
+
+ for (;;)
+ {
+ if (*e == '/') /* '//' in the path */
+ {
+ errno= ENOENT;
+ goto err;
+ }
+ while (*e && *e != '/')
+ e++;
+ *e= 0;
+
+ if (!memcmp(s, ".", 2) || !memcmp(s, "..", 3))
+ {
+ errno= ENOENT;
+ goto err;
+ }
+
+ if (++e >= end)
+ {
+ *pdfd= dfd;
+ return pathname + (s - buf);
+ }
+
+ fd = openat(dfd, s, O_NOFOLLOW | O_PATH);
+ if (fd < 0)
+ goto err;
+
+ if (dfd >= 0)
+ close(dfd);
+
+ dfd= fd;
+ s= e;
+ }
+err:
+ if (dfd >= 0)
+ close(dfd);
+ return NULL;
+}
+#endif
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c
index fcaf78ccff6..defcb5962d8 100644
--- a/mysys/my_symlink2.c
+++ b/mysys/my_symlink2.c
@@ -92,27 +92,6 @@ File my_create_with_symlink(const char *linkname, const char *filename,
}
/*
- If the file was a symlink, delete both symlink and the file which the
- symlink pointed to.
-*/
-
-int my_delete_with_symlink(const char *name, myf MyFlags)
-{
- char link_name[FN_REFLEN];
- int was_symlink= (!my_disable_symlinks &&
- !my_readlink(link_name, name, MYF(0)));
- int result;
- DBUG_ENTER("my_delete_with_symlink");
-
- if (!(result=my_delete(name, MyFlags)))
- {
- if (was_symlink)
- result=my_delete(link_name, MyFlags);
- }
- DBUG_RETURN(result);
-}
-
-/*
If the file is a normal file, just rename it.
If the file is a symlink:
- Create a new file with the name 'to' that points at
@@ -182,3 +161,31 @@ int my_rename_with_symlink(const char *from, const char *to, myf MyFlags)
DBUG_RETURN(result);
#endif /* HAVE_READLINK */
}
+
+/** delete a - possibly symlinked - table file
+
+ This is used to delete a file that is part of a table (e.g. MYI or MYD
+ file of MyISAM) when dropping a table. A file might be a symlink -
+ if the table was created with DATA DIRECTORY or INDEX DIRECTORY -
+ in this case both the symlink and the symlinked file are deleted,
+ but only if the symlinked file is not in the datadir.
+*/
+int my_handler_delete_with_symlink(PSI_file_key key, const char *name,
+ const char *ext, myf sync_dir)
+{
+ char orig[FN_REFLEN], real[FN_REFLEN];
+ int res= 0;
+ DBUG_ENTER("my_handler_delete_with_symlink");
+
+ fn_format(orig, name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
+ if (my_is_symlink(orig))
+ {
+ /*
+ Delete the symlinked file only if the symlink is not
+ pointing into datadir.
+ */
+ if (!(my_realpath(real, orig, MYF(0)) || mysys_test_invalid_symlink(real)))
+ res= mysql_file_delete(key, real, MYF(MY_NOSYMLINKS | sync_dir));
+ }
+ DBUG_RETURN(mysql_file_delete(key, orig, MYF(sync_dir)) || res);
+}
diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index c0afd587ada..d1e239692f1 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -196,7 +196,7 @@ int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
char dir_name[FN_REFLEN];
size_t dir_name_length;
dirname_part(dir_name, file_name, &dir_name_length);
- return my_sync_dir(dir_name, my_flags);
+ return my_sync_dir(dir_name, my_flags & ~MY_NOSYMLINKS);
#else
return 0;
#endif
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 1e4b85583b1..be8af98e2b9 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -44,6 +44,8 @@ static uint get_thread_lib(void);
/** True if @c my_thread_global_init() has been called. */
static my_bool my_thread_global_init_done= 0;
+/* True if THR_KEY_mysys is created */
+my_bool my_thr_key_mysys_exists= 0;
/*
@@ -167,11 +169,20 @@ my_bool my_thread_global_init(void)
return 0;
my_thread_global_init_done= 1;
- if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
+ /*
+ THR_KEY_mysys is deleted in my_end() as DBUG libraries are using it even
+ after my_thread_global_end() is called.
+ my_thr_key_mysys_exist is used to protect against application like QT
+ that calls my_thread_global_init() + my_thread_global_end() multiple times
+ without calling my_init() + my_end().
+ */
+ if (!my_thr_key_mysys_exists &&
+ (pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
{
fprintf(stderr, "Can't initialize threads: error %d\n", pth_ret);
return 1;
}
+ my_thr_key_mysys_exists= 1;
/* Mutex used by my_thread_init() and after my_thread_destroy_mutex() */
my_thread_init_internal_mutex();
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 9c6855bb92f..0072b8c77f0 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -92,6 +92,34 @@ size_t sf_malloc_usable_size(void *ptr, my_bool *is_thread_specific);
void my_error_unregister_all(void);
+#if !defined(O_PATH) && defined(O_EXEC) /* FreeBSD */
+#define O_PATH O_EXEC
+#endif
+
+#ifdef O_PATH
+#define HAVE_OPEN_PARENT_DIR_NOSYMLINKS
+const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd);
+#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
+ int dfd, res; \
+ const char *filename= my_open_parent_dir_nosymlinks(pathname, &dfd); \
+ if (filename == NULL) return -1; \
+ res= AT; \
+ if (dfd >= 0) close(dfd); \
+ return res;
+#elif defined(HAVE_REALPATH)
+#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
+ char buf[PATH_MAX+1]; \
+ if (realpath(pathname, buf) == NULL) return -1; \
+ if (strcmp(pathname, buf)) { errno= ENOTDIR; return -1; } \
+ return NOAT;
+#else
+#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
+ return NOAT;
+#endif
+
+#define CREATE_NOSYMLINK_FUNCTION(PROTO,AT,NOAT) \
+static int PROTO { NOSYMLINK_FUNCTION_BODY(AT,NOAT) }
+
#ifdef _WIN32
#include <sys/stat.h>
/* my_winfile.c exports, should not be used outside mysys */
diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c
index 4c5e6992a32..3b93d3277a6 100644
--- a/plugin/server_audit/server_audit.c
+++ b/plugin/server_audit/server_audit.c
@@ -156,10 +156,8 @@ static File loc_open(const char *FileName, int Flags)
File fd;
#if defined(_WIN32)
fd= my_win_open(FileName, Flags);
-#elif !defined(NO_OPEN_3)
- fd = open(FileName, Flags, my_umask); /* Normal unix */
#else
- fd = open((char *) FileName, Flags);
+ fd = open(FileName, Flags, my_umask);
#endif
my_errno= errno;
return fd;
@@ -2295,10 +2293,10 @@ typedef struct loc_system_variables
} LOC_SV;
+static int init_done= 0;
+
static int server_audit_init(void *p __attribute__((unused)))
{
- const void *my_hash_init_ptr;
-
if (!serv_ver)
{
#ifdef _WIN32
@@ -2307,11 +2305,16 @@ static int server_audit_init(void *p __attribute__((unused)))
serv_ver= server_version;
#endif /*_WIN32*/
}
- my_hash_init_ptr= dlsym(RTLD_DEFAULT, "_my_hash_init");
- if (!my_hash_init_ptr)
+ if (!mysql_57_started)
{
- maria_above_5= 1;
- my_hash_init_ptr= dlsym(RTLD_DEFAULT, "my_hash_init2");
+ const void *my_hash_init_ptr= dlsym(RTLD_DEFAULT, "_my_hash_init");
+ if (!my_hash_init_ptr)
+ {
+ maria_above_5= 1;
+ my_hash_init_ptr= dlsym(RTLD_DEFAULT, "my_hash_init2");
+ }
+ if (!my_hash_init_ptr)
+ return 1;
}
if(!(int_mysql_data_home= dlsym(RTLD_DEFAULT, "mysql_data_home")))
@@ -2320,7 +2323,7 @@ static int server_audit_init(void *p __attribute__((unused)))
int_mysql_data_home= &default_home;
}
- if (!serv_ver || !my_hash_init_ptr)
+ if (!serv_ver)
return 1;
if (!started_mysql)
@@ -2400,6 +2403,7 @@ static int server_audit_init(void *p __attribute__((unused)))
if (logging)
start_logging();
+ init_done= 1;
return 0;
}
@@ -2415,6 +2419,10 @@ static int server_audit_init_mysql(void *p)
static int server_audit_deinit(void *p __attribute__((unused)))
{
+ if (!init_done)
+ return 0;
+
+ init_done= 0;
coll_free(&incl_user_coll);
coll_free(&excl_user_coll);
@@ -2837,13 +2845,15 @@ void __attribute__ ((constructor)) audit_plugin_so_init(void)
if (sc >= 24)
use_event_data_for_disconnect= 1;
}
- else if (serv_ver[0] == '5' && serv_ver[2] == '7')
+ else if ((serv_ver[0] == '5' && serv_ver[2] == '7') ||
+ (serv_ver[0] == '8' && serv_ver[2] == '0'))
{
mysql_57_started= 1;
_mysql_plugin_declarations_[0].info= mysql_v4_descriptor;
use_event_data_for_disconnect= 1;
}
- MYSQL_SYSVAR_NAME(loc_info).flags= PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC;
+ MYSQL_SYSVAR_NAME(loc_info).flags= PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL |
+ PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC;
}
memset(locinfo_ini_value, 'O', sizeof(locinfo_ini_value)-1);
diff --git a/sql-common/client.c b/sql-common/client.c
index 78c5426367c..0b65853f61d 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2003, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2016, MariaDB
+ Copyright (c) 2009, 2017, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -3867,8 +3867,6 @@ static void mysql_close_free(MYSQL *mysql)
static void mysql_prune_stmt_list(MYSQL *mysql)
{
LIST *element= mysql->stmts;
- LIST *pruned_list= 0;
-
for (; element; element= element->next)
{
MYSQL_STMT *stmt= (MYSQL_STMT *) element->data;
@@ -3878,14 +3876,9 @@ static void mysql_prune_stmt_list(MYSQL *mysql)
stmt->last_errno= CR_SERVER_LOST;
strmov(stmt->last_error, ER(CR_SERVER_LOST));
strmov(stmt->sqlstate, unknown_sqlstate);
- }
- else
- {
- pruned_list= list_add(pruned_list, element);
+ mysql->stmts= list_delete(mysql->stmts, element);
}
}
-
- mysql->stmts= pruned_list;
}
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 69cc78588a8..86ea5a22a5b 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -7273,6 +7273,7 @@ int ha_partition::reset(void)
result= tmp;
}
bitmap_clear_all(&m_partitions_to_reset);
+ m_extra_prepare_for_update= FALSE;
DBUG_RETURN(result);
}
diff --git a/sql/handler.cc b/sql/handler.cc
index 249d68fccb1..d75d3e3ef21 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3371,6 +3371,7 @@ void handler::print_error(int error, myf errflag)
textno=ER_FILE_USED;
break;
case ENOENT:
+ case ENOTDIR:
textno=ER_FILE_NOT_FOUND;
break;
case ENOSPC:
@@ -3849,8 +3850,7 @@ int handler::delete_table(const char *name)
for (const char **ext=bas_ext(); *ext ; ext++)
{
- fn_format(buff, name, "", *ext, MY_UNPACK_FILENAME|MY_APPEND_EXT);
- if (mysql_file_delete_with_symlink(key_file_misc, buff, MYF(0)))
+ if (my_handler_delete_with_symlink(key_file_misc, name, *ext, 0))
{
if (my_errno != ENOENT)
{
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index f3a98785a0b..8cff6a1e6c8 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -894,7 +894,7 @@ void Item_subselect::update_used_tables()
if (!forced_const)
{
recalc_used_tables(parent_select, FALSE);
- if (!engine->uncacheable())
+ if (!(engine->uncacheable() & ~UNCACHEABLE_EXPLAIN))
{
// did all used tables become static?
if (!(used_tables_cache & ~engine->upper_select_const_tables()))
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5692c88d6c8..0492f443cf9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -21,7 +21,7 @@
#ifndef __WIN__
#include <netdb.h> // getservbyname, servent
#endif
-#include "sql_parse.h" // test_if_data_home_dir
+#include "sql_parse.h" // path_starts_from_data_home_dir
#include "sql_cache.h" // query_cache, query_cache_*
#include "sql_locale.h" // MY_LOCALES, my_locales, my_locale_by_name
#include "sql_show.h" // free_status_vars, add_status_vars,
@@ -8130,7 +8130,7 @@ 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_bin_log= opt_bin_log_used= 0;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 5d6891a1edf..8f9d5abfa4d 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -8067,8 +8067,15 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
if (cond_func->functype() == Item_func::BETWEEN ||
cond_func->functype() == Item_func::IN_FUNC)
inv= ((Item_func_opt_neg *) cond_func)->negated;
- else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
- DBUG_RETURN(0);
+ else
+ {
+ MEM_ROOT *tmp_root= param->mem_root;
+ param->thd->mem_root= param->old_root;
+ Item_func::optimize_type opt_res= cond_func->select_optimize();
+ param->thd->mem_root= tmp_root;
+ if (opt_res == Item_func::OPTIMIZE_NONE)
+ DBUG_RETURN(0);
+ }
param->cond= cond;
@@ -9923,6 +9930,13 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
if (!tmp->next_key_part)
{
+ if (key2->use_count)
+ {
+ SEL_ARG *key2_cpy= new SEL_ARG(*key2);
+ if (key2_cpy)
+ return 0;
+ key2= key2_cpy;
+ }
/*
tmp->next_key_part is empty: cut the range that is covered
by tmp from key2.
@@ -9954,13 +9968,6 @@ key_or(RANGE_OPT_PARAM *param, SEL_ARG *key1,SEL_ARG *key2)
key2: [---]
tmp: [---------]
*/
- if (key2->use_count)
- {
- SEL_ARG *key2_cpy= new SEL_ARG(*key2);
- if (key2_cpy)
- return 0;
- key2= key2_cpy;
- }
key2->copy_max_to_min(tmp);
continue;
}
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 1607b1937df..1eee5df2bc5 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -27,7 +27,7 @@
#include "sql_partition.h" // partition_info.h: LIST_PART_ENTRY
// NOT_A_PARTITION_ID
#include "partition_info.h"
-#include "sql_parse.h" // test_if_data_home_dir
+#include "sql_parse.h"
#include "sql_acl.h" // *_ACL
#include "sql_base.h" // fill_record
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index be1425e294a..ac833e01ba7 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -8935,13 +8935,13 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
case USER_ACL:
acl_user->user.str= strdup_root(&acl_memroot, user_to->user.str);
acl_user->user.length= user_to->user.length;
- acl_user->host.hostname= strdup_root(&acl_memroot, user_to->host.str);
- acl_user->hostname_length= user_to->host.length;
+ update_hostname(&acl_user->host, strdup_root(&acl_memroot, user_to->host.str));
+ acl_user->hostname_length= strlen(acl_user->host.hostname);
break;
case DB_ACL:
acl_db->user= strdup_root(&acl_memroot, user_to->user.str);
- acl_db->host.hostname= strdup_root(&acl_memroot, user_to->host.str);
+ update_hostname(&acl_db->host, strdup_root(&acl_memroot, user_to->host.str));
break;
case COLUMN_PRIVILEGES_HASH:
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 0a3ff64113f..3f43a33ab7c 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -815,7 +815,8 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
if there exists a table with the name 'db', so let's just do it
separately. We know this file exists and needs to be deleted anyway.
*/
- if (my_delete_with_symlink(path, MYF(0)) && my_errno != ENOENT)
+ if (my_handler_delete_with_symlink(key_file_misc, path, "", MYF(0)) &&
+ my_errno != ENOENT)
{
my_error(EE_DELETE, MYF(0), path, my_errno);
DBUG_RETURN(true);
@@ -1116,9 +1117,9 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp,
strxmov(filePath, path, "/", file->name, NullS);
/*
We ignore ENOENT error in order to skip files that was deleted
- by concurrently running statement like REAPIR TABLE ...
+ by concurrently running statement like REPAIR TABLE ...
*/
- if (my_delete_with_symlink(filePath, MYF(0)) &&
+ if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(0)) &&
my_errno != ENOENT)
{
my_error(EE_DELETE, MYF(0), filePath, my_errno);
@@ -1234,7 +1235,7 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path)
continue;
}
strxmov(filePath, org_path, "/", file->name, NullS);
- if (mysql_file_delete_with_symlink(key_file_misc, filePath, MYF(MY_WME)))
+ if (my_handler_delete_with_symlink(key_file_misc, filePath, "", MYF(MY_WME)))
{
goto err;
}
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index f2674cb8dab..af5b016df9d 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -447,6 +447,9 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
{
Item *expr= derived->on_expr;
expr= and_conds(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 --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index f701c424f63..7584b42c904 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -589,6 +589,11 @@ void JOIN_CACHE::create_remaining_fields()
{
MY_BITMAP *rem_field_set;
TABLE *table= tab->table;
+#if MYSQL_VERSION_ID < 100204
+ empty_record(table);
+#else
+#error remove
+#endif
if (all_read_fields)
rem_field_set= table->read_set;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 97d3ce24c25..a6574479e8d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1909,12 +1909,12 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
#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 */
DBUG_RETURN(1);
#else
+ {
DBUG_ASSERT(table_ident);
TABLE_LIST **query_tables_last= lex->query_tables_last;
schema_select_lex= new SELECT_LEX();
@@ -6487,7 +6487,7 @@ void mysql_init_multi_delete(LEX *lex)
/*
- 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.
*/
@@ -8465,48 +8465,24 @@ bool check_ident_length(LEX_STRING *ident)
}
-C_MODE_START
-
/*
Check if path does not contain mysql data home directory
SYNOPSIS
- test_if_data_home_dir()
- dir directory
+ path_starts_from_data_home_dir()
+ dir directory, with all symlinks resolved
RETURN VALUES
0 ok
1 error ; Given path contains data directory
*/
+extern "C" {
-int test_if_data_home_dir(const char *dir)
+int path_starts_from_data_home_dir(const char *path)
{
- char path[FN_REFLEN];
- int dir_len;
- DBUG_ENTER("test_if_data_home_dir");
+ int dir_len= strlen(path);
+ DBUG_ENTER("path_starts_from_data_home_dir");
- if (!dir)
- DBUG_RETURN(0);
-
- /*
- data_file_name and index_file_name include the table name without
- extension. Mostly this does not refer to an existing file. When
- comparing data_file_name or index_file_name against the data
- directory, we try to resolve all symbolic links. On some systems,
- we use realpath(3) for the resolution. This returns ENOENT if the
- resolved path does not refer to an existing file. my_realpath()
- does then copy the requested path verbatim, without symlink
- resolution. Thereafter the comparison can fail even if the
- requested path is within the data directory. E.g. if symlinks to
- another file system are used. To make realpath(3) return the
- resolved path, we strip the table name and compare the directory
- path only. If the directory doesn't exist either, table creation
- will fail anyway.
- */
-
- (void) fn_format(path, dir, "", "",
- (MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
- dir_len= strlen(path);
if (mysql_unpacked_real_data_home_len<= dir_len)
{
if (dir_len > mysql_unpacked_real_data_home_len &&
@@ -8534,7 +8510,31 @@ int test_if_data_home_dir(const char *dir)
DBUG_RETURN(0);
}
-C_MODE_END
+}
+
+/*
+ Check if path does not contain mysql data home directory
+
+ SYNOPSIS
+ test_if_data_home_dir()
+ dir directory
+
+ RETURN VALUES
+ 0 ok
+ 1 error ; Given path contains data directory
+*/
+
+int test_if_data_home_dir(const char *dir)
+{
+ char path[FN_REFLEN];
+ DBUG_ENTER("test_if_data_home_dir");
+
+ if (!dir)
+ DBUG_RETURN(0);
+
+ (void) fn_format(path, dir, "", "", MY_RETURN_REAL_PATH);
+ DBUG_RETURN(path_starts_from_data_home_dir(path));
+}
int error_if_data_home_dir(const char *path, const char *what)
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index 3d11d842259..fa414911093 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -33,7 +33,8 @@ enum enum_mysql_completiontype {
COMMIT_RELEASE=-1, COMMIT=0, COMMIT_AND_CHAIN=6
};
-extern "C" int test_if_data_home_dir(const char *dir);
+extern "C" int path_starts_from_data_home_dir(const char *dir);
+int test_if_data_home_dir(const char *dir);
int error_if_data_home_dir(const char *path, const char *what);
bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7850c7a0dcf..d459d0b88bf 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8510,8 +8510,6 @@ get_best_combination(JOIN *join)
form=join->table[tablenr]=j->table;
used_tables|= form->map;
form->reginfo.join_tab=j;
- if (!*j->on_expr_ref)
- form->reginfo.not_exists_optimize=0; // Only with LEFT JOIN
DBUG_PRINT("info",("type: %d", j->type));
if (j->type == JT_CONST)
goto loop_end; // Handled in make_join_stat..
@@ -9355,7 +9353,10 @@ make_outerjoin_info(JOIN *join)
tab->cond_equal= tbl->cond_equal;
if (embedding && !embedding->is_active_sjm())
tab->first_upper= embedding->nested_join->first_nested;
- }
+ }
+ else if (!embedding)
+ tab->table->reginfo.not_exists_optimize= 0;
+
for ( ; embedding ; embedding= embedding->embedding)
{
if (embedding->is_active_sjm())
@@ -9365,7 +9366,10 @@ make_outerjoin_info(JOIN *join)
}
/* Ignore sj-nests: */
if (!(embedding->on_expr && embedding->outer_join))
+ {
+ tab->table->reginfo.not_exists_optimize= 0;
continue;
+ }
NESTED_JOIN *nested_join= embedding->nested_join;
if (!nested_join->counter)
{
@@ -9381,17 +9385,10 @@ make_outerjoin_info(JOIN *join)
}
if (!tab->first_inner)
tab->first_inner= nested_join->first_nested;
- if (tab->table->reginfo.not_exists_optimize)
- tab->first_inner->table->reginfo.not_exists_optimize= 1;
if (++nested_join->counter < nested_join->n_tables)
break;
/* Table tab is the last inner table for nested join. */
nested_join->first_nested->last_inner= tab;
- if (tab->first_inner->table->reginfo.not_exists_optimize)
- {
- for (JOIN_TAB *join_tab= tab->first_inner; join_tab <= tab; join_tab++)
- join_tab->table->reginfo.not_exists_optimize= 1;
- }
}
}
DBUG_RETURN(FALSE);
@@ -15510,7 +15507,9 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
if (new_field)
new_field->init(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);
@@ -17982,32 +17981,41 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
first_unmatched->found= 1;
for (JOIN_TAB *tab= first_unmatched; tab <= join_tab; tab++)
{
+ /*
+ Check whether 'not exists' optimization can be used here.
+ If tab->table->reginfo.not_exists_optimize is set to true
+ then WHERE contains a conjunctive predicate IS NULL over
+ a non-nullable field of tab. When activated this predicate
+ will filter out all records with matches for the left part
+ of the outer join whose inner tables start from the
+ first_unmatched table and include table tab. To safely use
+ 'not exists' optimization we have to check that the
+ IS NULL predicate is really activated, i.e. all guards
+ that wrap it are in the 'open' state.
+ */
+ bool not_exists_opt_is_applicable=
+ tab->table->reginfo.not_exists_optimize;
+ for (JOIN_TAB *first_upper= first_unmatched->first_upper;
+ not_exists_opt_is_applicable && first_upper;
+ first_upper= first_upper->first_upper)
+ {
+ if (!first_upper->found)
+ not_exists_opt_is_applicable= false;
+ }
/* Check all predicates that has just been activated. */
/*
Actually all predicates non-guarded by first_unmatched->found
will be re-evaluated again. It could be fixed, but, probably,
it's not worth doing now.
*/
- /*
- not_exists_optimize has been created from a
- select_cond containing 'is_null'. This 'is_null'
- predicate is still present on any 'tab' with
- 'not_exists_optimize'. Furthermore, the usual rules
- for condition guards also applies for
- 'not_exists_optimize' -> When 'is_null==false' we
- know all cond. guards are open and we can apply
- the 'not_exists_optimize'.
- */
- DBUG_ASSERT(!(tab->table->reginfo.not_exists_optimize &&
- !tab->select_cond));
-
if (tab->select_cond && !tab->select_cond->val_int())
{
/* The condition attached to table tab is false */
-
if (tab == join_tab)
{
found= 0;
+ if (not_exists_opt_is_applicable)
+ DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS);
}
else
{
@@ -18016,21 +18024,10 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
not to the last table of the current nest level.
*/
join->return_tab= tab;
- }
-
- if (tab->table->reginfo.not_exists_optimize)
- {
- /*
- When not_exists_optimize is set: No need to further
- explore more rows of 'tab' for this partial result.
- Any found 'tab' matches are known to evaluate to 'false'.
- Returning .._NO_MORE_ROWS will skip rem. 'tab' rows.
- */
- DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS);
- }
- else if (tab != join_tab)
- {
- DBUG_RETURN(NESTED_LOOP_OK);
+ if (not_exists_opt_is_applicable)
+ DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS);
+ else
+ DBUG_RETURN(NESTED_LOOP_OK);
}
}
}
diff --git a/sql/table.cc b/sql/table.cc
index 33f5c1d5191..80d0e02c6b1 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -569,7 +569,7 @@ enum open_frm_error open_table_def(THD *thd, TABLE_SHARE *share, uint flags)
{
DBUG_ASSERT(flags & GTS_TABLE);
DBUG_ASSERT(flags & GTS_USE_DISCOVERY);
- mysql_file_delete_with_symlink(key_file_frm, path, MYF(0));
+ my_handler_delete_with_symlink(key_file_frm, path, "", MYF(0));
file= -1;
}
else
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index fca433f9648..4f24ad75e26 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1880,7 +1880,6 @@ btr_cur_update_alloc_zip_func(
const page_t* page = page_cur_get_page(cursor);
ut_ad(page_zip == page_cur_get_page_zip(cursor));
- ut_ad(page_zip);
ut_ad(!dict_index_is_ibuf(index));
ut_ad(rec_offs_validate(page_cur_get_rec(cursor), index, offsets));
@@ -2962,7 +2961,7 @@ btr_cur_del_mark_set_clust_rec(
ut_ad(page_is_leaf(page_align(rec)));
#ifdef UNIV_DEBUG
- if (btr_cur_print_record_ops && (thr != NULL)) {
+ if (btr_cur_print_record_ops) {
btr_cur_trx_report(thr_get_trx(thr)->id, index, "del mark ");
rec_print_new(stderr, rec, offsets);
}
@@ -4278,7 +4277,6 @@ btr_cur_disown_inherited_fields(
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
ut_ad(rec_offs_any_extern(offsets));
- ut_ad(mtr);
for (i = 0; i < rec_offs_n_fields(offsets); i++) {
if (rec_offs_nth_extern(offsets, i)
@@ -4341,9 +4339,6 @@ btr_push_update_extern_fields(
ulint n;
const upd_field_t* uf;
- ut_ad(tuple);
- ut_ad(update);
-
uf = update->fields;
n = upd_get_n_fields(update);
@@ -4515,7 +4510,6 @@ btr_store_big_rec_extern_fields(
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_any_extern(offsets));
- ut_ad(btr_mtr);
ut_ad(mtr_memo_contains(btr_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(btr_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 2e40946224e..6fd8afd2aee 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -6156,7 +6156,6 @@ dict_set_corrupted(
row_mysql_lock_data_dictionary(trx);
}
- ut_ad(index);
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
diff --git a/storage/innobase/dyn/dyn0dyn.cc b/storage/innobase/dyn/dyn0dyn.cc
index 3ef5297a7c9..dd1f6863c14 100644
--- a/storage/innobase/dyn/dyn0dyn.cc
+++ b/storage/innobase/dyn/dyn0dyn.cc
@@ -40,7 +40,6 @@ dyn_array_add_block(
mem_heap_t* heap;
dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
if (arr->heap == NULL) {
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 836ed2de27a..1732a02aeac 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1064,8 +1064,6 @@ fsp_fill_free_list(
ulint i;
mtr_t ibuf_mtr;
- ut_ad(header != NULL);
- ut_ad(mtr != NULL);
ut_ad(page_offset(header) == FSP_HEADER_OFFSET);
/* Check if we can fill free list from above the free list limit */
@@ -1348,9 +1346,6 @@ fsp_alloc_free_page(
ulint page_no;
ulint space_size;
- ut_ad(mtr);
- ut_ad(init_mtr);
-
header = fsp_get_space_header(space, zip_size, mtr);
/* Get the hinted descriptor */
@@ -2363,7 +2358,6 @@ fseg_alloc_free_page_low(
ibool success;
ulint n;
- ut_ad(mtr);
ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index 6fc6098f3d9..1ed231aa248 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -266,7 +266,6 @@ dict_index_is_clust(
/*================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->type & DICT_CLUSTERED);
@@ -280,7 +279,6 @@ dict_index_is_unique(
/*=================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->type & DICT_UNIQUE);
@@ -295,7 +293,6 @@ dict_index_is_ibuf(
/*===============*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->type & DICT_IBUF);
@@ -327,7 +324,6 @@ dict_index_is_sec_or_ibuf(
{
ulint type;
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
type = index->type;
@@ -345,7 +341,6 @@ dict_table_get_n_user_cols(
/*=======================*/
const dict_table_t* table) /*!< in: table */
{
- ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
return(table->n_cols - DATA_N_SYS_COLS);
@@ -377,7 +372,6 @@ dict_table_get_n_cols(
/*==================*/
const dict_table_t* table) /*!< in: table */
{
- ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
return(table->n_cols);
@@ -1373,7 +1367,6 @@ dict_index_is_corrupted(
/*====================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return((index->type & DICT_CORRUPT)
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 4b88a809520..10a57f620ad 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -133,7 +133,7 @@ allows InnoDB to update_create_info() accordingly. */
+ DICT_TF_WIDTH_DATA_DIR)
/** A mask of all the known/used bits in table flags */
-#define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS))
+#define DICT_TF_BIT_MASK (~(~0U << DICT_TF_BITS))
/** Zero relative shift position of the COMPACT field */
#define DICT_TF_POS_COMPACT 0
diff --git a/storage/innobase/include/dyn0dyn.ic b/storage/innobase/include/dyn0dyn.ic
index f18f2e6dff9..13003862638 100644
--- a/storage/innobase/include/dyn0dyn.ic
+++ b/storage/innobase/include/dyn0dyn.ic
@@ -47,8 +47,6 @@ dyn_block_get_used(
/*===============*/
const dyn_block_t* block) /*!< in: dyn array block */
{
- ut_ad(block);
-
return((block->used) & ~DYN_BLOCK_FULL_FLAG);
}
@@ -76,7 +74,6 @@ dyn_array_create(
dyn_array_t* arr) /*!< in/out: memory buffer of
size sizeof(dyn_array_t) */
{
- ut_ad(arr);
#if DYN_ARRAY_DATA_SIZE >= DYN_BLOCK_FULL_FLAG
# error "DYN_ARRAY_DATA_SIZE >= DYN_BLOCK_FULL_FLAG"
#endif
@@ -119,7 +116,6 @@ dyn_array_push(
dyn_block_t* block;
ulint used;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
ut_ad(size <= DYN_ARRAY_DATA_SIZE);
ut_ad(size);
@@ -159,7 +155,6 @@ dyn_array_open(
{
dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
ut_ad(size <= DYN_ARRAY_DATA_SIZE);
ut_ad(size);
@@ -195,7 +190,6 @@ dyn_array_close(
{
dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
block = dyn_array_get_last_block(arr);
@@ -222,7 +216,6 @@ dyn_array_get_element(
{
const dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
/* Get the first array block */
@@ -260,7 +253,6 @@ dyn_array_get_data_size(
const dyn_block_t* block;
ulint sum = 0;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
if (arr->heap == NULL) {
diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h
index 099cb8edc14..0097537e4d6 100644
--- a/storage/innobase/include/fsp0fsp.h
+++ b/storage/innobase/include/fsp0fsp.h
@@ -61,7 +61,7 @@ is found in a remote location, not the default data directory. */
+ FSP_FLAGS_WIDTH_DATA_DIR)
/** A mask of all the known/used bits in tablespace flags */
-#define FSP_FLAGS_MASK (~(~0 << FSP_FLAGS_WIDTH))
+#define FSP_FLAGS_MASK (~(~0U << FSP_FLAGS_WIDTH))
/** Zero relative shift position of the POST_ANTELOPE field */
#define FSP_FLAGS_POS_POST_ANTELOPE 0
diff --git a/storage/innobase/include/mach0data.ic b/storage/innobase/include/mach0data.ic
index c46fcec107e..6b303979b18 100644
--- a/storage/innobase/include/mach0data.ic
+++ b/storage/innobase/include/mach0data.ic
@@ -52,7 +52,6 @@ mach_read_from_1(
/*=============*/
const byte* b) /*!< in: pointer to byte */
{
- ut_ad(b);
return((ulint)(b[0]));
}
@@ -149,7 +148,6 @@ mach_read_from_3(
/*=============*/
const byte* b) /*!< in: pointer to 3 bytes */
{
- ut_ad(b);
return( ((ulint)(b[0]) << 16)
| ((ulint)(b[1]) << 8)
| (ulint)(b[2])
@@ -186,7 +184,6 @@ mach_read_from_4(
/*=============*/
const byte* b) /*!< in: pointer to four bytes */
{
- ut_ad(b);
return( ((ulint)(b[0]) << 24)
| ((ulint)(b[1]) << 16)
| ((ulint)(b[2]) << 8)
@@ -265,8 +262,6 @@ mach_read_compressed(
{
ulint flag;
- ut_ad(b);
-
flag = mach_read_from_1(b);
if (flag < 0x80UL) {
@@ -347,8 +342,6 @@ mach_read_from_7(
/*=============*/
const byte* b) /*!< in: pointer to 7 bytes */
{
- ut_ad(b);
-
return(ut_ull_create(mach_read_from_3(b), mach_read_from_4(b + 3)));
}
@@ -378,8 +371,6 @@ mach_read_from_6(
/*=============*/
const byte* b) /*!< in: pointer to 6 bytes */
{
- ut_ad(b);
-
return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2)));
}
@@ -427,8 +418,6 @@ mach_ull_read_compressed(
ib_uint64_t n;
ulint size;
- ut_ad(b);
-
n = (ib_uint64_t) mach_read_compressed(b);
size = mach_get_compressed_size((ulint) n);
@@ -494,8 +483,6 @@ mach_ull_read_much_compressed(
ib_uint64_t n;
ulint size;
- ut_ad(b);
-
if (*b != (byte)0xFF) {
n = 0;
size = 0;
diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic
index 99e17001c0a..a4d3bd40426 100644
--- a/storage/innobase/include/page0page.ic
+++ b/storage/innobase/include/page0page.ic
@@ -160,7 +160,6 @@ page_header_get_offs(
{
ulint offs;
- ut_ad(page);
ut_ad((field == PAGE_FREE)
|| (field == PAGE_LAST_INSERT)
|| (field == PAGE_HEAP_TOP));
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index f60ec648ba1..6e87671817e 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -309,7 +309,6 @@ mtr_commit(
/*=======*/
mtr_t* mtr) /*!< in: mini-transaction */
{
- ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad(!mtr->inside_ibuf);
diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc
index 95b8db0ccc8..090848a4525 100644
--- a/storage/innobase/page/page0page.cc
+++ b/storage/innobase/page/page0page.cc
@@ -1442,7 +1442,6 @@ page_dir_split_slot(
ulint i;
ulint n_owned;
- ut_ad(page);
ut_ad(!page_zip || page_is_comp(page));
ut_ad(slot_no > 0);
@@ -1504,7 +1503,6 @@ page_dir_balance_slot(
rec_t* old_rec;
rec_t* new_rec;
- ut_ad(page);
ut_ad(!page_zip || page_is_comp(page));
ut_ad(slot_no > 0);
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index e7d545ddb52..e8a147aab47 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -4807,8 +4807,6 @@ page_zip_parse_compress(
ulint size;
ulint trailer_size;
- ut_ad(ptr != NULL);
- ut_ad(end_ptr != NULL);
ut_ad(!page == !page_zip);
if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) {
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 9518712e160..f214633e9ce 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -944,14 +944,8 @@ row_merge_read_rec(
ulint data_size;
ulint avail_size;
- ut_ad(block);
- ut_ad(buf);
ut_ad(b >= &block[0]);
ut_ad(b < &block[srv_sort_buf_size]);
- ut_ad(index);
- ut_ad(foffs);
- ut_ad(mrec);
- ut_ad(offsets);
ut_ad(*offsets == 1 + REC_OFFS_HEADER_SIZE
+ dict_index_get_n_fields(index));
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 7f4cf1a39dd..7151801783c 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -1114,8 +1114,6 @@ row_upd_index_replace_new_col_vals_index_pos(
ulint n_fields;
const ulint zip_size = dict_table_zip_size(index->table);
- ut_ad(index);
-
dtuple_set_info_bits(entry, update->info_bits);
if (order_only) {
@@ -1300,8 +1298,6 @@ row_upd_changes_ord_field_binary_func(
ulint i;
const dict_index_t* clust_index;
- ut_ad(index);
- ut_ad(update);
ut_ad(thr);
ut_ad(thr->graph);
ut_ad(thr->graph->trx);
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 14ab6ec7599..3e0872b9a89 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -3609,10 +3609,6 @@ static int ha_maria_init(void *p)
maria_pagecache->extra_debug= 1;
maria_assert_if_crashed_table= debug_assert_if_crashed_table;
-#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 */
- maria_test_invalid_symlink= test_if_data_home_dir;
-#endif
if (res)
maria_hton= 0;
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index a189af40362..bd5c67c0409 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -2839,7 +2839,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
(param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0)) |
sync_dir) ||
- _ma_open_datafile(info, share, NullS, -1))
+ _ma_open_datafile(info, share))
{
goto err;
}
@@ -3994,7 +3994,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
(param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0)) |
sync_dir) ||
- _ma_open_datafile(info, share, NullS, -1))
+ _ma_open_datafile(info, share))
{
_ma_check_print_error(param, "Couldn't change to new data file");
goto err;
@@ -4627,7 +4627,7 @@ err:
MYF((param->testflag & T_BACKUP_DATA ?
MY_REDEL_MAKE_BACKUP : 0) |
sync_dir)) ||
- _ma_open_datafile(info,share, NullS, -1))
+ _ma_open_datafile(info,share))
got_error=1;
}
}
diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c
index 1176b2037b5..14809636616 100644
--- a/storage/maria/ma_create.c
+++ b/storage/maria/ma_create.c
@@ -53,7 +53,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
uint max_field_lengths, extra_header_size, column_nr;
uint internal_table= flags & HA_CREATE_INTERNAL_TABLE;
ulong reclength, real_reclength,min_pack_length;
- char filename[FN_REFLEN], linkname[FN_REFLEN], *linkname_ptr;
+ char kfilename[FN_REFLEN], klinkname[FN_REFLEN], *klinkname_ptr;
+ char dfilename[FN_REFLEN], dlinkname[FN_REFLEN], *dlinkname_ptr;
ulong pack_reclength;
ulonglong tot_length,max_rows, tmp;
enum en_fieldtype type;
@@ -808,19 +809,19 @@ int maria_create(const char *name, enum data_file_type datafile_type,
/* chop off the table name, tempory tables use generated name */
if ((path= strrchr(ci->index_file_name, FN_LIBCHAR)))
*path= '\0';
- fn_format(filename, name, ci->index_file_name, MARIA_NAME_IEXT,
+ fn_format(kfilename, name, ci->index_file_name, MARIA_NAME_IEXT,
MY_REPLACE_DIR | MY_UNPACK_FILENAME |
MY_RETURN_REAL_PATH | MY_APPEND_EXT);
}
else
{
- fn_format(filename, ci->index_file_name, "", MARIA_NAME_IEXT,
+ fn_format(kfilename, ci->index_file_name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
}
- fn_format(linkname, name, "", MARIA_NAME_IEXT,
+ fn_format(klinkname, name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT);
- linkname_ptr= linkname;
+ klinkname_ptr= klinkname;
/*
Don't create the table if the link or file exists to ensure that one
doesn't accidently destroy another table.
@@ -834,10 +835,10 @@ int maria_create(const char *name, enum data_file_type datafile_type,
{
char *iext= strrchr(name, '.');
int have_iext= iext && !strcmp(iext, MARIA_NAME_IEXT);
- fn_format(filename, name, "", MARIA_NAME_IEXT,
+ fn_format(kfilename, name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
- linkname_ptr= NullS;
+ klinkname_ptr= NullS;
/*
Replace the current file.
Don't sync dir now if the data file has the same path.
@@ -857,7 +858,7 @@ int maria_create(const char *name, enum data_file_type datafile_type,
NOTE: The filename is compared against unique_file_name of every
open table. Hence we need a real path here.
*/
- if (!internal_table && _ma_test_if_reopen(filename))
+ if (!internal_table && _ma_test_if_reopen(kfilename))
{
my_printf_error(HA_ERR_TABLE_EXIST, "Aria table '%s' is in use "
"(most likely by a MERGE table). Try FLUSH TABLES.",
@@ -866,8 +867,8 @@ int maria_create(const char *name, enum data_file_type datafile_type,
goto err;
}
- if ((file= mysql_file_create_with_symlink(key_file_kfile, linkname_ptr,
- filename, 0, create_mode,
+ if ((file= mysql_file_create_with_symlink(key_file_kfile, klinkname_ptr,
+ kfilename, 0, create_mode,
MYF(MY_WME|create_flag))) < 0)
goto err;
errpos=1;
@@ -1121,30 +1122,30 @@ int maria_create(const char *name, enum data_file_type datafile_type,
/* chop off the table name, tempory tables use generated name */
if ((path= strrchr(ci->data_file_name, FN_LIBCHAR)))
*path= '\0';
- fn_format(filename, name, ci->data_file_name, MARIA_NAME_DEXT,
+ fn_format(dfilename, name, ci->data_file_name, MARIA_NAME_DEXT,
MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_APPEND_EXT);
}
else
{
- fn_format(filename, ci->data_file_name, "", MARIA_NAME_DEXT,
+ fn_format(dfilename, ci->data_file_name, "", MARIA_NAME_DEXT,
MY_UNPACK_FILENAME |
(have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT));
}
- fn_format(linkname, name, "",MARIA_NAME_DEXT,
+ fn_format(dlinkname, name, "",MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT);
- linkname_ptr= linkname;
+ dlinkname_ptr= dlinkname;
create_flag=0;
}
else
{
- fn_format(filename,name,"", MARIA_NAME_DEXT,
+ fn_format(dfilename,name,"", MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT);
- linkname_ptr= NullS;
+ dlinkname_ptr= NullS;
create_flag= (flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
if ((dfile=
- mysql_file_create_with_symlink(key_file_dfile, linkname_ptr,
- filename, 0, create_mode,
+ mysql_file_create_with_symlink(key_file_dfile, dlinkname_ptr,
+ dfilename, 0, create_mode,
MYF(MY_WME | create_flag | sync_dir))) < 0)
goto err;
errpos=3;
@@ -1194,19 +1195,21 @@ err_no_lock:
mysql_file_close(dfile, MYF(0));
/* fall through */
case 2:
- if (! (flags & HA_DONT_TOUCH_DATA))
- mysql_file_delete_with_symlink(key_file_dfile,
- fn_format(filename,name,"",MARIA_NAME_DEXT,
- MY_UNPACK_FILENAME | MY_APPEND_EXT),
- sync_dir);
+ if (! (flags & HA_DONT_TOUCH_DATA))
+ {
+ mysql_file_delete(key_file_dfile, dfilename, MYF(sync_dir));
+ if (dlinkname_ptr)
+ mysql_file_delete(key_file_dfile, dlinkname_ptr, MYF(sync_dir));
+ }
/* fall through */
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));
+ }
}
my_free(log_data);
my_free(rec_per_key_part);
diff --git a/storage/maria/ma_delete_table.c b/storage/maria/ma_delete_table.c
index 56a6dfc8e5f..a9ab8e596cc 100644
--- a/storage/maria/ma_delete_table.c
+++ b/storage/maria/ma_delete_table.c
@@ -84,22 +84,13 @@ int maria_delete_table(const char *name)
int maria_delete_table_files(const char *name, 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:
- 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));
DBUG_RETURN(0);
}
diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c
index 1d274d796be..b37ebb8ff8b 100644
--- a/storage/maria/ma_open.c
+++ b/storage/maria/ma_open.c
@@ -86,7 +86,7 @@ MARIA_HA *_ma_test_if_reopen(const char *filename)
*/
-static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name,
+static MARIA_HA *maria_clone_internal(MARIA_SHARE *share,
int mode, File data_file,
uint internal_table)
{
@@ -106,7 +106,7 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name,
}
if (data_file >= 0)
info.dfile.file= data_file;
- else if (_ma_open_datafile(&info, share, name, -1))
+ else if (_ma_open_datafile(&info, share))
goto err;
errpos= 5;
@@ -252,7 +252,7 @@ MARIA_HA *maria_clone(MARIA_SHARE *share, int mode)
{
MARIA_HA *new_info;
mysql_mutex_lock(&THR_LOCK_maria);
- new_info= maria_clone_internal(share, NullS, mode,
+ new_info= maria_clone_internal(share, mode,
share->data_file_type == BLOCK_RECORD ?
share->bitmap.file.file : -1, 0);
mysql_mutex_unlock(&THR_LOCK_maria);
@@ -299,7 +299,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
MARIA_NAME_IEXT,
MY_UNPACK_FILENAME),MYF(0));
if (my_is_symlink(org_name) &&
- (realpath_err || (*maria_test_invalid_symlink)(name_buff)))
+ (realpath_err || mysys_test_invalid_symlink(name_buff)))
{
my_errno= HA_WRONG_CREATE_OPTION;
DBUG_RETURN(0);
@@ -324,13 +324,16 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
my_errno= HA_ERR_CRASHED;
goto err;
});
+ DEBUG_SYNC_C("mi_open_kfile");
if ((kfile=mysql_file_open(key_file_kfile, name_buff,
- (open_mode=O_RDWR) | O_SHARE,MYF(0))) < 0)
+ (open_mode=O_RDWR) | O_SHARE | O_NOFOLLOW,
+ MYF(MY_NOSYMLINKS))) < 0)
{
if ((errno != EROFS && errno != EACCES) ||
mode != O_RDONLY ||
(kfile=mysql_file_open(key_file_kfile, name_buff,
- (open_mode=O_RDONLY) | O_SHARE,MYF(0))) < 0)
+ (open_mode=O_RDONLY) | O_SHARE | O_NOFOLLOW,
+ MYF(MY_NOSYMLINKS))) < 0)
goto err;
}
share->mode=open_mode;
@@ -375,7 +378,18 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
(void) strmov(index_name, org_name);
*strrchr(org_name, FN_EXTCHAR)= '\0';
(void) fn_format(data_name,org_name,"",MARIA_NAME_DEXT,
- MY_APPEND_EXT|MY_UNPACK_FILENAME|MY_RESOLVE_SYMLINKS);
+ MY_APPEND_EXT|MY_UNPACK_FILENAME);
+ if (my_is_symlink(data_name))
+ {
+ if (my_realpath(data_name, data_name, MYF(0)))
+ goto err;
+ if (mysys_test_invalid_symlink(data_name))
+ {
+ my_errno= HA_WRONG_CREATE_OPTION;
+ goto err;
+ }
+ share->mode|= O_NOFOLLOW; /* all symlinks are resolved by realpath() */
+ }
info_length=mi_uint2korr(share->state.header.header_length);
base_pos= mi_uint2korr(share->state.header.base_pos);
@@ -832,7 +846,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
if ((share->data_file_type == BLOCK_RECORD ||
share->data_file_type == COMPRESSED_RECORD))
{
- if (_ma_open_datafile(&info, share, name, -1))
+ if (_ma_open_datafile(&info, share))
goto err;
data_file= info.dfile.file;
}
@@ -1004,7 +1018,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
data_file= share->bitmap.file.file; /* Only opened once */
}
- if (!(m_info= maria_clone_internal(share, name, mode, data_file,
+ if (!(m_info= maria_clone_internal(share, mode, data_file,
internal_table)))
goto err;
@@ -1878,35 +1892,15 @@ void _ma_set_index_pagecache_callbacks(PAGECACHE_FILE *file,
Open data file
We can't use dup() here as the data file descriptors need to have different
active seek-positions.
-
- The argument file_to_dup is here for the future if there would on some OS
- exist a dup()-like call that would give us two different file descriptors.
*************************************************************************/
-int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, const char *org_name,
- File file_to_dup __attribute__((unused)))
+int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share)
{
- char *data_name= share->data_file_name.str;
- char real_data_name[FN_REFLEN];
-
- if (org_name)
- {
- fn_format(real_data_name, org_name, "", MARIA_NAME_DEXT, 4);
- if (my_is_symlink(real_data_name))
- {
- if (my_realpath(real_data_name, real_data_name, MYF(0)) ||
- (*maria_test_invalid_symlink)(real_data_name))
- {
- my_errno= HA_WRONG_CREATE_OPTION;
- return 1;
- }
- data_name= real_data_name;
- }
- }
-
+ myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS : 0);
+ DEBUG_SYNC_C("mi_open_datafile");
info->dfile.file= share->bitmap.file.file=
- mysql_file_open(key_file_dfile, data_name,
- share->mode | O_SHARE, MYF(MY_WME));
+ mysql_file_open(key_file_dfile, share->data_file_name.str,
+ share->mode | O_SHARE, MYF(flags));
return info->dfile.file >= 0 ? 0 : 1;
}
@@ -1920,8 +1914,8 @@ int _ma_open_keyfile(MARIA_SHARE *share)
mysql_mutex_lock(&share->intern_lock);
share->kfile.file= mysql_file_open(key_file_kfile,
share->unique_file_name.str,
- share->mode | O_SHARE,
- MYF(MY_WME));
+ share->mode | O_SHARE | O_NOFOLLOW,
+ MYF(MY_WME | MY_NOSYMLINKS));
mysql_mutex_unlock(&share->intern_lock);
return (share->kfile.file < 0);
}
diff --git a/storage/maria/ma_static.c b/storage/maria/ma_static.c
index 35ad7d5a96a..3e4cf3249a8 100644
--- a/storage/maria/ma_static.c
+++ b/storage/maria/ma_static.c
@@ -106,12 +106,6 @@ uint32 maria_readnext_vec[]=
SEARCH_BIGGER, SEARCH_SMALLER, SEARCH_SMALLER
};
-static int always_valid(const char *filename __attribute__((unused)))
-{
- return 0;
-}
-
-int (*maria_test_invalid_symlink)(const char *filename)= always_valid;
my_bool (*ma_killed)(MARIA_HA *)= ma_killed_standalone;
#ifdef HAVE_PSI_INTERFACE
diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c
index c9d38400bc4..0cdbe28f86b 100644
--- a/storage/maria/maria_chk.c
+++ b/storage/maria/maria_chk.c
@@ -1275,7 +1275,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
mysql_file_close(info->dfile.file, MYF(MY_WME)); /* Close new file */
error|=maria_change_to_newfile(filename,MARIA_NAME_DEXT,DATA_TMP_EXT,
0, MYF(0));
- if (_ma_open_datafile(info,info->s, NullS, -1))
+ if (_ma_open_datafile(info, info->s))
error=1;
param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */
param->read_cache.file= info->dfile.file;
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index a1fff2e0e43..52d1033ab66 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -1312,8 +1312,7 @@ int _ma_def_scan_restore_pos(MARIA_HA *info, MARIA_RECORD_POS lastpos);
extern MARIA_HA *_ma_test_if_reopen(const char *filename);
my_bool _ma_check_table_is_closed(const char *name, const char *where);
-int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share, const char *org_name,
- File file_to_dup);
+int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share);
int _ma_open_keyfile(MARIA_SHARE *share);
void _ma_setup_functions(register MARIA_SHARE *share);
my_bool _ma_dynmap_file(MARIA_HA *info, my_off_t size);
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 730a63067ac..2b70518c8fd 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1896,15 +1896,22 @@ int ha_myisam::info(uint flag)
Set data_file_name and index_file_name to point at the symlink value
if table is symlinked (Ie; Real name is not same as generated name)
*/
+ char buf[FN_REFLEN];
data_file_name= index_file_name= 0;
fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
MY_APPEND_EXT | MY_UNPACK_FILENAME);
- if (strcmp(name_buff, misam_info.data_file_name))
- data_file_name=misam_info.data_file_name;
+ if (my_is_symlink(name_buff))
+ {
+ my_readlink(buf, name_buff, MYF(0));
+ data_file_name= ha_thd()->strdup(buf);
+ }
fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
MY_APPEND_EXT | MY_UNPACK_FILENAME);
- if (strcmp(name_buff, misam_info.index_file_name))
- index_file_name=misam_info.index_file_name;
+ if (my_is_symlink(name_buff))
+ {
+ my_readlink(buf, name_buff, MYF(0));
+ index_file_name= ha_thd()->strdup(buf);
+ }
}
if (flag & HA_STATUS_ERRKEY)
{
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index ec72e0b430a..bbe45aa3c26 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -80,8 +80,7 @@ static SORT_KEY_BLOCKS *alloc_key_blocks(HA_CHECK *param, uint blocks,
uint buffer_length);
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 *param, MI_INFO *info,
- const char *name, File new_file);
+static int replace_data_file(HA_CHECK *param, MI_INFO *info, File new_file);
void myisamchk_init(HA_CHECK *param)
{
@@ -1715,7 +1714,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
- got_error= replace_data_file(param, info, name, new_file);
+ got_error= replace_data_file(param, info, new_file);
new_file= -1;
param->retry_repair= 0;
}
@@ -2528,7 +2527,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
- got_error= replace_data_file(param, info, name, new_file);
+ got_error= replace_data_file(param, info, new_file);
new_file= -1;
}
}
@@ -2542,7 +2541,7 @@ err:
(void) mysql_file_delete(mi_key_file_datatmp,
param->temp_filename, MYF(MY_WME));
if (info->dfile == new_file) /* Retry with key cache */
- if (unlikely(mi_open_datafile(info, share, name, -1)))
+ if (unlikely(mi_open_datafile(info, share)))
param->retry_repair= 0; /* Safety */
}
mi_mark_crashed_on_repair(info);
@@ -3063,7 +3062,7 @@ err:
/* Replace the actual file with the temporary file */
if (new_file >= 0)
{
- got_error= replace_data_file(param, info, name, new_file);
+ got_error= replace_data_file(param, info, new_file);
new_file= -1;
}
}
@@ -3077,7 +3076,7 @@ err:
(void) mysql_file_delete(mi_key_file_datatmp,
param->temp_filename, MYF(MY_WME));
if (info->dfile == new_file) /* Retry with key cache */
- if (unlikely(mi_open_datafile(info, share, name, -1)))
+ if (unlikely(mi_open_datafile(info, share)))
param->retry_repair= 0; /* Safety */
}
mi_mark_crashed_on_repair(info);
@@ -4760,8 +4759,7 @@ int mi_make_backup_of_index(MI_INFO *info, time_t backup_time, myf flags)
}
-static int replace_data_file(HA_CHECK *param, MI_INFO *info,
- const char *name, File new_file)
+static int replace_data_file(HA_CHECK *param, MI_INFO *info, File new_file)
{
MYISAM_SHARE *share=info->s;
@@ -4796,7 +4794,7 @@ static int replace_data_file(HA_CHECK *param, MI_INFO *info,
DATA_TMP_EXT, param->backup_time,
(param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
- mi_open_datafile(info, share, name, -1))
+ mi_open_datafile(info, share))
return 1;
return 0;
}
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index 88b9da6f8a9..aa85a3718de 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -46,7 +46,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
uint aligned_key_start, block_length, res;
uint internal_table= flags & HA_CREATE_INTERNAL_TABLE;
ulong reclength, real_reclength,min_pack_length;
- char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr;
+ char kfilename[FN_REFLEN],klinkname[FN_REFLEN], *klinkname_ptr;
+ char dfilename[FN_REFLEN],dlinkname[FN_REFLEN], *dlinkname_ptr;
ulong pack_reclength;
ulonglong tot_length,max_rows, tmp;
enum en_fieldtype type;
@@ -594,19 +595,19 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
/* chop off the table name, tempory tables use generated name */
if ((path= strrchr(ci->index_file_name, FN_LIBCHAR)))
*path= '\0';
- fn_format(filename, name, ci->index_file_name, MI_NAME_IEXT,
+ fn_format(kfilename, name, ci->index_file_name, MI_NAME_IEXT,
MY_REPLACE_DIR | MY_UNPACK_FILENAME |
MY_RETURN_REAL_PATH | MY_APPEND_EXT);
}
else
{
- fn_format(filename, ci->index_file_name, "", MI_NAME_IEXT,
+ fn_format(kfilename, ci->index_file_name, "", MI_NAME_IEXT,
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
}
- fn_format(linkname, name, "", MI_NAME_IEXT,
+ fn_format(klinkname, name, "", MI_NAME_IEXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT);
- linkname_ptr=linkname;
+ klinkname_ptr= klinkname;
/*
Don't create the table if the link or file exists to ensure that one
doesn't accidently destroy another table.
@@ -617,10 +618,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
{
char *iext= strrchr(name, '.');
int have_iext= iext && !strcmp(iext, MI_NAME_IEXT);
- fn_format(filename, name, "", MI_NAME_IEXT,
+ fn_format(kfilename, name, "", MI_NAME_IEXT,
MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH |
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
- linkname_ptr=0;
+ klinkname_ptr= 0;
/* Replace the current file */
create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
@@ -635,7 +636,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
NOTE: The filename is compared against unique_file_name of every
open table. Hence we need a real path here.
*/
- if (!internal_table && test_if_reopen(filename))
+ if (!internal_table && test_if_reopen(kfilename))
{
my_printf_error(HA_ERR_TABLE_EXIST, "MyISAM table '%s' is in use "
"(most likely by a MERGE table). Try FLUSH TABLES.",
@@ -645,7 +646,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
}
if ((file= mysql_file_create_with_symlink(mi_key_file_kfile,
- linkname_ptr, filename, 0,
+ klinkname_ptr, kfilename, 0,
create_mode,
MYF(MY_WME | create_flag))) < 0)
goto err;
@@ -665,31 +666,31 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
/* chop off the table name, tempory tables use generated name */
if ((path= strrchr(ci->data_file_name, FN_LIBCHAR)))
*path= '\0';
- fn_format(filename, name, ci->data_file_name, MI_NAME_DEXT,
+ fn_format(dfilename, name, ci->data_file_name, MI_NAME_DEXT,
MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_APPEND_EXT);
}
else
{
- fn_format(filename, ci->data_file_name, "", MI_NAME_DEXT,
+ fn_format(dfilename, ci->data_file_name, "", MI_NAME_DEXT,
MY_UNPACK_FILENAME |
(have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT));
}
- fn_format(linkname, name, "",MI_NAME_DEXT,
+ fn_format(dlinkname, name, "",MI_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT);
- linkname_ptr=linkname;
+ dlinkname_ptr= dlinkname;
create_flag=0;
}
else
{
- fn_format(filename,name,"", MI_NAME_DEXT,
+ fn_format(dfilename,name,"", MI_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT);
- linkname_ptr=0;
+ dlinkname_ptr= 0;
create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
if ((dfile=
mysql_file_create_with_symlink(mi_key_file_dfile,
- linkname_ptr, filename, 0,
+ dlinkname_ptr, dfilename, 0,
create_mode,
MYF(MY_WME | create_flag))) < 0)
goto err;
@@ -843,19 +844,21 @@ err_no_lock:
(void) mysql_file_close(dfile, MYF(0));
/* fall through */
case 2:
- if (! (flags & HA_DONT_TOUCH_DATA))
- mysql_file_delete_with_symlink(mi_key_file_dfile,
- fn_format(filename, name, "", MI_NAME_DEXT,
- MY_UNPACK_FILENAME | MY_APPEND_EXT),
- MYF(0));
+ if (! (flags & HA_DONT_TOUCH_DATA))
+ {
+ mysql_file_delete(mi_key_file_dfile, dfilename, MYF(0));
+ if (dlinkname_ptr)
+ mysql_file_delete(mi_key_file_dfile, dlinkname_ptr, MYF(0));
+ }
/* fall through */
case 1:
(void) mysql_file_close(file, MYF(0));
if (! (flags & HA_DONT_TOUCH_DATA))
- mysql_file_delete_with_symlink(mi_key_file_kfile,
- fn_format(filename, name, "", MI_NAME_IEXT,
- MY_UNPACK_FILENAME | MY_APPEND_EXT),
- MYF(0));
+ {
+ mysql_file_delete(mi_key_file_kfile, kfilename, MYF(0));
+ if (klinkname_ptr)
+ mysql_file_delete(mi_key_file_kfile, klinkname_ptr, MYF(0));
+ }
}
my_free(rec_per_key_part);
DBUG_RETURN(my_errno=save_errno); /* return the fatal errno */
diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c
index 7da960011ca..a72a94b06d2 100644
--- a/storage/myisam/mi_delete_table.c
+++ b/storage/myisam/mi_delete_table.c
@@ -26,30 +26,6 @@
#define mi_key_file_dfile 0
#endif
-static int delete_one_file(const char *name, const char *ext,
- PSI_file_key pskey __attribute__((unused)),
- myf flags)
-{
- char from[FN_REFLEN];
- DBUG_ENTER("delete_one_file");
- fn_format(from,name, "", ext, MY_UNPACK_FILENAME | MY_APPEND_EXT);
- if (my_is_symlink(from) && (*myisam_test_invalid_symlink)(from))
- {
- /*
- Symlink is pointing to file in data directory.
- Remove symlink, keep file.
- */
- if (mysql_file_delete(pskey, from, flags))
- DBUG_RETURN(my_errno);
- }
- else
- {
- if (mysql_file_delete_with_symlink(pskey, from, flags))
- DBUG_RETURN(my_errno);
- }
- DBUG_RETURN(0);
-}
-
int mi_delete_table(const char *name)
{
int res;
@@ -59,14 +35,14 @@ int mi_delete_table(const char *name)
check_table_is_closed(name,"delete");
#endif
- if ((res= delete_one_file(name, MI_NAME_IEXT, mi_key_file_kfile, MYF(MY_WME))))
- DBUG_RETURN(res);
- if ((res= delete_one_file(name, MI_NAME_DEXT, mi_key_file_dfile, MYF(MY_WME))))
- DBUG_RETURN(res);
+ if (my_handler_delete_with_symlink(mi_key_file_kfile, name, MI_NAME_IEXT, MYF(MY_WME)) ||
+ my_handler_delete_with_symlink(mi_key_file_dfile, name, MI_NAME_DEXT, MYF(MY_WME)))
+ DBUG_RETURN(my_errno);
+
// optionally present:
- delete_one_file(name, ".OLD", mi_key_file_dfile, MYF(0));
- delete_one_file(name, ".TMD", mi_key_file_dfile, MYF(0));
+ my_handler_delete_with_symlink(mi_key_file_dfile, name, ".OLD", MYF(0));
+ my_handler_delete_with_symlink(mi_key_file_dfile, name, ".TMD", MYF(0));
DBUG_RETURN(0);
}
diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c
index 060017f10ad..31612b0e902 100644
--- a/storage/myisam/mi_open.c
+++ b/storage/myisam/mi_open.c
@@ -105,7 +105,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
realpath_err= my_realpath(name_buff,
fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0));
if (my_is_symlink(org_name) &&
- (realpath_err || (*myisam_test_invalid_symlink)(name_buff)))
+ (realpath_err || mysys_test_invalid_symlink(name_buff)))
{
my_errno= HA_WRONG_CREATE_OPTION;
DBUG_RETURN (NULL);
@@ -131,15 +131,17 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
my_errno= HA_ERR_CRASHED;
goto err;
});
- if ((kfile= mysql_file_open(mi_key_file_kfile,
- name_buff,
- (open_mode= O_RDWR) | O_SHARE, MYF(0))) < 0)
+
+ DEBUG_SYNC_C("mi_open_kfile");
+ if ((kfile= mysql_file_open(mi_key_file_kfile, name_buff,
+ (open_mode= O_RDWR) | O_SHARE | O_NOFOLLOW,
+ MYF(MY_NOSYMLINKS))) < 0)
{
if ((errno != EROFS && errno != EACCES) ||
mode != O_RDONLY ||
- (kfile= mysql_file_open(mi_key_file_kfile,
- name_buff,
- (open_mode= O_RDONLY) | O_SHARE, MYF(0))) < 0)
+ (kfile= mysql_file_open(mi_key_file_kfile, name_buff,
+ (open_mode= O_RDONLY) | O_SHARE| O_NOFOLLOW,
+ MYF(MY_NOSYMLINKS))) < 0)
goto err;
}
share->mode=open_mode;
@@ -183,7 +185,18 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
(void) strmov(index_name, org_name);
*strrchr(org_name, '.')= '\0';
(void) fn_format(data_name,org_name,"",MI_NAME_DEXT,
- MY_APPEND_EXT|MY_UNPACK_FILENAME|MY_RESOLVE_SYMLINKS);
+ MY_APPEND_EXT|MY_UNPACK_FILENAME);
+ if (my_is_symlink(data_name))
+ {
+ if (my_realpath(data_name, data_name, MYF(0)))
+ goto err;
+ if (mysys_test_invalid_symlink(data_name))
+ {
+ my_errno= HA_WRONG_CREATE_OPTION;
+ goto err;
+ }
+ share->mode|= O_NOFOLLOW; /* all symlinks are resolved by realpath() */
+ }
info_length=mi_uint2korr(share->state.header.header_length);
base_pos=mi_uint2korr(share->state.header.base_pos);
@@ -497,7 +510,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
lock_error=1; /* Database unlocked */
}
- if (mi_open_datafile(&info, share, name, -1))
+ if (mi_open_datafile(&info, share))
goto err;
errpos=5;
@@ -578,7 +591,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
my_errno=EACCES; /* Can't open in write mode */
goto err;
}
- if (mi_open_datafile(&info, share, name, old_info->dfile))
+ if (mi_open_datafile(&info, share))
goto err;
errpos=5;
have_rtree= old_info->rtree_recursion_state != NULL;
@@ -1250,33 +1263,14 @@ uchar *mi_recinfo_read(uchar *ptr, MI_COLUMNDEF *recinfo)
Open data file.
We can't use dup() here as the data file descriptors need to have different
active seek-positions.
-
-The argument file_to_dup is here for the future if there would on some OS
-exist a dup()-like call that would give us two different file descriptors.
*************************************************************************/
-int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *org_name,
- File file_to_dup __attribute__((unused)))
+int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share)
{
- char *data_name= share->data_file_name;
- char real_data_name[FN_REFLEN];
-
- if (org_name)
- {
- fn_format(real_data_name,org_name,"",MI_NAME_DEXT,4);
- if (my_is_symlink(real_data_name))
- {
- if (my_realpath(real_data_name, real_data_name, MYF(0)) ||
- (*myisam_test_invalid_symlink)(real_data_name))
- {
- my_errno= HA_WRONG_CREATE_OPTION;
- return 1;
- }
- data_name= real_data_name;
- }
- }
- info->dfile= mysql_file_open(mi_key_file_dfile,
- data_name, share->mode | O_SHARE, MYF(MY_WME));
+ myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS: 0);
+ DEBUG_SYNC_C("mi_open_datafile");
+ info->dfile= mysql_file_open(mi_key_file_dfile, share->data_file_name,
+ share->mode | O_SHARE, MYF(flags));
return info->dfile >= 0 ? 0 : 1;
}
@@ -1285,8 +1279,8 @@ int mi_open_keyfile(MYISAM_SHARE *share)
{
if ((share->kfile= mysql_file_open(mi_key_file_kfile,
share->unique_file_name,
- share->mode | O_SHARE,
- MYF(MY_WME))) < 0)
+ share->mode | O_SHARE | O_NOFOLLOW,
+ MYF(MY_NOSYMLINKS | MY_WME))) < 0)
return 1;
return 0;
}
diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c
index d77f4f6b8e2..49019fb861c 100644
--- a/storage/myisam/mi_static.c
+++ b/storage/myisam/mi_static.c
@@ -42,14 +42,6 @@ ulong myisam_data_pointer_size=4;
ulonglong myisam_mmap_size= SIZE_T_MAX, myisam_mmap_used= 0;
my_bool (*mi_killed)(MI_INFO *)= mi_killed_standalone;
-static int always_valid(const char *filename __attribute__((unused)))
-{
- return 0;
-}
-
-int (*myisam_test_invalid_symlink)(const char *filename)= always_valid;
-
-
/*
read_vec[] is used for converting between P_READ_KEY.. and SEARCH_
Position is , == , >= , <= , > , <
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index 7835ab83531..edbe235e190 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -1047,7 +1047,7 @@ static int myisamchk(HA_CHECK *param, char * filename)
MYF(MY_WME)); /* Close new file */
error|=change_to_newfile(filename, MI_NAME_DEXT, DATA_TMP_EXT,
0, MYF(0));
- if (mi_open_datafile(info,info->s, NULL, -1))
+ if (mi_open_datafile(info, info->s))
error=1;
param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */
param->read_cache.file=info->dfile;
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 07c4a5b473a..92fc5e45d5d 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -713,8 +713,7 @@ void mi_disable_indexes_for_rebuild(MI_INFO *info, ha_rows rows,
my_bool all_keys);
extern MI_INFO *test_if_reopen(char *filename);
my_bool check_table_is_closed(const char *name, const char *where);
-int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, const char *orn_name,
- File file_to_dup);
+int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share);
int mi_open_keyfile(MYISAM_SHARE *share);
void mi_setup_functions(register MYISAM_SHARE *share);
diff --git a/storage/xtradb/btr/btr0btr.cc b/storage/xtradb/btr/btr0btr.cc
index ecea98fccfe..36bbb0db9e0 100644
--- a/storage/xtradb/btr/btr0btr.cc
+++ b/storage/xtradb/btr/btr0btr.cc
@@ -3416,8 +3416,6 @@ btr_level_list_remove_func(
ulint prev_page_no;
ulint next_page_no;
- ut_ad(page != NULL);
- ut_ad(mtr != NULL);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
ut_ad(space == page_get_space_id(page));
/* Get the previous and next page numbers of page */
diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc
index 214d050d562..bf459c4d456 100644
--- a/storage/xtradb/btr/btr0cur.cc
+++ b/storage/xtradb/btr/btr0cur.cc
@@ -2014,7 +2014,6 @@ btr_cur_update_alloc_zip_func(
const page_t* page = page_cur_get_page(cursor);
ut_ad(page_zip == page_cur_get_page_zip(cursor));
- ut_ad(page_zip);
ut_ad(!dict_index_is_ibuf(index));
ut_ad(rec_offs_validate(page_cur_get_rec(cursor), index, offsets));
@@ -3141,7 +3140,7 @@ btr_cur_del_mark_set_clust_rec(
ut_ad(page_is_leaf(page_align(rec)));
#ifdef UNIV_DEBUG
- if (btr_cur_print_record_ops && (thr != NULL)) {
+ if (btr_cur_print_record_ops) {
btr_cur_trx_report(thr_get_trx(thr)->id, index, "del mark ");
rec_print_new(stderr, rec, offsets);
}
@@ -4482,7 +4481,6 @@ btr_cur_disown_inherited_fields(
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec));
ut_ad(rec_offs_any_extern(offsets));
- ut_ad(mtr);
for (i = 0; i < rec_offs_n_fields(offsets); i++) {
if (rec_offs_nth_extern(offsets, i)
@@ -4545,9 +4543,6 @@ btr_push_update_extern_fields(
ulint n;
const upd_field_t* uf;
- ut_ad(tuple);
- ut_ad(update);
-
uf = update->fields;
n = upd_get_n_fields(update);
@@ -4731,7 +4726,6 @@ btr_store_big_rec_extern_fields(
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_any_extern(offsets));
- ut_ad(btr_mtr);
ut_ad(mtr_memo_contains(btr_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(btr_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
diff --git a/storage/xtradb/buf/buf0buddy.cc b/storage/xtradb/buf/buf0buddy.cc
index 8cb880c1169..2ee39c6c992 100644
--- a/storage/xtradb/buf/buf0buddy.cc
+++ b/storage/xtradb/buf/buf0buddy.cc
@@ -485,7 +485,6 @@ buf_buddy_alloc_low(
{
buf_block_t* block;
- ut_ad(lru);
ut_ad(mutex_own(&buf_pool->LRU_list_mutex));
ut_ad(!mutex_own(&buf_pool->zip_mutex));
ut_ad(i >= buf_buddy_get_slot(UNIV_ZIP_SIZE_MIN));
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index 21b10196a25..520997591e8 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -3691,15 +3691,6 @@ buf_page_init(
/* Set the state of the block */
buf_block_set_file_page(block, space, offset);
-#ifdef UNIV_DEBUG_VALGRIND
- if (!space) {
- /* Silence valid Valgrind warnings about uninitialized
- data being written to data files. There are some unused
- bytes on some pages that InnoDB does not initialize. */
- UNIV_MEM_VALID(block->frame, UNIV_PAGE_SIZE);
- }
-#endif /* UNIV_DEBUG_VALGRIND */
-
buf_block_init_low(block);
block->lock_hash_val = lock_rec_hash(space, offset);
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 339e5615bea..01eaecb860d 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -6156,7 +6156,6 @@ dict_set_corrupted(
row_mysql_lock_data_dictionary(trx);
}
- ut_ad(index);
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
diff --git a/storage/xtradb/dyn/dyn0dyn.cc b/storage/xtradb/dyn/dyn0dyn.cc
index 3ef5297a7c9..dd1f6863c14 100644
--- a/storage/xtradb/dyn/dyn0dyn.cc
+++ b/storage/xtradb/dyn/dyn0dyn.cc
@@ -40,7 +40,6 @@ dyn_array_add_block(
mem_heap_t* heap;
dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
if (arr->heap == NULL) {
diff --git a/storage/xtradb/fsp/fsp0fsp.cc b/storage/xtradb/fsp/fsp0fsp.cc
index 64576c93545..7811f1cf5cc 100644
--- a/storage/xtradb/fsp/fsp0fsp.cc
+++ b/storage/xtradb/fsp/fsp0fsp.cc
@@ -1067,8 +1067,6 @@ fsp_fill_free_list(
ulint i;
mtr_t ibuf_mtr;
- ut_ad(header != NULL);
- ut_ad(mtr != NULL);
ut_ad(page_offset(header) == FSP_HEADER_OFFSET);
/* Check if we can fill free list from above the free list limit */
@@ -1351,9 +1349,6 @@ fsp_alloc_free_page(
ulint page_no;
ulint space_size;
- ut_ad(mtr);
- ut_ad(init_mtr);
-
header = fsp_get_space_header(space, zip_size, mtr);
/* Get the hinted descriptor */
@@ -2372,7 +2367,6 @@ fseg_alloc_free_page_low(
ibool success;
ulint n;
- ut_ad(mtr);
ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR));
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
== FSEG_MAGIC_N_VALUE);
diff --git a/storage/xtradb/include/btr0sea.ic b/storage/xtradb/include/btr0sea.ic
index 3cbcff75f31..e963d8a8449 100644
--- a/storage/xtradb/include/btr0sea.ic
+++ b/storage/xtradb/include/btr0sea.ic
@@ -90,7 +90,6 @@ btr_search_get_hash_table(
/*======================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->search_table);
return(index->search_table);
@@ -105,7 +104,6 @@ btr_search_get_latch(
/*=================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->search_latch >= btr_search_latch_arr &&
index->search_latch < btr_search_latch_arr +
btr_search_index_num);
@@ -132,8 +130,6 @@ btr_search_index_init(
/*===============*/
dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
-
index->search_latch =
&btr_search_latch_arr[btr_search_get_key(index->id)];
index->search_table =
diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic
index 58a9ef4d65d..efc2c3f0e68 100644
--- a/storage/xtradb/include/dict0dict.ic
+++ b/storage/xtradb/include/dict0dict.ic
@@ -266,7 +266,6 @@ dict_index_is_clust(
/*================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->type & DICT_CLUSTERED);
@@ -280,7 +279,6 @@ dict_index_is_unique(
/*=================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->type & DICT_UNIQUE);
@@ -295,7 +293,6 @@ dict_index_is_ibuf(
/*===============*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->type & DICT_IBUF);
@@ -327,7 +324,6 @@ dict_index_is_sec_or_ibuf(
{
ulint type;
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
type = index->type;
@@ -345,7 +341,6 @@ dict_table_get_n_user_cols(
/*=======================*/
const dict_table_t* table) /*!< in: table */
{
- ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
return(table->n_cols - DATA_N_SYS_COLS);
@@ -377,7 +372,6 @@ dict_table_get_n_cols(
/*==================*/
const dict_table_t* table) /*!< in: table */
{
- ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
return(table->n_cols);
@@ -1373,7 +1367,6 @@ dict_index_is_corrupted(
/*====================*/
const dict_index_t* index) /*!< in: index */
{
- ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return((index->type & DICT_CORRUPT)
diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h
index 942f8ba1b06..b4307f7d168 100644
--- a/storage/xtradb/include/dict0mem.h
+++ b/storage/xtradb/include/dict0mem.h
@@ -138,7 +138,7 @@ allows InnoDB to update_create_info() accordingly. */
+ DICT_TF_WIDTH_DATA_DIR)
/** A mask of all the known/used bits in table flags */
-#define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS))
+#define DICT_TF_BIT_MASK (~(~0U << DICT_TF_BITS))
/** Zero relative shift position of the COMPACT field */
#define DICT_TF_POS_COMPACT 0
diff --git a/storage/xtradb/include/dyn0dyn.ic b/storage/xtradb/include/dyn0dyn.ic
index f18f2e6dff9..13003862638 100644
--- a/storage/xtradb/include/dyn0dyn.ic
+++ b/storage/xtradb/include/dyn0dyn.ic
@@ -47,8 +47,6 @@ dyn_block_get_used(
/*===============*/
const dyn_block_t* block) /*!< in: dyn array block */
{
- ut_ad(block);
-
return((block->used) & ~DYN_BLOCK_FULL_FLAG);
}
@@ -76,7 +74,6 @@ dyn_array_create(
dyn_array_t* arr) /*!< in/out: memory buffer of
size sizeof(dyn_array_t) */
{
- ut_ad(arr);
#if DYN_ARRAY_DATA_SIZE >= DYN_BLOCK_FULL_FLAG
# error "DYN_ARRAY_DATA_SIZE >= DYN_BLOCK_FULL_FLAG"
#endif
@@ -119,7 +116,6 @@ dyn_array_push(
dyn_block_t* block;
ulint used;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
ut_ad(size <= DYN_ARRAY_DATA_SIZE);
ut_ad(size);
@@ -159,7 +155,6 @@ dyn_array_open(
{
dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
ut_ad(size <= DYN_ARRAY_DATA_SIZE);
ut_ad(size);
@@ -195,7 +190,6 @@ dyn_array_close(
{
dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
block = dyn_array_get_last_block(arr);
@@ -222,7 +216,6 @@ dyn_array_get_element(
{
const dyn_block_t* block;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
/* Get the first array block */
@@ -260,7 +253,6 @@ dyn_array_get_data_size(
const dyn_block_t* block;
ulint sum = 0;
- ut_ad(arr);
ut_ad(arr->magic_n == DYN_BLOCK_MAGIC_N);
if (arr->heap == NULL) {
diff --git a/storage/xtradb/include/fsp0fsp.h b/storage/xtradb/include/fsp0fsp.h
index 099cb8edc14..0097537e4d6 100644
--- a/storage/xtradb/include/fsp0fsp.h
+++ b/storage/xtradb/include/fsp0fsp.h
@@ -61,7 +61,7 @@ is found in a remote location, not the default data directory. */
+ FSP_FLAGS_WIDTH_DATA_DIR)
/** A mask of all the known/used bits in tablespace flags */
-#define FSP_FLAGS_MASK (~(~0 << FSP_FLAGS_WIDTH))
+#define FSP_FLAGS_MASK (~(~0U << FSP_FLAGS_WIDTH))
/** Zero relative shift position of the POST_ANTELOPE field */
#define FSP_FLAGS_POS_POST_ANTELOPE 0
diff --git a/storage/xtradb/include/mach0data.ic b/storage/xtradb/include/mach0data.ic
index 27b9f62b552..4b9275cc12c 100644
--- a/storage/xtradb/include/mach0data.ic
+++ b/storage/xtradb/include/mach0data.ic
@@ -52,7 +52,6 @@ mach_read_from_1(
/*=============*/
const byte* b) /*!< in: pointer to byte */
{
- ut_ad(b);
return((ulint)(b[0]));
}
@@ -132,7 +131,6 @@ mach_read_from_3(
/*=============*/
const byte* b) /*!< in: pointer to 3 bytes */
{
- ut_ad(b);
return( ((ulint)(b[0]) << 16)
| ((ulint)(b[1]) << 8)
| (ulint)(b[2])
@@ -182,7 +180,6 @@ mach_read_from_4(
/*=============*/
const byte* b) /*!< in: pointer to four bytes */
{
- ut_ad(b);
return( ((ulint)(b[0]) << 24)
| ((ulint)(b[1]) << 16)
| ((ulint)(b[2]) << 8)
@@ -261,8 +258,6 @@ mach_read_compressed(
{
ulint flag;
- ut_ad(b);
-
flag = mach_read_from_1(b);
if (flag < 0x80UL) {
@@ -339,8 +334,6 @@ mach_read_from_7(
/*=============*/
const byte* b) /*!< in: pointer to 7 bytes */
{
- ut_ad(b);
-
return(ut_ull_create(mach_read_from_3(b), mach_read_from_4(b + 3)));
}
@@ -370,8 +363,6 @@ mach_read_from_6(
/*=============*/
const byte* b) /*!< in: pointer to 6 bytes */
{
- ut_ad(b);
-
return(ut_ull_create(mach_read_from_2(b), mach_read_from_4(b + 2)));
}
@@ -419,8 +410,6 @@ mach_ull_read_compressed(
ib_uint64_t n;
ulint size;
- ut_ad(b);
-
n = (ib_uint64_t) mach_read_compressed(b);
size = mach_get_compressed_size((ulint) n);
@@ -486,8 +475,6 @@ mach_ull_read_much_compressed(
ib_uint64_t n;
ulint size;
- ut_ad(b);
-
if (*b != (byte)0xFF) {
n = 0;
size = 0;
diff --git a/storage/xtradb/include/page0page.ic b/storage/xtradb/include/page0page.ic
index 4a22a32112f..80939bbb828 100644
--- a/storage/xtradb/include/page0page.ic
+++ b/storage/xtradb/include/page0page.ic
@@ -154,7 +154,6 @@ page_header_get_offs(
{
ulint offs;
- ut_ad(page);
ut_ad((field == PAGE_FREE)
|| (field == PAGE_LAST_INSERT)
|| (field == PAGE_HEAP_TOP));
diff --git a/storage/xtradb/mtr/mtr0mtr.cc b/storage/xtradb/mtr/mtr0mtr.cc
index 5ed0803727f..ed44fba9762 100644
--- a/storage/xtradb/mtr/mtr0mtr.cc
+++ b/storage/xtradb/mtr/mtr0mtr.cc
@@ -312,7 +312,6 @@ mtr_commit(
/*=======*/
mtr_t* mtr) /*!< in: mini-transaction */
{
- ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad(!mtr->inside_ibuf);
diff --git a/storage/xtradb/page/page0page.cc b/storage/xtradb/page/page0page.cc
index 48c4b53aaa4..1a8271de1e4 100644
--- a/storage/xtradb/page/page0page.cc
+++ b/storage/xtradb/page/page0page.cc
@@ -1447,7 +1447,6 @@ page_dir_split_slot(
ulint i;
ulint n_owned;
- ut_ad(page);
ut_ad(!page_zip || page_is_comp(page));
ut_ad(slot_no > 0);
@@ -1509,7 +1508,6 @@ page_dir_balance_slot(
rec_t* old_rec;
rec_t* new_rec;
- ut_ad(page);
ut_ad(!page_zip || page_is_comp(page));
ut_ad(slot_no > 0);
diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc
index 21008ff0ffe..0d2bb7fb986 100644
--- a/storage/xtradb/page/page0zip.cc
+++ b/storage/xtradb/page/page0zip.cc
@@ -4814,8 +4814,6 @@ page_zip_parse_compress(
ulint size;
ulint trailer_size;
- ut_ad(ptr != NULL);
- ut_ad(end_ptr != NULL);
ut_ad(!page == !page_zip);
if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) {
diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc
index c1436f9e1b7..9029b06abd6 100644
--- a/storage/xtradb/row/row0merge.cc
+++ b/storage/xtradb/row/row0merge.cc
@@ -952,14 +952,8 @@ row_merge_read_rec(
ulint data_size;
ulint avail_size;
- ut_ad(block);
- ut_ad(buf);
ut_ad(b >= &block[0]);
ut_ad(b < &block[srv_sort_buf_size]);
- ut_ad(index);
- ut_ad(foffs);
- ut_ad(mrec);
- ut_ad(offsets);
ut_ad(*offsets == 1 + REC_OFFS_HEADER_SIZE
+ dict_index_get_n_fields(index));
diff --git a/storage/xtradb/row/row0upd.cc b/storage/xtradb/row/row0upd.cc
index f346adde850..66fe55bbcce 100644
--- a/storage/xtradb/row/row0upd.cc
+++ b/storage/xtradb/row/row0upd.cc
@@ -1116,8 +1116,6 @@ row_upd_index_replace_new_col_vals_index_pos(
ulint n_fields;
const ulint zip_size = dict_table_zip_size(index->table);
- ut_ad(index);
-
dtuple_set_info_bits(entry, update->info_bits);
if (order_only) {
@@ -1302,8 +1300,6 @@ row_upd_changes_ord_field_binary_func(
ulint i;
const dict_index_t* clust_index;
- ut_ad(index);
- ut_ad(update);
ut_ad(thr);
ut_ad(thr->graph);
ut_ad(thr->graph->trx);
diff --git a/support-files/SELinux/CMakeLists.txt b/support-files/SELinux/CMakeLists.txt
index e3cdb26ca8f..996d56d6c05 100644
--- a/support-files/SELinux/CMakeLists.txt
+++ b/support-files/SELinux/CMakeLists.txt
@@ -20,7 +20,7 @@ MARK_AS_ADVANCED(CHECKMODULE SEMODULE_PACKAGE)
SET(params DESTINATION ${INSTALL_SUPPORTFILESDIR}/SELinux COMPONENT SupportFiles)
IF(CHECKMODULE AND SEMODULE_PACKAGE)
- FOREACH(pol centos6-mariadb)
+ FOREACH(pol mariadb)
SET(src ${CMAKE_CURRENT_SOURCE_DIR}/${pol}.te)
SET(mod ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod)
SET(out ${CMAKE_CURRENT_BINARY_DIR}/${pol}.pp)
@@ -32,4 +32,4 @@ IF(CHECKMODULE AND SEMODULE_PACKAGE)
INSTALL(FILES ${out} ${params})
ENDFOREACH()
ENDIF()
-INSTALL(FILES centos6-mariadb.te rhel4-mysql.fc rhel4-mysql.te ${params})
+INSTALL(FILES mariadb.te rhel4-mysql.fc rhel4-mysql.te ${params})
diff --git a/support-files/SELinux/centos6-mariadb.te b/support-files/SELinux/mariadb.te
index 1d3de52c700..1d3de52c700 100644
--- a/support-files/SELinux/centos6-mariadb.te
+++ b/support-files/SELinux/mariadb.te
diff --git a/support-files/build-tags b/support-files/build-tags
index 4b76e01907a..03b243ee8cc 100755
--- a/support-files/build-tags
+++ b/support-files/build-tags
@@ -1,9 +1,16 @@
#! /bin/sh
rm -f TAGS
-filter='\.cpp$\|\.cc$\|\.c$\|\.h$\|sql_yacc\.yy$\|\.hpp$\|\.ic$\|errmsg-utf8\.txt$'
-list="find . -type f"
-git rev-parse >/dev/null 2>/dev/null && list="git ls-files"
-
-$list |grep $filter | xargs etags -o TAGS --append
+if git rev-parse HEAD >/dev/null 2>&1
+then
+ cd `git rev-parse --show-toplevel`
+ echo client storage dbug libmysql sql-common \
+ sql extra mysys mysys_ssl strings regex pcre vio include \
+ tools unittest plugin libmysqld | \
+ xargs -n1 git ls-files | grep -v '\.jar$' | \
+ xargs etags -o TAGS --append
+else
+ find . -type f ! -name "*.jar" |
+ xargs etags -o TAGS --append
+fi
diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh
index 377a752824d..139d9e3f700 100644
--- a/support-files/rpm/server-postin.sh
+++ b/support-files/rpm/server-postin.sh
@@ -55,36 +55,9 @@ fi
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/SELinux/centos6-mariadb.pp
- fi
- fi
+
+if [ -x /usr/sbin/semodule ] ; then
+ /usr/sbin/semodule -i /usr/share/mysql/SELinux/mariadb.pp
fi
if [ -x sbin/restorecon ] ; then
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 2acec60166e..4e4768559d4 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2002, 2012, Oracle and/or its affiliates.
- Copyright (c) 2008, 2013, Monty Program Ab
+/* Copyright (c) 2002, 2014, Oracle and/or its affiliates.
+ Copyright (c) 2008, 2017, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19274,6 +19274,49 @@ static void test_mdev4326()
}
+/**
+ BUG#17512527: LIST HANDLING INCORRECT IN MYSQL_PRUNE_STMT_LIST()
+*/
+static void test_bug17512527()
+{
+ MYSQL *conn;
+ MYSQL_STMT *stmt1, *stmt2;
+ unsigned long thread_id;
+ char query[MAX_TEST_QUERY_LENGTH];
+ int rc;
+
+ conn= client_connect(0, MYSQL_PROTOCOL_SOCKET, 1);
+
+ stmt1 = mysql_stmt_init(conn);
+ check_stmt(stmt1);
+ rc= mysql_stmt_prepare(stmt1, STRING_WITH_LEN("SELECT 1"));
+ check_execute(stmt1, rc);
+
+ stmt2 = mysql_stmt_init(conn);
+ check_stmt(stmt2);
+
+ thread_id= mysql_thread_id(conn);
+ sprintf(query, "KILL %lu", thread_id);
+ if (thread_query(query))
+ exit(1);
+
+ rc= mysql_stmt_prepare(stmt2, STRING_WITH_LEN("SELECT 2"));
+ check_execute(stmt2, rc);
+
+ rc= mysql_stmt_execute(stmt1);
+ check_execute_r(stmt1, rc);
+
+ rc= mysql_stmt_execute(stmt2);
+ check_execute(stmt2, rc);
+
+ mysql_close(conn);
+
+ mysql_stmt_close(stmt2);
+ mysql_stmt_close(stmt1);
+}
+
+
+
/*
Check compressed protocol
*/
@@ -19645,6 +19688,9 @@ static struct my_tests_st my_tests[]= {
{ "test_bug13001491", test_bug13001491 },
{ "test_mdev4326", test_mdev4326 },
{ "test_ps_sp_out_params", test_ps_sp_out_params },
+#ifndef _WIN32
+ { "test_bug17512527", test_bug17512527},
+#endif
{ "test_compressed_protocol", test_compressed_protocol },
{ "test_big_packet", test_big_packet },
{ 0, 0 }