diff -Nru mariadb-10.1-10.1.41/cmake/build_configurations/mysql_release.cmake mariadb-10.1-10.1.43/cmake/build_configurations/mysql_release.cmake --- mariadb-10.1-10.1.41/cmake/build_configurations/mysql_release.cmake 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/cmake/build_configurations/mysql_release.cmake 2019-11-06 06:20:35.000000000 +0000 @@ -118,6 +118,7 @@ IF(UNIX) SET(WITH_EXTRA_CHARSETS all CACHE STRING "") + SET(PLUGIN_AUTH_PAM YES) IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") IF(NOT IGNORE_AIO_CHECK) diff -Nru mariadb-10.1-10.1.41/cmake/cpack_rpm.cmake mariadb-10.1-10.1.43/cmake/cpack_rpm.cmake --- mariadb-10.1-10.1.41/cmake/cpack_rpm.cmake 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/cmake/cpack_rpm.cmake 2019-11-06 06:20:35.000000000 +0000 @@ -37,7 +37,8 @@ SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}") ELSE() SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT") - SET(CPACK_RPM_DEBUGINFO_PACKAGE ON CACHE INTERNAL "") + OPTION(CPACK_RPM_DEBUGINFO_PACKAGE "" ON) + MARK_AS_ADVANCED(CPACK_RPM_DEBUGINFO_PACKAGE) ENDIF() SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}") diff -Nru mariadb-10.1-10.1.41/cmake/os/Linux.cmake mariadb-10.1-10.1.43/cmake/os/Linux.cmake --- mariadb-10.1-10.1.41/cmake/os/Linux.cmake 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/cmake/os/Linux.cmake 2019-11-06 06:20:35.000000000 +0000 @@ -26,9 +26,9 @@ # Fix CMake (< 2.8) flags. -rdynamic exports too many symbols. FOREACH(LANG C CXX) - STRING(REPLACE "-rdynamic" "" + STRING(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS - ${CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS} + "${CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS}" ) ENDFOREACH() diff -Nru mariadb-10.1-10.1.41/dbug/dbug.c mariadb-10.1-10.1.43/dbug/dbug.c --- mariadb-10.1-10.1.41/dbug/dbug.c 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/dbug/dbug.c 2019-11-06 06:20:35.000000000 +0000 @@ -226,11 +226,8 @@ const char *file; /* Name of current user file */ struct _db_stack_frame_ *framep; /* Pointer to current frame */ struct settings *stack; /* debugging settings */ - const char *jmpfunc; /* Remember current function for setjmp */ - const char *jmpfile; /* Remember current file for setjmp */ int lineno; /* Current debugger output line number */ uint level; /* Current function nesting level */ - int jmplevel; /* Remember nesting level at setjmp() */ /* * The following variables are used to hold the state information diff -Nru mariadb-10.1-10.1.41/debian/changelog mariadb-10.1-10.1.43/debian/changelog --- mariadb-10.1-10.1.41/debian/changelog 2019-08-02 17:10:23.000000000 +0000 +++ mariadb-10.1-10.1.43/debian/changelog 2019-11-11 17:49:05.000000000 +0000 @@ -1,3 +1,14 @@ +mariadb-10.1 (1:10.1.43-0ubuntu0.18.04.1) bionic-security; urgency=high + + * SECURITY UPDATE: New upstream version 10.1.43 includes a fix for a + regression introduced in the previous release: + - MDEV-20987: InnoDB fails to start when FTS table has FK relation + Previous release 10.1.41 includes fix for the following security + vulnerability (LP: #1852109): + - CVE-2019-2974 + + -- Otto Kekäläinen Mon, 11 Nov 2019 18:49:05 +0100 + mariadb-10.1 (1:10.1.41-0ubuntu0.18.04.1) bionic-security; urgency=medium * SECURITY UPDATE: New upstream version 10.1.41. Includes fixes for the diff -Nru mariadb-10.1-10.1.41/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch mariadb-10.1-10.1.43/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch --- mariadb-10.1-10.1.41/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch 2019-08-02 17:10:23.000000000 +0000 +++ mariadb-10.1-10.1.43/debian/patches/0025-Change-the-default-optimization-from-O3-to-O2-in-mys.patch 2019-11-11 17:49:05.000000000 +0000 @@ -10,7 +10,7 @@ --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake -@@ -155,12 +155,12 @@ IF(UNIX) +@@ -156,12 +156,12 @@ IF(UNIX) IF(CMAKE_COMPILER_IS_GNUCC) SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized") SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}") @@ -25,7 +25,7 @@ ENDIF() # IBM Z flags -@@ -209,8 +209,8 @@ IF(UNIX) +@@ -210,8 +210,8 @@ IF(UNIX) ENDIF() SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") @@ -36,7 +36,7 @@ SET(WITH_SSL no) ENDIF() ENDIF() -@@ -219,12 +219,12 @@ IF(UNIX) +@@ -220,12 +220,12 @@ IF(UNIX) IF(CMAKE_C_COMPILER_ID MATCHES "Clang") SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing") SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") diff -Nru mariadb-10.1-10.1.41/debian/patches/mysqld_multi_confd.patch mariadb-10.1-10.1.43/debian/patches/mysqld_multi_confd.patch --- mariadb-10.1-10.1.41/debian/patches/mysqld_multi_confd.patch 2019-08-02 17:10:23.000000000 +0000 +++ mariadb-10.1-10.1.43/debian/patches/mysqld_multi_confd.patch 2019-11-11 17:49:05.000000000 +0000 @@ -6,11 +6,9 @@ scripts/mysqld_multi.sh | 1 + 1 file changed, 1 insertion(+) -diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh -index c6515a3..f50f0fe 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh -@@ -497,6 +497,7 @@ sub list_defaults_files +@@ -510,6 +510,7 @@ sub list_defaults_files '@prefix@/my.cnf', ($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef), $opt{'extra-file'}, diff -Nru mariadb-10.1-10.1.41/debian/patches/scripts__mysqld_safe.sh__signals.patch mariadb-10.1-10.1.43/debian/patches/scripts__mysqld_safe.sh__signals.patch --- mariadb-10.1-10.1.41/debian/patches/scripts__mysqld_safe.sh__signals.patch 2019-08-02 17:10:23.000000000 +0000 +++ mariadb-10.1-10.1.43/debian/patches/scripts__mysqld_safe.sh__signals.patch 2019-11-11 17:49:05.000000000 +0000 @@ -11,11 +11,9 @@ scripts/mysqld_safe.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh -index bcaf7b8..3236ebb 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh -@@ -37,7 +37,6 @@ skip_err_log=0 +@@ -38,7 +38,6 @@ skip_err_log=0 syslog_tag_mysqld=mysqld syslog_tag_mysqld_safe=mysqld_safe @@ -23,7 +21,7 @@ # MySQL-specific environment variable. First off, it's not really a umask, # it's the desired mode. Second, it follows umask(2), not umask(3) in that -@@ -182,7 +181,7 @@ eval_log_error () { +@@ -183,7 +182,7 @@ eval_log_error () { # sed buffers output (only GNU sed supports a -u (unbuffered) option) # which means that messages may not get sent to syslog until the # mysqld process quits. @@ -32,7 +30,7 @@ ;; *) echo "Internal program error (non-fatal):" \ -@@ -919,6 +918,13 @@ then +@@ -922,6 +921,13 @@ then fi # diff -Nru mariadb-10.1-10.1.41/Docs/INFO_SRC mariadb-10.1-10.1.43/Docs/INFO_SRC --- mariadb-10.1-10.1.41/Docs/INFO_SRC 2019-07-26 16:34:57.000000000 +0000 +++ mariadb-10.1-10.1.43/Docs/INFO_SRC 2019-11-06 06:20:37.000000000 +0000 @@ -1,8 +1,8 @@ -commit: 403e6615fdd3f5f4de6d159457b2bd2fe566e0ad -date: 2019-07-26 18:17:55 +0300 -build-date: 2019-07-26 16:34:57 +0000 -short: 403e661 +commit: 4e99e67c4e8a04bd03cb0e7efc2ce0129af60c34 +date: 2019-11-06 08:17:03 +0200 +build-date: 2019-11-06 06:20:37 +0000 +short: 4e99e67 branch: HEAD -MariaDB source 10.1.41 +MariaDB source 10.1.43 diff -Nru mariadb-10.1-10.1.41/extra/innochecksum.cc mariadb-10.1-10.1.43/extra/innochecksum.cc --- mariadb-10.1-10.1.41/extra/innochecksum.cc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/extra/innochecksum.cc 2019-11-06 06:20:35.000000000 +0000 @@ -525,7 +525,8 @@ page_size.is_compressed() ? page_size.physical() : 0); if (is_corrupted && log_file) { fprintf(log_file, - "Page " ULINTPF ":%llu may be corrupted;" + "[page id: space=" ULINTPF + ", page_number=%llu] may be corrupted;" " key_version=" ULINTPF "\n", space_id, cur_page_num, mach_read_from_4( diff -Nru mariadb-10.1-10.1.41/extra/mariabackup/backup_copy.cc mariadb-10.1-10.1.43/extra/mariabackup/backup_copy.cc --- mariadb-10.1-10.1.41/extra/mariabackup/backup_copy.cc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/extra/mariabackup/backup_copy.cc 2019-11-06 06:20:35.000000000 +0000 @@ -467,7 +467,7 @@ { memset(rel_path, 0, sizeof rel_path); if (filename) { - strncpy(abs_path, filename, sizeof abs_path); + strncpy(abs_path, filename, sizeof abs_path - 1); abs_path[(sizeof abs_path) - 1] = 0; } else { abs_path[0] = '\0'; diff -Nru mariadb-10.1-10.1.41/extra/mariabackup/changed_page_bitmap.cc mariadb-10.1-10.1.43/extra/mariabackup/changed_page_bitmap.cc --- mariadb-10.1-10.1.41/extra/mariabackup/changed_page_bitmap.cc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/extra/mariabackup/changed_page_bitmap.cc 2019-11-06 06:20:35.000000000 +0000 @@ -390,7 +390,7 @@ bitmap_files->files[array_pos].seq_num = file_seq_num; strncpy(bitmap_files->files[array_pos].name, - bitmap_dir_file_info.name, FN_REFLEN); + bitmap_dir_file_info.name, FN_REFLEN - 1); bitmap_files->files[array_pos].name[FN_REFLEN - 1] = '\0'; bitmap_files->files[array_pos].start_lsn diff -Nru mariadb-10.1-10.1.41/extra/mariabackup/xtrabackup.cc mariadb-10.1-10.1.43/extra/mariabackup/xtrabackup.cc --- mariadb-10.1-10.1.41/extra/mariabackup/xtrabackup.cc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/extra/mariabackup/xtrabackup.cc 2019-11-06 06:20:35.000000000 +0000 @@ -2425,7 +2425,8 @@ goto error; } - strncpy(dst_name, cursor.rel_path, sizeof(dst_name)); + strncpy(dst_name, cursor.rel_path, sizeof dst_name - 1); + dst_name[sizeof dst_name - 1] = '\0'; /* Setup the page write filter */ if (xtrabackup_incremental) { diff -Nru mariadb-10.1-10.1.41/include/heap.h mariadb-10.1-10.1.43/include/heap.h --- mariadb-10.1-10.1.41/include/heap.h 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/include/heap.h 2019-11-06 06:20:35.000000000 +0000 @@ -246,7 +246,7 @@ int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key); -extern int heap_check_heap(HP_INFO *info, my_bool print_status); +extern int heap_check_heap(const HP_INFO *info, my_bool print_status); extern uchar *heap_position(HP_INFO *info); /* The following is for programs that uses the old HEAP interface where diff -Nru mariadb-10.1-10.1.41/include/my_time.h mariadb-10.1-10.1.43/include/my_time.h --- mariadb-10.1-10.1.41/include/my_time.h 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/include/my_time.h 2019-11-06 06:20:35.000000000 +0000 @@ -118,7 +118,7 @@ static inline longlong double_to_datetime(double nr, MYSQL_TIME *ltime, uint flags, int *cut) { - if (nr < 0 || nr > LONGLONG_MAX) + if (nr < 0 || nr > (double)LONGLONG_MAX) nr= (double)LONGLONG_MAX; return number_to_datetime((longlong) floor(nr), (ulong)((nr-floor(nr))*TIME_SECOND_PART_FACTOR), diff -Nru mariadb-10.1-10.1.41/include/my_valgrind.h mariadb-10.1-10.1.43/include/my_valgrind.h --- mariadb-10.1-10.1.41/include/my_valgrind.h 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/include/my_valgrind.h 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Monty Program Ab +/* Copyright (C) 2010, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,11 +55,19 @@ #endif /* HAVE_VALGRIND */ #ifndef DBUG_OFF +/* NOTE: Do not invoke TRASH_FILL directly! Use TRASH_ALLOC or TRASH_FREE. + +The MEM_UNDEFINED() call before memset() is for canceling the effect +of any previous MEM_NOACCESS(). We must invoke MEM_UNDEFINED() after +writing the dummy pattern, unless MEM_NOACCESS() is going to be invoked. +On AddressSanitizer, the MEM_UNDEFINED() in TRASH_ALLOC() has no effect. */ #define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0) #else #define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0) #endif +/** Note that some memory became allocated or uninitialized. */ #define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0) +/** Note that some memory became freed. (Prohibit further access to it.) */ #define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0) #endif /* MY_VALGRIND_INCLUDED */ diff -Nru mariadb-10.1-10.1.41/mysql-test/extra/binlog_tests/drop_temp_table.test mariadb-10.1-10.1.43/mysql-test/extra/binlog_tests/drop_temp_table.test --- mariadb-10.1-10.1.41/mysql-test/extra/binlog_tests/drop_temp_table.test 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/extra/binlog_tests/drop_temp_table.test 2019-11-06 06:20:35.000000000 +0000 @@ -150,16 +150,16 @@ --echo # Test case for DROP query. --connection default -CREATE TABLE t1 (a INT) ENGINE=INNODB; +CREATE TABLE t2 (a INT) ENGINE=INNODB; --connection con1 -CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB; +CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB; --connection default -DROP TABLE t1; +DROP TABLE t2; --connection con1 -DROP TABLE t1; +DROP TABLE t2; --connection default --exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql diff -Nru mariadb-10.1-10.1.41/mysql-test/include/index_merge1.inc mariadb-10.1-10.1.43/mysql-test/include/index_merge1.inc --- mariadb-10.1-10.1.41/mysql-test/include/index_merge1.inc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/include/index_merge1.inc 2019-11-06 06:20:35.000000000 +0000 @@ -2,11 +2,10 @@ # # Index merge tests # -# The variables -# $engine_type -- storage engine to be tested +# The variable # $merge_table_support -- 1 storage engine supports merge tables # -- 0 storage engine does not support merge tables -# have to be set before sourcing this script. +# has to be set before sourcing this script. # # Note: The comments/expectations refer to MyISAM. # They might be not valid for other storage engines. @@ -16,15 +15,10 @@ # old name was t/index_merge.test # main code went into include/index_merge1.inc # +--source include/have_sequence.inc --echo #---------------- Index merge test 1 ------------------------------------------- -eval SET SESSION STORAGE_ENGINE = $engine_type; - ---disable_warnings -drop table if exists t0, t1, t2, t3, t4; ---enable_warnings - # Create and fill a table with simple keys create table t0 ( @@ -32,20 +26,7 @@ INDEX i1(key1) ); ---disable_query_log -insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8); - -let $1=7; -set @d=8; -begin; -while ($1) -{ - eval insert into t0 select key1+@d from t0; - eval set @d=@d*2; - dec $1; -} -commit; ---enable_query_log +insert into t0(key1) select seq from seq_1_to_1024; alter table t0 add key2 int not null, add index i2(key2); alter table t0 add key3 int not null, add index i3(key3); @@ -215,7 +196,7 @@ index i2_2(key2, key2_1) ); -insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0; +insert into t4 select seq,seq,seq div 10, seq % 10, seq % 10, seq from seq_1_to_1024; # the following will be handled by index_merge: select * from t4 where key1a = 3 or key1b = 4; @@ -390,14 +371,13 @@ # # BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 ( a int, b int, filler1 char(200), filler2 char(200), key(a),key(b) ); -insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C; +insert into t1 select @v:= seq % 10, @v, 't1', 'filler2' from seq_1_to_1000; + create table t2 like t1; create table t3 ( @@ -411,8 +391,7 @@ --replace_column 9 # explain select * from t3 where a=1 and b=1; -drop table t3; -drop table t0, t1, t2; +drop table t1, t2, t3; } # @@ -511,16 +490,13 @@ --echo # --echo # BUG#40974: Incorrect query results when using clause evaluated using range check --echo # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - create table t1 (a int); insert into t1 values (1),(2); create table t2(a int, b int); insert into t2 values (1,1), (2, 1000); create table t3 (a int, b int, filler char(100), key(a), key(b)); -insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; +insert into t3 select 1000, 1000,'filler' from seq_1_to_1000; insert into t3 values (1,1,'data'); insert into t3 values (1,1,'data'); -- echo The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) @@ -532,20 +508,14 @@ where exists (select 1 from t2, t3 where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1)); -drop table t0, t1, t2, t3; +drop table t1, t2, t3; --echo # --echo # BUG#44810: index merge and order by with low sort_buffer_size --echo # crashes server! --echo # CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)); -INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT REPEAT('a',128),REPEAT('b',128) FROM seq_1_to_64; SET SESSION sort_buffer_size=1024*8; EXPLAIN SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' diff -Nru mariadb-10.1-10.1.41/mysql-test/include/index_merge2.inc mariadb-10.1-10.1.43/mysql-test/include/index_merge2.inc --- mariadb-10.1-10.1.41/mysql-test/include/index_merge2.inc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/include/index_merge2.inc 2019-11-06 06:20:35.000000000 +0000 @@ -2,10 +2,6 @@ # # Index merge tests # -# The variable -# $engine_type -- storage engine to be tested -# has to be set before sourcing this script. -# # Note: The comments/expectations refer to InnoDB. # They might be not valid for other storage engines. # @@ -14,15 +10,10 @@ # old name was t/index_merge_innodb.test # main code went into include/index_merge2.inc # +--source include/have_sequence.inc --echo #---------------- Index merge test 2 ------------------------------------------- -eval SET SESSION STORAGE_ENGINE = $engine_type; - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - create table t1 ( key1 int not null, @@ -32,16 +23,7 @@ INDEX i2(key2) ); ---disable_query_log -let $1=200; -begin; -while ($1) -{ - eval insert into t1 values (200-$1, $1); - dec $1; -} -commit; ---enable_query_log +INSERT INTO t1 SELECT seq,200-seq FROM seq_0_to_200; # No primary key explain select * from t1 where key1 < 5 or key2 > 197; @@ -80,16 +62,8 @@ index (key2) ); show warnings; ---disable_query_log -let $1=30; -begin; -while ($1) -{ - eval insert into t1 (key1, key2, filler) values ($1/4, $1/8, 'filler-data'); - dec $1; -} -commit; ---enable_query_log +INSERT INTO t1 (key1, key2, filler) +SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0; explain select pk from t1 where key1 = 1 and key2 = 1; select pk from t1 where key2 = 1 and key1 = 1; select pk from t1 ignore index(key1,key2) where key2 = 1 and key1 = 1; @@ -331,19 +305,7 @@ key3 int not null default 0 ); -insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8); - -let $1=7; -set @d=8; -begin; -while ($1) -{ - eval insert into t1 (key1) select key1+@d from t1; - eval set @d=@d*2; - dec $1; -} -commit; - +insert into t1(key1) select seq from seq_1_to_1024; alter table t1 add index i2(key2); alter table t1 add index i3(key3); update t1 set key2=key1,key3=key1; diff -Nru mariadb-10.1-10.1.41/mysql-test/include/index_merge_2sweeps.inc mariadb-10.1-10.1.43/mysql-test/include/index_merge_2sweeps.inc --- mariadb-10.1-10.1.41/mysql-test/include/index_merge_2sweeps.inc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/include/index_merge_2sweeps.inc 2019-11-06 06:20:35.000000000 +0000 @@ -2,24 +2,15 @@ # # 2-sweeps read Index_merge test # -# The variable -# $engine_type -- storage engine to be tested -# has to be set before sourcing this script. -# # Last update: # 2006-08-02 ML test refactored # old name was index_merge_innodb2.test # main code went into include/index_merge_2sweeps.inc # +--source include/have_sequence.inc --echo #---------------- 2-sweeps read Index merge test 2 ------------------------------- -eval SET SESSION STORAGE_ENGINE = $engine_type; - ---disable_warnings -drop table if exists t1; ---enable_warnings - create table t1 ( pk int primary key, key1 int, @@ -30,17 +21,8 @@ index(key2) ); - ---disable_query_log -begin; -let $1=1000; -while ($1) -{ - eval insert into t1 values($1, $1, $1, 'filler-data','filler-data-2'); - dec $1; -} -commit; ---enable_query_log +insert into t1 select seq, seq, seq, 'filler-data', 'filler-data-2' +from seq_1000_to_1; select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 ); diff -Nru mariadb-10.1-10.1.41/mysql-test/include/index_merge_ror_cpk.inc mariadb-10.1-10.1.43/mysql-test/include/index_merge_ror_cpk.inc --- mariadb-10.1-10.1.41/mysql-test/include/index_merge_ror_cpk.inc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/include/index_merge_ror_cpk.inc 2019-11-06 06:20:35.000000000 +0000 @@ -2,10 +2,6 @@ # # Clustered PK ROR-index_merge tests # -# The variable -# $engine_type -- storage engine to be tested -# has to be set before sourcing this script. -# # Note: The comments/expectations refer to InnoDB. # They might be not valid for other storage engines. # @@ -15,13 +11,9 @@ # main code went into include/index_merge_ror_cpk.inc # ---echo #---------------- Clustered PK ROR-index_merge tests ----------------------------- - -eval SET SESSION STORAGE_ENGINE = $engine_type; +--source include/have_sequence.inc ---disable_warnings -drop table if exists t1; ---enable_warnings +--echo #---------------- Clustered PK ROR-index_merge tests ----------------------------- create table t1 ( diff -Nru mariadb-10.1-10.1.41/mysql-test/include/index_merge_ror.inc mariadb-10.1-10.1.43/mysql-test/include/index_merge_ror.inc --- mariadb-10.1-10.1.41/mysql-test/include/index_merge_ror.inc 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/include/index_merge_ror.inc 2019-11-06 06:20:35.000000000 +0000 @@ -17,11 +17,6 @@ --echo #---------------- ROR-index_merge tests ----------------------- -eval SET SESSION STORAGE_ENGINE = $engine_type; - ---disable_warnings -drop table if exists t0,t1,t2; ---enable_warnings create table t1 ( /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ diff -Nru mariadb-10.1-10.1.41/mysql-test/r/ctype_binary.result mariadb-10.1-10.1.43/mysql-test/r/ctype_binary.result --- mariadb-10.1-10.1.41/mysql-test/r/ctype_binary.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/ctype_binary.result 2019-11-06 06:20:35.000000000 +0000 @@ -102,7 +102,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varbinary(1) DEFAULT NULL + `c1` varbinary(2) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select hex(concat(-1)); diff -Nru mariadb-10.1-10.1.41/mysql-test/r/ctype_cp1251.result mariadb-10.1-10.1.43/mysql-test/r/ctype_cp1251.result --- mariadb-10.1-10.1.41/mysql-test/r/ctype_cp1251.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/ctype_cp1251.result 2019-11-06 06:20:35.000000000 +0000 @@ -496,7 +496,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(1) CHARACTER SET cp1251 DEFAULT NULL + `c1` varchar(2) CHARACTER SET cp1251 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select hex(concat(-1)); diff -Nru mariadb-10.1-10.1.41/mysql-test/r/ctype_latin1.result mariadb-10.1-10.1.43/mysql-test/r/ctype_latin1.result --- mariadb-10.1-10.1.41/mysql-test/r/ctype_latin1.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/ctype_latin1.result 2019-11-06 06:20:35.000000000 +0000 @@ -790,7 +790,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(1) DEFAULT NULL + `c1` varchar(2) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select hex(concat(-1)); diff -Nru mariadb-10.1-10.1.41/mysql-test/r/ctype_ucs.result mariadb-10.1-10.1.43/mysql-test/r/ctype_ucs.result --- mariadb-10.1-10.1.41/mysql-test/r/ctype_ucs.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/ctype_ucs.result 2019-11-06 06:20:35.000000000 +0000 @@ -1723,7 +1723,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(1) CHARACTER SET ucs2 DEFAULT NULL + `c1` varchar(2) CHARACTER SET ucs2 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select hex(concat(-1)); diff -Nru mariadb-10.1-10.1.41/mysql-test/r/ctype_utf8.result mariadb-10.1-10.1.43/mysql-test/r/ctype_utf8.result --- mariadb-10.1-10.1.41/mysql-test/r/ctype_utf8.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/ctype_utf8.result 2019-11-06 06:20:35.000000000 +0000 @@ -2565,7 +2565,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` varchar(1) CHARACTER SET utf8 DEFAULT NULL + `c1` varchar(2) CHARACTER SET utf8 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; select hex(concat(-1)); diff -Nru mariadb-10.1-10.1.41/mysql-test/r/drop_bad_db_type.result mariadb-10.1-10.1.43/mysql-test/r/drop_bad_db_type.result --- mariadb-10.1-10.1.41/mysql-test/r/drop_bad_db_type.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/drop_bad_db_type.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,3 +1,4 @@ +SET @save_dbug = @@debug_dbug; set debug_dbug='+d,unstable_db_type'; install soname 'ha_archive'; create table t1 (a int) engine=archive; @@ -30,4 +31,4 @@ t1.frm drop table t1; uninstall soname 'ha_archive'; -set debug_dbug='-d,unstable_db_type'; +set debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/drop_debug.result mariadb-10.1-10.1.43/mysql-test/r/drop_debug.result --- mariadb-10.1-10.1.41/mysql-test/r/drop_debug.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/drop_debug.result 2019-11-06 06:20:35.000000000 +0000 @@ -3,13 +3,12 @@ # -- Bug#43138: DROP DATABASE failure does not clean up message list. # -- -DROP DATABASE IF EXISTS mysql_test; - CREATE DATABASE mysql_test; CREATE TABLE mysql_test.t1(a INT); CREATE TABLE mysql_test.t2(b INT); CREATE TABLE mysql_test.t3(c INT); +SET @save_dbug = @@debug_dbug; SET SESSION debug_dbug= "+d,bug43138"; DROP DATABASE mysql_test; @@ -18,7 +17,7 @@ Error 1051 Unknown table 't2' Error 1051 Unknown table 't3' -SET SESSION debug_dbug= "-d,bug43138"; +SET SESSION debug_dbug=@save_dbug; # -- # -- End of Bug#43138. diff -Nru mariadb-10.1-10.1.41/mysql-test/r/func_math.result mariadb-10.1-10.1.43/mysql-test/r/func_math.result --- mariadb-10.1-10.1.41/mysql-test/r/func_math.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/func_math.result 2019-11-06 06:20:35.000000000 +0000 @@ -796,6 +796,104 @@ 0 DROP TABLE t1; # +# MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal +# +# Testing that dyadic arithmetic operations are symmetric +# for (+1) and (-1) and produce the same length in CONCAT(), +# because (+1) and (-1) have the same data type: signed int. +CREATE TABLE t1 AS SELECT +CONCAT(+1%2.0), +CONCAT(-1%2.0), +CONCAT(+1/2.0), +CONCAT(-1/2.0), +CONCAT(+1*2.0), +CONCAT(-1*2.0), +CONCAT(+1+2.0), +CONCAT(-1+2.0), +CONCAT(+1-2.0), +CONCAT(-1-2.0); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CONCAT(+1%2.0)` varchar(4) DEFAULT NULL, + `CONCAT(-1%2.0)` varchar(4) DEFAULT NULL, + `CONCAT(+1/2.0)` varchar(8) DEFAULT NULL, + `CONCAT(-1/2.0)` varchar(8) DEFAULT NULL, + `CONCAT(+1*2.0)` varchar(5) NOT NULL, + `CONCAT(-1*2.0)` varchar(5) NOT NULL, + `CONCAT(+1+2.0)` varchar(5) NOT NULL, + `CONCAT(-1+2.0)` varchar(5) NOT NULL, + `CONCAT(+1-2.0)` varchar(5) NOT NULL, + `CONCAT(-1-2.0)` varchar(5) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +CONCAT(+1%2), +CONCAT(-1%2), +CONCAT(+1/2), +CONCAT(-1/2), +CONCAT(+1*2), +CONCAT(-1*2), +CONCAT(+1+2), +CONCAT(-1+2), +CONCAT(+1-2), +CONCAT(-1-2); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CONCAT(+1%2)` varchar(2) DEFAULT NULL, + `CONCAT(-1%2)` varchar(2) DEFAULT NULL, + `CONCAT(+1/2)` varchar(7) DEFAULT NULL, + `CONCAT(-1/2)` varchar(7) DEFAULT NULL, + `CONCAT(+1*2)` varchar(3) NOT NULL, + `CONCAT(-1*2)` varchar(3) NOT NULL, + `CONCAT(+1+2)` varchar(3) NOT NULL, + `CONCAT(-1+2)` varchar(3) NOT NULL, + `CONCAT(+1-2)` varchar(3) NOT NULL, + `CONCAT(-1-2)` varchar(3) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# Bug #29723340: MYSQL SERVER CRASH AFTER SQL QUERY WITH DATA ?AST +# +create table t1(a int); +insert t1 values("1e-214748364"); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert t1 values("1e-2147483648"); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert t1 values("1e-21474836480"); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +insert t1 values("1e+214748364"); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert t1 values("1e+2147483647"); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +insert t1 values("1e+21474836470"); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +set global max_allowed_packet= cast(2*1024*1024*1024+1024 as unsigned); +Warnings: +Warning 1292 Truncated incorrect max_allowed_packet value: '2147484672' +set @a=2147483647; +insert t1 values (concat('1', repeat('0', @a+18), 'e-', @a-1, '0')); +Warnings: +Warning 1301 Result of repeat() was larger than max_allowed_packet (1073741824) - truncated +set global max_allowed_packet=default; +select * from t1; +a +0 +0 +0 +2147483647 +2147483647 +2147483647 +NULL +drop table t1; +# # End of 5.5 tests # # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/func_time.result mariadb-10.1-10.1.43/mysql-test/r/func_time.result --- mariadb-10.1-10.1.41/mysql-test/r/func_time.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/func_time.result 2019-11-06 06:20:35.000000000 +0000 @@ -2152,7 +2152,7 @@ SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( - `f2` varchar(26) DEFAULT NULL + `f2` varchar(28) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * FROM t2; f2 diff -Nru mariadb-10.1-10.1.41/mysql-test/r/group_min_max.result mariadb-10.1-10.1.43/mysql-test/r/group_min_max.result --- mariadb-10.1-10.1.41/mysql-test/r/group_min_max.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/group_min_max.result 2019-11-06 06:20:35.000000000 +0000 @@ -2119,12 +2119,12 @@ 1 SIMPLE t1 index NULL idx_t1_2 147 NULL 128 Using index explain extended select a1,a2,count(a2) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 94.12 Using where; Using index Warnings: Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,count(`test`.`t1`.`a2`) AS `count(a2)` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` explain extended select sum(ord(a1)) from t1 where (a1 > 'a') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 index idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 147 NULL 128 75.00 Using where; Using index +1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_2 65 NULL 102 94.12 Using where; Using index Warnings: Note 1003 select sum(ord(`test`.`t1`.`a1`)) AS `sum(ord(a1))` from `test`.`t1` where (`test`.`t1`.`a1` > 'a') group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b` create table t4 as select distinct a1, a2, b, c from t1; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/index_merge_innodb.result mariadb-10.1-10.1.43/mysql-test/r/index_merge_innodb.result --- mariadb-10.1-10.1.41/mysql-test/r/index_merge_innodb.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/index_merge_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,8 +1,9 @@ +# Disable the purge of InnoDB history, to make the test run faster. +START TRANSACTION WITH CONSISTENT SNAPSHOT; +SET STORAGE_ENGINE = InnoDB; set @optimizer_switch_save= @@optimizer_switch; set optimizer_switch='index_merge_sort_intersection=off'; #---------------- Index merge test 2 ------------------------------------------- -SET SESSION STORAGE_ENGINE = InnoDB; -drop table if exists t1,t2; create table t1 ( key1 int not null, @@ -10,6 +11,7 @@ INDEX i1(key1), INDEX i2(key2) ); +INSERT INTO t1 SELECT seq,200-seq FROM seq_0_to_200; explain select * from t1 where key1 < 5 or key2 > 197; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 8 Using sort_union(i1,i2); Using where @@ -67,6 +69,8 @@ ); show warnings; Level Code Message +INSERT INTO t1 (key1, key2, filler) +SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0; explain select pk from t1 where key1 = 1 and key2 = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge key1,key2 key1,key2 5,4 NULL 1 Using intersect(key1,key2); Using where; Using index @@ -292,24 +296,7 @@ key2 int not null default 0, key3 int not null default 0 ); -insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8); -set @d=8; -begin; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -commit; +insert into t1(key1) select seq from seq_1_to_1024; alter table t1 add index i2(key2); alter table t1 add index i3(key3); update t1 set key2=key1,key3=key1; @@ -388,8 +375,6 @@ 1 b DROP TABLE t1, t2; #---------------- 2-sweeps read Index merge test 2 ------------------------------- -SET SESSION STORAGE_ENGINE = InnoDB; -drop table if exists t1; create table t1 ( pk int primary key, key1 int, @@ -399,6 +384,8 @@ index(key1), index(key2) ); +insert into t1 select seq, seq, seq, 'filler-data', 'filler-data-2' +from seq_1000_to_1; select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 ); pk key1 key2 filler filler2 2 2 2 filler-data filler-data-2 @@ -526,8 +513,6 @@ 54 54 54 filler-data filler-data-2 drop table t1; #---------------- Clustered PK ROR-index_merge tests ----------------------------- -SET SESSION STORAGE_ENGINE = InnoDB; -drop table if exists t1; create table t1 ( pk1 int not null, @@ -668,34 +653,27 @@ # # BUG#56862/640419: Wrong result with sort_union index merge when one # of the merged index scans is the primary key scan -# +# +CREATE TABLE t0(a int, b int) ENGINE=MyISAM; CREATE TABLE t1 ( pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, a int, b int, INDEX idx(a)) ENGINE=INNODB; -begin; -INSERT INTO t1(a,b) VALUES +INSERT INTO t0(a,b) VALUES (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t0(a,b) SELECT a+20, b+2000 FROM t0; +INSERT INTO t0(a,b) SELECT a+40, b+4000 FROM t0; +INSERT INTO t0(a,b) SELECT a+80, b+8000 FROM t0; +begin; +INSERT INTO t1(a,b) SELECT t0.a,t0.b FROM t0, seq_1_to_1024; INSERT INTO t1 VALUES (1000000, 0, 0); commit; +DROP TABLE t0; SET SESSION sort_buffer_size = 1024*36; set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off'; @@ -759,8 +737,6 @@ # # BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows # -create table t0(a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 ( pk int auto_increment, zone_id int, @@ -769,7 +745,7 @@ key (zone_id), key (modified) ) engine=innodb; -insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D; +insert into t1 (zone_id, modified) select 0,0 from seq_1_to_10000; update t1 set zone_id=487, modified=9 where pk=7259; update t1 set zone_id=487, modified=9 where pk=7260; update t1 set zone_id=830, modified=9 where pk=8434; @@ -787,7 +763,7 @@ commit; select * from t1 where t1.zone_id=830 AND modified=9; pk zone_id modified -drop table t0, t1; +drop table t1; # # MDEV-376: Wrong result (missing rows) with index_merge+index_merge_intersection, join # @@ -822,14 +798,10 @@ KEY key1 (key1), KEY key2 (key2) ) ENGINE=InnoDB AUTO_INCREMENT=12860259 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; -create table t2(a int); -insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t3(a int); -insert into t3 select A.a + B.a* 10 + C.a * 100 + D.a*1000 from t2 A, t2 B, t2 C, t2 D; insert into t1 (key1, key2, col1,col2,col3,col4) -select a,a, a,a,a,a from t3; +select seq,seq,seq,seq,seq,seq from seq_1_to_10000; SELECT sum(col1) FROM t1 FORCE INDEX (key1,key2) WHERE (key1 between 10 and 8191+10) or (key2= 5); sum(col1) 33632261 -drop table t1,t2,t3; +drop table t1; set optimizer_switch=@tmp_optimizer_switch; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/index_merge_myisam.result mariadb-10.1-10.1.43/mysql-test/r/index_merge_myisam.result --- mariadb-10.1-10.1.41/mysql-test/r/index_merge_myisam.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/index_merge_myisam.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,13 +1,13 @@ +SET STORAGE_ENGINE = MyISAM; set @optimizer_switch_save= @@optimizer_switch; set optimizer_switch='index_merge_sort_intersection=off'; #---------------- Index merge test 1 ------------------------------------------- -SET SESSION STORAGE_ENGINE = MyISAM; -drop table if exists t0, t1, t2, t3, t4; create table t0 ( key1 int not null, INDEX i1(key1) ); +insert into t0(key1) select seq from seq_1_to_1024; alter table t0 add key2 int not null, add index i2(key2); alter table t0 add key3 int not null, add index i3(key3); alter table t0 add key4 int not null, add index i4(key4); @@ -225,7 +225,7 @@ ); Warnings: Note 1831 Duplicate index `i2_2`. This is deprecated and will be disallowed in a future release. -insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0; +insert into t4 select seq,seq,seq div 10, seq % 10, seq % 10, seq from seq_1_to_1024; select * from t4 where key1a = 3 or key1b = 4; key1a key1b key2 key2_1 key2_2 key3 3 3 0 3 3 3 @@ -411,14 +411,12 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge cola,colb cola,colb 3,3 NULL 32 Using intersect(cola,colb); Using where drop table t1; -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 ( a int, b int, filler1 char(200), filler2 char(200), key(a),key(b) ); -insert into t1 select @v:= A.a, @v, 't1', 'filler2' from t0 A, t0 B, t0 C; +insert into t1 select @v:= seq % 10, @v, 't1', 'filler2' from seq_1_to_1000; create table t2 like t1; create table t3 ( a int, b int, @@ -431,8 +429,7 @@ explain select * from t3 where a=1 and b=1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where -drop table t3; -drop table t0, t1, t2; +drop table t1, t2, t3; CREATE TABLE t1(a INT); INSERT INTO t1 VALUES(1); CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); @@ -537,14 +534,12 @@ # # BUG#40974: Incorrect query results when using clause evaluated using range check # -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1 (a int); insert into t1 values (1),(2); create table t2(a int, b int); insert into t2 values (1,1), (2, 1000); create table t3 (a int, b int, filler char(100), key(a), key(b)); -insert into t3 select 1000, 1000,'filler' from t0 A, t0 B, t0 C; +insert into t3 select 1000, 1000,'filler' from seq_1_to_1000; insert into t3 values (1,1,'data'); insert into t3 values (1,1,'data'); The plan should be ALL/ALL/ALL(Range checked for each record (index map: 0x3) @@ -561,19 +556,13 @@ a 1 2 -drop table t0, t1, t2, t3; +drop table t1, t2, t3; # # BUG#44810: index merge and order by with low sort_buffer_size # crashes server! # CREATE TABLE t1(a VARCHAR(128),b VARCHAR(128),KEY(A),KEY(B)); -INSERT INTO t1 VALUES (REPEAT('a',128),REPEAT('b',128)); -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; -INSERT INTO t1 SELECT * FROM t1; +INSERT INTO t1 SELECT REPEAT('a',128),REPEAT('b',128) FROM seq_1_to_64; SET SESSION sort_buffer_size=1024*8; EXPLAIN SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%' @@ -586,8 +575,6 @@ DROP TABLE t1; End of 5.0 tests #---------------- ROR-index_merge tests ----------------------- -SET SESSION STORAGE_ENGINE = MyISAM; -drop table if exists t0,t1,t2; create table t1 ( /* Field names reflect value(rowid) distribution, st=STairs, swt= SaWTooth */ @@ -836,8 +823,6 @@ c1 c2 c3 DROP TABLE t1,t2; #---------------- Index merge test 2 ------------------------------------------- -SET SESSION STORAGE_ENGINE = MyISAM; -drop table if exists t1,t2; create table t1 ( key1 int not null, @@ -845,6 +830,7 @@ INDEX i1(key1), INDEX i2(key2) ); +INSERT INTO t1 SELECT seq,200-seq FROM seq_0_to_200; explain select * from t1 where key1 < 5 or key2 > 197; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge i1,i2 i1,i2 4,4 NULL 10 Using sort_union(i1,i2); Using where @@ -902,6 +888,8 @@ ); show warnings; Level Code Message +INSERT INTO t1 (key1, key2, filler) +SELECT seq/4, seq/8, 'filler-data' FROM seq_30_to_0; explain select pk from t1 where key1 = 1 and key2 = 1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref key1,key2 key1 5 const 4 Using where @@ -1127,24 +1115,7 @@ key2 int not null default 0, key3 int not null default 0 ); -insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8); -set @d=8; -begin; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -insert into t1 (key1) select key1+@d from t1; -set @d=@d*2; -commit; +insert into t1(key1) select seq from seq_1_to_1024; alter table t1 add index i2(key2); alter table t1 add index i3(key3); update t1 set key2=key1,key3=key1; @@ -1223,8 +1194,6 @@ 1 b DROP TABLE t1, t2; #---------------- 2-sweeps read Index merge test 2 ------------------------------- -SET SESSION STORAGE_ENGINE = MyISAM; -drop table if exists t1; create table t1 ( pk int primary key, key1 int, @@ -1234,6 +1203,8 @@ index(key1), index(key2) ); +insert into t1 select seq, seq, seq, 'filler-data', 'filler-data-2' +from seq_1000_to_1; select * from t1 where (key1 >= 2 and key1 <= 10) or (pk >= 4 and pk <=8 ); pk key1 key2 filler filler2 10 10 10 filler-data filler-data-2 @@ -1361,8 +1332,6 @@ 1 1 1 filler-data filler-data-2 drop table t1; #---------------- Clustered PK ROR-index_merge tests ----------------------------- -SET SESSION STORAGE_ENGINE = MyISAM; -drop table if exists t1; create table t1 ( pk1 int not null, @@ -1723,22 +1692,7 @@ key1 int not null, INDEX i1(key1) ); -insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8); -set @d=8; -insert into t0 select key1+ @d from t0; -set @d=@d*2; -insert into t0 select key1+ @d from t0; -set @d=@d*2; -insert into t0 select key1+ @d from t0; -set @d=@d*2; -insert into t0 select key1+ @d from t0; -set @d=@d*2; -insert into t0 select key1+ @d from t0; -set @d=@d*2; -insert into t0 select key1+ @d from t0; -set @d=@d*2; -insert into t0 select key1+ @d from t0; -set @d=@d*2; +insert into t0 select * from seq_1_to_1024; alter table t0 add key2 int not null, add index i2(key2); alter table t0 add key3 int not null, add index i3(key3); alter table t0 add key8 int not null, add index i8(key8); diff -Nru mariadb-10.1-10.1.41/mysql-test/r/innodb_icp.result mariadb-10.1-10.1.43/mysql-test/r/innodb_icp.result --- mariadb-10.1-10.1.41/mysql-test/r/innodb_icp.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/innodb_icp.result 2019-11-06 06:20:35.000000000 +0000 @@ -679,7 +679,7 @@ SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort 1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 HAVING t1.c != 5 ORDER BY t1.c; @@ -690,7 +690,7 @@ SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 HAVING t1.c != 5 ORDER BY t1.c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort 1 SIMPLE t2 ref a a 515 test.t1.a 1 Using where SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0 HAVING t1.c != 5 ORDER BY t1.c; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/join.result mariadb-10.1-10.1.43/mysql-test/r/join.result --- mariadb-10.1-10.1.41/mysql-test/r/join.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/join.result 2019-11-06 06:20:35.000000000 +0000 @@ -2926,6 +2926,332 @@ NULL NULL NULL 5 drop table t1,t2,t3,t4,s1,s2; # +# MDEV-20265: Mix of comma joins with JOIN expressions +# (correction of the fix for MDEV-19421) +# MDEV-20330: duplicate +# +create table t1 (a int); +insert into t1 values (7), (5), (3); +create table t2 (a int); +insert into t2 values (5), (1), (7); +create table t3 (a int); +insert into t3 values (2), (7), (3); +create table t4 (a int); +insert into t4 values (4), (7), (9), (5); +create table t5 (a int); +insert into t5 values (3), (7), (9), (2); +explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a +from t1, t2 join t3 left join t4 on t3.a=t4.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` left join `test`.`t4` on((`test`.`t4`.`a` = `test`.`t3`.`a`)) where 1 +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a +from t1, t2 join t3 left join t4 on t3.a=t4.a; +t1_a t2_a t3_a t4_a +7 5 7 7 +5 5 7 7 +3 5 7 7 +7 1 7 7 +5 1 7 7 +3 1 7 7 +7 7 7 7 +5 7 7 7 +3 7 7 7 +7 5 2 NULL +5 5 2 NULL +3 5 2 NULL +7 1 2 NULL +5 1 2 NULL +3 1 2 NULL +7 7 2 NULL +5 7 2 NULL +3 7 2 NULL +7 5 3 NULL +5 5 3 NULL +3 5 3 NULL +7 1 3 NULL +5 1 3 NULL +3 1 3 NULL +7 7 3 NULL +5 7 3 NULL +3 7 3 NULL +explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a +from t1, t2 join t3 right join t4 on t3.a=t4.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t4` left join (`test`.`t2` join `test`.`t3`) on((`test`.`t3`.`a` = `test`.`t4`.`a`)) where 1 +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a +from t1, t2 join t3 right join t4 on t3.a=t4.a; +t1_a t2_a t3_a t4_a +7 5 7 7 +5 5 7 7 +3 5 7 7 +7 1 7 7 +5 1 7 7 +3 1 7 7 +7 7 7 7 +5 7 7 7 +3 7 7 7 +7 NULL NULL 4 +5 NULL NULL 4 +3 NULL NULL 4 +7 NULL NULL 9 +5 NULL NULL 9 +3 NULL NULL 9 +7 NULL NULL 5 +5 NULL NULL 5 +3 NULL NULL 5 +explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` left join `test`.`t5` on((`test`.`t5`.`a` = `test`.`t4`.`a`)) where 1 +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a; +t1_a t2_a t3_a t4_a t5_a +7 5 2 7 7 +5 5 2 7 7 +3 5 2 7 7 +7 1 2 7 7 +5 1 2 7 7 +3 1 2 7 7 +7 7 2 7 7 +5 7 2 7 7 +3 7 2 7 7 +7 5 7 7 7 +5 5 7 7 7 +3 5 7 7 7 +7 1 7 7 7 +5 1 7 7 7 +3 1 7 7 7 +7 7 7 7 7 +5 7 7 7 7 +3 7 7 7 7 +7 5 3 7 7 +5 5 3 7 7 +3 5 3 7 7 +7 1 3 7 7 +5 1 3 7 7 +3 1 3 7 7 +7 7 3 7 7 +5 7 3 7 7 +3 7 3 7 7 +7 5 2 9 9 +5 5 2 9 9 +3 5 2 9 9 +7 1 2 9 9 +5 1 2 9 9 +3 1 2 9 9 +7 7 2 9 9 +5 7 2 9 9 +3 7 2 9 9 +7 5 7 9 9 +5 5 7 9 9 +3 5 7 9 9 +7 1 7 9 9 +5 1 7 9 9 +3 1 7 9 9 +7 7 7 9 9 +5 7 7 9 9 +3 7 7 9 9 +7 5 3 9 9 +5 5 3 9 9 +3 5 3 9 9 +7 1 3 9 9 +5 1 3 9 9 +3 1 3 9 9 +7 7 3 9 9 +5 7 3 9 9 +3 7 3 9 9 +7 5 2 4 NULL +5 5 2 4 NULL +3 5 2 4 NULL +7 1 2 4 NULL +5 1 2 4 NULL +3 1 2 4 NULL +7 7 2 4 NULL +5 7 2 4 NULL +3 7 2 4 NULL +7 5 7 4 NULL +5 5 7 4 NULL +3 5 7 4 NULL +7 1 7 4 NULL +5 1 7 4 NULL +3 1 7 4 NULL +7 7 7 4 NULL +5 7 7 4 NULL +3 7 7 4 NULL +7 5 3 4 NULL +5 5 3 4 NULL +3 5 3 4 NULL +7 1 3 4 NULL +5 1 3 4 NULL +3 1 3 4 NULL +7 7 3 4 NULL +5 7 3 4 NULL +3 7 3 4 NULL +7 5 2 5 NULL +5 5 2 5 NULL +3 5 2 5 NULL +7 1 2 5 NULL +5 1 2 5 NULL +3 1 2 5 NULL +7 7 2 5 NULL +5 7 2 5 NULL +3 7 2 5 NULL +7 5 7 5 NULL +5 5 7 5 NULL +3 5 7 5 NULL +7 1 7 5 NULL +5 1 7 5 NULL +3 1 7 5 NULL +7 7 7 5 NULL +5 7 7 5 NULL +3 7 7 5 NULL +7 5 3 5 NULL +5 5 3 5 NULL +3 5 3 5 NULL +7 1 3 5 NULL +5 1 3 5 NULL +3 1 3 5 NULL +7 7 3 5 NULL +5 7 3 5 NULL +3 7 3 5 NULL +explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` join `test`.`t5` left join (`test`.`t2` join `test`.`t3` join `test`.`t4`) on((`test`.`t4`.`a` = `test`.`t5`.`a`)) where 1 +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a; +t1_a t2_a t3_a t4_a t5_a +7 5 2 7 7 +5 5 2 7 7 +3 5 2 7 7 +7 1 2 7 7 +5 1 2 7 7 +3 1 2 7 7 +7 7 2 7 7 +5 7 2 7 7 +3 7 2 7 7 +7 5 7 7 7 +5 5 7 7 7 +3 5 7 7 7 +7 1 7 7 7 +5 1 7 7 7 +3 1 7 7 7 +7 7 7 7 7 +5 7 7 7 7 +3 7 7 7 7 +7 5 3 7 7 +5 5 3 7 7 +3 5 3 7 7 +7 1 3 7 7 +5 1 3 7 7 +3 1 3 7 7 +7 7 3 7 7 +5 7 3 7 7 +3 7 3 7 7 +7 5 2 9 9 +5 5 2 9 9 +3 5 2 9 9 +7 1 2 9 9 +5 1 2 9 9 +3 1 2 9 9 +7 7 2 9 9 +5 7 2 9 9 +3 7 2 9 9 +7 5 7 9 9 +5 5 7 9 9 +3 5 7 9 9 +7 1 7 9 9 +5 1 7 9 9 +3 1 7 9 9 +7 7 7 9 9 +5 7 7 9 9 +3 7 7 9 9 +7 5 3 9 9 +5 5 3 9 9 +3 5 3 9 9 +7 1 3 9 9 +5 1 3 9 9 +3 1 3 9 9 +7 7 3 9 9 +5 7 3 9 9 +3 7 3 9 9 +7 NULL NULL NULL 3 +5 NULL NULL NULL 3 +3 NULL NULL NULL 3 +7 NULL NULL NULL 2 +5 NULL NULL NULL 2 +3 NULL NULL NULL 2 +explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) +1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`a` = `test`.`t1`.`a`)) join `test`.`t5` left join (`test`.`t3` join `test`.`t4`) on((`test`.`t4`.`a` = `test`.`t5`.`a`)) where 1 +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a; +t1_a t2_a t3_a t4_a t5_a +5 5 2 7 7 +7 7 2 7 7 +3 NULL 2 7 7 +5 5 7 7 7 +7 7 7 7 7 +3 NULL 7 7 7 +5 5 3 7 7 +7 7 3 7 7 +3 NULL 3 7 7 +5 5 2 9 9 +7 7 2 9 9 +3 NULL 2 9 9 +5 5 7 9 9 +7 7 7 9 9 +3 NULL 7 9 9 +5 5 3 9 9 +7 7 3 9 9 +3 NULL 3 9 9 +5 5 NULL NULL 3 +7 7 NULL NULL 3 +3 NULL NULL NULL 3 +5 5 NULL NULL 2 +7 7 NULL NULL 2 +3 NULL NULL NULL 2 +drop table t1,t2,t3,t4,t5; +select a.a +from (select 1 as a) a, +(select 2 as b) b +cross join +(select 3 as c) c +left join +(select 4 as d) d +on 1; +a +1 +# # End of MariaDB 5.5 tests # # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/log_slow_debug.result mariadb-10.1-10.1.43/mysql-test/r/log_slow_debug.result --- mariadb-10.1-10.1.41/mysql-test/r/log_slow_debug.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/log_slow_debug.result 2019-11-06 06:20:35.000000000 +0000 @@ -6,6 +6,7 @@ FLUSH SLOW LOGS; SET @@GLOBAL.slow_query_log=ON; SET @@GLOBAL.log_slow_admin_statements=ON; +SET @save_dbug = @@debug_dbug; SET SESSION debug_dbug="+d,simulate_slow_query"; CREATE PROCEDURE show_slow_log() BEGIN @@ -129,7 +130,7 @@ # # Clean up # -SET SESSION debug_dbug="-d,simulate_slow_query"; +SET SESSION debug_dbug=@save_dbug; TRUNCATE mysql.slow_log; SET @@global.slow_query_log= @org_slow_query_log; SET @@global.log_output= @org_log_output; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/myisam.result mariadb-10.1-10.1.43/mysql-test/r/myisam.result --- mariadb-10.1-10.1.41/mysql-test/r/myisam.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/myisam.result 2019-11-06 06:20:35.000000000 +0000 @@ -2560,3 +2560,26 @@ select @@global.myisam_block_size; @@global.myisam_block_size 1024 +# +# MDEV-20704 An index on a double column erroneously uses prefix compression +# +CREATE TABLE t1 ( +id INT NOT NULL PRIMARY KEY, +d DOUBLE, +KEY (d) +) ENGINE=MyISAM; + +MyISAM file: MYSQLD_DATADIR/test/t1 +Record format: Fixed length +Character set: latin1_swedish_ci (8) +Data records: 0 Deleted blocks: 0 +Recordlength: 13 + +table description: +Key Start Len Index Type +1 2 4 unique long +2 6 8 multip. double NULL +DROP TABLE t1; +# +# End of 5.5 tests +# diff -Nru mariadb-10.1-10.1.41/mysql-test/r/mysql_tzinfo_to_sql_symlink.result mariadb-10.1-10.1.43/mysql-test/r/mysql_tzinfo_to_sql_symlink.result --- mariadb-10.1-10.1.41/mysql-test/r/mysql_tzinfo_to_sql_symlink.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/mysql_tzinfo_to_sql_symlink.result 2019-11-06 06:20:35.000000000 +0000 @@ -2,9 +2,15 @@ # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # # Verbose run -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -28,11 +34,25 @@ Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # Silent run -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -53,39 +73,83 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # # Testing with explicit timezonefile # -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); SET @time_zone_id= LAST_INSERT_ID(); INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES (@time_zone_id, 0, 0, 0, 'GMT') ; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # # Testing --leap # -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone_leap_second ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone_leap_second; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone_leap_second ENGINE=MyISAM; +END IF| +\d ; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL # -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; TRUNCATE TABLE time_zone_transition_type; ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/order_by_innodb.result mariadb-10.1-10.1.43/mysql-test/r/order_by_innodb.result --- mariadb-10.1-10.1.41/mysql-test/r/order_by_innodb.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/order_by_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -48,3 +48,28 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using sort_union(key1,key2); Using where drop table t0, t1; +# +# MDEV-18094: Query with order by limit picking index scan over filesort +# +create table t0 (a int); +INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0); +CREATE TABLE t1 ( +a int(11), +b int(11), +c int(11), +KEY a_c (a,c), +KEY a_b (a,b) +) ENGINE=InnoDB; +insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C; +# should use ref access +explain select a,b,c from t1 where a=1 and c=2 order by b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a_c,a_b a_c 10 const,const 20 Using where; Using filesort +# both should use range access +explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where +explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where +drop table t1,t0; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/partition_debug_sync.result mariadb-10.1-10.1.43/mysql-test/r/partition_debug_sync.result --- mariadb-10.1-10.1.41/mysql-test/r/partition_debug_sync.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/partition_debug_sync.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,3 @@ -DROP TABLE IF EXISTS t1, t2; SET DEBUG_SYNC= 'RESET'; # # Bug#42438: Crash ha_partition::change_table_ptr diff -Nru mariadb-10.1-10.1.41/mysql-test/r/processlist_notembedded.result mariadb-10.1-10.1.43/mysql-test/r/processlist_notembedded.result --- mariadb-10.1-10.1.41/mysql-test/r/processlist_notembedded.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/processlist_notembedded.result 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1,8 @@ +# +# MDEV-20466: SHOW PROCESSLIST truncates query text on \0 bytes +# +SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync'; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +FOUND /sleep/ in MDEV-20466.text +SET DEBUG_SYNC = 'RESET'; +End of 5.5 tests diff -Nru mariadb-10.1-10.1.41/mysql-test/r/processlist.result mariadb-10.1-10.1.43/mysql-test/r/processlist.result --- mariadb-10.1-10.1.41/mysql-test/r/processlist.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/processlist.result 2019-11-06 06:20:35.000000000 +0000 @@ -17,6 +17,7 @@ command time < 5 Sleep 1 set debug_sync='reset'; +End of 5.5 tests # # 10.1 tests # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/range_vs_index_merge_innodb.result mariadb-10.1-10.1.43/mysql-test/r/range_vs_index_merge_innodb.result --- mariadb-10.1-10.1.41/mysql-test/r/range_vs_index_merge_innodb.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/range_vs_index_merge_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -1796,7 +1796,7 @@ 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 +1 SIMPLE t1 range state,capital state 71 NULL 8 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'; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/range_vs_index_merge.result mariadb-10.1-10.1.43/mysql-test/r/range_vs_index_merge.result --- mariadb-10.1-10.1.41/mysql-test/r/range_vs_index_merge.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/range_vs_index_merge.result 2019-11-06 06:20:35.000000000 +0000 @@ -1795,7 +1795,7 @@ 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 +1 SIMPLE t1 range state,capital state 71 NULL 8 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'; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/selectivity_innodb.result mariadb-10.1-10.1.43/mysql-test/r/selectivity_innodb.result --- mariadb-10.1-10.1.41/mysql-test/r/selectivity_innodb.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/selectivity_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -1645,6 +1645,182 @@ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; drop table t1; drop function f1; +# +# MDEV-19834 Selectivity of an equality condition discounted twice +# +set @@optimizer_use_condition_selectivity=4; +set @@use_stat_tables='preferably'; +create table t1 (a int, b int, key (b), key (a)); +insert into t1 +select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; +analyze table t1 ; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +# Check what info the optimizer has about selectivities +explain extended select * from t1 use index () where a in (17,51,5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.97 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where (`test`.`t1`.`a` in (17,51,5)) +explain extended select * from t1 use index () where b=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 4.76 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where (`test`.`t1`.`b` = 2) +# Now, the equality is used for ref access, while the range condition +# gives selectivity data +explain extended select * from t1 where a in (17,51,5) and b=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ref b,a b 5 const 59 2.80 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` in (17,51,5))) +drop table t1; +set use_stat_tables= @save_use_stat_tables; +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +# +# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1) +# +set @@optimizer_use_condition_selectivity=2; +set names utf8; +CREATE DATABASE world; +use world; +CREATE TABLE Country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +CREATE TABLE City ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +CREATE TABLE CountryLanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +CREATE INDEX Name ON City(Name); +CREATE INDEX CountryPopulation ON City(Country,Population); +CREATE INDEX CountryName ON City(Country,Name); +set @@optimizer_use_condition_selectivity=2; +EXPLAIN +SELECT * FROM City WHERE Country='FIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City ref Country,CountryPopulation,CountryName Country 3 const 7 Using index condition +DROP DATABASE world; +use test; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) ENGINE=MyISAM +DEFAULT CHARSET = utf8; +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +2071 +2061 +2051 +2041 +2031 +2021 +2011 +2001 +1991 +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +DROP TABLE t1; +# +# MDEV-20424: New default value for optimizer_use_condition-selectivity +# leads to bad plan +# +create table t1(a int, b int, c int, d int, key(a,b)); +insert into t1 select 50,seq-1,seq-1,seq from seq_1_to_10; +insert into t1 select seq-1,seq-1,seq-1,seq from seq_1_to_100 limit 90; +create table t2(a int, b int, c int, primary key(a)); +insert into t2 select seq-1,seq-1,seq-1 from seq_1_to_100; +create table t3(a int, b int, c int, primary key(a)); +insert into t3 select seq-1,seq-1,seq-1 from seq_1_to_100 limit 30; +set optimizer_use_condition_selectivity=1; +explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 10 NULL 11 100.00 Using index condition; Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`a` = `test`.`t1`.`c`) and (`test`.`t3`.`a` = `test`.`t1`.`d`) and (`test`.`t1`.`a` = 50) and (`test`.`t1`.`b` <= 100)) +select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +b a a b +0 0 1 1 +1 1 2 2 +2 2 3 3 +3 3 4 4 +4 4 5 5 +5 5 6 6 +6 6 7 7 +7 7 8 8 +8 8 9 9 +9 9 10 10 +set optimizer_use_condition_selectivity=2; +explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 10 NULL 11 11.00 Using index condition; Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`a` = `test`.`t1`.`c`) and (`test`.`t3`.`a` = `test`.`t1`.`d`) and (`test`.`t1`.`a` = 50) and (`test`.`t1`.`b` <= 100)) +select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +b a a b +0 0 1 1 +1 1 2 2 +2 2 3 3 +3 3 4 4 +4 4 5 5 +5 5 6 6 +6 6 7 7 +7 7 8 8 +8 8 9 9 +9 9 10 10 +set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +drop table t1,t2,t3; +# End of 10.1 tests set optimizer_switch=@save_optimizer_switch_for_selectivity_test; set @tmp_ust= @@use_stat_tables; set @tmp_oucs= @@optimizer_use_condition_selectivity; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/selectivity.result mariadb-10.1-10.1.43/mysql-test/r/selectivity.result --- mariadb-10.1-10.1.41/mysql-test/r/selectivity.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/selectivity.result 2019-11-06 06:20:35.000000000 +0000 @@ -1635,3 +1635,179 @@ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; drop table t1; drop function f1; +# +# MDEV-19834 Selectivity of an equality condition discounted twice +# +set @@optimizer_use_condition_selectivity=4; +set @@use_stat_tables='preferably'; +create table t1 (a int, b int, key (b), key (a)); +insert into t1 +select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; +analyze table t1 ; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +# Check what info the optimizer has about selectivities +explain extended select * from t1 use index () where a in (17,51,5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 2.97 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where (`test`.`t1`.`a` in (17,51,5)) +explain extended select * from t1 use index () where b=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 4.76 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where (`test`.`t1`.`b` = 2) +# Now, the equality is used for ref access, while the range condition +# gives selectivity data +explain extended select * from t1 where a in (17,51,5) and b=2; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ref b,a b 5 const 58 2.90 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 2) and (`test`.`t1`.`a` in (17,51,5))) +drop table t1; +set use_stat_tables= @save_use_stat_tables; +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +# +# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1) +# +set @@optimizer_use_condition_selectivity=2; +set names utf8; +CREATE DATABASE world; +use world; +CREATE TABLE Country ( +Code char(3) NOT NULL default '', +Name char(52) NOT NULL default '', +SurfaceArea float(10,2) NOT NULL default '0.00', +Population int(11) NOT NULL default '0', +Capital int(11) default NULL, +PRIMARY KEY (Code), +UNIQUE INDEX (Name) +); +CREATE TABLE City ( +ID int(11) NOT NULL auto_increment, +Name char(35) NOT NULL default '', +Country char(3) NOT NULL default '', +Population int(11) NOT NULL default '0', +PRIMARY KEY (ID), +INDEX (Population), +INDEX (Country) +); +CREATE TABLE CountryLanguage ( +Country char(3) NOT NULL default '', +Language char(30) NOT NULL default '', +Percentage float(3,1) NOT NULL default '0.0', +PRIMARY KEY (Country, Language), +INDEX (Percentage) +); +CREATE INDEX Name ON City(Name); +CREATE INDEX CountryPopulation ON City(Country,Population); +CREATE INDEX CountryName ON City(Country,Name); +set @@optimizer_use_condition_selectivity=2; +EXPLAIN +SELECT * FROM City WHERE Country='FIN'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE City ref Country,CountryPopulation,CountryName CountryName 3 const 5 Using index condition +DROP DATABASE world; +use test; +CREATE TABLE t1 ( +a INT, +b INT NOT NULL, +c char(100), +KEY (b, c), +KEY (b, a, c) +) ENGINE=MyISAM +DEFAULT CHARSET = utf8; +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +a +2071 +2061 +2051 +2041 +2031 +2021 +2011 +2001 +1991 +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +DROP TABLE t1; +# +# MDEV-20424: New default value for optimizer_use_condition-selectivity +# leads to bad plan +# +create table t1(a int, b int, c int, d int, key(a,b)); +insert into t1 select 50,seq-1,seq-1,seq from seq_1_to_10; +insert into t1 select seq-1,seq-1,seq-1,seq from seq_1_to_100 limit 90; +create table t2(a int, b int, c int, primary key(a)); +insert into t2 select seq-1,seq-1,seq-1 from seq_1_to_100; +create table t3(a int, b int, c int, primary key(a)); +insert into t3 select seq-1,seq-1,seq-1 from seq_1_to_100 limit 30; +set optimizer_use_condition_selectivity=1; +explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 10 NULL 9 100.00 Using index condition; Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`a` = `test`.`t1`.`c`) and (`test`.`t3`.`a` = `test`.`t1`.`d`) and (`test`.`t1`.`a` = 50) and (`test`.`t1`.`b` <= 100)) +select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +b a a b +0 0 1 1 +1 1 2 2 +2 2 3 3 +3 3 4 4 +4 4 5 5 +5 5 6 6 +6 6 7 7 +7 7 8 8 +8 8 9 9 +9 9 10 10 +set optimizer_use_condition_selectivity=2; +explain extended select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 range a a 10 NULL 9 9.00 Using index condition; Using where +1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.d 1 100.00 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.c 1 100.00 Using index +Warnings: +Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`a` = `test`.`t1`.`c`) and (`test`.`t3`.`a` = `test`.`t1`.`d`) and (`test`.`t1`.`a` = 50) and (`test`.`t1`.`b` <= 100)) +select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; +b a a b +0 0 1 1 +1 1 2 2 +2 2 3 3 +3 3 4 4 +4 4 5 5 +5 5 6 6 +6 6 7 7 +7 7 8 8 +8 8 9 9 +9 9 10 10 +set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +drop table t1,t2,t3; +# End of 10.1 tests diff -Nru mariadb-10.1-10.1.41/mysql-test/r/sp-code.result mariadb-10.1-10.1.43/mysql-test/r/sp-code.result --- mariadb-10.1-10.1.41/mysql-test/r/sp-code.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/sp-code.result 2019-11-06 06:20:35.000000000 +0000 @@ -919,6 +919,7 @@ CLOSE c; SELECT a INTO @foo FROM t1 LIMIT 1; # Clear warning stack END| +SET @save_dbug = @@debug_dbug; SET SESSION debug_dbug="+d,bug23032_emit_warning"; CALL p1(); Warning found! @@ -938,7 +939,7 @@ Level Code Message Warning 1105 Unknown error Error 1329 No data - zero rows fetched, selected, or processed -SET SESSION debug_dbug="-d,bug23032_emit_warning"; +SET SESSION debug_dbug=@save_dbug; DROP PROCEDURE p1; DROP TABLE t1; # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/sp.result mariadb-10.1-10.1.43/mysql-test/r/sp.result --- mariadb-10.1-10.1.41/mysql-test/r/sp.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/sp.result 2019-11-06 06:20:35.000000000 +0000 @@ -7644,7 +7644,7 @@ 1 1 DROP PROCEDURE sp; -CREATE PROCEDURE sp() SHOW USER_STATISTICS; +CREATE PROCEDURE sp() SET STATEMENT SQL_SELECT_LIMIT=0 FOR SHOW USER_STATISTICS; CALL sp; User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_read Rows_sent Rows_deleted Rows_inserted Rows_updated Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries Total_ssl_connections Max_statement_time_exceeded SELECT 1; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/subselect_sj_jcl6.result mariadb-10.1-10.1.43/mysql-test/r/subselect_sj_jcl6.result --- mariadb-10.1-10.1.41/mysql-test/r/subselect_sj_jcl6.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/subselect_sj_jcl6.result 2019-11-06 06:20:35.000000000 +0000 @@ -3208,6 +3208,32 @@ create table t2 (a2 varchar(25)) ; insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2); drop table t1,t2; +# +# MDEV-13172: Wrong result / SELECT ... WHERE EXISTS ... (with UNIQUE Key) +# +CREATE TABLE `t1` ( +`Id` int(11) NOT NULL, +PRIMARY KEY (`Id`) +); +INSERT INTO `t1` (`Id`) VALUES (1); +CREATE TABLE `t2` ( +`t1_Id` int(11) NOT NULL DEFAULT 0, +`col1` int(11) DEFAULT NULL, +UNIQUE KEY `col1` (`col1`) +); +INSERT INTO `t2` (`t1_Id`, `col1`) VALUES (1, NULL), (1, NULL); +SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); +Id +1 +explain extended +SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +2 MATERIALIZED t2 ref col1 col1 5 const 1 100.00 Using index condition; Using where +Warnings: +Note 1003 select 1 AS `Id` from (`test`.`t2`) where ((`test`.`t2`.`t1_Id` = 1) and isnull(`test`.`t2`.`col1`)) +DROP TABLE t1, t2; # End of 5.5 test set optimizer_switch=@subselect_sj_tmp; # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/subselect_sj.result mariadb-10.1-10.1.43/mysql-test/r/subselect_sj.result --- mariadb-10.1-10.1.41/mysql-test/r/subselect_sj.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/subselect_sj.result 2019-11-06 06:20:35.000000000 +0000 @@ -3194,5 +3194,31 @@ create table t2 (a2 varchar(25)) ; insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2); drop table t1,t2; +# +# MDEV-13172: Wrong result / SELECT ... WHERE EXISTS ... (with UNIQUE Key) +# +CREATE TABLE `t1` ( +`Id` int(11) NOT NULL, +PRIMARY KEY (`Id`) +); +INSERT INTO `t1` (`Id`) VALUES (1); +CREATE TABLE `t2` ( +`t1_Id` int(11) NOT NULL DEFAULT 0, +`col1` int(11) DEFAULT NULL, +UNIQUE KEY `col1` (`col1`) +); +INSERT INTO `t2` (`t1_Id`, `col1`) VALUES (1, NULL), (1, NULL); +SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); +Id +1 +explain extended +SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 system PRIMARY NULL NULL NULL 1 100.00 +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +2 MATERIALIZED t2 ref col1 col1 5 const 1 100.00 Using index condition; Using where +Warnings: +Note 1003 select 1 AS `Id` from (`test`.`t2`) where ((`test`.`t2`.`t1_Id` = 1) and isnull(`test`.`t2`.`col1`)) +DROP TABLE t1, t2; # End of 5.5 test set optimizer_switch=@subselect_sj_tmp; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/sum_distinct-big.result mariadb-10.1-10.1.43/mysql-test/r/sum_distinct-big.result --- mariadb-10.1-10.1.41/mysql-test/r/sum_distinct-big.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/sum_distinct-big.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,7 +1,5 @@ -DROP TABLE IF EXISTS t1, t2; set @save_tmp_table_size=@@tmp_table_size; set @save_max_heap_table_size=@@max_heap_table_size; -set @save_storage_engine=@@storage_engine; set storage_engine=MYISAM; CREATE TABLE t1 (id INTEGER); CREATE TABLE t2 (id INTEGER); @@ -126,35 +124,13 @@ DROP TABLE t2; SET @@tmp_table_size=@save_tmp_table_size; SET @@max_heap_table_size=@save_max_heap_table_size; -# -# Bug mdev-4311: COUNT(DISTINCT...) requiring a file for Unique -# (bug #68749) -# -set @save_storage_engine=@@storage_engine; -set storage_engine=INNODB; -CREATE TABLE t1 (id INTEGER) ENGINE=InnoDB; +# +# MDEV-4311: COUNT(DISTINCT...) requiring a file for UNIQUE (bug #68749) +# CREATE TABLE t2 (id INTEGER) ENGINE=InnoDB; -INSERT INTO t1 (id) VALUES (1), (1), (1),(1); -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 SELECT id+1 FROM t1; -INSERT INTO t1 SELECT id+2 FROM t1; -INSERT INTO t1 SELECT id+4 FROM t1; -INSERT INTO t1 SELECT id+8 FROM t1; -INSERT INTO t1 SELECT id+16 FROM t1; -INSERT INTO t1 SELECT id+32 FROM t1; -INSERT INTO t1 SELECT id+64 FROM t1; -INSERT INTO t1 SELECT id+128 FROM t1; -INSERT INTO t1 SELECT id+256 FROM t1; -INSERT INTO t1 SELECT id+512 FROM t1; -INSERT INTO t1 SELECT id+1024 FROM t1; -INSERT INTO t1 SELECT id+2048 FROM t1; -INSERT INTO t1 SELECT id+4096 FROM t1; -INSERT INTO t1 SELECT id+8192 FROM t1; -INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); +BEGIN; +INSERT INTO t2 SELECT b.seq FROM seq_1_to_128 a, seq_1_to_16384 b +ORDER BY b.seq*rand(); INSERT INTO t2 VALUE(NULL); # With default tmp_table_size / max_heap_table_size SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2; @@ -176,5 +152,5 @@ SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2; sm 16384 -DROP TABLE t1,t2; -set storage_engine=@save_storage_engine; +COMMIT; +DROP TABLE t2; diff -Nru mariadb-10.1-10.1.41/mysql-test/r/type_date.result mariadb-10.1-10.1.43/mysql-test/r/type_date.result --- mariadb-10.1-10.1.41/mysql-test/r/type_date.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/type_date.result 2019-11-06 06:20:35.000000000 +0000 @@ -863,12 +863,14 @@ FROM v1 GROUP BY greatest(pk, 0, d2); group_concat(d1/(CASE 'b' WHEN 'j' THEN 'c' END)) NULL +NULL Warnings: Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 1 Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2 +Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2 CREATE TABLE t2 AS SELECT greatest(pk, 0, d2) AS c1 FROM t1 LIMIT 0; SHOW CREATE TABLE t2; Table Create Table @@ -879,5 +881,36 @@ DROP VIEW v1; DROP TABLE t1; # +# MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table +# +CREATE TABLE t1 (d DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1999-11-04'); +SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01'; +d +1999-11-04 +DROP TABLE t1; +# +# MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view +# +CREATE TABLE t1 (pk INT NOT NULL, d DATE NOT NULL); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1,'2018-06-22'),(2,'2018-07-11'); +SELECT GREATEST(pk, d) FROM t1; +GREATEST(pk, d) +2018-06-22 +2018-07-11 +Warnings: +Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 +Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2 +SELECT GREATEST(pk, d) FROM v1; +GREATEST(pk, d) +2018-06-22 +2018-07-11 +Warnings: +Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 +Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2 +DROP VIEW v1; +DROP TABLE t1; +# # End of 10.1 tests # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/type_datetime.result mariadb-10.1-10.1.43/mysql-test/r/type_datetime.result --- mariadb-10.1-10.1.41/mysql-test/r/type_datetime.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/type_datetime.result 2019-11-06 06:20:35.000000000 +0000 @@ -1156,5 +1156,47 @@ 3 1976-12-14 13:21:07 DROP TABLE t1; # +# MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH +# +SET SQL_MODE=DEFAULT; +CREATE OR REPLACE TABLE t1 (a CHAR(11)); +CREATE OR REPLACE TABLE t2 (b DATETIME); +INSERT INTO t1 VALUES ('2010-02-19') ; +SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH'; +INSERT INTO t2 SELECT * FROM t1; +DROP TABLE t1, t2; +SET SQL_MODE=DEFAULT; +# +# MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table +# +CREATE TABLE t1 (d DATETIME) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1999-11-04'); +SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01'; +d +1999-11-04 00:00:00 +DROP TABLE t1; +# +# MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view +# +CREATE TABLE t1 (pk INT NOT NULL, d DATETIME NOT NULL); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1,'2018-06-22 00:00:00'),(2,'2018-07-11 00:00:00'); +SELECT GREATEST(pk, d) FROM t1; +GREATEST(pk, d) +2018-06-22 00:00:00 +2018-07-11 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 +Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2 +SELECT GREATEST(pk, d) FROM v1; +GREATEST(pk, d) +2018-06-22 00:00:00 +2018-07-11 00:00:00 +Warnings: +Warning 1292 Incorrect datetime value: '1' for column 'pk' at row 1 +Warning 1292 Incorrect datetime value: '2' for column 'pk' at row 2 +DROP VIEW v1; +DROP TABLE t1; +# # End of 10.1 tests # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/type_int.result mariadb-10.1-10.1.43/mysql-test/r/type_int.result --- mariadb-10.1-10.1.41/mysql-test/r/type_int.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/type_int.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,28 @@ # +# Start of 5.5 tests +# +# +# MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +@a := 1 +1 +SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +COALESCE(1) +1 +SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +COALESCE(@a:=1) +1 +SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +COALESCE(@a) +1 +DROP TABLE t1; +# +# End of 5.5 tests +# +# # Start of 10.1 tests # # diff -Nru mariadb-10.1-10.1.41/mysql-test/r/type_newdecimal.result mariadb-10.1-10.1.43/mysql-test/r/type_newdecimal.result --- mariadb-10.1-10.1.41/mysql-test/r/type_newdecimal.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/r/type_newdecimal.result 2019-11-06 06:20:35.000000000 +0000 @@ -2040,6 +2040,70 @@ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; # +# MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal +# +CREATE TABLE t1 (d DECIMAL(1,0) ZEROFILL); +CREATE TABLE t2 AS SELECT 0 MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f` decimal(1,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; +CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED); +CREATE TABLE t2 AS SELECT 0 MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f` decimal(1,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 (d DECIMAL(1,0) ZEROFILL); +CREATE TABLE t2 AS SELECT CAST(0 AS UNSIGNED) MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f` decimal(1,0) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; +CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED); +CREATE TABLE t2 AS SELECT CAST(0 AS UNSIGNED) MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f` decimal(1,0) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1,t2; +# +# MDEV-20560 Assertion `precision > 0' failed in decimal_bin_size upon SELECT with MOD short unsigned decimal +# +CREATE TABLE t1 (a DECIMAL(1,0) UNSIGNED); +INSERT INTO t1 VALUES (1.0),(2.0); +SELECT DISTINCT 1 MOD a FROM t1; +1 MOD a +0 +1 +CREATE TABLE t2 AS SELECT DISTINCT 1 MOD a AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f` decimal(1,0) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; +CREATE TABLE t1 (a DECIMAL(1,0) UNSIGNED); +INSERT INTO t1 VALUES (1.0),(2.0); +SELECT DISTINCT 1 MOD a FROM t1; +1 MOD a +0 +1 +CREATE TABLE t2 AS SELECT DISTINCT CAST(1 AS UNSIGNED) MOD a AS f FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f` decimal(1,0) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; +# # End of 5.5 tests # # diff -Nru mariadb-10.1-10.1.41/mysql-test/README mariadb-10.1-10.1.43/mysql-test/README --- mariadb-10.1-10.1.41/mysql-test/README 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/README 2019-11-06 06:20:35.000000000 +0000 @@ -60,7 +60,7 @@ load test data, and run some queries to manipulate it. Your test should begin by dropping the tables you are going to create and -end by dropping them again. This ensures that you can run the test over +end by dropping them again. This ensures that you can run the test over and over again. If you are using mysqltest commands in your test case, you should create @@ -81,7 +81,7 @@ # mysqltest --record --database test --result-file=r/test_case_name.result < t/test_case_name.test -When this is done, take a look at r/test_case_name.result . +When this is done, take a look at r/test_case_name.result. If the result is incorrect, you have found a bug. In this case, you should edit the test result to the correct results so that we can verify that the bug is corrected in future releases. diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result mariadb-10.1-10.1.43/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result --- mariadb-10.1-10.1.41/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result 2019-11-06 06:20:35.000000000 +0000 @@ -71,10 +71,10 @@ DROP TABLE IF EXISTS t1; RESET MASTER; # Test case for DROP query. -CREATE TABLE t1 (a INT) ENGINE=INNODB; -CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB; -DROP TABLE t1; -DROP TABLE t1; +CREATE TABLE t2 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB; +DROP TABLE t2; +DROP TABLE t2; # DROP table query fails with unknown table error without patch. # Clean up SET @@session.binlog_format= @save_binlog_format; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result mariadb-10.1-10.1.43/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result --- mariadb-10.1-10.1.41/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result 2019-11-06 06:20:35.000000000 +0000 @@ -99,10 +99,10 @@ DROP TABLE IF EXISTS t1; RESET MASTER; # Test case for DROP query. -CREATE TABLE t1 (a INT) ENGINE=INNODB; -CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB; -DROP TABLE t1; -DROP TABLE t1; +CREATE TABLE t2 (a INT) ENGINE=INNODB; +CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB; +DROP TABLE t2; +DROP TABLE t2; # DROP table query fails with unknown table error without patch. # Clean up SET @@session.binlog_format= @save_binlog_format; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/binlog/r/binlog_unsafe.result mariadb-10.1-10.1.43/mysql-test/suite/binlog/r/binlog_unsafe.result --- mariadb-10.1-10.1.41/mysql-test/suite/binlog/r/binlog_unsafe.result 2019-07-26 16:34:50.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/binlog/r/binlog_unsafe.result 2019-11-06 06:20:35.000000000 +0000 @@ -2706,6 +2706,8 @@ Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. CREATE... REPLACE SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are replaced. This order cannot be predicted and may differ on master and the slave. INSERT INTO insert_2_keys VALUES (1, 2) ON DUPLICATE KEY UPDATE a=VALUES(a)+10, b=VALUES(b)+10; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe DROP TABLE filler_table; DROP TABLE insert_table; DROP TABLE update_table; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result mariadb-10.1-10.1.43/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result --- mariadb-10.1-10.1.41/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.result 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1,57 @@ +include/master-slave.inc +[connection master] +connection server_2; +include/stop_slave.inc +connection server_2; +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL slave_parallel_mode='optimistic'; +SET GLOBAL slave_parallel_threads= 3; +CHANGE MASTER TO master_use_gtid=slave_pos; +CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +include/start_slave.inc +connection server_2; +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; +include/save_master_gtid.inc +connection server_1; +connection server_2; +include/sync_with_master_gtid.inc +connection server_2; +connect con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +BEGIN; +INSERT INTO t1 VALUES (32); +connection server_1; +INSERT INTO t1 VALUES (32); +connection server_2; +SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; +SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; +connection server_1; +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (33); +connection server_2; +SET debug_sync='now WAIT_FOR reached_pause'; +connection server_1; +INSERT INTO t1 VALUES (34); +connection server_2; +connection con_temp2; +COMMIT; +connection server_2; +include/stop_slave.inc +connection server_2; +include/assert.inc [table t1 should have zero rows where a>32] +connection server_2; +SELECT * FROM t1 WHERE a>32; +a +DELETE FROM t1 WHERE a=32; +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +SET GLOBAL slave_parallel_mode=@old_parallel_mode; +SET GLOBAL debug_dbug=@old_debug; +SET DEBUG_SYNC= 'RESET'; +include/start_slave.inc +connection server_2; +connection server_1; +DROP TABLE t1; +include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test mariadb-10.1-10.1.43/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test --- mariadb-10.1-10.1.41/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/binlog_encryption/rpl_parallel_ignored_errors.test 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1 @@ +--source suite/rpl/include/rpl_parallel_ignored_errors.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/galera/disabled.def mariadb-10.1-10.1.43/mysql-test/suite/galera/disabled.def --- mariadb-10.1-10.1.41/mysql-test/suite/galera/disabled.def 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/galera/disabled.def 2019-11-06 06:20:35.000000000 +0000 @@ -33,7 +33,6 @@ galera_migrate : MariaDB does not support START SLAVE USER galera_pc_ignore_sb : MDEV-17357 Test failure on galera.galera_pc_ignore_sb galera_ssl_upgrade : MDEV-13549 Galera test failures -galera_sst_mysqldump_with_key : MDEV-16890 Galera test failure galera_var_node_address : MDEV-17151 Galera test failure galera_var_notify_cmd : MDEV-13549 Galera test failures galera_wan : MDEV-17259: Test failure on galera.galera_wan diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb/r/innodb-alter-autoinc.result mariadb-10.1-10.1.43/mysql-test/suite/innodb/r/innodb-alter-autoinc.result --- mariadb-10.1-10.1.41/mysql-test/suite/innodb/r/innodb-alter-autoinc.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb/r/innodb-alter-autoinc.result 2019-11-06 06:20:35.000000000 +0000 @@ -148,7 +148,7 @@ `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), KEY `id` (`id`,`a`) -) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=latin1 INSERT INTO t1 SET a=123; INSERT INTO t1 VALUES(-123,-45); ALTER TABLE t1 AUTO_INCREMENT = 75; @@ -161,8 +161,8 @@ 123 55 347 60 33101 65 +123 70 123 75 -123 80 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -170,5 +170,5 @@ `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), KEY `id` (`id`,`a`) -) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=latin1 DROP TABLE t1; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb/r/innodb-autoinc.result mariadb-10.1-10.1.43/mysql-test/suite/innodb/r/innodb-autoinc.result --- mariadb-10.1-10.1.41/mysql-test/suite/innodb/r/innodb-autoinc.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb/r/innodb-autoinc.result 2019-11-06 06:20:35.000000000 +0000 @@ -567,7 +567,7 @@ auto_increment_increment 65535 auto_increment_offset 65535 INSERT INTO t1 VALUES (NULL),(NULL); -ERROR HY000: Failed to read auto-increment value from storage engine +ERROR 22003: Out of range value for column 'c1' at row 1 SELECT * FROM t1; c1 1 @@ -674,7 +674,7 @@ a b 1 S1 3 S2 -4 S2 +5 S2 # Client 1: Insert a record with auto_increment_increment=1 SET SESSION auto_increment_increment=1; SHOW CREATE TABLE t; @@ -683,14 +683,14 @@ `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `b` varchar(200) DEFAULT NULL, PRIMARY KEY (`a`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 INSERT INTO t(b) VALUES('S1'); SELECT a,b FROM t; a b 1 S1 3 S2 -4 S2 -5 S1 +5 S2 +6 S1 DROP TABLE t; # Autoincrement behaviour with mixed insert. CREATE TABLE t( @@ -728,22 +728,22 @@ `a` tinyint(4) NOT NULL AUTO_INCREMENT, `b` varchar(200) DEFAULT NULL, PRIMARY KEY (`a`) -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=latin1 INSERT INTO t(b) VALUES('S4'); SELECT * FROM t; a b 1 S0 11 S1 -22 S3 -23 S4 28 S2 +31 S3 +32 S4 SHOW CREATE TABLE t; Table Create Table t CREATE TABLE `t` ( `a` tinyint(4) NOT NULL AUTO_INCREMENT, `b` varchar(200) DEFAULT NULL, PRIMARY KEY (`a`) -) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1 DROP TABLE t; SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=5; DROP TABLE IF EXISTS t1; @@ -784,7 +784,7 @@ `n` int(10) unsigned NOT NULL, `o` enum('FALSE','TRUE') DEFAULT NULL, PRIMARY KEY (`m`) -) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1 INSERT INTO t1 (b,c) SELECT n,o FROM t2 ; SHOW CREATE TABLE t1; Table Create Table @@ -1464,13 +1464,13 @@ i 1 301 -351 +601 SHOW CREATE TABLE t; Table Create Table t CREATE TABLE `t` ( `i` int(11) NOT NULL AUTO_INCREMENT, KEY `i` (`i`) -) ENGINE=InnoDB AUTO_INCREMENT=401 DEFAULT CHARSET=latin1 +) ENGINE=InnoDB AUTO_INCREMENT=651 DEFAULT CHARSET=latin1 DROP TABLE t; # # MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op()) diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb/r/stat_tables.result mariadb-10.1-10.1.43/mysql-test/suite/innodb/r/stat_tables.result --- mariadb-10.1-10.1.41/mysql-test/suite/innodb/r/stat_tables.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb/r/stat_tables.result 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1,15 @@ +rename table mysql.table_stats to mysql.table_stats_save; +flush tables; +set use_stat_tables= PREFERABLY; +create table t1 (a int) engine=InnoDB; +start transaction; +insert t1 values (1); +insert t1 values (2); +commit; +select * from t1; +a +1 +2 +drop table t1; +rename table mysql.table_stats_save to mysql.table_stats; +flush tables; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb/t/innodb-autoinc.test mariadb-10.1-10.1.43/mysql-test/suite/innodb/t/innodb-autoinc.test --- mariadb-10.1-10.1.41/mysql-test/suite/innodb/t/innodb-autoinc.test 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb/t/innodb-autoinc.test 2019-11-06 06:20:35.000000000 +0000 @@ -349,7 +349,7 @@ SELECT * FROM t1; SET @@SESSION.AUTO_INCREMENT_INCREMENT=1152921504606846976, @@SESSION.AUTO_INCREMENT_OFFSET=1152921504606846976; SHOW VARIABLES LIKE "auto_inc%"; ---error 1467 +--error HA_ERR_AUTOINC_ERANGE INSERT INTO t1 VALUES (NULL),(NULL); SELECT * FROM t1; DROP TABLE t1; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb/t/stat_tables.test mariadb-10.1-10.1.43/mysql-test/suite/innodb/t/stat_tables.test --- mariadb-10.1-10.1.41/mysql-test/suite/innodb/t/stat_tables.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb/t/stat_tables.test 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1,17 @@ +source include/have_innodb.inc; + +# +# MDEV-20354 All but last insert ignored in InnoDB tables when table locked +# +rename table mysql.table_stats to mysql.table_stats_save; +flush tables; +set use_stat_tables= PREFERABLY; +create table t1 (a int) engine=InnoDB; +start transaction; +insert t1 values (1); +insert t1 values (2); +commit; +select * from t1; +drop table t1; +rename table mysql.table_stats_save to mysql.table_stats; +flush tables; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb/t/trx_id_future.test mariadb-10.1-10.1.43/mysql-test/suite/innodb/t/trx_id_future.test --- mariadb-10.1-10.1.41/mysql-test/suite/innodb/t/trx_id_future.test 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb/t/trx_id_future.test 2019-11-06 06:20:35.000000000 +0000 @@ -7,6 +7,16 @@ --source include/have_innodb.inc --source include/not_embedded.inc +perl; +open(OUT, ">$ENV{MYSQLTEST_VARDIR}/log/check.txt") || die; +print OUT "--skip innodb_checksum_algorithm=crc32 needs little-endian\n" +unless unpack("L","macs")==unpack("N","scam"); +close(OUT); +EOF + +--source $MYSQLTEST_VARDIR/log/check.txt +--remove_file $MYSQLTEST_VARDIR/log/check.txt + let PAGE_SIZE=`select @@innodb_page_size`; CREATE TABLE t1(a INT) row_format=redundant engine=innoDB; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/r/concurrent_insert.result mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/r/concurrent_insert.result --- mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/r/concurrent_insert.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/r/concurrent_insert.result 2019-11-06 06:20:35.000000000 +0000 @@ -6,3 +6,21 @@ SET DEBUG_SYNC = 'now SIGNAL race'; SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; +# +# MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX +# +CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB; +INSERT INTO t2 VALUES('mariadb'); +SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang'; +SET DEBUG_SYNC= 'fts_instrument_sync_request + SIGNAL drop_index_start WAIT_FOR sync_op'; +INSERT INTO t1 VALUES('Keyword'); +SET DEBUG_SYNC='now WAIT_FOR drop_index_start'; +SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index'; +ALTER TABLE t2 drop index idx1; +set DEBUG_SYNC= 'now SIGNAL fts_drop_index'; +SET global DEBUG_DBUG=RESET; +drop table t1, t2; +set DEBUG_SYNC=RESET; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/r/crash_recovery.result mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/r/crash_recovery.result --- mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/r/crash_recovery.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/r/crash_recovery.result 2019-11-06 06:20:35.000000000 +0000 @@ -67,6 +67,31 @@ BEGIN; INSERT INTO articles VALUES (100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...'); +# +# MDEV-19073 FTS row mismatch after crash recovery +# +CREATE TABLE mdev19073(id SERIAL, title VARCHAR(200), body TEXT, +FULLTEXT(title,body)) ENGINE=InnoDB; +INSERT INTO mdev19073 (title, body) VALUES +('MySQL Tutorial', 'DBMS stands for Database...'); +CREATE FULLTEXT INDEX idx ON mdev19073(title, body); +CREATE TABLE mdev19073_2 LIKE mdev19073; +INSERT INTO mdev19073_2 (title, body) VALUES +('MySQL Tutorial', 'DBMS stands for Database...'); +INSERT INTO mdev19073 (title, body) VALUES +('MariaDB Tutorial', 'DB means Database ...'); +INSERT INTO mdev19073_2 (title, body) VALUES +('MariaDB Tutorial', 'DB means Database ...'); +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... # Kill and restart INSERT INTO articles VALUES (8, 12, 'MySQL Tutorial','DBMS stands for DataBase ...'); SELECT * FROM articles WHERE MATCH (title, body) @@ -76,3 +101,14 @@ 1 10 MySQL Tutorial DBMS stands for DataBase ... 8 12 MySQL Tutorial DBMS stands for DataBase ... DROP TABLE articles; +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +DROP TABLE mdev19073, mdev19073_2; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result --- mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,3 @@ -drop table if exists t1; CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, a VARCHAR(200), @@ -415,7 +414,6 @@ id 105 DROP TABLE t1; -drop table if exists t50; set names utf8; "----------Test1---------" create table t50 (s1 varchar(60) character set utf8 collate utf8_bin) engine = innodb; @@ -670,9 +668,6 @@ ŁŁŁŁ LLLL ŁŁŁŁ ŁŁŁŁ -DROP TABLE if EXISTS t2; -Warnings: -Note 1051 Unknown table 'test.t2' CREATE TABLE t2 (s1 VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_POLISH_CI) ENGINE = InnoDB; CREATE FULLTEXT INDEX i ON t2 ( s1); Warnings: @@ -734,19 +729,26 @@ DROP TABLE t1; "----------Test27---------" CREATE TABLE t1 (id INT,char_column VARCHAR(60)); +CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB; +ALTER TABLE t2 DROP a; SET @@autocommit=0; CREATE FULLTEXT INDEX i ON t1 (char_column); INSERT INTO t1 values (1,'aaa'); -"restart server..." -# Restart the server ---source include/restart_mysqld.inc -DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb') -SET @@autocommit=1; -DROP TABLE t1; +CREATE TABLE mdev20987_1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; +CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100), +FULLTEXT(f2), +FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB; +INSERT INTO mdev20987_1 VALUES(1); +INSERT INTO mdev20987_2 VALUES(1, 'mariadb'); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`FTS_DOC_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); +DROP TABLE t1, t2, mdev20987_2, mdev20987_1; "----------Test28---------" -drop table if exists `fts_test`; -Warnings: -Note 1051 Unknown table 'test.fts_test' create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb; set session autocommit=0; insert into `fts_test` values (''); @@ -936,9 +938,6 @@ 2 How To Use MySQL Well After you went through a ... 3 Optimizing MySQL In this tutorial we will show ... DROP TABLE articles; -drop table if exists t1; -Warnings: -Note 1051 Unknown table 'test.t1' create table t1 (FTS_DOC_ID bigint unsigned auto_increment not null primary key, title varchar(200),body text,fulltext(title,body)) engine=innodb; insert into t1 set body='test'; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/t/concurrent_insert.test mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/t/concurrent_insert.test --- mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/t/concurrent_insert.test 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/t/concurrent_insert.test 2019-11-06 06:20:35.000000000 +0000 @@ -18,3 +18,34 @@ SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; + +--echo # +--echo # MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX +--echo # + +CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB; +INSERT INTO t2 VALUES('mariadb'); + +connection default; +SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang'; +SET DEBUG_SYNC= 'fts_instrument_sync_request + SIGNAL drop_index_start WAIT_FOR sync_op'; +send INSERT INTO t1 VALUES('Keyword'); + +connect(con1,localhost,root,,,); +SET DEBUG_SYNC='now WAIT_FOR drop_index_start'; +SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index'; +send ALTER TABLE t2 drop index idx1; + +connection default; +reap; +set DEBUG_SYNC= 'now SIGNAL fts_drop_index'; + +connection con1; +reap; +SET global DEBUG_DBUG=RESET; +drop table t1, t2; +connection default; +set DEBUG_SYNC=RESET; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/t/crash_recovery.test mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/t/crash_recovery.test --- mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/t/crash_recovery.test 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/t/crash_recovery.test 2019-11-06 06:20:35.000000000 +0000 @@ -6,6 +6,7 @@ --source include/have_innodb.inc # The embedded server tests do not support restarting. --source include/not_embedded.inc +--source include/maybe_debug.inc # Following are test for crash recovery on FTS index, the first scenario # is for bug Bug #14586855 INNODB: FAILING ASSERTION: (DICT_INDEX_GET_N_UNIQUE( @@ -62,13 +63,17 @@ ('MySQL vs. YourSQL','In the following database comparison ...'), ('MySQL Security','When configured properly, MySQL ...'); +connect(dml, localhost, root,,); BEGIN; INSERT INTO articles (title,body) VALUES ('MySQL Tutorial','DBMS stands for DataBase ...'); +connection default; --source include/kill_and_restart_mysqld.inc +disconnect dml; + # This insert will re-initialize the Doc ID counter, it should not crash INSERT INTO articles (title,body) VALUES ('MySQL Tutorial','DBMS stands for DataBase ...'); @@ -101,12 +106,55 @@ (5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'), (7, 4, 'MySQL Security','When configured properly, MySQL ...'); +connect(dml, localhost, root,,); BEGIN; INSERT INTO articles VALUES (100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...'); +connect(dml2, localhost, root,,); + +--echo # +--echo # MDEV-19073 FTS row mismatch after crash recovery +--echo # + +CREATE TABLE mdev19073(id SERIAL, title VARCHAR(200), body TEXT, + FULLTEXT(title,body)) ENGINE=InnoDB; +INSERT INTO mdev19073 (title, body) VALUES + ('MySQL Tutorial', 'DBMS stands for Database...'); +CREATE FULLTEXT INDEX idx ON mdev19073(title, body); +CREATE TABLE mdev19073_2 LIKE mdev19073; +if ($have_debug) +{ +--disable_query_log +SET @saved_dbug = @@debug_dbug; +SET DEBUG_DBUG = '+d,fts_instrument_sync_debug'; +--enable_query_log +} +INSERT INTO mdev19073_2 (title, body) VALUES + ('MySQL Tutorial', 'DBMS stands for Database...'); +if ($have_debug) +{ +--disable_query_log +SET DEBUG_DBUG = @saved_dbug; +--enable_query_log +} + +INSERT INTO mdev19073 (title, body) VALUES + ('MariaDB Tutorial', 'DB means Database ...'); +INSERT INTO mdev19073_2 (title, body) VALUES + ('MariaDB Tutorial', 'DB means Database ...'); + +# Should return 2 rows +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +connection default; --source include/kill_and_restart_mysqld.inc +disconnect dml; +disconnect dml2; # This would re-initialize the FTS index and do the re-tokenization # of above records @@ -116,3 +164,10 @@ AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); DROP TABLE articles; + +# Should return 2 rows +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +DROP TABLE mdev19073, mdev19073_2; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test --- mariadb-10.1-10.1.41/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test 2019-11-06 06:20:35.000000000 +0000 @@ -5,10 +5,6 @@ let collation=UTF8_UNICODE_CI; --source include/have_collation.inc ---disable_warnings -drop table if exists t1; ---enable_warnings - # Create FTS table CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, @@ -401,10 +397,6 @@ #------------------------------------------------------------------------------ # More FTS test from peter's testing #------------------------------------------------------------------------------ ---disable_warnings -drop table if exists t50; ---enable_warnings - set names utf8; @@ -606,7 +598,6 @@ INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('ŁŁŁŁ'),('LLLL'),(NULL),('ŁŁŁŁ ŁŁŁŁ'),('LLLLLLLL'); SELECT * FROM t1 WHERE MATCH(s1) AGAINST ('LLLL' COLLATE UTF8_UNICODE_520_CI); -DROP TABLE if EXISTS t2; CREATE TABLE t2 (s1 VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_POLISH_CI) ENGINE = InnoDB; CREATE FULLTEXT INDEX i ON t2 ( s1); INSERT INTO t2 VALUES @@ -667,18 +658,24 @@ --echo "----------Test27---------" #27 Crash after server restart CREATE TABLE t1 (id INT,char_column VARCHAR(60)); +CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB; +ALTER TABLE t2 DROP a; SET @@autocommit=0; CREATE FULLTEXT INDEX i ON t1 (char_column); INSERT INTO t1 values (1,'aaa'); -echo "restart server..." -# Restart the server + +CREATE TABLE mdev20987_1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; +CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100), + FULLTEXT(f2), + FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB; +INSERT INTO mdev20987_1 VALUES(1); +INSERT INTO mdev20987_2 VALUES(1, 'mariadb'); --source include/restart_mysqld.inc +SHOW CREATE TABLE t2; DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); -SET @@autocommit=1; -DROP TABLE t1; +DROP TABLE t1, t2, mdev20987_2, mdev20987_1; --echo "----------Test28---------" -drop table if exists `fts_test`; create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb; set session autocommit=0; insert into `fts_test` values (''); @@ -867,8 +864,6 @@ # Test for Bug 13940669 - 64901: INNODB: ASSERTION FAILURE IN # THREAD 34387022112 IN FILE REM0CMP.CC LINE 5 -drop table if exists t1; - create table t1 (FTS_DOC_ID bigint unsigned auto_increment not null primary key, title varchar(200),body text,fulltext(title,body)) engine=innodb; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/maria/icp.result mariadb-10.1-10.1.43/mysql-test/suite/maria/icp.result --- mariadb-10.1-10.1.41/mysql-test/suite/maria/icp.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/maria/icp.result 2019-11-06 06:20:35.000000000 +0000 @@ -167,7 +167,7 @@ ORDER BY ts DESC LIMIT 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using where +1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where DROP TABLE t1; # diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_add.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_add.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_add.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_add.inc 2019-11-06 06:20:35.000000000 +0000 @@ -1,33 +1,34 @@ # To be used with partition mgm commands like # ALTER TABLE t1 ADD PARTITION (LIST/RANGE PARTITIONING). --echo # Crash testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_add_partition_1"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_2"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_3"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_4"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_5"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_6"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_7"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_8"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_9"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_10"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_change.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_change.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_change.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_change.inc 2019-11-06 06:20:35.000000000 +0000 @@ -2,39 +2,40 @@ # ALTER TABLE t1 COALESCE/REBUILD/REORGANIZE PARTITION. --echo # Test change partition (REORGANIZE/REBUILD/COALESCE --echo # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_change_partition_1"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_2"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_3"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_4"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_5"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_6"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_7"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_8"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_9"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_10"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_11"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_12"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_drop.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_drop.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_drop.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_drop.inc 2019-11-06 06:20:35.000000000 +0000 @@ -1,30 +1,31 @@ # To be used with partition mgm commands like # ALTER TABLE t1 DROP PARTITION. --echo # Test DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_1"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_2"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_3"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_4"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_5"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_6"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_7"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_8"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_9"; --source suite/parts/inc/partition_crash.inc -SET SESSION debug_dbug="-d,crash_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_exchange.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_exchange.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_crash_exchange.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_crash_exchange.inc 2019-11-06 06:20:35.000000000 +0000 @@ -1,29 +1,30 @@ # To be used with WL#4445: EXCHANGE PARTITION WITH TABLE. +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_1"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_2"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_3"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_4"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_5"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_6"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_7"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_8"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_9"; --source suite/parts/inc/partition_crash_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_abort_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_add.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_add.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_add.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_add.inc 2019-11-06 06:20:35.000000000 +0000 @@ -1,33 +1,34 @@ # To be used with partition mgm commands like # ALTER TABLE t1 ADD PARTITION (LIST/RANGE PARTITIONING). --echo # Error recovery testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_add_partition_1"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_2"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_3"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_4"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_5"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_6"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_7"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_8"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_9"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_10"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_change.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_change.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_change.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_change.inc 2019-11-06 06:20:35.000000000 +0000 @@ -2,39 +2,40 @@ # ALTER TABLE t1 COALESCE/REBUILD/REORGANIZE PARTITION. --echo # Error recovery change partition (REORGANIZE/REBUILD/COALESCE --echo # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_change_partition_1"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_2"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_3"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_4"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_5"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_6"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_7"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_8"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_9"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_10"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_11"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_12"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_drop.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_drop.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_drop.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_drop.inc 2019-11-06 06:20:35.000000000 +0000 @@ -1,30 +1,31 @@ # To be used with partition mgm commands like # ALTER TABLE t1 DROP PARTITION. --echo # Error recovery DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_1"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_2"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_3"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_4"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_5"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_6"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_7"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_8"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_9"; --source suite/parts/inc/partition_fail.inc -SET SESSION debug_dbug="-d,fail_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_exchange.inc mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_exchange.inc --- mariadb-10.1-10.1.41/mysql-test/suite/parts/inc/partition_fail_exchange.inc 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/inc/partition_fail_exchange.inc 2019-11-06 06:20:35.000000000 +0000 @@ -1,27 +1,28 @@ +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_1"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_2"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_3"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_4"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_5"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_6"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_7"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_8"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_9"; --source suite/parts/inc/partition_fail_t2.inc -SET SESSION debug_dbug="-d,exchange_partition_fail_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/r/alter_data_directory_innodb.result mariadb-10.1-10.1.43/mysql-test/suite/parts/r/alter_data_directory_innodb.result --- mariadb-10.1-10.1.41/mysql-test/suite/parts/r/alter_data_directory_innodb.result 2019-07-26 16:34:51.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/r/alter_data_directory_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -53,6 +53,9 @@ PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB ); +Warnings: +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition SHOW CREATE TABLE t; Table Create Table t CREATE TABLE `t` ( diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/r/partition_debug_innodb.result mariadb-10.1-10.1.43/mysql-test/suite/parts/r/partition_debug_innodb.result --- mariadb-10.1-10.1.41/mysql-test/suite/parts/r/partition_debug_innodb.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/r/partition_debug_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,3 @@ -DROP TABLE IF EXISTS t1; call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was"); call mtr.add_suppression("InnoDB: Error: table .* does not exist in the InnoDB internal"); call mtr.add_suppression("InnoDB: Warning: MySQL is trying to drop table "); @@ -12,6 +11,7 @@ call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); flush tables; # Crash testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -76,7 +76,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -143,7 +143,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -210,7 +210,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -277,7 +277,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -345,7 +345,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -413,7 +413,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -481,7 +481,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -551,7 +551,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -619,7 +619,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -687,8 +687,9 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; # Error recovery testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -809,7 +810,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -930,7 +931,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1051,7 +1052,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1172,7 +1173,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1293,7 +1294,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1414,7 +1415,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1535,7 +1536,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1660,7 +1661,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1785,7 +1786,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1910,8 +1911,9 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; # Test DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -1975,7 +1977,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2041,7 +2043,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2107,7 +2109,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2167,7 +2169,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2227,7 +2229,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2287,7 +2289,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2345,7 +2347,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2402,7 +2404,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2459,8 +2461,9 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; # Error recovery DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2579,7 +2582,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2698,7 +2701,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2817,7 +2820,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -2924,7 +2927,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3031,7 +3034,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3138,7 +3141,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3245,7 +3248,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3352,7 +3355,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3459,9 +3462,10 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; # Test change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3527,7 +3531,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3595,7 +3599,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3663,7 +3667,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3733,7 +3737,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3803,7 +3807,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3873,7 +3877,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -3945,7 +3949,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4017,7 +4021,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4087,7 +4091,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4157,7 +4161,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4226,7 +4230,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4295,9 +4299,10 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; # Error recovery change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4420,7 +4425,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4543,7 +4548,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4666,7 +4671,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4789,7 +4794,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -4912,7 +4917,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5035,7 +5040,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5162,7 +5167,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5289,7 +5294,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5416,7 +5421,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5543,7 +5548,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5670,7 +5675,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'InnoDB' @@ -5797,13 +5802,14 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; # # WL#4445: EXCHANGE PARTITION WITH TABLE # Verify ddl_log and InnoDB in case of crashing. call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was "); call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); call mtr.add_suppression("table .* does not exist in the InnoDB internal"); +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5908,7 +5914,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6013,7 +6019,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6118,7 +6124,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6223,7 +6229,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6328,7 +6334,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6433,7 +6439,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6538,7 +6544,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6643,7 +6649,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6748,7 +6754,8 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_9"; +SET SESSION debug_dbug=@save_dbug; +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6846,7 +6853,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6944,7 +6951,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7042,7 +7049,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7140,7 +7147,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7238,7 +7245,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7336,7 +7343,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7434,7 +7441,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7532,7 +7539,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = InnoDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7630,4 +7637,4 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/r/partition_debug_myisam.result mariadb-10.1-10.1.43/mysql-test/suite/parts/r/partition_debug_myisam.result --- mariadb-10.1-10.1.41/mysql-test/suite/parts/r/partition_debug_myisam.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/r/partition_debug_myisam.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,3 @@ -DROP TABLE IF EXISTS t1; # Test crash and failure recovery in fast_alter_partition_table. # # Bug#53676: Unexpected errors and possible table corruption on @@ -9,6 +8,7 @@ call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); flush tables; # Crash testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -79,7 +79,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -152,7 +152,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -225,7 +225,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -298,7 +298,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -373,7 +373,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -448,7 +448,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -523,7 +523,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -601,7 +601,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -677,7 +677,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -753,8 +753,9 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; # Error recovery testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -883,7 +884,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1012,7 +1013,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1141,7 +1142,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1270,7 +1271,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1399,7 +1400,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1528,7 +1529,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1657,7 +1658,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1792,7 +1793,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -1927,7 +1928,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2062,8 +2063,9 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; # Test DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2133,7 +2135,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2205,7 +2207,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2277,7 +2279,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2342,7 +2344,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2407,7 +2409,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2472,7 +2474,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2535,7 +2537,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2596,7 +2598,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2657,8 +2659,9 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; # Error recovery DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2785,7 +2788,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -2912,7 +2915,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3039,7 +3042,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3152,7 +3155,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3265,7 +3268,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3378,7 +3381,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3491,7 +3494,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3604,7 +3607,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3717,9 +3720,10 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; # Test change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3791,7 +3795,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3865,7 +3869,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -3939,7 +3943,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4017,7 +4021,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4095,7 +4099,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4173,7 +4177,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4254,7 +4258,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4335,7 +4339,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4414,7 +4418,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4493,7 +4497,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4570,7 +4574,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4647,9 +4651,10 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; # Error recovery change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4780,7 +4785,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -4911,7 +4916,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5042,7 +5047,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5173,7 +5178,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5304,7 +5309,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5435,7 +5440,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5572,7 +5577,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5709,7 +5714,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5846,7 +5851,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -5983,7 +5988,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -6120,7 +6125,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'MyISAM' @@ -6257,4 +6262,4 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/r/partition_debug.result mariadb-10.1-10.1.43/mysql-test/suite/parts/r/partition_debug.result --- mariadb-10.1-10.1.41/mysql-test/suite/parts/r/partition_debug.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/r/partition_debug.result 2019-11-06 06:20:35.000000000 +0000 @@ -1,4 +1,3 @@ -DROP TABLE IF EXISTS t1; # # Bug#13737949: CRASH IN HA_PARTITION::INDEX_INIT # Bug#18694052: SERVER CRASH IN HA_PARTITION::INIT_RECORD_PRIORITY_QUEUE @@ -7,10 +6,11 @@ PARTITION BY HASH (a) PARTITIONS 3; INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "Four"), (5, "Five"), (6, "Six"), (7, "Seven"), (8, "Eight"), (9, "Nine"); +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,ha_partition_fail_index_init"; SELECT * FROM t1 WHERE b = "Seven"; ERROR HY000: Table has no partition for value 0 -SET SESSION debug_dbug="-d,ha_partition_fail_index_init"; +SET SESSION debug_dbug=@save_dbug; SELECT * FROM t1 WHERE b = "Seven"; a b 7 Seven @@ -20,6 +20,7 @@ # Verify ddl_log in case of crashing. call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); call mtr.add_suppression('InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata files do not match the log sequence number [0-9]+ in the ib_logfiles!'); +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -131,7 +132,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -243,7 +244,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -355,7 +356,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -467,7 +468,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -579,7 +580,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -691,7 +692,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -803,7 +804,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -915,7 +916,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1027,7 +1028,8 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_9"; +SET SESSION debug_dbug=@save_dbug; +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1129,7 +1131,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1231,7 +1233,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1333,7 +1335,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1435,7 +1437,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1537,7 +1539,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1639,7 +1641,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1741,7 +1743,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1843,7 +1845,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)); INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -1945,4 +1947,4 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/r/reorganize_partition_innodb.result mariadb-10.1-10.1.43/mysql-test/suite/parts/r/reorganize_partition_innodb.result --- mariadb-10.1-10.1.41/mysql-test/suite/parts/r/reorganize_partition_innodb.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/r/reorganize_partition_innodb.result 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1,153 @@ +# +# MDEV-15953 Alter InnoDB Partitioned Table Moves Files (which were originally not in the datadir) to the datadir +# +CREATE TABLE t ( +a INT NOT NULL +) ENGINE=INNODB +PARTITION BY HASH (a) ( +PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' ENGINE = INNODB, +PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' ENGINE = INNODB +); +INSERT INTO t VALUES (1); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +ALTER TABLE t DROP PRIMARY KEY, ALGORITHM=COPY; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE; +SET GLOBAL INNODB_FILE_PER_TABLE=OFF; +ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +SET GLOBAL INNODB_FILE_PER_TABLE=@TMP; +ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( +PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, +PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB +); +Warnings: +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( +PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/', +PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' +); +Warnings: +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( +PARTITION p1 INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, +PARTITION p2 INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB +); +Warnings: +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +(PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB, + PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */ +DROP TABLE t; +CREATE TABLE t ( +a INT NOT NULL +) ENGINE=INNODB +PARTITION BY RANGE (a) +SUBPARTITION BY HASH (a) +SUBPARTITIONS 2 +( +PARTITION p1 VALUES LESS THAN (7) +DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' + INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' + ENGINE = INNODB, +PARTITION p2 VALUES LESS THAN MAXVALUE +DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' + INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' + ENGINE = INNODB +); +Warnings: +Warning 1618 option ignored +Warning 1618 option ignored +Warning 1618 option ignored +Warning 1618 option ignored +ALTER TABLE t +REORGANIZE PARTITION p1,p2 INTO +( +PARTITION p1 VALUES LESS THAN (7) +DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + ENGINE = INNODB, +PARTITION p2 VALUES LESS THAN MAXVALUE +DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + ENGINE = INNODB +); +Warnings: +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +Warning 1982 option ignored for InnoDB partition +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +SUBPARTITION BY HASH (a) +SUBPARTITIONS 2 +(PARTITION p1 VALUES LESS THAN (7) DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = InnoDB, + PARTITION p2 VALUES LESS THAN MAXVALUE DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' INDEX DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = InnoDB) */ +DROP TABLE t; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/t/partition_debug_innodb.test mariadb-10.1-10.1.43/mysql-test/suite/parts/t/partition_debug_innodb.test --- mariadb-10.1-10.1.41/mysql-test/suite/parts/t/partition_debug_innodb.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/t/partition_debug_innodb.test 2019-11-06 06:20:35.000000000 +0000 @@ -9,10 +9,6 @@ # Crash tests don't work with embedded --source include/not_embedded.inc ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - --let $DATADIR= `SELECT @@datadir;` # Waiting for wl#6723 @@ -34,6 +30,7 @@ ALTER TABLE t1 ADD INDEX new_b_index (b); ALTER TABLE t1 DROP INDEX new_b_index; +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug = "+d,ha_partition_fail_final_add_index"; --error ER_NO_PARTITION_FOR_GIVEN_VALUE @@ -49,7 +46,7 @@ --sorted_result SELECT * FROM t1; -SET SESSION debug_dbug = "-d,ha_partition_fail_final_add_index"; +SET SESSION debug_dbug = @save_dbug; SHOW CREATE TABLE t1; DROP TABLE t1; } diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/t/partition_debug_myisam.test mariadb-10.1-10.1.43/mysql-test/suite/parts/t/partition_debug_myisam.test --- mariadb-10.1-10.1.41/mysql-test/suite/parts/t/partition_debug_myisam.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/t/partition_debug_myisam.test 2019-11-06 06:20:35.000000000 +0000 @@ -6,10 +6,6 @@ --source include/not_valgrind.inc --source include/not_embedded.inc ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - --let $DATADIR= `SELECT @@datadir;` let $engine= 'MyISAM'; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/t/partition_debug.test mariadb-10.1-10.1.43/mysql-test/suite/parts/t/partition_debug.test --- mariadb-10.1-10.1.41/mysql-test/suite/parts/t/partition_debug.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/t/partition_debug.test 2019-11-06 06:20:35.000000000 +0000 @@ -8,10 +8,6 @@ # Crash tests don't work with embedded --source include/not_embedded.inc ---disable_warnings -DROP TABLE IF EXISTS t1; ---enable_warnings - # Partitioning test that require debug features --echo # @@ -22,10 +18,11 @@ PARTITION BY HASH (a) PARTITIONS 3; INSERT INTO t1 VALUES (1, "1"), (2, "2"), (3, "3"), (4, "Four"), (5, "Five"), (6, "Six"), (7, "Seven"), (8, "Eight"), (9, "Nine"); +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,ha_partition_fail_index_init"; --error ER_NO_PARTITION_FOR_GIVEN_VALUE SELECT * FROM t1 WHERE b = "Seven"; -SET SESSION debug_dbug="-d,ha_partition_fail_index_init"; +SET SESSION debug_dbug=@save_dbug; SELECT * FROM t1 WHERE b = "Seven"; DROP TABLE t1; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/parts/t/reorganize_partition_innodb.test mariadb-10.1-10.1.43/mysql-test/suite/parts/t/reorganize_partition_innodb.test --- mariadb-10.1-10.1.41/mysql-test/suite/parts/t/reorganize_partition_innodb.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/parts/t/reorganize_partition_innodb.test 2019-11-06 06:20:35.000000000 +0000 @@ -0,0 +1,100 @@ +--source include/have_innodb.inc +--source include/have_partition.inc + +--echo # +--echo # MDEV-15953 Alter InnoDB Partitioned Table Moves Files (which were originally not in the datadir) to the datadir +--echo # + +mkdir $MYSQLTEST_VARDIR/tmp/partitions_here; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t ( + a INT NOT NULL + ) ENGINE=INNODB +PARTITION BY HASH (a) ( + PARTITION p1 DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_here/' ENGINE = INNODB, + PARTITION p2 DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_here/' ENGINE = INNODB +); +INSERT INTO t VALUES (1); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; +ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; +ALTER TABLE t DROP PRIMARY KEY, ALGORITHM=COPY; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; +SET @TMP = @@GLOBAL.INNODB_FILE_PER_TABLE; +SET GLOBAL INNODB_FILE_PER_TABLE=OFF; +ALTER TABLE t ADD PRIMARY KEY pk(a), ALGORITHM=INPLACE; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; +SET GLOBAL INNODB_FILE_PER_TABLE=@TMP; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( + PARTITION p1 DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, + PARTITION p2 DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB +); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( + PARTITION p1 DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/', + PARTITION p2 DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' +); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( + PARTITION p1 INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB, + PARTITION p2 INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB +); +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; + +DROP TABLE t; + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval CREATE TABLE t ( + a INT NOT NULL + ) ENGINE=INNODB +PARTITION BY RANGE (a) + SUBPARTITION BY HASH (a) + SUBPARTITIONS 2 + ( + PARTITION p1 VALUES LESS THAN (7) + DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_here/' + INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_here/' + ENGINE = INNODB, + PARTITION p2 VALUES LESS THAN MAXVALUE + DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_here/' + INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_here/' + ENGINE = INNODB + ); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +eval ALTER TABLE t +REORGANIZE PARTITION p1,p2 INTO +( + PARTITION p1 VALUES LESS THAN (7) + DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + ENGINE = INNODB, + PARTITION p2 VALUES LESS THAN MAXVALUE + DATA DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + INDEX DIRECTORY = '$MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' + ENGINE = INNODB +); + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +SHOW CREATE TABLE t; + +DROP TABLE t; + +rmdir $MYSQLTEST_VARDIR/tmp/partitions_here/test; +rmdir $MYSQLTEST_VARDIR/tmp/partitions_here; + diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/perfschema/r/misc.result mariadb-10.1-10.1.43/mysql-test/suite/perfschema/r/misc.result --- mariadb-10.1-10.1.41/mysql-test/suite/perfschema/r/misc.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/perfschema/r/misc.result 2019-11-06 06:20:36.000000000 +0000 @@ -134,3 +134,19 @@ select * from t1 3 insert into t1 select RAND()*10000 from t1 6 drop table t1; +# +# MDEV-17896 Assertion `pfs->get_refcount() > 0' failed +# in release_table_share +# +SELECT COUNT(*)<@@performance_schema_max_table_instances FROM +performance_schema.objects_summary_global_by_type WHERE OBJECT_TYPE='TABLE'; +COUNT(*)<@@performance_schema_max_table_instances +1 +CREATE TABLE t0(a INT); +SELECT * FROM t0; +a +DROP TEMPORARY TABLE IF EXISTS t0; +Warnings: +Note 1051 Unknown table 'test.t0' +FLUSH TABLE t0; +DROP TABLE t0; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/perfschema/t/misc.test mariadb-10.1-10.1.43/mysql-test/suite/perfschema/t/misc.test --- mariadb-10.1-10.1.41/mysql-test/suite/perfschema/t/misc.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/perfschema/t/misc.test 2019-11-06 06:20:36.000000000 +0000 @@ -222,3 +222,51 @@ select sql_text, rows_examined from performance_schema.events_statements_history; drop table t1; +--echo # +--echo # MDEV-17896 Assertion `pfs->get_refcount() > 0' failed +--echo # in release_table_share +--echo # + +# There must be at least one available slot in PFS table_share_array for +# this test to be meaningful. If there are no free slots we must +# restart mysqld, it is the only way to reset PFS table_share_array +let $query= SELECT COUNT(*)<@@performance_schema_max_table_instances FROM + performance_schema.objects_summary_global_by_type WHERE OBJECT_TYPE='TABLE'; + +let $free_slots_available= `$query`; + +if (!$free_slots_available) +{ + source include/restart_mysqld.inc; +} +eval $query; + +CREATE TABLE t0(a INT); + +# TABLE_SHARE must be cached in the table definition cache. +SELECT * FROM t0; + +# Dropping t0 using DROP TEMPORARY frees up a slot in table_share_array, +# but the persistent table is not correctly dropped, i.e. TABLE_SHARE::m_psi +# still points to that slot in table_share_array. +DROP TEMPORARY TABLE IF EXISTS t0; + +# Try re-using each and every slot in PFS table_share_array. If bug is +# there, we re-use t0 slot. +# The newly created table that re-uses the t0 slot ends up +# resetting the PFS_table_share refcount. +let $i= `SELECT @@performance_schema_max_table_instances`; +disable_query_log; +while ($i) +{ + # Memory engine is here to reduce disk IO + eval CREATE TABLE t$i(a INT) ENGINE=MEMORY; + eval DROP TABLE t$i; + dec $i; +} +enable_query_log; + +# FLUSH TABLE crashes the server when PFS_table_share is found with +# an unexpected refcount. +FLUSH TABLE t0; +DROP TABLE t0; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc mariadb-10.1-10.1.43/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/include/rpl_parallel_ignored_errors.inc 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,112 @@ +# ==== Purpose ==== +# +# Test verifies that, in parallel replication, transaction failure notification +# is propagated to all the workers. Workers should abort the execution of +# transaction event groups, whose event positions are higher than the failing +# transaction group. +# +# ==== Implementation ==== +# +# Steps: +# 0 - Create a table t1 on master which has a primary key. Enable parallel +# replication on slave with slave_parallel_mode='optimistic' and +# slave_parallel_threads=3. +# 1 - On slave start a transaction and execute a local INSERT statement +# which will insert value 32. This is done to block the INSERT coming +# from master. +# 2 - On master execute an INSERT statement with value 32, so that it is +# blocked on slave. +# 3 - On slave enable a debug sync point such that it holds the worker thread +# execution as soon as work is scheduled to it. +# 4 - INSERT value 33 on master. It will be held on slave by other worker +# thread due to debug simulation. +# 5 - INSERT value 34 on master. +# 6 - On slave, enusre that INSERT 34 has reached a state where it waits for +# its prior transactions to commit. +# 7 - Commit the local INSERT 32 on slave server so that first worker will +# error out. +# 8 - Now send a continue signal to second worker processing 33. It should +# wakeup and propagate the error to INSERT 34. +# 9 - Upon slave stop due to error, check that no rows are found after the +# failed INSERT 32. +# +# ==== References ==== +# +# MDEV-20645: Replication consistency is broken as workers miss the error +# notification from an earlier failed group. +# + +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/have_binlog_format_statement.inc +--source include/master-slave.inc + +--enable_connect_log +--connection server_2 +--source include/stop_slave.inc +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL slave_parallel_mode='optimistic'; +SET GLOBAL slave_parallel_threads= 3; +CHANGE MASTER TO master_use_gtid=slave_pos; +CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +--source include/start_slave.inc + +--connection server_1 +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc + +--connect (con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,) +BEGIN; +INSERT INTO t1 VALUES (32); + +--connection server_1 +INSERT INTO t1 VALUES (32); + +--connection server_2 +--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE info like "INSERT INTO t1 VALUES (32)" +--source include/wait_condition.inc +SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; +SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; + +--connection server_1 +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (33); + +--connection server_2 +SET debug_sync='now WAIT_FOR reached_pause'; + +--connection server_1 +INSERT INTO t1 VALUES (34); + +--connection server_2 +--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state like "Waiting for prior transaction to commit" +--source include/wait_condition.inc +--connection con_temp2 +COMMIT; + +# Clean up. +--connection server_2 +--source include/stop_slave.inc +--let $assert_cond= COUNT(*) = 0 FROM t1 WHERE a>32 +--let $assert_text= table t1 should have zero rows where a>32 +--source include/assert.inc +SELECT * FROM t1 WHERE a>32; +DELETE FROM t1 WHERE a=32; + +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +SET GLOBAL slave_parallel_mode=@old_parallel_mode; +SET GLOBAL debug_dbug=@old_debug; +SET DEBUG_SYNC= 'RESET'; +--source include/start_slave.inc + +--connection server_1 +DROP TABLE t1; +--disable_connect_log +--source include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/mdev_17588.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/mdev_17588.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/mdev_17588.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/mdev_17588.result 2019-11-06 06:20:36.000000000 +0000 @@ -1,16 +1,12 @@ include/master-slave.inc [connection master] +include/stop_slave.inc +CHANGE MASTER TO master_use_gtid=slave_pos; +include/start_slave.inc create table t1 (a int) engine=innodb; create table t2 (a int); create table t3 (a int) engine=innodb; -include/save_master_gtid.inc -include/wait_for_slave_sql_error.inc [errno=1286] -Last_Error = 'Error 'Unknown storage engine 'innodb'' on query. Default database: 'test'. Query: 'create table t1 (a int) engine=innodb'' -STOP SLAVE IO_THREAD; -include/wait_for_slave_to_stop.inc -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; -include/start_slave.inc -include/sync_with_master_gtid.inc +include/wait_for_slave_sql_error_and_skip.inc [errno=1286] show tables; Tables_in_test t2 diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_create_or_replace_fail.result 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,18 @@ +include/master-slave.inc +[connection master] +CREATE TEMPORARY TABLE t1 (a INT NOT NULL); +LOAD DATA INFILE 'x' INTO TABLE x; +ERROR 42S02: Table 'test.x' doesn't exist +CREATE OR REPLACE TEMPORARY TABLE t1 (x INT) PARTITION BY HASH(x); +ERROR HY000: Cannot create temporary table with partitions +"************** DROP TEMPORARY TABLE Should be present in Binary log **************" +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE t1 (a INT NOT NULL) +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TEMPORARY TABLE t1 (x INT) PARTITION BY HASH(x) +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (NULL); +DROP TABLE t1; +include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_known_bugs_detection.result 2019-11-06 06:20:36.000000000 +0000 @@ -1,26 +1,6 @@ call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); include/master-slave.inc [connection master] -call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); -CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, -UNIQUE(b)); -INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; -SELECT * FROM t1; -a b -1 10 -2 2 -call mtr.add_suppression("Slave SQL.*suffer.*http:..bugs.mysql.com.bug.php.id=24432"); -include/wait_for_slave_sql_error.inc [errno=1105] -Last_SQL_Error = 'Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10'' -SELECT * FROM t1; -a b -stop slave; -include/wait_for_slave_to_stop.inc -reset slave; -reset master; -drop table t1; -start slave; -include/wait_for_slave_to_start.inc CREATE TABLE t1 ( id bigint(20) unsigned NOT NULL auto_increment, field_1 int(10) unsigned NOT NULL, diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_mdev_17614.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_mdev_17614.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_mdev_17614.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_mdev_17614.result 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,98 @@ +include/master-slave.inc +[connection master] +call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY , b INT, +UNIQUE(b), c int) engine=innodb; +INSERT INTO t1 VALUES (1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe +INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe +COMMIT; +SELECT * FROM t1; +a b c +1 1 2 +2 2 3 +include/wait_for_slave_sql_error.inc [errno=1062] +Last_SQL_Error = 'Error 'Duplicate entry '1' for key 'b'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c)'' +#Different value from server +SELECT * FROM t1; +a b c +1 1 1 +2 2 3 +stop slave; +include/wait_for_slave_to_stop.inc +reset slave; +reset master; +drop table t1; +start slave; +include/wait_for_slave_to_start.inc +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, +UNIQUE(b), c int) engine=innodb; +INSERT INTO t1 VALUES (default, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (default, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +INSERT INTO t1 VALUES(default, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +COMMIT; +SELECT * FROM t1; +a b c +1 1 2 +3 2 3 +#same data as master +SELECT * FROM t1; +a b c +1 1 2 +3 2 3 +drop table t1; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, +UNIQUE(b), c int, d int ) engine=innodb; +INSERT INTO t1 VALUES (1, 1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, NULL, 2, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe +INSERT INTO t1 VALUES(3, NULL, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe +COMMIT; +SELECT * FROM t1; +a b c d +1 1 1 1 +2 NULL 2 2 +3 NULL 2 3 +#same data as master +SELECT * FROM t1; +a b c d +1 1 1 1 +2 NULL 2 2 +3 NULL 2 3 +drop table t1; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, +UNIQUE(b), c int) engine=innodb; +INSERT INTO t1 VALUES (1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +COMMIT; +SELECT * FROM t1; +a b c +1 1 2 +2 2 3 +include/wait_for_slave_sql_error.inc [errno=1062] +Last_SQL_Error = 'Error 'Duplicate entry '1' for key 'b'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c)'' +#Different value from server +SELECT * FROM t1; +a b c +1 1 1 +2 2 3 +stop slave; +include/wait_for_slave_to_stop.inc +reset slave; +reset master; +drop table t1; +start slave; +include/wait_for_slave_to_start.inc +include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,57 @@ +include/master-slave.inc +[connection master] +connection server_2; +include/stop_slave.inc +connection server_2; +SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; +SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; +SET @old_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL slave_parallel_mode='optimistic'; +SET GLOBAL slave_parallel_threads= 3; +CHANGE MASTER TO master_use_gtid=slave_pos; +CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); +include/start_slave.inc +connection server_2; +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=InnoDB; +include/save_master_gtid.inc +connection server_1; +connection server_2; +include/sync_with_master_gtid.inc +connection server_2; +connect con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +BEGIN; +INSERT INTO t1 VALUES (32); +connection server_1; +INSERT INTO t1 VALUES (32); +connection server_2; +SET GLOBAL debug_dbug="+d,hold_worker_on_schedule"; +SET debug_sync="debug_sync_action SIGNAL reached_pause WAIT_FOR continue_worker"; +connection server_1; +SET gtid_seq_no=100; +INSERT INTO t1 VALUES (33); +connection server_2; +SET debug_sync='now WAIT_FOR reached_pause'; +connection server_1; +INSERT INTO t1 VALUES (34); +connection server_2; +connection con_temp2; +COMMIT; +connection server_2; +include/stop_slave.inc +connection server_2; +include/assert.inc [table t1 should have zero rows where a>32] +connection server_2; +SELECT * FROM t1 WHERE a>32; +a +DELETE FROM t1 WHERE a=32; +SET GLOBAL slave_parallel_threads=@old_parallel_threads; +SET GLOBAL slave_parallel_mode=@old_parallel_mode; +SET GLOBAL debug_dbug=@old_debug; +SET DEBUG_SYNC= 'RESET'; +include/start_slave.inc +connection server_2; +connection server_1; +DROP TABLE t1; +include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_sync_with_innodb_thd_conc.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_sync_with_innodb_thd_conc.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_sync_with_innodb_thd_conc.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_sync_with_innodb_thd_conc.result 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,13 @@ +include/master-slave.inc +[connection master] +SET @old_innodb_thread_concurrency := @@innodb_thread_concurrency; +SET @old_innodb_thread_sleep_delay := @@innodb_thread_sleep_delay; +SET GLOBAL innodb_thread_concurrency = 100; +CREATE TABLE t(f INT) ENGINE=INNODB; +INSERT INTO t VALUES (10); +include/diff_tables.inc [master:t, slave:t] +"===== Clean up=======" +DROP TABLE t; +SET GLOBAL innodb_thread_concurrency = @old_innodb_thread_concurrency; +SET GLOBAL innodb_thread_sleep_delay = @old_innodb_thread_sleep_delay; +include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_unsafe_statements.result mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_unsafe_statements.result --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/r/rpl_unsafe_statements.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/r/rpl_unsafe_statements.result 2019-11-06 06:20:36.000000000 +0000 @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); CREATE TABLE t1(id INT AUTO_INCREMENT, i INT, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TABLE t2(id INT AUTO_INCREMENT, i INT, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TRIGGER trig1 AFTER INSERT ON t1 @@ -43,9 +44,13 @@ DROP TABLE t1; CREATE TABLE t1(i INT, j INT, UNIQUE KEY(i), UNIQUE KEY(j)) ENGINE=INNODB; INSERT INTO t1 (i,j) VALUES (1,2) ON DUPLICATE KEY UPDATE j=j+1; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe START TRANSACTION; LOCK TABLES t1 WRITE; INSERT INTO t1 (i,j) VALUES (1,2) ON DUPLICATE KEY UPDATE j=j+1; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe UNLOCK TABLES; COMMIT; include/diff_tables.inc [master:t1, slave:t1] diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/mdev_17588.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/mdev_17588.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/mdev_17588.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/mdev_17588.test 2019-11-06 06:20:36.000000000 +0000 @@ -1,23 +1,28 @@ --source include/master-slave.inc --source include/have_innodb.inc +--connection slave +--source include/stop_slave.inc +CHANGE MASTER TO master_use_gtid=slave_pos; +--source include/start_slave.inc + --connection master create table t1 (a int) engine=innodb; create table t2 (a int); create table t3 (a int) engine=innodb; ---source include/save_master_gtid.inc +--save_master_pos --connection slave # Using ER_UNKNOWN_STORAGE_ENGINE wont work let $slave_sql_errno= 1286; ---source include/wait_for_slave_sql_error.inc ---let $status_items= Last_Error ---source include/show_slave_status.inc -STOP SLAVE IO_THREAD; -source include/wait_for_slave_to_stop.inc; -SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; ---source include/start_slave.inc ---source include/sync_with_master_gtid.inc +--source include/wait_for_slave_sql_error_and_skip.inc +--sync_with_master + +--let $show_statement= SHOW PROCESSLIST +--let $field= State +--let $condition= 'Slave has read all relay log; waiting for the slave I/O thread to update it'; +--source include/wait_show_condition.inc + show tables; show create table t2; --error ER_NO_SUCH_TABLE diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_create_or_replace_fail.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_create_or_replace_fail.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_create_or_replace_fail.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_create_or_replace_fail.test 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,56 @@ +# ==== Purpose ==== +# +# Test verifies that failed CREATE OR REPLACE TEMPORARY TABLE statement which +# dropped the table but failed at a later stage of creation of temporary table +# is written to binarylog in row based replication. +# +# ==== Implementation ==== +# +# Steps: +# 0 - Have mixed based replication mode. +# 1 - Create a temporary table. It will be replicated as mixed replication +# mode is in use. +# 2 - Execute an unsafe statement which will switch current statement +# binlog format to 'ROW'. i.e If binlog_format=MIXED, there are open +# temporary tables, and an unsafe statement is executed, then subsequent +# statements are logged in row format. +# 3 - Execute a CREATE OR REPLACE TEMPORARY TABLE statement which tries to +# create partitions on temporary table. Since it is not supported it will +# fail. +# 4 - Check the binary log output to ensure that the failed statement is +# written to the binary log. +# 5 - Slave should be up and running and in sync with master. +# +# ==== References ==== +# +# MDEV-18930: Failed CREATE OR REPLACE TEMPORARY not written into binary log +# makes data on master and slave diverge +# + +--source include/have_partition.inc +--source include/have_binlog_format_mixed.inc +--source include/master-slave.inc + +CREATE TEMPORARY TABLE t1 (a INT NOT NULL); + +# Execute an unsafe statement which switches replication mode internally from +# "STATEMENT" to "ROW". +--error ER_NO_SUCH_TABLE +LOAD DATA INFILE 'x' INTO TABLE x; + +--error ER_PARTITION_NO_TEMPORARY +CREATE OR REPLACE TEMPORARY TABLE t1 (x INT) PARTITION BY HASH(x); + +--echo "************** DROP TEMPORARY TABLE Should be present in Binary log **************" +--source include/show_binlog_events.inc + +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (NULL); +--sync_slave_with_master + +# Cleanup +--connection master +DROP TABLE t1; + +--source include/rpl_end.inc + diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_known_bugs_detection.test 2019-11-06 06:20:36.000000000 +0000 @@ -14,45 +14,6 @@ source include/master-slave.inc; -call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); - -# -# This is to test that slave properly detects if -# master may suffer from: -# BUG#24432 "INSERT... ON DUPLICATE KEY UPDATE skips auto_increment values" -# (i.e. on master, INSERT ON DUPLICATE KEY UPDATE is used and manipulates -# an auto_increment column, and is binlogged statement-based). -# - -# testcase with INSERT VALUES -CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT, -UNIQUE(b)); -sync_slave_with_master; -connection master; -INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10; -SELECT * FROM t1; -connection slave; - -# show the error message -#1105 = ER_UNKNOWN_ERROR ---let $slave_sql_errno= 1105 ---let $show_slave_sql_error= 1 -call mtr.add_suppression("Slave SQL.*suffer.*http:..bugs.mysql.com.bug.php.id=24432"); ---source include/wait_for_slave_sql_error.inc -# show that it was not replicated -SELECT * FROM t1; - -# restart replication for the next testcase -stop slave; ---source include/wait_for_slave_to_stop.inc -reset slave; -connection master; -reset master; -drop table t1; -connection slave; -start slave; ---source include/wait_for_slave_to_start.inc - # testcase with INSERT SELECT connection master; CREATE TABLE t1 ( diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_mdev_17614.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_mdev_17614.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_mdev_17614.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_mdev_17614.test 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,121 @@ +source include/have_debug.inc; +source include/have_innodb.inc; +-- source include/have_binlog_format_statement.inc +source include/master-slave.inc; +# MDEV-17614 +# INSERT on dup key update is replication unsafe +# There can be three case +# 1. 2 unique key, Replication is unsafe. +# 2. 2 unique key , with one auto increment key, Safe to replicate because Innodb will acquire gap lock +# 3. n no of unique keys (n>1) but insert is only in 1 unique key +# 4. 2 unique key , with one auto increment key(but user gives auto inc value), unsafe to replicate + +# Case 1 +call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY , b INT, +UNIQUE(b), c int) engine=innodb; +sync_slave_with_master; +connection master; +INSERT INTO t1 VALUES (1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); + --connection master1 + INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +--connection master +COMMIT; +SELECT * FROM t1; +--connection slave +# show the error message +--let $slave_sql_errno= 1062 +--let $show_slave_sql_error= 1 +--source include/wait_for_slave_sql_error.inc +--echo #Different value from server +SELECT * FROM t1; + +# restart replication for the next testcase +stop slave; +--source include/wait_for_slave_to_stop.inc +reset slave; +connection master; +reset master; +drop table t1; +connection slave; +start slave; +--source include/wait_for_slave_to_start.inc +# Case 2 +--connection master +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, +UNIQUE(b), c int) engine=innodb; +sync_slave_with_master; +connection master; +INSERT INTO t1 VALUES (default, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (default, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); + --connection master1 + INSERT INTO t1 VALUES(default, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +--connection master +COMMIT; +SELECT * FROM t1; +--sync_slave_with_master +--echo #same data as master +SELECT * FROM t1; + +connection master; +drop table t1; +--sync_slave_with_master + +# Case 3 +--connection master +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, +UNIQUE(b), c int, d int ) engine=innodb; +sync_slave_with_master; +connection master; +INSERT INTO t1 VALUES (1, 1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, NULL, 2, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); + --connection master1 + INSERT INTO t1 VALUES(3, NULL, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +--connection master +COMMIT; +SELECT * FROM t1; +--sync_slave_with_master +--echo #same data as master +SELECT * FROM t1; +connection master; +drop table t1; +--sync_slave_with_master + +# Case 4 +--connection master +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, +UNIQUE(b), c int) engine=innodb; +sync_slave_with_master; +connection master; +INSERT INTO t1 VALUES (1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); + --connection master1 + INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +--connection master +COMMIT; +SELECT * FROM t1; +--connection slave +# show the error message +--let $slave_sql_errno= 1062 +--let $show_slave_sql_error= 1 +--source include/wait_for_slave_sql_error.inc +--echo #Different value from server +SELECT * FROM t1; + +# restart replication for the next testcase +stop slave; +--source include/wait_for_slave_to_stop.inc +reset slave; +connection master; +reset master; +drop table t1; +connection slave; +start slave; +--source include/wait_for_slave_to_start.inc + +--source include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_parallel_ignored_errors.test 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1 @@ +--source include/rpl_parallel_ignored_errors.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_sync_with_innodb_thd_conc.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_sync_with_innodb_thd_conc.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_sync_with_innodb_thd_conc.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_sync_with_innodb_thd_conc.test 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,41 @@ +# ==== Purpose ==== +# +# Test verifies that replication shouldn't hang when number of active threads +# on the slave server are less than the allowed innodb_thread_concurrency value. +# +# ==== Implementation ==== +# +# Steps: +# 0 - Have master slave replication setup with engine being Innodb. +# 1 - Configure innodb_thread_concurrency = 100. +# 2 - Do some DML on master and sync the slave with master. +# 3 - Ensure replication doesn't hang. +# +# ==== References ==== +# +# MDEV-20247: Replication hangs with "preparing" and never starts +# + +--source include/master-slave.inc +--source include/have_innodb.inc + +--connection slave +SET @old_innodb_thread_concurrency := @@innodb_thread_concurrency; +SET @old_innodb_thread_sleep_delay := @@innodb_thread_sleep_delay; +SET GLOBAL innodb_thread_concurrency = 100; + +--connection master +CREATE TABLE t(f INT) ENGINE=INNODB; +INSERT INTO t VALUES (10); +--sync_slave_with_master + +--let $diff_tables=master:t, slave:t +--source include/diff_tables.inc + +--echo "===== Clean up=======" +--connection master +DROP TABLE t; +--sync_slave_with_master +SET GLOBAL innodb_thread_concurrency = @old_innodb_thread_concurrency; +SET GLOBAL innodb_thread_sleep_delay = @old_innodb_thread_sleep_delay; +--source include/rpl_end.inc diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_unsafe_statements.test mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_unsafe_statements.test --- mariadb-10.1-10.1.41/mysql-test/suite/rpl/t/rpl_unsafe_statements.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/rpl/t/rpl_unsafe_statements.test 2019-11-06 06:20:36.000000000 +0000 @@ -24,7 +24,7 @@ --source include/have_innodb.inc --source include/have_binlog_format_mixed.inc --source include/master-slave.inc - +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); # Case-1: BINLOG_STMT_UNSAFE_AUTOINC_COLUMNS # Statement is unsafe because it invokes a trigger or a # stored function that inserts into an AUTO_INCREMENT column. diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result --- mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/r/delayed_insert_limit_func.result 2019-11-06 06:20:36.000000000 +0000 @@ -51,14 +51,12 @@ INSERT DELAYED INTO t1 VALUES('40','1','1'); INSERT DELAYED INTO t1 VALUES('41','1','1'); INSERT DELAYED INTO t1 VALUES('42','1','1'); -INSERT DELAYED INTO t1 VALUES('43','1','1');| +INSERT DELAYED INTO t1 VALUES('43','1','1'); ** Connection con0 ** SELECT COUNT(*) FROM t1; ** Connection default ** ** Wait till con0 is blocked ** UNLOCK TABLES; -** Connection con1 ** -Asynchronous "reap" result ** Connection con0 ** Asynchronous "reap" result The next result suffers from @@ -84,7 +82,6 @@ INSERT INTO t1 VALUES('6'); LOCK TABLE v1 READ; ** Connection con1 ** -Asynchronous execute INSERT DELAYED INTO t1 VALUES('7'); INSERT DELAYED INTO t1 VALUES('8'); INSERT DELAYED INTO t1 VALUES('9'); @@ -100,23 +97,22 @@ INSERT DELAYED INTO t1 VALUES('19'); INSERT DELAYED INTO t1 VALUES('20'); INSERT DELAYED INTO t1 VALUES('21'); -INSERT DELAYED INTO t1 VALUES('22');| +INSERT DELAYED INTO t1 VALUES('22'); ** Connection con0 ** Asynchronous execute -SELECT COUNT(*) BETWEEN 6 AND 22 FROM t1; +SELECT COUNT(*) FROM t1; ** Connection default ** ** Wait till con0 is blocked ** UNLOCK TABLES; -** Connection con1 ** ** Connection con0 ** Asynchronous "reap" result -COUNT(*) BETWEEN 6 AND 22 -1 +COUNT(*) +22 ** Connection default** Checking if the delayed insert gives the same result afterwards -SELECT COUNT(*) BETWEEN 6 AND 22 FROM t1; -COUNT(*) BETWEEN 6 AND 22 -1 +SELECT COUNT(*) FROM t1; +COUNT(*) +22 ** Connection default** DROP TABLE t1; DROP VIEW v1; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff --- mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff 2019-11-06 06:20:36.000000000 +0000 @@ -1215,7 +1215,7 @@ VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.45 -+GLOBAL_VALUE 5.6.44-86.0 ++GLOBAL_VALUE 5.6.45-86.1 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff --- mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff 2019-11-06 06:20:36.000000000 +0000 @@ -685,7 +685,7 @@ VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.45 -+GLOBAL_VALUE 5.6.44-86.0 ++GLOBAL_VALUE 5.6.45-86.1 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test --- mariadb-10.1-10.1.41/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test 2019-11-06 06:20:36.000000000 +0000 @@ -66,8 +66,6 @@ --echo ** Connection con1 ** connection con1; -delimiter |; -send INSERT DELAYED INTO t1 VALUES('7','1','1'); INSERT DELAYED INTO t1 VALUES('8','1','1'); INSERT DELAYED INTO t1 VALUES('9','1','1'); @@ -104,8 +102,7 @@ INSERT DELAYED INTO t1 VALUES('40','1','1'); INSERT DELAYED INTO t1 VALUES('41','1','1'); INSERT DELAYED INTO t1 VALUES('42','1','1'); -INSERT DELAYED INTO t1 VALUES('43','1','1');| -delimiter ;| +INSERT DELAYED INTO t1 VALUES('43','1','1'); --echo ** Connection con0 ** connection con0; @@ -126,11 +123,6 @@ --source include/wait_condition.inc UNLOCK TABLES; ---echo ** Connection con1 ** -connection con1; ---echo Asynchronous "reap" result -reap; - --echo ** Connection con0 ** connection con0; --echo Asynchronous "reap" result @@ -170,10 +162,6 @@ --echo ** Connection con1 ** connection con1; ---echo Asynchronous execute -delimiter |; - -send INSERT DELAYED INTO t1 VALUES('7'); INSERT DELAYED INTO t1 VALUES('8'); INSERT DELAYED INTO t1 VALUES('9'); @@ -189,9 +177,7 @@ INSERT DELAYED INTO t1 VALUES('19'); INSERT DELAYED INTO t1 VALUES('20'); INSERT DELAYED INTO t1 VALUES('21'); -INSERT DELAYED INTO t1 VALUES('22');| - -delimiter ;| +INSERT DELAYED INTO t1 VALUES('22'); --echo ** Connection con0 ** connection con0; @@ -202,7 +188,7 @@ --echo Asynchronous execute # Due to performance and server behaveiour the test observes values between 6 and 22. # In any case the value must not be outside of that range. -let $my_select= SELECT COUNT(*) BETWEEN 6 AND 22 FROM t1; +let $my_select= SELECT COUNT(*) FROM t1; send; eval $my_select; @@ -215,10 +201,6 @@ --source include/wait_condition.inc UNLOCK TABLES; ---echo ** Connection con1 ** -connection con1; -reap; - --echo ** Connection con0 ** connection con0; --echo Asynchronous "reap" result diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result mariadb-10.1-10.1.43/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result --- mariadb-10.1-10.1.41/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result 2019-11-06 06:20:36.000000000 +0000 @@ -2,9 +2,15 @@ # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above # # Verbose run -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -28,11 +34,25 @@ Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # Silent run -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=InnoDB; +ALTER TABLE time_zone_name ENGINE=InnoDB; +ALTER TABLE time_zone_transition ENGINE=InnoDB; +ALTER TABLE time_zone_transition_type ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; TRUNCATE TABLE time_zone_transition; @@ -53,26 +73,56 @@ Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # # Testing with explicit timezonefile # -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); SET @time_zone_id= LAST_INSERT_ID(); INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES (@time_zone_id, 0, 0, 0, 'GMT') ; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; # # Testing --leap # -set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?'); -prepare set_wsrep_myisam from @prep; -set @toggle=1; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone_leap_second ENGINE=InnoDB; +END IF| +\d ; TRUNCATE TABLE time_zone_leap_second; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone_leap_second ENGINE=MyISAM; +END IF| +\d ; ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -set @toggle=0; execute set_wsrep_myisam using @toggle; +\d | +IF (select count(*) from information_schema.global_variables where +variable_name='wsrep_on') = 1 THEN +ALTER TABLE time_zone ENGINE=MyISAM; +ALTER TABLE time_zone_name ENGINE=MyISAM; +ALTER TABLE time_zone_transition ENGINE=MyISAM; +ALTER TABLE time_zone_transition_type ENGINE=MyISAM; +END IF| +\d ; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result mariadb-10.1-10.1.43/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result --- mariadb-10.1-10.1.41/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,74 @@ +# +# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above +# +# Verbose run +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +prepare set_wsrep_write_binlog from @prep1; +set @toggle=0; execute set_wsrep_write_binlog using @toggle; +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. +Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it. +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. +Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it. +Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. +ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; +# Silent run +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +prepare set_wsrep_write_binlog from @prep1; +set @toggle=0; execute set_wsrep_write_binlog using @toggle; +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. +ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; +ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; +# +# Testing with explicit timezonefile +# +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +prepare set_wsrep_write_binlog from @prep1; +set @toggle=0; execute set_wsrep_write_binlog using @toggle; +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +# +# Testing --leap +# +set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); +prepare set_wsrep_write_binlog from @prep1; +set @toggle=0; execute set_wsrep_write_binlog using @toggle; +TRUNCATE TABLE time_zone_leap_second; +ALTER TABLE time_zone_leap_second ORDER BY Transition_time; diff -Nru mariadb-10.1-10.1.41/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test mariadb-10.1-10.1.43/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test --- mariadb-10.1-10.1.41/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/suite/wsrep/t/mysql_tzinfo_to_sql_symlink_skip.test 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,40 @@ +--source include/have_wsrep.inc +--source include/have_symlink.inc +--source include/not_windows.inc + +--echo # +--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above +--echo # + +--exec mkdir $MYSQLTEST_VARDIR/zoneinfo +--exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix +--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT +--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/garbage +--copy_file std_data/words.dat $MYSQLTEST_VARDIR/zoneinfo/ignored.tab + +--echo # Verbose run +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --verbose --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # Silent run +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1 + +--echo # +--echo # Testing with explicit timezonefile +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--echo # +--echo # Testing --leap +--echo # + +--exec $MYSQL_TZINFO_TO_SQL --leap --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +# +# Cleanup +# + +--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo diff -Nru mariadb-10.1-10.1.41/mysql-test/t/drop_bad_db_type.test mariadb-10.1-10.1.43/mysql-test/t/drop_bad_db_type.test --- mariadb-10.1-10.1.41/mysql-test/t/drop_bad_db_type.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/drop_bad_db_type.test 2019-11-06 06:20:36.000000000 +0000 @@ -7,6 +7,7 @@ let $mysqld_datadir= `select @@datadir`; +SET @save_dbug = @@debug_dbug; set debug_dbug='+d,unstable_db_type'; install soname 'ha_archive'; @@ -27,5 +28,4 @@ --list_files $mysqld_datadir/test uninstall soname 'ha_archive'; -set debug_dbug='-d,unstable_db_type'; - +set debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/drop_debug.test mariadb-10.1-10.1.43/mysql-test/t/drop_debug.test --- mariadb-10.1-10.1.41/mysql-test/t/drop_debug.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/drop_debug.test 2019-11-06 06:20:36.000000000 +0000 @@ -10,17 +10,13 @@ --echo # -- --echo ---disable_warnings -DROP DATABASE IF EXISTS mysql_test; ---enable_warnings - ---echo CREATE DATABASE mysql_test; CREATE TABLE mysql_test.t1(a INT); CREATE TABLE mysql_test.t2(b INT); CREATE TABLE mysql_test.t3(c INT); --echo +SET @save_dbug = @@debug_dbug; SET SESSION debug_dbug= "+d,bug43138"; --echo @@ -28,7 +24,7 @@ DROP DATABASE mysql_test; --echo -SET SESSION debug_dbug= "-d,bug43138"; +SET SESSION debug_dbug=@save_dbug; --echo --echo # -- diff -Nru mariadb-10.1-10.1.41/mysql-test/t/func_math.test mariadb-10.1-10.1.43/mysql-test/t/func_math.test --- mariadb-10.1-10.1.41/mysql-test/t/func_math.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/func_math.test 2019-11-06 06:20:36.000000000 +0000 @@ -587,6 +587,69 @@ SELECT STDDEV_SAMP(ROUND('0', 309)) FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal +--echo # + +--echo # Testing that dyadic arithmetic operations are symmetric +--echo # for (+1) and (-1) and produce the same length in CONCAT(), +--echo # because (+1) and (-1) have the same data type: signed int. + +CREATE TABLE t1 AS SELECT + CONCAT(+1%2.0), + CONCAT(-1%2.0), + CONCAT(+1/2.0), + CONCAT(-1/2.0), + CONCAT(+1*2.0), + CONCAT(-1*2.0), + CONCAT(+1+2.0), + CONCAT(-1+2.0), + CONCAT(+1-2.0), + CONCAT(-1-2.0); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + CONCAT(+1%2), + CONCAT(-1%2), + CONCAT(+1/2), + CONCAT(-1/2), + CONCAT(+1*2), + CONCAT(-1*2), + CONCAT(+1+2), + CONCAT(-1+2), + CONCAT(+1-2), + CONCAT(-1-2); +SHOW CREATE TABLE t1; +DROP TABLE t1; + + +--echo # +--echo # Bug #29723340: MYSQL SERVER CRASH AFTER SQL QUERY WITH DATA ?AST +--echo # + +create table t1(a int); +insert t1 values("1e-214748364"); +insert t1 values("1e-2147483648"); +insert t1 values("1e-21474836480"); +insert t1 values("1e+214748364"); +insert t1 values("1e+2147483647"); +insert t1 values("1e+21474836470"); + +# if max max_allowed_packet will ever be increased beyond 2GB, this could +# break again: +set global max_allowed_packet= cast(2*1024*1024*1024+1024 as unsigned); +connect foo,localhost,root; +set @a=2147483647; +insert t1 values (concat('1', repeat('0', @a+18), 'e-', @a-1, '0')); +disconnect foo; +connection default; +set global max_allowed_packet=default; + +select * from t1; +drop table t1; + --echo # --echo # End of 5.5 tests --echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/t/index_merge_innodb.test mariadb-10.1-10.1.43/mysql-test/t/index_merge_innodb.test --- mariadb-10.1-10.1.41/mysql-test/t/index_merge_innodb.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/index_merge_innodb.test 2019-11-06 06:20:36.000000000 +0000 @@ -14,7 +14,12 @@ --source include/not_staging.inc --source include/have_xtradb.inc -let $engine_type= InnoDB; +connect disable_purge,localhost,root,,; +--echo # Disable the purge of InnoDB history, to make the test run faster. +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; + +SET STORAGE_ENGINE = InnoDB; # InnoDB does not support Merge tables (affects include/index_merge1.inc) let $merge_table_support= 0; @@ -37,7 +42,9 @@ --echo # --echo # BUG#56862/640419: Wrong result with sort_union index merge when one --echo # of the merged index scans is the primary key scan ---echo # +--echo # + +CREATE TABLE t0(a int, b int) ENGINE=MyISAM; CREATE TABLE t1 ( pk int NOT NULL AUTO_INCREMENT PRIMARY KEY, @@ -46,27 +53,19 @@ INDEX idx(a)) ENGINE=INNODB; -begin; -INSERT INTO t1(a,b) VALUES +INSERT INTO t0(a,b) VALUES (11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500), (3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800), (6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700), (13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000); -INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1; -INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1; -INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; -INSERT INTO t1(a,b) SELECT a,b FROM t1; +INSERT INTO t0(a,b) SELECT a+20, b+2000 FROM t0; +INSERT INTO t0(a,b) SELECT a+40, b+4000 FROM t0; +INSERT INTO t0(a,b) SELECT a+80, b+8000 FROM t0; +begin; +INSERT INTO t1(a,b) SELECT t0.a,t0.b FROM t0, seq_1_to_1024; INSERT INTO t1 VALUES (1000000, 0, 0); commit; +DROP TABLE t0; SET SESSION sort_buffer_size = 1024*36; set @tmp_optimizer_switch=@@optimizer_switch; @@ -130,9 +129,6 @@ --echo # BUG#1006164: Multi-table DELETE that uses innodb + index_merge/intersect may fail to delete rows --echo # -create table t0(a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - create table t1 ( pk int auto_increment, zone_id int, @@ -142,7 +138,7 @@ key (modified) ) engine=innodb; -insert into t1 (zone_id, modified) select 0,0 from t0 A, t0 B, t0 C, t0 D; +insert into t1 (zone_id, modified) select 0,0 from seq_1_to_10000; update t1 set zone_id=487, modified=9 where pk=7259; update t1 set zone_id=487, modified=9 where pk=7260; update t1 set zone_id=830, modified=9 where pk=8434; @@ -156,7 +152,7 @@ commit; select * from t1 where t1.zone_id=830 AND modified=9; -drop table t0, t1; +drop table t1; --echo # --echo # MDEV-376: Wrong result (missing rows) with index_merge+index_merge_intersection, join @@ -196,14 +192,10 @@ KEY key2 (key2) ) ENGINE=InnoDB AUTO_INCREMENT=12860259 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT; -create table t2(a int); -insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -create table t3(a int); -insert into t3 select A.a + B.a* 10 + C.a * 100 + D.a*1000 from t2 A, t2 B, t2 C, t2 D; - insert into t1 (key1, key2, col1,col2,col3,col4) -select a,a, a,a,a,a from t3; +select seq,seq,seq,seq,seq,seq from seq_1_to_10000; SELECT sum(col1) FROM t1 FORCE INDEX (key1,key2) WHERE (key1 between 10 and 8191+10) or (key2= 5); -drop table t1,t2,t3; +drop table t1; set optimizer_switch=@tmp_optimizer_switch; + +disconnect disable_purge; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/index_merge_myisam.test mariadb-10.1-10.1.43/mysql-test/t/index_merge_myisam.test --- mariadb-10.1-10.1.41/mysql-test/t/index_merge_myisam.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/index_merge_myisam.test 2019-11-06 06:20:36.000000000 +0000 @@ -10,7 +10,7 @@ # include/index_merge*.inc files # -let $engine_type= MyISAM; +SET STORAGE_ENGINE = MyISAM; # MyISAM supports Merge tables let $merge_table_support= 1; @@ -33,7 +33,7 @@ A.a * B.a*10 + C.a*100, A.a, 'filler' -from t0 A, t0 B, t0 C; +from t0 A, t0 B, t0 C; --echo This should use union: explain select * from t1 where a=1 or b=1; @@ -253,15 +253,7 @@ INDEX i1(key1) ); -insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8); -let $1=7; -set @d=8; -while ($1) -{ - eval insert into t0 select key1+ @d from t0; - eval set @d=@d*2; - dec $1; -} +insert into t0 select * from seq_1_to_1024; alter table t0 add key2 int not null, add index i2(key2); alter table t0 add key3 int not null, add index i3(key3); alter table t0 add key8 int not null, add index i8(key8); diff -Nru mariadb-10.1-10.1.41/mysql-test/t/join.test mariadb-10.1-10.1.43/mysql-test/t/join.test --- mariadb-10.1-10.1.41/mysql-test/t/join.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/join.test 2019-11-06 06:20:36.000000000 +0000 @@ -1614,6 +1614,65 @@ drop table t1,t2,t3,t4,s1,s2; --echo # +--echo # MDEV-20265: Mix of comma joins with JOIN expressions +--echo # (correction of the fix for MDEV-19421) +--echo # MDEV-20330: duplicate +--echo # + +create table t1 (a int); +insert into t1 values (7), (5), (3); +create table t2 (a int); +insert into t2 values (5), (1), (7); +create table t3 (a int); +insert into t3 values (2), (7), (3); +create table t4 (a int); +insert into t4 values (4), (7), (9), (5); +create table t5 (a int); +insert into t5 values (3), (7), (9), (2); + + +let $q= +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a +from t1, t2 join t3 left join t4 on t3.a=t4.a; +eval explain extended $q; +eval $q; + +let $q= +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a +from t1, t2 join t3 right join t4 on t3.a=t4.a; +eval explain extended $q; +eval $q; + +let $q= +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a; +eval explain extended $q; +eval $q; + +let $q= +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a; +eval explain extended $q; +eval $q; + +let $q= +select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a +from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a; +eval explain extended $q; +eval $q; + +drop table t1,t2,t3,t4,t5; + +select a.a +from (select 1 as a) a, + (select 2 as b) b + cross join + (select 3 as c) c + left join + (select 4 as d) d + on 1; + +--echo # --echo # End of MariaDB 5.5 tests --echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/t/log_slow_debug.test mariadb-10.1-10.1.43/mysql-test/t/log_slow_debug.test --- mariadb-10.1-10.1.41/mysql-test/t/log_slow_debug.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/log_slow_debug.test 2019-11-06 06:20:36.000000000 +0000 @@ -9,6 +9,7 @@ FLUSH SLOW LOGS; SET @@GLOBAL.slow_query_log=ON; SET @@GLOBAL.log_slow_admin_statements=ON; +SET @save_dbug = @@debug_dbug; SET SESSION debug_dbug="+d,simulate_slow_query"; DELIMITER $$; @@ -118,7 +119,7 @@ --echo # Clean up --echo # -SET SESSION debug_dbug="-d,simulate_slow_query"; +SET SESSION debug_dbug=@save_dbug; TRUNCATE mysql.slow_log; SET @@global.slow_query_log= @org_slow_query_log; SET @@global.log_output= @org_log_output; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/myisam.test mariadb-10.1-10.1.43/mysql-test/t/myisam.test --- mariadb-10.1-10.1.41/mysql-test/t/myisam.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/myisam.test 2019-11-06 06:20:36.000000000 +0000 @@ -1781,3 +1781,22 @@ # show variables like 'myisam_block_size'; select @@global.myisam_block_size; + + +--echo # +--echo # MDEV-20704 An index on a double column erroneously uses prefix compression +--echo # + +CREATE TABLE t1 ( + id INT NOT NULL PRIMARY KEY, + d DOUBLE, + KEY (d) +) ENGINE=MyISAM; +let $MYSQLD_DATADIR= `select @@datadir`; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1 +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/t/order_by_innodb.test mariadb-10.1-10.1.43/mysql-test/t/order_by_innodb.test --- mariadb-10.1-10.1.41/mysql-test/t/order_by_innodb.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/order_by_innodb.test 2019-11-06 06:20:36.000000000 +0000 @@ -61,3 +61,27 @@ where key1<3 or key2<3; drop table t0, t1; + +--echo # +--echo # MDEV-18094: Query with order by limit picking index scan over filesort +--echo # + +create table t0 (a int); +INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0); + +CREATE TABLE t1 ( +a int(11), +b int(11), +c int(11), +KEY a_c (a,c), +KEY a_b (a,b) +) ENGINE=InnoDB; +insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C; + +--echo # should use ref access +explain select a,b,c from t1 where a=1 and c=2 order by b; + +--echo # both should use range access +explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000; +explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000; +drop table t1,t0; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/partition_debug_sync.test mariadb-10.1-10.1.43/mysql-test/t/partition_debug_sync.test --- mariadb-10.1-10.1.41/mysql-test/t/partition_debug_sync.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/partition_debug_sync.test 2019-11-06 06:20:36.000000000 +0000 @@ -8,10 +8,7 @@ --source include/have_debug.inc --source include/have_innodb.inc ---disable_warnings -DROP TABLE IF EXISTS t1, t2; SET DEBUG_SYNC= 'RESET'; ---enable_warnings --echo # --echo # Bug#42438: Crash ha_partition::change_table_ptr diff -Nru mariadb-10.1-10.1.41/mysql-test/t/processlist_notembedded.test mariadb-10.1-10.1.43/mysql-test/t/processlist_notembedded.test --- mariadb-10.1-10.1.41/mysql-test/t/processlist_notembedded.test 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/processlist_notembedded.test 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,34 @@ +source include/have_debug.inc; +source include/have_debug_sync.inc; +source include/not_embedded.inc; + +--echo # +--echo # MDEV-20466: SHOW PROCESSLIST truncates query text on \0 bytes +--echo # + +connect (con1,localhost,root,,); + +connection con1; + +let $q= `select CONCAT("SELECT user FROM mysql.user WHERE user ='some", CHAR(0), "' or sleep (30)")`; + +SET DEBUG_SYNC= 'before_join_optimize SIGNAL in_sync'; +--disable_query_log +--send_eval $q; +--enable_query_log +connection default; + +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; + +exec $MYSQL test -e "SHOW PROCESSLIST" > $MYSQLTEST_VARDIR/tmp/MDEV-20466.text; + +let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/MDEV-20466.text; +let SEARCH_PATTERN=sleep; +source include/search_pattern_in_file.inc; +remove_file $MYSQLTEST_VARDIR/tmp//MDEV-20466.text; + +disconnect con1; + +SET DEBUG_SYNC = 'RESET'; + +--echo End of 5.5 tests diff -Nru mariadb-10.1-10.1.41/mysql-test/t/processlist.test mariadb-10.1-10.1.43/mysql-test/t/processlist.test --- mariadb-10.1-10.1.41/mysql-test/t/processlist.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/processlist.test 2019-11-06 06:20:36.000000000 +0000 @@ -49,10 +49,10 @@ select command, time < 5 from information_schema.processlist where id != connection_id(); disconnect con1; -set debug_sync='reset'; - connection default; +set debug_sync='reset'; +--echo End of 5.5 tests --echo # --echo # 10.1 tests diff -Nru mariadb-10.1-10.1.41/mysql-test/t/selectivity.test mariadb-10.1-10.1.43/mysql-test/t/selectivity.test --- mariadb-10.1-10.1.41/mysql-test/t/selectivity.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/selectivity.test 2019-11-06 06:20:36.000000000 +0000 @@ -1,4 +1,5 @@ --source include/have_stat_tables.inc +--source include/have_sequence.inc --disable_warnings drop table if exists t0,t1,t2,t3; @@ -1102,3 +1103,136 @@ drop table t1; drop function f1; +--echo # +--echo # MDEV-19834 Selectivity of an equality condition discounted twice +--echo # +set @@optimizer_use_condition_selectivity=4; +set @@use_stat_tables='preferably'; +create table t1 (a int, b int, key (b), key (a)); +insert into t1 +select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; +analyze table t1 ; + +--echo # Check what info the optimizer has about selectivities +explain extended select * from t1 use index () where a in (17,51,5); +explain extended select * from t1 use index () where b=2; + +--echo # Now, the equality is used for ref access, while the range condition +--echo # gives selectivity data +explain extended select * from t1 where a in (17,51,5) and b=2; +drop table t1; + +set use_stat_tables= @save_use_stat_tables; +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; + +--echo # +--echo # MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1) +--echo # + +set @@optimizer_use_condition_selectivity=2; + +set names utf8; + +CREATE DATABASE world; + +use world; + +--source include/world_schema.inc + +--disable_query_log +--disable_result_log +--disable_warnings +--source include/world.inc +--enable_warnings +--enable_result_log +--enable_query_log + +CREATE INDEX Name ON City(Name); +CREATE INDEX CountryPopulation ON City(Country,Population); +CREATE INDEX CountryName ON City(Country,Name); + +--disable_query_log +--disable_result_log +--disable_warnings +ANALYZE TABLE City; +--enable_warnings +--enable_result_log +--enable_query_log + +set @@optimizer_use_condition_selectivity=2; + +EXPLAIN +SELECT * FROM City WHERE Country='FIN'; + +DROP DATABASE world; + +use test; + +CREATE TABLE t1 ( + a INT, + b INT NOT NULL, + c char(100), + KEY (b, c), + KEY (b, a, c) +) ENGINE=MyISAM +DEFAULT CHARSET = utf8; + +INSERT INTO t1 VALUES +(1, 1, 1), +(2, 2, 2), +(3, 3, 3), +(4, 4, 4), +(5, 5, 5), +(6, 6, 6), +(7, 7, 7), +(8, 8, 8), +(9, 9, 9); + +INSERT INTO t1 SELECT a + 10, b, c FROM t1; +INSERT INTO t1 SELECT a + 20, b, c FROM t1; +INSERT INTO t1 SELECT a + 40, b, c FROM t1; +INSERT INTO t1 SELECT a + 80, b, c FROM t1; +INSERT INTO t1 SELECT a + 160, b, c FROM t1; +INSERT INTO t1 SELECT a + 320, b, c FROM t1; +INSERT INTO t1 SELECT a + 640, b, c FROM t1; +INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80; + +EXPLAIN +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; +SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9; + +set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; + +DROP TABLE t1; + +--echo # +--echo # MDEV-20424: New default value for optimizer_use_condition-selectivity +--echo # leads to bad plan +--echo # + +create table t1(a int, b int, c int, d int, key(a,b)); +insert into t1 select 50,seq-1,seq-1,seq from seq_1_to_10; +insert into t1 select seq-1,seq-1,seq-1,seq from seq_1_to_100 limit 90; + +create table t2(a int, b int, c int, primary key(a)); +insert into t2 select seq-1,seq-1,seq-1 from seq_1_to_100; + +create table t3(a int, b int, c int, primary key(a)); +insert into t3 select seq-1,seq-1,seq-1 from seq_1_to_100 limit 30; + +let $query= select t1.b,t2.a,t3.a,t3.b from t1,t2,t3 +where t1.c = t2.a AND t1.d = t3.a and t1.a = 50 and t1.b <= 100; + +set optimizer_use_condition_selectivity=1; +eval explain extended $query; +eval $query; + +set optimizer_use_condition_selectivity=2; +eval explain extended $query; +eval $query; +set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; + +drop table t1,t2,t3; + +--echo # End of 10.1 tests + diff -Nru mariadb-10.1-10.1.41/mysql-test/t/sp-code.test mariadb-10.1-10.1.43/mysql-test/t/sp-code.test --- mariadb-10.1-10.1.41/mysql-test/t/sp-code.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/sp-code.test 2019-11-06 06:20:36.000000000 +0000 @@ -696,9 +696,10 @@ delimiter ;| +SET @save_dbug = @@debug_dbug; SET SESSION debug_dbug="+d,bug23032_emit_warning"; CALL p1(); -SET SESSION debug_dbug="-d,bug23032_emit_warning"; +SET SESSION debug_dbug=@save_dbug; DROP PROCEDURE p1; DROP TABLE t1; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/sp.test mariadb-10.1-10.1.43/mysql-test/t/sp.test --- mariadb-10.1-10.1.41/mysql-test/t/sp.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/sp.test 2019-11-06 06:20:36.000000000 +0000 @@ -9078,7 +9078,7 @@ CALL sp; SELECT 1; DROP PROCEDURE sp; -CREATE PROCEDURE sp() SHOW USER_STATISTICS; +CREATE PROCEDURE sp() SET STATEMENT SQL_SELECT_LIMIT=0 FOR SHOW USER_STATISTICS; CALL sp; SELECT 1; DROP PROCEDURE sp; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/subselect_sj.test mariadb-10.1-10.1.43/mysql-test/t/subselect_sj.test --- mariadb-10.1-10.1.41/mysql-test/t/subselect_sj.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/subselect_sj.test 2019-11-06 06:20:36.000000000 +0000 @@ -2885,6 +2885,32 @@ drop table t1,t2; + +--echo # +--echo # MDEV-13172: Wrong result / SELECT ... WHERE EXISTS ... (with UNIQUE Key) +--echo # + +CREATE TABLE `t1` ( + `Id` int(11) NOT NULL, + PRIMARY KEY (`Id`) +); + +INSERT INTO `t1` (`Id`) VALUES (1); + +CREATE TABLE `t2` ( + `t1_Id` int(11) NOT NULL DEFAULT 0, + `col1` int(11) DEFAULT NULL, + UNIQUE KEY `col1` (`col1`) +); + +INSERT INTO `t2` (`t1_Id`, `col1`) VALUES (1, NULL), (1, NULL); + +SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); +explain extended +SELECT Id FROM t1 WHERE Id in (SELECT t1_Id FROM t2 WHERE t2.col1 IS NULL); + +DROP TABLE t1, t2; + --echo # End of 5.5 test # The following command must be the last one the file diff -Nru mariadb-10.1-10.1.41/mysql-test/t/sum_distinct-big.test mariadb-10.1-10.1.43/mysql-test/t/sum_distinct-big.test --- mariadb-10.1-10.1.41/mysql-test/t/sum_distinct-big.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/sum_distinct-big.test 2019-11-06 06:20:36.000000000 +0000 @@ -4,15 +4,11 @@ --source include/big_test.inc --source include/have_innodb.inc ---disable_warnings -DROP TABLE IF EXISTS t1, t2; ---enable_warnings +--source include/have_sequence.inc set @save_tmp_table_size=@@tmp_table_size; set @save_max_heap_table_size=@@max_heap_table_size; -set @save_storage_engine=@@storage_engine; - # # Test the case when distinct values doesn't fit in memory and # filesort is used (see uniques.cc:merge_walk) @@ -94,39 +90,14 @@ SET @@tmp_table_size=@save_tmp_table_size; SET @@max_heap_table_size=@save_max_heap_table_size; ---echo # ---echo # Bug mdev-4311: COUNT(DISTINCT...) requiring a file for Unique ---echo # (bug #68749) ---echo # - -set @save_storage_engine=@@storage_engine; -set storage_engine=INNODB; - -CREATE TABLE t1 (id INTEGER) ENGINE=InnoDB; +--echo # +--echo # MDEV-4311: COUNT(DISTINCT...) requiring a file for UNIQUE (bug #68749) +--echo # CREATE TABLE t2 (id INTEGER) ENGINE=InnoDB; -INSERT INTO t1 (id) VALUES (1), (1), (1),(1); -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 (id) SELECT id FROM t1; -INSERT INTO t1 SELECT id+1 FROM t1; -INSERT INTO t1 SELECT id+2 FROM t1; -INSERT INTO t1 SELECT id+4 FROM t1; -INSERT INTO t1 SELECT id+8 FROM t1; -INSERT INTO t1 SELECT id+16 FROM t1; -INSERT INTO t1 SELECT id+32 FROM t1; -INSERT INTO t1 SELECT id+64 FROM t1; -INSERT INTO t1 SELECT id+128 FROM t1; -INSERT INTO t1 SELECT id+256 FROM t1; -INSERT INTO t1 SELECT id+512 FROM t1; -INSERT INTO t1 SELECT id+1024 FROM t1; -INSERT INTO t1 SELECT id+2048 FROM t1; -INSERT INTO t1 SELECT id+4096 FROM t1; -INSERT INTO t1 SELECT id+8192 FROM t1; - -INSERT INTO t2 SELECT id FROM t1 ORDER BY id*rand(); +BEGIN; +INSERT INTO t2 SELECT b.seq FROM seq_1_to_128 a, seq_1_to_16384 b +ORDER BY b.seq*rand(); INSERT INTO t2 VALUE(NULL); --echo # With default tmp_table_size / max_heap_table_size @@ -147,7 +118,6 @@ --echo # Back to default tmp_table_size / max_heap_table_size SELECT SQL_NO_CACHE count(DISTINCT id) sm FROM t2; +COMMIT; -DROP TABLE t1,t2; - -set storage_engine=@save_storage_engine; +DROP TABLE t2; diff -Nru mariadb-10.1-10.1.41/mysql-test/t/type_date.test mariadb-10.1-10.1.43/mysql-test/t/type_date.test --- mariadb-10.1-10.1.41/mysql-test/t/type_date.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/type_date.test 2019-11-06 06:20:36.000000000 +0000 @@ -600,6 +600,30 @@ DROP VIEW v1; DROP TABLE t1; + +--echo # +--echo # MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table +--echo # + +CREATE TABLE t1 (d DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1999-11-04'); +SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01'; +DROP TABLE t1; + + +--echo # +--echo # MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view +--echo # + +CREATE TABLE t1 (pk INT NOT NULL, d DATE NOT NULL); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1,'2018-06-22'),(2,'2018-07-11'); +SELECT GREATEST(pk, d) FROM t1; +SELECT GREATEST(pk, d) FROM v1; +DROP VIEW v1; +DROP TABLE t1; + + --echo # --echo # End of 10.1 tests --echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/t/type_datetime.test mariadb-10.1-10.1.43/mysql-test/t/type_datetime.test --- mariadb-10.1-10.1.41/mysql-test/t/type_datetime.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/type_datetime.test 2019-11-06 06:20:36.000000000 +0000 @@ -711,5 +711,42 @@ DROP TABLE t1; --echo # +--echo # MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH +--echo # + +SET SQL_MODE=DEFAULT; +CREATE OR REPLACE TABLE t1 (a CHAR(11)); +CREATE OR REPLACE TABLE t2 (b DATETIME); +INSERT INTO t1 VALUES ('2010-02-19') ; +SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH'; +INSERT INTO t2 SELECT * FROM t1; +DROP TABLE t1, t2; +SET SQL_MODE=DEFAULT; + + +--echo # +--echo # MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table +--echo # + +CREATE TABLE t1 (d DATETIME) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1999-11-04'); +SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01'; +DROP TABLE t1; + + +--echo # +--echo # MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view +--echo # + +CREATE TABLE t1 (pk INT NOT NULL, d DATETIME NOT NULL); +CREATE VIEW v1 AS SELECT * FROM t1; +INSERT INTO t1 VALUES (1,'2018-06-22 00:00:00'),(2,'2018-07-11 00:00:00'); +SELECT GREATEST(pk, d) FROM t1; +SELECT GREATEST(pk, d) FROM v1; +DROP VIEW v1; +DROP TABLE t1; + + +--echo # --echo # End of 10.1 tests --echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/t/type_int.test mariadb-10.1-10.1.43/mysql-test/t/type_int.test --- mariadb-10.1-10.1.41/mysql-test/t/type_int.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/type_int.test 2019-11-06 06:20:36.000000000 +0000 @@ -1,4 +1,25 @@ --echo # +--echo # Start of 5.5 tests +--echo # + +--echo # +--echo # MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar'); +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # + + +--echo # --echo # Start of 10.1 tests --echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/t/type_newdecimal.test mariadb-10.1-10.1.43/mysql-test/t/type_newdecimal.test --- mariadb-10.1-10.1.41/mysql-test/t/type_newdecimal.test 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/t/type_newdecimal.test 2019-11-06 06:20:36.000000000 +0000 @@ -1625,6 +1625,49 @@ DROP TABLE t1; --echo # +--echo # MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal +--echo # + +CREATE TABLE t1 (d DECIMAL(1,0) ZEROFILL); +CREATE TABLE t2 AS SELECT 0 MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + +CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED); +CREATE TABLE t2 AS SELECT 0 MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE IF EXISTS t1,t2; + +CREATE TABLE t1 (d DECIMAL(1,0) ZEROFILL); +CREATE TABLE t2 AS SELECT CAST(0 AS UNSIGNED) MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + +CREATE TABLE t1 (d DECIMAL(1,0) UNSIGNED); +CREATE TABLE t2 AS SELECT CAST(0 AS UNSIGNED) MOD d AS f FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-20560 Assertion `precision > 0' failed in decimal_bin_size upon SELECT with MOD short unsigned decimal +--echo # + +CREATE TABLE t1 (a DECIMAL(1,0) UNSIGNED); +INSERT INTO t1 VALUES (1.0),(2.0); +SELECT DISTINCT 1 MOD a FROM t1; +CREATE TABLE t2 AS SELECT DISTINCT 1 MOD a AS f FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + +CREATE TABLE t1 (a DECIMAL(1,0) UNSIGNED); +INSERT INTO t1 VALUES (1.0),(2.0); +SELECT DISTINCT 1 MOD a FROM t1; +CREATE TABLE t2 AS SELECT DISTINCT CAST(1 AS UNSIGNED) MOD a AS f FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; + + +--echo # --echo # End of 5.5 tests --echo # diff -Nru mariadb-10.1-10.1.41/mysql-test/unstable-tests mariadb-10.1-10.1.43/mysql-test/unstable-tests --- mariadb-10.1-10.1.41/mysql-test/unstable-tests 2019-07-26 16:34:52.000000000 +0000 +++ mariadb-10.1-10.1.43/mysql-test/unstable-tests 2019-11-06 06:20:36.000000000 +0000 @@ -23,10 +23,9 @@ # ############################################################################## # -# Based on 10.1 2382cd14a8c96cf8b4375d7338abfa6e1b333a86 +# Based on 10.1 1bb857089fdcd3a08cb166cb6d75f3e1dbb76f27 main.alter_table_trans : MDEV-12084 - timeout -main.analyze_stmt : Modified in 10.1.39 main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result main.auth_named_pipe : MDEV-14724 - System error 2 main.bootstrap : Modified in 10.1.41 @@ -34,139 +33,100 @@ main.count_distinct2 : MDEV-11768 - timeout main.create_delayed : MDEV-10605 - failed with timeout main.create_drop_event : MDEV-16271 - Wrong result -main.create_drop_role : Modified in 10.1.39 -main.ctype_big5 : Include file modified in 10.1.39 -main.ctype_euckr : Include file modified in 10.1.39 -main.ctype_gb2312 : Include file modified in 10.1.39 -main.ctype_gbk : Include file modified in 10.1.39 -main.ctype_latin1 : Include file modified in 10.1.39 -main.ctype_sjis : Include file modified in 10.1.39 -main.ctype_tis620 : Include file modified in 10.1.39 -main.ctype_uca : Include file modified in 10.1.39 -main.ctype_ucs : Include file modified in 10.1.39 -main.ctype_ujis : Include file modified in 10.1.39 -main.ctype_utf16 : MDEV-10675: timeout or extra warnings; include file modified in 10.1.39 -main.ctype_utf16_uca : Include file modified in 10.1.39 -main.ctype_utf16le : Include file modified in 10.1.39 -main.ctype_utf32 : Include file modified in 10.1.39 -main.ctype_utf32_uca : Include file modified in 10.1.39 -main.ctype_utf8 : Include file modified in 10.1.39 +main.ctype_utf16 : MDEV-10675: timeout or extra warnings main.ctype_utf8_def_upgrade : Added in 10.1.41 -main.ctype_utf8mb4 : Include file modified in 10.1.39 -main.ctype_utf8mb4_heap : Include file modified in 10.1.39 -main.ctype_utf8mb4_innodb : Include file modified in 10.1.39 -main.ctype_utf8mb4_myisam : Include file modified in 10.1.39 -main.ddl_i18n_koi8r : Modified in 10.1.39 -main.ddl_i18n_utf8 : Modified in 10.1.39 main.debug_sync : MDEV-10607 - internal error main.derived : Modified in 10.1.41 main.derived_opt : MDEV-11768 - timeout main.derived_view : Modified in 10.1.41 main.dirty_close : MDEV-19368 - mysqltest failed but provided no output -main.events_1 : Modified in 10.1.39 +main.drop_bad_db_type : Modified in 10.1.42 +main.drop_debug : Modified in 10.1.42 main.events_2 : MDEV-13277 - Server crash main.events_bugs : MDEV-12892 - Crash in fill_schema_processlist main.events_restart : MDEV-12236 - Server shutdown problem main.events_slowlog : MDEV-12821 - Wrong result main.flush : MDEV-19368 - mysqltest failed but provided no output -main.func_gconcat : Modified in 10.1.39 -main.func_hybrid_type : Modified in 10.1.39 -main.func_math : Modified in 10.1.39 -main.func_str : Modified in 10.1.39 -main.func_time : Modified in 10.1.39 -main.gis : MDEV-13411 - wrong result on P8; modified in 10.1.39 -main.gis-precise : Modified in 10.1.39 -main.gis_notembedded : Added in 10.1.39 -main.grant4 : Modified in 10.1.39 +main.func_math : Modified in 10.1.42 +main.gis : MDEV-13411 - wrong result on P8 main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown main.index_intersect_innodb : MDEV-10643 - failed with timeout -main.index_merge_innodb : MDEV-7142 - Wrong execution plan, timeout with valgrind; modified in 10.1.39 -main.index_merge_myisam : Include files modified in 10.1.39 +main.index_merge_innodb : MDEV-7142 - Wrong execution plan, timeout with valgrind; modified in 10.1.42 +main.index_merge_myisam : Modified in 10.1.42 main.information_schema_parameters : Modified in 10.1.41 -main.information_schema_prepare : Added in 10.1.39 main.innodb_mysql_lock : MDEV-7861 - sporadic lock detection failure -main.join : Modified in 10.1.41 +main.join : Modified in 10.1.42 main.join_cache : Modified in 10.1.41 main.join_nested : Modified in 10.1.41 main.join_outer : Modified in 10.1.41 main.join_outer_innodb : Modified in 10.1.41 -main.kill_processlist-6619 : MDEV-10793 - wrong result in processlist; modified in 10.1.39 -main.loaddata : MDEV-19368 - mysqltest failed but provided no output; modified in 10.1.39 -main.log_slow : MDEV-13263 - Wrong result; modified in 10.1.39 -main.log_slow_debug : Added in 10.1.39 +main.kill_processlist-6619 : MDEV-10793 - wrong result in processlist +main.loaddata : MDEV-19368 - mysqltest failed but provided no output +main.locale : MDEV-20521 - Wrong result (missing warning) +main.log_slow : MDEV-13263 - Wrong result +main.log_slow_debug : Modified in 10.1.42 main.log_tables-big : MDEV-13408 - wrong result main.mdev-504 : MDEV-10607 - sporadic "can't connect" main.mdev375 : MDEV-10607 - sporadic "can't connect" -main.mdev_19276 : Added in 10.1.39 main.merge : MDEV-10607 - sporadic "can't connect" main.multi_update : Modified in 10.1.41 -main.multi_update_big : Added in 10.1.39 main.multi_update_debug : MDEV-20136 - Debug sync point wait timed out; added in 10.1.41 main.multi_update_innodb : Modified in 10.1.41 -main.mysql : Modified in 10.1.39 +main.myisam : Modified in 10.1.42 main.mysql_client_test : MDEV-19369 - error: 5888, status: 23, errno: 2 main.mysql_client_test_comp : MDEV-19369 - error: 5888, status: 23, errno: 2 main.mysql_client_test_nonblock : MDEV-15096 - exec failed main.mysql_upgrade_noengine : MDEV-14355 - Plugin is busy main.mysqld--help : Modified in 10.1.41 main.mysqldump : Modified in 10.1.41 -main.mysqldump-compat : Modified in 10.1.39 main.mysqlhotcopy_myisam : MDEV-10995 - test hangs on debug build main.mysqlslap : MDEV-11801 - timeout main.mysqltest : MDEV-9269 - fails on Alpha -main.olap : Modified in 10.1.39 main.old-mode : MDEV-19373 - Wrong result +main.order_by_innodb : Modified in 10.1.42 main.order_by_optimizer_innodb : MDEV-10683 - wrong execution plan -main.partition : Modified in 10.1.39 -main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock -main.partition_innodb : Modified in 10.1.39 +main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock; modified in 10.1.42 main.partition_innodb_plugin : MDEV-12901 - Valgrind warnings main.plugin : Modified in 10.1.41 main.plugin_not_embedded : Modified in 10.1.41 +main.processlist : Modified in 10.1.42 +main.processlist_notembedded : Added in 10.1.42 main.ps : MDEV-11017 - sporadic wrong Prepared_stmt_count; modified in 10.1.41 main.ps_innodb : Added in 10.1.41 main.query_cache : MDEV-12895 - Wrong result main.query_cache_debug : MDEV-15281 - Resize or similar command in progress main.range_vs_index_merge_innodb : MDEV-15283 - Server has gone away main.repair_symlink-5543 : Modified in 10.1.41 +main.selectivity : Modified in 10.1.42 main.set_statement : MDEV-13183 - Wrong result main.show_explain : MDEV-10674 - sporadic failure -main.sp : Modified in 10.1.41 +main.sp : Modified in 10.1.42 +main.sp-code : Modified in 10.1.42 main.sp-security : MDEV-10607 - sporadic "can't connect" -main.sp-ucs2 : Modified in 10.1.39 -main.sp_notembedded : MDEV-10607 - internal error; modified in 10.1.39 -main.sp_trans : Modified in 10.1.39 -main.ssl_verify_ip : Added in 10.1.39 +main.sp_notembedded : MDEV-10607 - internal error main.stat_tables : Modified in 10.1.41 main.stat_tables_par_innodb : MDEV-14155 - wrong rounding -main.statistics : Modified in 10.1.39 main.status : MDEV-8510 - sporadic wrong result -main.status2 : Modified in 10.1.39 main.subselect : Modified in 10.1.41 main.subselect_innodb : MDEV-10614 - sporadic wrong results -main.subselect_sj : Modified in 10.1.41 +main.subselect_sj : Modified in 10.1.42 main.subselect_sj_mat : Modified in 10.1.41 +main.sum_distinct-big : Modified in 10.1.42 main.tc_heuristic_recover : MDEV-15200 - wrong error on mysqld_stub_cmd -main.timezone2 : Modified in 10.1.39 main.trigger_null-8605 : Modified in 10.1.41 -main.type_bit : Modified in 10.1.39 main.type_blob : MDEV-15195 - Wrong result -main.type_date : Modified in 10.1.39 -main.type_datetime : Modified in 10.1.41 +main.type_date : Modified in 10.1.42 +main.type_datetime : Modified in 10.1.42 main.type_datetime_hires : MDEV-10687 - timeout -main.type_decimal : Modified in 10.1.39 -main.type_year : Modified in 10.1.39 -main.update_innodb : Modified in 10.1.39 -main.userstat : Modified in 10.1.39 +main.type_int : Modified in 10.1.42 +main.type_newdecimal : Modified in 10.1.42 main.view : Modified in 10.1.41 -main.view_grant : Modified in 10.1.39 main.wait_timeout : Lost connection to MySQL server during query main.xa : MDEV-11769 - lock wait timeout #----------------------------------------------------------------------- archive.archive_bitfield : MDEV-11771 - Extra warning -archive.archive_eits : Added in 10.1.39 archive.archive_symlink : MDEV-12170 - unexpected error on rmdir archive.discover : MDEV-10510 - Table is marked as crashed archive.mysqlhotcopy_archive : MDEV-14726 - Table is marked as crashed @@ -178,27 +138,26 @@ #----------------------------------------------------------------------- binlog.binlog_commit_wait : MDEV-10150 - Error: too much time elapsed -binlog.binlog_innodb_stm : Added in 10.1.39 binlog.binlog_killed : MDEV-12925 - Wrong result -binlog.binlog_mysqlbinlog2 : Modified in 10.1.39 binlog.binlog_mysqlbinlog_stop_never : Added in 10.1.41 binlog.binlog_parallel_replication_marks_row : Include file modified in 10.1.41 binlog.binlog_parallel_replication_marks_stm_mix : Include file modified in 10.1.41 -binlog.binlog_row_drop_tmp_tbl : Include file modified in 10.1.41 -binlog.binlog_stm_drop_tmp_tbl : MDEV-20188 - Unknown table on exec; include file modified in 10.1.41 +binlog.binlog_row_drop_tmp_tbl : Include file modified in 10.1.42 +binlog.binlog_stm_drop_tmp_tbl : Include file modified in 10.1.42 binlog.binlog_xa_recover : MDEV-8517 - Extra checkpoint binlog.load_data_stm_view : MDEV-16948 - Wrong result #----------------------------------------------------------------------- -binlog_encryption.binlog_xa_recover : MDEV-12908 - Extra checkpoint -binlog_encryption.encrypted_master : MDEV-12906 - Failed to sync -binlog_encryption.rpl_parallel : MDEV-10653 - Timeout -binlog_encryption.rpl_relayrotate : MDEV-15194 - Timeout -binlog_encryption.rpl_semi_sync : MDEV-11220 - Wrong result, MDEV-11673 - Valgrind warning -binlog_encryption.rpl_ssl : MDEV-14507 - Timeout on SLES 11.4 -binlog_encryption.rpl_stm_relay_ign_space : MDEV-19375 - Test assertion failed in assertion.inc -binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL server during query +binlog_encryption.binlog_xa_recover : MDEV-12908 - Extra checkpoint +binlog_encryption.encrypted_master : MDEV-12906 - Failed to sync +binlog_encryption.rpl_parallel : MDEV-10653 - Timeout +binlog_encryption.rpl_parallel_ignored_errors : Added in 10.1.42 +binlog_encryption.rpl_relayrotate : MDEV-15194 - Timeout +binlog_encryption.rpl_semi_sync : MDEV-11220 - Wrong result, MDEV-11673 - Valgrind warning +binlog_encryption.rpl_ssl : MDEV-14507 - Timeout on SLES 11.4 +binlog_encryption.rpl_stm_relay_ign_space : MDEV-19375 - Test assertion failed in assertion.inc +binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL server during query #----------------------------------------------------------------------- @@ -216,7 +175,6 @@ encryption.encrypt_and_grep : MDEV-13765 - Wrong result encryption.innodb-bad-key-change2 : MDEV-19118 - Can't connect through socket encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate -encryption.innodb-encryption-alter : Modified in 10.1.39 encryption.innodb-first-page-read : MDEV-14356 - Timeout on wait condition encryption.innodb-page_encryption : MDEV-10641 - mutex problem encryption.innodb-read-only : MDEV-14728 - Unable to get certificate; MDEV-16563 - Crash on startup @@ -224,6 +182,7 @@ encryption.innodb-remove-encryption : MDEV-16493 - Timeout in wait condition encryption.innodb_encryption-page-compression : MDEV-12630 - crash or assertion failure encryption.innodb_encryption_discard_import : MDEV-16116 - Wrong result +encryption.innodb_encryption_is : MDEV-12898 - Server hang on startup encryption.innodb_encryption_row_compressed : MDEV-16113 - Crash encryption.innodb_first_page : MDEV-10689 - Crash encryption.innodb_scrub : MDEV-8139 - scrubbing tests need fixing @@ -253,11 +212,9 @@ #----------------------------------------------------------------------- -funcs_1.memory_views : MDEV-11773 - timeout -funcs_1.processlist_priv_no_prot : Include file modified in 10.1.39 -funcs_1.processlist_priv_ps : Include file modified in 10.1.39 -funcs_1.processlist_val_no_prot : MDEV-11223 - Wrong result; include file modified in 10.1.39 -funcs_1.processlist_val_ps : MDEV-12175 - Wrong plan; include file modified in 10.1.39 +funcs_1.memory_views : MDEV-11773 - timeout +funcs_1.processlist_val_no_prot : MDEV-11223 - Wrong result +funcs_1.processlist_val_ps : MDEV-12175 - Wrong plan #----------------------------------------------------------------------- @@ -278,29 +235,23 @@ #----------------------------------------------------------------------- -innodb.alter_crash : Added in 10.1.39 innodb.binlog_consistent : MDEV-10618 - Server fails to start innodb.check_ibd_filesize : Added in 10.1.41 innodb.create_select : Added in 10.1.41 innodb.doublewrite : MDEV-12905 - Lost connection to MySQL server innodb.foreign-keys : Modified in 10.1.41 -innodb.foreign_key : Modified in 10.1.39 innodb.group_commit_crash : MDEV-11770 - Checksum mismatch innodb.group_commit_crash_no_optimize_thread : MDEV-11770 - Checksum mismatch innodb.innodb-64k-crash : MDEV-13872 - Failure and crash on startup innodb.innodb-alter-debug : MDEV-13182 - InnoDB: adjusting FSP_SPACE_FLAGS -innodb.innodb-alter-nullable : Modified in 10.1.39 innodb.innodb-alter-table : MDEV-10619 - Testcase timeout -innodb.innodb-autoinc : Modified in 10.1.41 +innodb.innodb-autoinc : Modified in 10.1.42 innodb.innodb-blob : MDEV-12053 - Client crash -innodb.innodb-corrupted-table : Modified in 10.1.39 innodb.innodb-fk : MDEV-13832 - Assertion failure on shutdown -innodb.innodb-index : Modified in 10.1.39 innodb.innodb-page_compression_default : MDEV-14121 - Assertion failure innodb.innodb-page_compression_lzma : MDEV-14353 - Wrong result on Fedora 25 innodb.innodb-page_compression_zip : MDEV-10641 - Mutex problem innodb.innodb-system-table-view : Added in 10.1.41 -innodb.innodb-truncate : Modified in 10.1.39 innodb.innodb-wl5980-debug : Added in 10.1.41 innodb.innodb_bug14147491 : MDEV-11808 - Wrong error codes innodb.innodb_bug30423 : MDEV-7311 - Wrong number of rows in the plan @@ -314,15 +265,18 @@ innodb.log_file_size : MDEV-15668 - Not found pattern innodb.recovery_shutdown : MDEV-15671 - Warning: database page corruption innodb.row_format_redundant : MDEV-15192 - Trying to access missing tablespace +innodb.stat_tables : Added in 10.1.42 innodb.table_definition_cache_debug : MDEV-14206 - Extra warning innodb.table_flags : MDEV-19374 - Server failed to restart -innodb.trx_id_future : MDEV-20138 - Table doesn't exist in engine; added in 10.1.41 -innodb.xa_debug : Added in 10.1.39 +innodb.trx_id_future : Modified in 10.1.42 innodb.xa_recovery : MDEV-15279 - mysqld got exception #----------------------------------------------------------------------- +innodb_fts.concurrent_insert : Modified in 10.1.42 +innodb_fts.crash_recovery : Modified in 10.1.42 innodb_fts.innodb_ft_aux_table : Added in 10.1.41 +innodb_fts.innodb_fts_misc : Modified in 10.1.42 innodb_fts.innodb_fts_misc_debug : MDEV-14156 - Unexpected warning #----------------------------------------------------------------------- @@ -333,12 +287,10 @@ #----------------------------------------------------------------------- -mariabackup.absolute_ibdata_paths : Modified in 10.1.39 mariabackup.apply-log-only : MDEV-20135 - Timeout mariabackup.huge_lsn : MDEV-17286 - SSL error mariabackup.incremental_encrypted : MDEV-15667 - Timeout mariabackup.mdev-14447 : MDEV-15201 - Timeout -mariabackup.page_compression_level : Added in 10.1.39 mariabackup.xb_compressed_encrypted : MDEV-14812 - Segfault mariabackup.xb_partition : MDEV-17584 - Crash on shutdown @@ -372,9 +324,12 @@ parts.partition_alter2_2_maria : MDEV-14364 - Lost connection to MySQL server during query parts.partition_auto_increment_archive : MDEV-16491 - Table marked as crashed parts.partition_auto_increment_maria : MDEV-14430 - Wrong result -parts.partition_auto_increment_max : Added in 10.1.39 +parts.partition_debug : Modified in 10.1.42 +parts.partition_debug_innodb : Modified in 10.1.42 +parts.partition_debug_myisam : Modified in 10.1.42 parts.partition_exch_qa_10 : MDEV-11765 - wrong result parts.partition_innodb_status_file : MDEV-12901 - Valgrind +parts.reorganize_partition_innodb : Added in 10.1.42 #----------------------------------------------------------------------- @@ -397,25 +352,23 @@ #----------------------------------------------------------------------- plugins.feedback_plugin_send : MDEV-7932 - ssl failed for url -plugins.pam : Modified in 10.1.39 plugins.server_audit : MDEV-9562 - crashes on sol10-sparc plugins.thread_pool_server_audit : MDEV-9562 - crashes on sol10-sparc #----------------------------------------------------------------------- roles.create_and_grant_role : MDEV-11772 - wrong result -roles.flush_roles-17898 : Modified in 10.1.39 #----------------------------------------------------------------------- rpl.circular_serverid0 : MDEV-19372 - ASAN heap-use-after-free -rpl.create_or_replace_mix : Include file modified in 10.1.41 +rpl.create_or_replace_mix : MDEV-20523 - Wrong result; include file modified in 10.1.41 rpl.create_or_replace_row : Include file modified in 10.1.41 -rpl.create_or_replace_statement : Include file modified in 10.1.41 +rpl.create_or_replace_statement : MDEV-20523 - Wrong result; include file modified in 10.1.41 rpl.create_select : MDEV-14121 - Assertion failure rpl.kill_race_condition : Modified in 10.1.41 rpl.last_insert_id : MDEV-10625 - warnings in error log -rpl.mdev_17588 : MDEV-20137 - Table doesn't exist; added in 10.1.41 +rpl.mdev_17588 : Modified in 10.1.42 rpl.rpl_auto_increment : MDEV-10417 - Fails on Mips rpl.rpl_auto_increment_bug45679 : MDEV-10417 - Fails on Mips rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log @@ -423,6 +376,7 @@ rpl.rpl_blackhole : Modified in 10.1.41 rpl.rpl_blackhole_row_annotate : Added in 10.1.41 rpl.rpl_colSize : MDEV-16112 - Server crash +rpl.rpl_create_or_replace_fail : Added in 10.1.42 rpl.rpl_ddl : MDEV-10417 - Fails on Mips rpl.rpl_domain_id_filter_io_crash : MDEV-14357 - Wrong result rpl.rpl_domain_id_filter_master_crash : MDEV-19043 - Warnings/errors @@ -443,14 +397,17 @@ rpl.rpl_insert_id_pk : MDEV-16567 - Assertion failure rpl.rpl_insert_ignore : MDEV-14365 - Lost connection to MySQL server during query rpl.rpl_invoked_features : MDEV-10417 - Fails on Mips +rpl.rpl_known_bugs_detection : Modified in 10.1.42 rpl.rpl_mariadb_slave_capability : MDEV-11018 - sporadic wrong events in binlog rpl.rpl_mdev12179 : MDEV-19043 - Warnings/errors rpl.rpl_mdev6020 : MDEV-10417 - Fails on Mips +rpl.rpl_mdev_17614 : Added in 10.1.42 rpl.rpl_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_non_direct_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_non_direct_row_mixing_engines : MDEV-16561 - Timeout in master pos wait rpl.rpl_non_direct_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_parallel : MDEV-10653 - Timeouts +rpl.rpl_parallel_ignored_errors : Added in 10.1.42 rpl.rpl_parallel_mdev6589 : MDEV-12979 - Assertion failure rpl.rpl_parallel_multilevel2 : MDEV-14723 - Timeout rpl.rpl_parallel_optimistic : MDEV-10511 - Timeout @@ -458,7 +415,6 @@ rpl.rpl_parallel_temptable : MDEV-10356 - Crash in close_thread_tables rpl.rpl_partition_innodb : MDEV-10417 - Fails on Mips rpl.rpl_password_boundaries : MDEV-11534 - Slave IO warnings -rpl.rpl_rewrt_db : Modified in 10.1.39 rpl.rpl_row_basic_11bugs : MDEV-12171 - Server failed to start rpl.rpl_row_basic_2myisam : MDEV-13875 - command "diff_files" failed rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result @@ -479,15 +435,17 @@ rpl.rpl_show_slave_hosts : MDEV-10681 - server startup problem rpl.rpl_skip_replication : MDEV-9268 - Fails with timeout in sync_slave_with_master on Alpha rpl.rpl_slave_grp_exec : MDEV-10514 - Unexpected deadlock -rpl.rpl_slave_invalid_external_user : Added in 10.1.39 rpl.rpl_start_stop_slave : MDEV-13567 - Replication failure rpl.rpl_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_stm_relay_ign_space : MDEV-14360 - Test assertion rpl.rpl_sync : MDEV-10633 - Database page corruption +rpl.rpl_sync_with_innodb_thd_conc : Added in 10.1.42 rpl.rpl_temporary_error2 : MDEV-10634 - Wrong number of retries rpl.rpl_test_framework : MDEV-19368 - mysqltest failed but provided no output rpl.rpl_trigger : MDEV-18055 - Wrong result rpl.rpl_truncate_3innodb : MDEV-19454 - Syntax error in test +rpl.rpl_unsafe_statements : Modified in 10.1.42 +rpl.rpl_user_variables : MDEV-20522 - Wrong result rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result #----------------------------------------------------------------------- @@ -531,16 +489,14 @@ #----------------------------------------------------------------------- -sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x -sys_vars.delayed_insert_limit_func : MDEV-17683 - Wrong result -sys_vars.innodb_ft_result_cache_limit_32 : Modified in 10.1.41 -sys_vars.keep_files_on_create_basic : MDEV-10676 - timeout -sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash -sys_vars.rpl_init_slave_func : MDEV-10149 - wrong results -sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result -sys_vars.thread_stack_basic : Modified in 10.1.39 -sys_vars.transaction_prealloc_size_bug27322 : Modified in 10.1.39 -sys_vars.wait_timeout_func : MDEV-12896 - Wrong result +sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x +sys_vars.delayed_insert_limit_func : Modified in 10.1.42 +sys_vars.innodb_ft_result_cache_limit_32 : Modified in 10.1.41 +sys_vars.keep_files_on_create_basic : MDEV-10676 - timeout +sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash +sys_vars.rpl_init_slave_func : MDEV-10149 - wrong results +sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result +sys_vars.wait_timeout_func : MDEV-12896 - Wrong result #----------------------------------------------------------------------- @@ -569,8 +525,6 @@ #----------------------------------------------------------------------- -tokudb_bugs.PS-5158 : Added in 10.1.39 -tokudb_bugs.PS-5163 : Added in 10.1.39 tokudb_bugs.checkpoint_lock : MDEV-10637 - Wrong processlist output tokudb_bugs.checkpoint_lock_3 : MDEV-10637 - Wrong processlist output tokudb_bugs.frm_store : MDEV-12823 - Valgrind @@ -580,6 +534,10 @@ #----------------------------------------------------------------------- +tokudb_parts.partition_debug_tokudb : Include file modified in 10.1.42 + +#----------------------------------------------------------------------- + tokudb_rpl.* : MDEV-11001 - tests don't work #----------------------------------------------------------------------- @@ -597,14 +555,14 @@ vcol.not_supported : MDEV-10639 - Testcase timeout vcol.vcol_keys_innodb : MDEV-10639 - Testcase timeout vcol.vcol_misc : MDEV-16651 - Wrong error message -vcol.wrong_arena : Modified in 10.1.39 #----------------------------------------------------------------------- -wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node -wsrep.mdev_6832 : MDEV-14195 - Failure upon check-testcase -wsrep.pool_of_threads : MDEV-17345 - WSREP has not yet prepared node for application use -wsrep.variables : MDEV-17585 - Deadlock +wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node +wsrep.mdev_6832 : MDEV-14195 - Failure upon check-testcase +wsrep.mysql_tzinfo_to_sql_symlink_skip : Added in 10.1.42 +wsrep.pool_of_threads : MDEV-17345 - WSREP has not yet prepared node for application use +wsrep.variables : MDEV-17585 - Deadlock #----------------------------------------------------------------------- diff -Nru mariadb-10.1-10.1.41/scripts/mysqlaccess.sh mariadb-10.1-10.1.43/scripts/mysqlaccess.sh --- mariadb-10.1-10.1.41/scripts/mysqlaccess.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/mysqlaccess.sh 2019-11-06 06:20:36.000000000 +0000 @@ -26,7 +26,7 @@ BEGIN { # **************************** # static information... - $VERSION = "2.06, 20 Dec 2000"; + $VERSION = "2.10, 13 Sep 2019"; $0 =~ m%/([^/]+)$%o; $script = $1; $script = 'MySQLAccess' unless $script; diff -Nru mariadb-10.1-10.1.41/scripts/mysqld_multi.sh mariadb-10.1-10.1.43/scripts/mysqld_multi.sh --- mariadb-10.1-10.1.41/scripts/mysqld_multi.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/mysqld_multi.sh 2019-11-06 06:20:36.000000000 +0000 @@ -308,7 +308,9 @@ sub start_mysqlds() { - my (@groups, $com, $tmp, $i, @options, $j, $mysqld_found, $info_sent); + my (@groups, $com, $tmp, $i, @options, $j, $mysqld_found, $suffix_found, $info_sent); + + $suffix_found= 0; if (!$opt_no_log) { @@ -347,6 +349,10 @@ $options[$j]= quote_shell_word($options[$j]); $tmp.= " $options[$j]"; } + elsif ("--defaults-group-suffix=" eq substr($options[$j], 0, 24)) + { + $suffix_found= 1; + } else { $options[$j]= quote_shell_word($options[$j]); @@ -362,6 +368,13 @@ print "wanted mysqld binary.\n\n"; $info_sent= 1; } + + if (!$suffix_found) + { + $com.= " --defaults-group-suffix="; + $com.= substr($groups[$i],6); + } + $com.= $tmp; if ($opt_wsrep_new_cluster) { diff -Nru mariadb-10.1-10.1.41/scripts/mysqld_safe.sh mariadb-10.1-10.1.43/scripts/mysqld_safe.sh --- mariadb-10.1-10.1.41/scripts/mysqld_safe.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/mysqld_safe.sh 2019-11-06 06:20:36.000000000 +0000 @@ -23,6 +23,7 @@ unsafe_my_cnf=0 wsrep_on=0 dry_run=0 +defaults_group_suffix= # Initial logging status: error log is not open, and not using syslog logging=init @@ -378,6 +379,8 @@ append_arg_to_args "$arg" ;; + --defaults-group-suffix=*) defaults_group_suffix="$arg" ;; + --help) usage ;; *) @@ -964,13 +967,19 @@ exit 1 fi -for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ +for i in "$ledir/$MYSQLD" "$defaults_group_suffix" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ "--datadir=$DATADIR" "--plugin-dir=$plugin_dir" "$USER_OPTION" do cmd="$cmd "`shell_quote_string "$i"` done cmd="$cmd $args" -[ $dry_run -eq 1 ] && return + +if [ $dry_run -eq 1 ] +then + # RETURN or EXIT depending if the script is being sourced or not. + (return 2> /dev/null) && return || exit +fi + # Avoid 'nohup: ignoring input' warning test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null" diff -Nru mariadb-10.1-10.1.41/scripts/wsrep_sst_common.sh mariadb-10.1-10.1.43/scripts/wsrep_sst_common.sh --- mariadb-10.1-10.1.41/scripts/wsrep_sst_common.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/wsrep_sst_common.sh 2019-11-06 06:20:36.000000000 +0000 @@ -28,7 +28,12 @@ WSREP_SST_OPT_DEFAULT="" WSREP_SST_OPT_EXTRA_DEFAULT="" WSREP_SST_OPT_SUFFIX_DEFAULT="" +WSREP_SST_OPT_SUFFIX_VALUE="" +WSREP_SST_OPT_MYSQLD="" INNODB_DATA_HOME_DIR_ARG="" +INNODB_LOG_GROUP_HOME_ARG="" +INNODB_UNDO_DIR_ARG="" +LOG_BIN_ARG="" while [ $# -gt 0 ]; do case "$1" in @@ -83,6 +88,18 @@ readonly INNODB_DATA_HOME_DIR_ARG="$2" shift ;; + '--innodb-log-group-home-dir') + readonly INNODB_LOG_GROUP_HOME_ARG="$2" + shift + ;; + '--innodb-undo-directory') + readonly INNODB_UNDO_DIR_ARG="$2" + shift + ;; + '--log-bin') + readonly LOG_BIN_ARG="$2" + shift + ;; '--defaults-file') readonly WSREP_SST_OPT_DEFAULT="$1=$2" shift @@ -93,6 +110,7 @@ ;; '--defaults-group-suffix') readonly WSREP_SST_OPT_SUFFIX_DEFAULT="$1=$2" + readonly WSREP_SST_OPT_SUFFIX_VALUE="$2" shift ;; '--host') @@ -143,6 +161,50 @@ readonly WSREP_SST_OPT_GTID_DOMAIN_ID="$2" shift ;; + '--mysqld-args') + original_cmd="" + shift + while [ $# -gt 0 ]; do + option=${1%%=*} + if [[ "$option" != "--defaults-file" && \ + "$option" != "--defaults-extra-file" && \ + "$option" != "--defaults-group-suffix" && \ + "$option" != "--port" && \ + "$option" != "--socket" ]]; then + value=${1#*=} + case "$option" in + '--innodb-data-home-dir') + if [ -z "$INNODB_DATA_HOME_DIR_ARG" ]; then + readonly INNODB_DATA_HOME_DIR_ARG="$value" + fi + ;; + '--innodb-log-group-home-dir') + if [ -z "$INNODB_LOG_GROUP_HOME_ARG" ]; then + readonly INNODB_LOG_GROUP_HOME_ARG="$value" + fi + ;; + '--innodb-undo-directory') + if [ -z "$INNODB_UNDO_DIR_ARG" ]; then + readonly INNODB_UNDO_DIR_ARG="$value" + fi + ;; + '--log-bin') + if [ -z "$LOG_BIN_ARG" ]; then + readonly LOG_BIN_ARG="$value" + fi + ;; + esac + if [ -z "$original_cmd" ]; then + original_cmd="$1" + else + original_cmd="$original_cmd $1" + fi + fi + shift + done + readonly WSREP_SST_OPT_MYSQLD="$original_cmd" + break + ;; *) # must be command # usage # exit 1 @@ -191,7 +253,15 @@ MY_PRINT_DEFAULTS=$(which my_print_defaults) fi -readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT $WSREP_SST_OPT_SUFFIX_DEFAULT" +wsrep_defaults="$WSREP_SST_OPT_DEFAULT" +if [ -n "$wsrep_defaults" ]; then + wsrep_defaults="$wsrep_defaults " +fi +wsrep_defaults="$wsrep_defaults$WSREP_SST_OPT_EXTRA_DEFAULT" +if [ -n "$wsrep_defaults" ]; then + wsrep_defaults="$wsrep_defaults " +fi +readonly WSREP_SST_OPT_CONF="$wsrep_defaults$WSREP_SST_OPT_SUFFIX_DEFAULT" readonly MY_PRINT_DEFAULTS="$MY_PRINT_DEFAULTS $WSREP_SST_OPT_CONF" wsrep_auth_not_set() diff -Nru mariadb-10.1-10.1.41/scripts/wsrep_sst_mariabackup.sh mariadb-10.1-10.1.43/scripts/wsrep_sst_mariabackup.sh --- mariadb-10.1-10.1.41/scripts/wsrep_sst_mariabackup.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/wsrep_sst_mariabackup.sh 2019-11-06 06:20:36.000000000 +0000 @@ -60,7 +60,7 @@ rebuildcmd="" payload=0 pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " -pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " +pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " STATDIR="" uextra=0 disver="" @@ -130,7 +130,7 @@ if [[ $encrypt -eq 0 ]];then if $MY_PRINT_DEFAULTS xtrabackup | grep -q encrypt;then - wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html " + wsrep_log_error "Unexpected option combination. SST may fail. Refer to http://www.percona.com/doc/percona-xtradb-cluster/manual/xtrabackup_sst.html" fi return fi @@ -465,7 +465,7 @@ if [[ -n ${XTRABACKUP_PID:-} ]];then if check_pid $XTRABACKUP_PID then - wsrep_log_error "xtrabackup process is still running. Killing... " + wsrep_log_error "xtrabackup process is still running. Killing..." kill_xtrabackup fi @@ -567,7 +567,7 @@ # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. wsrep_log_info "SST through extra_port $eport" - INNOEXTRA+=" --host=127.0.0.1 --port=$eport " + INNOEXTRA+=" --host=127.0.0.1 --port=$eport" use_socket=0 else wsrep_log_error "Extra port $eport null, failing" @@ -577,8 +577,8 @@ wsrep_log_info "Thread pool not set, ignore the option use_extra" fi fi - if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then - INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}" + if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then + INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET" fi } @@ -699,8 +699,7 @@ iopts+=" --no-backup-locks " fi - -INNOEXTRA="" +INNOEXTRA=$WSREP_SST_OPT_MYSQLD INNODB_DATA_HOME_DIR=${INNODB_DATA_HOME_DIR:-""} # Try to set INNODB_DATA_HOME_DIR from the command line: @@ -709,6 +708,9 @@ fi # if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf if [ -z "$INNODB_DATA_HOME_DIR" ]; then + INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '') +fi +if [ -z "$INNODB_DATA_HOME_DIR" ]; then INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '') fi if [ ! -z "$INNODB_DATA_HOME_DIR" ]; then @@ -743,8 +745,8 @@ logger -p daemon.info -t ${ssystag}wsrep-sst-$WSREP_SST_OPT_ROLE "$@" } - INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply " - INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move " + INNOAPPLY="${INNOBACKUPEX_BIN} --innobackupex $disver $iapts \$INNOEXTRA --apply-log \$rebuildcmd \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-apply" + INNOMOVE="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $impts --move-back --force-non-empty-directories \${DATA} 2>&1 | logger -p daemon.err -t ${ssystag}innobackupex-move" INNOBACKUP="${INNOBACKUPEX_BIN} --innobackupex ${WSREP_SST_OPT_CONF} $disver $iopts \$tmpopts \$INNOEXTRA --galera-info --stream=\$sfmt \$itmpdir 2> >(logger -p daemon.err -t ${ssystag}innobackupex-backup)" fi @@ -828,9 +830,11 @@ exit 93 fi - if [[ -z $(parse_cnf --mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then + if [[ -z $(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE tmpdir "") && \ + -z $(parse_cnf --mysqld tmpdir "") && \ + -z $(parse_cnf xtrabackup tmpdir "") ]]; then xtmpdir=$(mktemp -d) - tmpopts=" --tmpdir=$xtmpdir " + tmpopts=" --tmpdir=$xtmpdir" wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory" fi @@ -852,13 +856,12 @@ get_keys if [[ $encrypt -eq 1 ]];then if [[ -n $ekey ]];then - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey " + INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey" else - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile " + INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile" fi fi - check_extra wsrep_log_info "Streaming GTID file before SST" @@ -879,7 +882,6 @@ tcmd=" $scomp | $tcmd " fi - send_donor $DATA "${stagemsg}-gtid" tcmd="$ttcmd" @@ -951,8 +953,24 @@ [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE ib_home_dir=$INNODB_DATA_HOME_DIR - ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "") - ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "") + + # Try to set ib_log_dir from the command line: + ib_log_dir=$INNODB_LOG_GROUP_HOME_ARG + if [ -z "$ib_log_dir" ]; then + ib_log_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir "") + fi + if [ -z "$ib_log_dir" ]; then + ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "") + fi + + # Try to set ib_undo_dir from the command line: + ib_undo_dir=$INNODB_UNDO_DIR_ARG + if [ -z "$ib_undo_dir" ]; then + ib_undo_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-undo-directory "") + fi + if [ -z "$ib_undo_dir" ]; then + ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "") + fi stagemsg="Joiner-Recv" @@ -1029,7 +1047,13 @@ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+ fi - tempdir=$(parse_cnf --mysqld log-bin "") + tempdir=$LOG_BIN_ARG + if [ -z "$tempdir" ]; then + tempdir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE log-bin "") + fi + if [ -z "$tempdir" ]; then + tempdir=$(parse_cnf --mysqld log-bin "") + fi if [[ -n ${tempdir:-} ]];then binlog_dir=$(dirname $tempdir) binlog_file=$(basename $tempdir) diff -Nru mariadb-10.1-10.1.41/scripts/wsrep_sst_rsync.sh mariadb-10.1-10.1.43/scripts/wsrep_sst_rsync.sh --- mariadb-10.1-10.1.41/scripts/wsrep_sst_rsync.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/wsrep_sst_rsync.sh 2019-11-06 06:20:36.000000000 +0000 @@ -23,7 +23,7 @@ RSYNC_REAL_PID= # rsync process id OS=$(uname) -[ "$OS" == "Darwin" ] && export -n LD_LIBRARY_PATH +[ "$OS" = "Darwin" ] && export -n LD_LIBRARY_PATH # Setting the path for lsof on CentOS export PATH="/usr/sbin:/sbin:$PATH" @@ -69,11 +69,6 @@ exit 2 # ENOENT fi - if ! which lsof > /dev/null; then - wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed." - exit 2 # ENOENT - fi - local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \ grep "(LISTEN)") local is_rsync=$(echo $port_info | \ @@ -116,8 +111,15 @@ fi WSREP_LOG_DIR=${WSREP_LOG_DIR:-""} +# Try to set WSREP_LOG_DIR from the command line: +if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$INNODB_LOG_GROUP_HOME_ARG +fi # if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf if [ -z "$WSREP_LOG_DIR" ]; then + WSREP_LOG_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir '') +fi +if [ -z "$WSREP_LOG_DIR" ]; then WSREP_LOG_DIR=$(parse_cnf --mysqld innodb-log-group-home-dir '') fi @@ -136,6 +138,9 @@ fi # if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf if [ -z "$INNODB_DATA_HOME_DIR" ]; then + INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '') +fi +if [ -z "$INNODB_DATA_HOME_DIR" ]; then INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '') fi @@ -308,8 +313,8 @@ cd $WSREP_SST_OPT_DATA count=1 - [ "$OS" == "Linux" ] && count=$(grep -c processor /proc/cpuinfo) - [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ] && count=$(sysctl -n hw.ncpu) + [ "$OS" = "Linux" ] && count=$(grep -c processor /proc/cpuinfo) + [ "$OS" = "Darwin" -o "$OS" = "FreeBSD" ] && count=$(sysctl -n hw.ncpu) find . -maxdepth 1 -mindepth 1 -type d -not -name "lost+found" \ -print0 | xargs -I{} -0 -P $count \ @@ -429,7 +434,7 @@ RSYNC_PID=$STUNNEL_PID fi - until check_pid_and_port $RSYNC_PID $RSYNC_REAL_PID $RSYNC_PORT + until check_pid_and_port "$RSYNC_PID" "$RSYNC_REAL_PID" "$RSYNC_PORT" do sleep 0.2 done diff -Nru mariadb-10.1-10.1.41/scripts/wsrep_sst_xtrabackup.sh mariadb-10.1-10.1.43/scripts/wsrep_sst_xtrabackup.sh --- mariadb-10.1-10.1.41/scripts/wsrep_sst_xtrabackup.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/wsrep_sst_xtrabackup.sh 2019-11-06 06:20:36.000000000 +0000 @@ -49,7 +49,7 @@ rebuildcmd="" payload=0 pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " -pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " +pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " uextra=0 if which pv &>/dev/null && pv --help | grep -q FORMAT;then @@ -380,7 +380,7 @@ # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. wsrep_log_info "SST through extra_port $eport" - INNOEXTRA+=" --host=127.0.0.1 --port=$eport " + INNOEXTRA+=" --host=127.0.0.1 --port=$eport" use_socket=0 else wsrep_log_error "Extra port $eport null, failing" @@ -390,8 +390,8 @@ wsrep_log_info "Thread pool not set, ignore the option use_extra" fi fi - if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then - INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}" + if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then + INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET" fi } @@ -439,14 +439,14 @@ get_keys if [[ $encrypt -eq 1 ]];then if [[ -n $ekey ]];then - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey " + INNOEXTRA+=" --encrypt=$ealgo --encrypt-key=$ekey" else - INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile " + INNOEXTRA+=" --encrypt=$ealgo --encrypt-key-file=$ekeyfile" fi fi if [[ -n $lsn ]];then - INNOEXTRA+=" --incremental --incremental-lsn=$lsn " + INNOEXTRA+=" --incremental --incremental-lsn=$lsn" fi check_extra diff -Nru mariadb-10.1-10.1.41/scripts/wsrep_sst_xtrabackup-v2.sh mariadb-10.1-10.1.43/scripts/wsrep_sst_xtrabackup-v2.sh --- mariadb-10.1-10.1.41/scripts/wsrep_sst_xtrabackup-v2.sh 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/scripts/wsrep_sst_xtrabackup-v2.sh 2019-11-06 06:20:36.000000000 +0000 @@ -56,7 +56,7 @@ rebuildcmd="" payload=0 pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' " -pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " +pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE " STATDIR="" uextra=0 disver="" @@ -675,7 +675,7 @@ # Xtrabackup works only locally. # Hence, setting host to 127.0.0.1 unconditionally. wsrep_log_info "SST through extra_port $eport" - INNOEXTRA+=" --host=127.0.0.1 --port=$eport " + INNOEXTRA+=" --host=127.0.0.1 --port=$eport" use_socket=0 else wsrep_log_error "Extra port $eport null, failing" @@ -685,8 +685,8 @@ wsrep_log_info "Thread pool not set, ignore the option use_extra" fi fi - if [[ $use_socket -eq 1 ]] && [[ -n "${WSREP_SST_OPT_SOCKET}" ]];then - INNOEXTRA+=" --socket=${WSREP_SST_OPT_SOCKET}" + if [[ $use_socket -eq 1 ]] && [[ -n "$WSREP_SST_OPT_SOCKET" ]];then + INNOEXTRA+=" --socket=$WSREP_SST_OPT_SOCKET" fi } @@ -906,7 +906,10 @@ fi # if INNODB_DATA_HOME_DIR env. variable is not set, try to get it from my.cnf if [ -z "$INNODB_DATA_HOME_DIR" ]; then - INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir "") + INNODB_DATA_HOME_DIR=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-data-home-dir '') +fi +if [ -z "$INNODB_DATA_HOME_DIR" ]; then + INNODB_DATA_HOME_DIR=$(parse_cnf --mysqld innodb-data-home-dir '') fi if [ ! -z "$INNODB_DATA_HOME_DIR" ]; then INNOEXTRA+=" --innodb-data-home-dir=$INNODB_DATA_HOME_DIR" @@ -937,9 +940,11 @@ exit 93 fi - if [[ -z $(parse_cnf --mysqld tmpdir "") && -z $(parse_cnf xtrabackup tmpdir "") ]];then + if [[ -z $(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE tmpdir "") && \ + -z $(parse_cnf --mysqld tmpdir "") && \ + -z $(parse_cnf xtrabackup tmpdir "") ]]; then xtmpdir=$(mktemp -d) - tmpopts=" --tmpdir=$xtmpdir " + tmpopts=" --tmpdir=$xtmpdir" wsrep_log_info "Using $xtmpdir as xtrabackup temporary directory" fi @@ -1057,8 +1062,24 @@ [[ -n $SST_PROGRESS_FILE ]] && touch $SST_PROGRESS_FILE ib_home_dir=$INNODB_DATA_HOME_DIR - ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "") - ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "") + + # Try to set ib_log_dir from the command line: + ib_log_dir=$INNODB_LOG_GROUP_HOME_ARG + if [ -z "$ib_log_dir" ]; then + ib_log_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-log-group-home-dir "") + fi + if [ -z "$ib_log_dir" ]; then + ib_log_dir=$(parse_cnf --mysqld innodb-log-group-home-dir "") + fi + + # Try to set ib_undo_dir from the command line: + ib_undo_dir=$INNODB_UNDO_DIR_ARG + if [ -z "$ib_undo_dir" ]; then + ib_undo_dir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE innodb-undo-directory "") + fi + if [ -z "$ib_undo_dir" ]; then + ib_undo_dir=$(parse_cnf --mysqld innodb-undo-directory "") + fi stagemsg="Joiner-Recv" @@ -1124,7 +1145,13 @@ find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+ fi - tempdir=$(parse_cnf --mysqld log-bin "") + tempdir=$LOG_BIN_ARG + if [ -z "$tempdir" ]; then + tempdir=$(parse_cnf mysqld$WSREP_SST_OPT_SUFFIX_VALUE log-bin "") + fi + if [ -z "$tempdir" ]; then + tempdir=$(parse_cnf --mysqld log-bin "") + fi if [[ -n ${tempdir:-} ]];then binlog_dir=$(dirname $tempdir) binlog_file=$(basename $tempdir) diff -Nru mariadb-10.1-10.1.41/sql/item.cc mariadb-10.1-10.1.43/sql/item.cc --- mariadb-10.1-10.1.41/sql/item.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/item.cc 2019-11-06 06:20:36.000000000 +0000 @@ -3131,6 +3131,20 @@ } +longlong Item_null::val_datetime_packed() +{ + null_value= true; + return 0; +} + + +longlong Item_null::val_time_packed() +{ + null_value= true; + return 0; +} + + bool Item_null::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) { // following assert is redundant, because fixed=1 assigned in constructor @@ -7296,6 +7310,24 @@ } +longlong Item_ref::val_datetime_packed() +{ + DBUG_ASSERT(fixed); + longlong tmp= (*ref)->val_datetime_packed(); + null_value= (*ref)->null_value; + return tmp; +} + + +longlong Item_ref::val_time_packed() +{ + DBUG_ASSERT(fixed); + longlong tmp= (*ref)->val_time_packed(); + null_value= (*ref)->null_value; + return tmp; +} + + my_decimal *Item_ref::val_decimal(my_decimal *decimal_value) { my_decimal *val= (*ref)->val_decimal_result(decimal_value); diff -Nru mariadb-10.1-10.1.41/sql/item_func.cc mariadb-10.1-10.1.43/sql/item_func.cc --- mariadb-10.1-10.1.41/sql/item_func.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/item_func.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1951,8 +1951,11 @@ void Item_func_mod::result_precision() { + unsigned_flag= args[0]->unsigned_flag; decimals= MY_MAX(args[0]->decimal_scale(), args[1]->decimal_scale()); - max_length= MY_MAX(args[0]->max_length, args[1]->max_length); + uint prec= MY_MAX(args[0]->decimal_precision(), args[1]->decimal_precision()); + fix_char_length(my_decimal_precision_to_length_no_truncation(prec, decimals, + unsigned_flag)); } @@ -1960,6 +1963,10 @@ { Item_num_op::fix_length_and_dec(); maybe_null= 1; + /* + result_precision() sets unsigned_flag for INT_RESULT and DECIMAL_RESULT. + Here we need to set it in case of REAL_RESULT. + */ unsigned_flag= args[0]->unsigned_flag; } diff -Nru mariadb-10.1-10.1.41/sql/item.h mariadb-10.1-10.1.43/sql/item.h --- mariadb-10.1-10.1.41/sql/item.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/item.h 2019-11-06 06:20:36.000000000 +0000 @@ -2,7 +2,7 @@ #define SQL_ITEM_INCLUDED /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB Corporation + Copyright (c) 2009, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -611,8 +611,6 @@ public Type_std_attributes, public Type_handler { - Item(const Item &); /* Prevent use of these */ - void operator=(Item &); /** The index in the JOIN::join_tab array of the JOIN_TAB this Item is attached to. Items are attached (or 'pushed') to JOIN_TABs during optimization by the @@ -650,7 +648,7 @@ /* Cache of the result of is_expensive(). */ int8 is_expensive_cache; - /* Reuse size, only used by SP local variable assignment, otherwize 0 */ + /* Reuse size, only used by SP local variable assignment, otherwise 0 */ uint rsize; protected: @@ -2627,6 +2625,8 @@ String *val_str(String *str); my_decimal *val_decimal(my_decimal *); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + longlong val_datetime_packed(); + longlong val_time_packed(); int save_in_field(Field *field, bool no_conversions); int save_safe_in_field(Field *field); bool send(Protocol *protocol, String *str); @@ -3971,6 +3971,8 @@ String *val_str(String* tmp); bool is_null(); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate); + longlong val_datetime_packed(); + longlong val_time_packed(); double val_result(); longlong val_int_result(); String *str_result(String* tmp); diff -Nru mariadb-10.1-10.1.41/sql/opt_range.cc mariadb-10.1-10.1.43/sql/opt_range.cc --- mariadb-10.1-10.1.41/sql/opt_range.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/opt_range.cc 2019-11-06 06:20:36.000000000 +0000 @@ -2420,12 +2420,16 @@ records= head->stat_records(); if (!records) records++; /* purecov: inspected */ - scan_time= (double) records / TIME_FOR_COMPARE + 1; - read_time= (double) head->file->scan_time() + scan_time + 1.1; - if (head->force_index) + + if (head->force_index || force_quick_range) scan_time= read_time= DBL_MAX; - if (limit < records) - read_time= (double) records + scan_time + 1; // Force to use index + else + { + scan_time= (double) records / TIME_FOR_COMPARE + 1; + read_time= (double) head->file->scan_time() + scan_time + 1.1; + if (limit < records) + read_time= (double) records + scan_time + 1; // Force to use index + } possible_keys.clear_all(); @@ -10179,6 +10183,16 @@ bufsize, mrr_flags, cost); if (rows != HA_POS_ERROR) { + ha_rows table_records= param->table->stat_records(); + if (rows > table_records) + { + /* + For any index the total number of records within all ranges + cannot be be bigger than the number of records in the table + */ + rows= table_records; + set_if_bigger(rows, 1); + } param->quick_rows[keynr]= rows; param->possible_keys.set_bit(keynr); if (update_tbl_stats) diff -Nru mariadb-10.1-10.1.41/sql/opt_subselect.cc mariadb-10.1-10.1.43/sql/opt_subselect.cc --- mariadb-10.1-10.1.41/sql/opt_subselect.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/opt_subselect.cc 2019-11-06 06:20:36.000000000 +0000 @@ -2657,9 +2657,17 @@ { do /* For all equalities on all key parts */ { - /* Check if this is "t.keypart = expr(outer_tables) */ + /* + Check if this is "t.keypart = expr(outer_tables) + + Don't allow variants that can produce duplicates: + - Dont allow "ref or null" + - the keyuse (that is, the operation) must be null-rejecting, + unless the other expression is non-NULLable. + */ if (!(keyuse->used_tables & sj_inner_tables) && - !(keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL)) + !(keyuse->optimize & KEY_OPTIMIZE_REF_OR_NULL) && + (keyuse->null_rejecting || !keyuse->val->maybe_null)) { bound_parts |= 1 << keyuse->keypart; } diff -Nru mariadb-10.1-10.1.41/sql/rpl_parallel.cc mariadb-10.1-10.1.43/sql/rpl_parallel.cc --- mariadb-10.1-10.1.41/sql/rpl_parallel.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/rpl_parallel.cc 2019-11-06 06:20:36.000000000 +0000 @@ -228,6 +228,12 @@ entry->stop_on_error_sub_id == (uint64)ULONGLONG_MAX) entry->stop_on_error_sub_id= sub_id; mysql_mutex_unlock(&entry->LOCK_parallel_entry); + DBUG_EXECUTE_IF("hold_worker_on_schedule", { + if (entry->stop_on_error_sub_id < (uint64)ULONGLONG_MAX) + { + debug_sync_set_action(thd, STRING_WITH_LEN("now SIGNAL continue_worker")); + } + }); if (rgi->killed_for_retry == rpl_group_info::RETRY_KILL_PENDING) wait_for_pending_deadlock_kill(thd, rgi); @@ -1096,6 +1102,13 @@ bool did_enter_cond= false; PSI_stage_info old_stage; + DBUG_EXECUTE_IF("hold_worker_on_schedule", { + if (rgi->current_gtid.domain_id == 0 && + rgi->current_gtid.seq_no == 100) { + debug_sync_set_action(thd, + STRING_WITH_LEN("now SIGNAL reached_pause WAIT_FOR continue_worker")); + } + }); DBUG_EXECUTE_IF("rpl_parallel_scheduled_gtid_0_x_100", { if (rgi->current_gtid.domain_id == 0 && rgi->current_gtid.seq_no == 100) { @@ -1137,7 +1150,10 @@ skip_event_group= do_gco_wait(rgi, gco, &did_enter_cond, &old_stage); if (unlikely(entry->stop_on_error_sub_id <= rgi->wait_commit_sub_id)) + { skip_event_group= true; + rgi->worker_error= 1; + } if (likely(!skip_event_group)) do_ftwrl_wait(rgi, &did_enter_cond, &old_stage); diff -Nru mariadb-10.1-10.1.41/sql/share/errmsg-utf8.txt mariadb-10.1-10.1.43/sql/share/errmsg-utf8.txt --- mariadb-10.1-10.1.41/sql/share/errmsg-utf8.txt 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/share/errmsg-utf8.txt 2019-11-06 06:20:36.000000000 +0000 @@ -7142,3 +7142,5 @@ ER_WARN_AGGFUNC_DEPENDENCE eng "Aggregate function '%-.192s)' of SELECT #%d belongs to SELECT #%d" ukr "Агрегатна функція '%-.192s)' з SELECTу #%d належить до SELECTу #%d" +WARN_INNODB_PARTITION_OPTION_IGNORED + eng "<%-.64s> option ignored for InnoDB partition" diff -Nru mariadb-10.1-10.1.41/sql/sql_base.cc mariadb-10.1-10.1.43/sql/sql_base.cc --- mariadb-10.1-10.1.41/sql/sql_base.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_base.cc 2019-11-06 06:20:36.000000000 +0000 @@ -4245,32 +4245,6 @@ goto end; } - if (get_use_stat_tables_mode(thd) > NEVER && tables->table) - { - TABLE_SHARE *table_share= tables->table->s; - if (table_share && table_share->table_category == TABLE_CATEGORY_USER && - table_share->tmp_table == NO_TMP_TABLE) - { - if (table_share->stats_cb.stats_can_be_read || - !alloc_statistics_for_table_share(thd, table_share, FALSE)) - { - if (table_share->stats_cb.stats_can_be_read) - { - KEY *key_info= table_share->key_info; - KEY *key_info_end= key_info + table_share->keys; - KEY *table_key_info= tables->table->key_info; - for ( ; key_info < key_info_end; key_info++, table_key_info++) - table_key_info->read_stats= key_info->read_stats; - Field **field_ptr= table_share->field; - Field **table_field_ptr= tables->table->field; - for ( ; *field_ptr; field_ptr++, table_field_ptr++) - (*table_field_ptr)->read_stats= (*field_ptr)->read_stats; - tables->table->stats_is_read= table_share->stats_cb.stats_is_read; - } - } - } - } - process_view_routines: /* Again we may need cache all routines used by this view and add diff -Nru mariadb-10.1-10.1.41/sql/sql_class.cc mariadb-10.1-10.1.43/sql/sql_class.cc --- mariadb-10.1-10.1.41/sql/sql_class.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_class.cc 2019-11-06 06:20:36.000000000 +0000 @@ -986,7 +986,6 @@ memset(&invoker_host, 0, sizeof(invoker_host)); prepare_derived_at_open= FALSE; create_tmp_table_for_derived= FALSE; - force_read_stats= FALSE; save_prep_leaf_list= FALSE; /* Restore THR_THD */ set_current_thd(old_THR_THD); @@ -6144,6 +6143,48 @@ DBUG_RETURN(0); } +int THD::decide_logging_format_low(TABLE *table) +{ + /* + INSERT...ON DUPLICATE KEY UPDATE on a table with more than one unique keys + can be unsafe. + */ + if(wsrep_binlog_format() <= BINLOG_FORMAT_STMT && + !is_current_stmt_binlog_format_row() && + !lex->is_stmt_unsafe() && + lex->sql_command == SQLCOM_INSERT && + lex->duplicates == DUP_UPDATE) + { + uint unique_keys= 0; + uint keys= table->s->keys, i= 0; + Field *field; + for (KEY* keyinfo= table->s->key_info; + i < keys && unique_keys <= 1; i++, keyinfo++) + if (keyinfo->flags & HA_NOSAME && + !(keyinfo->key_part->field->flags & AUTO_INCREMENT_FLAG && + //User given auto inc can be unsafe + !keyinfo->key_part->field->val_int())) + { + for (uint j= 0; j < keyinfo->user_defined_key_parts; j++) + { + field= keyinfo->key_part[j].field; + if(!bitmap_is_set(table->write_set,field->field_index)) + goto exit; + } + unique_keys++; +exit:; + } + + if (unique_keys > 1) + { + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS); + binlog_unsafe_warning_flags|= lex->get_stmt_unsafe_flags(); + set_current_stmt_binlog_format_row_if_mixed(); + return 1; + } + } + return 0; +} /* Implementation of interface to write rows to the binary log through the diff -Nru mariadb-10.1-10.1.41/sql/sql_class.h mariadb-10.1-10.1.43/sql/sql_class.h --- mariadb-10.1-10.1.41/sql/sql_class.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_class.h 2019-11-06 06:20:36.000000000 +0000 @@ -1444,12 +1444,16 @@ /** @class Sub_statement_state @brief Used to save context when executing a function or trigger + + operations on stat tables aren't technically a sub-statement, but they are + similar in a sense that they cannot change the transaction status. */ /* Defines used for Sub_statement_state::in_sub_stmt */ #define SUB_STMT_TRIGGER 1 #define SUB_STMT_FUNCTION 2 +#define SUB_STMT_STAT_TABLES 4 class Sub_statement_state @@ -2200,14 +2204,25 @@ */ bool create_tmp_table_for_derived; - /* The flag to force reading statistics from EITS tables */ - bool force_read_stats; - bool save_prep_leaf_list; /* container for handler's private per-connection data */ Ha_data ha_data[MAX_HA]; + /** + Bit field for the state of binlog warnings. + + The first Lex::BINLOG_STMT_UNSAFE_COUNT bits list all types of + unsafeness that the current statement has. + + This must be a member of THD and not of LEX, because warnings are + detected and issued in different places (@c + decide_logging_format() and @c binlog_query(), respectively). + Between these calls, the THD->lex object may change; e.g., if a + stored routine is invoked. Only THD persists between the calls. + */ + uint32 binlog_unsafe_warning_flags; + #ifndef MYSQL_CLIENT binlog_cache_mngr * binlog_setup_trx_data(); @@ -2317,20 +2332,6 @@ */ enum_binlog_format current_stmt_binlog_format; - /** - Bit field for the state of binlog warnings. - - The first Lex::BINLOG_STMT_UNSAFE_COUNT bits list all types of - unsafeness that the current statement has. - - This must be a member of THD and not of LEX, because warnings are - detected and issued in different places (@c - decide_logging_format() and @c binlog_query(), respectively). - Between these calls, the THD->lex object may change; e.g., if a - stored routine is invoked. Only THD persists between the calls. - */ - uint32 binlog_unsafe_warning_flags; - /* Number of outstanding table maps, i.e., table maps in the transaction cache. @@ -3939,6 +3940,18 @@ } void leave_locked_tables_mode(); int decide_logging_format(TABLE_LIST *tables); + /* + In Some cases when decide_logging_format is called it does not have all + information to decide the logging format. So that cases we call decide_logging_format_2 + at later stages in execution. + One example would be binlog format for IODKU but column with unique key is not inserted. + We dont have inserted columns info when we call decide_logging_format so on later stage we call + decide_logging_format_low + + @returns 0 if no format is changed + 1 if there is change in binlog format + */ + int decide_logging_format_low(TABLE *table); enum need_invoker { INVOKER_NONE=0, INVOKER_USER, INVOKER_ROLE}; void binlog_invoker(bool role) { m_binlog_invoker= role ? INVOKER_ROLE : INVOKER_USER; } diff -Nru mariadb-10.1-10.1.41/sql/sql_insert.cc mariadb-10.1-10.1.43/sql/sql_insert.cc --- mariadb-10.1-10.1.41/sql/sql_insert.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_insert.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1025,6 +1025,7 @@ error= 1; break; } + thd->decide_logging_format_low(table); #ifndef EMBEDDED_LIBRARY if (lock_type == TL_WRITE_DELAYED) { @@ -1950,7 +1951,7 @@ /****************************************************************************** - Check that all fields with arn't null_fields are used + Check that there aren't any null_fields ******************************************************************************/ diff -Nru mariadb-10.1-10.1.41/sql/sql_list.h mariadb-10.1-10.1.43/sql/sql_list.h --- mariadb-10.1-10.1.41/sql/sql_list.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_list.h 2019-11-06 06:20:36.000000000 +0000 @@ -1,6 +1,7 @@ #ifndef INCLUDES_MYSQL_SQL_LIST_H #define INCLUDES_MYSQL_SQL_LIST_H /* Copyright (c) 2000, 2012, Oracle and/or its affiliates. + Copyright (c) 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,6 +86,14 @@ next= elements ? tmp.next : &first; } + SQL_I_List& operator=(const SQL_I_List &tmp) + { + elements= tmp.elements; + first= tmp.first; + next= tmp.next; + return *this; + } + inline void empty() { elements= 0; @@ -175,6 +184,13 @@ first == rhs.first && last == rhs.last; } + base_list& operator=(const base_list &rhs) + { + elements= rhs.elements; + first= rhs.first; + last= elements ? rhs.last : &first; + return *this; + } inline void empty() { elements=0; first= &end_of_list; last=&first;} inline base_list() { empty(); } @@ -189,9 +205,7 @@ */ inline base_list(const base_list &tmp) :Sql_alloc() { - elements= tmp.elements; - first= tmp.first; - last= elements ? tmp.last : &first; + *this= tmp; } /** Construct a deep copy of the argument in memory root mem_root. @@ -200,7 +214,7 @@ list_copy_and_replace_each_value after creating a copy. */ base_list(const base_list &rhs, MEM_ROOT *mem_root); - inline base_list(bool error) { } + inline base_list(bool) { } inline bool push_back(void *info) { if (((*last)=new list_node(info, &end_of_list))) @@ -512,7 +526,6 @@ { public: inline List() :base_list() {} - inline List(const List &tmp) :base_list(tmp) {} inline List(const List &tmp, MEM_ROOT *mem_root) : base_list(tmp, mem_root) {} inline bool push_back(T *a) { return base_list::push_back(a); } diff -Nru mariadb-10.1-10.1.41/sql/sql_parse.cc mariadb-10.1-10.1.43/sql/sql_parse.cc --- mariadb-10.1-10.1.41/sql/sql_parse.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_parse.cc 2019-11-06 06:20:36.000000000 +0000 @@ -5487,7 +5487,7 @@ if (thd->is_error() || (thd->variables.option_bits & OPTION_MASTER_SQL_ERROR)) trans_rollback_stmt(thd); #ifdef WITH_WSREP - if (thd->spcont && + else if (thd->spcont && (thd->wsrep_conflict_state == MUST_ABORT || thd->wsrep_conflict_state == ABORTED || thd->wsrep_conflict_state == CERT_FAILURE)) @@ -7639,10 +7639,6 @@ TABLE_LIST *head= join_list->head(); if (head->nested_join && head->nested_join->nest_type & REBALANCED_NEST) { - List_iterator li(*join_list); - li++; - while (li++) - li.remove(); DBUG_RETURN(head); } @@ -7726,13 +7722,13 @@ context and right-associative in another context. In this query - SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a (Q1) + SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a (Q1) JOIN is left-associative and the query Q1 is interpreted as - SELECT * FROM (t1 JOIN t2) LEFT JOIN t3 ON t2.a=t3.a. + SELECT * FROM (t1 JOIN t2) LEFT JOIN t3 ON t2.a=t3.a. While in this query - SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.b=t2.b (Q2) + SELECT * FROM t1 JOIN t2 LEFT JOIN t3 ON t2.a=t3.a ON t1.b=t2.b (Q2) JOIN is right-associative and the query Q2 is interpreted as - SELECT * FROM t1 JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.b=t2.b + SELECT * FROM t1 JOIN (t2 LEFT JOIN t3 ON t2.a=t3.a) ON t1.b=t2.b JOIN is right-associative if it is used with ON clause or with USING clause. Otherwise it is left-associative. @@ -7778,9 +7774,9 @@ J LJ - ON / \ / \ - t1 LJ - ON (TQ3*) => J t2 - / \ / \ - t3 t2 t1 t3 + t1 LJ - ON (TQ3*) => t3 J + / \ / \ + t3 t2 t1 t2 With several left associative JOINs SELECT * FROM t1 JOIN t2 JOIN t3 LEFT JOIN t4 ON t3.a=t4.a (Q4) @@ -7788,15 +7784,15 @@ J1 LJ - ON / \ / \ - t1 LJ - ON J2 t4 + t1 J2 J2 t4 / \ => / \ - J2 t4 J1 t3 - / \ / \ - t2 t3 t1 t2 - - Here's another example: - SELECT * - FROM t1 JOIN t2 LEFT JOIN t3 JOIN t4 ON t3.a=t4.a ON t2.b=t3.b (Q5) + t2 LJ - ON J1 t3 + / \ / \ + t3 t4 t1 t2 + + Here's another example: + SELECT * + FROM t1 JOIN t2 LEFT JOIN t3 JOIN t4 ON t3.a=t4.a ON t2.b=t3.b (Q5) J LJ - ON / \ / \ @@ -7806,15 +7802,58 @@ / \ t3 t4 - If the transformed nested join node node is a natural join node like in - the following query - SELECT * FROM t1 JOIN t2 LEFT JOIN t3 USING(a) (Q6) - the transformation additionally has to take care about setting proper - references in the field natural_join for both operands of the natural - join operation. - The function also has to change the name resolution context for ON - expressions used in the transformed join expression to take into - account the tables of the left_op node. + If the transformed nested join node node is a natural join node like in + the following query + SELECT * FROM t1 JOIN t2 LEFT JOIN t3 USING(a) (Q6) + the transformation additionally has to take care about setting proper + references in the field natural_join for both operands of the natural + join operation. + + The queries that combine comma syntax for join operation with + JOIN expression require a special care. Consider the query + SELECT * FROM t1, t2 JOIN t3 LEFT JOIN t4 ON t3.a=t4.a (Q7) + This query is equivalent to the query + SELECT * FROM (t1, t2) JOIN t3 LEFT JOIN t4 ON t3.a=t4.a + The latter is transformed in the same way as query Q1 + + J LJ - ON + / \ / \ + (t1,t2) LJ - ON => J t4 + / \ / \ + t3 t4 (t1,t2) t3 + + A transformation similar to the transformation for Q3 is done for + the following query with RIGHT JOIN + SELECT * FROM t1, t2 JOIN t3 RIGHT JOIN t4 ON t3.a=t4.a (Q8) + + J LJ - ON + / \ / \ + t3 LJ - ON => t4 J + / \ / \ + t4 (t1,t2) (t1,t2) t3 + + The function also has to change the name resolution context for ON + expressions used in the transformed join expression to take into + account the tables of the left_op node. + + TODO: + A more elegant solution would be to implement the transformation that + eliminates nests for cross join operations. For Q7 it would work like this: + + J LJ - ON + / \ / \ + (t1,t2) LJ - ON => (t1,t2,t3) t4 + / \ + t3 t4 + + For Q8 with RIGHT JOIN the transformation would work similarly: + + J LJ - ON + / \ / \ + t3 LJ - ON => t4 (t1,t2,t3) + / \ + t4 (t1,t2) + */ bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op, @@ -7837,7 +7876,11 @@ } TABLE_LIST *tbl; - List *jl= &right_op->nested_join->join_list; + List *right_op_jl= right_op->join_list; + TABLE_LIST *r_tbl= right_op_jl->pop(); + DBUG_ASSERT(right_op == r_tbl); + TABLE_LIST *l_tbl= right_op_jl->pop(); + DBUG_ASSERT(left_op == l_tbl); TABLE_LIST *cj_nest; /* @@ -7854,6 +7897,8 @@ List *cjl= &cj_nest->nested_join->join_list; cjl->empty(); + List *jl= &right_op->nested_join->join_list; + DBUG_ASSERT(jl->elements == 2); /* Look for the left most node tbl of the right_op tree */ for ( ; ; ) { @@ -7925,6 +7970,8 @@ create a new top level nested join node. */ right_op->nested_join->nest_type|= REBALANCED_NEST; + if (unlikely(right_op_jl->push_front(right_op))) + DBUG_RETURN(true); DBUG_RETURN(false); } diff -Nru mariadb-10.1-10.1.41/sql/sql_partition.cc mariadb-10.1-10.1.43/sql/sql_partition.cc --- mariadb-10.1-10.1.41/sql/sql_partition.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_partition.cc 2019-11-06 06:20:36.000000000 +0000 @@ -4660,6 +4660,69 @@ } +/** + Check if the ALTER command tries to change DATA DIRECTORY + or INDEX DIRECTORY for its partitions and warn if so. + @param thd THD + @param part_elem partition_element to check + */ +static void warn_if_datadir_altered(THD *thd, + const partition_element *part_elem) +{ + DBUG_ASSERT(part_elem); + + if (part_elem->engine_type && + part_elem->engine_type->db_type != DB_TYPE_INNODB) + return; + + if (part_elem->data_file_name) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + WARN_INNODB_PARTITION_OPTION_IGNORED, + ER(WARN_INNODB_PARTITION_OPTION_IGNORED), + "DATA DIRECTORY"); + } + if (part_elem->index_file_name) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + WARN_INNODB_PARTITION_OPTION_IGNORED, + ER(WARN_INNODB_PARTITION_OPTION_IGNORED), + "INDEX DIRECTORY"); + } +} + + +/** + Currently changing DATA DIRECTORY and INDEX DIRECTORY for InnoDB partitions is + not possible. This function checks it and warns on that case. + @param thd THD + @param tab_part_info old partition info + @param alt_part_info new partition info + */ +static void check_datadir_altered_for_innodb(THD *thd, + partition_info *tab_part_info, + partition_info *alt_part_info) +{ + if (tab_part_info->default_engine_type->db_type != DB_TYPE_INNODB) + return; + + for (List_iterator_fast it(alt_part_info->partitions); + partition_element *part_elem= it++;) + { + if (alt_part_info->is_sub_partitioned()) + { + for (List_iterator_fast it2(part_elem->subpartitions); + const partition_element *sub_part_elem= it2++;) + { + warn_if_datadir_altered(thd, sub_part_elem); + } + } + else + warn_if_datadir_altered(thd, part_elem); + } +} + + /* Prepare for ALTER TABLE of partition structure @@ -5389,6 +5452,8 @@ { goto err; } + check_datadir_altered_for_innodb(thd, tab_part_info, alt_part_info); + /* Online handling: REORGANIZE PARTITION: diff -Nru mariadb-10.1-10.1.41/sql/sql_select.cc mariadb-10.1-10.1.43/sql/sql_select.cc --- mariadb-10.1-10.1.41/sql/sql_select.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_select.cc 2019-11-06 06:20:36.000000000 +0000 @@ -7618,6 +7618,7 @@ KEYUSE *keyuse= pos->key; KEYUSE *prev_ref_keyuse= keyuse; uint key= keyuse->key; + bool used_range_selectivity= false; /* Check if we have a prefix of key=const that matches a quick select. @@ -7642,7 +7643,20 @@ } keyparts++; } + /* + Here we discount selectivity of the constant range CR. To calculate + this selectivity we use elements from the quick_rows[] array. + If we have indexes i1,...,ik with the same prefix compatible + with CR any of the estimate quick_rows[i1], ... quick_rows[ik] could + be used for this calculation but here we don't know which one was + actually used. So sel could be greater than 1 and we have to cap it. + However if sel becomes greater than 2 then with high probability + something went wrong. + */ sel /= (double)table->quick_rows[key] / (double) table->stat_records(); + DBUG_ASSERT(0 < sel && sel <= 2.0); + set_if_smaller(sel, 1.0); + used_range_selectivity= true; } } @@ -7678,16 +7692,18 @@ if (keyparts > keyuse->keypart) { /* Ok this is the keyuse that will be used for ref access */ - uint fldno; - if (is_hash_join_key_no(key)) - fldno= keyuse->keypart; - else - fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1; - if (keyuse->val->const_item()) + if (!used_range_selectivity && keyuse->val->const_item()) { + uint fldno; + if (is_hash_join_key_no(key)) + fldno= keyuse->keypart; + else + fldno= table->key_info[key].key_part[keyparts-1].fieldnr - 1; + if (table->field[fldno]->cond_selectivity > 0) { sel /= table->field[fldno]->cond_selectivity; + DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); } /* @@ -7745,6 +7761,7 @@ if (field->cond_selectivity > 0) { sel/= field->cond_selectivity; + DBUG_ASSERT(0 < sel && sel <= 2.0); set_if_smaller(sel, 1.0); } break; @@ -7756,6 +7773,7 @@ sel*= table_multi_eq_cond_selectivity(join, idx, s, rem_tables, keyparts, ref_keyuse_steps); + DBUG_ASSERT(0.0 < sel && sel <= 1.0); return sel; } @@ -8452,7 +8470,10 @@ #max_nested_outer_joins=64-1) will not make it any more precise. */ if (pos->records_read) + { found= COST_MULT(found, pos->records_read); + found*= pos->cond_selectivity; + } } } return found; @@ -16155,8 +16176,31 @@ { Field *UNINIT_VAR(new_field); DBUG_ASSERT(thd == table->in_use); - new_field= item->Item::create_tmp_field(false, table); - + if (item->type() == Item::FUNC_ITEM && + static_cast(item)->functype() == Item_func::SUSERVAR_FUNC) + { + /* + A temporary solution for versions 5.5 .. 10.3. + This change should be null-merged to 10.4. + + Item_func_set_user_var is special. It overrides make_field(). + by adding a special branch `if (result_field)...`. + So it's important to preserve the exact data type here, + to avoid type mismatch in Protocol_text::store_longlong() + See MDEV-15955. + + Other Item_func descendants are not affected by MDEV-15955. + They don't override make_field() so they don't use result_field + when initializing Send_field. + + This is properly fixed in 10.4 in the method + Item_func_user_var::create_tmp_field_ex(). + */ + new_field= item->tmp_table_field_from_field_type(table, false, true); + } + else + new_field= item->Item::create_tmp_field(false, table); + if (copy_func && (item->is_result_field() || (item->real_item()->is_result_field()))) diff -Nru mariadb-10.1-10.1.41/sql/sql_show.cc mariadb-10.1-10.1.43/sql/sql_show.cc --- mariadb-10.1-10.1.41/sql/sql_show.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_show.cc 2019-11-06 06:20:36.000000000 +0000 @@ -2646,8 +2646,12 @@ else protocol->store_null(); protocol->store(thd_info->state_info, system_charset_info); - protocol->store(thd_info->query_string.str(), - thd_info->query_string.charset()); + if (thd_info->query_string.length()) + protocol->store(thd_info->query_string.str(), + thd_info->query_string.length(), + thd_info->query_string.charset()); + else + protocol->store_null(); if (!thd->variables.old_mode && !(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO)) protocol->store(thd_info->progress, 3, &store_buffer); @@ -4272,7 +4276,6 @@ SQLCOM_SHOW_FIELDS is used because it satisfies 'only_view_structure()'. */ - thd->force_read_stats= get_schema_table_idx(schema_table) == SCH_STATISTICS; lex->sql_command= SQLCOM_SHOW_FIELDS; result= (open_temporary_tables(thd, table_list) || open_normal_and_derived_tables(thd, table_list, @@ -4287,9 +4290,6 @@ */ lex->sql_command= old_lex->sql_command; - (void) read_statistics_for_tables_if_needed(thd, table_list); - thd->force_read_stats= false; - DEBUG_SYNC(thd, "after_open_table_ignore_flush"); /* @@ -6165,6 +6165,7 @@ KEY *key_info=show_table->s->key_info; if (show_table->file) { + (void) read_statistics_for_tables(thd, tables); show_table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); @@ -7707,8 +7708,7 @@ item->maybe_null= (fields_info->field_flags & MY_I_S_MAYBE_NULL); field_count++; } - TMP_TABLE_PARAM *tmp_table_param = - (TMP_TABLE_PARAM*) (thd->alloc(sizeof(TMP_TABLE_PARAM))); + TMP_TABLE_PARAM *tmp_table_param = new (thd->mem_root) TMP_TABLE_PARAM; tmp_table_param->init(); tmp_table_param->table_charset= cs; tmp_table_param->field_count= field_count; diff -Nru mariadb-10.1-10.1.41/sql/sql_statistics.cc mariadb-10.1-10.1.43/sql/sql_statistics.cc --- mariadb-10.1-10.1.41/sql/sql_statistics.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_statistics.cc 2019-11-06 06:20:36.000000000 +0000 @@ -257,10 +257,8 @@ Open all statistical tables and lock them */ -static -inline int open_stat_tables(THD *thd, TABLE_LIST *tables, - Open_tables_backup *backup, - bool for_write) +static int open_stat_tables(THD *thd, TABLE_LIST *tables, + Open_tables_backup *backup, bool for_write) { int rc; @@ -268,12 +266,14 @@ thd->push_internal_handler(&deh); init_table_list_for_stat_tables(tables, for_write); init_mdl_requests(tables); + thd->in_sub_stmt|= SUB_STMT_STAT_TABLES; rc= open_system_tables_for_read(thd, tables, backup); + thd->in_sub_stmt&= ~SUB_STMT_STAT_TABLES; thd->pop_internal_handler(); /* If the number of tables changes, we should revise the check below. */ - DBUG_ASSERT(STATISTICS_TABLES == 3); + compile_time_assert(STATISTICS_TABLES == 3); if (!rc && (stat_table_intact.check(tables[TABLE_STAT].table, &table_stat_def) || @@ -2109,7 +2109,12 @@ Histogram_type hist_type= (Histogram_type) (thd->variables.histogram_type); uchar *histogram= NULL; if (hist_size > 0) - histogram= (uchar *) alloc_root(&table->mem_root, hist_size * columns); + { + if ((histogram= (uchar *) alloc_root(&table->mem_root, + hist_size * columns))) + bzero(histogram, hist_size * columns); + + } if (!table_stats || !column_stats || !index_stats || !idx_avg_frequency || (hist_size && !histogram)) @@ -2156,54 +2161,6 @@ /** - @brief - Check whether any persistent statistics for the processed command is needed - - @param - thd The thread handle - - @details - The function checks whether any persitent statistics for the processed - command is needed to be read. - - @retval - TRUE statistics is needed to be read - @retval - FALSE Otherwise -*/ - -static -inline bool statistics_for_command_is_needed(THD *thd) -{ - if (thd->bootstrap || thd->variables.use_stat_tables == NEVER) - return FALSE; - - if (thd->force_read_stats) - return TRUE; - - switch(thd->lex->sql_command) { - case SQLCOM_SELECT: - case SQLCOM_INSERT: - case SQLCOM_INSERT_SELECT: - case SQLCOM_UPDATE: - case SQLCOM_UPDATE_MULTI: - case SQLCOM_DELETE: - case SQLCOM_DELETE_MULTI: - case SQLCOM_REPLACE: - case SQLCOM_REPLACE_SELECT: - case SQLCOM_CREATE_TABLE: - case SQLCOM_SET_OPTION: - case SQLCOM_DO: - break; - default: - return FALSE; - } - - return TRUE; -} - - -/** @brief Allocate memory for the statistical data used by a table share @@ -2211,8 +2168,6 @@ thd Thread handler @param table_share Table share for which the memory for statistical data is allocated - @param - is_safe TRUE <-> at any time only one thread can perform the function @note The function allocates the memory for the statistical data on a table in the @@ -2221,8 +2176,6 @@ mysql.index_stats. The memory is allocated for the statistics on the table, on the tables's columns, and on the table's indexes. The memory is allocated in the table_share's mem_root. - If the parameter is_safe is TRUE then it is guaranteed that at any given time - only one thread is executed the code of the function. @retval 0 If the memory for all statistical data has been successfully allocated @@ -2241,16 +2194,10 @@ Here the second and the third threads try to allocate the memory for statistical data at the same time. The precautions are taken to guarantee the correctness of the allocation. - - @note - Currently the function always is called with the parameter is_safe set - to FALSE. */ -int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share, - bool is_safe) +static int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share) { - Field **field_ptr; KEY *key_info, *end; TABLE_STATISTICS_CB *stats_cb= &table_share->stats_cb; @@ -2260,16 +2207,11 @@ DEBUG_SYNC(thd, "statistics_mem_alloc_start1"); DEBUG_SYNC(thd, "statistics_mem_alloc_start2"); - if (!statistics_for_command_is_needed(thd)) - DBUG_RETURN(1); - - if (!is_safe) - mysql_mutex_lock(&table_share->LOCK_share); + mysql_mutex_lock(&table_share->LOCK_share); if (stats_cb->stats_can_be_read) { - if (!is_safe) - mysql_mutex_unlock(&table_share->LOCK_share); + mysql_mutex_unlock(&table_share->LOCK_share); DBUG_RETURN(0); } @@ -2280,8 +2222,7 @@ sizeof(Table_statistics)); if (!table_stats) { - if (!is_safe) - mysql_mutex_unlock(&table_share->LOCK_share); + mysql_mutex_unlock(&table_share->LOCK_share); DBUG_RETURN(1); } memset(table_stats, 0, sizeof(Table_statistics)); @@ -2353,8 +2294,7 @@ if (column_stats && index_stats && idx_avg_frequency) stats_cb->stats_can_be_read= TRUE; - if (!is_safe) - mysql_mutex_unlock(&table_share->LOCK_share); + mysql_mutex_unlock(&table_share->LOCK_share); DBUG_RETURN(0); } @@ -3119,9 +3059,6 @@ { if (!tables) return FALSE; - - if (!statistics_for_command_is_needed(thd)) - return FALSE; /* Do not read statistics for any query that explicity involves @@ -3254,10 +3191,64 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables) { + switch (thd->lex->sql_command) { + case SQLCOM_SELECT: + case SQLCOM_INSERT: + case SQLCOM_INSERT_SELECT: + case SQLCOM_UPDATE: + case SQLCOM_UPDATE_MULTI: + case SQLCOM_DELETE: + case SQLCOM_DELETE_MULTI: + case SQLCOM_REPLACE: + case SQLCOM_REPLACE_SELECT: + case SQLCOM_CREATE_TABLE: + case SQLCOM_SET_OPTION: + case SQLCOM_DO: + return read_statistics_for_tables(thd, tables); + default: + return 0; + } +} + + +int read_statistics_for_tables(THD *thd, TABLE_LIST *tables) +{ TABLE_LIST stat_tables[STATISTICS_TABLES]; Open_tables_backup open_tables_backup; - DBUG_ENTER("read_statistics_for_tables_if_needed"); + DBUG_ENTER("read_statistics_for_tables"); + + if (thd->bootstrap || thd->variables.use_stat_tables == NEVER) + DBUG_RETURN(0); + + for (TABLE_LIST *tl= tables; tl; tl= tl->next_global) + { + if (tl->table) + { + TABLE_SHARE *table_share= tl->table->s; + if (table_share && table_share->table_category == TABLE_CATEGORY_USER && + table_share->tmp_table == NO_TMP_TABLE) + { + if (table_share->stats_cb.stats_can_be_read || + !alloc_statistics_for_table_share(thd, table_share)) + { + if (table_share->stats_cb.stats_can_be_read) + { + KEY *key_info= table_share->key_info; + KEY *key_info_end= key_info + table_share->keys; + KEY *table_key_info= tl->table->key_info; + for ( ; key_info < key_info_end; key_info++, table_key_info++) + table_key_info->read_stats= key_info->read_stats; + Field **field_ptr= table_share->field; + Field **table_field_ptr= tl->table->field; + for ( ; *field_ptr; field_ptr++, table_field_ptr++) + (*table_field_ptr)->read_stats= (*field_ptr)->read_stats; + tl->table->stats_is_read= table_share->stats_cb.stats_is_read; + } + } + } + } + } DEBUG_SYNC(thd, "statistics_read_start"); @@ -3265,10 +3256,7 @@ DBUG_RETURN(0); if (open_stat_tables(thd, stat_tables, &open_tables_backup, FALSE)) - { - thd->clear_error(); DBUG_RETURN(1); - } for (TABLE_LIST *tl= tables; tl; tl= tl->next_global) { diff -Nru mariadb-10.1-10.1.41/sql/sql_statistics.h mariadb-10.1-10.1.43/sql/sql_statistics.h --- mariadb-10.1-10.1.41/sql/sql_statistics.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_statistics.h 2019-11-06 06:20:36.000000000 +0000 @@ -89,9 +89,8 @@ } int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables); +int read_statistics_for_tables(THD *thd, TABLE_LIST *tables); int collect_statistics_for_table(THD *thd, TABLE *table); -int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *share, - bool is_safe); void delete_stat_values_for_table_share(TABLE_SHARE *table_share); int alloc_statistics_for_table(THD *thd, TABLE *table); int update_statistics_for_table(THD *thd, TABLE *table); diff -Nru mariadb-10.1-10.1.41/sql/sql_table.cc mariadb-10.1-10.1.43/sql/sql_table.cc --- mariadb-10.1-10.1.41/sql/sql_table.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/sql_table.cc 2019-11-06 06:20:36.000000000 +0000 @@ -2418,6 +2418,13 @@ ER_BAD_TABLE_ERROR, ER_THD(thd, ER_BAD_TABLE_ERROR), tbl_name.c_ptr_safe()); + + /* + Our job is done here. This statement was added to avoid executing + unnecessary code farther below which in some strange corner cases + caused the server to crash (see MDEV-17896). + */ + continue; } else { @@ -4059,16 +4066,16 @@ /* Use packed keys for long strings on the first column */ if (!((*db_options) & HA_OPTION_NO_PACK_KEYS) && !((create_info->table_options & HA_OPTION_NO_PACK_KEYS)) && - (key_part_length >= KEY_DEFAULT_PACK_LENGTH && - (sql_field->sql_type == MYSQL_TYPE_STRING || - sql_field->sql_type == MYSQL_TYPE_VARCHAR || - sql_field->pack_flag & FIELDFLAG_BLOB))) + (key_part_length >= KEY_DEFAULT_PACK_LENGTH && + (sql_field->sql_type == MYSQL_TYPE_STRING || + sql_field->sql_type == MYSQL_TYPE_VARCHAR || + f_is_blob(sql_field->pack_flag)))) { - if ((column_nr == 0 && (sql_field->pack_flag & FIELDFLAG_BLOB)) || + if ((column_nr == 0 && f_is_blob(sql_field->pack_flag)) || sql_field->sql_type == MYSQL_TYPE_VARCHAR) - key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; - else - key_info->flags|= HA_PACK_KEY; + key_info->flags|= HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY; + else + key_info->flags|= HA_PACK_KEY; } /* Check if the key segment is partial, set the key flag accordingly */ if (key_part_length != sql_field->key_length) @@ -5092,7 +5099,7 @@ err: /* In RBR we don't need to log CREATE TEMPORARY TABLE */ - if (thd->is_current_stmt_binlog_format_row() && create_info->tmp_table()) + if (!result && thd->is_current_stmt_binlog_format_row() && create_info->tmp_table()) DBUG_RETURN(result); if (create_info->tmp_table()) diff -Nru mariadb-10.1-10.1.41/sql/tztime.cc mariadb-10.1-10.1.43/sql/tztime.cc --- mariadb-10.1-10.1.41/sql/tztime.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/tztime.cc 2019-11-06 06:20:36.000000000 +0000 @@ -148,6 +148,7 @@ static my_bool prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage); +my_bool opt_leap, opt_verbose, opt_skip_write_binlog; #if defined(TZINFO2SQL) || defined(TESTTIME) @@ -2439,6 +2440,14 @@ We are assuming that there are only one list of leap seconds For all timezones. */ + if (!opt_skip_write_binlog) + printf("\\d |\n" + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on') = 1 THEN\n" + "ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n" + "END IF|\n" + "\\d ;\n"); + printf("TRUNCATE TABLE time_zone_leap_second;\n"); if (sp->leapcnt) @@ -2451,6 +2460,14 @@ printf(";\n"); } + if (!opt_skip_write_binlog) + printf("\\d |\n" + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on') = 1 THEN\n" + "ALTER TABLE time_zone_leap_second ENGINE=MyISAM;\n" + "END IF|\n" + "\\d ;\n"); + printf("ALTER TABLE time_zone_leap_second ORDER BY Transition_time;\n"); } @@ -2607,8 +2624,6 @@ } -my_bool opt_leap, opt_verbose; - static const char *load_default_groups[]= { "mysql_tzinfo_to_sql", 0}; @@ -2629,6 +2644,8 @@ &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"skip-write-binlog", 'S', "Do not replicate changes to time zone tables to other nodes in a Galera cluster", + &opt_skip_write_binlog,&opt_skip_write_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -2697,11 +2714,14 @@ return 1; } - // Replicate MyISAM DDL for this session, cf. lp:1161432 - // timezone info unfixable in XtraDB Cluster - printf("set @prep=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET GLOBAL wsrep_replicate_myisam=?', 'do ?');\n" - "prepare set_wsrep_myisam from @prep;\n" - "set @toggle=1; execute set_wsrep_myisam using @toggle;\n"); + if (opt_skip_write_binlog) + /* If skip_write_binlog is set and wsrep is compiled in we disable + sql_log_bin and wsrep_on to avoid Galera replicating below + truncate table clauses. This will allow user to set different + time zones to nodes in Galera cluster. */ + printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" + "prepare set_wsrep_write_binlog from @prep1;\n" + "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n"); if (argc == 1 && !opt_leap) { @@ -2709,6 +2729,21 @@ root_name_end= strmake_buf(fullname, argv[0]); + if(!opt_skip_write_binlog) + { + // Alter time zone tables to InnoDB if wsrep_on is enabled + // to allow changes to them to replicate with Galera + printf("\\d |\n" + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on') = 1 THEN\n" + "ALTER TABLE time_zone ENGINE=InnoDB;\n" + "ALTER TABLE time_zone_name ENGINE=InnoDB;\n" + "ALTER TABLE time_zone_transition ENGINE=InnoDB;\n" + "ALTER TABLE time_zone_transition_type ENGINE=InnoDB;\n" + "END IF|\n" + "\\d ;\n"); + } + printf("TRUNCATE TABLE time_zone;\n"); printf("TRUNCATE TABLE time_zone_name;\n"); printf("TRUNCATE TABLE time_zone_transition;\n"); @@ -2750,8 +2785,19 @@ free_root(&tz_storage, MYF(0)); } - // Reset wsrep_replicate_myisam. lp:1161432 - printf("set @toggle=0; execute set_wsrep_myisam using @toggle;\n"); + if(!opt_skip_write_binlog) + { + // Fall back to MyISAM + printf("\\d |\n" + "IF (select count(*) from information_schema.global_variables where\n" + "variable_name='wsrep_on') = 1 THEN\n" + "ALTER TABLE time_zone ENGINE=MyISAM;\n" + "ALTER TABLE time_zone_name ENGINE=MyISAM;\n" + "ALTER TABLE time_zone_transition ENGINE=MyISAM;\n" + "ALTER TABLE time_zone_transition_type ENGINE=MyISAM;\n" + "END IF|\n" + "\\d ;\n"); + } free_defaults(default_argv); my_end(0); diff -Nru mariadb-10.1-10.1.41/sql/wsrep_sst.cc mariadb-10.1-10.1.43/sql/wsrep_sst.cc --- mariadb-10.1-10.1.41/sql/wsrep_sst.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/wsrep_sst.cc 2019-11-06 06:20:36.000000000 +0000 @@ -16,6 +16,7 @@ #include "wsrep_sst.h" #include +#include #include #include #include @@ -379,7 +380,31 @@ } /* - Generate opt_binlog_opt_val for sst_donate_other(), sst_prepare_other(). + Generate "name 'value'" string. +*/ +static char* generate_name_value(const char* name, const char* value) +{ + size_t name_len= strlen(name); + size_t value_len= strlen(value); + char* buf= + (char*) my_malloc((name_len + value_len + 5) * sizeof(char), MYF(0)); + if (buf) + { + char* ref= buf; + *ref++ = ' '; + memcpy(ref, name, name_len * sizeof(char)); + ref += name_len; + *ref++ = ' '; + *ref++ = '\''; + memcpy(ref, value, value_len * sizeof(char)); + ref += value_len; + *ref++ = '\''; + *ref = 0; + } + return buf; +} +/* + Generate binlog option string for sst_donate_other(), sst_prepare_other(). Returns zero on success, negative error code otherwise. @@ -395,7 +420,9 @@ { assert(opt_bin_logname); *ret= strcmp(opt_bin_logname, "0") ? - my_strdup(opt_bin_logname, MYF(0)) : my_strdup("", MYF(0)); + generate_name_value(WSREP_SST_OPT_BINLOG, + opt_bin_logname) : + my_strdup("", MYF(0)); } else { @@ -411,7 +438,9 @@ *ret= NULL; if (opt_binlog_index_name) { *ret= strcmp(opt_binlog_index_name, "0") ? - my_strdup(opt_binlog_index_name, MYF(0)) : my_strdup("", MYF(0)); + generate_name_value(WSREP_SST_OPT_BINLOG_INDEX, + opt_binlog_index_name) : + my_strdup("", MYF(0)); } else { @@ -592,23 +621,320 @@ return -env.error(); } +static size_t estimate_cmd_len (bool* extra_args) +{ + /* + The length of the area reserved for the control parameters + of the SST script (excluding the copying of the original + mysqld arguments): + */ + size_t cmd_len= 4096; + bool extra= false; + /* + If mysqld was started with arguments, add them all: + */ + if (orig_argc > 1) + { + for (int i = 1; i < orig_argc; i++) + { + const char* arg= orig_argv[i]; + size_t n= strlen(arg); + if (n == 0) continue; + cmd_len += n; + bool quotation= false; + char c; + while ((c = *arg++) != 0) + { + /* A whitespace or a single quote requires double quotation marks: */ + if (isspace(c) || c == '\'') + { + quotation= true; + } + /* + If the equals symbol is encountered, then we need to separately + process the right side: + */ + else if (c == '=') + { + /* Perhaps we need to quote the left part of the argument: */ + if (quotation) + { + cmd_len += 2; + /* + Reset the quotation flag, since now the status for + the right side of the expression will be saved here: + */ + quotation= false; + } + while ((c = *arg++) != 0) + { + /* + A whitespace or a single quote requires double + quotation marks: + */ + if (isspace(c) || c == '\'') + { + quotation= true; + } + /* + Double quotation mark or backslash symbol requires backslash + prefixing: + */ +#ifdef __WIN__ + else if (c == '"' || c == '\\') +#else + /* + The dollar symbol is used to substitute a variable, therefore + it also requires escaping: + */ + else if (c == '"' || c == '\\' || c == '$') +#endif + { + cmd_len++; + } + } + break; + } + /* + Double quotation mark or backslash symbol requires backslash + prefixing: + */ +#ifdef __WIN__ + else if (c == '"' || c == '\\') +#else + /* + The dollar symbol is used to substitute a variable, therefore + it also requires escaping: + */ + else if (c == '"' || c == '\\' || c == '$') +#endif + { + cmd_len++; + } + } + /* Perhaps we need to quote the entire argument or its right part: */ + if (quotation) + { + cmd_len += 2; + } + } + extra = true; + cmd_len += strlen(WSREP_SST_OPT_MYSQLD); + /* + Add the separating spaces between arguments, + and one additional space before "--mysqld-args": + */ + cmd_len += orig_argc; + } + *extra_args= extra; + return cmd_len; +} + +static void copy_orig_argv (char* cmd_str) +{ + /* + If mysqld was started with arguments, copy them all: + */ + if (orig_argc > 1) + { + size_t n = strlen(WSREP_SST_OPT_MYSQLD); + *cmd_str++ = ' '; + memcpy(cmd_str, WSREP_SST_OPT_MYSQLD, n * sizeof(char)); + cmd_str += n; + for (int i = 1; i < orig_argc; i++) + { + char* arg= orig_argv[i]; + n = strlen(arg); + if (n == 0) continue; + *cmd_str++ = ' '; + bool quotation= false; + bool plain= true; + char *arg_scan= arg; + char c; + while ((c = *arg_scan++) != 0) + { + /* A whitespace or a single quote requires double quotation marks: */ + if (isspace(c) || c == '\'') + { + quotation= true; + } + /* + If the equals symbol is encountered, then we need to separately + process the right side: + */ + else if (c == '=') + { + /* Calculate length of the Left part of the argument: */ + size_t m = (size_t) (arg_scan - arg) - 1; + if (m) + { + /* Perhaps we need to quote the left part of the argument: */ + if (quotation) + { + *cmd_str++ = '"'; + } + /* + If there were special characters inside, then we can use + the fast memcpy function: + */ + if (plain) + { + memcpy(cmd_str, arg, m * sizeof(char)); + cmd_str += m; + /* Left part of the argument has already been processed: */ + n -= m; + arg += m; + } + /* Otherwise we need to prefix individual characters: */ + else + { + n -= m; + while (m) + { + c = *arg++; +#ifdef __WIN__ + if (c == '"' || c == '\\') +#else + if (c == '"' || c == '\\' || c == '$') +#endif + { + *cmd_str++ = '\\'; + } + *cmd_str++ = c; + m--; + } + /* + Reset the plain string flag, since now the status for + the right side of the expression will be saved here: + */ + plain= true; + } + /* Perhaps we need to quote the left part of the argument: */ + if (quotation) + { + *cmd_str++ = '"'; + /* + Reset the quotation flag, since now the status for + the right side of the expression will be saved here: + */ + quotation= false; + } + } + /* Copy equals symbol: */ + *cmd_str++ = '='; + arg++; + n--; + /* Let's deal with the left side of the expression: */ + while ((c = *arg_scan++) != 0) + { + /* + A whitespace or a single quote requires double + quotation marks: + */ + if (isspace(c) || c == '\'') + { + quotation= true; + } + /* + Double quotation mark or backslash symbol requires backslash + prefixing: + */ +#ifdef __WIN__ + else if (c == '"' || c == '\\') +#else + /* + The dollar symbol is used to substitute a variable, therefore + it also requires escaping: + */ + else if (c == '"' || c == '\\' || c == '$') +#endif + { + plain= false; + } + } + break; + } + /* + Double quotation mark or backslash symbol requires backslash + prefixing: + */ +#ifdef __WIN__ + else if (c == '"' || c == '\\') +#else + /* + The dollar symbol is used to substitute a variable, therefore + it also requires escaping: + */ + else if (c == '"' || c == '\\' || c == '$') +#endif + { + plain= false; + } + } + if (n) + { + /* Perhaps we need to quote the entire argument or its right part: */ + if (quotation) + { + *cmd_str++ = '"'; + } + /* + If there were no special characters inside, then we can use + the fast memcpy function: + */ + if (plain) + { + memcpy(cmd_str, arg, n * sizeof(char)); + cmd_str += n; + } + /* Otherwise we need to prefix individual characters: */ + else + { + while ((c = *arg++) != 0) + { +#ifdef __WIN__ + if (c == '"' || c == '\\') +#else + if (c == '"' || c == '\\' || c == '$') +#endif + { + *cmd_str++ = '\\'; + } + *cmd_str++ = c; + } + } + /* Perhaps we need to quote the entire argument or its right part: */ + if (quotation) + { + *cmd_str++ = '"'; + } + } + } + /* + Add a terminating null character (not counted in the length, + since we've overwritten the original null character which + was previously added by snprintf: + */ + *cmd_str = 0; + } +} + static ssize_t sst_prepare_other (const char* method, const char* sst_auth, const char* addr_in, const char** addr_out) { - int const cmd_len= 4096; + bool extra_args; + size_t const cmd_len= estimate_cmd_len(&extra_args); wsp::string cmd_str(cmd_len); if (!cmd_str()) { - WSREP_ERROR("sst_prepare_other(): could not allocate cmd buffer of %d bytes", + WSREP_ERROR("sst_prepare_other(): could not allocate cmd buffer of %zd bytes", cmd_len); return -ENOMEM; } - const char* binlog_opt= ""; - const char* binlog_index_opt= ""; char* binlog_opt_val= NULL; char* binlog_index_opt_val= NULL; @@ -626,9 +952,6 @@ ret); } - if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG; - if (strlen(binlog_index_opt_val)) binlog_index_opt= WSREP_SST_OPT_BINLOG_INDEX; - make_wsrep_defaults_file(); ret= snprintf (cmd_str(), cmd_len, @@ -636,23 +959,26 @@ WSREP_SST_OPT_ROLE " 'joiner' " WSREP_SST_OPT_ADDR " '%s' " WSREP_SST_OPT_DATA " '%s' " - " %s " + "%s" WSREP_SST_OPT_PARENT " '%d'" - " %s '%s'" - " %s '%s'", + "%s" + "%s", method, addr_in, mysql_real_data_home, wsrep_defaults_file, - (int)getpid(), binlog_opt, binlog_opt_val, - binlog_index_opt, binlog_index_opt_val); + (int)getpid(), + binlog_opt_val, binlog_index_opt_val); my_free(binlog_opt_val); my_free(binlog_index_opt_val); - if (ret < 0 || ret >= cmd_len) + if (ret < 0 || size_t(ret) >= cmd_len) { WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret); return (ret < 0 ? ret : -EMSGSIZE); } + if (extra_args) + copy_orig_argv(cmd_str() + ret); + wsp::env env(NULL); if (env.error()) { @@ -916,13 +1242,14 @@ } memcpy(host, address.get_address(), address.get_address_len()); int port= address.get_port(); - int const cmd_len= 4096; - wsp::string cmd_str(cmd_len); + bool extra_args; + size_t const cmd_len= estimate_cmd_len(&extra_args); + wsp::string cmd_str(cmd_len); if (!cmd_str()) { WSREP_ERROR("sst_donate_mysqldump(): " - "could not allocate cmd buffer of %d bytes", cmd_len); + "could not allocate cmd buffer of %zd bytes", cmd_len); return -ENOMEM; } @@ -936,7 +1263,7 @@ WSREP_SST_OPT_PORT " '%d' " WSREP_SST_OPT_LPORT " '%u' " WSREP_SST_OPT_SOCKET " '%s' " - " %s " + "%s" WSREP_SST_OPT_GTID " '%s:%lld' " WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'" "%s", @@ -945,12 +1272,15 @@ (long long)seqno, wsrep_gtid_domain_id, bypass ? " " WSREP_SST_OPT_BYPASS : ""); - if (ret < 0 || ret >= cmd_len) + if (ret < 0 || size_t(ret) >= cmd_len) { WSREP_ERROR("sst_donate_mysqldump(): snprintf() failed: %d", ret); return (ret < 0 ? ret : -EMSGSIZE); } + if (extra_args) + copy_orig_argv(cmd_str() + ret); + WSREP_DEBUG("Running: '%s'", cmd_str()); ret= sst_run_shell (cmd_str(), env, 3); @@ -1270,17 +1600,17 @@ bool bypass, char** env) // carries auth info { - int const cmd_len= 4096; - wsp::string cmd_str(cmd_len); + bool extra_args; + size_t const cmd_len= estimate_cmd_len(&extra_args); + wsp::string cmd_str(cmd_len); if (!cmd_str()) { WSREP_ERROR("sst_donate_other(): " - "could not allocate cmd buffer of %d bytes", cmd_len); + "could not allocate cmd buffer of %zd bytes", cmd_len); return -ENOMEM; } - const char* binlog_opt= ""; char* binlog_opt_val= NULL; int ret; @@ -1289,7 +1619,6 @@ WSREP_ERROR("sst_donate_other(): generate_binlog_opt_val() failed: %d",ret); return ret; } - if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG; make_wsrep_defaults_file(); @@ -1299,24 +1628,27 @@ WSREP_SST_OPT_ADDR " '%s' " WSREP_SST_OPT_SOCKET " '%s' " WSREP_SST_OPT_DATA " '%s' " - " %s " - " %s '%s' " + "%s" WSREP_SST_OPT_GTID " '%s:%lld' " WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'" + "%s" "%s", method, addr, mysqld_unix_port, mysql_real_data_home, wsrep_defaults_file, - binlog_opt, binlog_opt_val, uuid, (long long) seqno, wsrep_gtid_domain_id, + binlog_opt_val, bypass ? " " WSREP_SST_OPT_BYPASS : ""); my_free(binlog_opt_val); - if (ret < 0 || ret >= cmd_len) + if (ret < 0 || size_t(ret) >= cmd_len) { WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret); return (ret < 0 ? ret : -EMSGSIZE); } + if (extra_args) + copy_orig_argv(cmd_str() + ret); + if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(FALSE); pthread_t tmp; diff -Nru mariadb-10.1-10.1.41/sql/wsrep_sst.h mariadb-10.1-10.1.43/sql/wsrep_sst.h --- mariadb-10.1-10.1.41/sql/wsrep_sst.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql/wsrep_sst.h 2019-11-06 06:20:36.000000000 +0000 @@ -32,6 +32,7 @@ #define WSREP_SST_OPT_PARENT "--parent" #define WSREP_SST_OPT_BINLOG "--binlog" #define WSREP_SST_OPT_BINLOG_INDEX "--binlog-index" +#define WSREP_SST_OPT_MYSQLD "--mysqld-args" // mysqldump-specific options #define WSREP_SST_OPT_USER "--user" diff -Nru mariadb-10.1-10.1.41/sql-common/my_time.c mariadb-10.1-10.1.43/sql-common/my_time.c --- mariadb-10.1-10.1.41/sql-common/my_time.c 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/sql-common/my_time.c 2019-11-06 06:20:36.000000000 +0000 @@ -184,7 +184,7 @@ do { s++; - } while (my_isspace(&my_charset_latin1, *s)); + } while (s < end && my_isspace(&my_charset_latin1, *s)); *str= s; return 0; } diff -Nru mariadb-10.1-10.1.41/storage/connect/array.cpp mariadb-10.1-10.1.43/storage/connect/array.cpp --- mariadb-10.1-10.1.41/storage/connect/array.cpp 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/array.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /************* Array C++ Functions Source Code File (.CPP) *************/ /* Name: ARRAY.CPP Version 2.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2019 */ /* */ /* This file contains the XOBJECT derived class ARRAY functions. */ /* ARRAY is used for elaborate type of processing, such as sorting */ @@ -67,7 +67,7 @@ /* MakeValueArray: Makes a value array from a value list. */ /***********************************************************************/ PARRAY MakeValueArray(PGLOBAL g, PPARM pp) - { +{ int n, valtyp = 0; size_t len = 0; PARRAY par; @@ -82,8 +82,7 @@ if ((valtyp = pp->Type) != TYPE_STRING) len = 1; - if (trace(1)) - htrc("valtyp=%d len=%d\n", valtyp, len); + xtrc(1, "valtyp=%d len=%d\n", valtyp, len); /*********************************************************************/ /* Firstly check the list and count the number of values in it. */ @@ -127,13 +126,13 @@ // Integer stored inside pp->Value par->AddValue(g, parmp->Intval); break; - } // endswitch valtyp + } // endswitch valtyp /*********************************************************************/ /* Send back resulting array. */ /*********************************************************************/ return par; - } // end of MakeValueArray +} // end of MakeValueArray /* -------------------------- Class ARRAY ---------------------------- */ @@ -151,6 +150,9 @@ Type = type; Xsize = -1; Len = 1; + X = 0; + Inf = 0; + Sup = 0; switch (type) { case TYPE_STRING: @@ -281,130 +283,109 @@ /* Add a string element to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, PSZ strp) - { +{ if (Type != TYPE_STRING) { sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "CHAR"); return true; - } // endif Type - - if (trace(1)) - htrc(" adding string(%d): '%s'\n", Nval, strp); + } // endif Type -//Value->SetValue_psz(strp); -//Vblp->SetValue(valp, Nval++); + xtrc(1, " adding string(%d): '%s'\n", Nval, strp); Vblp->SetValue(strp, Nval++); return false; - } // end of AddValue +} // end of AddValue /***********************************************************************/ /* Add a char pointer element to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, void *p) - { +{ if (Type != TYPE_PCHAR) { sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR"); return true; - } // endif Type - - if (trace(1)) - htrc(" adding pointer(%d): %p\n", Nval, p); + } // endif Type + xtrc(1, " adding pointer(%d): %p\n", Nval, p); Vblp->SetValue((PSZ)p, Nval++); return false; - } // end of AddValue +} // end of AddValue /***********************************************************************/ /* Add a short integer element to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, short n) - { +{ if (Type != TYPE_SHORT) { sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "SHORT"); return true; - } // endif Type - - if (trace(1)) - htrc(" adding SHORT(%d): %hd\n", Nval, n); + } // endif Type -//Value->SetValue(n); -//Vblp->SetValue(valp, Nval++); + xtrc(1, " adding SHORT(%d): %hd\n", Nval, n); Vblp->SetValue(n, Nval++); return false; - } // end of AddValue +} // end of AddValue /***********************************************************************/ /* Add an integer element to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, int n) - { +{ if (Type != TYPE_INT) { sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "INTEGER"); return true; - } // endif Type + } // endif Type - if (trace(1)) - htrc(" adding int(%d): %d\n", Nval, n); - -//Value->SetValue(n); -//Vblp->SetValue(valp, Nval++); + xtrc(1, " adding int(%d): %d\n", Nval, n); Vblp->SetValue(n, Nval++); return false; - } // end of AddValue +} // end of AddValue /***********************************************************************/ /* Add a double float element to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, double d) - { +{ if (Type != TYPE_DOUBLE) { sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "DOUBLE"); return true; - } // endif Type - - if (trace(1)) - htrc(" adding float(%d): %lf\n", Nval, d); + } // endif Type + xtrc(1, " adding float(%d): %lf\n", Nval, d); Value->SetValue(d); Vblp->SetValue(Value, Nval++); return false; - } // end of AddValue +} // end of AddValue /***********************************************************************/ /* Add the value of a XOBJECT block to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, PXOB xp) - { - if (Type != xp->GetResultType()) { - sprintf(g->Message, MSG(ADD_BAD_TYPE), - GetTypeName(xp->GetResultType()), GetTypeName(Type)); - return true; - } // endif Type - - if (trace(1)) - htrc(" adding (%d) from xp=%p\n", Nval, xp); - -//AddValue(xp->GetValue()); - Vblp->SetValue(xp->GetValue(), Nval++); - return false; - } // end of AddValue +{ + if (Type != xp->GetResultType()) { + sprintf(g->Message, MSG(ADD_BAD_TYPE), + GetTypeName(xp->GetResultType()), GetTypeName(Type)); + return true; + } // endif Type + + xtrc(1, " adding (%d) from xp=%p\n", Nval, xp); + Vblp->SetValue(xp->GetValue(), Nval++); + return false; +} // end of AddValue /***********************************************************************/ /* Add a value to an array. */ /***********************************************************************/ bool ARRAY::AddValue(PGLOBAL g, PVAL vp) - { +{ if (Type != vp->GetType()) { sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(vp->GetType()), GetTypeName(Type)); return true; - } // endif Type - - if (trace(1)) - htrc(" adding (%d) from vp=%p\n", Nval, vp); + } // endif Type + xtrc(1, " adding (%d) from vp=%p\n", Nval, vp); Vblp->SetValue(vp, Nval++); return false; - } // end of AddValue +} // end of AddValue /***********************************************************************/ /* Retrieve the nth value of the array. */ @@ -973,7 +954,7 @@ /* MakeArrayList: Makes a value list from an SQL IN array (in work). */ /***********************************************************************/ PSZ ARRAY::MakeArrayList(PGLOBAL g) - { +{ char *p, *tp; int i; size_t z, len = 2; @@ -988,11 +969,9 @@ Value->SetValue_pvblk(Vblp, i); Value->Prints(g, tp, z); len += strlen(tp); - } // enfor i - - if (trace(1)) - htrc("Arraylist: len=%d\n", len); + } // enfor i + xtrc(1, "Arraylist: len=%d\n", len); p = (char *)PlugSubAlloc(g, NULL, len); strcpy(p, "("); @@ -1001,19 +980,17 @@ Value->Prints(g, tp, z); strcat(p, tp); strcat(p, (++i == Nval) ? ")" : ","); - } // enfor i - - if (trace(1)) - htrc("Arraylist: newlen=%d\n", strlen(p)); + } // enfor i + xtrc(1, "Arraylist: newlen=%d\n", strlen(p)); return p; - } // end of MakeArrayList +} // end of MakeArrayList /***********************************************************************/ /* Make file output of ARRAY contents. */ /***********************************************************************/ void ARRAY::Printf(PGLOBAL g, FILE *f, uint n) - { +{ char m[64]; int lim = MY_MIN(Nval,10); @@ -1035,19 +1012,19 @@ } else fprintf(f, "%sVALLST: numval=%d\n", m, Nval); - } // end of Printf +} // end of Printf /***********************************************************************/ /* Make string output of ARRAY contents. */ /***********************************************************************/ void ARRAY::Prints(PGLOBAL, char *ps, uint z) - { +{ if (z < 16) return; sprintf(ps, "ARRAY: type=%d\n", Type); // More to be implemented later - } // end of Prints +} // end of Prints /* -------------------------- Class MULAR ---------------------------- */ diff -Nru mariadb-10.1-10.1.41/storage/connect/block.h mariadb-10.1-10.1.43/storage/connect/block.h --- mariadb-10.1-10.1.41/storage/connect/block.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/block.h 2019-11-06 06:20:36.000000000 +0000 @@ -38,9 +38,7 @@ class DllExport BLOCK { public: void * operator new(size_t size, PGLOBAL g, void *p = NULL) { - if (trace(256)) - htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p); - + xtrc(256, "New BLOCK: size=%d g=%p p=%p\n", size, g, p); return (PlugSubAlloc(g, p, size)); } // end of new diff -Nru mariadb-10.1-10.1.41/storage/connect/CMakeLists.txt mariadb-10.1-10.1.43/storage/connect/CMakeLists.txt --- mariadb-10.1-10.1.41/storage/connect/CMakeLists.txt 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/CMakeLists.txt 2019-11-06 06:20:36.000000000 +0000 @@ -73,7 +73,15 @@ tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h) # Add exception handling to the CONNECT project) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD") SET(IPHLPAPI_LIBRARY iphlpapi.lib) + IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang)) + # Connect does not work with clang-cl + RETURN() + ENDIF() ENDIF(UNIX) @@ -114,7 +122,6 @@ FIND_PACKAGE(LibXml2) IF (LIBXML2_FOUND) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) - SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h) add_definitions(-DLIBXML2_SUPPORT) @@ -309,6 +316,30 @@ # +# REST +# + +OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON) + +IF(CONNECT_WITH_REST) + MESSAGE(STATUS "=====> REST support is ON") + FIND_PACKAGE(cpprestsdk) + IF (cpprestsdk_FOUND) + MESSAGE(STATUS "=====> cpprestsdk found") + IF(UNIX) +# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR}) +# If needed edit next line to set the path to libcpprest.so + SET(REST_LIBRARY -lcpprest) + MESSAGE (STATUS ${REST_LIBRARY}) + ENDIF(UNIX) + SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h) + add_definitions(-DREST_SUPPORT) + ELSE(NOT cpprestsdk_FOUND) + MESSAGE(STATUS "=====> cpprestsdk package not found") + ENDIF (cpprestsdk_FOUND) +ENDIF(CONNECT_WITH_REST) + +# # XMAP # @@ -327,24 +358,16 @@ COMPONENT connect-engine RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} - ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY}) + ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY} ${REST_LIBRARY}) IF(NOT TARGET connect) RETURN() ENDIF() -# Don't link with bundled zlib and systel libxml2 at the same time. -# System libxml2 uses system zlib, might conflict with the bundled one. -IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB) - GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES) - LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR}) - SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS}) -ENDIF() - IF(WIN32) IF (libmongoc-1.0_FOUND) - SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS - "/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll") + SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS + "/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll") ENDIF(libmongoc-1.0_FOUND) ENDIF(WIN32) @@ -371,3 +394,4 @@ ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) ENDIF() + diff -Nru mariadb-10.1-10.1.41/storage/connect/connect.cc mariadb-10.1-10.1.43/storage/connect/connect.cc --- mariadb-10.1-10.1.41/storage/connect/connect.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/connect.cc 2019-11-06 06:20:36.000000000 +0000 @@ -33,6 +33,7 @@ /* plgdbsem.h is header containing the DB applic. declarations. */ /***********************************************************************/ #define DONT_DEFINE_VOID +#include #include "handler.h" #undef OFFSET diff -Nru mariadb-10.1-10.1.41/storage/connect/connect.h mariadb-10.1-10.1.43/storage/connect/connect.h --- mariadb-10.1-10.1.41/storage/connect/connect.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/connect.h 2019-11-06 06:20:36.000000000 +0000 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /**************** Cnt H Declares Source Code File (.H) *****************/ /* Name: CONNECT.H Version 2.4 */ diff -Nru mariadb-10.1-10.1.41/storage/connect/global.h mariadb-10.1-10.1.43/storage/connect/global.h --- mariadb-10.1-10.1.41/storage/connect/global.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/global.h 2019-11-06 06:20:36.000000000 +0000 @@ -224,6 +224,7 @@ DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport void *MakePtr(void *, OFFSET); DllExport void htrc(char const *fmt, ...); +DllExport void xtrc(uint, char const* fmt, ...); DllExport uint GetTraceValue(void); #if defined(__cplusplus) diff -Nru mariadb-10.1-10.1.41/storage/connect/ha_connect.cc mariadb-10.1-10.1.43/storage/connect/ha_connect.cc --- mariadb-10.1-10.1.41/storage/connect/ha_connect.cc 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/ha_connect.cc 2019-11-06 06:20:36.000000000 +0000 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file ha_connect.cc @@ -164,15 +164,15 @@ /***********************************************************************/ /* Initialize the ha_connect static members. */ /***********************************************************************/ -#define SZCONV 8192 +#define SZCONV 1024 // Default converted text size #define SZWORK 67108864 // Default work area size 64M #define SZWMIN 4194304 // Minimum work area size 4M #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.06.0009 January 27, 2019"; + char version[]= "Version 1.06.0010 June 01, 2019"; #if defined(__WIN__) - char compver[]= "Version 1.06.0009 " __DATE__ " " __TIME__; + char compver[]= "Version 1.06.0010 " __DATE__ " " __TIME__; char slash= '\\'; #else // !__WIN__ char slash= '/'; @@ -211,14 +211,14 @@ { char buf[1024]; bool b; - THD *thd = current_thd; - CHARSET_INFO *cs = system_charset_info; - String *str = NULL, tmp(buf, sizeof(buf), cs); - HASH uvars = thd->user_vars; - user_var_entry *uvar = (user_var_entry*)my_hash_search(&uvars, varname, 0); + THD *thd= current_thd; + CHARSET_INFO *cs= system_charset_info; + String *str= NULL, tmp(buf, sizeof(buf), cs); + HASH uvars= thd->user_vars; + user_var_entry *uvar= (user_var_entry*)my_hash_search(&uvars, varname, 0); if (uvar) - str = uvar->val_str(&b, &tmp, NOT_FIXED_DEC); + str= uvar->val_str(&b, &tmp, NOT_FIXED_DEC); return str ? PlugDup(g, str->ptr()) : NULL; }; // end of GetUserVariable @@ -231,6 +231,9 @@ PQRYRES VirColumns(PGLOBAL g, bool info); PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info); PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info); +#if defined(REST_SUPPORT) +PQRYRES RESTColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); +#endif // REST_SUPPORT #if defined(JAVA_SUPPORT) PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ url, PTOS topt, bool info); #endif // JAVA_SUPPORT @@ -238,7 +241,9 @@ void PushWarning(PGLOBAL g, THD *thd, int level); bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, PCSZ host, PCSZ db, PCSZ tab, PCSZ src, int port); +#if defined(ZIP_SUPPORT) bool ZipLoadFile(PGLOBAL, PCSZ, PCSZ, PCSZ, bool, bool); +#endif // ZIP_SUPPORT bool ExactInfo(void); #if defined(CMGO_SUPPORT) //void mongo_init(bool); @@ -352,7 +357,7 @@ static MYSQL_THDVAR_INT(conv_size, PLUGIN_VAR_RQCMDARG, // opt "Size used when converting TEXT columns.", - NULL, NULL, SZCONV, 0, 65500, 8192); + NULL, NULL, SZCONV, 0, 65500, 1); /** Type conversion: @@ -583,7 +588,9 @@ HA_TOPTION_STRING("FILTER", filter), HA_TOPTION_STRING("OPTION_LIST", oplist), HA_TOPTION_STRING("DATA_CHARSET", data_charset), - HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1), + HA_TOPTION_STRING("HTTP", http), + HA_TOPTION_STRING("URI", uri), + HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1), HA_TOPTION_NUMBER("BLOCK_SIZE", elements, 0, 0, INT_MAX32, 1), //HA_TOPTION_NUMBER("ESTIMATE", estimate, 0, 0, INT_MAX32, 1), HA_TOPTION_NUMBER("MULTIPLE", multiple, 0, 0, 3, 1), @@ -991,11 +998,11 @@ pthread_mutex_unlock(&usrmut); if (!xp) { - xp = new user_connect(thd); + xp= new user_connect(thd); if (xp->user_init()) { delete xp; - xp = NULL; + xp= NULL; } // endif user_init } // endif xp @@ -1027,6 +1034,19 @@ if (type == TAB_UNDEF) type= pos->srcdef ? TAB_MYSQL : pos->tabname ? TAB_PRX : TAB_DOS; +#if defined(REST_SUPPORT) + else if (pos->http) + switch (type) { + case TAB_JSON: + case TAB_XML: + case TAB_CSV: + type = TAB_REST; + break; + case TAB_REST: + type = TAB_NIY; + break; + } // endswitch type +#endif // REST_SUPPORT } else type= TAB_UNDEF; @@ -1130,48 +1150,48 @@ return (char*)def; char key[16], val[256]; - char *pv, *pn, *pk = (char*)oplist; - PCSZ opval = def; + char *pv, *pn, *pk= (char*)oplist; + PCSZ opval= def; int n; while (*pk == ' ') pk++; - for (; pk; pk = pn) { - pn = strchr(pk, ','); - pv = strchr(pk, '='); + for (; pk; pk= pn) { + pn= strchr(pk, ','); + pv= strchr(pk, '='); if (pv && (!pn || pv < pn)) { - n = MY_MIN(static_cast(pv - pk), sizeof(key) - 1); + n= MY_MIN(static_cast(pv - pk), sizeof(key) - 1); memcpy(key, pk, n); while (n && key[n - 1] == ' ') n--; - key[n] = 0; + key[n]= 0; while (*(++pv) == ' '); - n = MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); + n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1); memcpy(val, pv, n); while (n && val[n - 1] == ' ') n--; - val[n] = 0; + val[n]= 0; } else { - n = MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); + n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1); memcpy(key, pk, n); while (n && key[n - 1] == ' ') n--; - key[n] = 0; - val[0] = 0; + key[n]= 0; + val[0]= 0; } // endif pv if (!stricmp(opname, key)) { - opval = PlugDup(g, val); + opval= PlugDup(g, val); break; } else if (!pn) break; @@ -1219,9 +1239,13 @@ else if (!stricmp(opname, "Colist")) opval= options->colist; else if (!stricmp(opname, "Filter")) - opval = options->filter; + opval= options->filter; else if (!stricmp(opname, "Data_charset")) opval= options->data_charset; + else if (!stricmp(opname, "Http") || !stricmp(opname, "URL")) + opval = options->http; + else if (!stricmp(opname, "Uri")) + opval = options->uri; if (!opval && options->oplist) opval= GetListOption(g, opname, options->oplist); @@ -1252,7 +1276,7 @@ else if (!stricmp(opname, "Header")) opval= (options->header != 0); // Is Boolean for some table types else if (!stricmp(opname, "Zipped")) - opval = options->zipped; + opval= options->zipped; else if (options->oplist) if ((pv= GetListOption(g, opname, options->oplist))) opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0); @@ -1317,7 +1341,7 @@ { char *sv; - if (IsPartitioned() && s && partname && *partname) { + if (IsPartitioned() && s && *partname) { sv= (char*)PlugSubAlloc(xp->g, NULL, 0); sprintf(sv, s, partname); PlugSubAlloc(xp->g, NULL, strlen(sv) + 1); @@ -1346,8 +1370,8 @@ } else if (!stricmp(opname, "Query_String")) { // This escapes everything and returns a wrong query -// opval = thd_query_string(table->in_use)->str; - opval = (PCSZ)PlugSubAlloc(xp->g, NULL, +// opval= thd_query_string(table->in_use)->str; + opval= (PCSZ)PlugSubAlloc(xp->g, NULL, thd_query_string(table->in_use)->length + 1); strcpy((char*)opval, thd_query_string(table->in_use)->str); // sprintf((char*)opval, "%s", thd_query_string(table->in_use)->str); @@ -1368,7 +1392,7 @@ || !stricmp(opname, "filename") || !stricmp(opname, "optname") || !stricmp(opname, "entry"))) - opval = GetRealString(opval); + opval= GetRealString(opval); if (!opval) { if (sdef && !strcmp(sdef, "*")) { @@ -1497,7 +1521,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) { const char *cp; - char *chset, v = 0; + char *chset, v= 0; ha_field_option_struct *fop; Field* fp; Field* *fldp; @@ -1549,7 +1573,7 @@ pcf->Fieldfmt= NULL; } // endif fop - chset = (char *)fp->charset()->name; + chset= (char *)fp->charset()->name; switch (fp->type()) { case MYSQL_TYPE_BLOB: @@ -1817,7 +1841,7 @@ { const char *path= tshp ? tshp->path.str : table_share->path.str; const char *name= strrchr(path, slash); - return name ? name+1 : path; + return name ? name + 1 : path; } // end of GetTableName char *ha_connect::GetPartName(void) @@ -2055,10 +2079,10 @@ } catch (int n) { if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); - brc = true; + brc= true; } catch (const char *msg) { strcpy(g->Message, msg); - brc = true; + brc= true; } // end catch return brc; @@ -2185,9 +2209,9 @@ rc= fp->store(p, strlen(p), charset, CHECK_FIELD_WARN); break; case TYPE_BIN: - p = value->GetCharValue(); - charset = &my_charset_bin; - rc = fp->store(p, strlen(p), charset, CHECK_FIELD_WARN); + p= value->GetCharValue(); + charset= &my_charset_bin; + rc= fp->store(p, strlen(p), charset, CHECK_FIELD_WARN); break; case TYPE_DOUBLE: rc= fp->store(value->GetFloatValue()); @@ -2436,7 +2460,7 @@ kfp= &table->key_info[active_index]; old_map= dbug_tmp_use_all_columns(table, table->write_set); - for (i = 0; i <= 1; i++) { + for (i= 0; i <= 1; i++) { if (ranges[i] == NULL) continue; @@ -2547,7 +2571,7 @@ switch (vop) { case OP_EQ: - val= " = "; + val= "= "; break; case OP_NE: val= " <> "; @@ -2817,7 +2841,7 @@ /***********************************************************************/ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) { - AMT tty = filp->Type; + AMT tty= filp->Type; char *body= filp->Body; char *havg= filp->Having; unsigned int i; @@ -2834,7 +2858,7 @@ if (cond->type() == COND::COND_ITEM) { char *pb0, *pb1, *pb2, *ph0= 0, *ph1= 0, *ph2= 0; - bool bb = false, bh = false; + bool bb= false, bh= false; Item_cond *cond_item= (Item_cond *)cond; if (x) @@ -2893,13 +2917,13 @@ bb |= filp->Bd; bh |= filp->Hv; - filp->Bd = filp->Hv = false; + filp->Bd= filp->Hv= false; } else return NULL; if (bb) { strcpy(pb1, ")"); - filp->Bd = bb; + filp->Bd= bb; } else *pb0= 0; @@ -2907,13 +2931,13 @@ if (bb && bh && vop == OP_OR) { // Cannot or'ed a where clause with a having clause bb= bh= 0; - *pb0 = 0; - *ph0 = 0; + *pb0= 0; + *ph0= 0; } else if (bh) { strcpy(ph1, ")"); filp->Hv= bh; } else - *ph0 = 0; + *ph0= 0; } // endif havg @@ -2926,7 +2950,7 @@ Item_func *condf= (Item_func *)cond; Item* *args= condf->arguments(); - filp->Bd = filp->Hv = false; + filp->Bd= filp->Hv= false; if (trace(1)) htrc("Func type=%d argnum=%d\n", condf->functype(), @@ -2942,10 +2966,10 @@ case Item_func::GT_FUNC: vop= OP_GT; break; case Item_func::LIKE_FUNC: vop= OP_LIKE; - neg = ((Item_func_opt_neg *)condf)->negated; + neg= ((Item_func_opt_neg *)condf)->negated; break; case Item_func::ISNOTNULL_FUNC: - neg = true; + neg= true; // fall through case Item_func::ISNULL_FUNC: vop= OP_NULL; break; case Item_func::IN_FUNC: vop= OP_IN; /* fall through */ @@ -3003,12 +3027,12 @@ } else { bool h; - fnm = filp->Chk(pField->field->field_name, &h); + fnm= filp->Chk(pField->field->field_name, &h); if (h && i && !ishav) return NULL; // Having should be col VOP arg else - ishav = h; + ishav= h; } // endif's @@ -3059,7 +3083,7 @@ if (!x) { const char *p; - char *s = (ishav) ? havg : body; + char *s= (ishav) ? havg : body; uint j, k, n; // Append the value to the filter @@ -3116,37 +3140,37 @@ strcat(s, "'}"); break; default: - j = strlen(s); - s[j++] = '\''; - p = res->ptr(); - n = res->length(); + j= strlen(s); + s[j++]= '\''; + p= res->ptr(); + n= res->length(); - for (k = 0; k < n; k++) { + for (k= 0; k < n; k++) { if (p[k] == '\'') - s[j++] = '\''; + s[j++]= '\''; - s[j++] = p[k]; + s[j++]= p[k]; } // endfor k - s[j++] = '\''; - s[j] = 0; + s[j++]= '\''; + s[j]= 0; } // endswitch field type } else { - j = strlen(s); - s[j++] = '\''; - p = res->ptr(); - n = res->length(); + j= strlen(s); + s[j++]= '\''; + p= res->ptr(); + n= res->length(); - for (k = 0; k < n; k++) { + for (k= 0; k < n; k++) { if (p[k] == '\'') - s[j++] = '\''; + s[j++]= '\''; - s[j++] = p[k]; + s[j++]= p[k]; } // endfor k - s[j++] = '\''; - s[j] = 0; + s[j++]= '\''; + s[j]= 0; } // endif tty break; @@ -3170,7 +3194,7 @@ } // endif's Type if (!x) { - char *s = (ishav) ? havg : body; + char *s= (ishav) ? havg : body; if (!i) strcat(s, GetValStr(vop, neg)); @@ -3184,11 +3208,11 @@ } // endfor i if (x) - filp->Op = vop; + filp->Op= vop; else if (ishav) - filp->Hv = true; + filp->Hv= true; else - filp->Bd = true; + filp->Bd= true; } else { if (trace(1)) @@ -3238,21 +3262,21 @@ PCFIL filp; int rc; - if ((filp = tdbp->GetCondFil()) && tdbp->GetCond() == cond && + if ((filp= tdbp->GetCondFil()) && tdbp->GetCond() == cond && filp->Idx == active_index && filp->Type == tty) goto fin; - filp = new(g) CONDFIL(active_index, tty); - rc = filp->Init(g, this); + filp= new(g) CONDFIL(active_index, tty); + rc= filp->Init(g, this); if (rc == RC_INFO) { - filp->Having = (char*)PlugSubAlloc(g, NULL, 256); - *filp->Having = 0; + filp->Having= (char*)PlugSubAlloc(g, NULL, 256); + *filp->Having= 0; } else if (rc == RC_FX) goto fin; - filp->Body = (char*)PlugSubAlloc(g, NULL, (x) ? 128 : 0); - *filp->Body = 0; + filp->Body= (char*)PlugSubAlloc(g, NULL, (x) ? 128 : 0); + *filp->Body= 0; if (CheckCond(g, filp, cond)) { if (filp->Having && strlen(filp->Having) > 255) @@ -3266,7 +3290,7 @@ if (!x) PlugSubAlloc(g, NULL, strlen(filp->Body) + 1); else - cond = NULL; // Does this work? + cond= NULL; // Does this work? tdbp->SetCondFil(filp); } else if (x && cond) @@ -3316,8 +3340,8 @@ int ha_connect::check(THD* thd, HA_CHECK_OPT* check_opt) { - int rc = HA_ADMIN_OK; - PGLOBAL g = ((table && table->in_use) ? GetPlug(table->in_use, xp) : + int rc= HA_ADMIN_OK; + PGLOBAL g= ((table && table->in_use) ? GetPlug(table->in_use, xp) : (xp) ? xp->g : NULL); DBUG_ENTER("ha_connect::check"); @@ -3327,32 +3351,32 @@ // Do not close the table if it was opened yet (possible?) if (IsOpened()) { if (IsPartitioned() && CheckColumnList(g)) // map can have been changed - rc = HA_ADMIN_CORRUPT; + rc= HA_ADMIN_CORRUPT; else if (tdbp->OpenDB(g)) // Rewind table - rc = HA_ADMIN_CORRUPT; + rc= HA_ADMIN_CORRUPT; } else if (xp->CheckQuery(valid_query_id)) { - tdbp = NULL; // Not valid anymore + tdbp= NULL; // Not valid anymore if (OpenTable(g, false)) - rc = HA_ADMIN_CORRUPT; + rc= HA_ADMIN_CORRUPT; } else // possible? DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); if (rc == HA_ADMIN_OK) { - TABTYPE type = GetTypeID(GetStringOption("Type", "*")); + TABTYPE type= GetTypeID(GetStringOption("Type", "*")); if (IsFileType(type)) { if (check_opt->flags & T_MEDIUM) { // TO DO do { - if ((rc = CntReadNext(g, tdbp)) == RC_FX) + if ((rc= CntReadNext(g, tdbp)) == RC_FX) break; } while (rc != RC_EF); - rc = (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT; + rc= (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT; } else if (check_opt->flags & T_EXTEND) { // TO DO } // endif's flags @@ -3380,7 +3404,7 @@ DBUG_ENTER("ha_connect::get_error_message"); if (xp && xp->g) { - PGLOBAL g = xp->g; + PGLOBAL g= xp->g; if (trace(1)) htrc("GEM(%d): %s\n", error, g->Message); @@ -3489,32 +3513,32 @@ try { // Ignore error on the opt file dup->Check &= ~CHK_OPT; - tdbp = GetTDB(g); + tdbp= GetTDB(g); dup->Check |= CHK_OPT; if (tdbp && !tdbp->IsRemote()) { - bool dop = IsTypeIndexable(GetRealType(NULL)); - bool dox = (tdbp->GetDef()->Indexable() == 1); + bool dop= IsTypeIndexable(GetRealType(NULL)); + bool dox= (tdbp->GetDef()->Indexable() == 1); - if ((rc = ((PTDBASE)tdbp)->ResetTableOpt(g, dop, dox))) { + if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, dop, dox))) { if (rc == RC_INFO) { push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); - rc = 0; + rc= 0; } else - rc = HA_ERR_CRASHED_ON_USAGE; // Table must be repaired + rc= HA_ERR_CRASHED_ON_USAGE; // Table must be repaired } // endif rc } else if (!tdbp) - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; } catch (int n) { if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; } catch (const char *msg) { strcpy(g->Message, msg); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; } // end catch if (rc) @@ -4214,7 +4238,7 @@ tdbp->SetFilter(NULL); rc= rnd_next(buf); } else { - PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp); + PGLOBAL g= GetPlug((table) ? table->in_use : NULL, xp); // strcpy(g->Message, "Not supported by this table type"); my_message(ER_ILLEGAL_HA, g->Message, MYF(0)); rc= HA_ERR_INTERNAL_ERROR; @@ -4298,12 +4322,12 @@ } else DBUG_RETURN(HA_ERR_INTERNAL_ERROR); // Should never happen - if (!(tdbp = GetTDB(g))) { + if (!(tdbp= GetTDB(g))) { my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); DBUG_RETURN(HA_ERR_INTERNAL_ERROR); } // endif tdbp - valid_info = false; + valid_info= false; } // endif tdbp if (!valid_info) { @@ -4446,6 +4470,7 @@ case TAB_XML: case TAB_INI: case TAB_VEC: + case TAB_REST: case TAB_JSON: if (options->filename && *options->filename) { if (!quick) { @@ -4582,13 +4607,13 @@ // newmode= MODE_UPDATE; // To be checked // break; case SQLCOM_DELETE_MULTI: - *cras = true; + *cras= true; case SQLCOM_DELETE: case SQLCOM_TRUNCATE: newmode= MODE_DELETE; break; case SQLCOM_UPDATE_MULTI: - *cras = true; + *cras= true; case SQLCOM_UPDATE: newmode= MODE_UPDATE; break; @@ -4616,7 +4641,7 @@ break; // } // endif partitioned case SQLCOM_REPAIR: // TODO implement it - newmode = MODE_UPDATE; + newmode= MODE_UPDATE; break; default: htrc("Unsupported sql_command=%d\n", thd_sql_command(thd)); @@ -4731,15 +4756,15 @@ if (CloseTable(g)) { // Make error a warning to avoid crash push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); - rc = 0; + rc= 0; } // endif Close - locked = 0; - xmod = MODE_ANY; // For info commands + locked= 0; + xmod= MODE_ANY; // For info commands DBUG_RETURN(rc); } // endif MODE_ANY - newmode = CheckMode(g, thd, newmode, &chk, &cras); + newmode= CheckMode(g, thd, newmode, &chk, &cras); if (newmode == MODE_ERROR) DBUG_RETURN(HA_ERR_INTERNAL_ERROR); @@ -4815,7 +4840,7 @@ DBUG_RETURN(0); } else if (g->Xchk) { if (!tdbp) { - if (!(tdbp = GetTDB(g))) { + if (!(tdbp= GetTDB(g))) { // DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); DBUG_RETURN(0); @@ -4952,7 +4977,7 @@ int ha_connect::check_stmt(PGLOBAL g, MODE newmode, bool cras) { - int rc = 0; + int rc= 0; DBUG_ENTER("ha_connect::check_stmt"); // If this is the start of a new query, cleanup the previous one @@ -5039,7 +5064,7 @@ { if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) lock.type=lock_type; - *to++ = &lock; + *to++= &lock; return to; } @@ -5316,7 +5341,7 @@ int dec, char *key, uint tm, const char *rem, char *dft, char *xtra, char *fmt, int flag, bool dbf, char v) { - char var = (len > 255) ? 'V' : v; + char var= (len > 255) ? 'V' : v; bool q, error= false; const char *type= PLGtoMYSQLtype(typ, dbf, var); @@ -5360,9 +5385,9 @@ error|= sql->append(" DEFAULT "); if (typ == TYPE_DATE) - q = (strspn(dft, "0123456789 -:/") == strlen(dft)); + q= (strspn(dft, "0123456789 -:/") == strlen(dft)); else - q = !IsTypeNum(typ); + q= !IsTypeNum(typ); if (q) { error|= sql->append("'"); @@ -5514,13 +5539,13 @@ PCSZ fncn= "?"; PCSZ user, fn, db, host, pwd, sep, tbl, src; PCSZ col, ocl, rnk, pic, fcl, skc, zfn; - char *tab, *dsn, *shm, *dpath; + char *tab, *dsn, *shm, *dpath, *url; #if defined(__WIN__) PCSZ nsp= NULL, cls= NULL; #endif // __WIN__ //int hdr, mxe; - int port = 0, mxr = 0, rc = 0, mul = 0, lrecl = 0; -//PCSZ tabtyp = NULL; + int port= 0, mxr= 0, rc= 0, mul= 0, lrecl= 0; +//PCSZ tabtyp= NULL; #if defined(ODBC_SUPPORT) POPARM sop= NULL; PCSZ ucnc= NULL; @@ -5530,7 +5555,6 @@ #if defined(JAVA_SUPPORT) PJPARM sjp= NULL; PCSZ driver= NULL; - char *url= NULL; #endif // JAVA_SUPPORT uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); bool bif, ok= false, dbf= false; @@ -5550,7 +5574,8 @@ String sql(buf, sizeof(buf), system_charset_info); sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info); - user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= zfn= dsn= NULL; + user = host = pwd = tbl = src = col = ocl = pic = fcl = skc = rnk = zfn = NULL; + dsn = url = NULL; // Get the useful create options ttp= GetTypeID(topt->type); @@ -5561,7 +5586,7 @@ fncn= topt->catfunc; fnc= GetFuncID(fncn); sep= topt->separator; - mul = (int)topt->multiple; + mul= (int)topt->multiple; tbl= topt->tablist; col= topt->colist; @@ -5584,7 +5609,7 @@ #endif // __WIN__ port= atoi(GetListOption(g, "port", topt->oplist, "0")); #if defined(ODBC_SUPPORT) -// tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL); +// tabtyp= GetListOption(g, "Tabtype", topt->oplist, NULL); mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0")); cto= atoi(GetListOption(g,"ConnectTimeout", topt->oplist, "-1")); qto= atoi(GetListOption(g,"QueryTimeout", topt->oplist, "-1")); @@ -5599,7 +5624,7 @@ cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0")); #endif // PROMPT_OK #if defined(ZIP_SUPPORT) - zfn = GetListOption(g, "Zipfile", topt->oplist, NULL); + zfn= GetListOption(g, "Zipfile", topt->oplist, NULL); #endif // ZIP_SUPPORT } else { host= "localhost"; @@ -5612,14 +5637,24 @@ try { // Check table type if (ttp == TAB_UNDEF) { - topt->type = (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS"; - ttp = GetTypeID(topt->type); + topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS"; + ttp= GetTypeID(topt->type); sprintf(g->Message, "No table_type. Was set to %s", topt->type); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); } else if (ttp == TAB_NIY) { sprintf(g->Message, "Unsupported table type %s", topt->type); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; +#if defined(REST_SUPPORT) + } else if (topt->http) { + switch (ttp) { + case TAB_JSON: + case TAB_XML: + case TAB_CSV: + ttp = TAB_REST; + break; + } // endswitch type +#endif // REST_SUPPORT } // endif ttp if (!tab) { @@ -5629,39 +5664,39 @@ if (!tbl) { strcpy(g->Message, "Missing table list"); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif tbl - tab = PlugDup(g, tbl); + tab= PlugDup(g, tbl); - if ((p = strchr(tab, ','))) - *p = 0; + if ((p= strchr(tab, ','))) + *p= 0; - if ((p = strchr(tab, '.'))) { - *p = 0; - db = tab; - tab = p + 1; + if ((p= strchr(tab, '.'))) { + *p= 0; + db= tab; + tab= p + 1; } // endif p } else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL))) - tab = (char*)table_s->table_name.str; // Default value + tab= (char*)table_s->table_name.str; // Default value } // endif tab switch (ttp) { #if defined(ODBC_SUPPORT) case TAB_ODBC: - dsn = strz(g, create_info->connect_string); + dsn= strz(g, create_info->connect_string); if (fnc & (FNC_DSN | FNC_DRIVER)) { - ok = true; + ok= true; #if defined(PROMPT_OK) } else if (!stricmp(thd->main_security_ctx.host, "localhost") && cop == 1) { - if ((dsn = ODBCCheckConnection(g, dsn, cop)) != NULL) { + if ((dsn= ODBCCheckConnection(g, dsn, cop)) != NULL) { thd->make_lex_string(&create_info->connect_string, dsn, strlen(dsn)); - ok = true; + ok= true; } // endif dsn #endif // PROMPT_OK @@ -5669,13 +5704,13 @@ sprintf(g->Message, "Missing %s connection string", topt->type); } else { // Store ODBC additional parameters - sop = (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM)); - sop->User = (char*)user; - sop->Pwd = (char*)pwd; - sop->Cto = cto; - sop->Qto = qto; - sop->UseCnc = cnc; - ok = true; + sop= (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM)); + sop->User= (char*)user; + sop->Pwd= (char*)pwd; + sop->Cto= cto; + sop->Qto= qto; + sop->UseCnc= cnc; + ok= true; } // endif's supfnc |= (FNC_TABLE | FNC_DSN | FNC_DRIVER); @@ -5684,31 +5719,31 @@ #if defined(JAVA_SUPPORT) case TAB_JDBC: if (fnc & FNC_DRIVER) { - ok = true; - } else if (!(url = strz(g, create_info->connect_string))) { + ok= true; + } else if (!(url= strz(g, create_info->connect_string))) { strcpy(g->Message, "Missing URL"); } else { // Store JDBC additional parameters int rc; - PJDBCDEF jdef = new(g) JDBCDEF(); + PJDBCDEF jdef= new(g) JDBCDEF(); jdef->SetName(create_info->alias); - sjp = (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM)); - sjp->Driver = driver; - // sjp->Properties = prop; - sjp->Fsize = 0; - sjp->Scrollable = false; - - if ((rc = jdef->ParseURL(g, url, false)) == RC_OK) { - sjp->Url = url; - sjp->User = (char*)user; - sjp->Pwd = (char*)pwd; - ok = true; + sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM)); + sjp->Driver= driver; + // sjp->Properties= prop; + sjp->Fsize= 0; + sjp->Scrollable= false; + + if ((rc= jdef->ParseURL(g, url, false)) == RC_OK) { + sjp->Url= url; + sjp->User= (char*)user; + sjp->Pwd= (char*)pwd; + ok= true; } else if (rc == RC_NF) { if (jdef->GetTabname()) - tab = (char*)jdef->GetTabname(); + tab= (char*)jdef->GetTabname(); - ok = jdef->SetParms(sjp); + ok= jdef->SetParms(sjp); } // endif rc } // endif's @@ -5717,7 +5752,7 @@ break; #endif // JAVA_SUPPORT case TAB_DBF: - dbf = true; + dbf= true; // fall through case TAB_CSV: if (!fn && fnc != FNC_NO) @@ -5725,55 +5760,55 @@ else if (sep && strlen(sep) > 1) sprintf(g->Message, "Invalid separator %s", sep); else - ok = true; + ok= true; break; case TAB_MYSQL: - ok = true; + ok= true; if (create_info->connect_string.str && create_info->connect_string.length) { - PMYDEF mydef = new(g) MYSQLDEF(); + PMYDEF mydef= new(g) MYSQLDEF(); - dsn = strz(g, create_info->connect_string); + dsn= strz(g, create_info->connect_string); mydef->SetName(create_info->alias); if (!mydef->ParseURL(g, dsn, false)) { if (mydef->GetHostname()) - host = mydef->GetHostname(); + host= mydef->GetHostname(); if (mydef->GetUsername()) - user = mydef->GetUsername(); + user= mydef->GetUsername(); if (mydef->GetPassword()) - pwd = mydef->GetPassword(); + pwd= mydef->GetPassword(); if (mydef->GetTabschema()) - db = mydef->GetTabschema(); + db= mydef->GetTabschema(); if (mydef->GetTabname()) - tab = (char*)mydef->GetTabname(); + tab= (char*)mydef->GetTabname(); if (mydef->GetPortnumber()) - port = mydef->GetPortnumber(); + port= mydef->GetPortnumber(); } else - ok = false; + ok= false; } else if (!user) - user = "root"; + user= "root"; if (ok && CheckSelf(g, table_s, host, db, tab, src, port)) - ok = false; + ok= false; break; #if defined(__WIN__) case TAB_WMI: - ok = true; + ok= true; break; #endif // __WIN__ case TAB_PIVOT: - supfnc = FNC_NO; + supfnc= FNC_NO; case TAB_PRX: case TAB_TBL: case TAB_XCL: @@ -5782,12 +5817,12 @@ (!db || !stricmp(db, table_s->db.str))) sprintf(g->Message, "A %s table cannot refer to itself", topt->type); else - ok = true; + ok= true; break; case TAB_OEM: if (topt->module && topt->subtype) - ok = true; + ok= true; else strcpy(g->Message, "Missing OEM module or subtype"); @@ -5796,24 +5831,33 @@ case TAB_XML: #endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT case TAB_JSON: - dsn = strz(g, create_info->connect_string); + dsn= strz(g, create_info->connect_string); if (!fn && !zfn && !mul && !dsn) sprintf(g->Message, "Missing %s file name", topt->type); else - ok = true; + ok= true; break; #if defined(JAVA_SUPPORT) case TAB_MONGO: if (!topt->tabname) - topt->tabname = tab; + topt->tabname= tab; - ok = true; + ok= true; break; #endif // JAVA_SUPPORT +#if defined(REST_SUPPORT) + case TAB_REST: + if (!topt->http) + sprintf(g->Message, "Missing %s HTTP address", topt->type); + else + ok = true; + + break; +#endif // REST_SUPPORT case TAB_VIR: - ok = true; + ok= true; break; default: sprintf(g->Message, "Cannot get column info for table type %s", topt->type); @@ -5824,12 +5868,12 @@ if (ok && !(supfnc & fnc)) { sprintf(g->Message, "Unsupported catalog function %s for table type %s", fncn, topt->type); - ok = false; + ok= false; } // endif supfnc if (src && fnc != FNC_NO) { strcpy(g->Message, "Cannot make catalog table from srcdef"); - ok = false; + ok= false; } // endif src if (ok) { @@ -5837,23 +5881,23 @@ char *dft, *xtra, *key, *fmt; int i, len, prec, dec, typ, flg; - if (!(dpath = SetPath(g, table_s->db.str))) { - rc = HA_ERR_INTERNAL_ERROR; + if (!(dpath= SetPath(g, table_s->db.str))) { + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif dpath if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC && ttp != TAB_JDBC) { - qrp = SrcColumns(g, host, db, user, pwd, src, port); + qrp= SrcColumns(g, host, db, user, pwd, src, port); if (qrp && ttp == TAB_OCCUR) if (OcrSrcCols(g, qrp, col, ocl, rnk)) { - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif OcrSrcCols } else switch (ttp) { case TAB_DBF: - qrp = DBFColumns(g, dpath, fn, fnc == FNC_COL); + qrp= DBFColumns(g, dpath, fn, fnc == FNC_COL); break; #if defined(ODBC_SUPPORT) case TAB_ODBC: @@ -5861,21 +5905,21 @@ case FNC_NO: case FNC_COL: if (src) { - qrp = ODBCSrcCols(g, dsn, (char*)src, sop); - src = NULL; // for next tests + qrp= ODBCSrcCols(g, dsn, (char*)src, sop); + src= NULL; // for next tests } else - qrp = ODBCColumns(g, dsn, shm, tab, NULL, + qrp= ODBCColumns(g, dsn, shm, tab, NULL, mxr, fnc == FNC_COL, sop); break; case FNC_TABLE: - qrp = ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop); + qrp= ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop); break; case FNC_DSN: - qrp = ODBCDataSources(g, mxr, true); + qrp= ODBCDataSources(g, mxr, true); break; case FNC_DRIVER: - qrp = ODBCDrivers(g, mxr, true); + qrp= ODBCDrivers(g, mxr, true); break; default: sprintf(g->Message, "invalid catfunc %s", fncn); @@ -5890,23 +5934,23 @@ case FNC_NO: case FNC_COL: if (src) { - qrp = JDBCSrcCols(g, (char*)src, sjp); - src = NULL; // for next tests + qrp= JDBCSrcCols(g, (char*)src, sjp); + src= NULL; // for next tests } else - qrp = JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp); + qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp); break; case FNC_TABLE: -// qrp = JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp); - qrp = JDBCTables(g, shm, tab, NULL, mxr, true, sjp); +// qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp); + qrp= JDBCTables(g, shm, tab, NULL, mxr, true, sjp); break; #if 0 case FNC_DSN: - qrp = JDBCDataSources(g, mxr, true); + qrp= JDBCDataSources(g, mxr, true); break; #endif // 0 case FNC_DRIVER: - qrp = JDBCDrivers(g, mxr, true); + qrp= JDBCDrivers(g, mxr, true); break; default: sprintf(g->Message, "invalid catfunc %s", fncn); @@ -5916,56 +5960,61 @@ break; #endif // JAVA_SUPPORT case TAB_MYSQL: - qrp = MyColumns(g, thd, host, db, user, pwd, tab, + qrp= MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, fnc == FNC_COL); break; case TAB_CSV: - qrp = CSVColumns(g, dpath, topt, fnc == FNC_COL); + qrp= CSVColumns(g, dpath, topt, fnc == FNC_COL); break; #if defined(__WIN__) case TAB_WMI: - qrp = WMIColumns(g, nsp, cls, fnc == FNC_COL); + qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL); break; #endif // __WIN__ case TAB_PRX: case TAB_TBL: case TAB_XCL: case TAB_OCCUR: - bif = fnc == FNC_COL; - qrp = TabColumns(g, thd, db, tab, bif); + bif= fnc == FNC_COL; + qrp= TabColumns(g, thd, db, tab, bif); if (!qrp && bif && fnc != FNC_COL) // tab is a view - qrp = MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false); + qrp= MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false); if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL) if (OcrColumns(g, qrp, col, ocl, rnk)) { - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif OcrColumns break; case TAB_PIVOT: - qrp = PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port); + qrp= PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port); break; case TAB_VIR: - qrp = VirColumns(g, fnc == FNC_COL); + qrp= VirColumns(g, fnc == FNC_COL); break; case TAB_JSON: - qrp = JSONColumns(g, db, dsn, topt, fnc == FNC_COL); + qrp= JSONColumns(g, db, dsn, topt, fnc == FNC_COL); break; #if defined(JAVA_SUPPORT) case TAB_MONGO: - url = strz(g, create_info->connect_string); - qrp = MGOColumns(g, db, url, topt, fnc == FNC_COL); + url= strz(g, create_info->connect_string); + qrp= MGOColumns(g, db, url, topt, fnc == FNC_COL); break; #endif // JAVA_SUPPORT #if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT) case TAB_XML: - qrp = XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL); + qrp= XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL); break; #endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT +#if defined(REST_SUPPORT) + case TAB_REST: + qrp = RESTColumns(g, topt, tab, (char *)db, fnc == FNC_COL); + break; +#endif // REST_SUPPORT case TAB_OEM: - qrp = OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL); + qrp= OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL); break; default: strcpy(g->Message, "System error during assisted discovery"); @@ -5973,33 +6022,33 @@ } // endswitch ttp if (!qrp) { - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif !qrp if (fnc != FNC_NO || src || ttp == TAB_PIVOT) { // Catalog like table - for (crp = qrp->Colresp; !rc && crp; crp = crp->Next) { - cnm = (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name); - typ = crp->Type; - len = crp->Length; - dec = crp->Prec; - flg = crp->Flag; - v = (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var; - tm = (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG; + for (crp= qrp->Colresp; !rc && crp; crp= crp->Next) { + cnm= (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name); + typ= crp->Type; + len= crp->Length; + dec= crp->Prec; + flg= crp->Flag; + v= (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var; + tm= (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG; if (!len && typ == TYPE_STRING) - len = 256; // STRBLK's have 0 length + len= 256; // STRBLK's have 0 length // Now add the field if (add_field(&sql, cnm, typ, len, dec, NULL, tm, NULL, NULL, NULL, NULL, flg, dbf, v)) - rc = HA_ERR_OUT_OF_MEM; + rc= HA_ERR_OUT_OF_MEM; } // endfor crp } else { - char *schem = NULL; - char *tn = NULL; + char *schem= NULL; + char *tn= NULL; // Not a catalog table if (!qrp->Nblin) { @@ -6008,57 +6057,57 @@ else strcpy(g->Message, "Fail to retrieve columns"); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif !nblin - for (i = 0; !rc && i < qrp->Nblin; i++) { - typ = len = prec = dec = 0; - tm = NOT_NULL_FLAG; - cnm = (char*)"noname"; - dft = xtra = key = fmt = tn = NULL; - v = ' '; - rem = NULL; + for (i= 0; !rc && i < qrp->Nblin; i++) { + typ= len= prec= dec= 0; + tm= NOT_NULL_FLAG; + cnm= (char*)"noname"; + dft= xtra= key= fmt= tn= NULL; + v= ' '; + rem= NULL; - for (crp = qrp->Colresp; crp; crp = crp->Next) + for (crp= qrp->Colresp; crp; crp= crp->Next) switch (crp->Fld) { case FLD_NAME: if (ttp == TAB_PRX || (ttp == TAB_CSV && topt->data_charset && (!stricmp(topt->data_charset, "UTF8") || !stricmp(topt->data_charset, "UTF-8")))) - cnm = crp->Kdata->GetCharValue(i); + cnm= crp->Kdata->GetCharValue(i); else - cnm = encode(g, crp->Kdata->GetCharValue(i)); + cnm= encode(g, crp->Kdata->GetCharValue(i)); break; case FLD_TYPE: - typ = crp->Kdata->GetIntValue(i); - v = (crp->Nulls) ? crp->Nulls[i] : 0; + typ= crp->Kdata->GetIntValue(i); + v= (crp->Nulls) ? crp->Nulls[i] : 0; break; case FLD_TYPENAME: - tn = crp->Kdata->GetCharValue(i); + tn= crp->Kdata->GetCharValue(i); break; case FLD_PREC: // PREC must be always before LENGTH - len = prec = crp->Kdata->GetIntValue(i); + len= prec= crp->Kdata->GetIntValue(i); break; case FLD_LENGTH: - len = crp->Kdata->GetIntValue(i); + len= crp->Kdata->GetIntValue(i); break; case FLD_SCALE: - dec = (!crp->Kdata->IsNull(i)) ? crp->Kdata->GetIntValue(i) : -1; + dec= (!crp->Kdata->IsNull(i)) ? crp->Kdata->GetIntValue(i) : -1; break; case FLD_NULL: if (crp->Kdata->GetIntValue(i)) - tm = 0; // Nullable + tm= 0; // Nullable break; case FLD_FORMAT: - fmt = (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL; + fmt= (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL; break; case FLD_REM: - rem = crp->Kdata->GetCharValue(i); + rem= crp->Kdata->GetCharValue(i); break; // case FLD_CHARSET: // No good because remote table is already translated @@ -6067,19 +6116,19 @@ // break; case FLD_DEFAULT: - dft = crp->Kdata->GetCharValue(i); + dft= crp->Kdata->GetCharValue(i); break; case FLD_EXTRA: - xtra = crp->Kdata->GetCharValue(i); + xtra= crp->Kdata->GetCharValue(i); // Auto_increment is not supported yet if (!stricmp(xtra, "AUTO_INCREMENT")) - xtra = NULL; + xtra= NULL; break; case FLD_KEY: if (ttp == TAB_VIR) - key = crp->Kdata->GetCharValue(i); + key= crp->Kdata->GetCharValue(i); break; case FLD_SCHEM: @@ -6088,10 +6137,10 @@ if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) { sprintf(g->Message, "Several %s tables found, specify DBNAME", tab); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } else if (!schem) - schem = crp->Kdata->GetCharValue(i); + schem= crp->Kdata->GetCharValue(i); } // endif ttp #endif // ODBC_SUPPORT || JAVA_SUPPORT @@ -6102,10 +6151,10 @@ #if defined(ODBC_SUPPORT) if (ttp == TAB_ODBC) { int plgtyp; - bool w = false; // Wide character type + bool w= false; // Wide character type // typ must be PLG type, not SQL type - if (!(plgtyp = TranslateSQLType(typ, dec, prec, v, w))) { + if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) { if (GetTypeConv() == TPC_SKIP) { // Skip this column sprintf(g->Message, "Column %s skipped (unsupported type %d)", @@ -6114,12 +6163,12 @@ continue; } else { sprintf(g->Message, "Unsupported SQL type %d", typ); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif type_conv } else - typ = plgtyp; + typ= plgtyp; switch (typ) { case TYPE_STRING: @@ -6134,10 +6183,10 @@ prec += (dec + 2); // To be safe break; case TYPE_DECIM: - prec = len; + prec= len; break; default: - dec = 0; + dec= 0; } // endswitch typ } else @@ -6147,7 +6196,7 @@ int plgtyp; // typ must be PLG type, not SQL type - if (!(plgtyp = TranslateJDBCType(typ, tn, dec, prec, v))) { + if (!(plgtyp= TranslateJDBCType(typ, tn, dec, prec, v))) { if (GetTypeConv() == TPC_SKIP) { // Skip this column sprintf(g->Message, "Column %s skipped (unsupported type %d)", @@ -6156,12 +6205,12 @@ continue; } else { sprintf(g->Message, "Unsupported SQL type %d", typ); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; goto err; } // endif type_conv } else - typ = plgtyp; + typ= plgtyp; switch (typ) { case TYPE_DOUBLE: @@ -6170,43 +6219,43 @@ prec += (dec + 2); // To be safe break; default: - dec = 0; + dec= 0; } // endswitch typ } else #endif // ODBC_SUPPORT // Make the arguments as required by add_fields if (typ == TYPE_DOUBLE) - prec = len; + prec= len; if (typ == TYPE_DATE) - prec = 0; + prec= 0; // Now add the field if (add_field(&sql, cnm, typ, prec, dec, key, tm, rem, dft, xtra, fmt, 0, dbf, v)) - rc = HA_ERR_OUT_OF_MEM; + rc= HA_ERR_OUT_OF_MEM; } // endfor i } // endif fnc if (!rc) - rc = init_table_share(thd, table_s, create_info, &sql); + rc= init_table_share(thd, table_s, create_info, &sql); //g->jump_level--; //PopUser(xp); //return rc; } else { - rc = HA_ERR_UNSUPPORTED; + rc= HA_ERR_UNSUPPORTED; } // endif ok } catch (int n) { if (trace(1)) htrc("Exception %d: %s\n", n, g->Message); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; } catch (const char *msg) { strcpy(g->Message, msg); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; } // end catch err: @@ -6274,9 +6323,9 @@ TABTYPE type; TABLE *st= table; // Probably unuseful THD *thd= ha_thd(); - LEX_STRING cnc = table_arg->s->connect_string; -#ifdef WITH_PARTITION_STORAGE_ENGINE - partition_info *part_info= table_arg->part_info; + LEX_STRING cnc= table_arg->s->connect_string; +#if defined(WITH_PARTITION_STORAGE_ENGINE) + partition_info *part_info= table_arg->part_info; #else // !WITH_PARTITION_STORAGE_ENGINE #define part_info 0 #endif // !WITH_PARTITION_STORAGE_ENGINE @@ -6401,7 +6450,7 @@ host= mydef->GetHostname(); if (mydef->GetTabschema()) - db = mydef->GetTabschema(); + db= mydef->GetTabschema(); if (mydef->GetTabname()) tab= mydef->GetTabname(); @@ -6484,7 +6533,7 @@ } // endif type JSON if (type == TAB_CSV) { - const char *sep = options->separator; + const char *sep= options->separator; if (sep && strlen(sep) > 1) { sprintf(g->Message, "Invalid separator %s", sep); @@ -6683,17 +6732,18 @@ if (trace(1)) htrc("xchk=%p createas=%d\n", g->Xchk, g->Createas); +#if defined(ZIP_SUPPORT) if (options->zipped) { // Check whether the zip entry must be made from a file - PCSZ fn = GetListOption(g, "Load", options->oplist, NULL); + PCSZ fn= GetListOption(g, "Load", options->oplist, NULL); if (fn) { char zbuf[_MAX_PATH], buf[_MAX_PATH], dbpath[_MAX_PATH]; - PCSZ entry = GetListOption(g, "Entry", options->oplist, NULL); - PCSZ a = GetListOption(g, "Append", options->oplist, "NO"); - bool append = *a == '1' || *a == 'Y' || *a == 'y' || !stricmp(a, "ON"); - PCSZ m = GetListOption(g, "Mulentries", options->oplist, "NO"); - bool mul = *m == '1' || *m == 'Y' || *m == 'y' || !stricmp(m, "ON"); + PCSZ entry= GetListOption(g, "Entry", options->oplist, NULL); + PCSZ a= GetListOption(g, "Append", options->oplist, "NO"); + bool append= *a == '1' || *a == 'Y' || *a == 'y' || !stricmp(a, "ON"); + PCSZ m= GetListOption(g, "Mulentries", options->oplist, "NO"); + bool mul= *m == '1' || *m == 'Y' || *m == 'y' || !stricmp(m, "ON"); if (!entry && !mul) { my_message(ER_UNKNOWN_ERROR, "Missing entry name", MYF(0)); @@ -6712,6 +6762,7 @@ } // endif fn } // endif zipped +#endif // ZIP_SUPPORT // To check whether indexes have to be made or remade if (!g->Xchk) { @@ -6761,7 +6812,7 @@ if (SetDataPath(g, table_arg->s->db.str)) { my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); - rc = HA_ERR_INTERNAL_ERROR; + rc= HA_ERR_INTERNAL_ERROR; } else if (cat) { if (part_info) strncpy(partname, @@ -7103,7 +7154,7 @@ /* ALTER TABLE tbl_name CONVERT TO CHARACTER SET .. and - ALTER TABLE table_name DEFAULT CHARSET = .. most likely + ALTER TABLE table_name DEFAULT CHARSET= .. most likely change column charsets and so not supported in-place through old API. @@ -7335,7 +7386,7 @@ 0x0106, /* version number (1.06) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.06.0009", /* string version */ + "1.06.0010", /* string version */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ } maria_declare_plugin_end; diff -Nru mariadb-10.1-10.1.41/storage/connect/ha_connect.h mariadb-10.1-10.1.43/storage/connect/ha_connect.h --- mariadb-10.1-10.1.41/storage/connect/ha_connect.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/ha_connect.h 2019-11-06 06:20:36.000000000 +0000 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file ha_connect.h Author Olivier Bertrand diff -Nru mariadb-10.1-10.1.41/storage/connect/inihandl.cpp mariadb-10.1-10.1.43/storage/connect/inihandl.cpp --- mariadb-10.1-10.1.41/storage/connect/inihandl.cpp 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/inihandl.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -194,7 +194,7 @@ } for (key = section->key; key; key = key->next) - if (key->name[0]) { + if (key->name && key->name[0]) { fprintf(file, "%s", SVP(key->name)); if (key->value) diff -Nru mariadb-10.1-10.1.41/storage/connect/jmgoconn.cpp mariadb-10.1-10.1.43/storage/connect/jmgoconn.cpp --- mariadb-10.1-10.1.41/storage/connect/jmgoconn.cpp 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/jmgoconn.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -813,4 +813,3 @@ return fld; } // end of GetColumnValue - diff -Nru mariadb-10.1-10.1.41/storage/connect/jsonudf.cpp mariadb-10.1-10.1.43/storage/connect/jsonudf.cpp --- mariadb-10.1-10.1.41/storage/connect/jsonudf.cpp 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/jsonudf.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -1,6 +1,6 @@ /****************** jsonudf C++ Program Source Code File (.CPP) ******************/ -/* PROGRAM NAME: jsonudf Version 1.7 */ -/* (C) Copyright to the author Olivier BERTRAND 2015-2018 */ +/* PROGRAM NAME: jsonudf Version 1.8 */ +/* (C) Copyright to the author Olivier BERTRAND 2015-2019 */ /* This program are the JSON User Defined Functions . */ /*********************************************************************************/ @@ -1686,7 +1686,7 @@ } // endif *s if (n < 1) - return "Key"; + return (PCSZ) "Key"; if (!b) { if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) { @@ -1703,7 +1703,7 @@ return s; } // endif count - return "Key"; + return (PCSZ) "Key"; } // end of MakeKey /*********************************************************************************/ diff -Nru mariadb-10.1-10.1.41/storage/connect/libdoc.cpp mariadb-10.1-10.1.43/storage/connect/libdoc.cpp --- mariadb-10.1-10.1.41/storage/connect/libdoc.cpp 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/libdoc.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -1035,7 +1035,7 @@ // If name has the format m[n] only m is taken as node name if ((p = strchr(pn, '['))) - p = BufAlloc(g, pn, p - pn); + p = BufAlloc(g, pn, int(p - pn)); else p = pn; diff -Nru mariadb-10.1-10.1.41/storage/connect/mini-global.h mariadb-10.1-10.1.43/storage/connect/mini-global.h --- mariadb-10.1-10.1.41/storage/connect/mini-global.h 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/mini-global.h 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,33 @@ +/***********************************************************************/ +/* Definitions needed by the included files. */ +/***********************************************************************/ +#if !defined(MY_GLOBAL_H) +#define MY_GLOBAL_H +typedef unsigned int uint; +typedef unsigned int uint32; +typedef unsigned short ushort; +typedef unsigned long ulong; +typedef unsigned long DWORD; +typedef char *LPSTR; +typedef const char *LPCSTR; +typedef int BOOL; +#if defined(_WINDOWS) +typedef void *HANDLE; +#else +typedef int HANDLE; +#endif +typedef char *PSZ; +typedef const char *PCSZ; +typedef unsigned char BYTE; +typedef unsigned char uchar; +typedef long long longlong; +typedef unsigned long long ulonglong; +typedef char my_bool; +struct charset_info_st {}; +typedef const charset_info_st CHARSET_INFO; +#define FALSE 0 +#define TRUE 1 +#define Item char +#define MY_MAX(a,b) ((a>b)?(a):(b)) +#define MY_MIN(a,b) ((aGetName(), SVP(type)); +{ + PRELDEF tdp= NULL; + + if (trace(1)) + htrc("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type)); - // If not specified get the type of this table - if (!type) - type= Hc->GetStringOption("Type","*"); + // If not specified get the type of this table + //if (!type) + // type= Hc->GetStringOption("Type","*"); - return MakeTableDesc(g, tablep, type); - } // end of GetTableDesc + tdp= MakeTableDesc(g, tablep, type); + + if (trace(1)) + htrc("GetTableDesc: tdp=%p\n", tdp); + + return tdp; +} // end of GetTableDesc /***********************************************************************/ /* MakeTableDesc: make a table/view description. */ @@ -500,18 +508,22 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) { TABTYPE tc; - LPCSTR name = (PSZ)PlugDup(g, tablep->GetName()); - LPCSTR schema = (PSZ)PlugDup(g, tablep->GetSchema()); + LPCSTR name= (PSZ)PlugDup(g, tablep->GetName()); + LPCSTR schema= (PSZ)PlugDup(g, tablep->GetSchema()); PRELDEF tdp= NULL; - if (trace(1)) - printf("MakeTableDesc: name=%s schema=%s am=%s\n", - name, SVP(schema), SVP(am)); + if (trace(1)) + htrc("MakeTableDesc: name=%s schema=%s am=%s\n", + name, SVP(schema), SVP(am)); /*********************************************************************/ /* Get a unique enum identifier for types. */ /*********************************************************************/ - tc= GetTypeID(am); + if (!am) { + tc= Hc->GetRealType(); + am= Hc->GetStringOption("Type","*"); + } else + tc= GetTypeID(am); switch (tc) { case TAB_FIX: @@ -526,46 +538,52 @@ case TAB_XML: tdp= new(g) XMLDEF; break; #endif // XML_SUPPORT #if defined(VCT_SUPPORT) - case TAB_VEC: tdp = new(g) VCTDEF; break; + case TAB_VEC: tdp = new(g) VCTDEF; break; #endif // VCT_SUPPORT #if defined(ODBC_SUPPORT) case TAB_ODBC: tdp= new(g) ODBCDEF; break; #endif // ODBC_SUPPORT #if defined(JAVA_SUPPORT) - case TAB_JDBC: tdp= new(g) JDBCDEF; break; + case TAB_JDBC: tdp= new(g) JDBCDEF; break; #endif // JAVA_SUPPORT #if defined(__WIN__) case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break; #endif // __WIN__ case TAB_OEM: tdp= new(g) OEMDEF; break; - case TAB_TBL: tdp= new(g) TBLDEF; break; - case TAB_XCL: tdp= new(g) XCLDEF; break; - case TAB_PRX: tdp= new(g) PRXDEF; break; - case TAB_OCCUR: tdp= new(g) OCCURDEF; break; - case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; + case TAB_TBL: tdp= new(g) TBLDEF; break; + case TAB_XCL: tdp= new(g) XCLDEF; break; + case TAB_PRX: tdp= new(g) PRXDEF; break; + case TAB_OCCUR: tdp= new(g) OCCURDEF; break; + case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; case TAB_VIR: tdp= new(g) VIRDEF; break; case TAB_JSON: tdp= new(g) JSONDEF; break; #if defined(ZIP_SUPPORT) - case TAB_ZIP: tdp = new(g) ZIPDEF; break; + case TAB_ZIP: tdp = new(g) ZIPDEF; break; #endif // ZIP_SUPPORT +#if defined(REST_SUPPORT) + case TAB_REST: tdp= new (g) RESTDEF; break; +#endif // REST_SUPPORT #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) - case TAB_MONGO: - if (MongoEnabled()) { - tdp = new(g) MGODEF; - break; - } // endif enabled - // fall through + case TAB_MONGO: + if (MongoEnabled()) { + tdp = new(g) MGODEF; + break; + } // endif enabled + // fall through #endif // JAVA_SUPPORT || CMGO_SUPPORT - default: - sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); + default: + sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); } // endswitch // Do make the table/view definition if (tdp && tdp->Define(g, this, name, schema, am)) tdp= NULL; + if (trace(1)) + htrc("Table %s made\n", am); + return tdp; } // end of MakeTableDesc @@ -578,26 +596,29 @@ PTDB tdbp= NULL; // LPCSTR name= tablep->GetName(); - if (trace(1)) - printf("GetTableDB: name=%s\n", tablep->GetName()); + if (trace(1)) + htrc("GetTableDB: name=%s\n", tablep->GetName()); // Look for the description of the requested table tdp= GetTableDesc(g, tablep, type); if (tdp) { - if (trace(1)) - printf("tdb=%p type=%s\n", tdp, tdp->GetType()); + if (trace(1)) + htrc("tdb=%p type=%s\n", tdp, tdp->GetType()); + + if (tablep->GetSchema()) + tdp->Database = SetPath(g, tablep->GetSchema()); + + if (trace(2)) + htrc("Going to get table...\n"); - if (tablep->GetSchema()) - tdp->Database = SetPath(g, tablep->GetSchema()); - tdbp= tdp->GetTable(g, mode); - } // endif tdp + } // endif tdp if (tdbp) { - if (trace(1)) - printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), - tdbp->GetAmType()); + if (trace(1)) + htrc("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), + tdbp->GetAmType()); tablep->SetTo_Tdb(tdbp); tdbp->SetTable(tablep); tdbp->SetMode(mode); diff -Nru mariadb-10.1-10.1.41/storage/connect/mycat.h mariadb-10.1-10.1.43/storage/connect/mycat.h --- mariadb-10.1-10.1.41/storage/connect/mycat.h 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/mycat.h 2019-11-06 06:20:36.000000000 +0000 @@ -14,7 +14,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /**************** MYCAT H Declares Source Code File (.H) ***************/ -/* Name: MYCAT.H Version 2.3 */ +/* Name: MYCAT.H Version 2.4 */ /* Author: Olivier Bertrand */ /* This file contains the CONNECT plugin MYCAT class definitions. */ /***********************************************************************/ @@ -50,6 +50,8 @@ const char *filter; const char *oplist; const char *data_charset; + const char *http; + const char *uri; ulonglong lrecl; ulonglong elements; //ulonglong estimate; diff -Nru mariadb-10.1-10.1.41/storage/connect/mysql-test/connect/r/xml2_mult.result mariadb-10.1-10.1.43/storage/connect/mysql-test/connect/r/xml2_mult.result --- mariadb-10.1-10.1.41/storage/connect/mysql-test/connect/r/xml2_mult.result 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/mysql-test/connect/r/xml2_mult.result 2019-11-06 06:20:36.000000000 +0000 @@ -51,14 +51,14 @@ WEB XQuery Kick Start en Kurt Cagle 2003 49.99 WEB Learning XML en Erik T. Ray 2003 39.95 Warnings: -Warning 1105 Mutiple values limited to 3 +Warning 1105 Multiple values limited to 3 # One line lost because the where clause is applied only on the first 3 rows SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; category title author price CHILDREN Harry Potter J K. Rowling 29.99 WEB XQuery Kick Start James McGovern 49.99 Warnings: -Warning 1105 Mutiple values limited to 3 +Warning 1105 Multiple values limited to 3 # # Testing concatenated values # @@ -91,12 +91,12 @@ WEB XQuery Kick Start en James McGovern, Per Bothner, Kurt Cagle, James Linn 2003 49.99 WEB Learning XML en Erik T. Ray 2003 39.95 Warnings: -Warning 1105 Mutiple values limited to 4 +Warning 1105 Multiple values limited to 4 # The where clause is applied on the concatenated column result SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; category title author price CHILDREN Harry Potter J K. Rowling 29.99 WEB XQuery Kick Start James McGovern, Per Bothner, Kurt Cagle, James Linn 49.99 Warnings: -Warning 1105 Mutiple values limited to 4 +Warning 1105 Multiple values limited to 4 DROP TABLE bookstore; diff -Nru mariadb-10.1-10.1.41/storage/connect/mysql-test/connect/r/xml_mult.result mariadb-10.1-10.1.43/storage/connect/mysql-test/connect/r/xml_mult.result --- mariadb-10.1-10.1.41/storage/connect/mysql-test/connect/r/xml_mult.result 2019-07-26 16:34:53.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/mysql-test/connect/r/xml_mult.result 2019-11-06 06:20:36.000000000 +0000 @@ -49,14 +49,14 @@ WEB XQuery Kick Start en Kurt Cagle 2003 49.99 WEB Learning XML en Erik T. Ray 2003 39.95 Warnings: -Warning 1105 Mutiple values limited to 3 +Warning 1105 Multiple values limited to 3 # One line lost because the where clause is applied only on the first 3 rows SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; category title author price CHILDREN Harry Potter J K. Rowling 29.99 WEB XQuery Kick Start James McGovern 49.99 Warnings: -Warning 1105 Mutiple values limited to 3 +Warning 1105 Multiple values limited to 3 # # Testing concatenated values # @@ -89,12 +89,12 @@ WEB XQuery Kick Start en James McGovern, Per Bothner, Kurt Cagle, James Linn 2003 49.99 WEB Learning XML en Erik T. Ray 2003 39.95 Warnings: -Warning 1105 Mutiple values limited to 4 +Warning 1105 Multiple values limited to 4 # The where clause is applied on the concatenated column result SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; category title author price CHILDREN Harry Potter J K. Rowling 29.99 WEB XQuery Kick Start James McGovern, Per Bothner, Kurt Cagle, James Linn 49.99 Warnings: -Warning 1105 Mutiple values limited to 4 +Warning 1105 Multiple values limited to 4 DROP TABLE bookstore; diff -Nru mariadb-10.1-10.1.41/storage/connect/osutil.h mariadb-10.1-10.1.43/storage/connect/osutil.h --- mariadb-10.1-10.1.41/storage/connect/osutil.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/osutil.h 2019-11-06 06:20:36.000000000 +0000 @@ -3,7 +3,11 @@ #define __OSUTIL_H__ #if defined(UNIX) || defined(UNIV_LINUX) +#if defined(MARIADB) #include "my_global.h" +#else +#include "mini-global.h" +#endif #include #include #include "os.h" diff -Nru mariadb-10.1-10.1.41/storage/connect/plgdbsem.h mariadb-10.1-10.1.43/storage/connect/plgdbsem.h --- mariadb-10.1-10.1.41/storage/connect/plgdbsem.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/plgdbsem.h 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /************** PlgDBSem H Declares Source Code File (.H) **************/ -/* Name: PLGDBSEM.H Version 3.7 */ +/* Name: PLGDBSEM.H Version 3.8 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 1998-2019 */ /* */ /* This file contains the CONNECT storage engine definitions. */ /***********************************************************************/ @@ -82,6 +82,7 @@ TAB_JDBC = 26, /* Table accessed via JDBC */ TAB_ZIP = 27, /* ZIP file info table */ TAB_MONGO = 28, /* Table retrieved from MongoDB */ + TAB_REST = 29, /* Table retrieved from Rest */ TAB_NIY = 30}; /* Table not implemented yet */ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ @@ -400,6 +401,7 @@ typedef class PIVOTDEF *PPIVOTDEF; typedef class DOMDEF *PDOMDEF; typedef class DIRDEF *PDIRDEF; +typedef class RESTDEF *PRESTDEF; typedef class OEMDEF *POEMDEF; typedef class COLCRT *PCOLCRT; typedef class COLDEF *PCOLDEF; diff -Nru mariadb-10.1-10.1.41/storage/connect/plugutil.cpp mariadb-10.1-10.1.43/storage/connect/plugutil.cpp --- mariadb-10.1-10.1.41/storage/connect/plugutil.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/plugutil.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -2,11 +2,11 @@ /* */ /* PROGRAM NAME: PLUGUTIL */ /* ------------- */ -/* Version 3.0 */ +/* Version 3.1 */ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 1993-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 1993-2019 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -111,21 +111,31 @@ #endif // UNIX /**************************************************************************/ -/* Tracing output function. */ +/* Conditional tracing output function. */ /**************************************************************************/ -void htrc(char const *fmt, ...) - { - va_list ap; - va_start (ap, fmt); - +void xtrc(uint x, char const *fmt, ...) +{ + if (GetTraceValue() & x) { + va_list ap; + va_start(ap, fmt); + + vfprintf(stderr, fmt, ap); + va_end(ap); + } // endif x -//if (trace == 1) -// vfprintf(debug, fmt, ap); -//else - vfprintf(stderr, fmt, ap); +} // end of xtrc - va_end (ap); - } // end of htrc +/**************************************************************************/ +/* Tracing output function. */ +/**************************************************************************/ +void htrc(char const* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + + vfprintf(stderr, fmt, ap); + va_end(ap); +} // end of htrc /***********************************************************************/ /* Plug initialization routine. */ diff -Nru mariadb-10.1-10.1.41/storage/connect/reldef.cpp mariadb-10.1-10.1.43/storage/connect/reldef.cpp --- mariadb-10.1-10.1.41/storage/connect/reldef.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/reldef.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -81,51 +81,51 @@ /* This function return a pointer to the Table Option Struct. */ /***********************************************************************/ PTOS RELDEF::GetTopt(void) - { - return Hc->GetTableOptionStruct(); - } // end of GetTopt + { + return Hc->GetTableOptionStruct(); + } // end of GetTopt /***********************************************************************/ /* This function sets an integer table information. */ /***********************************************************************/ bool RELDEF::SetIntCatInfo(PCSZ what, int n) - { - return Hc->SetIntegerOption(what, n); - } // end of SetIntCatInfo + { + return Hc->SetIntegerOption(what, n); + } // end of SetIntCatInfo /***********************************************************************/ /* This function returns integer table information. */ /***********************************************************************/ int RELDEF::GetIntCatInfo(PCSZ what, int idef) - { - int n= Hc->GetIntegerOption(what); + { + int n= Hc->GetIntegerOption(what); - return (n == NO_IVAL) ? idef : n; - } // end of GetIntCatInfo + return (n == NO_IVAL) ? idef : n; + } // end of GetIntCatInfo /***********************************************************************/ /* This function returns Boolean table information. */ /***********************************************************************/ bool RELDEF::GetBoolCatInfo(PCSZ what, bool bdef) - { - bool b= Hc->GetBooleanOption(what, bdef); + { + bool b= Hc->GetBooleanOption(what, bdef); - return b; - } // end of GetBoolCatInfo + return b; + } // end of GetBoolCatInfo /***********************************************************************/ /* This function returns size catalog information. */ /***********************************************************************/ int RELDEF::GetSizeCatInfo(PCSZ what, PCSZ sdef) - { - char c; - PCSZ s; + { + char c; + PCSZ s; int i, n= 0; - if (!(s= Hc->GetStringOption(what))) - s= sdef; + if (!(s= Hc->GetStringOption(what))) + s= sdef; - if ((i= sscanf(s, " %d %c ", &n, &c)) == 2) + if ((i= sscanf(s, " %d %c ", &n, &c)) == 2) switch (toupper(c)) { case 'M': n *= 1024; @@ -141,41 +141,41 @@ /* This function sets char table information in buf. */ /***********************************************************************/ int RELDEF::GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size) - { - PCSZ s= Hc->GetStringOption(what); + { + PCSZ s= Hc->GetStringOption(what); - strncpy(buf, ((s) ? s : sdef), size); - return size; - } // end of GetCharCatInfo + strncpy(buf, ((s) ? s : sdef), size); + return size; + } // end of GetCharCatInfo /***********************************************************************/ /* To be used by any TDB's. */ /***********************************************************************/ bool RELDEF::Partitioned(void) - { - return Hc->IsPartitioned(); - } // end of Partitioned + { + return Hc->IsPartitioned(); + } // end of Partitioned /***********************************************************************/ /* This function returns string table information. */ /* Default parameter is "*" to get the handler default. */ /***********************************************************************/ char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef) - { - char *sval = NULL; - PCSZ name, s= Hc->GetStringOption(what, sdef); - - if (s) { + { + char *sval = NULL; + PCSZ name, s= Hc->GetStringOption(what, sdef); + + if (s) { if (!Hc->IsPartitioned() || (stricmp(what, "filename") && stricmp(what, "tabname") && stricmp(what, "connect"))) - sval= PlugDup(g, s); + sval= PlugDup(g, s); else sval= (char*)s; } else if (!stricmp(what, "filename")) { // Return default file name - PCSZ ftype= Hc->GetStringOption("Type", "*"); + PCSZ ftype= Hc->GetStringOption("Type", "*"); int i, n; if (IsFileType(GetTypeID(ftype))) { @@ -183,7 +183,7 @@ sval= (char*)PlugSubAlloc(g, NULL, strlen(name) + 12); strcat(strcpy(sval, name), "."); n= strlen(sval); - + // Fold ftype to lower case for (i= 0; i < 12; i++) if (!ftype[i]) { @@ -196,8 +196,8 @@ } // endif s - return sval; - } // end of GetStringCatInfo + return sval; + } // end of GetStringCatInfo /* --------------------------- Class TABDEF -------------------------- */ @@ -223,14 +223,14 @@ /***********************************************************************/ /* Define: initialize the table definition block from XDB file. */ /***********************************************************************/ -bool TABDEF::Define(PGLOBAL g, PCATLG cat, - LPCSTR name, LPCSTR schema, LPCSTR am) +bool TABDEF::Define(PGLOBAL g, PCATLG cat, + LPCSTR name, LPCSTR schema, LPCSTR am) { int poff = 0; - Hc = ((MYCAT*)cat)->GetHandler(); - Name = (PSZ)name; - Schema = (PSZ)Hc->GetDBName(schema); + Hc = ((MYCAT*)cat)->GetHandler(); + Name = (PSZ)name; + Schema = (PSZ)Hc->GetDBName(schema); Cat = cat; Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL)); Elemt = GetIntCatInfo("Elements", 0); @@ -263,14 +263,14 @@ /* This function returns column table information. */ /***********************************************************************/ int TABDEF::GetColCatInfo(PGLOBAL g) - { - char *type= GetStringCatInfo(g, "Type", "*"); + { + char *type= GetStringCatInfo(g, "Type", "*"); char c, fty, eds; - int i, n, loff, poff, nof, nlg; - void *field= NULL; + int i, n, loff, poff, nof, nlg; + void *field= NULL; TABTYPE tc; PCOLDEF cdp, lcdp= NULL, tocols= NULL; - PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO)); + PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO)); memset(pcf, 0, sizeof(COLINFO)); @@ -278,33 +278,33 @@ tc= (Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX; // Take care of the column definitions - i= poff= nof= nlg= 0; + i= poff= nof= nlg= 0; #if defined(__WIN__) - // Offsets of HTML and DIR tables start from 0, DBF at 1 - loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0; + // Offsets of HTML and DIR tables start from 0, DBF at 1 + loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0; #else // !__WIN__ - // Offsets of HTML tables start from 0, DIR and DBF at 1 - loff = (tc == TAB_DBF || tc == TAB_DIR) ? 1 : (tc == TAB_XML) ? -1 : 0; + // Offsets of HTML tables start from 0, DIR and DBF at 1 + loff = (tc == TAB_DBF || tc == TAB_DIR) ? 1 : (tc == TAB_XML) ? -1 : 0; #endif // !__WIN__ while (true) { - // Default Offset depends on table type - switch (tc) { + // Default Offset depends on table type + switch (tc) { case TAB_DOS: case TAB_FIX: case TAB_BIN: case TAB_VEC: case TAB_DBF: - poff= loff + nof; // Default next offset - nlg= MY_MAX(nlg, poff); // Default lrecl + poff= loff + nof; // Default next offset + nlg= MY_MAX(nlg, poff); // Default lrecl break; case TAB_CSV: case TAB_FMT: - nlg+= nof; + nlg+= nof; case TAB_DIR: case TAB_XML: - poff= loff + (pcf->Flags & U_VIRTUAL ? 0 : 1); + poff= loff + (pcf->Flags & U_VIRTUAL ? 0 : 1); break; case TAB_INI: case TAB_MAC: @@ -316,39 +316,39 @@ poff = 0; // Offset represents an independant flag break; default: // VCT PLG ODBC JDBC MYSQL WMI... - poff = 0; // NA + poff = 0; // NA break; - } // endswitch tc + } // endswitch tc -// do { - field= Hc->GetColumnOption(g, field, pcf); +// do { + field= Hc->GetColumnOption(g, field, pcf); // } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/)); - if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) { - // DBF date format defaults to 'YYYMMDD' - pcf->Datefmt= "YYYYMMDD"; - pcf->Length= 8; - } // endif tc + if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) { + // DBF date format defaults to 'YYYMMDD' + pcf->Datefmt= "YYYYMMDD"; + pcf->Length= 8; + } // endif tc - if (!field) - break; + if (!field) + break; // Allocate the column description block cdp= new(g) COLDEF; if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0) - return -1; // Error, probably unhandled type - else - loff= cdp->GetOffset(); - - switch (tc) { - case TAB_VEC: - cdp->SetOffset(0); // Not to have shift - case TAB_BIN: - // BIN/VEC are packed by default + return -1; // Error, probably unhandled type + else + loff= cdp->GetOffset(); + + switch (tc) { + case TAB_VEC: + cdp->SetOffset(0); // Not to have shift + case TAB_BIN: + // BIN/VEC are packed by default if (nof) { - // Field width is the internal representation width - // that can also depend on the column format + // Field width is the internal representation width + // that can also depend on the column format fty = cdp->Decode ? 'C' : 'X'; eds = 0; n = 0; @@ -371,38 +371,38 @@ if (n) nof = n; else switch (fty) { - case 'X': + case 'X': if (eds && IsTypeChar(cdp->Buf_Type)) nof = sizeof(longlong); else nof= cdp->Clen; break; - case 'C': break; - case 'R': - case 'F': nof = sizeof(float); break; - case 'I': nof = sizeof(int); break; - case 'D': nof = sizeof(double); break; - case 'S': nof = sizeof(short); break; - case 'T': nof = sizeof(char); break; - case 'G': nof = sizeof(longlong); break; - default: /* Wrong format */ + case 'C': break; + case 'R': + case 'F': nof = sizeof(float); break; + case 'I': nof = sizeof(int); break; + case 'D': nof = sizeof(double); break; + case 'S': nof = sizeof(short); break; + case 'T': nof = sizeof(char); break; + case 'G': nof = sizeof(longlong); break; + default: /* Wrong format */ sprintf(g->Message, "Invalid format %c", fty); return -1; - } // endswitch fty + } // endswitch fty } // endif nof default: - break; - } // endswitch tc + break; + } // endswitch tc - if (lcdp) - lcdp->SetNext(cdp); - else - tocols= cdp; + if (lcdp) + lcdp->SetNext(cdp); + else + tocols= cdp; - lcdp= cdp; + lcdp= cdp; i++; } // endwhile @@ -410,31 +410,31 @@ if (i != GetDegree()) SetDegree(i); - if (GetDefType() == TYPE_AM_DOS) { - int ending, recln= 0; + if (GetDefType() == TYPE_AM_DOS) { + int ending, recln= 0; - // Was commented because sometimes ending is 0 even when - // not specified (for instance if quoted is specified) -// if ((ending= Hc->GetIntegerOption("Ending")) < 0) { - if ((ending= Hc->GetIntegerOption("Ending")) <= 0) { + // Was commented because sometimes ending is 0 even when + // not specified (for instance if quoted is specified) +// if ((ending= Hc->GetIntegerOption("Ending")) < 0) { + if ((ending= Hc->GetIntegerOption("Ending")) <= 0) { ending= (tc == TAB_BIN || tc == TAB_VEC) ? 0 : CRLF; - Hc->SetIntegerOption("Ending", ending); - } // endif ending + Hc->SetIntegerOption("Ending", ending); + } // endif ending - // Calculate the default record size - switch (tc) { + // Calculate the default record size + switch (tc) { case TAB_FIX: case TAB_BIN: recln= nlg + ending; // + length of line ending break; case TAB_VEC: recln= nlg; - + // if ((k= (pak < 0) ? 8 : pak) > 1) // See above for detailed comment // Round up lrecl to multiple of 8 or pak // recln= ((recln + k - 1) / k) * k; - + break; case TAB_DOS: case TAB_DBF: @@ -443,26 +443,30 @@ case TAB_CSV: case TAB_FMT: // The number of separators (assuming an extra one can exist) -// recln= poff * ((qotd) ? 3 : 1); to be investigated - recln= nlg + poff * 3; // To be safe +// recln= poff * ((qotd) ? 3 : 1); to be investigated + recln= nlg + poff * 3; // To be safe default: break; } // endswitch tc - // lrecl must be at least recln to avoid buffer overflow - if (trace(1)) - htrc("Lrecl: Calculated=%d defined=%d\n", - recln, Hc->GetIntegerOption("Lrecl")); - - recln = MY_MAX(recln, Hc->GetIntegerOption("Lrecl")); - Hc->SetIntegerOption("Lrecl", recln); - ((PDOSDEF)this)->SetLrecl(recln); - } // endif Lrecl - - // Attach the column definition to the tabdef - SetCols(tocols); - return poff; - } // end of GetColCatInfo + // lrecl must be at least recln to avoid buffer overflow + if (trace(1)) + htrc("Lrecl: Calculated=%d defined=%d\n", + recln, Hc->GetIntegerOption("Lrecl")); + + recln = MY_MAX(recln, Hc->GetIntegerOption("Lrecl")); + Hc->SetIntegerOption("Lrecl", recln); + ((PDOSDEF)this)->SetLrecl(recln); + + if (trace(1)) + htrc("Lrecl set to %d\n", recln); + + } // endif Lrecl + + // Attach the column definition to the tabdef + SetCols(tocols); + return poff; + } // end of GetColCatInfo /***********************************************************************/ /* SetIndexInfo: retrieve index description from the table structure. */ @@ -487,16 +491,17 @@ PCATLG cat = Cat; /*********************************************************************/ - /* Ensure that the .dll doesn't have a path. */ - /* This is done to ensure that only approved dll from the system */ + /* Ensure that the module name doesn't have a path. */ + /* This is done to ensure that only approved libs from the system */ /* directories are used (to make this even remotely secure). */ /*********************************************************************/ if (check_valid_path(Module, strlen(Module))) { strcpy(g->Message, "Module cannot contain a path"); return NULL; } else - PlugSetPath(soname, Module, GetPluginDir()); - +// PlugSetPath(soname, Module, GetPluginDir()); // Crashes on Fedora + strncat(strcpy(soname, GetPluginDir()), Module, _MAX_PATH); + #if defined(__WIN__) // Is the DLL already loaded? if (!Hdll && !(Hdll = GetModuleHandle(soname))) @@ -522,31 +527,31 @@ // Get the function returning an instance of the external DEF class if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) { - char buf[256]; - DWORD rc = GetLastError(); + char buf[256]; + DWORD rc = GetLastError(); - sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname); - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, - (LPTSTR)buf, sizeof(buf), NULL); - strcat(strcat(g->Message, ": "), buf); - FreeLibrary((HMODULE)Hdll); + sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname); + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, + (LPTSTR)buf, sizeof(buf), NULL); + strcat(strcat(g->Message, ": "), buf); + FreeLibrary((HMODULE)Hdll); return NULL; } // endif getdef #else // !__WIN__ const char *error = NULL; - + #if 0 // Don't know what all this stuff does - Dl_info dl_info; + Dl_info dl_info; - // The OEM lib must retrieve exported CONNECT variables + // The OEM lib must retrieve exported CONNECT variables if (dladdr(&connect_hton, &dl_info)) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { error = dlerror(); sprintf(g->Message, "dlopen failed: %s, OEM not supported", SVP(error)); return NULL; } // endif dlopen - + } else { error = dlerror(); sprintf(g->Message, "dladdr failed: %s, OEM not supported", SVP(error)); @@ -626,7 +631,7 @@ char *desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) + strlen(Subtype) + 3); sprintf(desc, "%s(%s)", Module, Subtype); - Desc = desc; + Desc = desc; return false; } // end of DefineAM @@ -701,17 +706,17 @@ txfp = new(g) FIXFAM(defp); } else if (rfm == RECFM_VCT) { #if defined(VCT_SUPPORT) - assert(Pxdef->GetDefType() == TYPE_AM_VCT); + assert(Pxdef->GetDefType() == TYPE_AM_VCT); if (map) txfp = new(g) VCMFAM((PVCTDEF)defp); else txfp = new(g) VCTFAM((PVCTDEF)defp); #else // !VCT_SUPPORT - strcpy(g->Message, "VCT no more supported"); - return NULL; + strcpy(g->Message, "VCT no more supported"); + return NULL; #endif // !VCT_SUPPORT - } // endif's + } // endif's ((PTDBDOS)tdbp)->SetTxfp(txfp); } // endif Txfp diff -Nru mariadb-10.1-10.1.41/storage/connect/rest.def mariadb-10.1-10.1.43/storage/connect/rest.def --- mariadb-10.1-10.1.41/storage/connect/rest.def 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/rest.def 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,4 @@ +LIBRARY REST2 +EXPORTS + GetREST @1 + ColREST @2 diff -Nru mariadb-10.1-10.1.41/storage/connect/restget.cpp mariadb-10.1-10.1.43/storage/connect/restget.cpp --- mariadb-10.1-10.1.41/storage/connect/restget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/restget.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,94 @@ +/************* Restget C++ Program Source Code File (.CPP) *************/ +/* Adapted from the sample program of the Casablanca tutorial. */ +/* Copyright Olivier Bertrand 2019. */ +/***********************************************************************/ +#include +#include +#if defined(MARIADB) +#include +#else +#include "mini-global.h" +#define _OS_H_INCLUDED // Prevent os.h to be called +#endif + +using namespace utility::conversions; // String conversions utilities +using namespace web; // Common features like URIs. +using namespace web::http; // Common HTTP functionality +using namespace web::http::client; // HTTP client features +using namespace concurrency::streams; // Asynchronous streams + +#include "global.h" + +/***********************************************************************/ +/* Make a local copy of the requested file. */ +/***********************************************************************/ +int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn) +{ + int rc = 0; + bool xt = trace(515); + auto fileStream = std::make_shared(); + + if (!http || !fn) { + strcpy(g->Message, "Missing http or filename"); + return 2; + } // endif + + if (xt) + htrc("restGetFile: fn=%s\n", fn); + + // Open stream to output file. + pplx::task requestTask = fstream::open_ostream(to_string_t(fn)) + .then([=](ostream outFile) { + *fileStream= outFile; + + if (xt) + htrc("Outfile isopen=%d\n", outFile.is_open()); + + // Create http_client to send the request. + http_client client(to_string_t(http)); + + if (uri) { + // Build request URI and start the request. + uri_builder builder(to_string_t(uri)); + return client.request(methods::GET, builder.to_string()); + } else + return client.request(methods::GET); + }) + + // Handle response headers arriving. + .then([=](http_response response) { + if (xt) + htrc("Received response status code:%u\n", + response.status_code()); + + // Write response body into the file. + return response.body().read_to_end(fileStream->streambuf()); + }) + + // Close the file stream. + .then([=](size_t n) { + if (xt) + htrc("Return size=%u\n", n); + + return fileStream->close(); + }); + + // Wait for all the outstanding I/O to complete and handle any exceptions + try { + requestTask.wait(); + + if (xt) + htrc("In Wait\n"); + + } catch (const std::exception &e) { + if (xt) + htrc("Error exception: %s\n", e.what()); + sprintf(g->Message, "Error exception: %s", e.what()); + rc= 1; + } // end try/catch + + if (xt) + htrc("restget done: rc=%d\n", rc); + + return rc; +} // end of restGetFile diff -Nru mariadb-10.1-10.1.41/storage/connect/tabfmt.cpp mariadb-10.1-10.1.43/storage/connect/tabfmt.cpp --- mariadb-10.1-10.1.41/storage/connect/tabfmt.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabfmt.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -189,9 +189,11 @@ htrc("File %s Sep=%c Qot=%c Header=%d maxerr=%d\n", SVP(tdp->Fn), tdp->Sep, tdp->Qot, tdp->Header, tdp->Maxerr); +#if defined(ZIP_SUPPORT) if (tdp->Zipped) tcvp = new(g)TDBCSV(tdp, new(g)UNZFAM(tdp)); else +#endif // ZIP_SUPPORT tcvp = new(g) TDBCSV(tdp, new(g) DOSFAM(tdp)); tcvp->SetMode(MODE_READ); diff -Nru mariadb-10.1-10.1.41/storage/connect/tabjdbc.cpp mariadb-10.1-10.1.43/storage/connect/tabjdbc.cpp --- mariadb-10.1-10.1.41/storage/connect/tabjdbc.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabjdbc.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -72,7 +72,6 @@ #include "tabext.h" #include "tabjdbc.h" #include "tabmul.h" -//#include "reldef.h" #include "tabcol.h" #include "valblk.h" #include "ha_connect.h" @@ -89,6 +88,9 @@ /* External function. */ /***********************************************************************/ bool ExactInfo(void); +#if defined(DEVELOPMENT) +extern char *GetUserVariable(PGLOBAL g, const uchar *varname); +#endif // DEVELOPMENT /* -------------------------- Class JDBCDEF -------------------------- */ @@ -147,10 +149,6 @@ return RC_FX; Tabname = p; -// } else if (b) { -// // Otherwise, straight server name, -// Tabname = GetStringCatInfo(g, "Name", NULL); -// Tabname = GetStringCatInfo(g, "Tabname", Tabname); } // endif if (trace(1)) @@ -165,6 +163,11 @@ return RC_FX; } // endif server +#if defined(DEVELOPMENT) + if (*server->host == '@') { + Url = GetUserVariable(g, (const uchar*)&server->host[1]); + } else +#endif // 0 if (strncmp(server->host, "jdbc:", 5)) { // Now make the required URL Url = (PSZ)PlugSubAlloc(g, NULL, 0); @@ -191,6 +194,9 @@ if (!Password && server->password) Password = PlugDup(g, server->password); + Driver = PlugDup(g, GetListOption(g, "Driver", server->owner, NULL)); + Wrapname = PlugDup(g, GetListOption(g, "Wrapper", server->owner, NULL)); + Memory = atoi(GetListOption(g, "Memory", server->owner, "0")); return RC_NF; } // endif @@ -208,7 +214,6 @@ if (EXTDEF::DefineAM(g, am, poff)) return true; - Driver = GetStringCatInfo(g, "Driver", NULL); Desc = Url = GetStringCatInfo(g, "Connect", NULL); if (!Url && !Catfunc) { @@ -228,7 +233,10 @@ return true; } // endif rc - Wrapname = GetStringCatInfo(g, "Wrapper", NULL); + // Default values may have been set in ParseURL + Memory = GetIntCatInfo("Memory", Memory); + Driver = GetStringCatInfo(g, "Driver", Driver); + Wrapname = GetStringCatInfo(g, "Wrapper", Wrapname); return false; } // end of DefineAM @@ -633,7 +641,9 @@ Cnp->InitValue(g); if ((n = Jcp->GetResultSize(Query->GetStr(), Cnp)) < 0) { - sprintf(g->Message, "Cannot get result size rc=%d", n); + char* msg = PlugDup(g, g->Message); + + sprintf(g->Message, "Get result size: %s (rc=%d)", msg, n); return true; } else if (n) { Jcp->m_Rows = n; diff -Nru mariadb-10.1-10.1.41/storage/connect/tabjson.cpp mariadb-10.1-10.1.43/storage/connect/tabjson.cpp --- mariadb-10.1-10.1.41/storage/connect/tabjson.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabjson.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -71,15 +71,15 @@ /***********************************************************************/ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info) { - static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, + static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT, TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_STRING}; - static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, + static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_TYPENAME, FLD_PREC, FLD_LENGTH, FLD_SCALE, FLD_NULL, FLD_FORMAT}; static unsigned int length[] = {0, 6, 8, 10, 10, 6, 6, 0}; - int i, n = 0; + int i, n = 0; int ncol = sizeof(buftyp) / sizeof(int); - PJCL jcp; - JSONDISC *pjdc = NULL; + PJCL jcp; + JSONDISC *pjdc = NULL; PQRYRES qrp; PCOLRES crp; @@ -89,15 +89,15 @@ goto skipit; } // endif info - if (GetIntegerTableOption(g, topt, "Multiple", 0)) { - strcpy(g->Message, "Cannot find column definition for multiple table"); - return NULL; - } // endif Multiple + if (GetIntegerTableOption(g, topt, "Multiple", 0)) { + strcpy(g->Message, "Cannot find column definition for multiple table"); + return NULL; + } // endif Multiple - pjdc = new(g) JSONDISC(g, length); + pjdc = new(g) JSONDISC(g, length); - if (!(n = pjdc->GetColumns(g, db, dsn, topt))) - return NULL; + if (!(n = pjdc->GetColumns(g, db, dsn, topt))) + return NULL; skipit: if (trace(1)) @@ -110,8 +110,8 @@ buftyp, fldtyp, length, false, false); crp = qrp->Colresp->Next->Next->Next->Next->Next->Next; - crp->Name = PlugDup(g, "Nullable"); - crp->Next->Name = PlugDup(g, "Jpath"); + crp->Name = PlugDup(g, "Nullable"); + crp->Next->Name = PlugDup(g, "Jpath"); if (info || !qrp) return qrp; @@ -122,8 +122,8 @@ /* Now get the results into blocks. */ /*********************************************************************/ for (i = 0, jcp = pjdc->fjcp; jcp; i++, jcp = jcp->Next) { - if (jcp->Type == TYPE_UNKNOWN) - jcp->Type = TYPE_STRING; // Void column + if (jcp->Type == TYPE_UNKNOWN) + jcp->Type = TYPE_STRING; // Void column crp = qrp->Colresp; // Column Name crp->Kdata->SetValue(jcp->Name, i); @@ -159,380 +159,380 @@ /***********************************************************************/ JSONDISC::JSONDISC(PGLOBAL g, uint *lg) { - length = lg; - jcp = fjcp = pjcp = NULL; - tjnp = NULL; - jpp = NULL; - tjsp = NULL; - jsp = NULL; - row = NULL; - sep = NULL; - i = n = bf = ncol = lvl = 0; - all = false; -} // end of JSONDISC constructor + length = lg; + jcp = fjcp = pjcp = NULL; + tjnp = NULL; + jpp = NULL; + tjsp = NULL; + jsp = NULL; + row = NULL; + sep = NULL; + i = n = bf = ncol = lvl = 0; + all = false; +} // end of JSONDISC constructor int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) { - char filename[_MAX_PATH]; - bool mgo = (GetTypeID(topt->type) == TAB_MONGO); - PCSZ level = GetStringTableOption(g, topt, "Level", NULL); - - if (level) { - lvl = atoi(level); - lvl = (lvl > 16) ? 16 : lvl; - } else - lvl = 0; - - sep = GetStringTableOption(g, topt, "Separator", "."); - - /*********************************************************************/ - /* Open the input file. */ - /*********************************************************************/ - tdp = new(g) JSONDEF; + char filename[_MAX_PATH]; + bool mgo = (GetTypeID(topt->type) == TAB_MONGO); + PCSZ level = GetStringTableOption(g, topt, "Level", NULL); + + if (level) { + lvl = atoi(level); + lvl = (lvl > 16) ? 16 : lvl; + } else + lvl = 0; + + sep = GetStringTableOption(g, topt, "Separator", "."); + + /*********************************************************************/ + /* Open the input file. */ + /*********************************************************************/ + tdp = new(g) JSONDEF; #if defined(ZIP_SUPPORT) - tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL); - tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false); + tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL); + tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false); #endif // ZIP_SUPPORT - tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); + tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL); + + if (!(tdp->Database = SetPath(g, db))) + return 0; - if (!(tdp->Database = SetPath(g, db))) - return 0; + tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); + tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; + tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); + tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL); + tdp->Accept = GetBooleanTableOption(g, topt, "Accept", false); + tdp->Uri = (dsn && *dsn ? dsn : NULL); - tdp->Objname = GetStringTableOption(g, topt, "Object", NULL); - tdp->Base = GetIntegerTableOption(g, topt, "Base", 0) ? 1 : 0; - tdp->Pretty = GetIntegerTableOption(g, topt, "Pretty", 2); - tdp->Xcol = GetStringTableOption(g, topt, "Expand", NULL); - tdp->Accept = GetBooleanTableOption(g, topt, "Accept", false); - tdp->Uri = (dsn && *dsn ? dsn : NULL); - - if (!tdp->Fn && !tdp->Uri) { - strcpy(g->Message, MSG(MISSING_FNAME)); - return 0; - } // endif Fn - - if (tdp->Fn) { - // We used the file name relative to recorded datapath - PlugSetPath(filename, tdp->Fn, tdp->GetPath()); - tdp->Fn = PlugDup(g, filename); - } // endif Fn - - if (trace(1)) - htrc("File %s objname=%s pretty=%d lvl=%d\n", - tdp->Fn, tdp->Objname, tdp->Pretty, lvl); + if (!tdp->Fn && !tdp->Uri) { + strcpy(g->Message, MSG(MISSING_FNAME)); + return 0; + } // endif Fn + + if (tdp->Fn) { + // We used the file name relative to recorded datapath + PlugSetPath(filename, tdp->Fn, tdp->GetPath()); + tdp->Fn = PlugDup(g, filename); + } // endif Fn + + if (trace(1)) + htrc("File %s objname=%s pretty=%d lvl=%d\n", + tdp->Fn, tdp->Objname, tdp->Pretty, lvl); - if (tdp->Uri) { + if (tdp->Uri) { #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) - tdp->Collname = GetStringTableOption(g, topt, "Name", NULL); - tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname); - tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test"); - tdp->Options = (PSZ)GetStringTableOption(g, topt, "Colist", "all"); - tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false); - tdp->Driver = (PSZ)GetStringTableOption(g, topt, "Driver", NULL); - tdp->Version = GetIntegerTableOption(g, topt, "Version", 3); - tdp->Wrapname = (PSZ)GetStringTableOption(g, topt, "Wrapper", - (tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface"); - tdp->Pretty = 0; + tdp->Collname = GetStringTableOption(g, topt, "Name", NULL); + tdp->Collname = GetStringTableOption(g, topt, "Tabname", tdp->Collname); + tdp->Schema = GetStringTableOption(g, topt, "Dbname", "test"); + tdp->Options = (PSZ)GetStringTableOption(g, topt, "Colist", "all"); + tdp->Pipe = GetBooleanTableOption(g, topt, "Pipeline", false); + tdp->Driver = (PSZ)GetStringTableOption(g, topt, "Driver", NULL); + tdp->Version = GetIntegerTableOption(g, topt, "Version", 3); + tdp->Wrapname = (PSZ)GetStringTableOption(g, topt, "Wrapper", + (tdp->Version == 2) ? "Mongo2Interface" : "Mongo3Interface"); + tdp->Pretty = 0; #else // !MONGO_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); - return 0; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); + return 0; #endif // !MONGO_SUPPORT - } // endif Uri + } // endif Uri - if (tdp->Pretty == 2) { - if (tdp->Zipped) { + if (tdp->Pretty == 2) { + if (tdp->Zipped) { #if defined(ZIP_SUPPORT) - tjsp = new(g) TDBJSON(tdp, new(g) UNZFAM(tdp)); + tjsp = new(g) TDBJSON(tdp, new(g) UNZFAM(tdp)); #else // !ZIP_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); - return 0; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); + return 0; #endif // !ZIP_SUPPORT - } else - tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); + } else + tjsp = new(g) TDBJSON(tdp, new(g) MAPFAM(tdp)); - if (tjsp->MakeDocument(g)) - return 0; + if (tjsp->MakeDocument(g)) + return 0; - jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; - } else { - if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) - if (!mgo) { - sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); - return 0; - } else - tdp->Lrecl = 8192; // Should be enough + jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; + } else { + if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) + if (!mgo) { + sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); + return 0; + } else + tdp->Lrecl = 8192; // Should be enough - tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); + tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); - if (tdp->Zipped) { + if (tdp->Zipped) { #if defined(ZIP_SUPPORT) - tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp)); + tjnp = new(g)TDBJSN(tdp, new(g) UNZFAM(tdp)); #else // !ZIP_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); - return NULL; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); + return NULL; #endif // !ZIP_SUPPORT - } else if (tdp->Uri) { - if (tdp->Driver && toupper(*tdp->Driver) == 'C') { + } else if (tdp->Uri) { + if (tdp->Driver && toupper(*tdp->Driver) == 'C') { #if defined(CMGO_SUPPORT) - tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); + tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); #else - sprintf(g->Message, "Mongo %s Driver not available", "C"); - return 0; + sprintf(g->Message, "Mongo %s Driver not available", "C"); + return 0; #endif - } else if (tdp->Driver && toupper(*tdp->Driver) == 'J') { + } else if (tdp->Driver && toupper(*tdp->Driver) == 'J') { #if defined(JAVA_SUPPORT) - tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); + tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); #else - sprintf(g->Message, "Mongo %s Driver not available", "Java"); - return 0; + sprintf(g->Message, "Mongo %s Driver not available", "Java"); + return 0; #endif - } else { // Driver not specified + } else { // Driver not specified #if defined(CMGO_SUPPORT) - tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); + tjnp = new(g) TDBJSN(tdp, new(g) CMGFAM(tdp)); #elif defined(JAVA_SUPPORT) - tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); + tjnp = new(g) TDBJSN(tdp, new(g) JMGFAM(tdp)); #else - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); - return 0; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); + return 0; #endif - } // endif Driver + } // endif Driver - } else - tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp)); + } else + tjnp = new(g) TDBJSN(tdp, new(g) DOSFAM(tdp)); - tjnp->SetMode(MODE_READ); + tjnp->SetMode(MODE_READ); - // Allocate the parse work memory - PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); - memset(G, 0, sizeof(GLOBAL)); - G->Sarea_Size = tdp->Lrecl * 10; - G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); - PlugSubSet(G->Sarea, G->Sarea_Size); - G->jump_level = 0; - tjnp->SetG(G); - - if (tjnp->OpenDB(g)) - return 0; - - switch (tjnp->ReadDB(g)) { - case RC_EF: - strcpy(g->Message, "Void json table"); - case RC_FX: - goto err; - default: - jsp = tjnp->GetRow(); - } // endswitch ReadDB - - } // endif pretty - - if (!(row = (jsp) ? jsp->GetObject() : NULL)) { - strcpy(g->Message, "Can only retrieve columns from object rows"); - goto err; - } // endif row - - all = GetBooleanTableOption(g, topt, "Fullarray", false); - jcol.Name = jcol.Fmt = NULL; - jcol.Next = NULL; - jcol.Found = true; - colname[0] = 0; - - if (!tdp->Uri) { - fmt[0] = '$'; - fmt[1] = '.'; - bf = 2; - } // endif Uri - - /*********************************************************************/ - /* Analyse the JSON tree and define columns. */ - /*********************************************************************/ - for (i = 1; ; i++) { - for (jpp = row->GetFirst(); jpp; jpp = jpp->GetNext()) { - strncpy(colname, jpp->GetKey(), 64); - fmt[bf] = 0; - - if (Find(g, jpp->GetVal(), colname, MY_MIN(lvl, 0))) - goto err; - - } // endfor jpp - - // Missing column can be null - for (jcp = fjcp; jcp; jcp = jcp->Next) { - jcp->Cbn |= !jcp->Found; - jcp->Found = false; - } // endfor jcp - - if (tdp->Pretty != 2) { - // Read next record - switch (tjnp->ReadDB(g)) { - case RC_EF: - jsp = NULL; - break; - case RC_FX: - goto err; - default: - jsp = tjnp->GetRow(); - } // endswitch ReadDB - - } else - jsp = tjsp->GetDoc()->GetValue(i); - - if (!(row = (jsp) ? jsp->GetObject() : NULL)) - break; + // Allocate the parse work memory + PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); + memset(G, 0, sizeof(GLOBAL)); + G->Sarea_Size = tdp->Lrecl * 10; + G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); + PlugSubSet(G->Sarea, G->Sarea_Size); + G->jump_level = 0; + tjnp->SetG(G); + + if (tjnp->OpenDB(g)) + return 0; + + switch (tjnp->ReadDB(g)) { + case RC_EF: + strcpy(g->Message, "Void json table"); + case RC_FX: + goto err; + default: + jsp = tjnp->GetRow(); + } // endswitch ReadDB + + } // endif pretty + + if (!(row = (jsp) ? jsp->GetObject() : NULL)) { + strcpy(g->Message, "Can only retrieve columns from object rows"); + goto err; + } // endif row + + all = GetBooleanTableOption(g, topt, "Fullarray", false); + jcol.Name = jcol.Fmt = NULL; + jcol.Next = NULL; + jcol.Found = true; + colname[0] = 0; + + if (!tdp->Uri) { + fmt[0] = '$'; + fmt[1] = '.'; + bf = 2; + } // endif Uri - } // endfor i + /*********************************************************************/ + /* Analyse the JSON tree and define columns. */ + /*********************************************************************/ + for (i = 1; ; i++) { + for (jpp = row->GetFirst(); jpp; jpp = jpp->GetNext()) { + strncpy(colname, jpp->GetKey(), 64); + fmt[bf] = 0; + + if (Find(g, jpp->GetVal(), colname, MY_MIN(lvl, 0))) + goto err; + + } // endfor jpp + + // Missing column can be null + for (jcp = fjcp; jcp; jcp = jcp->Next) { + jcp->Cbn |= !jcp->Found; + jcp->Found = false; + } // endfor jcp + + if (tdp->Pretty != 2) { + // Read next record + switch (tjnp->ReadDB(g)) { + case RC_EF: + jsp = NULL; + break; + case RC_FX: + goto err; + default: + jsp = tjnp->GetRow(); + } // endswitch ReadDB - if (tdp->Pretty != 2) - tjnp->CloseDB(g); + } else + jsp = tjsp->GetDoc()->GetValue(i); + + if (!(row = (jsp) ? jsp->GetObject() : NULL)) + break; - return n; + } // endfor i + + if (tdp->Pretty != 2) + tjnp->CloseDB(g); + + return n; err: - if (tdp->Pretty != 2) - tjnp->CloseDB(g); + if (tdp->Pretty != 2) + tjnp->CloseDB(g); - return 0; -} // end of GetColumns + return 0; +} // end of GetColumns bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j) { - char *p, *pc = colname + strlen(colname); - int ars; - PJOB job; - PJAR jar; - - if ((valp = jvp ? jvp->GetValue() : NULL)) { - jcol.Type = valp->GetType(); - jcol.Len = valp->GetValLen(); - jcol.Scale = valp->GetValPrec(); - jcol.Cbn = valp->IsNull(); - } else if (!jvp || jvp->IsNull()) { - jcol.Type = TYPE_UNKNOWN; - jcol.Len = jcol.Scale = 0; - jcol.Cbn = true; - } else if (j < lvl) { - if (!fmt[bf]) - strcat(fmt, colname); - - p = fmt + strlen(fmt); - jsp = jvp->GetJson(); - - switch (jsp->GetType()) { - case TYPE_JOB: - job = (PJOB)jsp; - - for (PJPR jrp = job->GetFirst(); jrp; jrp = jrp->GetNext()) { - PCSZ k = jrp->GetKey(); - - if (*k != '$') { - strncat(strncat(fmt, sep, 128), k, 128); - strncat(strncat(colname, "_", 64), k, 64); - } // endif Key - - if (Find(g, jrp->GetVal(), k, j + 1)) - return true; - - *p = *pc = 0; - } // endfor jrp - - return false; - case TYPE_JAR: - jar = (PJAR)jsp; - - if (all || (tdp->Xcol && !stricmp(tdp->Xcol, key))) - ars = jar->GetSize(false); - else - ars = MY_MIN(jar->GetSize(false), 1); - - for (int k = 0; k < ars; k++) { - if (!tdp->Xcol || stricmp(tdp->Xcol, key)) { - sprintf(buf, "%d", k); - - if (tdp->Uri) - strncat(strncat(fmt, sep, 128), buf, 128); - else - strncat(strncat(strncat(fmt, "[", 128), buf, 128), "]", 128); - - if (all) - strncat(strncat(colname, "_", 64), buf, 64); - - } else - strncat(fmt, (tdp->Uri ? sep : "[*]"), 128); - - if (Find(g, jar->GetValue(k), "", j)) - return true; - - *p = *pc = 0; - } // endfor k - - return false; - default: - sprintf(g->Message, "Logical error after %s", fmt); - return true; - } // endswitch Type - - } else if (lvl >= 0) { - jcol.Type = TYPE_STRING; - jcol.Len = 256; - jcol.Scale = 0; - jcol.Cbn = true; - } else - return false; - - AddColumn(g); - return false; -} // end of Find + char *p, *pc = colname + strlen(colname); + int ars; + PJOB job; + PJAR jar; + + if ((valp = jvp ? jvp->GetValue() : NULL)) { + jcol.Type = valp->GetType(); + jcol.Len = valp->GetValLen(); + jcol.Scale = valp->GetValPrec(); + jcol.Cbn = valp->IsNull(); + } else if (!jvp || jvp->IsNull()) { + jcol.Type = TYPE_UNKNOWN; + jcol.Len = jcol.Scale = 0; + jcol.Cbn = true; + } else if (j < lvl) { + if (!fmt[bf]) + strcat(fmt, colname); + + p = fmt + strlen(fmt); + jsp = jvp->GetJson(); + + switch (jsp->GetType()) { + case TYPE_JOB: + job = (PJOB)jsp; + + for (PJPR jrp = job->GetFirst(); jrp; jrp = jrp->GetNext()) { + PCSZ k = jrp->GetKey(); + + if (*k != '$') { + strncat(strncat(fmt, sep, 128), k, 128); + strncat(strncat(colname, "_", 64), k, 64); + } // endif Key + + if (Find(g, jrp->GetVal(), k, j + 1)) + return true; + + *p = *pc = 0; + } // endfor jrp + + return false; + case TYPE_JAR: + jar = (PJAR)jsp; + + if (all || (tdp->Xcol && !stricmp(tdp->Xcol, key))) + ars = jar->GetSize(false); + else + ars = MY_MIN(jar->GetSize(false), 1); + + for (int k = 0; k < ars; k++) { + if (!tdp->Xcol || stricmp(tdp->Xcol, key)) { + sprintf(buf, "%d", k); + + if (tdp->Uri) + strncat(strncat(fmt, sep, 128), buf, 128); + else + strncat(strncat(strncat(fmt, "[", 128), buf, 128), "]", 128); + + if (all) + strncat(strncat(colname, "_", 64), buf, 64); + + } else + strncat(fmt, (tdp->Uri ? sep : "[*]"), 128); + + if (Find(g, jar->GetValue(k), "", j)) + return true; + + *p = *pc = 0; + } // endfor k + + return false; + default: + sprintf(g->Message, "Logical error after %s", fmt); + return true; + } // endswitch Type + + } else if (lvl >= 0) { + jcol.Type = TYPE_STRING; + jcol.Len = 256; + jcol.Scale = 0; + jcol.Cbn = true; + } else + return false; + + AddColumn(g); + return false; +} // end of Find void JSONDISC::AddColumn(PGLOBAL g) { - bool b = fmt[bf] != 0; // True if formatted + bool b = fmt[bf] != 0; // True if formatted + + // Check whether this column was already found + for (jcp = fjcp; jcp; jcp = jcp->Next) + if (!strcmp(colname, jcp->Name)) + break; - // Check whether this column was already found - for (jcp = fjcp; jcp; jcp = jcp->Next) - if (!strcmp(colname, jcp->Name)) - break; - - if (jcp) { - if (jcp->Type != jcol.Type) { - if (jcp->Type == TYPE_UNKNOWN) - jcp->Type = jcol.Type; - else if (jcol.Type != TYPE_UNKNOWN) - jcp->Type = TYPE_STRING; - - } // endif Type - - if (b && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) { - jcp->Fmt = PlugDup(g, fmt); - length[7] = MY_MAX(length[7], strlen(fmt)); - } // endif fmt - - jcp->Len = MY_MAX(jcp->Len, jcol.Len); - jcp->Scale = MY_MAX(jcp->Scale, jcol.Scale); - jcp->Cbn |= jcol.Cbn; - jcp->Found = true; - } else if (jcol.Type != TYPE_UNKNOWN || tdp->Accept) { - // New column - jcp = (PJCL)PlugSubAlloc(g, NULL, sizeof(JCOL)); - *jcp = jcol; - jcp->Cbn |= (i > 1); - jcp->Name = PlugDup(g, colname); - length[0] = MY_MAX(length[0], strlen(colname)); - - if (b) { - jcp->Fmt = PlugDup(g, fmt); - length[7] = MY_MAX(length[7], strlen(fmt)); - } else - jcp->Fmt = NULL; - - if (pjcp) { - jcp->Next = pjcp->Next; - pjcp->Next = jcp; - } else - fjcp = jcp; + if (jcp) { + if (jcp->Type != jcol.Type) { + if (jcp->Type == TYPE_UNKNOWN) + jcp->Type = jcol.Type; + else if (jcol.Type != TYPE_UNKNOWN) + jcp->Type = TYPE_STRING; + + } // endif Type + + if (b && (!jcp->Fmt || strlen(jcp->Fmt) < strlen(fmt))) { + jcp->Fmt = PlugDup(g, fmt); + length[7] = MY_MAX(length[7], strlen(fmt)); + } // endif fmt + + jcp->Len = MY_MAX(jcp->Len, jcol.Len); + jcp->Scale = MY_MAX(jcp->Scale, jcol.Scale); + jcp->Cbn |= jcol.Cbn; + jcp->Found = true; + } else if (jcol.Type != TYPE_UNKNOWN || tdp->Accept) { + // New column + jcp = (PJCL)PlugSubAlloc(g, NULL, sizeof(JCOL)); + *jcp = jcol; + jcp->Cbn |= (i > 1); + jcp->Name = PlugDup(g, colname); + length[0] = MY_MAX(length[0], strlen(colname)); + + if (b) { + jcp->Fmt = PlugDup(g, fmt); + length[7] = MY_MAX(length[7], strlen(fmt)); + } else + jcp->Fmt = NULL; - n++; - } // endif jcp + if (pjcp) { + jcp->Next = pjcp->Next; + pjcp->Next = jcp; + } else + fjcp = jcp; - if (jcp) - pjcp = jcp; + n++; + } // endif jcp + + if (jcp) + pjcp = jcp; } // end of AddColumn @@ -548,13 +548,13 @@ Limit = 1; Base = 0; Strict = false; - Sep = '.'; - Uri = NULL; - Collname = Options = Filter = NULL; - Pipe = false; - Driver = NULL; - Version = 0; - Wrapname = NULL; + Sep = '.'; + Uri = NULL; + Collname = Options = Filter = NULL; + Pipe = false; + Driver = NULL; + Version = 0; + Wrapname = NULL; } // end of JSONDEF constructor /***********************************************************************/ @@ -562,41 +562,41 @@ /***********************************************************************/ bool JSONDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { - Schema = GetStringCatInfo(g, "DBname", Schema); - Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT); + Schema = GetStringCatInfo(g, "DBname", Schema); + Jmode = (JMODE)GetIntCatInfo("Jmode", MODE_OBJECT); Objname = GetStringCatInfo(g, "Object", NULL); Xcol = GetStringCatInfo(g, "Expand", NULL); Pretty = GetIntCatInfo("Pretty", 2); Limit = GetIntCatInfo("Limit", 10); Base = GetIntCatInfo("Base", 0) ? 1 : 0; - Sep = *GetStringCatInfo(g, "Separator", "."); - Accept = GetBoolCatInfo("Accept", false); + Sep = *GetStringCatInfo(g, "Separator", "."); + Accept = GetBoolCatInfo("Accept", false); - // Don't use url as uri when called from REST OEM module - if (stricmp(am, "REST") && (Uri = GetStringCatInfo(g, "Connect", NULL))) { + // Don't use url as MONGO uri when called from REST + if (stricmp(am, "REST") && (Uri = GetStringCatInfo(g, "Connect", NULL))) { #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) - Collname = GetStringCatInfo(g, "Name", - (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); - Collname = GetStringCatInfo(g, "Tabname", Collname); - Options = GetStringCatInfo(g, "Colist", NULL); - Filter = GetStringCatInfo(g, "Filter", NULL); - Pipe = GetBoolCatInfo("Pipeline", false); - Driver = GetStringCatInfo(g, "Driver", NULL); - Version = GetIntCatInfo("Version", 3); - Pretty = 0; + Collname = GetStringCatInfo(g, "Name", + (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); + Collname = GetStringCatInfo(g, "Tabname", Collname); + Options = GetStringCatInfo(g, "Colist", NULL); + Filter = GetStringCatInfo(g, "Filter", NULL); + Pipe = GetBoolCatInfo("Pipeline", false); + Driver = GetStringCatInfo(g, "Driver", NULL); + Version = GetIntCatInfo("Version", 3); + Pretty = 0; #if defined(JAVA_SUPPORT) - if (Version == 2) - Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo2Interface"); - else - Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface"); + if (Version == 2) + Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo2Interface"); + else + Wrapname = GetStringCatInfo(g, "Wrapper", "Mongo3Interface"); #endif // JAVA_SUPPORT #else // !MONGO_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); - return true; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); + return true; #endif // !MONGO_SUPPORT - } // endif Uri + } // endif Uri - return DOSDEF::DefineAM(g, (Uri ? "XMGO" : "DOS"), poff); + return DOSDEF::DefineAM(g, (Uri ? "XMGO" : "DOS"), poff); } // end of DefineAM /***********************************************************************/ @@ -604,6 +604,9 @@ /***********************************************************************/ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) { + if (trace(1)) + htrc("JSON GetTable Pretty=%d Uri=%s\n", Pretty, SVP(Uri)); + if (Catfunc == FNC_COL) return new(g)TDBJCL(this); @@ -618,47 +621,47 @@ !(tmp == TMP_FORCE && (m == MODE_UPDATE || m == MODE_DELETE)); - if (Uri) { - if (Driver && toupper(*Driver) == 'C') { + if (Uri) { + if (Driver && toupper(*Driver) == 'C') { #if defined(CMGO_SUPPORT) - txfp = new(g) CMGFAM(this); + txfp = new(g) CMGFAM(this); #else - sprintf(g->Message, "Mongo %s Driver not available", "C"); - return NULL; + sprintf(g->Message, "Mongo %s Driver not available", "C"); + return NULL; #endif - } else if (Driver && toupper(*Driver) == 'J') { + } else if (Driver && toupper(*Driver) == 'J') { #if defined(JAVA_SUPPORT) - txfp = new(g) JMGFAM(this); + txfp = new(g) JMGFAM(this); #else - sprintf(g->Message, "Mongo %s Driver not available", "Java"); - return NULL; + sprintf(g->Message, "Mongo %s Driver not available", "Java"); + return NULL; #endif - } else { // Driver not specified + } else { // Driver not specified #if defined(CMGO_SUPPORT) - txfp = new(g) CMGFAM(this); + txfp = new(g) CMGFAM(this); #elif defined(JAVA_SUPPORT) - txfp = new(g) JMGFAM(this); -#else // !MONGO_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); - return NULL; + txfp = new(g) JMGFAM(this); +#else // !MONGO_SUPPORT + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "MONGO"); + return NULL; #endif // !MONGO_SUPPORT - } // endif Driver + } // endif Driver - } else if (Zipped) { + } else if (Zipped) { #if defined(ZIP_SUPPORT) - if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { - txfp = new(g) UNZFAM(this); - } else if (m == MODE_INSERT) { - txfp = new(g) ZIPFAM(this); - } else { - strcpy(g->Message, "UPDATE/DELETE not supported for ZIP"); - return NULL; - } // endif's m + if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { + txfp = new(g) UNZFAM(this); + } else if (m == MODE_INSERT) { + txfp = new(g) ZIPFAM(this); + } else { + strcpy(g->Message, "UPDATE/DELETE not supported for ZIP"); + return NULL; + } // endif's m #else // !ZIP_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); - return NULL; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); + return NULL; #endif // !ZIP_SUPPORT - } else if (Compressed) { + } else if (Compressed) { #if defined(GZ_SUPPORT) if (Compressed == 1) txfp = new(g) GZFAM(this); @@ -668,7 +671,7 @@ sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); return NULL; #endif // !GZ_SUPPORT - } else if (map) + } else if (map) txfp = new(g) MAPFAM(this); else txfp = new(g) DOSFAM(this); @@ -676,41 +679,41 @@ // Txfp must be set for TDBDOS tdbp = new(g) TDBJSN(this, txfp); - if (Lrecl) { - // Allocate the parse work memory - PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); - memset(G, 0, sizeof(GLOBAL)); - G->Sarea_Size = Lrecl * 10; - G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); - PlugSubSet(G->Sarea, G->Sarea_Size); - G->jump_level = 0; - ((TDBJSN*)tdbp)->G = G; - } else { - strcpy(g->Message, "LRECL is not defined"); - return NULL; - } // endif Lrecl + if (Lrecl) { + // Allocate the parse work memory + PGLOBAL G = (PGLOBAL)PlugSubAlloc(g, NULL, sizeof(GLOBAL)); + memset(G, 0, sizeof(GLOBAL)); + G->Sarea_Size = Lrecl * 10; + G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); + PlugSubSet(G->Sarea, G->Sarea_Size); + G->jump_level = 0; + ((TDBJSN*)tdbp)->G = G; + } else { + strcpy(g->Message, "LRECL is not defined"); + return NULL; + } // endif Lrecl - } else { - if (Zipped) { + } else { + if (Zipped) { #if defined(ZIP_SUPPORT) - if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { - txfp = new(g) UNZFAM(this); - } else if (m == MODE_INSERT) { - strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0"); - return NULL; - } else { - strcpy(g->Message, "UPDATE/DELETE not supported for ZIP"); - return NULL; - } // endif's m + if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) { + txfp = new(g) UNZFAM(this); + } else if (m == MODE_INSERT) { + strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0"); + return NULL; + } else { + strcpy(g->Message, "UPDATE/DELETE not supported for ZIP"); + return NULL; + } // endif's m #else // !ZIP_SUPPORT - sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); - return NULL; + sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP"); + return NULL; #endif // !ZIP_SUPPORT - } else - txfp = new(g) MAPFAM(this); + } else + txfp = new(g) MAPFAM(this); tdbp = new(g) TDBJSON(this, txfp); - ((TDBJSON*)tdbp)->G = g; + ((TDBJSON*)tdbp)->G = g; } // endif Pretty if (Multiple) @@ -738,16 +741,16 @@ Limit = tdp->Limit; Pretty = tdp->Pretty; B = tdp->Base ? 1 : 0; - Sep = tdp->Sep; + Sep = tdp->Sep; Strict = tdp->Strict; } else { Jmode = MODE_OBJECT; Objname = NULL; - Xcol = NULL; + Xcol = NULL; Limit = 1; Pretty = 0; B = 0; - Sep = '.'; + Sep = '.'; Strict = false; } // endif tdp @@ -761,7 +764,7 @@ TDBJSN::TDBJSN(TDBJSN *tdbp) : TDBDOS(NULL, tdbp) { - G = NULL; + G = NULL; Top = tdbp->Top; Row = tdbp->Row; Val = tdbp->Val; @@ -777,7 +780,7 @@ SameRow = tdbp->SameRow; Xval = tdbp->Xval; B = tdbp->B; - Sep = tdbp->Sep; + Sep = tdbp->Sep; Pretty = tdbp->Pretty; Strict = tdbp->Strict; Comma = tdbp->Comma; @@ -786,7 +789,7 @@ // Used for update PTDB TDBJSN::Clone(PTABS t) { - G = NULL; + G = NULL; PTDB tp; PJCOL cp1, cp2; PGLOBAL g = t->G; @@ -860,33 +863,33 @@ PJSON jsp = Row; PJVAL val = NULL; - for (objpath = PlugDup(g, Objname); jsp && objpath; objpath = p) { - if ((p = strchr(objpath, Sep))) - *p++ = 0; - - if (*objpath != '[' && !IsNum(objpath)) { // objpass is a key - val = (jsp->GetType() == TYPE_JOB) ? - jsp->GetObject()->GetValue(objpath) : NULL; - } else { - if (*objpath == '[') { - if (objpath[strlen(objpath) - 1] == ']') - objpath++; - else - return NULL; - } // endif [ - - val = (jsp->GetType() == TYPE_JAR) ? - jsp->GetArray()->GetValue(atoi(objpath) - B) : NULL; - } // endif objpath + for (objpath = PlugDup(g, Objname); jsp && objpath; objpath = p) { + if ((p = strchr(objpath, Sep))) + *p++ = 0; + + if (*objpath != '[' && !IsNum(objpath)) { // objpass is a key + val = (jsp->GetType() == TYPE_JOB) ? + jsp->GetObject()->GetValue(objpath) : NULL; + } else { + if (*objpath == '[') { + if (objpath[strlen(objpath) - 1] == ']') + objpath++; + else + return NULL; + } // endif [ + + val = (jsp->GetType() == TYPE_JAR) ? + jsp->GetArray()->GetValue(atoi(objpath) - B) : NULL; + } // endif objpath - jsp = (val) ? val->GetJson() : NULL; - } // endfor objpath + jsp = (val) ? val->GetJson() : NULL; + } // endfor objpath return jsp; } // end of FindRow /***********************************************************************/ -/* OpenDB: Data Base open routine for JSN access method. */ +/* OpenDB: Data Base open routine for JSN access method. */ /***********************************************************************/ bool TDBJSN::OpenDB(PGLOBAL g) { @@ -911,15 +914,15 @@ return true; } // endswitch Jmode - } // endif Use + } // endif Use - if (TDBDOS::OpenDB(g)) - return true; + if (TDBDOS::OpenDB(g)) + return true; - if (Xcol) - To_Filter = NULL; // Imcompatible + if (Xcol) + To_Filter = NULL; // Imcompatible - return false; + return false; } // end of OpenDB /***********************************************************************/ @@ -969,27 +972,27 @@ NextSame = 0; M++; return RC_OK; - } else if ((rc = TDBDOS::ReadDB(g)) == RC_OK) { - if (!IsRead() && ((rc = ReadBuffer(g)) != RC_OK)) - // Deferred reading failed - return rc; - - // Recover the memory used for parsing - PlugSubSet(G->Sarea, G->Sarea_Size); - - if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) { - Row = FindRow(g); - SameRow = 0; - Fpos++; - M = 1; - rc = RC_OK; - } else if (Pretty != 1 || strcmp(To_Line, "]")) { - strcpy(g->Message, G->Message); - rc = RC_FX; - } else - rc = RC_EF; + } else if ((rc = TDBDOS::ReadDB(g)) == RC_OK) { + if (!IsRead() && ((rc = ReadBuffer(g)) != RC_OK)) + // Deferred reading failed + return rc; + + // Recover the memory used for parsing + PlugSubSet(G->Sarea, G->Sarea_Size); + + if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) { + Row = FindRow(g); + SameRow = 0; + Fpos++; + M = 1; + rc = RC_OK; + } else if (Pretty != 1 || strcmp(To_Line, "]")) { + strcpy(g->Message, G->Message); + rc = RC_FX; + } else + rc = RC_EF; - } // endif ReadDB + } // endif ReadDB return rc; } // end of ReadDB @@ -999,68 +1002,68 @@ /***********************************************************************/ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) { - if (Objname) { - if (!Val) { - // Parse and allocate Objname item(s) - char *p; - char *objpath = PlugDup(g, Objname); - int i; - PJOB objp; - PJAR arp; - PJVAL val = NULL; - - Top = NULL; - - for (; objpath; objpath = p) { - if ((p = strchr(objpath, Sep))) - *p++ = 0; - - if (*objpath != '[' && !IsNum(objpath)) { - objp = new(g) JOBJECT; - - if (!Top) - Top = objp; - - if (val) - val->SetValue(objp); - - val = new(g) JVALUE; - objp->SetValue(g, val, objpath); - } else { - if (*objpath == '[') { - // Old style - if (objpath[strlen(objpath) - 1] != ']') { - sprintf(g->Message, "Invalid Table path %s", Objname); - return RC_FX; - } else - objpath++; - - } // endif objpath - - arp = new(g) JARRAY; - - if (!Top) - Top = arp; - - if (val) - val->SetValue(arp); - - val = new(g) JVALUE; - i = atoi(objpath) - B; - arp->SetValue(g, val, i); - arp->InitArray(g); - } // endif objpath - - } // endfor p - - Val = val; - } // endif Val - - Val->SetValue(jsp); - } else - Top = jsp; + if (Objname) { + if (!Val) { + // Parse and allocate Objname item(s) + char *p; + char *objpath = PlugDup(g, Objname); + int i; + PJOB objp; + PJAR arp; + PJVAL val = NULL; + + Top = NULL; + + for (; objpath; objpath = p) { + if ((p = strchr(objpath, Sep))) + *p++ = 0; + + if (*objpath != '[' && !IsNum(objpath)) { + objp = new(g) JOBJECT; + + if (!Top) + Top = objp; + + if (val) + val->SetValue(objp); + + val = new(g) JVALUE; + objp->SetValue(g, val, objpath); + } else { + if (*objpath == '[') { + // Old style + if (objpath[strlen(objpath) - 1] != ']') { + sprintf(g->Message, "Invalid Table path %s", Objname); + return RC_FX; + } else + objpath++; + + } // endif objpath - return RC_OK; + arp = new(g) JARRAY; + + if (!Top) + Top = arp; + + if (val) + val->SetValue(arp); + + val = new(g) JVALUE; + i = atoi(objpath) - B; + arp->SetValue(g, val, i); + arp->InitArray(g); + } // endif objpath + + } // endfor p + + Val = val; + } // endif Val + + Val->SetValue(jsp); + } else + Top = jsp; + + return RC_OK; } // end of MakeTopTree /***********************************************************************/ @@ -1095,11 +1098,11 @@ /***********************************************************************/ int TDBJSN::WriteDB(PGLOBAL g) { - int rc = TDBDOS::WriteDB(g); + int rc = TDBDOS::WriteDB(g); - PlugSubSet(G->Sarea, G->Sarea_Size); - Row->Clear(); - return rc; + PlugSubSet(G->Sarea, G->Sarea_Size); + Row->Clear(); + return rc; } // end of WriteDB /* ---------------------------- JSONCOL ------------------------------ */ @@ -1111,12 +1114,12 @@ : DOSCOL(g, cdp, tdbp, cprec, i, "DOS") { Tjp = (TDBJSN *)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp); - G = Tjp->G; + G = Tjp->G; Jpath = cdp->GetFmt(); MulVal = NULL; Nodes = NULL; Nod = 0; - Sep = Tjp->Sep; + Sep = Tjp->Sep; Xnod = -1; Xpd = false; Parsed = false; @@ -1128,14 +1131,14 @@ /***********************************************************************/ JSONCOL::JSONCOL(JSONCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) { - G = col1->G; + G = col1->G; Tjp = col1->Tjp; Jpath = col1->Jpath; MulVal = col1->MulVal; Nodes = col1->Nodes; Nod = col1->Nod; - Sep = col1->Sep; - Xnod = col1->Xnod; + Sep = col1->Sep; + Xnod = col1->Xnod; Xpd = col1->Xpd; Parsed = col1->Parsed; } // end of JSONCOL copy constructor @@ -1153,7 +1156,7 @@ return true; Tjp = (TDBJSN*)To_Tdb; - G = Tjp->G; + G = Tjp->G; return false; } // end of SetBuffer @@ -1179,130 +1182,130 @@ /***********************************************************************/ bool JSONCOL::SetArrayOptions(PGLOBAL g, char *p, int i, PSZ nm) { - int n; - bool dg = true, b = false; - PJNODE jnp = &Nodes[i]; - - //if (*p == '[') p++; // Old syntax .[ or :[ - n = (int)strlen(p); - - if (*p) { - if (p[n - 1] == ']') { - p[--n] = 0; - } else if (!IsNum(p)) { - // Wrong array specification - sprintf(g->Message, "Invalid array specification %s for %s", p, Name); - return true; - } // endif p - - } else - b = true; - - // To check whether a numeric Rank was specified - dg = IsNum(p); - - if (!n) { - // Default specifications - if (CheckExpand(g, i, nm, false)) - return true; - else if (jnp->Op != OP_EXP) { - if (b) { - // Return 1st value (B is the index base) - jnp->Rank = Tjp->B; - jnp->Op = OP_EQ; - } else if (!Value->IsTypeNum()) { - jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING); - jnp->Op = OP_CNC; - } else - jnp->Op = OP_ADD; - - } // endif OP - - } else if (dg) { - // Return nth value - jnp->Rank = atoi(p) - Tjp->B; - jnp->Op = OP_EQ; - } else if (n == 1) { - // Set the Op value; - if (Sep == ':') - switch (*p) { - case '*': *p = 'x'; break; - case 'x': - case 'X': *p = '*'; break; // Expand this array - default: break; - } // endswitch p - - switch (*p) { - case '+': jnp->Op = OP_ADD; break; - case 'x': jnp->Op = OP_MULT; break; - case '>': jnp->Op = OP_MAX; break; - case '<': jnp->Op = OP_MIN; break; - case '!': jnp->Op = OP_SEP; break; // Average - case '#': jnp->Op = OP_NUM; break; - case '*': // Expand this array - if (!Tjp->Xcol && nm) { - Xpd = true; - jnp->Op = OP_EXP; - Tjp->Xval = i; - Tjp->Xcol = nm; - } else if (CheckExpand(g, i, nm, true)) - return true; - - break; - default: - sprintf(g->Message, - "Invalid function specification %c for %s", *p, Name); - return true; - } // endswitch *p - - } else if (*p == '"' && p[n - 1] == '"') { - // This is a concat specification - jnp->Op = OP_CNC; - - if (n > 2) { - // Set concat intermediate string - p[n - 1] = 0; - jnp->CncVal = AllocateValue(g, p + 1, TYPE_STRING); - } // endif n - - } else { - sprintf(g->Message, "Wrong array specification for %s", Name); - return true; - } // endif's - - // For calculated arrays, a local Value must be used - switch (jnp->Op) { - case OP_NUM: - jnp->Valp = AllocateValue(g, TYPE_INT); - break; - case OP_ADD: - case OP_MULT: - case OP_SEP: - if (!IsTypeChar(Buf_Type)) - jnp->Valp = AllocateValue(g, Buf_Type, 0, GetPrecision()); - else - jnp->Valp = AllocateValue(g, TYPE_DOUBLE, 0, 2); - - break; - case OP_MIN: - case OP_MAX: - jnp->Valp = AllocateValue(g, Buf_Type, Long, GetPrecision()); - break; - case OP_CNC: - if (IsTypeChar(Buf_Type)) - jnp->Valp = AllocateValue(g, TYPE_STRING, Long, GetPrecision()); - else - jnp->Valp = AllocateValue(g, TYPE_STRING, 512); - - break; - default: - break; - } // endswitch Op + int n; + bool dg = true, b = false; + PJNODE jnp = &Nodes[i]; + + //if (*p == '[') p++; // Old syntax .[ or :[ + n = (int)strlen(p); + + if (*p) { + if (p[n - 1] == ']') { + p[--n] = 0; + } else if (!IsNum(p)) { + // Wrong array specification + sprintf(g->Message, "Invalid array specification %s for %s", p, Name); + return true; + } // endif p + + } else + b = true; + + // To check whether a numeric Rank was specified + dg = IsNum(p); + + if (!n) { + // Default specifications + if (CheckExpand(g, i, nm, false)) + return true; + else if (jnp->Op != OP_EXP) { + if (b) { + // Return 1st value (B is the index base) + jnp->Rank = Tjp->B; + jnp->Op = OP_EQ; + } else if (!Value->IsTypeNum()) { + jnp->CncVal = AllocateValue(g, (void*)", ", TYPE_STRING); + jnp->Op = OP_CNC; + } else + jnp->Op = OP_ADD; + + } // endif OP - if (jnp->Valp) - MulVal = AllocateValue(g, jnp->Valp); + } else if (dg) { + // Return nth value + jnp->Rank = atoi(p) - Tjp->B; + jnp->Op = OP_EQ; + } else if (n == 1) { + // Set the Op value; + if (Sep == ':') + switch (*p) { + case '*': *p = 'x'; break; + case 'x': + case 'X': *p = '*'; break; // Expand this array + default: break; + } // endswitch p + + switch (*p) { + case '+': jnp->Op = OP_ADD; break; + case 'x': jnp->Op = OP_MULT; break; + case '>': jnp->Op = OP_MAX; break; + case '<': jnp->Op = OP_MIN; break; + case '!': jnp->Op = OP_SEP; break; // Average + case '#': jnp->Op = OP_NUM; break; + case '*': // Expand this array + if (!Tjp->Xcol && nm) { + Xpd = true; + jnp->Op = OP_EXP; + Tjp->Xval = i; + Tjp->Xcol = nm; + } else if (CheckExpand(g, i, nm, true)) + return true; - return false; + break; + default: + sprintf(g->Message, + "Invalid function specification %c for %s", *p, Name); + return true; + } // endswitch *p + + } else if (*p == '"' && p[n - 1] == '"') { + // This is a concat specification + jnp->Op = OP_CNC; + + if (n > 2) { + // Set concat intermediate string + p[n - 1] = 0; + jnp->CncVal = AllocateValue(g, p + 1, TYPE_STRING); + } // endif n + + } else { + sprintf(g->Message, "Wrong array specification for %s", Name); + return true; + } // endif's + + // For calculated arrays, a local Value must be used + switch (jnp->Op) { + case OP_NUM: + jnp->Valp = AllocateValue(g, TYPE_INT); + break; + case OP_ADD: + case OP_MULT: + case OP_SEP: + if (!IsTypeChar(Buf_Type)) + jnp->Valp = AllocateValue(g, Buf_Type, 0, GetPrecision()); + else + jnp->Valp = AllocateValue(g, TYPE_DOUBLE, 0, 2); + + break; + case OP_MIN: + case OP_MAX: + jnp->Valp = AllocateValue(g, Buf_Type, Long, GetPrecision()); + break; + case OP_CNC: + if (IsTypeChar(Buf_Type)) + jnp->Valp = AllocateValue(g, TYPE_STRING, Long, GetPrecision()); + else + jnp->Valp = AllocateValue(g, TYPE_STRING, 512); + + break; + default: + break; + } // endswitch Op + + if (jnp->Valp) + MulVal = AllocateValue(g, jnp->Valp); + + return false; } // end of SetArrayOptions /***********************************************************************/ @@ -1313,87 +1316,87 @@ /***********************************************************************/ bool JSONCOL::ParseJpath(PGLOBAL g) { - char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; - int i; - bool a, mul = false; - - if (Parsed) - return false; // Already done - else if (InitValue(g)) - return true; - else if (!Jpath) - Jpath = Name; - - if (To_Tdb->GetOrig()) { - // This is an updated column, get nodes from origin - for (PJCOL colp = (PJCOL)Tjp->GetColumns(); colp; - colp = (PJCOL)colp->GetNext()) - if (!stricmp(Name, colp->GetName())) { - Nod = colp->Nod; - Nodes = colp->Nodes; - Xpd = colp->Xpd; - goto fin; - } // endif Name - - sprintf(g->Message, "Cannot parse updated column %s", Name); - return true; - } // endif To_Orig - - pbuf = PlugDup(g, Jpath); - if (*pbuf == '$') pbuf++; - if (*pbuf == Sep) pbuf++; - if (*pbuf == '[') p1 = pbuf++; - - // Estimate the required number of nodes - for (i = 0, p = pbuf; (p = NextChr(p, Sep)); i++, p++) - Nod++; // One path node found - - Nodes = (PJNODE)PlugSubAlloc(g, NULL, (++Nod) * sizeof(JNODE)); - memset(Nodes, 0, (Nod) * sizeof(JNODE)); - - // Analyze the Jpath for this column - for (i = 0, p = pbuf; p && i < Nod; i++, p = (p2 ? p2 : NULL)) { - a = (p1 != NULL); - p1 = strchr(p, '['); - p2 = strchr(p, Sep); - - if (!p2) - p2 = p1; - else if (p1) { - if (p1 < p2) - p2 = p1; - else if (p1 == p2 + 1) - *p2++ = 0; // Old syntax .[ or :[ - else - p1 = NULL; - - } // endif p1 - - if (p2) - *p2++ = 0; - - // Jpath must be explicit - if (a || *p == 0 || *p == '[' || IsNum(p)) { - // Analyse intermediate array processing - if (SetArrayOptions(g, p, i, Nodes[i - 1].Key)) - return true; - - } else if (*p == '*') { - // Return JSON - Nodes[i].Op = OP_XX; - } else { - Nodes[i].Key = p; - Nodes[i].Op = OP_EXIST; - } // endif's + char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; + int i; + bool a, mul = false; + + if (Parsed) + return false; // Already done + else if (InitValue(g)) + return true; + else if (!Jpath) + Jpath = Name; + + if (To_Tdb->GetOrig()) { + // This is an updated column, get nodes from origin + for (PJCOL colp = (PJCOL)Tjp->GetColumns(); colp; + colp = (PJCOL)colp->GetNext()) + if (!stricmp(Name, colp->GetName())) { + Nod = colp->Nod; + Nodes = colp->Nodes; + Xpd = colp->Xpd; + goto fin; + } // endif Name + + sprintf(g->Message, "Cannot parse updated column %s", Name); + return true; + } // endif To_Orig + + pbuf = PlugDup(g, Jpath); + if (*pbuf == '$') pbuf++; + if (*pbuf == Sep) pbuf++; + if (*pbuf == '[') p1 = pbuf++; + + // Estimate the required number of nodes + for (i = 0, p = pbuf; (p = NextChr(p, Sep)); i++, p++) + Nod++; // One path node found + + Nodes = (PJNODE)PlugSubAlloc(g, NULL, (++Nod) * sizeof(JNODE)); + memset(Nodes, 0, (Nod) * sizeof(JNODE)); + + // Analyze the Jpath for this column + for (i = 0, p = pbuf; p && i < Nod; i++, p = (p2 ? p2 : NULL)) { + a = (p1 != NULL); + p1 = strchr(p, '['); + p2 = strchr(p, Sep); + + if (!p2) + p2 = p1; + else if (p1) { + if (p1 < p2) + p2 = p1; + else if (p1 == p2 + 1) + *p2++ = 0; // Old syntax .[ or :[ + else + p1 = NULL; + + } // endif p1 + + if (p2) + *p2++ = 0; - } // endfor i, p + // Jpath must be explicit + if (a || *p == 0 || *p == '[' || IsNum(p)) { + // Analyse intermediate array processing + if (SetArrayOptions(g, p, i, Nodes[i - 1].Key)) + return true; + + } else if (*p == '*') { + // Return JSON + Nodes[i].Op = OP_XX; + } else { + Nodes[i].Key = p; + Nodes[i].Op = OP_EXIST; + } // endif's - Nod = i; + } // endfor i, p + + Nod = i; fin: - MulVal = AllocateValue(g, Value); - Parsed = true; - return false; + MulVal = AllocateValue(g, Value); + Parsed = true; + return false; } // end of ParseJpath /***********************************************************************/ @@ -1401,66 +1404,66 @@ /***********************************************************************/ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj) { - if (Jpath) { - char *p1, *p2, *mgopath; - int i = 0; - - if (strcmp(Jpath, "*")) { - p1 = Jpath; - if (*p1 == '$') p1++; - if (*p1 == '.') p1++; - mgopath = PlugDup(g, p1); - } else - return NULL; - - for (p1 = p2 = mgopath; *p1; p1++) - if (i) { // Inside [] - if (isdigit(*p1)) { - if (!proj) - *p2++ = *p1; - - } else if (*p1 == ']' && i == 1) { - if (proj && p1[1] == '.') - p1++; - - i = 0; - } else if (*p1 == '.' && i == 2) { - if (!proj) - *p2++ = '.'; - - i = 0; - } else if (!proj) - return NULL; - - } else switch (*p1) { - case ':': - case '.': - if (isdigit(p1[1])) - i = 2; - - *p2++ = '.'; - break; - case '[': - if (*(p2 - 1) != '.') - *p2++ = '.'; - - i = 1; - break; - case '*': - if (*(p2 - 1) == '.' && !*(p1 + 1)) { - p2--; // Suppress last :* - break; - } // endif p2 - - default: - *p2++ = *p1; - break; - } // endswitch p1; - - *p2 = 0; - return mgopath; - } else - return NULL; + if (Jpath) { + char *p1, *p2, *mgopath; + int i = 0; + + if (strcmp(Jpath, "*")) { + p1 = Jpath; + if (*p1 == '$') p1++; + if (*p1 == '.') p1++; + mgopath = PlugDup(g, p1); + } else + return NULL; + + for (p1 = p2 = mgopath; *p1; p1++) + if (i) { // Inside [] + if (isdigit(*p1)) { + if (!proj) + *p2++ = *p1; + + } else if (*p1 == ']' && i == 1) { + if (proj && p1[1] == '.') + p1++; + + i = 0; + } else if (*p1 == '.' && i == 2) { + if (!proj) + *p2++ = '.'; + + i = 0; + } else if (!proj) + return NULL; + + } else switch (*p1) { + case ':': + case '.': + if (isdigit(p1[1])) + i = 2; + + *p2++ = '.'; + break; + case '[': + if (*(p2 - 1) != '.') + *p2++ = '.'; + + i = 1; + break; + case '*': + if (*(p2 - 1) == '.' && !*(p1 + 1)) { + p2--; // Suppress last :* + break; + } // endif p2 + + default: + *p2++ = *p1; + break; + } // endswitch p1; + + *p2 = 0; + return mgopath; + } else + return NULL; } // end of GetJpath @@ -1469,7 +1472,7 @@ /***********************************************************************/ PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp) { - if (Value->IsTypeNum()) { + if (Value->IsTypeNum()) { strcpy(g->Message, "Cannot make Json for a numeric column"); Value->Reset(); } else @@ -1484,22 +1487,22 @@ void JSONCOL::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n) { if (val) { - vp->SetNull(false); + vp->SetNull(false); switch (val->GetValType()) { case TYPE_STRG: case TYPE_INTG: - case TYPE_BINT: - case TYPE_DBL: - case TYPE_DTM: - vp->SetValue_pval(val->GetValue()); + case TYPE_BINT: + case TYPE_DBL: + case TYPE_DTM: + vp->SetValue_pval(val->GetValue()); break; case TYPE_BOOL: if (vp->IsTypeNum()) vp->SetValue(val->GetInteger() ? 1 : 0); else vp->SetValue_psz((PSZ)(val->GetInteger() ? "true" : "false")); - + break; case TYPE_JAR: SetJsonValue(g, vp, val->GetArray()->GetValue(0), n); @@ -1509,16 +1512,16 @@ vp->SetValue_psz(val->GetObject()->GetText(g, NULL)); break; // } // endif Type - + default: - vp->Reset(); - vp->SetNull(true); - } // endswitch Type - - } else { - vp->Reset(); - vp->SetNull(true); - } // endif val + vp->Reset(); + vp->SetNull(true); + } // endswitch Type + + } else { + vp->Reset(); + vp->SetNull(true); + } // endif val } // end of SetJsonValue @@ -1530,8 +1533,8 @@ if (!Tjp->SameRow || Xnod >= Tjp->SameRow) Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0)); - if (Xpd && Value->IsNull() && !((PJDEF)Tjp->To_Def)->Accept) - throw("Null expandable JSON value"); + if (Xpd && Value->IsNull() && !((PJDEF)Tjp->To_Def)->Accept) + throw("Null expandable JSON value"); // Set null when applicable if (!Nullable) @@ -1579,11 +1582,11 @@ else return CalculateArray(g, arp, i); - } else { - // Unexpected array, unwrap it as [0] - val = arp->GetValue(0); - i--; - } // endif's + } else { + // Unexpected array, unwrap it as [0] + val = arp->GetValue(0); + i--; + } // endif's break; case TYPE_JVAL: @@ -1612,17 +1615,17 @@ PJVAL jvp; JVALUE jval; - if (!ars) { - Value->Reset(); - Value->SetNull(true); - Tjp->NextSame = 0; - return Value; - } // endif ars + if (!ars) { + Value->Reset(); + Value->SetNull(true); + Tjp->NextSame = 0; + return Value; + } // endif ars if (!(jvp = arp->GetValue((Nodes[n].Rx = Nodes[n].Nx)))) { strcpy(g->Message, "Logical error expanding array"); - throw 666; - } // endif jvp + throw 666; + } // endif jvp if (n < Nod - 1 && jvp->GetJson()) { jval.SetValue(GetColumnValue(g, jvp->GetJson(), n + 1)); @@ -1637,7 +1640,7 @@ Xnod = n; Tjp->NextSame = Xnod; - } // endif NextSame + } // endif NextSame SetJsonValue(g, Value, jvp, n); return Value; @@ -1648,58 +1651,58 @@ /***********************************************************************/ PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n) { - int i, ars, nv = 0, nextsame = Tjp->NextSame; - bool err; + int i, ars, nv = 0, nextsame = Tjp->NextSame; + bool err; OPVAL op = Nodes[n].Op; PVAL val[2], vp = Nodes[n].Valp; PJVAL jvrp, jvp; JVALUE jval; vp->Reset(); - ars = MY_MIN(Tjp->Limit, arp->size()); + ars = MY_MIN(Tjp->Limit, arp->size()); + + if (trace(1)) + htrc("CalculateArray: size=%d op=%d nextsame=%d\n", + ars, op, nextsame); + + for (i = 0; i < ars; i++) { + jvrp = arp->GetValue(i); - if (trace(1)) - htrc("CalculateArray: size=%d op=%d nextsame=%d\n", - ars, op, nextsame); - - for (i = 0; i < ars; i++) { - jvrp = arp->GetValue(i); - - if (trace(1)) - htrc("i=%d nv=%d\n", i, nv); - - if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do { - if (jvrp->IsNull()) { - jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING); - jvp = jvrp; - } else if (n < Nod - 1 && jvrp->GetJson()) { + if (trace(1)) + htrc("i=%d nv=%d\n", i, nv); + + if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do { + if (jvrp->IsNull()) { + jvrp->Value = AllocateValue(g, GetJsonNull(), TYPE_STRING); + jvp = jvrp; + } else if (n < Nod - 1 && jvrp->GetJson()) { Tjp->NextSame = nextsame; jval.SetValue(GetColumnValue(g, jvrp->GetJson(), n + 1)); jvp = &jval; } else jvp = jvrp; - - if (trace(1)) - htrc("jvp=%s null=%d\n", - jvp->GetString(g), jvp->IsNull() ? 1 : 0); - if (!nv++) { + if (trace(1)) + htrc("jvp=%s null=%d\n", + jvp->GetString(g), jvp->IsNull() ? 1 : 0); + + if (!nv++) { SetJsonValue(g, vp, jvp, n); continue; } else SetJsonValue(g, MulVal, jvp, n); - if (!MulVal->IsNull()) { - switch (op) { + if (!MulVal->IsNull()) { + switch (op) { case OP_CNC: if (Nodes[n].CncVal) { val[0] = Nodes[n].CncVal; err = vp->Compute(g, val, 1, op); } // endif CncVal - + val[0] = MulVal; err = vp->Compute(g, val, 1, op); - break; + break; // case OP_NUM: case OP_SEP: val[0] = Nodes[n].Valp; @@ -1714,16 +1717,16 @@ if (err) vp->Reset(); - - if (trace(1)) { - char buf(32); - htrc("vp='%s' err=%d\n", - vp->GetCharString(&buf), err ? 1 : 0); + if (trace(1)) { + char buf(32); - } // endif trace + htrc("vp='%s' err=%d\n", + vp->GetCharString(&buf), err ? 1 : 0); - } // endif Null + } // endif trace + + } // endif Null } while (Tjp->NextSame > nextsame); @@ -1753,8 +1756,8 @@ PJAR arp; PJSON nwr, row = Tjp->Row; - for (int i = 0; i < Nod && row; i++) { - if (Nodes[i+1].Op == OP_XX) + for (int i = 0; i < Nod && row; i++) { + if (Nodes[i+1].Op == OP_XX) break; else switch (row->GetType()) { case TYPE_JOB: @@ -1765,19 +1768,19 @@ val = ((PJOB)row)->GetValue(Nodes[i].Key); break; case TYPE_JAR: - arp = (PJAR)row; + arp = (PJAR)row; - if (!Nodes[i].Key) { + if (!Nodes[i].Key) { if (Nodes[i].Op == OP_EQ) val = arp->GetValue(Nodes[i].Rank); else val = arp->GetValue(Nodes[i].Rx); } else { - // Unexpected array, unwrap it as [0] - val = arp->GetValue(0); - i--; - } // endif Nodes + // Unexpected array, unwrap it as [0] + val = arp->GetValue(0); + i--; + } // endif Nodes break; case TYPE_JVAL: @@ -1827,10 +1830,10 @@ /***********************************************************************/ void JSONCOL::WriteColumn(PGLOBAL g) { - if (Xpd && Tjp->Pretty < 2) { - strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); - throw 666; - } // endif Xpd + if (Xpd && Tjp->Pretty < 2) { + strcpy(g->Message, "Cannot write expanded column when Pretty is not 2"); + throw 666; + } // endif Xpd /*********************************************************************/ /* Check whether this node must be written. */ @@ -1864,8 +1867,8 @@ if (!(jsp = ParseJson(G, s, (int)strlen(s)))) { strcpy(g->Message, s); - throw 666; - } // endif jsp + throw 666; + } // endif jsp if (arp) { if (Nod > 1 && Nodes[Nod-2].Op == OP_EQ) @@ -1887,10 +1890,10 @@ // fall through case TYPE_DATE: case TYPE_INT: - case TYPE_TINY: - case TYPE_SHORT: - case TYPE_BIGINT: - case TYPE_DOUBLE: + case TYPE_TINY: + case TYPE_SHORT: + case TYPE_BIGINT: + case TYPE_DOUBLE: if (arp) { if (Nodes[Nod-1].Op == OP_EQ) arp->SetValue(G, new(G) JVALUE(G, Value), Nodes[Nod-1].Rank); @@ -1981,7 +1984,7 @@ return RC_OK; /*********************************************************************/ - /* Create the mapping file object in mode read. */ + /* Create the mapping file object in mode read. */ /*********************************************************************/ Mode = MODE_READ; @@ -2010,70 +2013,70 @@ if (!jsp && g->Message[0]) return RC_FX; - if ((objpath = PlugDup(g, Objname))) { - if (*objpath == '$') objpath++; - if (*objpath == '.') objpath++; - - /*********************************************************************/ - /* Find the table in the tree structure. */ - /*********************************************************************/ - for (; jsp && objpath; objpath = p) { - if ((p = strchr(objpath, Sep))) - *p++ = 0; - - if (*objpath != '[' && !IsNum(objpath)) { - // objpass is a key - if (jsp->GetType() != TYPE_JOB) { - strcpy(g->Message, "Table path does not match the json file"); - return RC_FX; - } // endif Type - - key = objpath; - objp = jsp->GetObject(); - arp = NULL; - val = objp->GetValue(key); - - if (!val || !(jsp = val->GetJson())) { - sprintf(g->Message, "Cannot find object key %s", key); - return RC_FX; - } // endif val - - } else { - if (*objpath == '[') { - // Old style - if (objpath[strlen(objpath) - 1] != ']') { - sprintf(g->Message, "Invalid Table path %s", Objname); - return RC_FX; - } else - objpath++; - - } // endif objpath - - if (jsp->GetType() != TYPE_JAR) { - strcpy(g->Message, "Table path does not match the json file"); - return RC_FX; - } // endif Type - - arp = jsp->GetArray(); - objp = NULL; - i = atoi(objpath) - B; - val = arp->GetValue(i); - - if (!val) { - sprintf(g->Message, "Cannot find array value %d", i); - return RC_FX; - } // endif val + if ((objpath = PlugDup(g, Objname))) { + if (*objpath == '$') objpath++; + if (*objpath == '.') objpath++; + + /*********************************************************************/ + /* Find the table in the tree structure. */ + /*********************************************************************/ + for (; jsp && objpath; objpath = p) { + if ((p = strchr(objpath, Sep))) + *p++ = 0; + + if (*objpath != '[' && !IsNum(objpath)) { + // objpass is a key + if (jsp->GetType() != TYPE_JOB) { + strcpy(g->Message, "Table path does not match the json file"); + return RC_FX; + } // endif Type + + key = objpath; + objp = jsp->GetObject(); + arp = NULL; + val = objp->GetValue(key); + + if (!val || !(jsp = val->GetJson())) { + sprintf(g->Message, "Cannot find object key %s", key); + return RC_FX; + } // endif val + + } else { + if (*objpath == '[') { + // Old style + if (objpath[strlen(objpath) - 1] != ']') { + sprintf(g->Message, "Invalid Table path %s", Objname); + return RC_FX; + } else + objpath++; + + } // endif objpath + + if (jsp->GetType() != TYPE_JAR) { + strcpy(g->Message, "Table path does not match the json file"); + return RC_FX; + } // endif Type + + arp = jsp->GetArray(); + objp = NULL; + i = atoi(objpath) - B; + val = arp->GetValue(i); + + if (!val) { + sprintf(g->Message, "Cannot find array value %d", i); + return RC_FX; + } // endif val - } // endif + } // endif - jsp = val->GetJson(); - } // endfor objpath + jsp = val->GetJson(); + } // endfor objpath - } // endif objpath + } // endif objpath if (jsp && jsp->GetType() == TYPE_JAR) Doc = jsp->GetArray(); - else { + else { // The table is void or is just one object or one value Doc = new(g) JARRAY; @@ -2149,7 +2152,7 @@ } else return RC_OK; - } // end of MakeIndex + } // end of MakeIndex /***********************************************************************/ /* Return the position in the table. */ @@ -2227,11 +2230,11 @@ return true; } // endswitch Jmode - if (Xcol) - To_Filter = NULL; // Imcompatible + if (Xcol) + To_Filter = NULL; // Imcompatible - Use = USE_OPEN; - return false; + Use = USE_OPEN; + return false; } // end of OpenDB /***********************************************************************/ @@ -2241,7 +2244,7 @@ { int rc; - N++; + N++; if (NextSame) { SameRow = NextSame; @@ -2352,8 +2355,8 @@ TDBJCL::TDBJCL(PJDEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); - Db = tdp->Schema; - Dsn = tdp->Uri; + Db = tdp->Schema; + Dsn = tdp->Uri; } // end of TDBJCL constructor /***********************************************************************/ diff -Nru mariadb-10.1-10.1.41/storage/connect/tabrest.cpp mariadb-10.1-10.1.43/storage/connect/tabrest.cpp --- mariadb-10.1-10.1.41/storage/connect/tabrest.cpp 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabrest.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,201 @@ +/*************** Rest C++ Program Source Code File (.CPP) **************/ +/* PROGRAM NAME: Rest Version 1.5 */ +/* (C) Copyright to the author Olivier BERTRAND 2018 - 2019 */ +/* This program is the REST Web API support for MariaDB. */ +/* When compiled without MARIADB defined, it is the EOM module code. */ +/***********************************************************************/ + +/***********************************************************************/ +/* Definitions needed by the included files. */ +/***********************************************************************/ +#if defined(MARIADB) +#include // All MariaDB stuff +#else // !MARIADB OEM module +#include "mini-global.h" +#define _MAX_PATH 260 +#if !defined(__WIN__) +#define __stdcall +#endif // !__WIN__ +#define _OS_H_INCLUDED // Prevent os.h to be called +#endif // !MARIADB + +/***********************************************************************/ +/* Include application header files: */ +/* global.h is header containing all global declarations. */ +/* plgdbsem.h is header containing the DB application declarations. */ +/* (x)table.h is header containing the TDBASE declarations. */ +/***********************************************************************/ +#include "global.h" +#include "plgdbsem.h" +#include "xtable.h" +#include "filamtxt.h" +#include "tabdos.h" +#include "plgxml.h" +#include "tabxml.h" +#include "tabjson.h" +#include "tabfmt.h" +#include "tabrest.h" + +/***********************************************************************/ +/* Get the file from the Web. */ +/***********************************************************************/ +int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn); + +#if defined(__WIN__) +static PCSZ slash = "\\"; +#else // !__WIN__ +static PCSZ slash = "/"; +#define stricmp strcasecmp +#endif // !__WIN__ + +#if !defined(MARIADB) +/***********************************************************************/ +/* DB static variables. */ +/***********************************************************************/ +int TDB::Tnum; +int DTVAL::Shift; +int CSORT::Limit = 0; +double CSORT::Lg2 = log(2.0); +size_t CSORT::Cpn[1000] = { 0 }; + +/***********************************************************************/ +/* These functions are exported from the REST library. */ +/***********************************************************************/ +extern "C" { + PTABDEF __stdcall GetREST(PGLOBAL, void*); + PQRYRES __stdcall ColREST(PGLOBAL, PTOS, char*, char*, bool); +} // extern "C" + +/***********************************************************************/ +/* This function returns a table definition class. */ +/***********************************************************************/ +PTABDEF __stdcall GetREST(PGLOBAL g, void *memp) +{ + return new(g, memp) RESTDEF; +} // end of GetREST +#endif // !MARIADB + +/***********************************************************************/ +/* Return the columns definition to MariaDB. */ +/***********************************************************************/ +#if defined(MARIADB) +PQRYRES RESTColumns(PGLOBAL g, PTOS tp, char *tab, char *db, bool info) +#else // !MARIADB +PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info) +#endif // !MARIADB +{ + PQRYRES qrp= NULL; + char filename[_MAX_PATH + 1]; // MAX PATH ??? + PCSZ http, uri, fn, ftype; + + http = GetStringTableOption(g, tp, "Http", NULL); + uri = GetStringTableOption(g, tp, "Uri", NULL); + fn = GetStringTableOption(g, tp, "Filename", "rest.json"); +#if defined(MARIADB) + ftype = GetStringTableOption(g, tp, "Type", "JSON"); +#else // !MARIADB + // OEM tables must specify the file type + ftype = GetStringTableOption(g, tp, "Ftype", "JSON"); +#endif // !MARIADB + + // We used the file name relative to recorded datapath + strcat(strcat(strcat(strcpy(filename, "."), slash), db), slash); + strncat(filename, fn, _MAX_PATH); + + // Retrieve the file from the web and copy it locally + if (http && restGetFile(g, http, uri, filename)) { + // sprintf(g->Message, "Failed to get file at %s", http); + } else if (!stricmp(ftype, "XML")) + qrp = XMLColumns(g, db, tab, tp, info); + else if (!stricmp(ftype, "JSON")) + qrp = JSONColumns(g, db, NULL, tp, info); + else if (!stricmp(ftype, "CSV")) + qrp = CSVColumns(g, NULL, tp, info); + else + sprintf(g->Message, "Usupported file type %s", ftype); + + return qrp; +} // end of RESTColumns + +/* -------------------------- Class RESTDEF -------------------------- */ + +/***********************************************************************/ +/* DefineAM: define specific AM block values. */ +/***********************************************************************/ +bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) +{ + char filename[_MAX_PATH + 1]; + int rc = 0, n; + LPCSTR ftype; + +#if defined(MARIADB) + ftype = GetStringCatInfo(g, "Type", "JSON"); +#else // !MARIADB + // OEM tables must specify the file type + ftype = GetStringCatInfo(g, "Ftype", "JSON"); +#endif // !MARIADB + + if (trace(515)) + htrc("ftype = %s am = %s\n", ftype, SVP(am)); + + n = (!stricmp(ftype, "JSON")) ? 1 + : (!stricmp(ftype, "XML")) ? 2 + : (!stricmp(ftype, "CSV")) ? 3 : 0; + + if (n == 0) { + htrc("DefineAM: Unsupported REST table type %s", am); + sprintf(g->Message, "Unsupported REST table type %s", am); + return true; + } // endif n + + Http = GetStringCatInfo(g, "Http", NULL); + Uri = GetStringCatInfo(g, "Uri", NULL); + Fn = GetStringCatInfo(g, "Filename", "rest.json"); + + // We used the file name relative to recorded datapath + //PlugSetPath(filename, Fn, GetPath()); + strncat(strcpy(filename, GetPath()), Fn, _MAX_PATH); + + // Retrieve the file from the web and copy it locally + rc = restGetFile(g, Http, Uri, filename); + + if (trace(515)) + htrc("Return from restGetFile: rc=%d\n", rc); + + if (rc) + return true; + else switch (n) { + case 1: Tdp = new (g) JSONDEF; break; + case 2: Tdp = new (g) XMLDEF; break; + case 3: Tdp = new (g) CSVDEF; break; + default: Tdp = NULL; + } // endswitch n + + // Do make the table/view definition + if (Tdp && Tdp->Define(g, Cat, Name, Schema, "REST")) + Tdp = NULL; // Error occured + + if (trace(515)) + htrc("Tdp defined\n", rc); + + // Return true in case of error + return (Tdp == NULL); +} // end of DefineAM + +/***********************************************************************/ +/* GetTable: makes a new Table Description Block. */ +/***********************************************************************/ +PTDB RESTDEF::GetTable(PGLOBAL g, MODE m) +{ + if (trace(515)) + htrc("REST GetTable mode=%d\n", m); + + if (m != MODE_READ && m != MODE_READX) { + strcpy(g->Message, "REST tables are currently read only"); + return NULL; + } // endif m + + return Tdp->GetTable(g, m); // Leave file type do the job +} // end of GetTable + +/* ---------------------- End of Class RESTDEF ----------------------- */ diff -Nru mariadb-10.1-10.1.41/storage/connect/tabrest.h mariadb-10.1-10.1.43/storage/connect/tabrest.h --- mariadb-10.1-10.1.41/storage/connect/tabrest.h 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabrest.h 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,29 @@ +/*************** TabRest H Declares Source Code File (.H) **************/ +/* Name: tabrest.h Version 1.0 */ +/* (C) Copyright to the author Olivier BERTRAND 2019 */ +/* This file contains the common tabrest classes declares. */ +/***********************************************************************/ +#pragma once + +/***********************************************************************/ +/* Restest table. */ +/***********************************************************************/ +class RESTDEF : public TABDEF { /* Table description */ +public: + // Constructor + RESTDEF(void) { Tdp = NULL; Http = Uri = Fn = NULL; } + + // Implementation + virtual const char *GetType(void) { return "REST"; } + + // Methods + virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); + virtual PTDB GetTable(PGLOBAL g, MODE m); + +protected: + // Members + PRELDEF Tdp; + PCSZ Http; /* Web connection HTTP */ + PCSZ Uri; /* Web connection URI */ + PCSZ Fn; /* The intermediate file name */ +}; // end of class RESTDEF diff -Nru mariadb-10.1-10.1.41/storage/connect/tabtbl.cpp mariadb-10.1-10.1.43/storage/connect/tabtbl.cpp --- mariadb-10.1-10.1.41/storage/connect/tabtbl.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabtbl.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -232,7 +232,7 @@ { int n; uint sln; - char *scs; + const char *scs; PTABLE tp, tabp; PCOL colp; PTBLDEF tdp = (PTBLDEF)To_Def; @@ -281,7 +281,7 @@ } // endfor tp - hc->get_table()->s->connect_string.str = scs; + hc->get_table()->s->connect_string.str = (char*)scs; hc->get_table()->s->connect_string.length = sln; //NumTables = n; diff -Nru mariadb-10.1-10.1.41/storage/connect/tabxml.cpp mariadb-10.1-10.1.43/storage/connect/tabxml.cpp --- mariadb-10.1-10.1.41/storage/connect/tabxml.cpp 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/tabxml.cpp 2019-11-06 06:20:36.000000000 +0000 @@ -1880,7 +1880,7 @@ if (N > Tdbp->Limit) { N = Tdbp->Limit; - sprintf(g->Message, "Mutiple values limited to %d", Tdbp->Limit); + sprintf(g->Message, "Multiple values limited to %d", Tdbp->Limit); PushWarning(g, Tdbp); } // endif N diff -Nru mariadb-10.1-10.1.41/storage/connect/user_connect.cc mariadb-10.1-10.1.43/storage/connect/user_connect.cc --- mariadb-10.1-10.1.41/storage/connect/user_connect.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/user_connect.cc 2019-11-06 06:20:36.000000000 +0000 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file user_connect.cc diff -Nru mariadb-10.1-10.1.41/storage/connect/user_connect.h mariadb-10.1-10.1.43/storage/connect/user_connect.h --- mariadb-10.1-10.1.41/storage/connect/user_connect.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/connect/user_connect.h 2019-11-06 06:20:36.000000000 +0000 @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file user_connect.h diff -Nru mariadb-10.1-10.1.41/storage/heap/_check.c mariadb-10.1-10.1.43/storage/heap/_check.c --- mariadb-10.1-10.1.41/storage/heap/_check.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/heap/_check.c 2019-11-06 06:20:36.000000000 +0000 @@ -18,10 +18,8 @@ #include "heapdef.h" -static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, - ulong blength, my_bool print_status); -static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, - my_bool print_status); +static int check_one_key(HP_KEYDEF *, uint, ulong, ulong, my_bool); +static int check_one_rb_key(const HP_INFO *, uint, ulong, my_bool); /* @@ -40,13 +38,13 @@ 1 error */ -int heap_check_heap(HP_INFO *info, my_bool print_status) +int heap_check_heap(const HP_INFO *info, my_bool print_status) { int error; uint key; ulong records=0, deleted=0, pos, next_block; HP_SHARE *share=info->s; - HP_INFO save_info= *info; /* Needed because scan_init */ + uchar *current_ptr= info->current_ptr; DBUG_ENTER("heap_check_heap"); for (error=key= 0 ; key < share->keys ; key++) @@ -65,7 +63,7 @@ { if (pos < next_block) { - info->current_ptr+= share->block.recbuffer; + current_ptr+= share->block.recbuffer; } else { @@ -77,9 +75,9 @@ break; /* End of file */ } } - hp_find_record(info,pos); + current_ptr= hp_find_block(&share->block, pos); - if (!info->current_ptr[share->visible]) + if (!current_ptr[share->visible]) deleted++; else records++; @@ -92,7 +90,6 @@ deleted, (ulong) share->deleted)); error= 1; } - *info= save_info; DBUG_RETURN(error); } @@ -165,7 +162,7 @@ return error; } -static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, +static int check_one_rb_key(const HP_INFO *info, uint keynr, ulong records, my_bool print_status) { HP_KEYDEF *keydef= info->s->keydef + keynr; @@ -174,9 +171,11 @@ uchar *key, *recpos; uint key_length; uint not_used[2]; + TREE_ELEMENT **last_pos; + TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1]; - if ((key= tree_search_edge(&keydef->rb_tree, info->parents, - &info->last_pos, offsetof(TREE_ELEMENT, left)))) + if ((key= tree_search_edge(&keydef->rb_tree, parents, + &last_pos, offsetof(TREE_ELEMENT, left)))) { do { @@ -191,7 +190,7 @@ } else found++; - key= tree_search_next(&keydef->rb_tree, &info->last_pos, + key= tree_search_next(&keydef->rb_tree, &last_pos, offsetof(TREE_ELEMENT, left), offsetof(TREE_ELEMENT, right)); } while (key); diff -Nru mariadb-10.1-10.1.41/storage/heap/ha_heap.cc mariadb-10.1-10.1.43/storage/heap/ha_heap.cc --- mariadb-10.1-10.1.41/storage/heap/ha_heap.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/heap/ha_heap.cc 2019-11-06 06:20:36.000000000 +0000 @@ -431,6 +431,10 @@ int ha_heap::external_lock(THD *thd, int lock_type) { +#ifndef DBUG_OFF + if (lock_type == F_UNLCK && file->s->changed && heap_check_heap(file, 0)) + return HA_ERR_CRASHED; +#endif return 0; // No external locking } diff -Nru mariadb-10.1-10.1.41/storage/heap/hp_close.c mariadb-10.1-10.1.43/storage/heap/hp_close.c --- mariadb-10.1-10.1.41/storage/heap/hp_close.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/heap/hp_close.c 2019-11-06 06:20:36.000000000 +0000 @@ -35,12 +35,6 @@ { int error=0; DBUG_ENTER("hp_close"); -#ifndef DBUG_OFF - if (info->s->changed && heap_check_heap(info,0)) - { - error=my_errno=HA_ERR_CRASHED; - } -#endif info->s->changed=0; if (info->open_list.data) heap_open_list=list_delete(heap_open_list,&info->open_list); diff -Nru mariadb-10.1-10.1.41/storage/innobase/buf/buf0dblwr.cc mariadb-10.1-10.1.43/storage/innobase/buf/buf0dblwr.cc --- mariadb-10.1-10.1.41/storage/innobase/buf/buf0dblwr.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/buf/buf0dblwr.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -291,6 +291,13 @@ ut_ad(rw_lock_get_x_lock_count(&new_block->lock) == 1); page_no = buf_block_get_page_no(new_block); + /* We only do this in the debug build, to ensure that + both the check in buf_flush_init_for_writing() and + recv_parse_or_apply_log_rec_body() will see a valid + page type. The flushes of new_block are actually + unnecessary here. */ + ut_d(mlog_write_ulint(FIL_PAGE_TYPE + new_block->frame, + FIL_PAGE_TYPE_SYS, MLOG_2BYTES, &mtr)); if (i == FSP_EXTENT_SIZE / 2) { ut_a(page_no == FSP_EXTENT_SIZE); @@ -353,6 +360,7 @@ /* Flush the modified pages to disk and make a checkpoint */ log_make_checkpoint_at(LSN_MAX, TRUE); + buf_dblwr_being_created = FALSE; /* Remove doublewrite pages from LRU */ buf_pool_invalidate(); diff -Nru mariadb-10.1-10.1.41/storage/innobase/buf/buf0flu.cc mariadb-10.1-10.1.43/storage/innobase/buf/buf0flu.cc --- mariadb-10.1-10.1.41/storage/innobase/buf/buf0flu.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/buf/buf0flu.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. Copyright (c) 2013, 2014, Fusion-io This program is free software; you can redistribute it and/or modify it under diff -Nru mariadb-10.1-10.1.41/storage/innobase/.clang-format mariadb-10.1-10.1.43/storage/innobase/.clang-format --- mariadb-10.1-10.1.41/storage/innobase/.clang-format 1970-01-01 00:00:00.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/.clang-format 2019-11-06 06:20:36.000000000 +0000 @@ -0,0 +1,11 @@ +UseTab: Always +TabWidth: 8 +IndentWidth: 8 +ContinuationIndentWidth: 8 +BreakBeforeBinaryOperators: All +PointerAlignment: Left +BreakBeforeBraces: Custom +ColumnLimit: 79 +BraceWrapping: + AfterFunction: true +AccessModifierOffset: -8 diff -Nru mariadb-10.1-10.1.41/storage/innobase/dict/dict0dict.cc mariadb-10.1-10.1.43/storage/innobase/dict/dict0dict.cc --- mariadb-10.1-10.1.41/storage/innobase/dict/dict0dict.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/dict/dict0dict.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1850,8 +1850,7 @@ /* The old table name in my_charset_filename is stored in old_name_cs_filename */ - strncpy(old_name_cs_filename, old_name, - MAX_FULL_NAME_LEN); + strcpy(old_name_cs_filename, old_name); old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0'; if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) { @@ -1873,8 +1872,7 @@ } else { /* Old name already in my_charset_filename */ - strncpy(old_name_cs_filename, old_name, - MAX_FULL_NAME_LEN); + strcpy(old_name_cs_filename, old_name); old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0'; } @@ -2911,33 +2909,6 @@ } } -/******************************************************************** -Wait until all the background threads of the given table have exited, i.e., -bg_threads == 0. Note: bg_threads_mutex must be reserved when -calling this. */ -UNIV_INTERN -void -dict_table_wait_for_bg_threads_to_exit( -/*===================================*/ - dict_table_t* table, /*< in: table */ - ulint delay) /*< in: time in microseconds to wait between - checks of bg_threads. */ -{ - fts_t* fts = table->fts; - -#ifdef UNIV_SYNC_DEBUG - ut_ad(mutex_own(&fts->bg_threads_mutex)); -#endif /* UNIV_SYNC_DEBUG */ - - while (fts->bg_threads > 0) { - mutex_exit(&fts->bg_threads_mutex); - - os_thread_sleep(delay); - - mutex_enter(&fts->bg_threads_mutex); - } -} - /*******************************************************************//** Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user. diff -Nru mariadb-10.1-10.1.41/storage/innobase/dict/dict0load.cc mariadb-10.1-10.1.43/storage/innobase/dict/dict0load.cc --- mariadb-10.1-10.1.41/storage/innobase/dict/dict0load.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/dict/dict0load.cc 2019-11-06 06:20:36.000000000 +0000 @@ -46,6 +46,7 @@ #include "dict0priv.h" #include "ha_prototypes.h" /* innobase_casedn_str() */ #include "fts0priv.h" +#include "fts0opt.h" /** Following are the InnoDB system tables. The positions in this array are referenced by enum dict_system_table_id. */ @@ -2548,8 +2549,12 @@ FTS */ fts_optimize_remove_table(table); fts_free(table); - } else { + } else if (fts_optimize_wq) { fts_optimize_add_table(table); + } else if (table->can_be_evicted) { + /* fts_optimize_thread is not started yet. + So make the table as non-evictable from cache. */ + dict_table_move_from_lru_to_non_lru(table); } } diff -Nru mariadb-10.1-10.1.41/storage/innobase/fts/fts0config.cc mariadb-10.1-10.1.43/storage/innobase/fts/fts0config.cc --- mariadb-10.1-10.1.41/storage/innobase/fts/fts0config.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/fts/fts0config.cc 2019-11-06 06:20:36.000000000 +0000 @@ -224,8 +224,7 @@ pars_info_bind_varchar_literal(info, "value", value->f_str, value->f_len); - const bool dict_locked = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + const bool dict_locked = fts_table->table->fts->dict_locked; fts_table->suffix = "CONFIG"; fts_get_table_name(fts_table, table_name, dict_locked); diff -Nru mariadb-10.1-10.1.41/storage/innobase/fts/fts0fts.cc mariadb-10.1-10.1.43/storage/innobase/fts/fts0fts.cc --- mariadb-10.1-10.1.41/storage/innobase/fts/fts0fts.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/fts/fts0fts.cc 2019-11-06 06:20:36.000000000 +0000 @@ -458,7 +458,7 @@ dberr_t error = DB_SUCCESS; ibool ret = TRUE; trx_t* trx; - ibool has_lock = fts->fts_status & TABLE_DICT_LOCKED; + ibool has_lock = fts->dict_locked; trx = trx_allocate_for_background(); trx->op_info = "Load user stopword table into FTS cache"; @@ -933,18 +933,16 @@ const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ que_t* graph) /*!< in: query graph */ { - ibool has_dict = FALSE; + bool has_dict = FALSE; if (fts_table && fts_table->table) { ut_ad(fts_table->table->fts); - has_dict = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + has_dict = fts_table->table->fts->dict_locked; } else if (index_cache) { ut_ad(index_cache->index->table->fts); - has_dict = index_cache->index->table->fts->fts_status - & TABLE_DICT_LOCKED; + has_dict = index_cache->index->table->fts->dict_locked; } if (!has_dict) { @@ -2741,6 +2739,10 @@ } if (read_only) { + /* InnoDB stores actual synced_doc_id value + 1 in + FTS_CONFIG table. Reduce the value by 1 while reading + after startup. */ + if (*doc_id) *doc_id -= 1; goto func_exit; } @@ -2831,7 +2833,7 @@ pars_info_bind_varchar_literal(info, "doc_id", id, id_len); fts_get_table_name(&fts_table, fts_name, - table->fts->fts_status & TABLE_DICT_LOCKED); + table->fts->dict_locked); pars_info_bind_id(info, true, "table_name", fts_name); graph = fts_parse_sql( @@ -2947,7 +2949,7 @@ into cache from last crash (delete Doc will not initialize the sync). Avoid any added counter accounting until the FTS cache is re-established and sync-ed */ - if (table->fts->fts_status & ADDED_TABLE_SYNCED + if (table->fts->added_synced && doc_id > cache->synced_doc_id) { mutex_enter(&table->fts->cache->deleted_lock); @@ -3385,7 +3387,7 @@ /* If Doc ID has been supplied by the user, then the table might not yet be sync-ed */ - if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!ftt->table->fts->added_synced) { fts_init_index(ftt->table, FALSE); } @@ -4933,7 +4935,7 @@ fts_init_index((dict_table_t*) table, TRUE); } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; table->fts->cache->first_doc_id = max_doc_id; @@ -5387,69 +5389,6 @@ } /*********************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -UNIV_INTERN -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait) /*!< in: time in microseconds, if - set to 0 then it disables - timeout checking */ -{ - ulint count = 0; - ibool done = FALSE; - - ut_a(max_wait == 0 || max_wait >= FTS_MAX_BACKGROUND_THREAD_WAIT); - - for (;;) { - fts_t* fts = table->fts; - - mutex_enter(&fts->bg_threads_mutex); - - if (fts->fts_status & BG_THREAD_READY) { - - done = TRUE; - } - - mutex_exit(&fts->bg_threads_mutex); - - if (!done) { - os_thread_sleep(FTS_MAX_BACKGROUND_THREAD_WAIT); - - if (max_wait > 0) { - - max_wait -= FTS_MAX_BACKGROUND_THREAD_WAIT; - - /* We ignore the residual value. */ - if (max_wait < FTS_MAX_BACKGROUND_THREAD_WAIT) { - break; - } - } - - ++count; - } else { - break; - } - - if (count >= FTS_BACKGROUND_THREAD_WAIT_COUNT) { - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: Error the background thread " - "for the FTS table %s refuses to start\n", - table->name); - - count = 0; - } - } - - return(done); -} - -/*********************************************************************//** Add the FTS document id hidden column. */ UNIV_INTERN void @@ -5590,42 +5529,6 @@ } /*********************************************************************//** -Signal FTS threads to initiate shutdown. */ -UNIV_INTERN -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance that needs - to be informed about shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - fts->fts_status |= BG_THREAD_STOP; - - mutex_exit(&fts->bg_threads_mutex); - -} - -/*********************************************************************//** -Wait for FTS threads to shutdown. */ -UNIV_INTERN -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance to shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - ut_a(fts->fts_status & BG_THREAD_STOP); - - dict_table_wait_for_bg_threads_to_exit(table, 20000); - - mutex_exit(&fts->bg_threads_mutex); -} - -/*********************************************************************//** Take a FTS savepoint. */ UNIV_INLINE void @@ -7639,7 +7542,7 @@ } rw_lock_x_unlock(&cache->init_lock); - if (table->fts->fts_status & ADDED_TABLE_SYNCED) { + if (table->fts->added_synced) { goto func_exit; } @@ -7681,7 +7584,7 @@ } } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; fts_get_docs_clear(cache->get_docs); diff -Nru mariadb-10.1-10.1.41/storage/innobase/fts/fts0opt.cc mariadb-10.1-10.1.43/storage/innobase/fts/fts0opt.cc --- mariadb-10.1-10.1.41/storage/innobase/fts/fts0opt.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/fts/fts0opt.cc 2019-11-06 06:20:36.000000000 +0000 @@ -34,6 +34,7 @@ #include "ut0wqueue.h" #include "srv0start.h" #include "zlib.h" +#include "fts0opt.h" #ifndef UNIV_NONINL #include "fts0types.ic" @@ -41,7 +42,7 @@ #endif /** The FTS optimize thread's work queue. */ -static ib_wqueue_t* fts_optimize_wq; +ib_wqueue_t* fts_optimize_wq; /** The FTS vector to store fts_slot_t */ static ib_vector_t* fts_slots; @@ -169,8 +170,8 @@ /** We use this information to determine when to start the optimize cycle for a table. */ struct fts_slot_t { - /** table identifier, or 0 if the slot is empty */ - table_id_t table_id; + /** table, or NULL if the slot is unused */ + dict_table_t* table; /** whether this slot is being processed */ bool running; @@ -2456,14 +2457,7 @@ return(DB_SUCCESS); } - dict_table_t* table = dict_table_open_on_id( - slot->table_id, FALSE, DICT_TABLE_OP_NORMAL); - - if (!table) { - slot->last_run = now; - return DB_SUCCESS; - } - + dict_table_t* table = slot->table; dberr_t error; if (fil_table_accessible(table) @@ -2483,8 +2477,6 @@ error = DB_SUCCESS; } - dict_table_close(table, FALSE, FALSE); - return(error); } /*********************************************************************//** @@ -2614,6 +2606,12 @@ return; } + /* If there is no fts index present then don't add to + optimize queue. */ + if (!ib_vector_size(table->fts->indexes)) { + return; + } + /* Make sure table with FTS index cannot be evicted */ if (table->can_be_evicted) { dict_table_move_from_lru_to_non_lru(table); @@ -2621,7 +2619,13 @@ msg = fts_optimize_create_msg(FTS_MSG_ADD_TABLE, table); - ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + mutex_enter(&fts_optimize_wq->mutex); + + ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true); + + table->fts->in_queue = true; + + mutex_exit(&fts_optimize_wq->mutex); } /**********************************************************************//** @@ -2638,7 +2642,7 @@ fts_msg_del_t* remove; /* if the optimize system not yet initialized, return */ - if (!fts_optimize_is_init()) { + if (!fts_optimize_wq) { return; } @@ -2650,6 +2654,13 @@ return; } + mutex_enter(&fts_optimize_wq->mutex); + + if (!table->fts->in_queue) { + mutex_exit(&fts_optimize_wq->mutex); + return; + } + msg = fts_optimize_create_msg(FTS_MSG_DEL_TABLE, NULL); /* We will wait on this event until signalled by the consumer. */ @@ -2662,11 +2673,17 @@ remove->event = event; msg->ptr = remove; - ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true); + + mutex_exit(&fts_optimize_wq->mutex); os_event_wait(event); os_event_free(event); + + ut_d(mutex_enter(&fts_optimize_wq->mutex)); + ut_ad(!table->fts->in_queue); + ut_d(mutex_exit(&fts_optimize_wq->mutex)); } /** Send sync fts cache for the table. @@ -2677,10 +2694,9 @@ dict_table_t* table) { fts_msg_t* msg; - table_id_t* table_id; /* if the optimize system not yet initialized, return */ - if (!fts_optimize_is_init()) { + if (!fts_optimize_wq) { return; } @@ -2692,35 +2708,36 @@ return; } - msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, NULL); + msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, table); - table_id = static_cast( - mem_heap_alloc(msg->heap, sizeof(table_id_t))); - *table_id = table->id; - msg->ptr = table_id; + mutex_enter(&fts_optimize_wq->mutex); - ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true); + + table->fts->in_queue = true; + + mutex_exit(&fts_optimize_wq->mutex); } /** Add a table to fts_slots if it doesn't already exist. */ static bool fts_optimize_new_table(dict_table_t* table) { + ut_ad(table); + ulint i; fts_slot_t* slot; fts_slot_t* empty = NULL; - const table_id_t table_id = table->id; - ut_ad(table_id); /* Search for duplicates, also find a free slot if one exists. */ for (i = 0; i < ib_vector_size(fts_slots); ++i) { slot = static_cast(ib_vector_get(fts_slots, i)); - if (!slot->table_id) { + if (!slot->table) { empty = slot; - } else if (slot->table_id == table_id) { + } else if (slot->table == table) { /* Already exists in our optimize queue. */ - return(FALSE); + return false; } } @@ -2729,37 +2746,36 @@ memset(slot, 0x0, sizeof(*slot)); - slot->table_id = table->id; - slot->running = false; - - return(TRUE); + slot->table = table; + return true; } /** Remove a table from fts_slots if it exists. @param[in,out] table table to be removed from fts_slots */ static bool fts_optimize_del_table(const dict_table_t* table) { - const table_id_t table_id = table->id; - ut_ad(table_id); - for (ulint i = 0; i < ib_vector_size(fts_slots); ++i) { fts_slot_t* slot; slot = static_cast(ib_vector_get(fts_slots, i)); - if (slot->table_id == table_id) { + if (slot->table == table) { if (fts_enable_diag_print) { ib_logf(IB_LOG_LEVEL_INFO, "FTS Optimize Removing table %s", table->name); } - slot->table_id = 0; - return(TRUE); + mutex_enter(&fts_optimize_wq->mutex); + slot->table->fts->in_queue = false; + mutex_exit(&fts_optimize_wq->mutex); + + slot->table = NULL; + return true; } } - return(FALSE); + return false; } /**********************************************************************//** @@ -2773,7 +2789,7 @@ for (ulint i = 0; i < ib_vector_size(fts_slots); ++i) { const fts_slot_t* slot = static_cast( ib_vector_get_const(fts_slots, i)); - if (slot->table_id == 0) { + if (!slot->table) { continue; } @@ -2809,22 +2825,14 @@ const fts_slot_t* slot = static_cast( ib_vector_get_const(fts_slots, i)); - if (slot->table_id == 0) { - continue; - } - - dict_table_t* table = dict_table_open_on_id( - slot->table_id, FALSE, DICT_TABLE_OP_NORMAL); - if (!table) { + if (!slot->table) { continue; } - if (table->fts && table->fts->cache) { - total_memory += table->fts->cache->total_size; + if (slot->table->fts && slot->table->fts->cache) { + total_memory += slot->table->fts->cache->total_size; } - dict_table_close(table, FALSE, FALSE); - if (total_memory > fts_max_total_cache_size) { return(true); } @@ -2834,18 +2842,16 @@ } /** Sync fts cache of a table -@param[in] table_id table id */ -static void fts_optimize_sync_table(table_id_t table_id) +@param[in,out] table table to be synced */ +static void fts_optimize_sync_table(dict_table_t* table) { - if (dict_table_t* table = dict_table_open_on_id( - table_id, FALSE, DICT_TABLE_OP_NORMAL)) { - if (fil_table_accessible(table) - && table->fts && table->fts->cache) { - fts_sync_table(table, true, false, false); - } - - dict_table_close(table, FALSE, FALSE); + if (fil_table_accessible(table) + && table->fts && table->fts->cache) { + fts_sync_table(table, true, false, false); } + + DBUG_EXECUTE_IF("ib_optimize_wq_hang", + os_thread_sleep(6000000);); } /**********************************************************************//** @@ -2887,7 +2893,7 @@ ib_vector_get(fts_slots, current)); /* Handle the case of empty slots. */ - if (slot->table_id) { + if (slot->table) { slot->running = true; fts_optimize_table_bk(slot); } @@ -2947,7 +2953,7 @@ os_thread_sleep(300000);); fts_optimize_sync_table( - *static_cast(msg->ptr)); + static_cast(msg->ptr)); break; default: @@ -2966,8 +2972,8 @@ fts_slot_t* slot = static_cast( ib_vector_get(fts_slots, i)); - if (table_id_t table_id = slot->table_id) { - fts_optimize_sync_table(table_id); + if (slot->table) { + fts_optimize_sync_table(slot->table); } } } @@ -2997,24 +3003,35 @@ ut_ad(!srv_read_only_mode); /* For now we only support one optimize thread. */ - ut_a(!fts_optimize_is_init()); + ut_a(!fts_optimize_wq); fts_optimize_wq = ib_wqueue_create(); ut_a(fts_optimize_wq != NULL); last_check_sync_time = time(NULL); - os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); -} + /* Add fts tables to fts slots which could be skipped + during dict_load_table() because fts_optimize_thread + wasn't even started. */ + mutex_enter(&dict_sys->mutex); -/**********************************************************************//** -Check whether the work queue is initialized. -@return TRUE if optimze queue is initialized. */ -UNIV_INTERN -ibool -fts_optimize_is_init(void) -/*======================*/ -{ - return(fts_optimize_wq != NULL); + for (dict_table_t* table = UT_LIST_GET_FIRST(dict_sys->table_LRU); + table != NULL; + table = UT_LIST_GET_NEXT(table_LRU, table)) { + + if (!table->fts || !dict_table_has_fts_index(table)) { + continue; + } + + /* fts_optimize_thread is not started yet. So there is no + need to acqquire fts_optimize_wq->mutex for adding the fts + table to the fts slots. */ + ut_ad(!table->can_be_evicted); + fts_optimize_new_table(table); + table->fts->in_queue = true; + } + + mutex_exit(&dict_sys->mutex); + os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); } /**********************************************************************//** diff -Nru mariadb-10.1-10.1.41/storage/innobase/fts/fts0sql.cc mariadb-10.1-10.1.43/storage/innobase/fts/fts0sql.cc --- mariadb-10.1-10.1.41/storage/innobase/fts/fts0sql.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/fts/fts0sql.cc 2019-11-06 06:20:36.000000000 +0000 @@ -165,8 +165,7 @@ str = ut_str3cat(fts_sql_begin, sql, fts_sql_end); dict_locked = (fts_table && fts_table->table->fts - && (fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED)); + && fts_table->table->fts->dict_locked); if (!dict_locked) { ut_ad(!mutex_own(&(dict_sys->mutex))); diff -Nru mariadb-10.1-10.1.41/storage/innobase/handler/ha_innodb.cc mariadb-10.1-10.1.43/storage/innobase/handler/ha_innodb.cc --- mariadb-10.1-10.1.41/storage/innobase/handler/ha_innodb.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/handler/ha_innodb.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -1686,9 +1686,9 @@ && thd_is_replication_slave_thread(trx->mysql_thd)) { const ulonglong end = my_interval_timer() + ulonglong(srv_replication_delay) * 1000000; - while (srv_conc_get_active_threads() - >= srv_thread_concurrency - || my_interval_timer() >= end) { + while ((srv_conc_get_active_threads() + >= srv_thread_concurrency) + && my_interval_timer() < end) { os_thread_sleep(2000 /* 2 ms */); } } else { @@ -2588,11 +2588,10 @@ if (next_value == 0) { ulonglong next; - if (current >= offset) { + if (current > offset) { next = (current - offset) / step; } else { - next = 0; - block -= step; + next = (offset - current) / step; } ut_a(max_value > next); @@ -10094,10 +10093,10 @@ return(NULL); } - if (!(ft_table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!(ft_table->fts->added_synced)) { fts_init_index(ft_table, FALSE); - ft_table->fts->fts_status |= ADDED_TABLE_SYNCED; + ft_table->fts->added_synced = true; } error = fts_query(trx, index, flags, query, query_len, &result); @@ -16018,7 +16017,7 @@ if (increment > 1 && thd_sql_command(user_thd) != SQLCOM_ALTER_TABLE && autoinc < col_max_value) { - ulonglong prev_auto_inc = autoinc; + ulonglong prev_auto_inc = autoinc; autoinc = ((autoinc - 1) + increment - offset)/ increment; @@ -16072,26 +16071,6 @@ current = *first_value; - if (prebuilt->autoinc_increment != increment) { - - WSREP_DEBUG("autoinc decrease: %llu -> %llu\n" - "THD: %ld, current: %llu, autoinc: %llu", - prebuilt->autoinc_increment, - increment, - thd_get_thread_id(ha_thd()), - current, autoinc); - if (!wsrep_on(ha_thd())) - { - current = autoinc - prebuilt->autoinc_increment; - current = innobase_next_autoinc( - current, 1, increment, offset, col_max_value); - } - - dict_table_autoinc_initialize(prebuilt->table, current); - - *first_value = current; - } - /* Compute the last value in the interval */ next_value = innobase_next_autoinc( current, *nb_reserved_values, increment, offset, diff -Nru mariadb-10.1-10.1.41/storage/innobase/handler/handler0alter.cc mariadb-10.1-10.1.43/storage/innobase/handler/handler0alter.cc --- mariadb-10.1-10.1.41/storage/innobase/handler/handler0alter.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/handler/handler0alter.cc 2019-11-06 06:20:36.000000000 +0000 @@ -3245,15 +3245,13 @@ goto error_handling; } - ctx->new_table->fts->fts_status - |= TABLE_DICT_LOCKED; + ctx->new_table->fts->dict_locked = true; error = innobase_fts_load_stopword( ctx->new_table, ctx->trx, ctx->prebuilt->trx->mysql_thd) ? DB_SUCCESS : DB_ERROR; - ctx->new_table->fts->fts_status - &= ~TABLE_DICT_LOCKED; + ctx->new_table->fts->dict_locked = false; if (error != DB_SUCCESS) { goto error_handling; @@ -5624,6 +5622,7 @@ || (index->type & DICT_CORRUPT)); DBUG_ASSERT(index->table->fts); + DEBUG_SYNC_C("norebuild_fts_drop"); fts_drop_index(index->table, index, trx); } diff -Nru mariadb-10.1-10.1.41/storage/innobase/ibuf/ibuf0ibuf.cc mariadb-10.1-10.1.43/storage/innobase/ibuf/ibuf0ibuf.cc --- mariadb-10.1-10.1.41/storage/innobase/ibuf/ibuf0ibuf.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/ibuf/ibuf0ibuf.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -2130,14 +2130,14 @@ buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW); page = buf_block_get_frame(block); + mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST, + MLOG_2BYTES, &mtr); + /* Add the page to the free list and update the ibuf size data */ flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); - mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST, - MLOG_2BYTES, &mtr); - ibuf->seg_size++; ibuf->free_list_len++; diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/buf0flu.h mariadb-10.1-10.1.43/storage/innobase/include/buf0flu.h --- mariadb-10.1-10.1.41/storage/innobase/include/buf0flu.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/buf0flu.h 2019-11-06 06:20:36.000000000 +0000 @@ -143,17 +143,6 @@ buf_pool_t* buf_pool, /*!< in: buffer pool instance */ buf_flush_t type); /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ -/******************************************************************//** -Waits until a flush batch of the given type ends. This is called by -a thread that only wants to wait for a flush to end but doesn't do -any flushing itself. */ -UNIV_INTERN -void -buf_flush_wait_batch_end_wait_only( -/*===============================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - buf_flush_t type); /*!< in: BUF_FLUSH_LRU - or BUF_FLUSH_LIST */ /********************************************************************//** This function should be called at a mini-transaction commit, if a page was modified in it. Puts the block to the list of modified blocks, if it not diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/data0type.ic mariadb-10.1-10.1.43/storage/innobase/include/data0type.ic --- mariadb-10.1-10.1.41/storage/innobase/include/data0type.ic 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/data0type.ic 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/dict0dict.h mariadb-10.1-10.1.43/storage/innobase/include/dict0dict.h --- mariadb-10.1-10.1.41/storage/innobase/include/dict0dict.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/dict0dict.h 2019-11-06 06:20:36.000000000 +0000 @@ -1016,18 +1016,6 @@ dtuple_t* tuple, /*!< in/out: data tuple */ const dict_table_t* table) /*!< in: table */ MY_ATTRIBUTE((nonnull)); -/******************************************************************** -Wait until all the background threads of the given table have exited, i.e., -bg_threads == 0. Note: bg_threads_mutex must be reserved when -calling this. */ -UNIV_INTERN -void -dict_table_wait_for_bg_threads_to_exit( -/*===================================*/ - dict_table_t* table, /* in: table */ - ulint delay) /* in: time in microseconds to wait between - checks of bg_threads. */ - MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/fts0fts.h mariadb-10.1-10.1.43/storage/innobase/include/fts0fts.h --- mariadb-10.1-10.1.41/storage/innobase/include/fts0fts.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/fts0fts.h 2019-11-06 06:20:36.000000000 +0000 @@ -279,40 +279,18 @@ index auxiliary table */ }; -enum fts_status { - BG_THREAD_STOP = 1, /*!< TRUE if the FTS background thread - has finished reading the ADDED table, - meaning more items can be added to - the table. */ - - BG_THREAD_READY = 2, /*!< TRUE if the FTS background thread - is ready */ - - ADD_THREAD_STARTED = 4, /*!< TRUE if the FTS add thread - has started */ - - ADDED_TABLE_SYNCED = 8, /*!< TRUE if the ADDED table record is - sync-ed after crash recovery */ - - TABLE_DICT_LOCKED = 16 /*!< Set if the table has - dict_sys->mutex */ -}; - -typedef enum fts_status fts_status_t; - /** The state of the FTS sub system. */ struct fts_t { /*!< mutex protecting bg_threads* and fts_add_wq. */ ib_mutex_t bg_threads_mutex; - ulint bg_threads; /*!< number of background threads - accessing this table */ - - /*!< TRUE if background threads running - should stop themselves */ - ulint fts_status; /*!< Status bit regarding fts - running state */ + /* Whether the ADDED table record sync-ed after + crash recovery; protected by bg_threads mutex */ + unsigned added_synced:1; + /* Whether the table hold dict_sys->mutex; + protected by bg_threads mutex */ + unsigned dict_locked:1; ib_wqueue_t* add_wq; /*!< Work queue for scheduling jobs for the FTS 'Add' thread, or NULL @@ -329,6 +307,11 @@ ib_vector_t* indexes; /*!< Vector of FTS indexes, this is mainly for caching purposes. */ + + /* Whether the table was added to fts_optimize_wq(); + protected by fts_optimize_wq mutex */ + bool in_queue; + mem_heap_t* fts_heap; /*!< heap for fts_t allocation */ }; @@ -615,28 +598,6 @@ /*==============*/ /******************************************************************//** -Signal FTS threads to initiate shutdown. */ -UNIV_INTERN -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS - indexes */ - fts_t* fts); /*!< in: fts instance to - shutdown */ - -/******************************************************************//** -Wait for FTS threads to shutdown. */ -UNIV_INTERN -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS - indexes */ - fts_t* fts); /*!< in: fts instance to - shutdown */ - -/******************************************************************//** Create an instance of fts_t. @return instance of fts_t */ UNIV_INTERN @@ -672,14 +633,6 @@ fts_optimize_init(void); /*====================*/ -/**********************************************************************//** -Check whether the work queue is initialized. -@return TRUE if optimze queue is initialized. */ -UNIV_INTERN -ibool -fts_optimize_is_init(void); -/*======================*/ - /****************************************************************//** Drops index ancillary tables for a FTS index @return DB_SUCCESS or error code */ diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/fts0opt.h mariadb-10.1-10.1.43/storage/innobase/include/fts0opt.h --- mariadb-10.1-10.1.41/storage/innobase/include/fts0opt.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/fts0opt.h 2019-11-06 06:20:36.000000000 +0000 @@ -25,6 +25,9 @@ #ifndef INNODB_FTS0OPT_H #define INNODB_FTS0OPT_H +/** The FTS optimize thread's work queue. */ +extern ib_wqueue_t* fts_optimize_wq; + /******************************************************************** Callback function to fetch the rows in an FTS INDEX record. */ UNIV_INTERN diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/fts0priv.h mariadb-10.1-10.1.43/storage/innobase/include/fts0priv.h --- mariadb-10.1-10.1.41/storage/innobase/include/fts0priv.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/fts0priv.h 2019-11-06 06:20:36.000000000 +0000 @@ -521,20 +521,6 @@ const fts_cache_t* cache, /*!< in: cache to use */ ib_vector_t* vector); /*!< in: append to this vector */ -/******************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -UNIV_INTERN -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait); /*!< in: time in microseconds, if set - to 0 then it disables timeout - checking */ #ifdef FTS_DOC_STATS_DEBUG /******************************************************************//** Get the total number of words in the FTS for a particular FTS index. diff -Nru mariadb-10.1-10.1.41/storage/innobase/include/ut0wqueue.h mariadb-10.1-10.1.43/storage/innobase/include/ut0wqueue.h --- mariadb-10.1-10.1.41/storage/innobase/include/ut0wqueue.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/include/ut0wqueue.h 2019-11-06 06:20:36.000000000 +0000 @@ -56,16 +56,15 @@ /*===========*/ ib_wqueue_t* wq); /*!< in: work queue */ -/****************************************************************//** -Add a work item to the queue. */ +/** Add a work item to the queue. +@param[in,out] wq work queue +@param[in] item work item +@param[in,out] heap memory heap to use for allocating list node +@param[in] wq_locked work queue mutex locked */ UNIV_INTERN void -ib_wqueue_add( -/*==========*/ - ib_wqueue_t* wq, /*!< in: work queue */ - void* item, /*!< in: work item */ - mem_heap_t* heap); /*!< in: memory heap to use for allocating the - list node */ +ib_wqueue_add(ib_wqueue_t* wq, void* item, mem_heap_t* heap, + bool wq_locked = false); /** Check if queue is empty. @param wq wait queue @@ -107,14 +106,16 @@ /*==========*/ ib_wqueue_t* wq); /*fts->fts_status |= TABLE_DICT_LOCKED; + table->fts->dict_locked = true; fts_update_next_doc_id(trx, table, 0); fts_cache_clear(table->fts->cache); fts_cache_init(table->fts->cache); - table->fts->fts_status &= ~TABLE_DICT_LOCKED; + table->fts->dict_locked = false; } } @@ -4434,8 +4434,7 @@ /* Need to set TABLE_DICT_LOCKED bit, since fts_que_graph_free_check_lock would try to acquire dict mutex lock */ - table->fts->fts_status |= TABLE_DICT_LOCKED; - + table->fts->dict_locked = true; fts_free(table); } diff -Nru mariadb-10.1-10.1.41/storage/innobase/row/row0umod.cc mariadb-10.1-10.1.43/storage/innobase/row/row0umod.cc --- mariadb-10.1-10.1.41/storage/innobase/row/row0umod.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/row/row0umod.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -184,36 +184,6 @@ trx_id_offset = btr_cur_get_index(btr_cur)->trx_id_offset; - if (!trx_id_offset) { - mem_heap_t* heap = NULL; - ulint trx_id_col; - const ulint* offsets; - ulint len; - - trx_id_col = dict_index_get_sys_col_pos( - btr_cur_get_index(btr_cur), DATA_TRX_ID); - ut_ad(trx_id_col > 0); - ut_ad(trx_id_col != ULINT_UNDEFINED); - - offsets = rec_get_offsets( - btr_cur_get_rec(btr_cur), btr_cur_get_index(btr_cur), - NULL, trx_id_col + 1, &heap); - - trx_id_offset = rec_get_nth_field_offs( - offsets, trx_id_col, &len); - ut_ad(len == DATA_TRX_ID_LEN); - mem_heap_free(heap); - } - - if (trx_read_trx_id(btr_cur_get_rec(btr_cur) + trx_id_offset) - != node->new_trx_id) { - /* The record must have been purged and then replaced - with a different one. */ - return(DB_SUCCESS); - } - - trx_id_offset = btr_cur_get_index(btr_cur)->trx_id_offset; - if (!trx_id_offset) { mem_heap_t* heap = NULL; ulint trx_id_col; diff -Nru mariadb-10.1-10.1.41/storage/innobase/trx/trx0trx.cc mariadb-10.1-10.1.43/storage/innobase/trx/trx0trx.cc --- mariadb-10.1-10.1.41/storage/innobase/trx/trx0trx.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/trx/trx0trx.cc 2019-11-06 06:20:36.000000000 +0000 @@ -1062,27 +1062,16 @@ { fts_t* fts = ftt->table->fts; fts_doc_ids_t* doc_ids = ftt->added_doc_ids; + mem_heap_t* heap; - mutex_enter(&fts->bg_threads_mutex); + ut_a(fts->add_wq); - if (fts->fts_status & BG_THREAD_STOP) { - /* The table is about to be dropped, no use - adding anything to its work queue. */ + heap = static_cast(doc_ids->self_heap->arg); - mutex_exit(&fts->bg_threads_mutex); - } else { - mem_heap_t* heap; - mutex_exit(&fts->bg_threads_mutex); + ib_wqueue_add(fts->add_wq, doc_ids, heap); - ut_a(fts->add_wq); - - heap = static_cast(doc_ids->self_heap->arg); - - ib_wqueue_add(fts->add_wq, doc_ids, heap); - - /* fts_trx_table_t no longer owns the list. */ - ftt->added_doc_ids = NULL; - } + /* fts_trx_table_t no longer owns the list. */ + ftt->added_doc_ids = NULL; } /******************************************************************//** diff -Nru mariadb-10.1-10.1.41/storage/innobase/ut/ut0wqueue.cc mariadb-10.1-10.1.43/storage/innobase/ut/ut0wqueue.cc --- mariadb-10.1-10.1.41/storage/innobase/ut/ut0wqueue.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/innobase/ut/ut0wqueue.cc 2019-11-06 06:20:36.000000000 +0000 @@ -61,23 +61,25 @@ mem_free(wq); } -/****************************************************************//** -Add a work item to the queue. */ +/** Add a work item to the queue. +@param[in,out] wq work queue +@param[in] item work item +@param[in,out] heap memory heap to use for allocating list node +@param[in] wq_locked work queue mutex locked */ UNIV_INTERN void -ib_wqueue_add( -/*==========*/ - ib_wqueue_t* wq, /*!< in: work queue */ - void* item, /*!< in: work item */ - mem_heap_t* heap) /*!< in: memory heap to use for allocating the - list node */ +ib_wqueue_add(ib_wqueue_t* wq, void* item, mem_heap_t* heap, bool wq_locked) { - mutex_enter(&wq->mutex); + if (!wq_locked) { + mutex_enter(&wq->mutex); + } ib_list_add_last(wq->items, item, heap); os_event_set(wq->event); - mutex_exit(&wq->mutex); + if (!wq_locked) { + mutex_exit(&wq->mutex); + } } /****************************************************************//** diff -Nru mariadb-10.1-10.1.41/storage/myisam/ft_boolean_search.c mariadb-10.1-10.1.43/storage/myisam/ft_boolean_search.c --- mariadb-10.1-10.1.41/storage/myisam/ft_boolean_search.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/ft_boolean_search.c 2019-11-06 06:20:37.000000000 +0000 @@ -335,7 +335,7 @@ When performing prefix search (a word with truncation operator), we must preserve original prefix to ensure that characters which may be expanded/contracted do not break the prefix. This is done by storing - newly found key immediatly after the original word in ftbw->word + newly found key immediately after the original word in ftbw->word buffer. ftbw->word= LENGTH WORD [ LENGTH1 WORD1 ] WEIGHT REFERENCE diff -Nru mariadb-10.1-10.1.41/storage/myisam/ha_myisam.cc mariadb-10.1-10.1.43/storage/myisam/ha_myisam.cc --- mariadb-10.1-10.1.41/storage/myisam/ha_myisam.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/ha_myisam.cc 2019-11-06 06:20:37.000000000 +0000 @@ -741,8 +741,8 @@ growing files. Using an open_flag instead of calling mi_extra(... HA_EXTRA_MMAP ...) after mi_open() has the advantage that the mapping is not repeated for every open, but just done on the initial - open, when the MyISAM share is created. Everytime the server - requires to open a new instance of a table it calls this method. We + open, when the MyISAM share is created. Every time the server + requires opening a new instance of a table it calls this method. We will always supply HA_OPEN_MMAP for a permanent table. However, the MyISAM storage engine will ignore this flag if this is a secondary open of a table that is in use by other threads already (if the diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_check.c mariadb-10.1-10.1.43/storage/myisam/mi_check.c --- mariadb-10.1-10.1.41/storage/myisam/mi_check.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_check.c 2019-11-06 06:20:37.000000000 +0000 @@ -283,7 +283,7 @@ /* Read the key block with MI_MIN_KEY_BLOCK_LENGTH to find next link. If the key cache block size is smaller than block_size, we can so - avoid unecessary eviction of cache block. + avoid unnecessary eviction of cache block. */ if (!(buff=key_cache_read(info->s->key_cache, info->s->kfile, next_link, DFLT_INIT_HITS, @@ -1894,7 +1894,7 @@ } /* flush_blocks */ - /* Sort index for more efficent reads */ + /* Sort index for more efficient reads */ int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name) { @@ -3047,13 +3047,13 @@ /* Destroy the write cache. The master thread did already detach from the share by remove_io_thread() or it was not yet started (if the - error happend before creating the thread). + error happened before creating the thread). */ (void) end_io_cache(&info->rec_cache); /* Destroy the new data cache in case of non-quick repair. All slave threads did either detach from the share by remove_io_thread() - already or they were not yet started (if the error happend before + already or they were not yet started (if the error happened before creating the threads). */ if (!rep_quick && my_b_inited(&new_data_cache)) @@ -4591,7 +4591,7 @@ keypart_k=c_k for arbitrary constants c_1 ... c_k) = {assuming that values have uniform distribution and index contains all - tuples from the domain (or that {c_1, ..., c_k} tuple is choosen from + tuples from the domain (or that {c_1, ..., c_k} tuple is chosen from index tuples} = #tuples-in-the-index / #distinct-tuples-in-the-index. diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_create.c mariadb-10.1-10.1.43/storage/myisam/mi_create.c --- mariadb-10.1-10.1.41/storage/myisam/mi_create.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_create.c 2019-11-06 06:20:37.000000000 +0000 @@ -610,7 +610,7 @@ klinkname_ptr= klinkname; /* Don't create the table if the link or file exists to ensure that one - doesn't accidently destroy another table. + doesn't accidentally destroy another table. */ create_flag=0; } diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_delete.c mariadb-10.1-10.1.43/storage/myisam/mi_delete.c --- mariadb-10.1-10.1.41/storage/myisam/mi_delete.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_delete.c 2019-11-06 06:20:37.000000000 +0000 @@ -326,7 +326,7 @@ { DBUG_PRINT("error",("Didn't find key")); mi_print_error(info->s, HA_ERR_CRASHED); - my_errno=HA_ERR_CRASHED; /* This should newer happend */ + my_errno=HA_ERR_CRASHED; /* This should never happen */ goto err; } save_flag=0; diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_dynrec.c mariadb-10.1-10.1.43/storage/myisam/mi_dynrec.c --- mariadb-10.1-10.1.41/storage/myisam/mi_dynrec.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_dynrec.c 2019-11-06 06:20:37.000000000 +0000 @@ -886,8 +886,8 @@ /* Check if next block is a deleted block Above we have MI_MIN_BLOCK_LENGTH to avoid the problem where - the next block is so small it can't be splited which could - casue problems + the next block is so small it can't be split which could + cause problems */ MI_BLOCK_INFO del_block; diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_extra.c mariadb-10.1-10.1.43/storage/myisam/mi_extra.c --- mariadb-10.1-10.1.41/storage/myisam/mi_extra.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_extra.c 2019-11-06 06:20:37.000000000 +0000 @@ -211,7 +211,7 @@ info->read_record= share->read_record; info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); break; - case HA_EXTRA_NO_USER_CHANGE: /* Database is somehow locked agains changes */ + case HA_EXTRA_NO_USER_CHANGE: /* Database is somehow locked against changes */ info->lock_type= F_EXTRA_LCK; /* Simulate as locked */ break; case HA_EXTRA_WAIT_LOCK: @@ -349,7 +349,7 @@ if (share->base.blobs) mi_alloc_rec_buff(info, -1, &info->rec_buff); break; - case HA_EXTRA_NORMAL: /* Theese isn't in use */ + case HA_EXTRA_NORMAL: /* These aren't in use */ info->quick_mode=0; break; case HA_EXTRA_QUICK: diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_key.c mariadb-10.1-10.1.43/storage/myisam/mi_key.c --- mariadb-10.1-10.1.41/storage/myisam/mi_key.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_key.c 2019-11-06 06:20:37.000000000 +0000 @@ -605,7 +605,7 @@ } /* - The following code works becasue if s_value < 0 then value is 0 + The following code works because if s_value < 0 then value is 0 and if s_value == 0 then value will contain either s_value or the correct value. */ diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_locking.c mariadb-10.1-10.1.43/storage/myisam/mi_locking.c --- mariadb-10.1-10.1.41/storage/myisam/mi_locking.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_locking.c 2019-11-06 06:20:37.000000000 +0000 @@ -446,7 +446,7 @@ @param org_table @param new_table that should point on org_lock. new_table is 0 - in case this is the first occurence of the table in the lock + in case this is the first occurrence of the table in the lock structure. */ diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_packrec.c mariadb-10.1-10.1.43/storage/myisam/mi_packrec.c --- mariadb-10.1-10.1.41/storage/myisam/mi_packrec.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_packrec.c 2019-11-06 06:20:37.000000000 +0000 @@ -810,7 +810,7 @@ return &uf_varchar2; case FIELD_LAST: default: - return 0; /* This should never happend */ + return 0; /* This should never happen */ } } diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_rfirst.c mariadb-10.1-10.1.43/storage/myisam/mi_rfirst.c --- mariadb-10.1-10.1.41/storage/myisam/mi_rfirst.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_rfirst.c 2019-11-06 06:20:37.000000000 +0000 @@ -16,7 +16,7 @@ #include "myisamdef.h" - /* Read first row through a specfic key */ + /* Read first row through a specific key */ int mi_rfirst(MI_INFO *info, uchar *buf, int inx) { diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_search.c mariadb-10.1-10.1.43/storage/myisam/mi_search.c --- mariadb-10.1-10.1.41/storage/myisam/mi_search.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_search.c 2019-11-06 06:20:37.000000000 +0000 @@ -432,7 +432,7 @@ /* If prefix_len > cmplen then we are in the end-space comparison - phase. Do not try to acces the key any more ==> left= 0. + phase. Do not try to access the key any more ==> left= 0. */ left= ((len <= cmplen) ? suffix_len : ((prefix_len < cmplen) ? cmplen - prefix_len : 0)); diff -Nru mariadb-10.1-10.1.41/storage/myisam/mi_test_all.sh mariadb-10.1-10.1.43/storage/myisam/mi_test_all.sh --- mariadb-10.1-10.1.41/storage/myisam/mi_test_all.sh 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/mi_test_all.sh 2019-11-06 06:20:37.000000000 +0000 @@ -19,8 +19,8 @@ # MA 02110-1335 USA # -# Execute some simple basic test on MyISAM libary to check if things -# works at all. +# Execute some simple basic tests on the MyISAM library to check if +# things work at all. valgrind="valgrind --alignment=8 --leak-check=yes" silent="-s" diff -Nru mariadb-10.1-10.1.41/storage/myisam/myisamchk.c mariadb-10.1-10.1.43/storage/myisam/myisamchk.c --- mariadb-10.1-10.1.41/storage/myisam/myisamchk.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/myisamchk.c 2019-11-06 06:20:37.000000000 +0000 @@ -379,7 +379,7 @@ puts("Check options (check is the default action for myisamchk):\n\ -c, --check Check table for errors.\n\ - -e, --extend-check Check the table VERY throughly. Only use this in\n\ + -e, --extend-check Check the table VERY thoroughly. Only use this in\n\ extreme cases as myisamchk should normally be able to\n\ find out if the table is ok even without this switch.\n\ -F, --fast Check only tables that haven't been closed properly.\n\ diff -Nru mariadb-10.1-10.1.41/storage/myisam/myisamdef.h mariadb-10.1-10.1.43/storage/myisam/myisamdef.h --- mariadb-10.1-10.1.41/storage/myisam/myisamdef.h 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/myisamdef.h 2019-11-06 06:20:37.000000000 +0000 @@ -195,7 +195,7 @@ ulong last_process; /* For table-change-check */ ulong last_version; /* Version on start */ ulong options; /* Options used */ - ulong min_pack_length; /* Theese are used by packed data */ + ulong min_pack_length; /* These are used by packed data */ ulong max_pack_length; ulong state_diff_length; uint rec_reflength; /* rec_reflength in use now */ diff -Nru mariadb-10.1-10.1.41/storage/myisam/myisamlog.c mariadb-10.1-10.1.43/storage/myisam/myisamlog.c --- mariadb-10.1-10.1.41/storage/myisam/myisamlog.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/myisamlog.c 2019-11-06 06:20:37.000000000 +0000 @@ -415,7 +415,7 @@ left_root_right); file_info.id=open_param.max_id+1; /* - * In the line below +10 is added to accomodate '<' and '>' chars + * In the line below +10 is added to accommodate '<' and '>' chars * plus '\0' at the end, so that there is place for 7 digits. * It is improbable that same table can have that many entries in * the table cache. diff -Nru mariadb-10.1-10.1.41/storage/myisam/myisampack.c mariadb-10.1-10.1.43/storage/myisam/myisampack.c --- mariadb-10.1-10.1.41/storage/myisam/myisampack.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/myisampack.c 2019-11-06 06:20:37.000000000 +0000 @@ -110,7 +110,7 @@ MI_INFO **file,**current,**end; uint free_file; uint count; - uint min_pack_length; /* Theese is used by packed data */ + uint min_pack_length; /* These are used by packed data */ uint max_pack_length; uint ref_length; uint max_blob_length; @@ -1237,7 +1237,7 @@ huff_counts->counts[0]=0; goto found_pack; } - /* Remeber the number of significant spaces. */ + /* Remember the number of significant spaces. */ old_space_count=huff_counts->counts[' ']; /* Add all leading and trailing spaces. */ huff_counts->counts[' ']+= (huff_counts->tot_end_space + diff -Nru mariadb-10.1-10.1.41/storage/myisam/NEWS mariadb-10.1-10.1.43/storage/myisam/NEWS --- mariadb-10.1-10.1.41/storage/myisam/NEWS 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/NEWS 2019-11-06 06:20:37.000000000 +0000 @@ -26,7 +26,7 @@ - Index on BLOB and VARCHAR. - One can now have NULL in an index. This takes 0-1 bytes / key. - MYISAM will allow one to specify one AUTO_INCREMENT column; MYISAM will - automaticly update this on INSERT/UPDATE. The AUTO_INCREMENT value can be + automatically update this on INSERT/UPDATE. The AUTO_INCREMENT value can be reset with myisamchk. - Max key length will be 500 by default; In cases of longer keys than 250, a bigger key block size than the default of 1024 byes is used for this key. @@ -39,7 +39,7 @@ - 'myisamchk -a' stores statistic for key parts (and not only for whole keys as in NISAM). - Dynamic size rows will now be much less fragmented when mixing deletes with - update and insert. This is done by automaticly combine adjacent deleted + update and insert. This is done by automatically combining adjacent deleted blocks and by extending blocks if the next block is deleted. - For dynamic size rows, the delete link contains a pointer to itself (to make repairs easier). diff -Nru mariadb-10.1-10.1.41/storage/myisam/sort.c mariadb-10.1-10.1.43/storage/myisam/sort.c --- mariadb-10.1-10.1.41/storage/myisam/sort.c 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/myisam/sort.c 2019-11-06 06:20:37.000000000 +0000 @@ -860,7 +860,7 @@ buffpek Where to read from sort_length max length to read RESULT - > 0 Ammount of bytes read + > 0 Number of bytes read -1 Error */ diff -Nru mariadb-10.1-10.1.41/storage/perfschema/pfs_instr.cc mariadb-10.1-10.1.43/storage/perfschema/pfs_instr.cc --- mariadb-10.1-10.1.41/storage/perfschema/pfs_instr.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/perfschema/pfs_instr.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1265,7 +1265,6 @@ char dirbuffer[FN_REFLEN]; size_t dirlen; const char *normalized_filename; - int normalized_length; dirlen= dirname_length(safe_filename); if (dirlen == 0) @@ -1296,7 +1295,7 @@ *buf_end= '\0'; normalized_filename= buffer; - normalized_length= strlen(normalized_filename); + size_t normalized_length= strlen(normalized_filename); PFS_file **entry; uint retry_count= 0; @@ -1345,7 +1344,7 @@ pfs->m_class= klass; pfs->m_enabled= klass->m_enabled && flag_global_instrumentation; pfs->m_timed= klass->m_timed; - strncpy(pfs->m_filename, normalized_filename, normalized_length); + strncpy(pfs->m_filename, normalized_filename, normalized_length + 1); pfs->m_filename[normalized_length]= '\0'; pfs->m_filename_length= normalized_length; pfs->m_file_stat.m_open_count= 1; diff -Nru mariadb-10.1-10.1.41/storage/sphinx/ha_sphinx.cc mariadb-10.1-10.1.43/storage/sphinx/ha_sphinx.cc --- mariadb-10.1-10.1.41/storage/sphinx/ha_sphinx.cc 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/sphinx/ha_sphinx.cc 2019-11-06 06:20:37.000000000 +0000 @@ -2291,7 +2291,8 @@ CSphSEThreadTable * pTable = GetTls (); if ( pTable ) { - strncpy ( pTable->m_tStats.m_sLastMessage, mysql_error ( pConn ), sizeof ( pTable->m_tStats.m_sLastMessage ) ); + strncpy ( pTable->m_tStats.m_sLastMessage, mysql_error ( pConn ), sizeof pTable->m_tStats.m_sLastMessage - 1 ); + pTable->m_tStats.m_sLastMessage[sizeof pTable->m_tStats.m_sLastMessage - 1] = '\0'; pTable->m_tStats.m_bLastError = true; } @@ -2558,7 +2559,8 @@ CSphSEThreadTable * pTable = GetTls (); if ( pTable ) { - strncpy ( pTable->m_tStats.m_sLastMessage, sMessage, sizeof(pTable->m_tStats.m_sLastMessage) ); + strncpy ( pTable->m_tStats.m_sLastMessage, sMessage, sizeof pTable->m_tStats.m_sLastMessage - 1 ); + pTable->m_tStats.m_sLastMessage[sizeof pTable->m_tStats.m_sLastMessage - 1] = '\0'; pTable->m_tStats.m_bLastError = ( uStatus==SEARCHD_ERROR ); } @@ -2982,7 +2984,8 @@ SPH_RET ( HA_ERR_END_OF_FILE ); } - strncpy ( pTable->m_tStats.m_sLastMessage, sMessage, sizeof(pTable->m_tStats.m_sLastMessage) ); + strncpy ( pTable->m_tStats.m_sLastMessage, sMessage, sizeof pTable->m_tStats.m_sLastMessage - 1 ); + pTable->m_tStats.m_sLastMessage[sizeof pTable->m_tStats.m_sLastMessage - 1] = '\0'; SafeDeleteArray ( sMessage ); if ( uRespStatus!=SEARCHD_WARNING ) diff -Nru mariadb-10.1-10.1.41/storage/tokudb/CMakeLists.txt mariadb-10.1-10.1.43/storage/tokudb/CMakeLists.txt --- mariadb-10.1-10.1.41/storage/tokudb/CMakeLists.txt 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/CMakeLists.txt 2019-11-06 06:20:37.000000000 +0000 @@ -47,6 +47,7 @@ MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough") +MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-cpp" DEBUG) ############################################ SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump" PARENT_SCOPE) diff -Nru mariadb-10.1-10.1.41/storage/tokudb/hatoku_cmp.cc mariadb-10.1-10.1.43/storage/tokudb/hatoku_cmp.cc --- mariadb-10.1-10.1.41/storage/tokudb/hatoku_cmp.cc 2019-07-26 16:34:55.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/hatoku_cmp.cc 2019-11-06 06:20:37.000000000 +0000 @@ -954,9 +954,8 @@ const void* saved_key_data, const uint32_t saved_key_size ) { - assert_always( - (new_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH) && - (saved_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH)); + assert_always(new_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH); + assert_always(saved_key_size >= TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH); ulonglong a = hpk_char_to_num((uchar *) new_key_data); ulonglong b = hpk_char_to_num((uchar *) saved_key_data); return a < b ? -1 : (a > b ? 1 : 0); @@ -2534,7 +2533,8 @@ bool is_col_in_pk = false; if (bitmap_is_set(&kc_info->key_filters[pk_index],field_index)) { - assert_always(!has_hpk && prim_key != NULL); + assert_always(!has_hpk); + assert_always(prim_key != nullptr); is_col_in_pk = true; } else { diff -Nru mariadb-10.1-10.1.41/storage/tokudb/ha_tokudb.cc mariadb-10.1-10.1.43/storage/tokudb/ha_tokudb.cc --- mariadb-10.1-10.1.41/storage/tokudb/ha_tokudb.cc 2019-07-26 16:34:55.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/ha_tokudb.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1077,7 +1077,8 @@ } buff = (uchar *)dest_key->data; - assert_always(buff != NULL && max_key_len > 0); + assert_always(buff != nullptr); + assert_always(max_key_len > 0); } else { assert_unreachable(); } diff -Nru mariadb-10.1-10.1.41/storage/tokudb/ha_tokudb.h mariadb-10.1-10.1.43/storage/tokudb/ha_tokudb.h --- mariadb-10.1-10.1.41/storage/tokudb/ha_tokudb.h 2019-07-26 16:34:55.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/ha_tokudb.h 2019-11-06 06:20:37.000000000 +0000 @@ -387,7 +387,8 @@ assert_debug(_mutex.is_owned_by_me()); // can not change number of keys live - assert_always(_rec_per_key == NULL && _rec_per_keys == 0); + assert_always(_rec_per_key == nullptr); + assert_always(_rec_per_keys == 0); _rec_per_keys = rec_per_keys; _rec_per_key = rec_per_key; } diff -Nru mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result --- mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result 2019-07-26 16:34:55.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result 2019-11-06 06:20:37.000000000 +0000 @@ -26,7 +26,7 @@ # number of rows should be 9 explain select * from foo where a > 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where +1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where # should have just 4 values select * from foo where a > 1; a b @@ -37,7 +37,7 @@ # number of rows should be 9 explain select * from foo where a > 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where +1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where # 9 values select * From foo where a > 1; a b diff -Nru mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result --- mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result 2019-07-26 16:34:55.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result 2019-11-06 06:20:37.000000000 +0000 @@ -26,7 +26,7 @@ # number of rows should be 9 explain select * from foo where a < 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where +1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where # should have just 4 values select * from foo where a < 50; a b @@ -37,7 +37,7 @@ # number of rows should be 9 explain select * from foo where a < 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where +1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where # 9 values select * From foo where a < 50; a b diff -Nru mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result --- mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result 2019-07-26 16:34:55.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result 2019-11-06 06:20:37.000000000 +0000 @@ -26,7 +26,7 @@ # number of rows should be 8 explain select * from foo where a > 1 and a < 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where +1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where # should have just 4 values select * from foo where a > 1 and a < 50; a b @@ -37,7 +37,7 @@ # number of rows should be 8 explain select * from foo where a > 1 and a < 50; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where +1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where # 8 values select * from foo where a > 1 and a < 50; a b diff -Nru mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result --- mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result 2019-11-06 06:20:37.000000000 +0000 @@ -6,5 +6,5 @@ insert into t2970 values (1,1,1,1),(1,2,3,4); explain select a,count(b),max(b) from t2970 where a > 0 group by a order by a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2970 index a,a_2 a_2 10 NULL 2 Using where; Using index +1 SIMPLE t2970 range a,a_2 a_2 5 NULL 2 Using where; Using index drop table t2970; diff -Nru mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result --- mariadb-10.1-10.1.41/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/mysql-test/tokudb_parts/r/partition_debug_tokudb.result 2019-11-06 06:20:37.000000000 +0000 @@ -12,6 +12,7 @@ call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); flush tables; # Crash testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -70,7 +71,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -131,7 +132,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -192,7 +193,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -253,7 +254,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -314,7 +315,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -375,7 +376,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -436,7 +437,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -498,7 +499,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -558,7 +559,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -618,8 +619,9 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; # Error recovery testing ADD PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_add_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -732,7 +734,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -845,7 +847,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -958,7 +960,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1071,7 +1073,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1184,7 +1186,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1297,7 +1299,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1410,7 +1412,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1525,7 +1527,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1640,7 +1642,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_add_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1755,8 +1757,9 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_add_partition_10"; +SET SESSION debug_dbug=@save_dbug; # Test DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1814,7 +1817,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1874,7 +1877,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1934,7 +1937,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -1989,7 +1992,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2044,7 +2047,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2099,7 +2102,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2152,7 +2155,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2205,7 +2208,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2258,8 +2261,9 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; # Error recovery DROP PARTITION +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2370,7 +2374,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2481,7 +2485,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2592,7 +2596,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2693,7 +2697,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2794,7 +2798,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2895,7 +2899,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -2996,7 +3000,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3097,7 +3101,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_drop_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3198,9 +3202,10 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_drop_partition_9"; +SET SESSION debug_dbug=@save_dbug; # Test change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,crash_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3260,7 +3265,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3322,7 +3327,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3384,7 +3389,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3446,7 +3451,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3508,7 +3513,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3570,7 +3575,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3633,7 +3638,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3696,7 +3701,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3757,7 +3762,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3818,7 +3823,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3879,7 +3884,7 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,crash_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -3940,9 +3945,10 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t1; -SET SESSION debug_dbug="-d,crash_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; # Error recovery change partition (REORGANIZE/REBUILD/COALESCE # or ADD HASH PARTITION). +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,fail_change_partition_1"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4057,7 +4063,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_2"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4172,7 +4178,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_3"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4287,7 +4293,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_4"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4402,7 +4408,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_5"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4517,7 +4523,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_6"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4632,7 +4638,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_7"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4749,7 +4755,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_8"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4866,7 +4872,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_9"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -4983,7 +4989,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_9"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_10"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -5100,7 +5106,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_10"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_11"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -5217,7 +5223,7 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_11"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,fail_change_partition_12"; CREATE TABLE t1 (a INT, b VARCHAR(64)) ENGINE = 'TokuDB' @@ -5334,13 +5340,14 @@ 4 Original from partition p0 UNLOCK TABLES; DROP TABLE t1; -SET SESSION debug_dbug="-d,fail_change_partition_12"; +SET SESSION debug_dbug=@save_dbug; # # WL#4445: EXCHANGE PARTITION WITH TABLE # Verify ddl_log and TokuDB in case of crashing. call mtr.add_suppression("TokuDB: Warning: allocated tablespace .*, old maximum was "); call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); call mtr.add_suppression("table .* does not exist in the TokuDB internal"); +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5436,7 +5443,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5532,7 +5539,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5628,7 +5635,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5724,7 +5731,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5820,7 +5827,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -5916,7 +5923,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6012,7 +6019,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6108,7 +6115,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_abort_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6204,7 +6211,8 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_abort_9"; +SET SESSION debug_dbug=@save_dbug; +SET @save_dbug=@@debug_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_1"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6296,7 +6304,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_1"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_2"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6388,7 +6396,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_2"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_3"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6480,7 +6488,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_3"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_4"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6572,7 +6580,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_4"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_5"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6664,7 +6672,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_5"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_6"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6756,7 +6764,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_6"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_7"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6848,7 +6856,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_7"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_8"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -6940,7 +6948,7 @@ 7 Original from table t2 8 Original from table t2 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_8"; +SET SESSION debug_dbug=@save_dbug; SET SESSION debug_dbug="+d,exchange_partition_fail_9"; CREATE TABLE t2 (a INT, b VARCHAR(64)) ENGINE = TokuDB; INSERT INTO t2 VALUES (5, "Original from table t2"), (6, "Original from table t2"), (7, "Original from table t2"), (8, "Original from table t2"); @@ -7032,4 +7040,4 @@ 3 Original from partition p0 4 Original from partition p0 DROP TABLE t2; -SET SESSION debug_dbug="-d,exchange_partition_fail_9"; +SET SESSION debug_dbug=@save_dbug; diff -Nru mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake --- mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/cmake_modules/TokuMergeLibs.cmake 2019-11-06 06:20:37.000000000 +0000 @@ -6,7 +6,7 @@ IF(deps) FOREACH(lib ${deps}) # Filter out keywords for used for debug vs optimized builds - IF(NOT lib MATCHES "general" AND NOT lib MATCHES "debug" AND NOT lib MATCHES "optimized") + IF(TARGET ${lib}) GET_TARGET_PROPERTY(lib_location ${lib} LOCATION) IF(NOT lib_location) SET(ret ${ret} ${lib}) diff -Nru mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake --- mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake 2019-11-06 06:20:37.000000000 +0000 @@ -1,39 +1,5 @@ include(ExternalProject) -if (CMAKE_PROJECT_NAME STREQUAL TokuDB) - ## add jemalloc with an external project - set(JEMALLOC_SOURCE_DIR "${TokuDB_SOURCE_DIR}/third_party/jemalloc" CACHE FILEPATH "Where to find jemalloc sources.") - if (EXISTS "${JEMALLOC_SOURCE_DIR}/configure") - set(jemalloc_configure_opts "CC=${CMAKE_C_COMPILER}" "--with-jemalloc-prefix=" "--with-private-namespace=tokudb_jemalloc_internal_" "--enable-cc-silence") - option(JEMALLOC_DEBUG "Build jemalloc with --enable-debug." OFF) - if (JEMALLOC_DEBUG) - list(APPEND jemalloc_configure_opts --enable-debug) - endif () - ExternalProject_Add(build_jemalloc - PREFIX jemalloc - SOURCE_DIR "${JEMALLOC_SOURCE_DIR}" - CONFIGURE_COMMAND - "${JEMALLOC_SOURCE_DIR}/configure" ${jemalloc_configure_opts} - "--prefix=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc" - ) - - add_library(jemalloc STATIC IMPORTED GLOBAL) - set_target_properties(jemalloc PROPERTIES IMPORTED_LOCATION - "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib/libjemalloc_pic.a") - add_dependencies(jemalloc build_jemalloc) - add_library(jemalloc_nopic STATIC IMPORTED GLOBAL) - set_target_properties(jemalloc_nopic PROPERTIES IMPORTED_LOCATION - "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib/libjemalloc.a") - add_dependencies(jemalloc_nopic build_jemalloc) - - # detect when we are being built as a subproject - if (NOT DEFINED MYSQL_PROJECT_NAME_DOCSTRING) - install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib" DESTINATION . - COMPONENT tokukv_libs_extra) - endif () - endif () -endif () - ## add lzma with an external project set(xz_configure_opts --with-pic --enable-static) if (APPLE) diff -Nru mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/scripts/run-nightly-coverage-tests.bash mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/scripts/run-nightly-coverage-tests.bash --- mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/scripts/run-nightly-coverage-tests.bash 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/scripts/run-nightly-coverage-tests.bash 2019-11-06 06:20:37.000000000 +0000 @@ -26,7 +26,7 @@ -D RUN_LONG_TESTS=ON \ -D TOKUDB_DATA=$tokudbdir/../tokudb.data \ .. - ninja build_jemalloc build_lzma build_snappy + ninja build_lzma build_snappy popd fi diff -Nru mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/scripts/run-nightly-drd-tests.bash mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/scripts/run-nightly-drd-tests.bash --- mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/scripts/run-nightly-drd-tests.bash 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/scripts/run-nightly-drd-tests.bash 2019-11-06 06:20:37.000000000 +0000 @@ -25,7 +25,7 @@ -D RUN_LONG_TESTS=ON \ -D TOKUDB_DATA=$tokudbdir/../tokudb.data \ .. - ninja build_jemalloc build_lzma build_snappy + ninja build_lzma build_snappy popd fi diff -Nru mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/scripts/run-nightly-release-tests.bash mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/scripts/run-nightly-release-tests.bash --- mariadb-10.1-10.1.41/storage/tokudb/PerconaFT/scripts/run-nightly-release-tests.bash 2019-07-26 16:34:54.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/PerconaFT/scripts/run-nightly-release-tests.bash 2019-11-06 06:20:37.000000000 +0000 @@ -25,7 +25,7 @@ -D RUN_LONG_TESTS=ON \ -D TOKUDB_DATA=$tokudbdir/../tokudb.data \ .. - ninja build_jemalloc build_lzma build_snappy + ninja build_lzma build_snappy popd fi diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/math_test_int.cc mariadb-10.1-10.1.43/storage/tokudb/tests/math_test_int.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/math_test_int.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/math_test_int.cc 2019-11-06 06:20:37.000000000 +0000 @@ -54,16 +54,20 @@ assert(over); else if (m < -max) assert(over); - else - assert(!over && n == m); + else { + assert(!over); + assert(n == m); + } n = int_sub(x, y, 8, &over); m = x - y; if (m > max-1) assert(over); else if (m < -max) assert(over); - else - assert(!over && n == m); + else { + assert(!over); + asset(n == m); + } } } } @@ -82,16 +86,20 @@ assert(over); else if (m < -max) assert(over); - else - assert(!over && n == m); + else { + assert(!over); + assert(n == m); + } n = int_sub(x, y, 16, &over); m = x - y; if (m > max-1) assert(over); else if (m < -max) assert(over); - else - assert(!over && n == m); + else { + assert(!over); + assert(n == m); + } } } } @@ -104,20 +112,42 @@ s = int_add(1, (1ULL<<23)-1, 24, &over); assert(over); s = int_add((1ULL<<23)-1, 1, 24, &over); assert(over); - s = int_sub(-1, (1ULL<<23), 24, &over); assert(!over && s == (1ULL<<23)-1); + s = int_sub(-1, (1ULL<<23), 24, &over); + assert(!over); + assert(s == (1ULL<<23)-1); s = int_sub((1ULL<<23), 1, 24, &over); assert(over); - s = int_add(0, 0, 24, &over); assert(!over && s == 0); - s = int_sub(0, 0, 24, &over); assert(!over && s == 0); - s = int_add(0, -1, 24, &over); assert(!over && s == -1); - s = int_sub(0, 1, 24, &over); assert(!over && s == -1); - s = int_add(0, (1ULL<<23), 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)); - s = int_sub(0, (1ULL<<23)-1, 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)+1); - - s = int_add(-1, 0, 24, &over); assert(!over && s == -1); - s = int_add(-1, 1, 24, &over); assert(!over && s == 0); - s = int_sub(-1, -1, 24, &over); assert(!over && s == 0); - s = int_sub(-1, (1ULL<<23)-1, 24, &over); assert(!over && (s & ((1ULL<<24)-1)) == (1ULL<<23)); + s = int_add(0, 0, 24, &over); + assert(!over); + assert(s == 0); + s = int_sub(0, 0, 24, &over); + assert(!over); + assert(s == 0); + s = int_add(0, -1, 24, &over); + assert(!over); + assert(s == -1); + s = int_sub(0, 1, 24, &over); + assert(!over); + assert(s == -1); + s = int_add(0, (1ULL<<23), 24, &over); + assert(!over); + assert((s & ((1ULL<<24)-1)) == (1ULL<<23)); + s = int_sub(0, (1ULL<<23)-1, 24, &over); + assert(!over); + assert((s & ((1ULL<<24)-1)) == (1ULL<<23)+1); + + s = int_add(-1, 0, 24, &over); + assert(!over); + assert(s == -1); + s = int_add(-1, 1, 24, &over); + assert(!over); + assert(s == 0); + s = int_sub(-1, -1, 24, &over); + assert(!over); + assert(s == 0); + s = int_sub(-1, (1ULL<<23)-1, 24, &over); + assert(!over); + assert((s & ((1ULL<<24)-1)) == (1ULL<<23)); } static void test_int32() { @@ -128,20 +158,42 @@ s = int_add(1, (1ULL<<31)-1, 32, &over); assert(over); s = int_add((1ULL<<31)-1, 1, 32, &over); assert(over); - s = int_sub(-1, (1ULL<<31), 32, &over); assert(s == (1ULL<<31)-1 && !over); + s = int_sub(-1, (1ULL<<31), 32, &over); + assert(s == (1ULL<<31)-1); + assert(!over); s = int_sub((1ULL<<31), 1, 32, &over); assert(over); - s = int_add(0, 0, 32, &over); assert(s == 0 && !over); - s = int_sub(0, 0, 32, &over); assert(s == 0 && !over); - s = int_add(0, -1, 32, &over); assert(s == -1 && !over); - s = int_sub(0, 1, 32, &over); assert(s == -1 && !over); - s = int_add(0, (1ULL<<31), 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31) && !over); - s = int_sub(0, (1ULL<<31)-1, 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31)+1 && !over); - - s = int_add(-1, 0, 32, &over); assert(s == -1 && !over); - s = int_add(-1, 1, 32, &over); assert(s == 0 && !over); - s = int_sub(-1, -1, 32, &over); assert(s == 0 && !over); - s = int_sub(-1, (1ULL<<31)-1, 32, &over); assert((s & ((1ULL<<32)-1)) == (1ULL<<31) && !over); + s = int_add(0, 0, 32, &over); + assert(s == 0); + assert(!over); + s = int_sub(0, 0, 32, &over); + assert(s == 0); + assert(!over); + s = int_add(0, -1, 32, &over); + assert(s == -1); + assert(!over); + s = int_sub(0, 1, 32, &over); + assert(s == -1); + assert(!over); + s = int_add(0, (1ULL<<31), 32, &over); + assert((s & ((1ULL<<32)-1)) == (1ULL<<31)); + assert(!over); + s = int_sub(0, (1ULL<<31)-1, 32, &over); + assert((s & ((1ULL<<32)-1)) == (1ULL<<31)+1); + assert(!over); + + s = int_add(-1, 0, 32, &over); + assert(s == -1); + assert(!over); + s = int_add(-1, 1, 32, &over); + assert(s == 0); + assert(!over); + s = int_sub(-1, -1, 32, &over); + assert(s == 0); + assert(!over); + s = int_sub(-1, (1ULL<<31)-1, 32, &over); + assert((s & ((1ULL<<32)-1)) == (1ULL<<31)); + assert(!over); } static void test_int64() { @@ -152,20 +204,42 @@ s = int_add(1, (1ULL<<63)-1, 64, &over); assert(over); s = int_add((1ULL<<63)-1, 1, 64, &over); assert(over); - s = int_sub(-1, (1ULL<<63), 64, &over); assert(s == (1ULL<<63)-1 && !over); + s = int_sub(-1, (1ULL<<63), 64, &over); + assert(s == (1ULL<<63)-1); + assert(!over); s = int_sub((1ULL<<63), 1, 64, &over); assert(over); - s = int_add(0, 0, 64, &over); assert(s == 0 && !over); - s = int_sub(0, 0, 64, &over); assert(s == 0 && !over); - s = int_add(0, -1, 64, &over); assert(s == -1 && !over); - s = int_sub(0, 1, 64, &over); assert(s == -1 && !over); - s = int_add(0, (1ULL<<63), 64, &over); assert(s == (int64_t)(1ULL<<63) && !over); - s = int_sub(0, (1ULL<<63)-1, 64, &over); assert(s == (int64_t)((1ULL<<63)+1) && !over); - - s = int_add(-1, 0, 64, &over); assert(s == -1 && !over); - s = int_add(-1, 1, 64, &over); assert(s == 0 && !over); - s = int_sub(-1, -1, 64, &over); assert(s == 0 && !over); - s = int_sub(-1, (1ULL<<63)-1, 64, &over); assert(s == (int64_t)(1ULL<<63) && !over); + s = int_add(0, 0, 64, &over); + assert(s == 0); + assert(!over); + s = int_sub(0, 0, 64, &over); + assert(s == 0); + assert(!over); + s = int_add(0, -1, 64, &over); + assert(s == -1); + assert(!over); + s = int_sub(0, 1, 64, &over); + assert(s == -1); + assert(!over); + s = int_add(0, (1ULL<<63), 64, &over); + assert(s == (int64_t)(1ULL<<63)); + assert(!over); + s = int_sub(0, (1ULL<<63)-1, 64, &over); + assert(s == (int64_t)((1ULL<<63)+1)); + assert(!over); + + s = int_add(-1, 0, 64, &over); + assert(s == -1); + assert(!over); + s = int_add(-1, 1, 64, &over); + assert(s == 0); + assert(!over); + s = int_sub(-1, -1, 64, &over); + assert(s == 0); + assert(!over); + s = int_sub(-1, (1ULL<<63)-1, 64, &over); + assert(s == (int64_t)(1ULL<<63)); + assert(!over); } static void test_int_sign(uint length_bits) { diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/math_test_uint.cc mariadb-10.1-10.1.43/storage/tokudb/tests/math_test_uint.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/math_test_uint.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/math_test_uint.cc 2019-11-06 06:20:37.000000000 +0000 @@ -51,14 +51,18 @@ m = x + y; if (m > (1ULL<<8)-1) assert(over); - else - assert(!over && n == (m % 256)); + else { + assert(!over); + assert(n == (m % 256)); + } n = uint_sub(x, y, 8, &over); m = x - y; if (m > x) assert(over); - else - assert(!over && n == (m % 256)); + else { + assert(!over); + assert(n == (m % 256)); + } } } } @@ -75,14 +79,18 @@ m = x + y; if (m > (1ULL<<16)-1) assert(over); - else - assert(!over && n == (m % (1ULL<<16))); + else { + assert(!over); + assert(n == (m % (1ULL<<16))); + } n = uint_sub(x, y, 16, &over); m = x - y; if (m > x) assert(over); - else - assert(!over && n == (m % (1ULL<<16))); + else { + assert(!over); + assert(n == (m % (1ULL<<16))); + } } } } @@ -95,13 +103,23 @@ s = uint_add((1ULL<<24)-1, (1ULL<<24)-1, 24, &over); assert(over); s = uint_add((1ULL<<24)-1, 1, 24, &over); assert(over); - s = uint_add((1ULL<<24)-1, 0, 24, &over); assert(!over && s == (1ULL<<24)-1); - s = uint_add(0, 1, 24, &over); assert(!over && s == 1); - s = uint_add(0, 0, 24, &over); assert(!over && s == 0); - s = uint_sub(0, 0, 24, &over); assert(!over && s == 0); + s = uint_add((1ULL<<24)-1, 0, 24, &over); + assert(!over); + assert(s == (1ULL<<24)-1); + s = uint_add(0, 1, 24, &over); + assert(!over); + assert(s == 1); + s = uint_add(0, 0, 24, &over); + assert(!over); + assert(s == 0); + s = uint_sub(0, 0, 24, &over); + assert(!over); + assert(s == 0); s = uint_sub(0, 1, 24, &over); assert(over); s = uint_sub(0, (1ULL<<24)-1, 24, &over); assert(over); - s = uint_sub((1ULL<<24)-1, (1ULL<<24)-1, 24, &over); assert(!over && s == 0); + s = uint_sub((1ULL<<24)-1, (1ULL<<24)-1, 24, &over); + assert(!over); + assert(s == 0); } static void test_uint32() { @@ -112,13 +130,23 @@ s = uint_add((1ULL<<32)-1, (1ULL<<32)-1, 32, &over); assert(over); s = uint_add((1ULL<<32)-1, 1, 32, &over); assert(over); - s = uint_add((1ULL<<32)-1, 0, 32, &over); assert(!over && s == (1ULL<<32)-1); - s = uint_add(0, 1, 32, &over); assert(!over && s == 1); - s = uint_add(0, 0, 32, &over); assert(!over && s == 0); - s = uint_sub(0, 0, 32, &over); assert(!over && s == 0); + s = uint_add((1ULL<<32)-1, 0, 32, &over); + assert(!over); + assert(s == (1ULL<<32)-1); + s = uint_add(0, 1, 32, &over); + assert(!over); + assert(s == 1); + s = uint_add(0, 0, 32, &over); + assert(!over); + assert(s == 0); + s = uint_sub(0, 0, 32, &over); + assert(!over); + assert(s == 0); s = uint_sub(0, 1, 32, &over); assert(over); s = uint_sub(0, (1ULL<<32)-1, 32, &over); assert(over); - s = uint_sub((1ULL<<32)-1, (1ULL<<32)-1, 32, &over); assert(!over && s == 0); + s = uint_sub((1ULL<<32)-1, (1ULL<<32)-1, 32, &over); + assert(!over); + assert(s == 0); } static void test_uint64() { @@ -129,13 +157,23 @@ s = uint_add(~0ULL, ~0ULL, 64, &over); assert(over); s = uint_add(~0ULL, 1, 64, &over); assert(over); - s = uint_add(~0ULL, 0, 64, &over); assert(!over && s == ~0ULL); - s = uint_add(0, 1, 64, &over); assert(!over && s == 1); - s = uint_add(0, 0, 64, &over); assert(!over && s == 0); - s = uint_sub(0, 0, 64, &over); assert(!over && s == 0); + s = uint_add(~0ULL, 0, 64, &over); + assert(!over); + assert(s == ~0ULL); + s = uint_add(0, 1, 64, &over); + assert(!over); + assert(s == 1); + s = uint_add(0, 0, 64, &over); + assert(!over); + assert(s == 0); + s = uint_sub(0, 0, 64, &over); + assert(!over); + assert(s == 0); s = uint_sub(0, 1, 64, &over); assert(over); s = uint_sub(0, ~0ULL, 64, &over); assert(over); - s = uint_sub(~0ULL, ~0ULL, 64, &over); assert(!over && s == 0); + s = uint_sub(~0ULL, ~0ULL, 64, &over); + assert(!over); + assert(s == 0); } int main() { diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/sint_test.cc mariadb-10.1-10.1.43/storage/tokudb/tests/sint_test.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/sint_test.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/sint_test.cc 2019-11-06 06:20:37.000000000 +0000 @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/tokudb_buffer_test.cc mariadb-10.1-10.1.43/storage/tokudb/tests/tokudb_buffer_test.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/tokudb_buffer_test.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/tokudb_buffer_test.cc 2019-11-06 06:20:37.000000000 +0000 @@ -32,9 +32,13 @@ static void test_null() { tokudb::buffer b; - assert(b.data() == NULL && b.size() == 0 && b.limit() == 0); + assert(b.data() == nullptr); + assert(b.size() == 0); + assert(b.limit() == 0); b.append(NULL, 0); - assert(b.data() == NULL && b.size() == 0 && b.limit() == 0); + assert(b.data() == nullptr); + assert(b.size() == 0); + assert(b.limit() == 0); } static void append_az(tokudb::buffer &b) { @@ -132,7 +136,8 @@ } for (size_t i = 0; i < a.size()/2; i++) { unsigned char *cp = (unsigned char *) a.data() + 2*i; - assert(cp[0] == 'a'+i && cp[1] == 'a'+i); + assert(cp[0] == 'a'+i); + assert(cp[1] == 'a'+i); } } diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/uint_test.cc mariadb-10.1-10.1.43/storage/tokudb/tests/uint_test.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/uint_test.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/uint_test.cc 2019-11-06 06:20:37.000000000 +0000 @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/vlq_test.cc mariadb-10.1-10.1.43/storage/tokudb/tests/vlq_test.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/vlq_test.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/vlq_test.cc 2019-11-06 06:20:37.000000000 +0000 @@ -52,7 +52,8 @@ in_s = tokudb::vlq_decode_ui(&n, b, 1); assert(in_s == 0); in_s = tokudb::vlq_decode_ui(&n, b, 2); - assert(in_s == 2 && n == 128); + assert(in_s == 2); + assert(n == 128); } static void test_80000000(void) { @@ -63,7 +64,8 @@ out_s = tokudb::vlq_encode_ui(v, b, sizeof b); assert(out_s == 5); in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 5 && n == v); + assert(in_s == 5); + assert(n == v); } static void test_100000000(void) { @@ -74,7 +76,8 @@ out_s = tokudb::vlq_encode_ui(v, b, sizeof b); assert(out_s == 5); in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 5 && n == v); + assert(in_s == 5); + assert(n == v); } int main(void) { diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/vlq_test_uint32.cc mariadb-10.1-10.1.43/storage/tokudb/tests/vlq_test_uint32.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/vlq_test_uint32.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/vlq_test_uint32.cc 2019-11-06 06:20:37.000000000 +0000 @@ -44,7 +44,8 @@ assert(out_s == 1); uint32_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 1 && n == v); + assert(in_s == 1); + assert(n == v); } printf("%u\n", 1<<7); @@ -54,7 +55,8 @@ assert(out_s == 2); uint32_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 2 && n == v); + assert(in_s == 2); + assert(n == v); } printf("%u\n", 1<<14); @@ -64,7 +66,8 @@ assert(out_s == 3); uint32_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 3 && n == v); + assert(in_s == 3); + assert(n == v); } printf("%u\n", 1<<21); @@ -74,7 +77,8 @@ assert(out_s == 4); uint32_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 4 && n == v); + assert(in_s == 4); + assert(n == v); } printf("%u\n", 1<<28); @@ -84,7 +88,8 @@ assert(out_s == 5); uint32_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 5 && n == v); + assert(in_s == 5); + assert(n == v); } } diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tests/vlq_test_uint64.cc mariadb-10.1-10.1.43/storage/tokudb/tests/vlq_test_uint64.cc --- mariadb-10.1-10.1.41/storage/tokudb/tests/vlq_test_uint64.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tests/vlq_test_uint64.cc 2019-11-06 06:20:37.000000000 +0000 @@ -46,7 +46,8 @@ assert(out_s == 1); uint64_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 1 && n == v); + assert(in_s == 1); + assert(n == v); } printf("%u\n", 1<<7); @@ -56,7 +57,8 @@ assert(out_s == 2); uint64_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 2 && n == v); + assert(in_s == 2); + assert(n == v); } printf("%u\n", 1<<14); @@ -66,7 +68,8 @@ assert(out_s == 3); uint64_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 3 && n == v); + assert(in_s == 3); + assert(n == v); } printf("%u\n", 1<<21); @@ -76,7 +79,8 @@ assert(out_s == 4); uint64_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 4 && n == v); + assert(in_s == 4); + assert(n == v); } printf("%u\n", 1<<28); @@ -90,7 +94,8 @@ assert(out_s == 5); uint64_t n; size_t in_s = tokudb::vlq_decode_ui(&n, b, out_s); - assert(in_s == 5 && n == v); + assert(in_s == 5); + assert(n == v); } } diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tokudb_buffer.h mariadb-10.1-10.1.43/storage/tokudb/tokudb_buffer.h --- mariadb-10.1-10.1.41/storage/tokudb/tokudb_buffer.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tokudb_buffer.h 2019-11-06 06:20:37.000000000 +0000 @@ -134,8 +134,8 @@ char* data_offset = (char*)m_data + offset; if (new_s != old_s) { size_t n = m_size - (offset + old_s); - assert_always( - offset + new_s + n <= m_limit && offset + old_s + n <= m_limit); + assert_always(offset + new_s + n <= m_limit); + assert_always(offset + old_s + n <= m_limit); memmove(data_offset + new_s, data_offset + old_s, n); if (new_s > old_s) m_size += new_s - old_s; diff -Nru mariadb-10.1-10.1.41/storage/tokudb/tokudb_math.h mariadb-10.1-10.1.43/storage/tokudb/tokudb_math.h --- mariadb-10.1-10.1.41/storage/tokudb/tokudb_math.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/tokudb/tokudb_math.h 2019-11-06 06:20:37.000000000 +0000 @@ -59,7 +59,8 @@ bool* over)); static uint64_t uint_add(uint64_t x, uint64_t y, uint length_bits, bool *over) { uint64_t mask = uint_mask(length_bits); - assert_always((x & ~mask) == 0 && (y & ~mask) == 0); + assert_always((x & ~mask) == 0); + assert_always((y & ~mask) == 0); uint64_t s = (x + y) & mask; *over = s < x; // check for overflow return s; @@ -75,7 +76,8 @@ bool* over)); static uint64_t uint_sub(uint64_t x, uint64_t y, uint length_bits, bool *over) { uint64_t mask = uint_mask(length_bits); - assert_always((x & ~mask) == 0 && (y & ~mask) == 0); + assert_always((x & ~mask) == 0); + assert_always((y & ~mask) == 0); uint64_t s = (x - y) & mask; *over = s > x; // check for overflow return s; diff -Nru mariadb-10.1-10.1.41/storage/xtradb/buf/buf0buf.cc mariadb-10.1-10.1.43/storage/xtradb/buf/buf0buf.cc --- mariadb-10.1-10.1.41/storage/xtradb/buf/buf0buf.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/buf/buf0buf.cc 2019-11-06 06:20:37.000000000 +0000 @@ -124,7 +124,8 @@ byte block_hash_offset; ut_ad(block); - ut_ad(trx && trx->take_stats); + ut_ad(trx); + ut_ad(trx->take_stats); if (!trx->distinct_page_access_hash) { trx->distinct_page_access_hash diff -Nru mariadb-10.1-10.1.41/storage/xtradb/buf/buf0dblwr.cc mariadb-10.1-10.1.43/storage/xtradb/buf/buf0dblwr.cc --- mariadb-10.1-10.1.41/storage/xtradb/buf/buf0dblwr.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/buf/buf0dblwr.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2018, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -291,6 +291,13 @@ ut_ad(rw_lock_get_x_lock_count(&new_block->lock) == 1); page_no = buf_block_get_page_no(new_block); + /* We only do this in the debug build, to ensure that + both the check in buf_flush_init_for_writing() and + recv_parse_or_apply_log_rec_body() will see a valid + page type. The flushes of new_block are actually + unnecessary here. */ + ut_d(mlog_write_ulint(FIL_PAGE_TYPE + new_block->frame, + FIL_PAGE_TYPE_SYS, MLOG_2BYTES, &mtr)); if (i == FSP_EXTENT_SIZE / 2) { ut_a(page_no == FSP_EXTENT_SIZE); @@ -353,6 +360,7 @@ /* Flush the modified pages to disk and make a checkpoint */ log_make_checkpoint_at(LSN_MAX, TRUE); + buf_dblwr_being_created = FALSE; /* Remove doublewrite pages from LRU */ buf_pool_invalidate(); diff -Nru mariadb-10.1-10.1.41/storage/xtradb/buf/buf0flu.cc mariadb-10.1-10.1.43/storage/xtradb/buf/buf0flu.cc --- mariadb-10.1-10.1.41/storage/xtradb/buf/buf0flu.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/buf/buf0flu.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2019, MariaDB Corporation. Copyright (c) 2013, 2014, Fusion-io This program is free software; you can redistribute it and/or modify it under diff -Nru mariadb-10.1-10.1.41/storage/xtradb/dict/dict0dict.cc mariadb-10.1-10.1.43/storage/xtradb/dict/dict0dict.cc --- mariadb-10.1-10.1.41/storage/xtradb/dict/dict0dict.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/dict/dict0dict.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1856,8 +1856,7 @@ /* The old table name in my_charset_filename is stored in old_name_cs_filename */ - strncpy(old_name_cs_filename, old_name, - MAX_FULL_NAME_LEN); + strcpy(old_name_cs_filename, old_name); old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0'; if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) { @@ -1879,8 +1878,7 @@ } else { /* Old name already in my_charset_filename */ - strncpy(old_name_cs_filename, old_name, - MAX_FULL_NAME_LEN); + strcpy(old_name_cs_filename, old_name); old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0'; } @@ -2921,33 +2919,6 @@ } } -/******************************************************************** -Wait until all the background threads of the given table have exited, i.e., -bg_threads == 0. Note: bg_threads_mutex must be reserved when -calling this. */ -UNIV_INTERN -void -dict_table_wait_for_bg_threads_to_exit( -/*===================================*/ - dict_table_t* table, /*< in: table */ - ulint delay) /*< in: time in microseconds to wait between - checks of bg_threads. */ -{ - fts_t* fts = table->fts; - -#ifdef UNIV_SYNC_DEBUG - ut_ad(mutex_own(&fts->bg_threads_mutex)); -#endif /* UNIV_SYNC_DEBUG */ - - while (fts->bg_threads > 0) { - mutex_exit(&fts->bg_threads_mutex); - - os_thread_sleep(delay); - - mutex_enter(&fts->bg_threads_mutex); - } -} - /*******************************************************************//** Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user. diff -Nru mariadb-10.1-10.1.41/storage/xtradb/dict/dict0load.cc mariadb-10.1-10.1.43/storage/xtradb/dict/dict0load.cc --- mariadb-10.1-10.1.41/storage/xtradb/dict/dict0load.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/dict/dict0load.cc 2019-11-06 06:20:37.000000000 +0000 @@ -46,6 +46,7 @@ #include "dict0priv.h" #include "ha_prototypes.h" /* innobase_casedn_str() */ #include "fts0priv.h" +#include "fts0opt.h" /** Following are the InnoDB system tables. The positions in this array are referenced by enum dict_system_table_id. */ @@ -2570,8 +2571,12 @@ FTS */ fts_optimize_remove_table(table); fts_free(table); - } else { + } else if (fts_optimize_wq) { fts_optimize_add_table(table); + } else if (table->can_be_evicted) { + /* fts_optimize_thread is not started yet. + So make the table as non-evictable from cache. */ + dict_table_move_from_lru_to_non_lru(table); } } diff -Nru mariadb-10.1-10.1.41/storage/xtradb/fts/fts0config.cc mariadb-10.1-10.1.43/storage/xtradb/fts/fts0config.cc --- mariadb-10.1-10.1.41/storage/xtradb/fts/fts0config.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/fts/fts0config.cc 2019-11-06 06:20:37.000000000 +0000 @@ -224,8 +224,7 @@ pars_info_bind_varchar_literal(info, "value", value->f_str, value->f_len); - const bool dict_locked = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + const bool dict_locked = fts_table->table->fts->dict_locked; fts_table->suffix = "CONFIG"; fts_get_table_name(fts_table, table_name, dict_locked); diff -Nru mariadb-10.1-10.1.41/storage/xtradb/fts/fts0fts.cc mariadb-10.1-10.1.43/storage/xtradb/fts/fts0fts.cc --- mariadb-10.1-10.1.41/storage/xtradb/fts/fts0fts.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/fts/fts0fts.cc 2019-11-06 06:20:37.000000000 +0000 @@ -458,7 +458,7 @@ dberr_t error = DB_SUCCESS; ibool ret = TRUE; trx_t* trx; - ibool has_lock = fts->fts_status & TABLE_DICT_LOCKED; + ibool has_lock = fts->dict_locked; trx = trx_allocate_for_background(); trx->op_info = "Load user stopword table into FTS cache"; @@ -933,18 +933,16 @@ const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ que_t* graph) /*!< in: query graph */ { - ibool has_dict = FALSE; + bool has_dict = FALSE; if (fts_table && fts_table->table) { ut_ad(fts_table->table->fts); - has_dict = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + has_dict = fts_table->table->fts->dict_locked; } else if (index_cache) { ut_ad(index_cache->index->table->fts); - has_dict = index_cache->index->table->fts->fts_status - & TABLE_DICT_LOCKED; + has_dict = index_cache->index->table->fts->dict_locked; } if (!has_dict) { @@ -2741,6 +2739,10 @@ } if (read_only) { + /* InnoDB stores actual synced_doc_id value + 1 in + FTS_CONFIG table. Reduce the value by 1 while reading + after startup. */ + if (*doc_id) *doc_id -= 1; goto func_exit; } @@ -2831,7 +2833,7 @@ pars_info_bind_varchar_literal(info, "doc_id", id, id_len); fts_get_table_name(&fts_table, fts_name, - table->fts->fts_status & TABLE_DICT_LOCKED); + table->fts->dict_locked); pars_info_bind_id(info, true, "table_name", fts_name); graph = fts_parse_sql( @@ -2947,7 +2949,7 @@ into cache from last crash (delete Doc will not initialize the sync). Avoid any added counter accounting until the FTS cache is re-established and sync-ed */ - if (table->fts->fts_status & ADDED_TABLE_SYNCED + if (table->fts->added_synced && doc_id > cache->synced_doc_id) { mutex_enter(&table->fts->cache->deleted_lock); @@ -3385,7 +3387,7 @@ /* If Doc ID has been supplied by the user, then the table might not yet be sync-ed */ - if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!ftt->table->fts->added_synced) { fts_init_index(ftt->table, FALSE); } @@ -4933,7 +4935,7 @@ fts_init_index((dict_table_t*) table, TRUE); } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; table->fts->cache->first_doc_id = max_doc_id; @@ -5387,69 +5389,6 @@ } /*********************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -UNIV_INTERN -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait) /*!< in: time in microseconds, if - set to 0 then it disables - timeout checking */ -{ - ulint count = 0; - ibool done = FALSE; - - ut_a(max_wait == 0 || max_wait >= FTS_MAX_BACKGROUND_THREAD_WAIT); - - for (;;) { - fts_t* fts = table->fts; - - mutex_enter(&fts->bg_threads_mutex); - - if (fts->fts_status & BG_THREAD_READY) { - - done = TRUE; - } - - mutex_exit(&fts->bg_threads_mutex); - - if (!done) { - os_thread_sleep(FTS_MAX_BACKGROUND_THREAD_WAIT); - - if (max_wait > 0) { - - max_wait -= FTS_MAX_BACKGROUND_THREAD_WAIT; - - /* We ignore the residual value. */ - if (max_wait < FTS_MAX_BACKGROUND_THREAD_WAIT) { - break; - } - } - - ++count; - } else { - break; - } - - if (count >= FTS_BACKGROUND_THREAD_WAIT_COUNT) { - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: Error the background thread " - "for the FTS table %s refuses to start\n", - table->name); - - count = 0; - } - } - - return(done); -} - -/*********************************************************************//** Add the FTS document id hidden column. */ UNIV_INTERN void @@ -5590,42 +5529,6 @@ } /*********************************************************************//** -Signal FTS threads to initiate shutdown. */ -UNIV_INTERN -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance that needs - to be informed about shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - fts->fts_status |= BG_THREAD_STOP; - - mutex_exit(&fts->bg_threads_mutex); - -} - -/*********************************************************************//** -Wait for FTS threads to shutdown. */ -UNIV_INTERN -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance to shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - ut_a(fts->fts_status & BG_THREAD_STOP); - - dict_table_wait_for_bg_threads_to_exit(table, 20000); - - mutex_exit(&fts->bg_threads_mutex); -} - -/*********************************************************************//** Take a FTS savepoint. */ UNIV_INLINE void @@ -7639,7 +7542,7 @@ } rw_lock_x_unlock(&cache->init_lock); - if (table->fts->fts_status & ADDED_TABLE_SYNCED) { + if (table->fts->added_synced) { goto func_exit; } @@ -7681,7 +7584,7 @@ } } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; fts_get_docs_clear(cache->get_docs); diff -Nru mariadb-10.1-10.1.41/storage/xtradb/fts/fts0opt.cc mariadb-10.1-10.1.43/storage/xtradb/fts/fts0opt.cc --- mariadb-10.1-10.1.41/storage/xtradb/fts/fts0opt.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/fts/fts0opt.cc 2019-11-06 06:20:37.000000000 +0000 @@ -34,6 +34,7 @@ #include "ut0wqueue.h" #include "srv0start.h" #include "zlib.h" +#include "fts0opt.h" #ifndef UNIV_NONINL #include "fts0types.ic" @@ -41,7 +42,7 @@ #endif /** The FTS optimize thread's work queue. */ -static ib_wqueue_t* fts_optimize_wq; +ib_wqueue_t* fts_optimize_wq; /** The FTS vector to store fts_slot_t */ static ib_vector_t* fts_slots; @@ -169,8 +170,8 @@ /** We use this information to determine when to start the optimize cycle for a table. */ struct fts_slot_t { - /** table identifier, or 0 if the slot is empty */ - table_id_t table_id; + /** table, or NULL if the slot is unused */ + dict_table_t* table; /** whether this slot is being processed */ bool running; @@ -2456,14 +2457,7 @@ return(DB_SUCCESS); } - dict_table_t* table = dict_table_open_on_id( - slot->table_id, FALSE, DICT_TABLE_OP_NORMAL); - - if (!table) { - slot->last_run = now; - return DB_SUCCESS; - } - + dict_table_t* table = slot->table; dberr_t error; if (fil_table_accessible(table) @@ -2483,8 +2477,6 @@ error = DB_SUCCESS; } - dict_table_close(table, FALSE, FALSE); - return(error); } /*********************************************************************//** @@ -2614,6 +2606,12 @@ return; } + /* If there is no fts index present then don't add to + optimize queue. */ + if (!ib_vector_size(table->fts->indexes)) { + return; + } + /* Make sure table with FTS index cannot be evicted */ if (table->can_be_evicted) { dict_table_move_from_lru_to_non_lru(table); @@ -2621,7 +2619,13 @@ msg = fts_optimize_create_msg(FTS_MSG_ADD_TABLE, table); - ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + mutex_enter(&fts_optimize_wq->mutex); + + ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true); + + table->fts->in_queue = true; + + mutex_exit(&fts_optimize_wq->mutex); } /**********************************************************************//** @@ -2638,7 +2642,7 @@ fts_msg_del_t* remove; /* if the optimize system not yet initialized, return */ - if (!fts_optimize_is_init()) { + if (!fts_optimize_wq) { return; } @@ -2650,6 +2654,13 @@ return; } + mutex_enter(&fts_optimize_wq->mutex); + + if (!table->fts->in_queue) { + mutex_exit(&fts_optimize_wq->mutex); + return; + } + msg = fts_optimize_create_msg(FTS_MSG_DEL_TABLE, NULL); /* We will wait on this event until signalled by the consumer. */ @@ -2662,11 +2673,17 @@ remove->event = event; msg->ptr = remove; - ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true); + + mutex_exit(&fts_optimize_wq->mutex); os_event_wait(event); os_event_free(event); + + ut_d(mutex_enter(&fts_optimize_wq->mutex)); + ut_ad(!table->fts->in_queue); + ut_d(mutex_exit(&fts_optimize_wq->mutex)); } /** Send sync fts cache for the table. @@ -2677,10 +2694,9 @@ dict_table_t* table) { fts_msg_t* msg; - table_id_t* table_id; /* if the optimize system not yet initialized, return */ - if (!fts_optimize_is_init()) { + if (!fts_optimize_wq) { return; } @@ -2692,35 +2708,36 @@ return; } - msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, NULL); + msg = fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, table); - table_id = static_cast( - mem_heap_alloc(msg->heap, sizeof(table_id_t))); - *table_id = table->id; - msg->ptr = table_id; + mutex_enter(&fts_optimize_wq->mutex); - ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true); + + table->fts->in_queue = true; + + mutex_exit(&fts_optimize_wq->mutex); } /** Add a table to fts_slots if it doesn't already exist. */ static bool fts_optimize_new_table(dict_table_t* table) { + ut_ad(table); + ulint i; fts_slot_t* slot; fts_slot_t* empty = NULL; - const table_id_t table_id = table->id; - ut_ad(table_id); /* Search for duplicates, also find a free slot if one exists. */ for (i = 0; i < ib_vector_size(fts_slots); ++i) { slot = static_cast(ib_vector_get(fts_slots, i)); - if (!slot->table_id) { + if (!slot->table) { empty = slot; - } else if (slot->table_id == table_id) { + } else if (slot->table == table) { /* Already exists in our optimize queue. */ - return(FALSE); + return false; } } @@ -2729,37 +2746,36 @@ memset(slot, 0x0, sizeof(*slot)); - slot->table_id = table->id; - slot->running = false; - - return(TRUE); + slot->table = table; + return true; } /** Remove a table from fts_slots if it exists. @param[in,out] table table to be removed from fts_slots */ static bool fts_optimize_del_table(const dict_table_t* table) { - const table_id_t table_id = table->id; - ut_ad(table_id); - for (ulint i = 0; i < ib_vector_size(fts_slots); ++i) { fts_slot_t* slot; slot = static_cast(ib_vector_get(fts_slots, i)); - if (slot->table_id == table_id) { + if (slot->table == table) { if (fts_enable_diag_print) { ib_logf(IB_LOG_LEVEL_INFO, "FTS Optimize Removing table %s", table->name); } - slot->table_id = 0; - return(TRUE); + mutex_enter(&fts_optimize_wq->mutex); + slot->table->fts->in_queue = false; + mutex_exit(&fts_optimize_wq->mutex); + + slot->table = NULL; + return true; } } - return(FALSE); + return false; } /**********************************************************************//** @@ -2773,7 +2789,7 @@ for (ulint i = 0; i < ib_vector_size(fts_slots); ++i) { const fts_slot_t* slot = static_cast( ib_vector_get_const(fts_slots, i)); - if (slot->table_id == 0) { + if (!slot->table) { continue; } @@ -2809,22 +2825,14 @@ const fts_slot_t* slot = static_cast( ib_vector_get_const(fts_slots, i)); - if (slot->table_id == 0) { - continue; - } - - dict_table_t* table = dict_table_open_on_id( - slot->table_id, FALSE, DICT_TABLE_OP_NORMAL); - if (!table) { + if (!slot->table) { continue; } - if (table->fts && table->fts->cache) { - total_memory += table->fts->cache->total_size; + if (slot->table->fts && slot->table->fts->cache) { + total_memory += slot->table->fts->cache->total_size; } - dict_table_close(table, FALSE, FALSE); - if (total_memory > fts_max_total_cache_size) { return(true); } @@ -2834,18 +2842,16 @@ } /** Sync fts cache of a table -@param[in] table_id table id */ -static void fts_optimize_sync_table(table_id_t table_id) +@param[in,out] table table to be synced */ +static void fts_optimize_sync_table(dict_table_t* table) { - if (dict_table_t* table = dict_table_open_on_id( - table_id, FALSE, DICT_TABLE_OP_NORMAL)) { - if (fil_table_accessible(table) - && table->fts && table->fts->cache) { - fts_sync_table(table, true, false, false); - } - - dict_table_close(table, FALSE, FALSE); + if (fil_table_accessible(table) + && table->fts && table->fts->cache) { + fts_sync_table(table, true, false, false); } + + DBUG_EXECUTE_IF("ib_optimize_wq_hang", + os_thread_sleep(6000000);); } /**********************************************************************//** @@ -2887,7 +2893,7 @@ ib_vector_get(fts_slots, current)); /* Handle the case of empty slots. */ - if (slot->table_id) { + if (slot->table) { slot->running = true; fts_optimize_table_bk(slot); } @@ -2947,7 +2953,7 @@ os_thread_sleep(300000);); fts_optimize_sync_table( - *static_cast(msg->ptr)); + static_cast(msg->ptr)); break; default: @@ -2966,8 +2972,8 @@ fts_slot_t* slot = static_cast( ib_vector_get(fts_slots, i)); - if (table_id_t table_id = slot->table_id) { - fts_optimize_sync_table(table_id); + if (slot->table) { + fts_optimize_sync_table(slot->table); } } } @@ -2997,24 +3003,35 @@ ut_ad(!srv_read_only_mode); /* For now we only support one optimize thread. */ - ut_a(!fts_optimize_is_init()); + ut_a(!fts_optimize_wq); fts_optimize_wq = ib_wqueue_create(); ut_a(fts_optimize_wq != NULL); last_check_sync_time = time(NULL); - os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); -} + /* Add fts tables to fts slots which could be skipped + during dict_load_table() because fts_optimize_thread + wasn't even started. */ + mutex_enter(&dict_sys->mutex); -/**********************************************************************//** -Check whether the work queue is initialized. -@return TRUE if optimze queue is initialized. */ -UNIV_INTERN -ibool -fts_optimize_is_init(void) -/*======================*/ -{ - return(fts_optimize_wq != NULL); + for (dict_table_t* table = UT_LIST_GET_FIRST(dict_sys->table_LRU); + table != NULL; + table = UT_LIST_GET_NEXT(table_LRU, table)) { + + if (!table->fts || !dict_table_has_fts_index(table)) { + continue; + } + + /* fts_optimize_thread is not started yet. So there is no + need to acqquire fts_optimize_wq->mutex for adding the fts + table to the fts slots. */ + ut_ad(!table->can_be_evicted); + fts_optimize_new_table(table); + table->fts->in_queue = true; + } + + mutex_exit(&dict_sys->mutex); + os_thread_create(fts_optimize_thread, fts_optimize_wq, NULL); } /**********************************************************************//** diff -Nru mariadb-10.1-10.1.41/storage/xtradb/fts/fts0sql.cc mariadb-10.1-10.1.43/storage/xtradb/fts/fts0sql.cc --- mariadb-10.1-10.1.41/storage/xtradb/fts/fts0sql.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/fts/fts0sql.cc 2019-11-06 06:20:37.000000000 +0000 @@ -165,8 +165,7 @@ str = ut_str3cat(fts_sql_begin, sql, fts_sql_end); dict_locked = (fts_table && fts_table->table->fts - && (fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED)); + && fts_table->table->fts->dict_locked); if (!dict_locked) { ut_ad(!mutex_own(&(dict_sys->mutex))); diff -Nru mariadb-10.1-10.1.41/storage/xtradb/handler/ha_innodb.cc mariadb-10.1-10.1.43/storage/xtradb/handler/ha_innodb.cc --- mariadb-10.1-10.1.41/storage/xtradb/handler/ha_innodb.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/handler/ha_innodb.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. @@ -1949,9 +1949,9 @@ && thd_is_replication_slave_thread(trx->mysql_thd)) { const ulonglong end = my_interval_timer() + ulonglong(srv_replication_delay) * 1000000; - while (srv_conc_get_active_threads() - >= srv_thread_concurrency - || my_interval_timer() >= end) { + while ((srv_conc_get_active_threads() + >= srv_thread_concurrency) + && my_interval_timer() < end) { os_thread_sleep(2000 /* 2 ms */); } } else { @@ -2136,12 +2136,13 @@ ulong thd_flush_log_at_trx_commit( /*================================*/ - void* thd) + THD* thd) { /* THDVAR cannot be used in xtrabackup, plugin variables for innodb are not loaded, this makes xtrabackup crash when trying to use them. */ - return (thd || !IS_XTRABACKUP())? THDVAR((THD*)thd, flush_log_at_trx_commit) : FALSE; + return (thd || !IS_XTRABACKUP()) + ? THDVAR(thd, flush_log_at_trx_commit) : 0; } /********************************************************************//** @@ -2899,11 +2900,10 @@ if (next_value == 0) { ulonglong next; - if (current >= offset) { + if (current > offset) { next = (current - offset) / step; } else { - next = 0; - block -= step; + next = (offset - current) / step; } ut_a(max_value > next); @@ -10640,10 +10640,10 @@ return(NULL); } - if (!(ft_table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!(ft_table->fts->added_synced)) { fts_init_index(ft_table, FALSE); - ft_table->fts->fts_status |= ADDED_TABLE_SYNCED; + ft_table->fts->added_synced = true; } error = fts_query(trx, index, flags, query, query_len, &result); @@ -16656,7 +16656,7 @@ if (increment > 1 && thd_sql_command(user_thd) != SQLCOM_ALTER_TABLE && autoinc < col_max_value) { - ulonglong prev_auto_inc = autoinc; + ulonglong prev_auto_inc = autoinc; autoinc = ((autoinc - 1) + increment - offset)/ increment; @@ -16710,26 +16710,6 @@ current = *first_value; - if (prebuilt->autoinc_increment != increment) { - - WSREP_DEBUG("autoinc decrease: %llu -> %llu\n" - "THD: %ld, current: %llu, autoinc: %llu", - prebuilt->autoinc_increment, - increment, - thd_get_thread_id(ha_thd()), - current, autoinc); - if (!wsrep_on(ha_thd())) - { - current = autoinc - prebuilt->autoinc_increment; - current = innobase_next_autoinc( - current, 1, increment, offset, col_max_value); - } - - dict_table_autoinc_initialize(prebuilt->table, current); - - *first_value = current; - } - /* Compute the last value in the interval */ next_value = innobase_next_autoinc( current, *nb_reserved_values, increment, offset, @@ -18993,7 +18973,7 @@ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, "Failed to set the master thread " - "priority to %lu, " + "priority to %lu, " "the nice is %lu and the current priority is %lu", priority, nice, actual_priority); } @@ -21124,14 +21104,14 @@ "Do not allow to create table without primary key (off by default)", NULL, NULL, FALSE); -const char *corrupt_table_action_names[]= +static const char *corrupt_table_action_names[]= { "assert", /* 0 */ "warn", /* 1 */ "salvage", /* 2 */ NullS }; -TYPELIB corrupt_table_action_typelib= +static TYPELIB corrupt_table_action_typelib= { array_elements(corrupt_table_action_names) - 1, "corrupt_table_action_typelib", corrupt_table_action_names, NULL diff -Nru mariadb-10.1-10.1.41/storage/xtradb/handler/handler0alter.cc mariadb-10.1-10.1.43/storage/xtradb/handler/handler0alter.cc --- mariadb-10.1-10.1.41/storage/xtradb/handler/handler0alter.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/handler/handler0alter.cc 2019-11-06 06:20:37.000000000 +0000 @@ -3252,15 +3252,13 @@ goto error_handling; } - ctx->new_table->fts->fts_status - |= TABLE_DICT_LOCKED; + ctx->new_table->fts->dict_locked = true; error = innobase_fts_load_stopword( ctx->new_table, ctx->trx, ctx->prebuilt->trx->mysql_thd) ? DB_SUCCESS : DB_ERROR; - ctx->new_table->fts->fts_status - &= ~TABLE_DICT_LOCKED; + ctx->new_table->fts->dict_locked = false; if (error != DB_SUCCESS) { goto error_handling; @@ -5642,6 +5640,7 @@ || (index->type & DICT_CORRUPT)); DBUG_ASSERT(index->table->fts); + DEBUG_SYNC_C("norebuild_fts_drop"); fts_drop_index(index->table, index, trx); } diff -Nru mariadb-10.1-10.1.41/storage/xtradb/ibuf/ibuf0ibuf.cc mariadb-10.1-10.1.43/storage/xtradb/ibuf/ibuf0ibuf.cc --- mariadb-10.1-10.1.41/storage/xtradb/ibuf/ibuf0ibuf.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/ibuf/ibuf0ibuf.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -2171,14 +2171,14 @@ buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW); page = buf_block_get_frame(block); + mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST, + MLOG_2BYTES, &mtr); + /* Add the page to the free list and update the ibuf size data */ flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr); - mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST, - MLOG_2BYTES, &mtr); - ibuf->seg_size++; ibuf->free_list_len++; diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/btr0sea.ic mariadb-10.1-10.1.43/storage/xtradb/include/btr0sea.ic --- mariadb-10.1-10.1.41/storage/xtradb/include/btr0sea.ic 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/btr0sea.ic 2019-11-06 06:20:37.000000000 +0000 @@ -104,8 +104,8 @@ /*=================*/ const dict_index_t* index) /*!< in: index */ { - ut_ad(index->search_latch >= btr_search_latch_arr && - index->search_latch < btr_search_latch_arr + + ut_ad(index->search_latch >= btr_search_latch_arr); + ut_ad(index->search_latch < btr_search_latch_arr + btr_search_index_num); return(index->search_latch); diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/buf0flu.h mariadb-10.1-10.1.43/storage/xtradb/include/buf0flu.h --- mariadb-10.1-10.1.41/storage/xtradb/include/buf0flu.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/buf0flu.h 2019-11-06 06:20:37.000000000 +0000 @@ -142,17 +142,6 @@ buf_pool_t* buf_pool, /*!< in: buffer pool instance */ buf_flush_t type); /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ -/******************************************************************//** -Waits until a flush batch of the given type ends. This is called by -a thread that only wants to wait for a flush to end but doesn't do -any flushing itself. */ -UNIV_INTERN -void -buf_flush_wait_batch_end_wait_only( -/*===============================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - buf_flush_t type); /*!< in: BUF_FLUSH_LRU - or BUF_FLUSH_LIST */ /********************************************************************//** This function should be called at a mini-transaction commit, if a page was modified in it. Puts the block to the list of modified blocks, if it not diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/dict0dict.h mariadb-10.1-10.1.43/storage/xtradb/include/dict0dict.h --- mariadb-10.1-10.1.41/storage/xtradb/include/dict0dict.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/dict0dict.h 2019-11-06 06:20:37.000000000 +0000 @@ -1015,18 +1015,6 @@ dtuple_t* tuple, /*!< in/out: data tuple */ const dict_table_t* table) /*!< in: table */ MY_ATTRIBUTE((nonnull)); -/******************************************************************** -Wait until all the background threads of the given table have exited, i.e., -bg_threads == 0. Note: bg_threads_mutex must be reserved when -calling this. */ -UNIV_INTERN -void -dict_table_wait_for_bg_threads_to_exit( -/*===================================*/ - dict_table_t* table, /* in: table */ - ulint delay) /* in: time in microseconds to wait between - checks of bg_threads. */ - MY_ATTRIBUTE((nonnull)); /**********************************************************************//** Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/fts0fts.h mariadb-10.1-10.1.43/storage/xtradb/include/fts0fts.h --- mariadb-10.1-10.1.41/storage/xtradb/include/fts0fts.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/fts0fts.h 2019-11-06 06:20:37.000000000 +0000 @@ -279,40 +279,18 @@ index auxiliary table */ }; -enum fts_status { - BG_THREAD_STOP = 1, /*!< TRUE if the FTS background thread - has finished reading the ADDED table, - meaning more items can be added to - the table. */ - - BG_THREAD_READY = 2, /*!< TRUE if the FTS background thread - is ready */ - - ADD_THREAD_STARTED = 4, /*!< TRUE if the FTS add thread - has started */ - - ADDED_TABLE_SYNCED = 8, /*!< TRUE if the ADDED table record is - sync-ed after crash recovery */ - - TABLE_DICT_LOCKED = 16 /*!< Set if the table has - dict_sys->mutex */ -}; - -typedef enum fts_status fts_status_t; - /** The state of the FTS sub system. */ struct fts_t { /*!< mutex protecting bg_threads* and fts_add_wq. */ ib_mutex_t bg_threads_mutex; - ulint bg_threads; /*!< number of background threads - accessing this table */ - - /*!< TRUE if background threads running - should stop themselves */ - ulint fts_status; /*!< Status bit regarding fts - running state */ + /* Whether the ADDED table record sync-ed afer + crash recovery; protected by bg_threads mutex */ + unsigned added_synced:1; + /* Whether the table hold dict_sys->mutex; + protected by bg_threads mutex */ + unsigned dict_locked:1; ib_wqueue_t* add_wq; /*!< Work queue for scheduling jobs for the FTS 'Add' thread, or NULL @@ -329,6 +307,11 @@ ib_vector_t* indexes; /*!< Vector of FTS indexes, this is mainly for caching purposes. */ + + /* Whether the table was added to fts_optimize_wq(); + protected by fts_optimize_wq mutex */ + bool in_queue; + mem_heap_t* fts_heap; /*!< heap for fts_t allocation */ }; @@ -615,28 +598,6 @@ /*==============*/ /******************************************************************//** -Signal FTS threads to initiate shutdown. */ -UNIV_INTERN -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS - indexes */ - fts_t* fts); /*!< in: fts instance to - shutdown */ - -/******************************************************************//** -Wait for FTS threads to shutdown. */ -UNIV_INTERN -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS - indexes */ - fts_t* fts); /*!< in: fts instance to - shutdown */ - -/******************************************************************//** Create an instance of fts_t. @return instance of fts_t */ UNIV_INTERN @@ -672,14 +633,6 @@ fts_optimize_init(void); /*====================*/ -/**********************************************************************//** -Check whether the work queue is initialized. -@return TRUE if optimze queue is initialized. */ -UNIV_INTERN -ibool -fts_optimize_is_init(void); -/*======================*/ - /****************************************************************//** Drops index ancillary tables for a FTS index @return DB_SUCCESS or error code */ diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/fts0opt.h mariadb-10.1-10.1.43/storage/xtradb/include/fts0opt.h --- mariadb-10.1-10.1.41/storage/xtradb/include/fts0opt.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/fts0opt.h 2019-11-06 06:20:37.000000000 +0000 @@ -25,6 +25,9 @@ #ifndef INNODB_FTS0OPT_H #define INNODB_FTS0OPT_H +/** The FTS optimize thread's work queue. */ +extern ib_wqueue_t* fts_optimize_wq; + /******************************************************************** Callback function to fetch the rows in an FTS INDEX record. */ UNIV_INTERN diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/fts0priv.h mariadb-10.1-10.1.43/storage/xtradb/include/fts0priv.h --- mariadb-10.1-10.1.41/storage/xtradb/include/fts0priv.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/fts0priv.h 2019-11-06 06:20:37.000000000 +0000 @@ -521,20 +521,6 @@ const fts_cache_t* cache, /*!< in: cache to use */ ib_vector_t* vector); /*!< in: append to this vector */ -/******************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -UNIV_INTERN -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait); /*!< in: time in microseconds, if set - to 0 then it disables timeout - checking */ #ifdef FTS_DOC_STATS_DEBUG /******************************************************************//** Get the total number of words in the FTS for a particular FTS index. diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/ha_prototypes.h mariadb-10.1-10.1.43/storage/xtradb/include/ha_prototypes.h --- mariadb-10.1-10.1.41/storage/xtradb/include/ha_prototypes.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/ha_prototypes.h 2019-11-06 06:20:37.000000000 +0000 @@ -418,7 +418,7 @@ ulong thd_flush_log_at_trx_commit( /*================================*/ - void* thd); + THD* thd); /**********************************************************************//** Get the current setting of the lower_case_table_names global parameter from diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/sync0rw.ic mariadb-10.1-10.1.43/storage/xtradb/include/sync0rw.ic --- mariadb-10.1-10.1.41/storage/xtradb/include/sync0rw.ic 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/sync0rw.ic 2019-11-06 06:20:37.000000000 +0000 @@ -453,7 +453,8 @@ return(false); } - ut_ad(priority_lock && !high_priority); + ut_ad(priority_lock); + ut_ad(!high_priority); prio_rw_lock_t *prio_rw_lock = (prio_rw_lock_t *) lock; return prio_rw_lock->high_priority_wait_ex_waiter > 0 diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/univ.i mariadb-10.1-10.1.43/storage/xtradb/include/univ.i --- mariadb-10.1-10.1.41/storage/xtradb/include/univ.i 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/univ.i 2019-11-06 06:20:37.000000000 +0000 @@ -45,10 +45,10 @@ #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 44 +#define INNODB_VERSION_BUGFIX 45 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 86.0 +#define PERCONA_INNODB_VERSION 86.1 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/ut0ut.h mariadb-10.1-10.1.43/storage/xtradb/include/ut0ut.h --- mariadb-10.1-10.1.41/storage/xtradb/include/ut0ut.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/ut0ut.h 2019-11-06 06:20:37.000000000 +0000 @@ -83,7 +83,7 @@ the YieldProcessor macro defined in WinNT.h. It is a CPU architecture- independent way by using YieldProcessor. */ # define UT_RELAX_CPU() YieldProcessor() -# elif defined(__powerpc__) +# elif defined(__powerpc__) && defined __GLIBC__ #include # define UT_RELAX_CPU() __ppc_get_timebase() # else diff -Nru mariadb-10.1-10.1.41/storage/xtradb/include/ut0wqueue.h mariadb-10.1-10.1.43/storage/xtradb/include/ut0wqueue.h --- mariadb-10.1-10.1.41/storage/xtradb/include/ut0wqueue.h 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/include/ut0wqueue.h 2019-11-06 06:20:37.000000000 +0000 @@ -56,16 +56,15 @@ /*===========*/ ib_wqueue_t* wq); /*!< in: work queue */ -/****************************************************************//** -Add a work item to the queue. */ +/** Add a work item to the queue. +@param[in,out] wq work queue +@param[in] item work item +@param[in,out] heap memory heap to use for allocating list node +@param[in] wq_locked work queue mutex locked */ UNIV_INTERN void -ib_wqueue_add( -/*==========*/ - ib_wqueue_t* wq, /*!< in: work queue */ - void* item, /*!< in: work item */ - mem_heap_t* heap); /*!< in: memory heap to use for allocating the - list node */ +ib_wqueue_add(ib_wqueue_t* wq, void* item, mem_heap_t* heap, + bool wq_locked = false); /** Check if queue is empty. @param wq wait queue @@ -99,7 +98,6 @@ /*=============*/ ib_wqueue_t* wq); /*type == OS_FILE_TYPE_FILE || file_info->type == OS_FILE_TYPE_LINK) - && (sscanf(file_info->name, "%[a-z_]%lu_%llu.xdb", stem, - bitmap_file_seq_num, - (unsigned long long *)bitmap_file_start_lsn) == 3) + && (sscanf(file_info->name, "%[a-z_]%lu_" LSN_PF ".xdb", stem, + bitmap_file_seq_num, bitmap_file_start_lsn) == 3) && (!strcmp(stem, bmp_file_name_stem))); } diff -Nru mariadb-10.1-10.1.41/storage/xtradb/row/row0mysql.cc mariadb-10.1-10.1.43/storage/xtradb/row/row0mysql.cc --- mariadb-10.1-10.1.41/storage/xtradb/row/row0mysql.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/row/row0mysql.cc 2019-11-06 06:20:37.000000000 +0000 @@ -3839,11 +3839,11 @@ DBUG_EXECUTE_IF("ib_trunc_sleep_before_fts_cache_clear", os_thread_sleep(10000000);); - table->fts->fts_status |= TABLE_DICT_LOCKED; + table->fts->dict_locked = true; fts_update_next_doc_id(trx, table, 0); fts_cache_clear(table->fts->cache); fts_cache_init(table->fts->cache); - table->fts->fts_status &= ~TABLE_DICT_LOCKED; + table->fts->dict_locked = false; } } @@ -4444,8 +4444,7 @@ /* Need to set TABLE_DICT_LOCKED bit, since fts_que_graph_free_check_lock would try to acquire dict mutex lock */ - table->fts->fts_status |= TABLE_DICT_LOCKED; - + table->fts->dict_locked = true; fts_free(table); } diff -Nru mariadb-10.1-10.1.41/storage/xtradb/trx/trx0trx.cc mariadb-10.1-10.1.43/storage/xtradb/trx/trx0trx.cc --- mariadb-10.1-10.1.41/storage/xtradb/trx/trx0trx.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/trx/trx0trx.cc 2019-11-06 06:20:37.000000000 +0000 @@ -1269,27 +1269,16 @@ { fts_t* fts = ftt->table->fts; fts_doc_ids_t* doc_ids = ftt->added_doc_ids; + mem_heap_t* heap; - mutex_enter(&fts->bg_threads_mutex); + ut_a(fts->add_wq); - if (fts->fts_status & BG_THREAD_STOP) { - /* The table is about to be dropped, no use - adding anything to its work queue. */ + heap = static_cast(doc_ids->self_heap->arg); - mutex_exit(&fts->bg_threads_mutex); - } else { - mem_heap_t* heap; - mutex_exit(&fts->bg_threads_mutex); + ib_wqueue_add(fts->add_wq, doc_ids, heap); - ut_a(fts->add_wq); - - heap = static_cast(doc_ids->self_heap->arg); - - ib_wqueue_add(fts->add_wq, doc_ids, heap); - - /* fts_trx_table_t no longer owns the list. */ - ftt->added_doc_ids = NULL; - } + /* fts_trx_table_t no longer owns the list. */ + ftt->added_doc_ids = NULL; } /******************************************************************//** diff -Nru mariadb-10.1-10.1.41/storage/xtradb/ut/ut0ut.cc mariadb-10.1-10.1.43/storage/xtradb/ut/ut0ut.cc --- mariadb-10.1-10.1.41/storage/xtradb/ut/ut0ut.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/ut/ut0ut.cc 2019-11-06 06:20:37.000000000 +0000 @@ -40,7 +40,6 @@ #include #ifndef UNIV_HOTBACKUP -# include "btr0types.h" # include "trx0trx.h" # include "ha_prototypes.h" # include "mysql_com.h" /* NAME_LEN */ diff -Nru mariadb-10.1-10.1.41/storage/xtradb/ut/ut0wqueue.cc mariadb-10.1-10.1.43/storage/xtradb/ut/ut0wqueue.cc --- mariadb-10.1-10.1.41/storage/xtradb/ut/ut0wqueue.cc 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/storage/xtradb/ut/ut0wqueue.cc 2019-11-06 06:20:37.000000000 +0000 @@ -61,23 +61,25 @@ mem_free(wq); } -/****************************************************************//** -Add a work item to the queue. */ +/** Add a work item to the queue. +@param[in,out] wq work queue +@param[in] item work item +@param[in,out] heap memory heap to use for allocating list node +@param[in] wq_locked work queue mutex locked */ UNIV_INTERN void -ib_wqueue_add( -/*==========*/ - ib_wqueue_t* wq, /*!< in: work queue */ - void* item, /*!< in: work item */ - mem_heap_t* heap) /*!< in: memory heap to use for allocating the - list node */ +ib_wqueue_add(ib_wqueue_t* wq, void* item, mem_heap_t* heap, bool wq_locked) { - mutex_enter(&wq->mutex); + if (!wq_locked) { + mutex_enter(&wq->mutex); + } ib_list_add_last(wq->items, item, heap); os_event_set(wq->event); - mutex_exit(&wq->mutex); + if (!wq_locked) { + mutex_exit(&wq->mutex); + } } /****************************************************************//** diff -Nru mariadb-10.1-10.1.41/strings/ctype-simple.c mariadb-10.1-10.1.43/strings/ctype-simple.c --- mariadb-10.1-10.1.41/strings/ctype-simple.c 2019-07-26 16:34:56.000000000 +0000 +++ mariadb-10.1-10.1.43/strings/ctype-simple.c 2019-11-06 06:20:37.000000000 +0000 @@ -1,5 +1,5 @@ /* Copyright (c) 2002, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. + Copyright (c) 2009, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1622,10 +1622,20 @@ goto ret_sign; } } - for (exponent= 0 ; - str < end && (ch= (uchar) (*str - '0')) < 10; - str++) + if (shift > 0 && !negative_exp) + goto ret_too_big; + for (exponent= 0 ; str < end && (ch= (uchar) (*str - '0')) < 10; str++) { + if (negative_exp) + { + if (exponent - shift > DIGITS_IN_ULONGLONG) + goto ret_zero; + } + else + { + if (exponent + shift > DIGITS_IN_ULONGLONG) + goto ret_too_big; + } exponent= exponent * 10 + ch; } shift+= negative_exp ? -exponent : exponent; diff -Nru mariadb-10.1-10.1.41/support-files/CMakeLists.txt mariadb-10.1-10.1.43/support-files/CMakeLists.txt --- mariadb-10.1-10.1.41/support-files/CMakeLists.txt 2019-07-26 16:34:57.000000000 +0000 +++ mariadb-10.1-10.1.43/support-files/CMakeLists.txt 2019-11-06 06:20:37.000000000 +0000 @@ -77,11 +77,12 @@ IF(CHECKMODULE AND SEMODULE_PACKAGE) FOREACH(pol mariadb) SET(src ${CMAKE_CURRENT_SOURCE_DIR}/policy/selinux/${pol}.te) - SET(tmp ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${pol}-pp.dir/${pol}.mod) + SET(tmp ${CMAKE_CURRENT_BINARY_DIR}/${pol}.mod) SET(out ${CMAKE_CURRENT_BINARY_DIR}/${pol}.pp) ADD_CUSTOM_COMMAND(OUTPUT ${out} COMMAND ${CHECKMODULE} -M -m ${src} -o ${tmp} COMMAND ${SEMODULE_PACKAGE} -m ${tmp} -o ${out} + COMMAND ${CMAKE_COMMAND} -E remove ${tmp} DEPENDS ${src}) ADD_CUSTOM_TARGET(${pol}-pp ALL DEPENDS ${out}) INSTALL(FILES ${out} DESTINATION ${inst_location}/policy/selinux COMPONENT SupportFiles) diff -Nru mariadb-10.1-10.1.41/support-files/mariadb@.service.in mariadb-10.1-10.1.43/support-files/mariadb@.service.in --- mariadb-10.1-10.1.41/support-files/mariadb@.service.in 2019-07-26 16:34:57.000000000 +0000 +++ mariadb-10.1-10.1.43/support-files/mariadb@.service.in 2019-11-06 06:20:37.000000000 +0000 @@ -18,7 +18,7 @@ # Inspired from https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mysql-init-scripts/files/mysqld_at.service [Unit] -Description=MariaDB @VERSION@ database server (multi-instance) +Description=MariaDB @VERSION@ database server (multi-instance %I) Documentation=man:mysqld(8) Documentation=https://mariadb.com/kb/en/library/systemd/ After=network.target diff -Nru mariadb-10.1-10.1.41/support-files/mysql-log-rotate.sh mariadb-10.1-10.1.43/support-files/mysql-log-rotate.sh --- mariadb-10.1-10.1.41/support-files/mysql-log-rotate.sh 2019-07-26 16:34:57.000000000 +0000 +++ mariadb-10.1-10.1.43/support-files/mysql-log-rotate.sh 2019-11-06 06:20:37.000000000 +0000 @@ -1,9 +1,9 @@ # This logname can be set in /etc/my.cnf -# by setting the variable "err-log" -# in the [safe_mysqld] section as follows: +# by setting the variable "log-error" +# in the [mysqld] section as follows: # -# [safe_mysqld] -# err-log=@localstatedir@/mysqld.log +# [mysqld] +# log-error=@localstatedir@/mysqld.log # # If the root user has a password you have to create a # /root/.my.cnf configuration file with the following @@ -21,7 +21,7 @@ @localstatedir@/mysqld.log { # create 600 mysql mysql notifempty - daily + daily rotate 3 missingok compress diff -Nru mariadb-10.1-10.1.41/support-files/rpm/server-postin.sh mariadb-10.1-10.1.43/support-files/rpm/server-postin.sh --- mariadb-10.1-10.1.41/support-files/rpm/server-postin.sh 2019-07-26 16:34:57.000000000 +0000 +++ mariadb-10.1-10.1.43/support-files/rpm/server-postin.sh 2019-11-06 06:20:37.000000000 +0000 @@ -16,7 +16,8 @@ # Make MySQL start/shutdown automatically when the machine does it. if [ $1 = 1 ] ; then if [ -x /usr/bin/systemctl ] ; then - /usr/bin/systemctl daemon-reload >/dev/null 2>&1 + /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : + /usr/bin/systemctl preset mariadb.service >/dev/null 2>&1 || : elif [ -x /sbin/chkconfig ] ; then /sbin/chkconfig --add mysql fi diff -Nru mariadb-10.1-10.1.41/support-files/rpm/server-preun.sh mariadb-10.1-10.1.43/support-files/rpm/server-preun.sh --- mariadb-10.1-10.1.41/support-files/rpm/server-preun.sh 2019-07-26 16:34:57.000000000 +0000 +++ mariadb-10.1-10.1.43/support-files/rpm/server-preun.sh 2019-11-06 06:20:37.000000000 +0000 @@ -9,7 +9,7 @@ %{_sysconfdir}/init.d/mysql stop > /dev/null fi if [ -x /sbin/chkconfig ] ; then - /sbin/chkconfig --del mysql > /dev/null 2>&1 + /sbin/chkconfig --del mysql > /dev/null 2>&1 || : fi fi diff -Nru mariadb-10.1-10.1.41/VERSION mariadb-10.1-10.1.43/VERSION --- mariadb-10.1-10.1.41/VERSION 2019-07-26 16:34:49.000000000 +0000 +++ mariadb-10.1-10.1.43/VERSION 2019-11-06 06:20:35.000000000 +0000 @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=1 -MYSQL_VERSION_PATCH=41 +MYSQL_VERSION_PATCH=43