summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-05-30 11:04:27 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-05-30 11:04:27 +0300
commit6da14d7b4a935466de55a6aa87db14bc359dbd30 (patch)
treea2d1a73a6bf6bbe0dab2857fd87fa782969412f4
parent4783494a5e21939424ecca92bf23d2df65528266 (diff)
parent2e1d10ecacc8ccfc0bda8a199c741ee36df981be (diff)
downloadmariadb-git-6da14d7b4a935466de55a6aa87db14bc359dbd30.tar.gz
Merge 10.3 into 10.4
-rw-r--r--cmake/build_configurations/mysql_release.cmake3
-rw-r--r--cmake/cpack_source_ignore_files.cmake1
-rw-r--r--cmake/submodules.cmake4
-rw-r--r--include/ilist.h (renamed from include/intrusive_list.h)99
m---------libmariadb0
-rw-r--r--mysql-test/lib/mtr_report.pm60
-rw-r--r--mysql-test/main/comment_table.result5
-rw-r--r--mysql-test/main/comment_table.test11
-rw-r--r--mysql-test/main/partition_alter.result53
-rw-r--r--mysql-test/main/partition_alter.test54
-rw-r--r--mysql-test/main/processlist_notembedded.result3
-rw-r--r--mysql-test/main/processlist_notembedded.test3
-rw-r--r--mysql-test/main/repair.result21
-rw-r--r--mysql-test/main/repair.test21
-rw-r--r--mysql-test/main/selectivity.result15
-rw-r--r--mysql-test/main/selectivity.test12
-rw-r--r--mysql-test/main/selectivity_innodb.result15
-rwxr-xr-xmysql-test/mysql-test-run.pl50
-rw-r--r--mysql-test/suite/maria/bulk_insert_crash.opt2
-rw-r--r--mysql-test/suite/maria/bulk_insert_crash.result13
-rw-r--r--mysql-test/suite/maria/bulk_insert_crash.test36
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result291
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test465
-rw-r--r--mysql-test/suite/vcol/r/vcol_keys_myisam.result9
-rw-r--r--mysql-test/suite/vcol/t/vcol_keys_myisam.test11
-rw-r--r--mysql-test/suite/versioning/r/partition.result25
-rw-r--r--mysql-test/suite/versioning/r/partition_innodb.result13
-rw-r--r--mysql-test/suite/versioning/r/select.result3
-rw-r--r--mysql-test/suite/versioning/r/select2.result3
-rw-r--r--mysql-test/suite/versioning/t/partition.test35
-rw-r--r--mysql-test/suite/versioning/t/partition_innodb.test13
-rw-r--r--mysql-test/suite/versioning/t/select.test1
-rw-r--r--mysql-test/suite/versioning/t/select2.test1
-rw-r--r--mysys/my_bitmap.c56
-rw-r--r--sql/ha_partition.cc17
-rw-r--r--sql/handler.cc13
-rw-r--r--sql/handler.h8
-rw-r--r--sql/mysqld.cc1
-rw-r--r--sql/opt_range.h1
-rw-r--r--sql/opt_range_mrr.cc1
-rw-r--r--sql/rpl_parallel.cc6
-rw-r--r--sql/rpl_rli.cc65
-rw-r--r--sql/rpl_rli.h21
-rw-r--r--sql/slave.cc31
-rw-r--r--sql/sql_class.h5
-rw-r--r--sql/sql_partition.cc48
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_table.cc44
-rw-r--r--sql/table.cc8
-rw-r--r--sql/unireg.cc2
-rw-r--r--storage/innobase/fil/fil0crypt.cc3
-rw-r--r--storage/innobase/fil/fil0fil.cc52
-rw-r--r--storage/innobase/include/dyn0buf.h8
-rw-r--r--storage/innobase/include/fil0fil.h22
-rw-r--r--storage/maria/ma_recovery.c21
-rw-r--r--storage/maria/ma_write.c15
-rw-r--r--storage/mroonga/vendor/groonga/lib/db.c3
-rw-r--r--storage/mroonga/vendor/groonga/lib/grn_tokenizers.h1
-rw-r--r--storage/mroonga/vendor/groonga/lib/tokenizers.c30
-rw-r--r--storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c11
-rw-r--r--storage/myisam/mi_check.c6
-rw-r--r--storage/rocksdb/build_rocksdb.cmake2
-rw-r--r--storage/rocksdb/ha_rocksdb.cc8
-rw-r--r--win/packaging/ca/CustomAction.cpp97
-rw-r--r--win/packaging/create_msi.cmake2
-rw-r--r--win/packaging/custom_ui.wxs183
-rw-r--r--win/packaging/extra.wxs.in2
67 files changed, 1679 insertions, 475 deletions
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake
index 37a6c459260..c522c39571b 100644
--- a/cmake/build_configurations/mysql_release.cmake
+++ b/cmake/build_configurations/mysql_release.cmake
@@ -106,6 +106,7 @@ ELSEIF(DEB)
SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "")
ELSE()
SET(WITH_SSL bundled CACHE STRING "")
+ SET(WITH_PCRE bundled CACHE STRING "")
SET(WITH_ZLIB bundled CACHE STRING "")
SET(WITH_JEMALLOC static CACHE STRING "")
SET(PLUGIN_AUTH_SOCKET STATIC CACHE STRING "")
@@ -141,7 +142,7 @@ IF(UNIX)
RedHat/Fedora/Oracle Linux: yum install libaio-devel
SuSE: zypper install libaio-devel
- If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.
+ If you really do not want it, pass -DIGNORE_AIO_CHECK=ON to cmake.
")
ENDIF()
diff --git a/cmake/cpack_source_ignore_files.cmake b/cmake/cpack_source_ignore_files.cmake
index 5b103501a99..eb1ec191d17 100644
--- a/cmake/cpack_source_ignore_files.cmake
+++ b/cmake/cpack_source_ignore_files.cmake
@@ -15,6 +15,7 @@
SET(CPACK_SOURCE_IGNORE_FILES
\\\\.git/
+\\\\.git$
\\\\.gitignore$
\\\\.gitattributes$
CMakeCache\\\\.txt$
diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake
index c8f7b3cc400..0eae3e1176b 100644
--- a/cmake/submodules.cmake
+++ b/cmake/submodules.cmake
@@ -19,11 +19,11 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
SET(update_result 0)
ELSEIF (cmake_update_submodules MATCHES force)
MESSAGE(STATUS "Updating submodules (forced)")
- EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --force --recursive
+ EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --force --recursive --depth=1
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE update_result)
ELSEIF (cmake_update_submodules MATCHES yes)
- EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive
+ EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive --depth=1
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE update_result)
ELSE()
diff --git a/include/intrusive_list.h b/include/ilist.h
index d745c6c6c62..46e15e9998a 100644
--- a/include/intrusive_list.h
+++ b/include/ilist.h
@@ -21,26 +21,28 @@
#include <cstddef>
#include <iterator>
-namespace intrusive
-{
-
// Derive your class from this struct to insert to a linked list.
-template <class Tag= void> struct list_node
+template <class Tag= void> struct ilist_node
{
- list_node(list_node *next= NULL, list_node *prev= NULL)
- : next(next), prev(prev)
+ ilist_node()
+#ifndef DBUG_OFF
+ :
+ next(NULL), prev(NULL)
+#endif
{
}
- list_node *next;
- list_node *prev;
+ ilist_node(ilist_node *next, ilist_node *prev) : next(next), prev(prev) {}
+
+ ilist_node *next;
+ ilist_node *prev;
};
// Modelled after std::list<T>
-template <class T, class Tag= void> class list
+template <class T, class Tag= void> class ilist
{
public:
- typedef list_node<Tag> ListNode;
+ typedef ilist_node<Tag> ListNode;
class Iterator;
// All containers in C++ should define these types to implement generic
@@ -103,10 +105,10 @@ public:
private:
ListNode *node_;
- friend class list;
+ friend class ilist;
};
- list() : sentinel_(&sentinel_, &sentinel_), size_(0) {}
+ ilist() : sentinel_(&sentinel_, &sentinel_) {}
reference front() { return *begin(); }
reference back() { return *--end(); }
@@ -129,14 +131,18 @@ public:
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return reverse_iterator(begin()); }
- bool empty() const { return size_ == 0; }
- size_type size() const { return size_; }
+ bool empty() const { return sentinel_.next == &sentinel_; }
+
+ // Not implemented because it's O(N)
+ // size_type size() const
+ // {
+ // return static_cast<size_type>(std::distance(begin(), end()));
+ // }
void clear()
{
sentinel_.next= &sentinel_;
sentinel_.prev= &sentinel_;
- size_= 0;
}
iterator insert(iterator pos, reference value)
@@ -150,7 +156,6 @@ public:
static_cast<ListNode &>(value).prev= prev;
static_cast<ListNode &>(value).next= curr;
- ++size_;
return iterator(&value);
}
@@ -162,13 +167,12 @@ public:
prev->next= next;
next->prev= prev;
- // This is not required for list functioning. But maybe it'll prevent bugs
- // and ease debugging.
+#ifndef DBUG_OFF
ListNode *curr= pos.node_;
curr->prev= NULL;
curr->next= NULL;
+#endif
- --size_;
return next;
}
@@ -179,12 +183,63 @@ public:
void pop_front() { erase(begin()); }
// STL version is O(n) but this is O(1) because an element can't be inserted
- // several times in the same intrusive list.
+ // several times in the same ilist.
void remove(reference value) { erase(iterator(&value)); }
private:
ListNode sentinel_;
- size_type size_;
};
-} // namespace intrusive
+// Similar to ilist but also has O(1) size() method.
+template <class T, class Tag= void> class sized_ilist : public ilist<T, Tag>
+{
+ typedef ilist<T, Tag> BASE;
+
+public:
+ // All containers in C++ should define these types to implement generic
+ // container interface.
+ typedef T value_type;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef value_type &reference;
+ typedef const value_type &const_reference;
+ typedef T *pointer;
+ typedef const T *const_pointer;
+ typedef typename BASE::Iterator iterator;
+ typedef const typename BASE::Iterator const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const iterator> const_reverse_iterator;
+
+ sized_ilist() : size_(0) {}
+
+ size_type size() const { return size_; }
+
+ void clear()
+ {
+ BASE::clear();
+ size_= 0;
+ }
+
+ iterator insert(iterator pos, reference value)
+ {
+ ++size_;
+ return BASE::insert(pos, value);
+ }
+
+ iterator erase(iterator pos)
+ {
+ --size_;
+ return BASE::erase(pos);
+ }
+
+ void push_back(reference value) { insert(BASE::end(), value); }
+ void pop_back() { erase(BASE::end()); }
+
+ void push_front(reference value) { insert(BASE::begin(), value); }
+ void pop_front() { erase(BASE::begin()); }
+
+ void remove(reference value) { erase(iterator(&value)); }
+
+private:
+ size_type size_;
+};
diff --git a/libmariadb b/libmariadb
-Subproject cdfecebc9932a0dd5516c10505bfe78d79132e7
+Subproject ce74fd0c4009ed9f4bcbdb4a01e96c823e961dc
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index 766f5e47e95..32250802815 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -37,8 +37,20 @@ use My::Platform;
use POSIX qw[ _exit ];
use IO::Handle qw[ flush ];
use mtr_results;
-
use Term::ANSIColor;
+use English;
+
+my $tot_real_time= 0;
+my $tests_done= 0;
+my $tests_failed= 0;
+
+our $timestamp= 0;
+our $timediff= 0;
+our $name;
+our $verbose;
+our $verbose_restart= 0;
+our $timer= 1;
+our $tests_total;
my %color_map = qw/pass green
retry-pass green
@@ -47,20 +59,39 @@ my %color_map = qw/pass green
disabled bright_black
skipped yellow
reset reset/;
-sub xterm_color {
- if (-t STDOUT and defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
- syswrite STDOUT, color($color_map{$_[0]});
+
+my $set_titlebar;
+my $set_color= sub { };
+
+if (-t STDOUT) {
+ if (IS_WINDOWS) {
+ eval {
+ require Win32::Console;
+ $set_titlebar = sub { &Win32::Console::Title($_[0]);};
+ }
+ } elsif ($ENV{TERM} =~ /xterm/) {
+ $set_titlebar = sub { syswrite STDOUT, "\e]0;$_[0]\a"; };
+ $set_color = sub { syswrite STDOUT, color($color_map{$_[0]}); }
}
}
-my $tot_real_time= 0;
+sub titlebar_stat($) {
-our $timestamp= 0;
-our $timediff= 0;
-our $name;
-our $verbose;
-our $verbose_restart= 0;
-our $timer= 1;
+ sub time_format($) {
+ sprintf '%d:%02d:%02d', $_[0]/3600, ($_[0]/60)%60, $_[0]%60;
+ }
+
+ $tests_done++;
+ $tests_failed++ if $_[0] =~ /fail/;
+ $tests_total++ if $_[0] =~ /retry/;
+
+ my $spent = time - $BASETIME;
+ my $left = $tests_total - $tests_done;
+
+ &$set_titlebar(sprintf "mtr: spent %s on %d tests. %s (%d tests) left, %d failed",
+ time_format($spent), $tests_done,
+ time_format($spent/$tests_done * $left), $left, $tests_failed);
+}
sub report_option {
my ($opt, $value)= @_;
@@ -321,8 +352,6 @@ sub mtr_report_stats ($$$$) {
if ( $timer )
{
- use English;
-
mtr_report("Spent", sprintf("%.3f", $tot_real_time),"of",
time - $BASETIME, "seconds executing testcases");
}
@@ -620,10 +649,11 @@ sub mtr_report (@) {
my @s = split /\[ (\S+) \]/, _name() . "@_\n";
if (@s > 1) {
print $s[0];
- xterm_color($s[1]);
+ &$set_color($s[1]);
print "[ $s[1] ]";
- xterm_color('reset');
+ &$set_color('reset');
print $s[2];
+ titlebar_stat($s[1]) if $set_titlebar;
} else {
print $s[0];
}
diff --git a/mysql-test/main/comment_table.result b/mysql-test/main/comment_table.result
index 99ecb04a362..d0af71b4540 100644
--- a/mysql-test/main/comment_table.result
+++ b/mysql-test/main/comment_table.result
@@ -1,4 +1,3 @@
-DROP TABLE IF EXISTS t1;
create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
@@ -125,3 +124,7 @@ SELECT table_comment,char_length(table_comment) FROM information_schema.tables W
table_comment char_length(table_comment)
SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
column_comment char_length(column_comment)
+set names utf8;
+create table t1 (x int comment 'a’');
+ERROR HY000: Invalid utf8 character string: 'a'
+set names latin1;
diff --git a/mysql-test/main/comment_table.test b/mysql-test/main/comment_table.test
index 2a85fbac571..db8bdf54ba6 100644
--- a/mysql-test/main/comment_table.test
+++ b/mysql-test/main/comment_table.test
@@ -1,6 +1,3 @@
---disable_warnings
-DROP TABLE IF EXISTS t1;
---enable_warnings
#1024 bytes
create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INTEGER COMMENT '012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', c4 INTEGER, c5 INTEGER, c6 INTEGER, c7 INTEGER, INDEX i1 (c1) COMMENT 'i1 comment',INDEX i2(c2)
) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcd';
@@ -53,3 +50,11 @@ create table t1 (c1 VARCHAR(10) NOT NULL COMMENT 'c1 comment', c2 INTEGER,c3 INT
) COMMENT='abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcde';
SELECT table_comment,char_length(table_comment) FROM information_schema.tables WHERE table_name='t1';
SELECT column_comment,char_length(column_comment) FROM information_schema.columns WHERE table_name='t1';
+
+#
+# MDEV-22558 wrong error for invalid utf8 table comment
+#
+set names utf8;
+--error ER_INVALID_CHARACTER_STRING
+create table t1 (x int comment 'a’');
+set names latin1;
diff --git a/mysql-test/main/partition_alter.result b/mysql-test/main/partition_alter.result
index d946f2b8822..997a5cf97fa 100644
--- a/mysql-test/main/partition_alter.result
+++ b/mysql-test/main/partition_alter.result
@@ -122,7 +122,55 @@ t1 CREATE TABLE `t1` (
PARTITION `p02` ENGINE = MyISAM,
PARTITION `p03` ENGINE = MyISAM)
drop table t1;
-create or replace table t1 (x int) partition by hash (x) (partition p1, partition p2);
+#
+# MDEV-19751 Wrong partitioning by KEY() after key dropped
+#
+create or replace table t1 (pk int, x timestamp(6), primary key (pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Inplace for DROP PRIMARY KEY when partitioned by default field list is denied
+alter table t1 drop primary key, drop column x, add primary key (pk), algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+alter table t1 drop primary key, drop column x, add primary key (pk);
+select * from t1 partition (p0);
+pk
+1
+drop table t1;
+create or replace table t1 (pk int not null, x timestamp(6), unique u(pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Same for NOT NULL UNIQUE KEY as this is actually primary key
+alter table t1 drop key u, drop column x, add unique (pk), algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+alter table t1 drop key u, drop column x, add unique (pk);
+select * from t1 partition (p0);
+pk
+1
+drop table t1;
+create or replace table t1 (pk int, x timestamp(6), primary key (pk)) engine innodb
+partition by key(pk) partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Inplace for DROP PRIMARY KEY when partitioned by explicit field list is allowed
+alter table t1 drop primary key, add primary key (pk, x), algorithm=inplace;
+select * from t1 partition (p0);
+pk x
+1 2000-01-01 00:00:00.000000
+drop table t1;
+create or replace table t1 (k int, x timestamp(6), unique key u (x, k)) engine innodb
+partition by key(k) partitions 2;
+insert into t1 (k, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+# Inplace for DROP KEY is allowed
+alter table t1 drop key u, algorithm=inplace;
+select * from t1 partition (p0);
+k x
+1 2000-01-01 00:00:00.000000
+drop table t1;
+# End of 10.2 tests
+#
+# MDEV-14817 Server crashes in prep_alter_part_table()
+# after table lock and multiple add partition
+#
+create table t1 (x int) partition by hash (x) (partition p1, partition p2);
lock table t1 write;
alter table t1 add partition (partition p1);
ERROR HY000: Duplicate partition name p1
@@ -134,7 +182,7 @@ drop table t1;
# ha_partition::update_row or `part_id == m_last_part' in
# ha_partition::delete_row upon UPDATE/DELETE after dropping versioning
#
-create or replace table t1 (pk int, f int, primary key(pk, f)) engine=innodb
+create table t1 (pk int, f int, primary key(pk, f)) engine=innodb
partition by key() partitions 2;
insert into t1 values (1,10),(2,11);
# expected to hit same partition
@@ -152,3 +200,4 @@ pk
2
delete from t1;
drop table t1;
+# End of 10.3 tests
diff --git a/mysql-test/main/partition_alter.test b/mysql-test/main/partition_alter.test
index dbe7802b5fb..804b43dc3c2 100644
--- a/mysql-test/main/partition_alter.test
+++ b/mysql-test/main/partition_alter.test
@@ -113,10 +113,52 @@ alter online table t1 delay_key_write=1;
show create table t1;
drop table t1;
-#
-# MDEV-14817 Server crashes in prep_alter_part_table() after table lock and multiple add partition
-#
-create or replace table t1 (x int) partition by hash (x) (partition p1, partition p2);
+--echo #
+--echo # MDEV-19751 Wrong partitioning by KEY() after key dropped
+--echo #
+create or replace table t1 (pk int, x timestamp(6), primary key (pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Inplace for DROP PRIMARY KEY when partitioned by default field list is denied
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 drop primary key, drop column x, add primary key (pk), algorithm=inplace;
+alter table t1 drop primary key, drop column x, add primary key (pk);
+select * from t1 partition (p0);
+drop table t1;
+
+create or replace table t1 (pk int not null, x timestamp(6), unique u(pk, x)) engine innodb
+partition by key() partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Same for NOT NULL UNIQUE KEY as this is actually primary key
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+alter table t1 drop key u, drop column x, add unique (pk), algorithm=inplace;
+alter table t1 drop key u, drop column x, add unique (pk);
+select * from t1 partition (p0);
+drop table t1;
+
+create or replace table t1 (pk int, x timestamp(6), primary key (pk)) engine innodb
+partition by key(pk) partitions 2;
+insert into t1 (pk, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Inplace for DROP PRIMARY KEY when partitioned by explicit field list is allowed
+alter table t1 drop primary key, add primary key (pk, x), algorithm=inplace;
+select * from t1 partition (p0);
+drop table t1;
+
+create or replace table t1 (k int, x timestamp(6), unique key u (x, k)) engine innodb
+partition by key(k) partitions 2;
+insert into t1 (k, x) values (1, '2000-01-01 00:00'), (2, '2000-01-01 00:01');
+--echo # Inplace for DROP KEY is allowed
+alter table t1 drop key u, algorithm=inplace;
+select * from t1 partition (p0);
+drop table t1;
+
+--echo # End of 10.2 tests
+
+--echo #
+--echo # MDEV-14817 Server crashes in prep_alter_part_table()
+--echo # after table lock and multiple add partition
+--echo #
+create table t1 (x int) partition by hash (x) (partition p1, partition p2);
lock table t1 write;
--error ER_SAME_NAME_PARTITION
alter table t1 add partition (partition p1);
@@ -129,7 +171,7 @@ drop table t1;
--echo # ha_partition::update_row or `part_id == m_last_part' in
--echo # ha_partition::delete_row upon UPDATE/DELETE after dropping versioning
--echo #
-create or replace table t1 (pk int, f int, primary key(pk, f)) engine=innodb
+create table t1 (pk int, f int, primary key(pk, f)) engine=innodb
partition by key() partitions 2;
insert into t1 values (1,10),(2,11);
@@ -142,3 +184,5 @@ select * from t1 partition(p0);
select * from t1 partition(p1);
delete from t1;
drop table t1;
+
+--echo # End of 10.3 tests
diff --git a/mysql-test/main/processlist_notembedded.result b/mysql-test/main/processlist_notembedded.result
index e663c407a1b..b622fdf32b9 100644
--- a/mysql-test/main/processlist_notembedded.result
+++ b/mysql-test/main/processlist_notembedded.result
@@ -8,6 +8,9 @@ connection default;
SET DEBUG_SYNC= 'now WAIT_FOR in_sync';
FOUND 1 /sleep/ in MDEV-20466.text
SET DEBUG_SYNC= 'now SIGNAL go';
+connection con1;
+User
disconnect con1;
+connection default;
SET DEBUG_SYNC = 'RESET';
End of 5.5 tests
diff --git a/mysql-test/main/processlist_notembedded.test b/mysql-test/main/processlist_notembedded.test
index 4979e40a85a..6f269a816fc 100644
--- a/mysql-test/main/processlist_notembedded.test
+++ b/mysql-test/main/processlist_notembedded.test
@@ -30,7 +30,10 @@ remove_file $MYSQLTEST_VARDIR/tmp/MDEV-20466.text;
SET DEBUG_SYNC= 'now SIGNAL go';
+connection con1;
+reap;
disconnect con1;
+connection default;
SET DEBUG_SYNC = 'RESET';
diff --git a/mysql-test/main/repair.result b/mysql-test/main/repair.result
index 93da34b9657..a8d82afc626 100644
--- a/mysql-test/main/repair.result
+++ b/mysql-test/main/repair.result
@@ -233,3 +233,24 @@ i
UNLOCK TABLES;
DROP TABLE t1;
# End of 10.0 tests
+create table t1 (a int, b varchar(200));
+insert t1 select seq, repeat(200, seq) from seq_1_to_30;
+delete from t1 where a % 13 = 0;
+repair table t1 use_frm;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 28
+test.t1 repair status OK
+delete from t1 where a % 11 = 0;
+repair table t1 extended use_frm;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 26
+test.t1 repair status OK
+delete from t1 where a % 7 = 0;
+set myisam_repair_threads = 2;
+repair table t1 use_frm;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 22
+test.t1 repair status OK
+set myisam_repair_threads = default;
+drop table t1;
+# End of 10.2 tests
diff --git a/mysql-test/main/repair.test b/mysql-test/main/repair.test
index 75978ac482b..435eb99683a 100644
--- a/mysql-test/main/repair.test
+++ b/mysql-test/main/repair.test
@@ -1,6 +1,7 @@
#
# Test of repair table
#
+--source include/have_sequence.inc
--source include/default_charset.inc
call mtr.add_suppression("character set is multi-byte");
@@ -246,3 +247,23 @@ UNLOCK TABLES;
DROP TABLE t1;
--echo # End of 10.0 tests
+
+#
+# MDEV-17153 server crash on repair table ... use_frm
+#
+# Note, this test case doesn't crash, but shows spurios warnings
+# unless the bug is fixed
+#
+create table t1 (a int, b varchar(200));
+insert t1 select seq, repeat(200, seq) from seq_1_to_30;
+delete from t1 where a % 13 = 0;
+repair table t1 use_frm;
+delete from t1 where a % 11 = 0;
+repair table t1 extended use_frm;
+delete from t1 where a % 7 = 0;
+set myisam_repair_threads = 2;
+repair table t1 use_frm;
+set myisam_repair_threads = default;
+drop table t1;
+
+--echo # End of 10.2 tests
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index 4366ef6a564..ca6a7ef25c7 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -1866,5 +1866,20 @@ id select_type table type possible_keys key key_len ref rows Extra
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
+#
+# MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next
+#
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
+set optimizer_use_condition_selectivity=4;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT * from t1 WHERE a = 5 and b = 5;
+a b
+5 5
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test
index d0158fb717e..2a0cc823eb4 100644
--- a/mysql-test/main/selectivity.test
+++ b/mysql-test/main/selectivity.test
@@ -1267,6 +1267,18 @@ set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
+--echo #
+--echo # MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next
+--echo #
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
+set optimizer_use_condition_selectivity=4;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+SELECT * from t1 WHERE a = 5 and b = 5;
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
+
--echo # End of 10.1 tests
#
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index 062b2da7b4f..3bf313ae2b3 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -1876,6 +1876,21 @@ id select_type table type possible_keys key key_len ref rows Extra
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
+#
+# MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next
+#
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 SELECT seq, seq from seq_1_to_100;
+set optimizer_use_condition_selectivity=4;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT * from t1 WHERE a = 5 and b = 5;
+a b
+5 5
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 5bf1b667105..495d5b664fb 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -373,32 +373,6 @@ my $opt_stop_keep_alive= $ENV{MTR_STOP_KEEP_ALIVE};
select(STDOUT);
$| = 1; # Automatically flush STDOUT
-my $set_titlebar;
-
-
- BEGIN {
- if (IS_WINDOWS) {
- my $have_win32_console= 0;
- eval {
- require Win32::Console;
- Win32::Console->import();
- $have_win32_console = 1;
- };
- eval 'sub HAVE_WIN32_CONSOLE { $have_win32_console }';
- } else {
- eval 'sub HAVE_WIN32_CONSOLE { 0 }';
- }
-}
-
-if (-t STDOUT) {
- if (IS_WINDOWS and HAVE_WIN32_CONSOLE) {
- $set_titlebar = sub {Win32::Console::Title $_[0];};
- } elsif (defined $ENV{TERM} and $ENV{TERM} =~ /xterm/) {
- $set_titlebar = sub { syswrite STDOUT, "\e];$_[0]\a"; };
- }
-}
-
-
main();
sub main {
@@ -471,7 +445,7 @@ sub main {
}
#######################################################################
- my $num_tests= @$tests;
+ my $num_tests= $mtr_report::tests_total= @$tests;
if ( $opt_parallel eq "auto" ) {
# Try to find a suitable value for number of workers
if (IS_WINDOWS)
@@ -912,8 +886,6 @@ sub run_test_server ($$$) {
delete $next->{reserved};
}
- titlebar_stat(scalar(@$tests)) if $set_titlebar;
-
if ($next) {
# We don't need this any more
delete $next->{criteria};
@@ -6549,23 +6521,3 @@ sub list_options ($) {
exit(1);
}
-
-sub time_format($) {
- sprintf '%d:%02d:%02d', $_[0]/3600, ($_[0]/60)%60, $_[0]%60;
-}
-
-our $num_tests;
-
-sub titlebar_stat {
- my ($left) = @_;
-
- # 2.5 -> best by test
- $num_tests = $left + 2.5 unless $num_tests;
-
- my $done = $num_tests - $left;
- my $spent = time - $^T;
-
- &$set_titlebar(sprintf "mtr: spent %s on %d tests. %s (%d tests) left",
- time_format($spent), $done,
- time_format($spent/$done * $left), $left);
-}
diff --git a/mysql-test/suite/maria/bulk_insert_crash.opt b/mysql-test/suite/maria/bulk_insert_crash.opt
new file mode 100644
index 00000000000..f85a8d9c973
--- /dev/null
+++ b/mysql-test/suite/maria/bulk_insert_crash.opt
@@ -0,0 +1,2 @@
+--skip-stack-trace --skip-core-file
+--default-storage-engine=Aria
diff --git a/mysql-test/suite/maria/bulk_insert_crash.result b/mysql-test/suite/maria/bulk_insert_crash.result
new file mode 100644
index 00000000000..fc28bf325ba
--- /dev/null
+++ b/mysql-test/suite/maria/bulk_insert_crash.result
@@ -0,0 +1,13 @@
+create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1;
+insert into t1 values (1000,1000,1000);
+insert into t1 select seq,seq+100, seq+200 from seq_1_to_10;
+SET GLOBAL debug_dbug="+d,crash_end_bulk_insert";
+REPLACE into t1 select seq+20,seq+95, seq + 300 from seq_1_to_10;
+ERROR HY000: Lost connection to MySQL server during query
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+select sum(a),sum(b),sum(c) from t1;
+sum(a) sum(b) sum(c)
+1055 2055 3055
+drop table t1;
diff --git a/mysql-test/suite/maria/bulk_insert_crash.test b/mysql-test/suite/maria/bulk_insert_crash.test
new file mode 100644
index 00000000000..d9167c3f0d7
--- /dev/null
+++ b/mysql-test/suite/maria/bulk_insert_crash.test
@@ -0,0 +1,36 @@
+--source include/not_embedded.inc
+--source include/not_valgrind.inc
+# Avoid CrashReporter popup on Mac
+--source include/not_crashrep.inc
+# Binary must be compiled with debug for crash to occur
+--source include/have_debug.inc
+--source include/have_sequence.inc
+
+#
+# MDEV-20578 Got error 126 when executing undo undo_key_delete upon Aria crash
+# recovery
+#
+
+# Write file to make mysql-test-run.pl expect crash and restart
+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1;
+insert into t1 values (1000,1000,1000);
+insert into t1 select seq,seq+100, seq+200 from seq_1_to_10;
+
+# Insert into t1 with batch insert where we get a rows replaced after
+# a few sucessful inserts
+
+SET GLOBAL debug_dbug="+d,crash_end_bulk_insert";
+
+--error 2013
+REPLACE into t1 select seq+20,seq+95, seq + 300 from seq_1_to_10;
+
+# Wait until restarted
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
+
+check table t1;
+select sum(a),sum(b),sum(c) from t1;
+drop table t1;
diff --git a/mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result b/mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result
new file mode 100644
index 00000000000..a83a9b61b9f
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_parallel_optimistic_until.result
@@ -0,0 +1,291 @@
+include/master-slave.inc
+[connection master]
+connection slave;
+include/stop_slave.inc
+RESET MASTER;
+RESET SLAVE;
+connection master;
+RESET MASTER;
+CREATE TABLE t1 (a int primary key, b text) ENGINE=InnoDB;
+INSERT INTO t1 SET a=25, b='trx0';
+connection slave;
+include/start_slave.inc
+connection master;
+connection slave;
+include/stop_slave.inc
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=2;
+SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
+SET GLOBAL slave_parallel_mode='optimistic';
+connection slave;
+SET @old_max_relay_log_size = @@global.max_relay_log_size;
+SET @@global.max_relay_log_size=4096;
+connection master;
+BEGIN;
+INSERT INTO t1 SET a=1, b='trx1';
+INSERT INTO t1 SET a=2, b='trx1';
+INSERT INTO t1 SET a=3, b='trx1';
+INSERT INTO t1 SET a=4, b='trx1';
+INSERT INTO t1 SET a=5, b='trx1';
+INSERT INTO t1 SET a=6, b='trx1';
+INSERT INTO t1 SET a=7, b='trx1';
+INSERT INTO t1 SET a=8, b='trx1';
+INSERT INTO t1 SET a=9, b='trx1';
+INSERT INTO t1 SET a=10, b='trx1';
+INSERT INTO t1 SET a=11, b='trx1';
+INSERT INTO t1 SET a=12, b='trx1';
+INSERT INTO t1 SET a=13, b='trx1';
+INSERT INTO t1 SET a=14, b='trx1';
+INSERT INTO t1 SET a=15, b='trx1';
+INSERT INTO t1 SET a=16, b='trx1';
+INSERT INTO t1 SET a=17, b='trx1';
+INSERT INTO t1 SET a=18, b='trx1';
+INSERT INTO t1 SET a=19, b='trx1';
+INSERT INTO t1 SET a=20, b='trx1';
+INSERT INTO t1 SET a=21, b='trx1';
+INSERT INTO t1 SET a=22, b='trx1';
+INSERT INTO t1 SET a=23, b='trx1';
+INSERT INTO t1 SET a=24, b='trx1';
+COMMIT;
+FLUSH LOGS;
+BEGIN;
+UPDATE t1 SET b='trx2_0' WHERE a = 25;
+UPDATE t1 SET b='trx2' WHERE a = 25;
+COMMIT;
+INSERT INTO t1 SET a=26,b='trx3';
+*** case 1 UNTIL inside trx2
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1;
+connection slave;
+SELECT <pos_0> <= <pos_until> AND <pos_until> < <pos_trx2> as "pos_until < trx0 and is within trx2";
+pos_until < trx0 and is within trx2
+1
+CHANGE MASTER TO MASTER_USE_GTID=no;
+START SLAVE UNTIL MASTER_LOG_FILE = 'file_2', MASTER_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2';
+trx2 is committed
+1
+SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3';
+trx3 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 2 UNTIL inside trx2
+connection slave;
+DELETE FROM t1 WHERE a <> 25;
+UPDATE t1 SET b='trx0' WHERE a = 25;
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1;
+connection slave;
+include/stop_slave.inc
+SELECT <pos_0> <= <pos_until> AND <pos_until> < <pos_trx2> as "pos_until >= trx0 and is within trx2";
+pos_until >= trx0 and is within trx2
+1
+CHANGE MASTER TO MASTER_LOG_FILE = 'file_1', MASTER_LOG_POS = <pos_trx0>, MASTER_USE_GTID=no;
+START SLAVE UNTIL MASTER_LOG_FILE = 'file_2', MASTER_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2';
+trx2 is committed
+1
+SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3';
+trx3 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 3 UNTIL inside trx1
+connection slave;
+DELETE FROM t1 WHERE a <> 25;
+UPDATE t1 SET b='trx0' WHERE a = 25;
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1; # block trx1;
+connection slave;
+include/stop_slave.inc
+SELECT <pos_until> < <pos_0> as "pos_until before trx2 start position";
+pos_until before trx2 start position
+1
+CHANGE MASTER TO MASTER_LOG_FILE = 'file_1', MASTER_LOG_POS = <pos_trx0>, MASTER_USE_GTID=no;
+START SLAVE UNTIL MASTER_LOG_FILE = 'file_2', MASTER_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 25-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1';
+trx1 is committed
+1
+SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2';
+trx2 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 4 Relay-log UNTIL inside trx1
+connection slave;
+DELETE FROM t1 WHERE a <> 25;
+UPDATE t1 SET b='trx0' WHERE a = 25;
+connection slave1;
+BEGIN;
+INSERT INTO t1 SET a= 1; # block trx1;
+connection slave;
+include/stop_slave.inc
+CHANGE MASTER TO MASTER_LOG_FILE = 'file_1', MASTER_LOG_POS = <pos_trx0>, MASTER_USE_GTID=no;
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+START SLAVE UNTIL RELAY_LOG_FILE = 'file_2', RELAY_LOG_POS = <pos_until>;
+connection slave1;
+ROLLBACK;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+SELECT count(*) = 25-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1';
+trx1 is committed
+1
+SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2';
+trx2 is not committed
+1
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+*** case 5 Relay-log UNTIL inside a "big" trx that spawns few relay logs
+connection master;
+CREATE TABLE t2 (a TEXT) ENGINE=InnoDB;
+FLUSH LOGS;
+connection slave;
+connection slave;
+include/stop_slave.inc
+connection master;
+BEGIN;
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+INSERT INTO t2 SET a=repeat('a',1024);
+COMMIT;
+INSERT INTO t2 SET a='a';
+connection slave;
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+START SLAVE UNTIL RELAY_LOG_FILE = 'file_2', RELAY_LOG_POS = <pos_until>;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+include/diff_tables.inc [master:t2,slave:t2]
+*** case 6 Relay-log UNTIL inside a small trx inside a sequence of relay logs
+connection slave;
+include/stop_slave.inc
+connection master;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+BEGIN;
+DELETE FROM t2 LIMIT 1;
+COMMIT;
+COMMIT;
+connection slave;
+START SLAVE IO_THREAD;
+include/wait_for_slave_io_to_start.inc
+connection master;
+include/sync_slave_io_with_master.inc
+connection slave;
+START SLAVE UNTIL RELAY_LOG_FILE = 'file_2', RELAY_LOG_POS = <pos_until>;
+Proof 1: Correct stop
+connection slave;
+include/wait_for_slave_sql_to_stop.inc
+Proof 2: Resume works out
+include/start_slave.inc
+connection master;
+connection slave;
+include/diff_tables.inc [master:t2,slave:t2]
+connection slave;
+include/stop_slave.inc
+SET GLOBAL max_relay_log_size=@old_max_relay_log_size;
+SET GLOBAL slave_parallel_mode=@old_parallel_mode;
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+include/start_slave.inc
+connection master;
+DROP TABLE t1, t2;
+connection slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test b/mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test
new file mode 100644
index 00000000000..508213c9075
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_parallel_optimistic_until.test
@@ -0,0 +1,465 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/master-slave.inc
+# Format is restricted because the test expects a specific result of
+# relay-logging that splits a transaction into two different files.
+--source include/have_binlog_format_row.inc
+
+#
+# MDEV-15152 Optimistic parallel slave doesn't cope well with START SLAVE UNTIL
+#
+--connection slave
+--source include/stop_slave.inc
+RESET MASTER;
+RESET SLAVE;
+
+--connection master
+RESET MASTER;
+CREATE TABLE t1 (a int primary key, b text) ENGINE=InnoDB;
+--let $a0 = 25
+--eval INSERT INTO t1 SET a=$a0, b='trx0'
+# Memorize the position for replication restart from it
+--let $pos_trx0 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+--connection slave
+--source include/start_slave.inc
+
+--connection master
+# --connection slave
+--sync_slave_with_master
+--source include/stop_slave.inc
+ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
+SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
+SET GLOBAL slave_parallel_threads=2;
+SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
+SET GLOBAL slave_parallel_mode='optimistic';
+
+# Run the slave in the following modes one by one.
+#
+# 1. the until position is set in the middle of trx2
+# below $pos_trx0 of the last exec position in the first file
+# 2. and above $pos_trx0
+# In either case trx2 must commit before slave stops.
+# 3. the until postion is inside trx1
+# 4. RELAY log until inside trx1
+# 5. RELAY log until inside a "big" trx
+# 6. RELAY log until inside a trx within a sequence of relay logs
+#
+# Execution flaw for Until_Master_Pos cases follows as:
+# create the transaction trx1, trx2
+# logged at the beginning of two subsequent binlog files.
+# Set the until position to at the middle of the 2rd transaction.
+# Engage the optimistic scheduler while having trx1 execution blocked.
+# Lift the block after trx2 has reached waiting its order to commit.
+# *Proof 1*
+# Observe that the slave applier stops at a correct position.
+# In the bug condition it would stop prematurely having the stop position
+# in the first file, therefore trx2 not committed.
+# Specifically, an internal transaction position until makes the applier to run
+# beyond it to commit commit the current transaction.
+# *Proof 2*
+# Observe the following START SLAVE resumes OK.
+#
+# Auxiliary third trx3 on master is just for triggering the actual stop
+# (whihc is a legacy UNTIL's property).
+# trx0 is to produce a specific value of the last executed binlog file:pos
+# to emulate the bug condition.
+#
+# Intermediate checks via SELECT are supposed to succeed
+# with putting out value 1.
+#
+# NOTE: Relay log until tests have to use explicit log names and position
+# which may require to adjust with future changes to event formats etc.
+#
+
+--connection slave
+SET @old_max_relay_log_size = @@global.max_relay_log_size;
+SET @@global.max_relay_log_size=4096;
+
+--connection master
+# trx1
+--let $a=1
+BEGIN;
+while (`SELECT $a < $a0`)
+{
+ --eval INSERT INTO t1 SET a=$a, b='trx1'
+--inc $a
+}
+COMMIT;
+--let $fil_1 = query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_trx1 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+FLUSH LOGS;
+
+# $pos_0 the offset of the first event of trx2 in new file
+--let $pos_0=query_get_value(SHOW MASTER STATUS, Position, 1)
+# trx2
+--let $a=$a0
+BEGIN;
+--eval UPDATE t1 SET b='trx2_0' WHERE a = $a
+--eval UPDATE t1 SET b='trx2' WHERE a = $a
+COMMIT;
+--let $fil_2=query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_trx2=query_get_value(SHOW MASTER STATUS, Position, 1)
+
+# trx3
+--let $a=$a0
+--inc $a
+--eval INSERT INTO t1 SET a=$a,b='trx3'
+--let $pos_trx3=query_get_value(SHOW MASTER STATUS, Position, 1)
+--let $a=
+
+
+--echo *** case 1 UNTIL inside trx2
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1
+--connection slave
+--let $pos_until=`SELECT $pos_trx0 - 1`
+--replace_result $pos_0 <pos_0> $pos_until <pos_until> $pos_trx2 <pos_trx2>
+--eval SELECT $pos_0 <= $pos_until AND $pos_until < $pos_trx2 as "pos_until < trx0 and is within trx2"
+CHANGE MASTER TO MASTER_USE_GTID=no;
+--replace_result $fil_2 file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL MASTER_LOG_FILE = '$fil_2', MASTER_LOG_POS = $pos_until
+
+--let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit"
+--source include/wait_condition.inc
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+if (`SELECT "$file_stop" != "$fil_2" OR $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $fil_2:$pos_until.
+ --die
+}
+--eval SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2'
+--eval SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+--echo *** case 2 UNTIL inside trx2
+
+--connection slave
+--eval DELETE FROM t1 WHERE a <> $a0
+--eval UPDATE t1 SET b='trx0' WHERE a = $a0
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1
+
+--connection slave
+--source include/stop_slave.inc
+
+--let $pos_until=`SELECT $pos_trx2 - 1`
+--replace_result $pos_trx0 <pos_0> $pos_until <pos_until> $pos_trx2 <pos_trx2>
+--eval SELECT $pos_trx0 <= $pos_until AND $pos_until < $pos_trx2 as "pos_until >= trx0 and is within trx2"
+--replace_result $fil_1 file_1 $pos_trx0 <pos_trx0>
+--eval CHANGE MASTER TO MASTER_LOG_FILE = '$fil_1', MASTER_LOG_POS = $pos_trx0, MASTER_USE_GTID=no
+--replace_result $fil_2 file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL MASTER_LOG_FILE = '$fil_2', MASTER_LOG_POS = $pos_until
+
+--let $wait_condition= SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit"
+--source include/wait_condition.inc
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+if (`SELECT "$file_stop" != "$fil_2" OR $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $fil_2:$pos_until.
+ --die
+}
+--eval SELECT count(*) = 1 as 'trx2 is committed' FROM t1 WHERE b = 'trx2'
+--eval SELECT count(*) = 0 as 'trx3 is not committed' FROM t1 WHERE b = 'trx3'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+--echo *** case 3 UNTIL inside trx1
+
+--connection slave
+--eval DELETE FROM t1 WHERE a <> $a0
+--eval UPDATE t1 SET b='trx0' WHERE a = $a0
+
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1; # block trx1
+
+--connection slave
+--source include/stop_slave.inc
+
+--let $pos_until=`SELECT $pos_0 - 1`
+--replace_result $pos_0 <pos_0> $pos_until <pos_until> $pos_trx2 <pos_trx2>
+--eval SELECT $pos_until < $pos_0 as "pos_until before trx2 start position"
+--replace_result $fil_1 file_1 $pos_trx0 <pos_trx0>
+--eval CHANGE MASTER TO MASTER_LOG_FILE = '$fil_1', MASTER_LOG_POS = $pos_trx0, MASTER_USE_GTID=no
+--replace_result $fil_2 file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL MASTER_LOG_FILE = '$fil_2', MASTER_LOG_POS = $pos_until
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+if (`SELECT "$file_stop" != "$fil_2" OR $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $fil_2:$pos_until.
+ --die
+}
+--eval SELECT count(*) = $a0-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1'
+--eval SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+--echo *** case 4 Relay-log UNTIL inside trx1
+
+--connection slave
+--eval DELETE FROM t1 WHERE a <> $a0
+--eval UPDATE t1 SET b='trx0' WHERE a = $a0
+
+--connection slave1
+# Blocker to hold off EXEC_MASTER_LOG_POS advance
+BEGIN;
+ --eval INSERT INTO t1 SET a= 1; # block trx1
+
+--connection slave
+--source include/stop_slave.inc
+--replace_result $fil_1 file_1 $pos_trx0 <pos_trx0>
+--eval CHANGE MASTER TO MASTER_LOG_FILE = '$fil_1', MASTER_LOG_POS = $pos_trx0, MASTER_USE_GTID=no
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+
+# The following test sets the stop coordinate is set to inside the first event
+# of a relay log that holds events of a transaction started in an earlier log.
+# Peek the stop position in the middle of trx1, not even on a event boundary.
+--let $pos_until=255
+--let $file_rl=slave-relay-bin.000003
+--let $binlog_file=$file_rl
+
+--let $pos_xid=508
+--let $info= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_xid LIMIT 1, Info, 1)
+
+if (`SELECT "$info" NOT LIKE "COMMIT /* xid=% */" OR $pos_xid < $pos_until`)
+{
+ --echo *** Unexpected offset. Refine it to point to the correct XID event!
+ --die
+}
+
+--replace_result $file_rl file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL RELAY_LOG_FILE = '$file_rl', RELAY_LOG_POS = $pos_until
+
+--connection slave1
+# unblock to see the slave applier stops at $until
+ROLLBACK;
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+if (`SELECT strcmp("$file_rl","$file_stop") > -1`)
+{
+ --echo *** ERROR: Slave stopped at $file_stop:$pos_stop which is not $file_rl:$pos_until.
+ --die
+}
+
+--eval SELECT count(*) = $a0-1 as 'trx1 is committed' FROM t1 WHERE b = 'trx1'
+--eval SELECT count(*) = 0 as 'trx2 is not committed' FROM t1 WHERE b = 'trx2'
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+
+
+--echo *** case 5 Relay-log UNTIL inside a "big" trx that spawns few relay logs
+
+--connection master
+CREATE TABLE t2 (a TEXT) ENGINE=InnoDB;
+FLUSH LOGS;
+
+--sync_slave_with_master
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+--let $records=`SELECT floor(4*@@global.max_relay_log_size / 1024) + 1`
+
+--connection slave
+--source include/stop_slave.inc
+
+--connection master
+# trx4
+BEGIN;
+--let $i=$records
+while ($i)
+{
+ INSERT INTO t2 SET a=repeat('a',1024);
+
+--dec $i
+}
+COMMIT;
+
+# slave will stop there:
+--let $file_trx4 = query_get_value(SHOW MASTER STATUS, File, 1)
+--let $pos_trx4 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+# trx5
+INSERT INTO t2 SET a='a';
+--let $pos_trx5 = query_get_value(SHOW MASTER STATUS, Position, 1)
+
+--connection slave
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+
+# Set position inside the transaction though the value
+# specified is beyond that relay log file.
+# The coordianate may point to in a different event in future changes
+# but should not move away from inside this big group of events.
+# So we don't test which event in the transaction it points to.
+--let $pos_until= 4500
+--let $file_rl= slave-relay-bin.000010
+
+--replace_result $file_rl file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL RELAY_LOG_FILE = '$file_rl', RELAY_LOG_POS = $pos_until
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
+# It's showed the actual stop occurred before trx5
+if (`SELECT strcmp("$file_trx4", "$file_stop") <> 0 OR $pos_stop >= $pos_trx5 OR count(*) <> $records FROM t2`)
+{
+ --echo *** ERROR: Slave stopped at *binlog* $file_stop:$pos_stop which is not $file_trx4:$pos_trx4.
+ --die
+}
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+--let $diff_tables=master:t2,slave:t2
+--source include/diff_tables.inc
+
+
+
+--echo *** case 6 Relay-log UNTIL inside a small trx inside a sequence of relay logs
+
+--connection slave
+--source include/stop_slave.inc
+
+--connection master
+# trx6
+--let $records=`SELECT count(*) FROM t2`
+while ($records)
+{
+ BEGIN;
+ DELETE FROM t2 LIMIT 1;
+ COMMIT;
+--dec $records
+}
+COMMIT;
+
+--connection slave
+START SLAVE IO_THREAD;
+--source include/wait_for_slave_io_to_start.inc
+
+--connection master
+--source include/sync_slave_io_with_master.inc
+
+--connection slave
+# The relay-log coordinate is not at an event boundary and
+# also may change across the server version.
+# The test makes its best to check its coherance.
+--let $pos_until= 3130
+--let $file_rl= slave-relay-bin.000018
+
+--let $pos_gtid = 2987
+--let $info= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_gtid LIMIT 1, Info, 1)
+
+if (`SELECT "$info" != "BEGIN GTID 0-1-23"`)
+{
+ --echo *** Unexpected offset. Refine it to point to the correct GTID!
+ --die
+}
+--let $pos_event = 3120
+--let $type= query_get_value(SHOW RELAYLOG EVENTS IN '$file_rl' FROM $pos_event LIMIT 1, Event_type, 1)
+if (`SELECT "$type" != "Delete_rows_v1"`)
+{
+ --echo *** Unexpected offset. Refine it to point to the expected event!
+ --die
+}
+
+--replace_result $file_rl file_2 $pos_until <pos_until>
+--eval START SLAVE UNTIL RELAY_LOG_FILE = '$file_rl', RELAY_LOG_POS = $pos_until
+
+--echo Proof 1: Correct stop
+--connection slave
+--source include/wait_for_slave_sql_to_stop.inc
+--let $file_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+--let $pos_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
+if (`SELECT strcmp("$file_stop", "$file_rl") = -1 OR
+ strcmp("$file_stop", "$file_rl") = 0 AND $pos_stop < $pos_until`)
+{
+ --echo *** ERROR: Slave stopped at *relay* $file_stop:$pos_stop which is not $file_rl:$pos_until.
+ --die
+}
+
+--echo Proof 2: Resume works out
+--source include/start_slave.inc
+--connection master
+--sync_slave_with_master
+
+--let $diff_tables=master:t2,slave:t2
+--source include/diff_tables.inc
+
+#
+# Clean up.
+#
+--connection slave
+--source include/stop_slave.inc
+SET GLOBAL max_relay_log_size=@old_max_relay_log_size;
+SET GLOBAL slave_parallel_mode=@old_parallel_mode;
+SET GLOBAL slave_parallel_threads=@old_parallel_threads;
+--source include/start_slave.inc
+
+--connection master
+DROP TABLE t1, t2;
+
+--sync_slave_with_master
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
index 9400127211c..803f7446810 100644
--- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result
@@ -409,3 +409,12 @@ SELECT * FROM t1 WHERE d2 < d1;
i d1 d2 t
1 2023-03-16 2023-03-15 1
DROP TABLE t1;
+#
+# MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field
+#
+create or replace table t1 (a int);
+insert into t1 (a) values (1), (1);
+create or replace table t2 (pk int, b int, c int as (b) virtual, primary key (pk), key(c));
+insert into t2 (pk) select a from t1;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+drop tables t1, t2;
diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
index 86fb8aecbe2..6c3a94d2086 100644
--- a/mysql-test/suite/vcol/t/vcol_keys_myisam.test
+++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test
@@ -300,3 +300,14 @@ DROP TABLE t1;
# Cleanup
--let $datadir= `SELECT @@datadir`
--remove_file $datadir/test/load_t1
+
+
+--echo #
+--echo # MDEV-20015 Assertion `!in_use->is_error()' failed in TABLE::update_virtual_field
+--echo #
+create or replace table t1 (a int);
+insert into t1 (a) values (1), (1);
+create or replace table t2 (pk int, b int, c int as (b) virtual, primary key (pk), key(c));
+--error ER_DUP_ENTRY
+insert into t2 (pk) select a from t1;
+drop tables t1, t2;
diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result
index cba47537e7a..2e66fb2ba9b 100644
--- a/mysql-test/suite/versioning/r/partition.result
+++ b/mysql-test/suite/versioning/r/partition.result
@@ -659,6 +659,30 @@ update t1 set f=pk;
delete from t1;
drop table t1;
#
+# MDEV-22413 Server hangs upon UPDATE/DELETE on a view reading from versioned partitioned table
+#
+create or replace table t1 (f char(6)) engine innodb with system versioning;
+insert into t1 values (null);
+update t1 set f= 'foo';
+update t1 set f= 'bar';
+create or replace view v1 as select * from t1 for system_time all;
+update v1 set f = '';
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+create or replace table t1 (f char(6)) engine innodb with system versioning
+partition by system_time limit 1
+(partition p1 history, partition p2 history, partition pn current);
+insert into t1 values (null);
+update t1 set f= 'foo';
+update t1 set f= 'bar';
+create or replace view v1 as select * from t1 for system_time all;
+update v1 set f= '';
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+delete from v1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+drop view v1;
+drop table t1;
+# End of 10.3 tests
+#
# MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine
#
create table t1 (a int primary key) engine=aria page_checksum=0
@@ -678,3 +702,4 @@ partition by system_time (partition p1 history, partition pn current);
insert into t1 values (1);
replace into t1 values (1);
drop table t1;
+# End of 10.4 tests
diff --git a/mysql-test/suite/versioning/r/partition_innodb.result b/mysql-test/suite/versioning/r/partition_innodb.result
index afed90ffe05..1bc0549a735 100644
--- a/mysql-test/suite/versioning/r/partition_innodb.result
+++ b/mysql-test/suite/versioning/r/partition_innodb.result
@@ -65,3 +65,16 @@ partition by range columns (a, row_start) (
partition p1 values less than (100, 100)
);
ERROR HY000: Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END
+#
+# MDEV-18794 Assertion `!m_innodb' failed in ha_partition::cmp_ref upon SELECT from partitioned table
+#
+create or replace table t1 (pk int auto_increment, i int, c char(1), primary key (pk), key(i))
+engine=innodb with system versioning partition by key() partitions 2;
+insert into t1 (i, c) values (1, 'a'), (2, 'b'), (null, 'c'), (null, 'b');
+alter table t1 drop system versioning;
+replace into t1 select * from t1;
+select * from t1 where i > 0 or pk = 1000 limit 1;
+pk i c
+1 1 a
+drop table t1;
+# End of 10.3 tests
diff --git a/mysql-test/suite/versioning/r/select.result b/mysql-test/suite/versioning/r/select.result
index a969c16bad4..3cecc6dc893 100644
--- a/mysql-test/suite/versioning/r/select.result
+++ b/mysql-test/suite/versioning/r/select.result
@@ -242,8 +242,7 @@ ERROR HY000: Table `t1` is not system-versioned
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
select * from t1 for system_time all for update;
-x
-1
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
a
diff --git a/mysql-test/suite/versioning/r/select2.result b/mysql-test/suite/versioning/r/select2.result
index a2642b319ee..8c9c519c349 100644
--- a/mysql-test/suite/versioning/r/select2.result
+++ b/mysql-test/suite/versioning/r/select2.result
@@ -233,8 +233,7 @@ ERROR HY000: Table `t1` is not system-versioned
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
select * from t1 for system_time as of now() for update;
-x
-1
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
a
diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test
index 271c17ac7dc..5fcd1d6ecfb 100644
--- a/mysql-test/suite/versioning/t/partition.test
+++ b/mysql-test/suite/versioning/t/partition.test
@@ -596,6 +596,39 @@ delete from t1;
drop table t1;
--echo #
+--echo # MDEV-22413 Server hangs upon UPDATE/DELETE on a view reading from versioned partitioned table
+--echo #
+create or replace table t1 (f char(6)) engine innodb with system versioning;
+
+insert into t1 values (null);
+update t1 set f= 'foo';
+update t1 set f= 'bar';
+
+create or replace view v1 as select * from t1 for system_time all;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+update v1 set f = '';
+
+create or replace table t1 (f char(6)) engine innodb with system versioning
+partition by system_time limit 1
+(partition p1 history, partition p2 history, partition pn current);
+
+insert into t1 values (null);
+update t1 set f= 'foo';
+update t1 set f= 'bar';
+
+create or replace view v1 as select * from t1 for system_time all;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+update v1 set f= '';
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+delete from v1;
+
+# cleanup
+drop view v1;
+drop table t1;
+
+--echo # End of 10.3 tests
+
+--echo #
--echo # MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine
--echo #
create table t1 (a int primary key) engine=aria page_checksum=0
@@ -614,4 +647,6 @@ replace into t1 values (1);
# cleanup
drop table t1;
+--echo # End of 10.4 tests
+
--source suite/versioning/common_finish.inc
diff --git a/mysql-test/suite/versioning/t/partition_innodb.test b/mysql-test/suite/versioning/t/partition_innodb.test
index 088a4b81252..e09a684961e 100644
--- a/mysql-test/suite/versioning/t/partition_innodb.test
+++ b/mysql-test/suite/versioning/t/partition_innodb.test
@@ -77,4 +77,17 @@ partition by range columns (a, row_start) (
partition p1 values less than (100, 100)
);
+--echo #
+--echo # MDEV-18794 Assertion `!m_innodb' failed in ha_partition::cmp_ref upon SELECT from partitioned table
+--echo #
+create or replace table t1 (pk int auto_increment, i int, c char(1), primary key (pk), key(i))
+engine=innodb with system versioning partition by key() partitions 2;
+insert into t1 (i, c) values (1, 'a'), (2, 'b'), (null, 'c'), (null, 'b');
+alter table t1 drop system versioning;
+replace into t1 select * from t1;
+select * from t1 where i > 0 or pk = 1000 limit 1;
+drop table t1;
+
+--echo # End of 10.3 tests
+
--source suite/versioning/common_finish.inc
diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test
index a250a60770e..01052d4ae03 100644
--- a/mysql-test/suite/versioning/t/select.test
+++ b/mysql-test/suite/versioning/t/select.test
@@ -149,6 +149,7 @@ select * from t1 for system_time all;
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
select * from t1 for system_time all for update;
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
diff --git a/mysql-test/suite/versioning/t/select2.test b/mysql-test/suite/versioning/t/select2.test
index 75c8165886f..7ede218cabf 100644
--- a/mysql-test/suite/versioning/t/select2.test
+++ b/mysql-test/suite/versioning/t/select2.test
@@ -128,6 +128,7 @@ select * from t1 for system_time all;
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
select * from t1 for system_time as of now() for update;
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 8059b909788..c69eb4748f7 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -247,7 +247,8 @@ my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit)
my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit)
{
my_bool res;
- DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(bitmap_bit < map->n_bits);
bitmap_lock(map);
res= bitmap_fast_test_and_set(map, bitmap_bit);
bitmap_unlock(map);
@@ -280,7 +281,8 @@ my_bool bitmap_fast_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
my_bool bitmap_test_and_clear(MY_BITMAP *map, uint bitmap_bit)
{
my_bool res;
- DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(bitmap_bit < map->n_bits);
bitmap_lock(map);
res= bitmap_fast_test_and_clear(map, bitmap_bit);
bitmap_unlock(map);
@@ -309,8 +311,8 @@ void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size)
uint prefix_bytes, prefix_bits, d;
uchar *m= (uchar *)map->bitmap;
- DBUG_ASSERT(map->bitmap &&
- (prefix_size <= map->n_bits || prefix_size == (uint) ~0));
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(prefix_size <= map->n_bits || prefix_size == (uint) ~0);
set_if_smaller(prefix_size, map->n_bits);
if ((prefix_bytes= prefix_size / 8))
memset(m, 0xff, prefix_bytes);
@@ -332,7 +334,8 @@ my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size)
uchar *m= (uchar*) map->bitmap;
uchar *end_prefix= m+(prefix_size-1)/8;
uchar *end;
- DBUG_ASSERT(m && prefix_size <= map->n_bits);
+ DBUG_ASSERT(m);
+ DBUG_ASSERT(prefix_size <= map->n_bits);
/* Empty prefix is always true */
if (!prefix_size)
@@ -385,8 +388,8 @@ my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2)
{
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
- DBUG_ASSERT(map1->bitmap && map2->bitmap &&
- map1->n_bits==map2->n_bits);
+ DBUG_ASSERT(map1->bitmap && map2->bitmap);
+ DBUG_ASSERT(map1->n_bits==map2->n_bits);
end= map1->last_word_ptr;
while (m1 < end)
@@ -404,8 +407,9 @@ my_bool bitmap_is_overlapping(const MY_BITMAP *map1, const MY_BITMAP *map2)
{
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
- DBUG_ASSERT(map1->bitmap && map2->bitmap &&
- map1->n_bits==map2->n_bits);
+ DBUG_ASSERT(map1->bitmap);
+ DBUG_ASSERT(map2->bitmap);
+ DBUG_ASSERT(map1->n_bits==map2->n_bits);
end= map1->last_word_ptr;
while (m1 < end)
@@ -423,7 +427,8 @@ void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2)
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
uint len= no_words_in_map(map), len2 = no_words_in_map(map2);
- DBUG_ASSERT(map->bitmap && map2->bitmap);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(map2->bitmap);
end= to+MY_MIN(len,len2);
while (to < end)
@@ -468,7 +473,8 @@ my_bool bitmap_exists_intersection(const MY_BITMAP **bitmap_array,
uint i, j, start_idx, end_idx;
my_bitmap_map cur_res;
- DBUG_ASSERT(bitmap_count && end_bit >= start_bit);
+ DBUG_ASSERT(bitmap_count);
+ DBUG_ASSERT(end_bit >= start_bit);
for (j= 0; j < bitmap_count; j++)
DBUG_ASSERT(end_bit < bitmap_array[j]->n_bits);
@@ -496,8 +502,9 @@ my_bool bitmap_union_is_set_all(const MY_BITMAP *map1, const MY_BITMAP *map2)
{
my_bitmap_map *m1= map1->bitmap, *m2= map2->bitmap, *end;
- DBUG_ASSERT(map1->bitmap && map2->bitmap &&
- map1->n_bits==map2->n_bits);
+ DBUG_ASSERT(map1->bitmap);
+ DBUG_ASSERT(map2->bitmap);
+ DBUG_ASSERT(map1->n_bits==map2->n_bits);
end= map1->last_word_ptr;
while ( m1 < end)
if ((*m1++ | *m2++) != 0xFFFFFFFF)
@@ -542,8 +549,9 @@ void bitmap_set_above(MY_BITMAP *map, uint from_byte, uint use_bit)
void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2)
{
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
- DBUG_ASSERT(map->bitmap && map2->bitmap &&
- map->n_bits==map2->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(map2->bitmap);
+ DBUG_ASSERT(map->n_bits==map2->n_bits);
end= map->last_word_ptr;
@@ -556,8 +564,9 @@ void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2)
{
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
- DBUG_ASSERT(map->bitmap && map2->bitmap &&
- map->n_bits==map2->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(map2->bitmap);
+ DBUG_ASSERT(map->n_bits == map2->n_bits);
end= map->last_word_ptr;
while (to <= end)
@@ -568,8 +577,9 @@ void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2)
void bitmap_xor(MY_BITMAP *map, const MY_BITMAP *map2)
{
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end= map->last_word_ptr;
- DBUG_ASSERT(map->bitmap && map2->bitmap &&
- map->n_bits==map2->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(map2->bitmap);
+ DBUG_ASSERT(map->n_bits == map2->n_bits);
while (to <= end)
*to++ ^= *from++;
}
@@ -606,8 +616,9 @@ void bitmap_copy(MY_BITMAP *map, const MY_BITMAP *map2)
{
my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end;
- DBUG_ASSERT(map->bitmap && map2->bitmap &&
- map->n_bits==map2->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(map2->bitmap);
+ DBUG_ASSERT(map->n_bits == map2->n_bits);
end= map->last_word_ptr;
while (to <= end)
@@ -736,7 +747,8 @@ uint bitmap_lock_set_next(MY_BITMAP *map)
void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit)
{
bitmap_lock(map);
- DBUG_ASSERT(map->bitmap && bitmap_bit < map->n_bits);
+ DBUG_ASSERT(map->bitmap);
+ DBUG_ASSERT(bitmap_bit < map->n_bits);
bitmap_clear_bit(map, bitmap_bit);
bitmap_unlock(map);
}
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 6af69fc67b6..b9342a327e2 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -2240,7 +2240,8 @@ void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
sub_elem= subpart_it++;
DBUG_ASSERT(sub_elem);
part= i * num_subparts + j;
- DBUG_ASSERT(part < m_file_tot_parts && m_file[part]);
+ DBUG_ASSERT(part < m_file_tot_parts);
+ DBUG_ASSERT(m_file[part]);
dummy_info.data_file_name= dummy_info.index_file_name = NULL;
m_file[part]->update_create_info(&dummy_info);
sub_elem->data_file_name = (char*) dummy_info.data_file_name;
@@ -3909,7 +3910,8 @@ int ha_partition::external_lock(THD *thd, int lock_type)
MY_BITMAP *used_partitions;
DBUG_ENTER("ha_partition::external_lock");
- DBUG_ASSERT(!auto_increment_lock && !auto_increment_safe_stmt_log_lock);
+ DBUG_ASSERT(!auto_increment_lock);
+ DBUG_ASSERT(!auto_increment_safe_stmt_log_lock);
if (lock_type == F_UNLCK)
used_partitions= &m_locked_partitions;
@@ -4188,8 +4190,8 @@ void ha_partition::unlock_row()
bool ha_partition::was_semi_consistent_read()
{
DBUG_ENTER("ha_partition::was_semi_consistent_read");
- DBUG_ASSERT(m_last_part < m_tot_parts &&
- bitmap_is_set(&(m_part_info->read_partitions), m_last_part));
+ DBUG_ASSERT(m_last_part < m_tot_parts);
+ DBUG_ASSERT(bitmap_is_set(&(m_part_info->read_partitions), m_last_part));
DBUG_RETURN(m_file[m_last_part]->was_semi_consistent_read());
}
@@ -7101,8 +7103,8 @@ int ha_partition::partition_scan_set_up(uchar * buf, bool idx_read_flag)
DBUG_ASSERT(m_part_spec.start_part < m_tot_parts);
m_ordered_scan_ongoing= m_ordered;
}
- DBUG_ASSERT(m_part_spec.start_part < m_tot_parts &&
- m_part_spec.end_part < m_tot_parts);
+ DBUG_ASSERT(m_part_spec.start_part < m_tot_parts);
+ DBUG_ASSERT(m_part_spec.end_part < m_tot_parts);
DBUG_RETURN(0);
}
@@ -10549,7 +10551,8 @@ void ha_partition::get_auto_increment(ulonglong offset, ulonglong increment,
DBUG_PRINT("enter", ("offset: %lu inc: %lu desired_values: %lu "
"first_value: %lu", (ulong) offset, (ulong) increment,
(ulong) nb_desired_values, (ulong) *first_value));
- DBUG_ASSERT(increment && nb_desired_values);
+ DBUG_ASSERT(increment);
+ DBUG_ASSERT(nb_desired_values);
*first_value= 0;
if (table->s->next_number_keypart)
{
diff --git a/sql/handler.cc b/sql/handler.cc
index a7e7e2554cb..cc7eedd18f2 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4380,6 +4380,19 @@ int handler::ha_repair(THD* thd, HA_CHECK_OPT* check_opt)
/**
+ End bulk insert
+*/
+
+int handler::ha_end_bulk_insert()
+{
+ DBUG_ENTER("handler::ha_end_bulk_insert");
+ DBUG_EXECUTE_IF("crash_end_bulk_insert",
+ { extra(HA_EXTRA_FLUSH) ; DBUG_SUICIDE();});
+ estimation_rows_to_insert= 0;
+ DBUG_RETURN(end_bulk_insert());
+}
+
+/**
Bulk update row: public interface.
@sa handler::bulk_update_row()
diff --git a/sql/handler.h b/sql/handler.h
index c764915cc51..cdcb117da97 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -3301,13 +3301,7 @@ public:
start_bulk_insert(rows, flags);
DBUG_VOID_RETURN;
}
- int ha_end_bulk_insert()
- {
- DBUG_ENTER("handler::ha_end_bulk_insert");
- estimation_rows_to_insert= 0;
- int ret= end_bulk_insert();
- DBUG_RETURN(ret);
- }
+ int ha_end_bulk_insert();
int ha_bulk_update_row(const uchar *old_data, const uchar *new_data,
ha_rows *dup_key_found);
int ha_delete_all_rows();
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d0859ad5573..99b8457cf20 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -340,7 +340,6 @@ static bool max_long_data_size_used= false;
static bool volatile select_thread_in_use, signal_thread_in_use;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_short_log_format= 0, opt_silent_startup= 0;
-bool my_disable_leak_check= false;
uint kill_cached_threads;
static uint wake_thread;
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 73def7bde92..11d9f80865a 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -672,6 +672,7 @@ public:
bool statement_should_be_aborted() const
{
return
+ thd->killed ||
thd->is_fatal_error ||
thd->is_error() ||
alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
diff --git a/sql/opt_range_mrr.cc b/sql/opt_range_mrr.cc
index 267d764bb3b..20413f5df63 100644
--- a/sql/opt_range_mrr.cc
+++ b/sql/opt_range_mrr.cc
@@ -79,6 +79,7 @@ range_seq_t sel_arg_range_seq_init(void *init_param, uint n_ranges, uint flags)
SEL_ARG_RANGE_SEQ *seq= (SEL_ARG_RANGE_SEQ*)init_param;
seq->param->range_count=0;
seq->at_start= TRUE;
+ seq->param->max_key_parts= 0;
seq->stack[0].key_tree= NULL;
seq->stack[0].min_key= seq->param->min_key;
seq->stack[0].min_key_flag= 0;
diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc
index 9344312fe62..88e036d4481 100644
--- a/sql/rpl_parallel.cc
+++ b/sql/rpl_parallel.cc
@@ -93,18 +93,18 @@ handle_queued_pos_update(THD *thd, rpl_parallel_thread::queued_event *qev)
/* Do not update position if an earlier event group caused an error abort. */
DBUG_ASSERT(qev->typ == rpl_parallel_thread::queued_event::QUEUED_POS_UPDATE);
+ rli= qev->rgi->rli;
e= qev->entry_for_queued;
- if (e->stop_on_error_sub_id < (uint64)ULONGLONG_MAX || e->force_abort)
+ if (e->stop_on_error_sub_id < (uint64)ULONGLONG_MAX ||
+ (e->force_abort && !rli->stop_for_until))
return;
- rli= qev->rgi->rli;
mysql_mutex_lock(&rli->data_lock);
cmp= strcmp(rli->group_relay_log_name, qev->event_relay_log_name);
if (cmp < 0)
{
rli->group_relay_log_pos= qev->future_event_relay_log_pos;
strmake_buf(rli->group_relay_log_name, qev->event_relay_log_name);
- rli->notify_group_relay_log_name_update();
} else if (cmp == 0 &&
rli->group_relay_log_pos < qev->future_event_relay_log_pos)
rli->group_relay_log_pos= qev->future_event_relay_log_pos;
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 49b2e00882e..2c3e3d5a838 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -62,6 +62,7 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery)
slave_running(MYSQL_SLAVE_NOT_RUN), until_condition(UNTIL_NONE),
until_log_pos(0), retried_trans(0), executed_entries(0),
sql_delay(0), sql_delay_end(0),
+ until_relay_log_names_defer(false),
m_flags(0)
{
DBUG_ENTER("Relay_log_info::Relay_log_info");
@@ -503,6 +504,8 @@ void Relay_log_info::clear_until_condition()
until_condition= Relay_log_info::UNTIL_NONE;
until_log_name[0]= 0;
until_log_pos= 0;
+ until_relay_log_names_defer= false;
+
DBUG_VOID_RETURN;
}
@@ -993,7 +996,6 @@ void Relay_log_info::inc_group_relay_log_pos(ulonglong log_pos,
{
group_relay_log_pos= rgi->future_event_relay_log_pos;
strmake_buf(group_relay_log_name, rgi->event_relay_log_name);
- notify_group_relay_log_name_update();
} else if (cmp == 0 && group_relay_log_pos < rgi->future_event_relay_log_pos)
group_relay_log_pos= rgi->future_event_relay_log_pos;
@@ -1283,29 +1285,78 @@ err:
autoincrement or if we have transactions).
Should be called ONLY if until_condition != UNTIL_NONE !
+
+ In the parallel execution mode and UNTIL_MASTER_POS the file name is
+ presented by future_event_master_log_name which may be ahead of
+ group_master_log_name. Log_event::log_pos does relate to it nevertheless
+ so the pair comprises a correct binlog coordinate.
+ Internal group events and events that have zero log_pos also
+ produce the zero for the local log_pos which may not lead to the
+ function falsely return true.
+ In UNTIL_RELAY_POS the original caching and notification are simplified
+ to straightforward files comparison when the current event can't be
+ a part of an event group.
+
RETURN VALUE
true - condition met or error happened (condition seems to have
bad log file name)
false - condition not met
*/
-bool Relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
+bool Relay_log_info::is_until_satisfied(Log_event *ev)
{
const char *log_name;
ulonglong log_pos;
+ /* Prevents stopping within transaction; needed solely for Relay UNTIL. */
+ bool in_trans= false;
+
DBUG_ENTER("Relay_log_info::is_until_satisfied");
if (until_condition == UNTIL_MASTER_POS)
{
log_name= (mi->using_parallel() ? future_event_master_log_name
: group_master_log_name);
- log_pos= master_beg_pos;
+ log_pos= (get_flag(Relay_log_info::IN_TRANSACTION) || !ev || !ev->log_pos) ?
+ (mi->using_parallel() ? 0 : group_master_log_pos) :
+ ev->log_pos - ev->data_written;
}
else
{
DBUG_ASSERT(until_condition == UNTIL_RELAY_POS);
- log_name= group_relay_log_name;
- log_pos= group_relay_log_pos;
+ if (!mi->using_parallel())
+ {
+ log_name= group_relay_log_name;
+ log_pos= group_relay_log_pos;
+ }
+ else
+ {
+ log_name= event_relay_log_name;
+ log_pos= event_relay_log_pos;
+ in_trans= get_flag(Relay_log_info::IN_TRANSACTION);
+ /*
+ until_log_names_cmp_result is set to UNKNOWN either
+ - by a non-group event *and* only when it is in the middle of a group
+ - or by a group event when the preceding group made the above
+ non-group event to defer the resetting.
+ */
+ if ((ev && !Log_event::is_group_event(ev->get_type_code())))
+ {
+ if (in_trans)
+ {
+ until_relay_log_names_defer= true;
+ }
+ else
+ {
+ until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_UNKNOWN;
+ until_relay_log_names_defer= false;
+ }
+ }
+ else if (!in_trans && until_relay_log_names_defer)
+ {
+ until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_UNKNOWN;
+ until_relay_log_names_defer= false;
+ }
+ }
}
DBUG_PRINT("info", ("group_master_log_name='%s', group_master_log_pos=%llu",
@@ -1359,8 +1410,8 @@ bool Relay_log_info::is_until_satisfied(my_off_t master_beg_pos)
}
DBUG_RETURN(((until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_EQUAL &&
- log_pos >= until_log_pos) ||
- until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_GREATER));
+ (log_pos >= until_log_pos && !in_trans)) ||
+ until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_GREATER));
}
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index fafe8ead63d..f89b40b1efc 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -219,7 +219,7 @@ public:
*/
char future_event_master_log_name[FN_REFLEN];
- /*
+ /*
Original log name and position of the group we're currently executing
(whose coordinates are group_relay_log_name/pos in the relay log)
in the master's binlog. These concern the *group*, because in the master's
@@ -419,7 +419,7 @@ public:
void close_temporary_tables();
/* Check if UNTIL condition is satisfied. See slave.cc for more. */
- bool is_until_satisfied(my_off_t);
+ bool is_until_satisfied(Log_event *ev);
inline ulonglong until_pos()
{
DBUG_ASSERT(until_condition == UNTIL_MASTER_POS ||
@@ -427,7 +427,13 @@ public:
return ((until_condition == UNTIL_MASTER_POS) ? group_master_log_pos :
group_relay_log_pos);
}
-
+ inline char *until_name()
+ {
+ DBUG_ASSERT(until_condition == UNTIL_MASTER_POS ||
+ until_condition == UNTIL_RELAY_POS);
+ return ((until_condition == UNTIL_MASTER_POS) ? group_master_log_name :
+ group_relay_log_name);
+ }
/**
Helper function to do after statement completion.
@@ -564,6 +570,15 @@ private:
relay_log.info had 4 lines. Now it has 5 lines.
*/
static const int LINES_IN_RELAY_LOG_INFO_WITH_DELAY= 5;
+ /*
+ Hint for when to stop event distribution by sql driver thread.
+ The flag is set ON by a non-group event when this event is in the middle
+ of a group (e.g a transaction group) so it's too early
+ to refresh the current-relay-log vs until-log cached comparison result.
+ And it is checked and to decide whether it's a right time to do so
+ when the being processed group has been fully scheduled.
+ */
+ bool until_relay_log_names_defer;
/*
Holds the state of the data in the relay log.
diff --git a/sql/slave.cc b/sql/slave.cc
index 6dd31151715..31025b835b2 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4311,12 +4311,8 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli,
rli->until_condition == Relay_log_info::UNTIL_RELAY_POS) &&
(ev->server_id != global_system_variables.server_id ||
rli->replicate_same_server_id) &&
- rli->is_until_satisfied((rli->get_flag(Relay_log_info::IN_TRANSACTION) || !ev->log_pos)
- ? rli->group_master_log_pos
- : ev->log_pos - ev->data_written))
+ rli->is_until_satisfied(ev))
{
- sql_print_information("Slave SQL thread stopped because it reached its"
- " UNTIL position %llu", rli->until_pos());
/*
Setting abort_slave flag because we do not want additional
message about error in query execution to be printed.
@@ -5559,10 +5555,14 @@ pthread_handler_t handle_slave_sql(void *arg)
}
if ((rli->until_condition == Relay_log_info::UNTIL_MASTER_POS ||
rli->until_condition == Relay_log_info::UNTIL_RELAY_POS) &&
- rli->is_until_satisfied(rli->group_master_log_pos))
+ rli->is_until_satisfied(NULL))
{
sql_print_information("Slave SQL thread stopped because it reached its"
- " UNTIL position %llu", rli->until_pos());
+ " UNTIL position %llu in %s %s file",
+ rli->until_pos(), rli->until_name(),
+ rli->until_condition ==
+ Relay_log_info::UNTIL_MASTER_POS ?
+ "binlog" : "relaylog");
mysql_mutex_unlock(&rli->data_lock);
goto err;
}
@@ -5641,7 +5641,24 @@ pthread_handler_t handle_slave_sql(void *arg)
err:
if (mi->using_parallel())
rli->parallel.wait_for_done(thd, rli);
+ /* Gtid_list_log_event::do_apply_event has already reported the GTID until */
+ if (rli->stop_for_until && rli->until_condition != Relay_log_info::UNTIL_GTID)
+ {
+ if (global_system_variables.log_warnings > 2)
+ sql_print_information("Slave SQL thread UNTIL stop was requested at position "
+ "%llu in %s %s file",
+ rli->until_log_pos, rli->until_log_name,
+ rli->until_condition ==
+ Relay_log_info::UNTIL_MASTER_POS ?
+ "binlog" : "relaylog");
+ sql_print_information("Slave SQL thread stopped because it reached its"
+ " UNTIL position %llu in %s %s file",
+ rli->until_pos(), rli->until_name(),
+ rli->until_condition ==
+ Relay_log_info::UNTIL_MASTER_POS ?
+ "binlog" : "relaylog");
+ };
/* Thread stopped. Print the current replication position to the log */
{
StringBuffer<100> tmp;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 1cef262cffa..02ecb87038c 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2019, MariaDB Corporation.
+ Copyright (c) 2009, 2020, 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
@@ -4013,7 +4013,8 @@ public:
The worst things that can happen is that we get
a suboptimal error message.
*/
- if (likely((killed_err= (err_info*) alloc(sizeof(*killed_err)))))
+ killed_err= (err_info*) alloc_root(&main_mem_root, sizeof(*killed_err));
+ if (likely(killed_err))
{
killed_err->no= killed_errno_arg;
::strmake((char*) killed_err->msg, killed_err_msg_arg,
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 9a08973562c..9a212cd2246 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -5981,6 +5981,37 @@ the generated partition syntax in a correct manner.
*partition_changed= TRUE;
}
}
+ /*
+ Prohibit inplace when partitioned by primary key and the primary key is changed.
+ */
+ if (!*partition_changed &&
+ tab_part_info->part_field_array &&
+ !tab_part_info->part_field_list.elements &&
+ table->s->primary_key != MAX_KEY)
+ {
+
+ if (alter_info->flags & (ALTER_DROP_SYSTEM_VERSIONING |
+ ALTER_ADD_SYSTEM_VERSIONING))
+ {
+ *partition_changed= true;
+ }
+ else
+ {
+ KEY *primary_key= table->key_info + table->s->primary_key;
+ List_iterator_fast<Alter_drop> drop_it(alter_info->drop_list);
+ const char *primary_name= primary_key->name.str;
+ const Alter_drop *drop;
+ drop_it.rewind();
+ while ((drop= drop_it++))
+ {
+ if (drop->type == Alter_drop::KEY &&
+ 0 == my_strcasecmp(system_charset_info, primary_name, drop->name))
+ break;
+ }
+ if (drop)
+ *partition_changed= TRUE;
+ }
+ }
}
if (thd->work_part_info)
{
@@ -6013,23 +6044,6 @@ the generated partition syntax in a correct manner.
}
}
- // In case of PARTITION BY KEY(), check if primary key has changed
- // System versioning also implicitly adds/removes primary key parts
- if (alter_info->partition_flags == 0 && part_info->list_of_part_fields
- && part_info->part_field_list.elements == 0)
- {
- if (alter_info->flags & (ALTER_DROP_SYSTEM_VERSIONING |
- ALTER_ADD_SYSTEM_VERSIONING))
- *partition_changed= true;
-
- List_iterator<Key> it(alter_info->key_list);
- Key *key;
- while((key= it++) && !*partition_changed)
- {
- if (key->type == Key::PRIMARY)
- *partition_changed= true;
- }
- }
/*
Set up partition default_engine_type either from the create_info
or from the previus table
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index ee74cfa8e97..568a3ed6062 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1029,10 +1029,16 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
if (vers_conditions.is_set())
{
+ if (vers_conditions.was_set() &&
+ table->lock_type > TL_READ_NO_INSERT &&
+ !vers_conditions.delete_history)
+ {
+ my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE, MYF(0), table->alias.str);
+ DBUG_RETURN(-1);
+ }
+
if (vers_conditions.type == SYSTEM_TIME_ALL)
continue;
-
- lock_type= TL_READ; // ignore TL_WRITE, history is immutable anyway
}
bool timestamps_only= table->table->versioned(VERS_TIMESTAMP);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index ff6c2873dfc..1c5aac08584 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4402,6 +4402,25 @@ bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len,
Well_formed_prefix(system_charset_info, *comment, max_len).length();
if (tmp_len < comment->length)
{
+#if MARIADB_VERSION_ID < 100500
+ if (comment->length <= max_len)
+ {
+ if (thd->is_strict_mode())
+ {
+ my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
+ system_charset_info->csname, comment->str);
+ DBUG_RETURN(true);
+ }
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_INVALID_CHARACTER_STRING,
+ ER_THD(thd, ER_INVALID_CHARACTER_STRING),
+ system_charset_info->csname, comment->str);
+ comment->length= tmp_len;
+ DBUG_RETURN(false);
+ }
+#else
+#error do it in TEXT_STRING_sys
+#endif
if (thd->is_strict_mode())
{
my_error(err_code, MYF(0), name, static_cast<ulong>(max_len));
@@ -7910,16 +7929,13 @@ blob_length_by_type(enum_field_types type)
}
-static void append_drop_column(THD *thd, bool dont, String *str,
- Field *field)
+static inline
+void append_drop_column(THD *thd, String *str, Field *field)
{
- if (!dont)
- {
- if (str->length())
- str->append(STRING_WITH_LEN(", "));
- str->append(STRING_WITH_LEN("DROP COLUMN "));
- append_identifier(thd, str, &field->field_name);
- }
+ if (str->length())
+ str->append(STRING_WITH_LEN(", "));
+ str->append(STRING_WITH_LEN("DROP COLUMN "));
+ append_identifier(thd, str, &field->field_name);
}
@@ -8175,7 +8191,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
field->invisible < INVISIBLE_SYSTEM)
{
StringBuffer<NAME_LEN*3> tmp;
- append_drop_column(thd, false, &tmp, field);
+ append_drop_column(thd, &tmp, field);
my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr());
goto err;
}
@@ -8228,10 +8244,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
!vers_system_invisible)
{
StringBuffer<NAME_LEN*3> tmp;
- append_drop_column(thd, dropped_sys_vers_fields & VERS_SYS_START_FLAG,
- &tmp, table->vers_start_field());
- append_drop_column(thd, dropped_sys_vers_fields & VERS_SYS_END_FLAG,
- &tmp, table->vers_end_field());
+ if (!(dropped_sys_vers_fields & VERS_SYS_START_FLAG))
+ append_drop_column(thd, &tmp, table->vers_start_field());
+ if (!(dropped_sys_vers_fields & VERS_SYS_END_FLAG))
+ append_drop_column(thd, &tmp, table->vers_end_field());
my_error(ER_MISSING, MYF(0), table->s->table_name.str, tmp.c_ptr());
goto err;
}
diff --git a/sql/table.cc b/sql/table.cc
index 92dfa59e648..a4de5d9c930 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -8383,9 +8383,10 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
int TABLE::update_virtual_field(Field *vf)
{
- DBUG_ASSERT(!in_use->is_error());
- Query_arena backup_arena;
DBUG_ENTER("TABLE::update_virtual_field");
+ Query_arena backup_arena;
+ Counting_error_handler count_errors;
+ in_use->push_internal_handler(&count_errors);
in_use->set_n_backup_active_arena(expr_arena, &backup_arena);
bitmap_clear_all(&tmp_set);
vf->vcol_info->expr->walk(&Item::update_vcol_processor, 0, &tmp_set);
@@ -8393,7 +8394,8 @@ int TABLE::update_virtual_field(Field *vf)
vf->vcol_info->expr->save_in_field(vf, 0);
DBUG_RESTORE_WRITE_SET(vf);
in_use->restore_active_arena(expr_arena, &backup_arena);
- DBUG_RETURN(in_use->is_error());
+ in_use->pop_internal_handler();
+ DBUG_RETURN(count_errors.errors);
}
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 2b162e9a374..7990a67081e 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2018, MariaDB Corporation
+ Copyright (c) 2009, 2020, 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
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index bd22e78c5b2..1f12093b634 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -2447,7 +2447,7 @@ static void fil_crypt_rotation_list_fill()
space != NULL;
space = UT_LIST_GET_NEXT(space_list, space)) {
if (space->purpose != FIL_TYPE_TABLESPACE
- || space->is_in_rotation_list()
+ || space->is_in_rotation_list
|| space->is_stopping()
|| UT_LIST_GET_LEN(space->chain) == 0) {
continue;
@@ -2494,6 +2494,7 @@ static void fil_crypt_rotation_list_fill()
}
fil_system.rotation_list.push_back(*space);
+ space->is_in_rotation_list = true;
}
}
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index a41a95025fd..16ff86c3f91 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -693,7 +693,7 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
/* No need to flush. User has explicitly disabled
buffering. */
- ut_ad(!space->is_in_unflushed_spaces());
+ ut_ad(!space->is_in_unflushed_spaces);
ut_ad(fil_space_is_flushed(space));
ut_ad(space->n_pending_flushes == 0);
@@ -757,10 +757,11 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
skip_flush:
#endif /* _WIN32 */
if (!node->needs_flush) {
- if (space->is_in_unflushed_spaces()
+ if (space->is_in_unflushed_spaces
&& fil_space_is_flushed(space)) {
fil_system.unflushed_spaces.remove(*space);
+ space->is_in_unflushed_spaces = false;
}
}
@@ -1048,13 +1049,14 @@ fil_node_close_to_free(
if (fil_buffering_disabled(space)) {
- ut_ad(!space->is_in_unflushed_spaces());
+ ut_ad(!space->is_in_unflushed_spaces);
ut_ad(fil_space_is_flushed(space));
- } else if (space->is_in_unflushed_spaces()
+ } else if (space->is_in_unflushed_spaces
&& fil_space_is_flushed(space)) {
fil_system.unflushed_spaces.remove(*space);
+ space->is_in_unflushed_spaces = false;
}
node->close();
@@ -1074,14 +1076,16 @@ fil_space_detach(
HASH_DELETE(fil_space_t, hash, fil_system.spaces, space->id, space);
- if (space->is_in_unflushed_spaces()) {
+ if (space->is_in_unflushed_spaces) {
ut_ad(!fil_buffering_disabled(space));
fil_system.unflushed_spaces.remove(*space);
+ space->is_in_unflushed_spaces = false;
}
- if (space->is_in_rotation_list()) {
+ if (space->is_in_rotation_list) {
fil_system.rotation_list.remove(*space);
+ space->is_in_rotation_list = false;
}
UT_LIST_REMOVE(fil_system.space_list, space);
@@ -1297,6 +1301,7 @@ fil_space_create(
/* Key rotation is not enabled, need to inform background
encryption threads. */
fil_system.rotation_list.push_back(*space);
+ space->is_in_rotation_list = true;
mutex_exit(&fil_system.mutex);
os_event_set(fil_crypt_threads_event);
} else {
@@ -4023,13 +4028,14 @@ fil_node_complete_io(fil_node_t* node, const IORequest& type)
/* We don't need to keep track of unflushed
changes as user has explicitly disabled
buffering. */
- ut_ad(!node->space->is_in_unflushed_spaces());
+ ut_ad(!node->space->is_in_unflushed_spaces);
ut_ad(node->needs_flush == false);
} else {
node->needs_flush = true;
- if (!node->space->is_in_unflushed_spaces()) {
+ if (!node->space->is_in_unflushed_spaces) {
+ node->space->is_in_unflushed_spaces = true;
fil_system.unflushed_spaces.push_front(
*node->space);
}
@@ -4503,7 +4509,7 @@ fil_flush_file_spaces(
n_space_ids = 0;
- for (intrusive::list<fil_space_t, unflushed_spaces_tag_t>::iterator it
+ for (sized_ilist<fil_space_t, unflushed_spaces_tag_t>::iterator it
= fil_system.unflushed_spaces.begin(),
end = fil_system.unflushed_spaces.end();
it != end; ++it) {
@@ -5016,7 +5022,8 @@ fil_space_remove_from_keyrotation(fil_space_t* space)
ut_ad(mutex_own(&fil_system.mutex));
ut_ad(space);
- if (!space->referenced() && space->is_in_rotation_list()) {
+ if (!space->referenced() && space->is_in_rotation_list) {
+ space->is_in_rotation_list = false;
ut_a(!fil_system.rotation_list.empty());
fil_system.rotation_list.remove(*space);
}
@@ -5046,8 +5053,8 @@ fil_space_t *fil_system_t::keyrotate_next(fil_space_t *prev_space,
don't remove the last processed tablespace from the rotation list. */
const bool remove= (!recheck || prev_space->crypt_data) &&
!key_version == !srv_encrypt_tables;
- intrusive::list<fil_space_t, rotation_list_tag_t>::iterator it=
- prev_space == NULL ? fil_system.rotation_list.end() : prev_space;
+ sized_ilist<fil_space_t, rotation_list_tag_t>::iterator it=
+ prev_space ? prev_space : fil_system.rotation_list.end();
if (it == fil_system.rotation_list.end())
it= fil_system.rotation_list.begin();
@@ -5124,24 +5131,3 @@ fil_space_found_by_id(
mutex_exit(&fil_system.mutex);
return space;
}
-
-/** Checks that this tablespace in a list of unflushed tablespaces.
-@return true if in a list */
-bool fil_space_t::is_in_unflushed_spaces() const
-{
- ut_ad(mutex_own(&fil_system.mutex));
-
- return static_cast<const intrusive::list_node<unflushed_spaces_tag_t> *>(
- this)
- ->next;
-}
-
-/** Checks that this tablespace needs key rotation.
-@return true if in a rotation list */
-bool fil_space_t::is_in_rotation_list() const
-{
- ut_ad(mutex_own(&fil_system.mutex));
-
- return static_cast<const intrusive::list_node<rotation_list_tag_t> *>(this)
- ->next;
-}
diff --git a/storage/innobase/include/dyn0buf.h b/storage/innobase/include/dyn0buf.h
index f66c7e3d405..be263e04e15 100644
--- a/storage/innobase/include/dyn0buf.h
+++ b/storage/innobase/include/dyn0buf.h
@@ -29,7 +29,7 @@ Created 2013-03-16 Sunny Bains
#include "mem0mem.h"
#include "dyn0types.h"
-#include "intrusive_list.h"
+#include "ilist.h"
/** Class that manages dynamic buffers. It uses a UT_LIST of
@@ -43,9 +43,9 @@ class mtr_buf_t {
public:
/** SIZE - sizeof(m_node) + sizeof(m_used) */
enum { MAX_DATA_SIZE = DYN_ARRAY_DATA_SIZE
- - sizeof(intrusive::list_node<>) + sizeof(uint32_t) };
+ - sizeof(ilist_node<>) + sizeof(uint32_t) };
- class block_t : public intrusive::list_node<> {
+ class block_t : public ilist_node<> {
public:
block_t()
@@ -160,7 +160,7 @@ public:
friend class mtr_buf_t;
};
- typedef intrusive::list<block_t> list_t;
+ typedef sized_ilist<block_t> list_t;
/** Default constructor */
mtr_buf_t()
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index a24b2a43fda..e78c9587325 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -33,7 +33,7 @@ Created 10/25/1995 Heikki Tuuri
#include "log0recv.h"
#include "dict0types.h"
-#include "intrusive_list.h"
+#include "ilist.h"
#ifdef UNIV_LINUX
# include <set>
#endif
@@ -82,8 +82,8 @@ struct fil_node_t;
/** Tablespace or log data space */
#ifndef UNIV_INNOCHECKSUM
-struct fil_space_t : intrusive::list_node<unflushed_spaces_tag_t>,
- intrusive::list_node<rotation_list_tag_t>
+struct fil_space_t : ilist_node<unflushed_spaces_tag_t>,
+ ilist_node<rotation_list_tag_t>
#else
struct fil_space_t
#endif
@@ -160,18 +160,18 @@ struct fil_space_t
UT_LIST_NODE_T(fil_space_t) named_spaces;
/*!< list of spaces for which MLOG_FILE_NAME
records have been issued */
- /** Checks that this tablespace in a list of unflushed tablespaces.
- @return true if in a list */
- bool is_in_unflushed_spaces() const;
UT_LIST_NODE_T(fil_space_t) space_list;
/*!< list of all spaces */
- /** Checks that this tablespace needs key rotation.
- @return true if in a rotation list */
- bool is_in_rotation_list() const;
/** MariaDB encryption data */
fil_space_crypt_t* crypt_data;
+ /** Checks that this tablespace in a list of unflushed tablespaces. */
+ bool is_in_unflushed_spaces;
+
+ /** Checks that this tablespace needs key rotation. */
+ bool is_in_rotation_list;
+
/** True if the device this filespace is on supports atomic writes */
bool atomic_write_supported;
@@ -933,7 +933,7 @@ public:
not put to this list: they are opened
after the startup, and kept open until
shutdown */
- intrusive::list<fil_space_t, unflushed_spaces_tag_t> unflushed_spaces;
+ sized_ilist<fil_space_t, unflushed_spaces_tag_t> unflushed_spaces;
/*!< list of those
tablespaces whose files contain
unflushed writes; those spaces have
@@ -954,7 +954,7 @@ public:
record has been written since
the latest redo log checkpoint.
Protected only by log_sys.mutex. */
- intrusive::list<fil_space_t, rotation_list_tag_t> rotation_list;
+ ilist<fil_space_t, rotation_list_tag_t> rotation_list;
/*!< list of all file spaces needing
key rotation.*/
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 27c941705b7..8f108e3f03f 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -956,6 +956,7 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE)
char *old_name, *new_name;
int error= 1;
MARIA_HA *info= NULL;
+ my_bool from_table_is_crashed= 0;
DBUG_ENTER("exec_REDO_LOGREC_REDO_RENAME_TABLE");
if (skip_DDLs)
@@ -1025,15 +1026,15 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE)
}
if (maria_is_crashed(info))
{
- tprint(tracef, ", is crashed, can't rename it");
- ALERT_USER();
- goto end;
+ tprint(tracef, "is crashed, can't be used for rename ; new-name table ");
+ from_table_is_crashed= 1;
}
if (close_one_table(info->s->open_file_name.str, rec->lsn) ||
maria_close(info))
goto end;
info= NULL;
- tprint(tracef, ", is ok for renaming; new-name table ");
+ if (!from_table_is_crashed)
+ tprint(tracef, "is ok for renaming; new-name table ");
}
else /* one or two files absent, or header corrupted... */
{
@@ -1098,11 +1099,19 @@ prototype_redo_exec_hook(REDO_RENAME_TABLE)
goto end;
info= NULL;
/* abnormal situation */
- tprint(tracef, ", exists but is older than record, can't rename it");
+ tprint(tracef, "exists but is older than record, can't rename it");
goto end;
}
else /* one or two files absent, or header corrupted... */
- tprint(tracef, ", can't be opened, probably does not exist");
+ tprint(tracef, "can't be opened, probably does not exist");
+
+ if (from_table_is_crashed)
+ {
+ eprint(tracef, "Aborting rename as old table was crashed");
+ ALERT_USER();
+ goto end;
+ }
+
tprint(tracef, ", renaming '%s'", old_name);
if (maria_rename(old_name, new_name))
{
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index 07be8333794..86770749a45 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -335,12 +335,6 @@ err:
my_errno == HA_ERR_NULL_IN_SPATIAL ||
my_errno == HA_ERR_OUT_OF_MEM)
{
- if (info->bulk_insert)
- {
- uint j;
- for (j=0 ; j < share->base.keys ; j++)
- maria_flush_bulk_insert(info, j);
- }
info->errkey= i < share->base.keys ? (int) i : -1;
/*
We delete keys in the reverse order of insertion. This is the order that
@@ -366,6 +360,7 @@ err:
{
if (_ma_ft_del(info,i,buff,record,filepos))
{
+ fatal_error= 1;
if (local_lock_tree)
mysql_rwlock_unlock(&keyinfo->root_lock);
break;
@@ -380,6 +375,7 @@ err:
filepos,
info->trn->trid)))
{
+ fatal_error= 1;
if (local_lock_tree)
mysql_rwlock_unlock(&keyinfo->root_lock);
break;
@@ -399,6 +395,13 @@ err:
fatal_error= 1;
}
+ if (info->bulk_insert)
+ {
+ uint j;
+ for (j=0 ; j < share->base.keys ; j++)
+ maria_flush_bulk_insert(info, j);
+ }
+
if (fatal_error)
{
maria_print_error(info->s, HA_ERR_CRASHED);
diff --git a/storage/mroonga/vendor/groonga/lib/db.c b/storage/mroonga/vendor/groonga/lib/db.c
index cba22aa0e64..f3769f9aa4c 100644
--- a/storage/mroonga/vendor/groonga/lib/db.c
+++ b/storage/mroonga/vendor/groonga/lib/db.c
@@ -445,6 +445,9 @@ grn_db_close(grn_ctx *ctx, grn_obj *db)
ctx_used_db = ctx->impl && ctx->impl->db == db;
if (ctx_used_db) {
+#ifdef GRN_WITH_MECAB
+ grn_db_fin_mecab_tokenizer(ctx);
+#endif
grn_ctx_loader_clear(ctx);
if (ctx->impl->parser) {
grn_expr_parser_close(ctx);
diff --git a/storage/mroonga/vendor/groonga/lib/grn_tokenizers.h b/storage/mroonga/vendor/groonga/lib/grn_tokenizers.h
index e90dbfc0b31..81ac2ab6c46 100644
--- a/storage/mroonga/vendor/groonga/lib/grn_tokenizers.h
+++ b/storage/mroonga/vendor/groonga/lib/grn_tokenizers.h
@@ -30,6 +30,7 @@ grn_rc grn_tokenizers_init(void);
grn_rc grn_tokenizers_fin(void);
grn_rc grn_db_init_mecab_tokenizer(grn_ctx *ctx);
+void grn_db_fin_mecab_tokenizer(grn_ctx *ctx);
grn_rc grn_db_init_builtin_tokenizers(grn_ctx *ctx);
#ifdef __cplusplus
diff --git a/storage/mroonga/vendor/groonga/lib/tokenizers.c b/storage/mroonga/vendor/groonga/lib/tokenizers.c
index 11f274e72db..3daacce7ef9 100644
--- a/storage/mroonga/vendor/groonga/lib/tokenizers.c
+++ b/storage/mroonga/vendor/groonga/lib/tokenizers.c
@@ -797,6 +797,36 @@ grn_db_init_mecab_tokenizer(grn_ctx *ctx)
}
}
+void
+grn_db_fin_mecab_tokenizer(grn_ctx *ctx)
+{
+ switch (GRN_CTX_GET_ENCODING(ctx)) {
+ case GRN_ENC_EUC_JP :
+ case GRN_ENC_UTF8 :
+ case GRN_ENC_SJIS :
+#if defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB)
+ {
+ GRN_PLUGIN_DECLARE_FUNCTIONS(tokenizers_mecab);
+ GRN_PLUGIN_IMPL_NAME_TAGGED(fin, tokenizers_mecab)(ctx);
+ }
+#else /* defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB) */
+ {
+ const char *mecab_plugin_name = "tokenizers/mecab";
+ char *path;
+ path = grn_plugin_find_path(ctx, mecab_plugin_name);
+ if (path) {
+ GRN_FREE(path);
+ grn_plugin_unregister(ctx, mecab_plugin_name);
+ }
+ }
+#endif /* defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB) */
+ break;
+ default :
+ break;
+ }
+ return;
+}
+
#define DEF_TOKENIZER(name, init, next, fin, vars)\
(grn_proc_create(ctx, (name), (sizeof(name) - 1),\
GRN_PROC_TOKENIZER, (init), (next), (fin), 3, (vars)))
diff --git a/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c b/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c
index 3dd969a89c5..cabf2c94e53 100644
--- a/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c
+++ b/storage/mroonga/vendor/groonga/plugins/tokenizers/mecab.c
@@ -31,6 +31,7 @@
#include <string.h>
#include <ctype.h>
+static unsigned int sole_mecab_init_counter = 0;
static mecab_t *sole_mecab = NULL;
static grn_plugin_mutex *sole_mecab_mutex = NULL;
static grn_encoding sole_mecab_encoding = GRN_ENC_NONE;
@@ -563,6 +564,11 @@ check_mecab_dictionary_encoding(grn_ctx *ctx)
grn_rc
GRN_PLUGIN_INIT(grn_ctx *ctx)
{
+ ++sole_mecab_init_counter;
+ if (sole_mecab_init_counter > 1)
+ {
+ return GRN_SUCCESS;
+ }
{
char env[GRN_ENV_BUFFER_SIZE];
@@ -636,6 +642,11 @@ GRN_PLUGIN_REGISTER(grn_ctx *ctx)
grn_rc
GRN_PLUGIN_FIN(grn_ctx *ctx)
{
+ --sole_mecab_init_counter;
+ if (sole_mecab_init_counter > 0)
+ {
+ return GRN_SUCCESS;
+ }
if (sole_mecab) {
mecab_destroy(sole_mecab);
sole_mecab = NULL;
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index 3f3c60a4249..a0cdd37b302 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -1587,6 +1587,8 @@ int mi_repair(HA_CHECK *param, register MI_INFO *info,
sort_param.filepos=new_header_length;
param->read_cache.end_of_file=sort_info.filelength=
mysql_file_seek(info->dfile, 0L, MY_SEEK_END, MYF(0));
+ if (info->state->data_file_length == 0)
+ info->state->data_file_length= sort_info.filelength;
sort_info.dupp=0;
sort_param.fix_datafile= (my_bool) (! rep_quick);
sort_param.master=1;
@@ -2292,6 +2294,8 @@ int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
sort_info.buff=0;
param->read_cache.end_of_file=sort_info.filelength=
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
+ if (info->state->data_file_length == 0)
+ info->state->data_file_length= sort_info.filelength;
sort_param.wordlist=NULL;
init_alloc_root(&sort_param.wordroot, "sort", FTPARSER_MEMROOT_ALLOC_SIZE, 0,
@@ -2759,6 +2763,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
sort_info.buff=0;
param->read_cache.end_of_file=sort_info.filelength=
mysql_file_seek(param->read_cache.file, 0L, MY_SEEK_END, MYF(0));
+ if (info->state->data_file_length == 0)
+ info->state->data_file_length= sort_info.filelength;
if (share->data_file_type == DYNAMIC_RECORD)
rec_length=MY_MAX(share->base.min_pack_length+1,share->base.min_block_length);
diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake
index 1a3b2076c82..2e939587811 100644
--- a/storage/rocksdb/build_rocksdb.cmake
+++ b/storage/rocksdb/build_rocksdb.cmake
@@ -67,7 +67,7 @@ if(SNAPPY_FOUND AND (NOT WITH_ROCKSDB_snappy STREQUAL "OFF"))
endif()
include(CheckFunctionExists)
-if(ZSTD_FOUND AND (NOT WITH_ROCKSDB_zstd STREQUAL "OFF"))
+if(ZSTD_FOUND AND (NOT WITH_ROCKSDB_ZSTD STREQUAL "OFF"))
SET(CMAKE_REQUIRED_LIBRARIES zstd)
CHECK_FUNCTION_EXISTS(ZDICT_trainFromBuffer ZSTD_VALID)
UNSET(CMAKE_REQUIRED_LIBRARIES)
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index 1f4b53029b8..52c93c37806 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -114,7 +114,6 @@ int thd_binlog_format(const MYSQL_THD thd);
bool thd_binlog_filter_ok(const MYSQL_THD thd);
}
-MYSQL_PLUGIN_IMPORT bool my_disable_leak_check;
extern my_bool opt_core_file;
// Needed in rocksdb_init_func
@@ -5716,13 +5715,6 @@ static int rocksdb_init_func(void *const p) {
}
#endif
- /**
- Rocksdb does not always shutdown its threads, when
- plugin is shut down. Disable server's leak check
- at exit to avoid crash.
- */
- my_disable_leak_check = true;
-
err = my_error_register(rdb_get_error_messages, HA_ERR_ROCKSDB_FIRST,
HA_ERR_ROCKSDB_LAST);
if (err != 0) {
diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp
index 6e78266496e..93383f3fd20 100644
--- a/win/packaging/ca/CustomAction.cpp
+++ b/win/packaging/ca/CustomAction.cpp
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#undef NOMINMAX
#include <winsock2.h>
+#include <ws2tcpip.h>
#include <windows.h>
#include <winreg.h>
#include <msi.h>
@@ -41,6 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
using namespace std;
+
#define ONE_MB 1048576
UINT ExecRemoveDataDirectory(wchar_t *dir)
{
@@ -264,36 +266,89 @@ bool ExecRemoveService(const wchar_t *name)
return ret;
}
-/*
- Check if port is free by trying to bind to the port
-*/
-bool IsPortFree(short port)
+/* Find whether TCP port is in use by trying to bind to the port. */
+static bool IsPortInUse(unsigned short port)
{
- WORD wVersionRequested;
- WSADATA wsaData;
-
- wVersionRequested = MAKEWORD(2, 2);
+ struct addrinfo* ai, * a;
+ struct addrinfo hints {};
- WSAStartup(wVersionRequested, &wsaData);
+ char port_buf[NI_MAXSERV];
+ SOCKET ip_sock = INVALID_SOCKET;
+ hints.ai_flags = AI_PASSIVE;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_family = AF_UNSPEC;
+ snprintf(port_buf, NI_MAXSERV, "%u", (unsigned)port);
- struct sockaddr_in sin;
- SOCKET sock;
- sock = socket(AF_INET, SOCK_STREAM, 0);
- if(sock == INVALID_SOCKET)
+ if (getaddrinfo(NULL, port_buf, &hints, &ai))
{
return false;
}
- sin.sin_port = htons(port);
- sin.sin_addr.s_addr = 0;
- sin.sin_addr.s_addr = INADDR_ANY;
- sin.sin_family = AF_INET;
- if(bind(sock, (struct sockaddr *)&sin,sizeof(struct sockaddr_in) ) == -1)
+
+ /*
+ Prefer IPv6 socket to IPv4, since we'll use IPv6 dual socket,
+ which coveres both IP versions.
+ */
+ for (a = ai; a; a = a->ai_next)
+ {
+ if (a->ai_family == AF_INET6 &&
+ (ip_sock = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) != INVALID_SOCKET)
+ {
+ break;
+ }
+ }
+
+ if (ip_sock == INVALID_SOCKET)
+ {
+ for (a = ai; a; a = a->ai_next)
+ {
+ if (ai->ai_family == AF_INET &&
+ (ip_sock = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) != INVALID_SOCKET)
+ {
+ break;
+ }
+ }
+ }
+
+ if (ip_sock == INVALID_SOCKET)
{
return false;
}
- closesocket(sock);
+
+ /* Use SO_EXCLUSIVEADDRUSE to prevent multiple binding. */
+ int arg = 1;
+ setsockopt(ip_sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&arg, sizeof(arg));
+
+ /* Allow dual socket, so that IPv4 and IPv6 are both covered.*/
+ if (a->ai_family == AF_INET6)
+ {
+ arg = 0;
+ setsockopt(ip_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&arg, sizeof(arg));
+ }
+
+ bool in_use = false;
+ if (bind(ip_sock, a->ai_addr, a->ai_addrlen) == SOCKET_ERROR)
+ {
+ DWORD last_error = WSAGetLastError();
+ in_use = (last_error == WSAEADDRINUSE || last_error == WSAEACCES);
+ }
+
+ freeaddrinfo(ai);
+ closesocket(ip_sock);
+ return in_use;
+}
+
+
+/*
+ Check if TCP port is free
+*/
+bool IsPortFree(unsigned short port)
+{
+ WORD wVersionRequested = MAKEWORD(2, 2);
+ WSADATA wsaData;
+ WSAStartup(wVersionRequested, &wsaData);
+ bool in_use = IsPortInUse(port);
WSACleanup();
- return true;
+ return !in_use;
}
@@ -650,7 +705,7 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall)
goto LExit;
}
- short port = (short)_wtoi(Port);
+ unsigned short port = (unsigned short)_wtoi(Port);
if (!IsPortFree(port))
{
ErrorMsg =
diff --git a/win/packaging/create_msi.cmake b/win/packaging/create_msi.cmake
index 0cd24676e5e..f992915cd22 100644
--- a/win/packaging/create_msi.cmake
+++ b/win/packaging/create_msi.cmake
@@ -35,10 +35,12 @@ IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(Win64 " Win64='yes'")
SET(Platform x64)
SET(PlatformProgramFilesFolder ProgramFiles64Folder)
+ SET(CA_QUIET_EXEC CAQuietExec64)
ELSE()
SET(CANDLE_ARCH -arch x86)
SET(Platform x86)
SET(PlatformProgramFilesFolder ProgramFilesFolder)
+ SET(CA_QUIET_EXEC CAQuietExec)
SET(Win64)
ENDIF()
diff --git a/win/packaging/custom_ui.wxs b/win/packaging/custom_ui.wxs
deleted file mode 100644
index 70fa3ba3abd..00000000000
--- a/win/packaging/custom_ui.wxs
+++ /dev/null
@@ -1,183 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
- <Fragment>
- <Property Id="PortTemplate" Value="####" />
- <Property Id="PORT" Value="3306"></Property>
- <Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable"/>
- <Property Id="CREATEDBINSTANCE"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Property>
- <UI>
- <Dialog Id="DatabaseCreationDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
- <Control Id="ServiceNameLabel" Type="Text" X="20" Y="73" Width="70" Height="15" TabSkip="no" Text="Service Name:" />
- <Control Id="ServiceName" Type="Edit" X="90" Y="73" Width="120" Height="15" Property="SERVICENAME" Text="{20}" />
-
- <Control Id="RootPasswordLabel" Type="Text" X="20" Y="90" Width="120" Height="15" TabSkip="no" Text="&amp;Root password:" />
- <Control Id="RootPassword" Type="Edit" X="20" Y="105" Width="120" Height="18" Property="ROOT_PASSWORD" Password="yes" Text="{20}" />
-
- <Control Id="RootPasswordConfirmLabel" Type="Text" X="150" Y="90" Width="150" Height="15" TabSkip="no" Text="&amp;Confirm Root password:" />
- <Control Id="RootPasswordConfirm" Type="Edit" X="150" Y="105" Width="120" Height="18" Property="ROOT_PASSWORD_CONFIRM" Password="yes" Text="{20}" />
- <Control Id="BannerLine0" Type="Line" X="0" Y="128" Width="370" Height="0" />
-
- <Control Id="PortLabel" Type="Text" X="20" Y="137" Width="40" Height="15" TabSkip="no" Text="TCP port:" />
-
- <Control Id="Port" Type="MaskedEdit" X="60" Y="136" Width="30" Height="15" Property="PORT" Text="[PortTemplate]"/>
- <!--<Control Id="FirewallExceptionCheckBox" Type="CheckBox" X="150" Y="136" Height="15" Property="FIREWALL_EXCEPTION" Width="200" CheckBoxValue="1"
- Text="Create Firewall exception for this port"/>-->
-
- <Control Id="BannerLine2" Type="Line" X="0" Y="155" Width="370" Height="0" />
-
- <Control Id="FolderLabel" Type="Text" X="20" Y="181" Width="100" Height="15" TabSkip="no" Text="Database location:" />
- <Control Id="Folder" Type="PathEdit" X="20" Y="204" Width="200" Height="18" Property="DATABASELOCATION" Indirect="no" />
-
- <!-- Navigation buttons-->
- <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
- <Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
- </Control>
- <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
- <!--
- <Publish Event="ValidateProductID" Value="0">1</Publish>
- <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
- -->
- <!--<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>-->
- </Control>
- <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
- <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
- </Control>
- <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
- <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
- <Text>Create default [ProductName] instance</Text>
- </Control>
- <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
- <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
- <Text>{\WixUI_Font_Title}Default instance properties</Text>
- </Control>
- <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
- </Dialog>
-
- <Dialog Id="ConfirmDataCleanupDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
- <Control Id="ServiceRemoveText" Type="Text" X="20" Y="73" Width="300" Height="15" TabSkip="no">
- <Text>Service '[SERVICENAME]' will be removed</Text>
- </Control>
- <Control Id="CleanupDataCheckBox" Type="CheckBox" X="20" Y="100" Height="15" Property="CLEANUP_DATA" Width="15" CheckBoxValue="0"/>
- <Control Id="RemoveDataText" Type="Text" X="37" Y="101" Width="300" Height="200" TabSkip="no">
- <Text>Remove default database directory '[DATABASELOCATION]'</Text>
- </Control>
-
- <!-- Navigation buttons-->
- <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
- <Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
- </Control>
- <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
- <Publish Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
- </Control>
- <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
- <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
- </Control>
- <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
- <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
- <Text>Remove default [ProductName] database</Text>
- </Control>
- <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
- <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
- <Text>{\WixUI_Font_Title}Default instance properties</Text>
- </Control>
- <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
- </Dialog>
- </UI>
- <UI Id="MyWixUI_Mondo">
- <UIRef Id="WixUI_FeatureTree" />
- <UIRef Id="WixUI_ErrorProgressText" />
- <DialogRef Id="DatabaseCreationDlg" />
- <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="DatabaseCreationDlg" Order="999"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
- <Publish Dialog="DatabaseCreationDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish>
- <Publish Dialog="DatabaseCreationDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="3">1</Publish>
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="DatabaseCreationDlg" Order="3" ><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Publish>
- <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="3" ><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></Publish>
- <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="999"><![CDATA[(&DBInstance=2) AND (!DBInstance=3)]]></Publish>
- <Publish Dialog="ConfirmDataCleanupDlg" Control="Back" Event="NewDialog" Value="CustomizeDlg">WixUI_InstallMode = "Change"</Publish>
- <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="ConfirmDataCleanupDlg" Order="999">!DBInstance=3</Publish>
- <Publish Dialog="ConfirmDataCleanupDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg">WixUI_InstallMode = "Remove"</Publish>
- </UI>
-
- <DirectoryRef Id='TARGETDIR'>
- <Directory Id="CommonAppDataFolder">
- <Directory Id="DatabasesRoot" Name="MariaDB">
- <Directory Id="DATABASELOCATION" Name="MariaDB Server 5.1">
- </Directory>
- </Directory>
- </Directory>
- </DirectoryRef>
-
- <Feature Id='DBInstance'
- Title='Database instance'
- Description='Install database instance'
- ConfigurableDirectory='DATABASELOCATION'
- AllowAdvertise='no'
- Level='1'>
- <Component Id="C.datadir" Guid="*" Directory="DATABASELOCATION">
- <RegistryValue Root='HKLM'
- Key='SOFTWARE\[Manufacturer]\[ProductName]'
- Name='DatabaseLocation' Value='[DATABASELOCATION]' Type='string' KeyPath='yes'/>
- <CreateFolder />
- </Component>
- <Component Id="C.service" Guid="*" Directory="DATABASELOCATION">
- <Condition>SERVICENAME</Condition>
- <RegistryValue Root='HKLM'
- Key='SOFTWARE\[Manufacturer]\[ProductName]'
- Name='ServiceName' Value='[SERVICENAME]' Type='string' KeyPath='yes'/>
- <ServiceControl Id='DBInstanceServiceStop' Name='[SERVICENAME]' Stop='uninstall' Wait='yes'></ServiceControl>
- <ServiceControl Id='DBInstanceServiceStart' Name='[SERVICENAME]' Start='install' Wait='no'></ServiceControl>
- <ServiceControl Id='DBInstanceServiceRemove' Name='[SERVICENAME]' Remove='uninstall' Wait='yes'></ServiceControl>
- </Component>
- </Feature>
-
- <CustomAction Id="QtExecDeferredExampleWithProperty_Cmd" Property="QtExecDeferredExampleWithProperty"
- Value="&quot;[#F.bin.mysql_install_db.exe]&quot; &quot;--service=[SERVICENAME]&quot; &quot;--password=[ROOT_PASSWORD]&quot; &quot;--datadir=[DATABASELOCATION]&quot;"
- Execute="immediate"/>
- <CustomAction Id="QtExecDeferredExampleWithProperty" BinaryKey="WixCA" DllEntry="CAQuietExec"
- Execute="deferred" Return="check" Impersonate="no"/>
-
- <UI>
- <ProgressText Action="QtExecDeferredExampleWithProperty">Running mysql_install_db.exe</ProgressText>
- </UI>
-
- <!-- Use Wix toolset "remember property" pattern to store properties between major upgrades etc -->
- <InstallExecuteSequence>
- <Custom Action="QtExecDeferredExampleWithProperty_Cmd" After="CostFinalize"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Custom>
- <Custom Action="QtExecDeferredExampleWithProperty" After="InstallFiles"><![CDATA[&DBInstance=3 AND NOT !DBInstance=3]]></Custom>
- </InstallExecuteSequence>
-
- <Property Id='SERVICENAME'>
- <RegistrySearch Id='ServiceNameProperty' Root='HKLM'
- Key='SOFTWARE\[Manufacturer]\[ProductName]'
- Name='ServiceName' Type='raw' />
- </Property>
- <SetProperty After='AppSearch' Id="SERVICENAME" Value="MariaDB_51"><![CDATA[NOT SERVICENAME]]></SetProperty>
- <Property Id="DATABASELOCATION">
- <RegistrySearch Id='DatabaseLocationProperty' Root='HKLM'
- Key='SOFTWARE\[Manufacturer]\[ProductName]'
- Name='´DatabaseLocation' Type='raw' />
- </Property>
- <SetProperty After='AppSearch' Id="DATABASELOCATION" Value="[CommonAppDataFolder]\MariaDB\[ProductName]"><![CDATA[NOT DATABASELOCATION]]></SetProperty>
- <CustomAction Id='SaveCmdLineValue_SERVICENAME' Property='CMDLINE_SERVICENAME'
- Value='[SERVICENAME]' Execute='firstSequence' />
- <CustomAction Id='SetFromCmdLineValue_SERVICENAME' Property='SERVICENAME' Value='[CMDLINE_SERVICENAME]' Execute='firstSequence' />
- <CustomAction Id='SaveCmdLineValue_DATABASELOCATION' Property='CMDLINE_DATABASELOCATION'
- Value='[DATABASELOCATION]' Execute='firstSequence' />
- <CustomAction Id='SetFromCmdLineValue_DATABASELOCATION' Property='DATABASELOCATION' Value='[CMDLINE_DATABASELOCATION]' Execute='firstSequence' />
-
- <InstallUISequence>
- <Custom Action='SaveCmdLineValue_SERVICENAME' Before='AppSearch' />
- <Custom Action='SetFromCmdLineValue_SERVICENAME' After='AppSearch'>CMDLINE_SERVICENAME</Custom>
- <Custom Action='SaveCmdLineValue_DATABASELOCATION' Before='AppSearch' />
- <Custom Action='SetFromCmdLineValue_DATABASELOCATION' After='AppSearch'>CMDLINE_DATABASELOCATION</Custom>
- </InstallUISequence>
- <InstallExecuteSequence>
- <Custom Action='SaveCmdLineValue_SERVICENAME' Before='AppSearch' />
- <Custom Action='SetFromCmdLineValue_SERVICENAME' After='AppSearch'>CMDLINE_SERVICENAME</Custom>
- <Custom Action='SaveCmdLineValue_DATABASELOCATION' Before='AppSearch' />
- <Custom Action='SetFromCmdLineValue_DATABASELOCATION' After='AppSearch'>CMDLINE_DATABASELOCATION</Custom>
- </InstallExecuteSequence>
- </Fragment>
-</Wix> \ No newline at end of file
diff --git a/win/packaging/extra.wxs.in b/win/packaging/extra.wxs.in
index b55994af4bd..d4fcce17445 100644
--- a/win/packaging/extra.wxs.in
+++ b/win/packaging/extra.wxs.in
@@ -692,7 +692,7 @@
<CustomAction Id="CreateDatabaseRollbackCommand" Property="CreateDatabaseRollback"
Value="[SERVICENAME]\[DATADIR]"
Execute="immediate"/>
- <CustomAction Id="CreateDatabase" BinaryKey="WixCA" DllEntry="CAQuietExec"
+ <CustomAction Id="CreateDatabase" BinaryKey="WixCA" DllEntry="@CA_QUIET_EXEC@"
Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="CreateDatabaseRollback" BinaryKey="wixca.dll" DllEntry="CreateDatabaseRollback"
Execute="rollback" Return="check" Impersonate="no"/>