summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-02-19 17:26:32 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2019-02-19 17:26:32 +0100
commit055c09ad6b94365b29d2132c2da99f019c74d269 (patch)
treeb5e694a4c6c7a73494762d7f54c9114e14c9098e
parent75bb5e457c268baf8f8956595669fcea4ed04fe2 (diff)
parentfc124778ea4e3d0d6bc35d816b367d0ed470bf0c (diff)
downloadmariadb-git-055c09ad6b94365b29d2132c2da99f019c74d269.tar.gz
Merge branch '10.3' into bb-10.3-merge
-rw-r--r--client/mysqltest.cc59
-rw-r--r--cmake/submodules.cmake12
-rw-r--r--extra/mariabackup/backup_copy.cc13
-rw-r--r--extra/mariabackup/xtrabackup.cc10
-rw-r--r--include/my_sys.h1
-rw-r--r--mysql-test/main/constraints.result17
-rw-r--r--mysql-test/main/constraints.test20
-rw-r--r--mysql-test/suite/innodb/include/ibd_convert.pl23
-rw-r--r--mysql-test/suite/innodb/r/alter_kill.result2
-rw-r--r--mysql-test/suite/innodb/r/foreign_key.result13
-rw-r--r--mysql-test/suite/innodb/r/undo_truncate_recover.result1
-rw-r--r--mysql-test/suite/innodb/t/101_compatibility.test3
-rw-r--r--mysql-test/suite/innodb/t/alter_kill.test33
-rw-r--r--mysql-test/suite/innodb/t/doublewrite.test12
-rw-r--r--mysql-test/suite/innodb/t/foreign_key.test11
-rw-r--r--mysql-test/suite/innodb/t/log_corruption.test75
-rw-r--r--mysql-test/suite/innodb/t/row_format_redundant.test8
-rw-r--r--mysql-test/suite/innodb/t/table_flags.test8
-rw-r--r--mysql-test/suite/innodb/t/undo_truncate_recover.test3
-rw-r--r--mysql-test/suite/mariabackup/huge_lsn.test8
-rw-r--r--mysql-test/suite/mariabackup/incremental_rocksdb.opt1
-rw-r--r--mysql-test/suite/mariabackup/incremental_rocksdb.result19
-rw-r--r--mysql-test/suite/mariabackup/incremental_rocksdb.test38
-rw-r--r--mysys/my_delete.c61
-rw-r--r--mysys/my_open.c5
-rw-r--r--sql/field.cc1
-rw-r--r--sql/item_func.cc11
-rw-r--r--sql/table.cc25
-rw-r--r--storage/heap/heapdef.h1
-rw-r--r--storage/heap/hp_hash.c135
-rw-r--r--storage/innobase/dict/dict0dict.cc49
-rw-r--r--storage/innobase/include/trx0rseg.h4
-rw-r--r--storage/innobase/log/log0recv.cc11
-rw-r--r--storage/innobase/srv/srv0start.cc6
-rw-r--r--storage/maria/ma_delete.c2
-rw-r--r--storage/maria/ma_write.c3
-rw-r--r--storage/maria/maria_def.h4
37 files changed, 386 insertions, 322 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index fbb24c799f7..82aa73939ac 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -4019,63 +4019,6 @@ void do_mkdir(struct st_command *command)
}
-/*
- Remove directory recursively.
-*/
-static int rmtree(const char *dir)
-{
- char path[FN_REFLEN];
- char sep[]={ FN_LIBCHAR, 0 };
- int err=0;
-
- MY_DIR *dir_info= my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT));
- if (!dir_info)
- return 1;
-
- for (uint i= 0; i < dir_info->number_of_files; i++)
- {
- FILEINFO *file= dir_info->dir_entry + i;
- /* Skip "." and ".." */
- if (!strcmp(file->name, ".") || !strcmp(file->name, ".."))
- continue;
-
- strxnmov(path, sizeof(path), dir, sep, file->name, NULL);
-
- if (!MY_S_ISDIR(file->mystat->st_mode))
- {
- err= my_delete(path, 0);
-#ifdef _WIN32
- /*
- On Windows, check and possible reset readonly attribute.
- my_delete(), or DeleteFile does not remove theses files.
- */
- if (err)
- {
- DWORD attr= GetFileAttributes(path);
- if (attr != INVALID_FILE_ATTRIBUTES &&
- (attr & FILE_ATTRIBUTE_READONLY))
- {
- SetFileAttributes(path, attr &~ FILE_ATTRIBUTE_READONLY);
- err= my_delete(path, 0);
- }
- }
-#endif
- }
- else
- err= rmtree(path);
-
- if(err)
- break;
- }
-
- my_dirend(dir_info);
-
- if (!err)
- err= rmdir(dir);
-
- return err;
-}
-
/*
SYNOPSIS
@@ -4103,7 +4046,7 @@ void do_rmdir(struct st_command *command)
DBUG_VOID_RETURN;
DBUG_PRINT("info", ("removing directory: %s", ds_dirname.str));
- if (rmtree(ds_dirname.str))
+ if (my_rmtree(ds_dirname.str, MYF(0)))
handle_command_error(command, 1, errno);
dynstr_free(&ds_dirname);
diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake
index 4181f4cd01e..34d1f37c956 100644
--- a/cmake/submodules.cmake
+++ b/cmake/submodules.cmake
@@ -10,7 +10,12 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE cmake_update_submodules
RESULT_VARIABLE git_config_get_result)
- IF(git_config_get_result EQUAL 128 OR cmake_update_submodules MATCHES no)
+ IF(cmake_update_submodules MATCHES no)
+ SET(update_result 0)
+ SET(SUBMODULE_UPDATE_CONFIG_MESSAGE
+"\n\nTo update submodules automatically, set cmake.update-submodules to 'yes', or 'force' to update automatically:
+ ${GIT_EXECUTABLE} config cmake.update-submodules yes")
+ ELSEIF(git_config_get_result EQUAL 128)
SET(update_result 0)
ELSEIF (cmake_update_submodules MATCHES force)
MESSAGE(STATUS "Updating submodules (forced)")
@@ -31,7 +36,6 @@ ENDIF()
IF(update_result OR NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt)
MESSAGE(FATAL_ERROR "No MariaDB Connector/C! Run
- git submodule update --init
-Then restart the build.
-")
+ ${GIT_EXECUTABLE} submodule update --init
+Then restart the build.${SUBMODULE_UPDATE_CONFIG_MESSAGE}")
ENDIF()
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index fcbecd6dfe8..5e529e665e1 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -1629,8 +1629,21 @@ ibx_copy_incremental_over_full()
}
}
+ if (directory_exists(ROCKSDB_BACKUP_DIR, false)) {
+ if (my_rmtree(ROCKSDB_BACKUP_DIR, MYF(0))) {
+ die("Can't remove " ROCKSDB_BACKUP_DIR);
+ }
+ }
+ snprintf(path, sizeof(path), "%s/" ROCKSDB_BACKUP_DIR, xtrabackup_incremental_dir);
+ if (directory_exists(path, false)) {
+ if (my_mkdir(ROCKSDB_BACKUP_DIR, 0777, MYF(0))) {
+ die("my_mkdir failed for " ROCKSDB_BACKUP_DIR);
+ }
+ copy_or_move_dir(path, ROCKSDB_BACKUP_DIR, true, true);
+ }
}
+
cleanup:
if (it != NULL) {
datadir_iter_free(it);
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 62e0a4b47cf..3e64a4f3afb 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -799,7 +799,6 @@ enum options_xtrabackup
OPT_INNODB_LOG_CHECKSUMS,
OPT_XTRA_INCREMENTAL_FORCE_SCAN,
OPT_DEFAULTS_GROUP,
- OPT_INNODB_ENCRYPT_LOG,
OPT_CLOSE_FILES,
OPT_CORE_FILE,
@@ -1369,10 +1368,6 @@ struct my_option xb_server_options[] =
&xb_plugin_dir, &xb_plugin_dir,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
- { "innodb-encrypt-log", OPT_INNODB_ENCRYPT_LOG, "Whether to encrypt innodb log",
- &srv_encrypt_log, &srv_encrypt_log,
- 0, GET_BOOL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
-
{"innodb-log-checksums", OPT_INNODB_LOG_CHECKSUMS,
"Whether to require checksums for InnoDB redo log blocks",
&innodb_log_checksums, &innodb_log_checksums,
@@ -2757,7 +2752,10 @@ static bool xtrabackup_copy_logfile(bool last = false)
log_mutex_exit();
if (!start_lsn) {
- die("xtrabackup_copy_logfile() failed.");
+ msg(recv_sys->found_corrupt_log
+ ? "xtrabackup_copy_logfile() failed: corrupt log."
+ : "xtrabackup_copy_logfile() failed.");
+ return true;
}
} while (start_lsn == end_lsn);
diff --git a/include/my_sys.h b/include/my_sys.h
index 9a3acffe41d..ddaceff8708 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -630,6 +630,7 @@ extern int (*mysys_test_invalid_symlink)(const char *filename);
extern int my_copy(const char *from,const char *to,myf MyFlags);
extern int my_delete(const char *name,myf MyFlags);
+extern int my_rmtree(const char *name, myf Myflags);
extern int my_getwd(char * buf,size_t size,myf MyFlags);
extern int my_setwd(const char *dir,myf MyFlags);
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
diff --git a/mysql-test/main/constraints.result b/mysql-test/main/constraints.result
index 3c061989fd3..aba226cdd33 100644
--- a/mysql-test/main/constraints.result
+++ b/mysql-test/main/constraints.result
@@ -111,3 +111,20 @@ long_enough_name CREATE TABLE `long_enough_name` (
CONSTRAINT `constr` CHECK (`f6` >= 0)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE long_enough_name;
+create table t1 (a int check (a>10)) select 100 as 'a';
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL CHECK (`a` > 10)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a text default(length(now())) check (length(a) > 1));
+insert into t1 values ();
+insert into t1 values ("ccc");
+insert into t1 values ("");
+ERROR 23000: CONSTRAINT `t1.a` failed for `test`.`t1`
+select * from t1;
+a
+19
+ccc
+drop table t1;
diff --git a/mysql-test/main/constraints.test b/mysql-test/main/constraints.test
index fe51e5060dc..c06f585d04f 100644
--- a/mysql-test/main/constraints.test
+++ b/mysql-test/main/constraints.test
@@ -102,3 +102,23 @@ SELECT * FROM long_enough_name AS tbl;
SHOW CREATE TABLE long_enough_name;
DROP TABLE long_enough_name;
+
+#
+# Check that we don't loose constraints as part of CREATE ... SELECT
+#
+
+create table t1 (a int check (a>10)) select 100 as 'a';
+show create table t1;
+drop table t1;
+
+#
+# Check that we constraints on field with default expressions work
+#
+
+create table t1 (a text default(length(now())) check (length(a) > 1));
+insert into t1 values ();
+insert into t1 values ("ccc");
+--error ER_CONSTRAINT_FAILED
+insert into t1 values ("");
+select * from t1;
+drop table t1;
diff --git a/mysql-test/suite/innodb/include/ibd_convert.pl b/mysql-test/suite/innodb/include/ibd_convert.pl
index 9327de6d79a..dfa29ee14d1 100644
--- a/mysql-test/suite/innodb/include/ibd_convert.pl
+++ b/mysql-test/suite/innodb/include/ibd_convert.pl
@@ -19,9 +19,26 @@ sub convert_to_mariadb_101
{
warn "$file: changing $flags to $badflags\n";
substr ($_, 54, 4) = pack("N", $badflags);
- # Replace the innodb_checksum_algorithm=none checksum
- substr ($_, 0, 4) = pack("N", 0xdeadbeef);
- substr ($_, $page_size - 8, 4) = pack("N", 0xdeadbeef);
+ # Compute and replace the innodb_checksum_algorithm=crc32 checksum
+ my $polynomial = 0x82f63b78; # CRC-32C
+ if ($page_size == 1024)
+ {
+ # ROW_FORMAT=COMPRESSED
+ substr($_,0,4)=pack("N",
+ mycrc32(substr($_, 4, 12), 0, $polynomial) ^
+ mycrc32(substr($_, 24, 2), 0, $polynomial) ^
+ mycrc32(substr($_, 34, $page_size - 34), 0,
+ $polynomial));
+ }
+ else
+ {
+ my $ck=pack("N",
+ mycrc32(substr($_, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($_, 38, $page_size - 38 - 8), 0,
+ $polynomial));
+ substr($_, 0, 4) = $ck;
+ substr ($_, $page_size - 8, 4) = $ck;
+ }
syswrite(FILE, $_, $page_size)==$page_size||die "Unable to write $file\n";
}
close(FILE);
diff --git a/mysql-test/suite/innodb/r/alter_kill.result b/mysql-test/suite/innodb/r/alter_kill.result
index 87c89834ec1..4188031eed9 100644
--- a/mysql-test/suite/innodb/r/alter_kill.result
+++ b/mysql-test/suite/innodb/r/alter_kill.result
@@ -12,7 +12,7 @@ connection default;
# Cleanly shutdown mysqld
disconnect con1;
# Corrupt FIL_PAGE_OFFSET in bug16720368.ibd,
-# and update the checksum to the "don't care" value.
+# and recompute innodb_checksum_algorithm=crc32
# Restart mysqld
# This will succeed after a clean shutdown, due to
# fil_open_single_table_tablespace(check_space_id=FALSE).
diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result
index b8b25732451..a6322284923 100644
--- a/mysql-test/suite/innodb/r/foreign_key.result
+++ b/mysql-test/suite/innodb/r/foreign_key.result
@@ -248,6 +248,19 @@ Warnings:
Warning 1088 failed to load FOREIGN KEY constraints
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
DROP TABLE t1;
+#
+# MDEV-18630 Conditional jump or move depends on uninitialised value
+# in ib_push_warning / dict_create_foreign_constraints_low
+#
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+ALTER IGNORE TABLE t1 ADD FOREIGN KEY (a) REFERENCES t2 (b);
+ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
+SHOW WARNINGS;
+Level Code Message
+Warning 150 Alter table test/#sql-temporary with foreign key constraint failed. Referenced table `test`.`t2` not found in the data dictionary near 'FOREIGN KEY (a) REFERENCES t2 (b)'.
+Error 1005 Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
+Warning 1215 Cannot add foreign key constraint for `t1`
+DROP TABLE t1;
# Start of 10.2 tests
#
# MDEV-13246 Stale rows despite ON DELETE CASCADE constraint
diff --git a/mysql-test/suite/innodb/r/undo_truncate_recover.result b/mysql-test/suite/innodb/r/undo_truncate_recover.result
index 2619f384847..bcfc136e8c0 100644
--- a/mysql-test/suite/innodb/r/undo_truncate_recover.result
+++ b/mysql-test/suite/innodb/r/undo_truncate_recover.result
@@ -9,6 +9,7 @@ update t1 set c = 'MariaDB';
update t1 set c = 'InnoDB';
set global debug_dbug = '+d,ib_undo_trunc';
commit;
+call mtr.add_suppression("InnoDB: innodb_undo_tablespaces=0 disables dedicated undo log tablespaces");
call mtr.add_suppression("InnoDB: The redo log transaction size ");
SET GLOBAL innodb_fast_shutdown=0;
FOUND 1 /ib_undo_trunc/ in mysqld.1.err
diff --git a/mysql-test/suite/innodb/t/101_compatibility.test b/mysql-test/suite/innodb/t/101_compatibility.test
index 470f543cd91..eb1ec3b26ac 100644
--- a/mysql-test/suite/innodb/t/101_compatibility.test
+++ b/mysql-test/suite/innodb/t/101_compatibility.test
@@ -42,6 +42,7 @@ perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "ti");
ib_restore_tablespaces("test", "ti");
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
do "$ENV{MTR_SUITE_DIR}/include/ibd_convert.pl";
my $ps = $ENV{INNODB_PAGE_SIZE};
my $dd = $ENV{MYSQLD_DATADIR};
@@ -62,6 +63,7 @@ INSERT INTO ti VALUES(1);
--source include/kill_mysqld.inc
perl;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
do "$ENV{MTR_SUITE_DIR}/include/ibd_convert.pl";
my $ps = $ENV{INNODB_PAGE_SIZE};
my $dd = $ENV{MYSQLD_DATADIR};
@@ -81,6 +83,7 @@ CHECK TABLE tr,tc,td,tz,tdd,tp,ti;
--source include/shutdown_mysqld.inc
perl;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
do "$ENV{MTR_SUITE_DIR}/include/ibd_convert.pl";
my $ps = $ENV{INNODB_PAGE_SIZE};
my $dd = $ENV{MYSQLD_DATADIR};
diff --git a/mysql-test/suite/innodb/t/alter_kill.test b/mysql-test/suite/innodb/t/alter_kill.test
index 8de9781c972..2a130a6ed2c 100644
--- a/mysql-test/suite/innodb/t/alter_kill.test
+++ b/mysql-test/suite/innodb/t/alter_kill.test
@@ -44,13 +44,23 @@ connection default;
disconnect con1;
-- echo # Corrupt FIL_PAGE_OFFSET in bug16720368.ibd,
--- echo # and update the checksum to the "don't care" value.
+-- echo # and recompute innodb_checksum_algorithm=crc32
perl;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
-print FILE pack("H*","deadbeefc001cafe") || die "Unable to write $file";
-seek(FILE, $ENV{PAGE_SIZE}-8, 0) || die "Unable to seek $file";
-print FILE pack("H*","deadbeef") || die "Unable to write $file";
+binmode FILE;
+my $ps= $ENV{PAGE_SIZE};
+my $page;
+die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
+substr($page,4,4)=pack("N",0xc001cafe);
+my $polynomial = 0x82f63b78; # CRC-32C
+my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
+substr($page,0,4)=$ck;
+substr($page,$ps-8,4)=$ck;
+sysseek(FILE, 0, 0) || die "Unable to rewind $file\n";
+syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file";
EOF
@@ -97,10 +107,21 @@ SELECT COUNT(*) FROM bug16720368;
# Uncorrupt the FIL_PAGE_OFFSET.
perl;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd";
open(FILE, "+<$file") || die "Unable to open $file";
-# Uncorrupt FIL_PAGE_OFFSET.
-print FILE pack("H*","deadbeef00000000") || die "Unable to write $file";
+binmode FILE;
+my $ps= $ENV{PAGE_SIZE};
+my $page;
+die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
+substr($page,4,4)=pack("N",0);
+my $polynomial = 0x82f63b78; # CRC-32C
+my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
+substr($page,0,4)=$ck;
+substr($page,$ps-8,4)=$ck;
+sysseek(FILE, 0, 0) || die "Unable to rewind $file\n";
+syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file";
EOF
diff --git a/mysql-test/suite/innodb/t/doublewrite.test b/mysql-test/suite/innodb/t/doublewrite.test
index bdeaba2dcec..a5b2ffef4c8 100644
--- a/mysql-test/suite/innodb/t/doublewrite.test
+++ b/mysql-test/suite/innodb/t/doublewrite.test
@@ -73,6 +73,9 @@ set global innodb_buf_flush_list_now = 1;
perl;
use IO::Handle;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
+my $polynomial = 0x82f63b78; # CRC-32C
+
my $fname= "$ENV{'MYSQLD_DATADIR'}test/t1.ibd";
my $page_size = $ENV{INNODB_PAGE_SIZE};
my $page;
@@ -102,9 +105,12 @@ for (my $d = $d1; $d < $d2 + 64; $d++)
$badflags |= ($flags & 15 << 6) << 7; # PAGE_SSIZE
substr ($_, 54, 4) = pack("N", $badflags);
- # Replace the innodb_checksum_algorithm=none checksum
- substr ($_, 0, 4) = pack("N", 0xdeadbeef);
- substr ($_, $page_size - 8, 4) = pack("N", 0xdeadbeef);
+ # Replace the innodb_checksum_algorithm=crc32 checksum
+ my $ck= pack("N",
+ mycrc32(substr($_, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($_, 38, $page_size - 38 - 8), 0, $polynomial));
+ substr ($_, 0, 4) = $ck;
+ substr ($_, $page_size - 8, 4) = $ck;
syswrite(FILE, $_, $page_size)==$page_size||die;
close(FILE);
exit 0;
diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test
index 9de69b7a22d..4330f807d69 100644
--- a/mysql-test/suite/innodb/t/foreign_key.test
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@ -230,6 +230,17 @@ ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f);
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
DROP TABLE t1;
+--echo #
+--echo # MDEV-18630 Conditional jump or move depends on uninitialised value
+--echo # in ib_push_warning / dict_create_foreign_constraints_low
+--echo #
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+--error ER_CANT_CREATE_TABLE
+ALTER IGNORE TABLE t1 ADD FOREIGN KEY (a) REFERENCES t2 (b);
+--replace_regex /#sql-[0-9_a-f-]*/#sql-temporary/
+SHOW WARNINGS;
+DROP TABLE t1;
+
--echo # Start of 10.2 tests
--echo #
diff --git a/mysql-test/suite/innodb/t/log_corruption.test b/mysql-test/suite/innodb/t/log_corruption.test
index e9b081cff76..3d68724f7a9 100644
--- a/mysql-test/suite/innodb/t/log_corruption.test
+++ b/mysql-test/suite/innodb/t/log_corruption.test
@@ -33,55 +33,60 @@ EOF
--let $dirs= --innodb-data-home-dir=$bugdir --innodb-log-group-home-dir=$bugdir
perl;
+do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
# Create a dummy system tablespace file using the default innodb_page_size=16k
die unless open OUT, ">", "$ENV{bugdir}/ibdata1";
binmode OUT;
+# We calculate innodb_checksum_algorithm=crc32 for the pages.
+# The following bytes are excluded:
+# bytes 0..3 (the checksum is stored there)
+# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id)
+# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN)
+my $polynomial = 0x82f63b78; # CRC-32C
+
# Tablespace header page with valid FSP_SIZE=768 pages.
# Also, write a dummy FSEG_MAGIC_N at offset 60 to keep fseg_inode_try_get()
# happy when fseg_n_reserved_pages() is following an invalid pointer
# from the all-zero change buffer header page (page 3).
-print OUT pack("Nx[42]Nx[10]Nx[16312]Nx[4]",
- 0xdeadbeef, # checksum
- 768, # FSP_PAGE_SIZE
- 97937874, # FSEG_MAGIC_N
- 0xdeadbeef); # checksum
+## FIL_PAGE_OFFSET
+my $head = pack("Nx[18]", 0);
+## FSP_PAGE_SIZE, # FSEG_MAGIC_N
+my $body = pack("x[8]Nx[10]Nx[16312]", 768, 97937874);
+my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
+print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck);
# Dummy pages 1..6.
print OUT chr(0) x (6 * 16384);
-# Dictionary header page.
-print OUT pack("NNx[62]Nx[8]Nx[16290]Nx[4]",
- 0xdeadbeef, # checksum
- 7, # FIL_PAGE_OFFSET
- 8, # DICT_HDR_TABLES
- 9, # DICT_HDR_INDEXES
- 0xdeadbeef); # checksum
+# Dictionary header page (page 7).
+## FIL_PAGE_OFFSET
+$head = pack("Nx[18]", 7);
+## DICT_HDR_TABLES,DICT_HDR_INDEXES
+$body = pack("x[32]Nx[8]Nx[16290]", 8, 9);
+$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
+print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck);
# Empty SYS_TABLES page (page 8).
-print OUT pack("NNNNx[8]nx[12]nnx[31]Cx[20]",
- 0xdeadbeef, # checksum
- 8, # FIL_PAGE_OFFSET
- ~0, ~0, # FIL_PAGE_PREV, FIL_PAGE_NEXT
- 17855, # FIL_PAGE_TYPE == FIL_PAGE_INDEX
- 2, # PAGE_N_DIR_SLOTS
- 124, # PAGE_HEAP_TOP
- 1); # PAGE_INDEX_ID == DICT_TABLES_ID
-print OUT pack("nxnn", 0x801, 3, 116), "infimum";
-print OUT pack("xnxnxx", 0x901, 0x803), "supremum";
-print OUT pack("x[16248]nnNx[4]", 116, 101, 0xdeadbeef);
+## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE
+$head = pack("NNNx[8]n", 8, ~0, ~0, 17855);
+## PAGE_N_DIR_SLOTS, PAGE_HEAP_TOP, PAGE_INDEX_ID == DICT_TABLES_ID
+$body = pack("nnx[31]Cx[20]", 2, 124, 1);
+$body .= pack("nxnn", 0x801, 3, 116) . "infimum";
+$body .= pack("xnxnxx", 0x901, 0x803) . "supremum";
+$body .= pack("x[16248]nn", 116, 101);
+$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
+print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck);
# Empty SYS_INDEXES page (page 9).
-print OUT pack("NNNNx[8]nx[12]nnx[31]Cx[20]",
- 0xdeadbeef, # checksum
- 9, # FIL_PAGE_OFFSET
- ~0, ~0, # FIL_PAGE_PREV, FIL_PAGE_NEXT
- 17855, # FIL_PAGE_TYPE == FIL_PAGE_INDEX
- 2, # PAGE_N_DIR_SLOTS
- 124, # PAGE_HEAP_TOP
- 3); # PAGE_INDEX_ID == DICT_INDEXES_ID
-
-print OUT pack("nxnn", 0x801, 3, 116), "infimum";
-print OUT pack("xnxnxx", 0x901, 0x803), "supremum";
-print OUT pack("x[16248]nnNx[4]", 116, 101, 0xdeadbeef);
+## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE
+$head = pack("NNNx[8]n", 9, ~0, ~0, 17855);
+## PAGE_N_DIR_SLOTS, PAGE_HEAP_TOP, PAGE_INDEX_ID == DICT_INDEXES_ID
+$body = pack("nnx[31]Cx[20]", 2, 124, 3);
+$body .= pack("nxnn", 0x801, 3, 116) . "infimum";
+$body .= pack("xnxnxx", 0x901, 0x803) . "supremum";
+$body .= pack("x[16248]nn", 116, 101);
+$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
+print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck);
+
print OUT chr(0) x (759 * 16384);
close OUT or die;
diff --git a/mysql-test/suite/innodb/t/row_format_redundant.test b/mysql-test/suite/innodb/t/row_format_redundant.test
index 81541fb0582..fc72e5c2664 100644
--- a/mysql-test/suite/innodb/t/row_format_redundant.test
+++ b/mysql-test/suite/innodb/t/row_format_redundant.test
@@ -92,6 +92,7 @@ TRUNCATE TABLE t3;
--source include/shutdown_mysqld.inc
--perl
use strict;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
my $ps= $ENV{INNODB_PAGE_SIZE};
my $file= "$ENV{bugdir}/ibdata1";
open(FILE, "+<", $file) || die "Unable to open $file\n";
@@ -120,8 +121,11 @@ for (my $offset= 0x65; $offset;
$start= $end & 0x7f;
}
}
-substr($page,0,4)=pack("N",0xdeadbeef);
-substr($page,$ps-8,4)=pack("N",0xdeadbeef);
+my $polynomial = 0x82f63b78; # CRC-32C
+my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
+substr($page,0,4)=$ck;
+substr($page,$ps-8,4)=$ck;
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file\n";
diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test
index e979b5fffe0..13e1fc01dc0 100644
--- a/mysql-test/suite/innodb/t/table_flags.test
+++ b/mysql-test/suite/innodb/t/table_flags.test
@@ -52,6 +52,7 @@ PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
--source include/shutdown_mysqld.inc
--perl
use strict;
+do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
my $ps= $ENV{INNODB_PAGE_SIZE};
my $file= "$ENV{bugdir}/ibdata1";
open(FILE, "+<", $file) || die "Unable to open $file\n";
@@ -127,8 +128,11 @@ for (my $offset= 0x65; $offset;
}
print ")\n";
}
-substr($page,0,4)=pack("N",0xdeadbeef);
-substr($page,$ps-8,4)=pack("N",0xdeadbeef);
+my $polynomial = 0x82f63b78; # CRC-32C
+my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
+substr($page,0,4)=$ck;
+substr($page,$ps-8,4)=$ck;
sysseek(FILE, $sys_tables_root*$ps, 0) || die "Unable to seek $file";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file\n";
diff --git a/mysql-test/suite/innodb/t/undo_truncate_recover.test b/mysql-test/suite/innodb/t/undo_truncate_recover.test
index 56647bcc567..c3fa698ff13 100644
--- a/mysql-test/suite/innodb/t/undo_truncate_recover.test
+++ b/mysql-test/suite/innodb/t/undo_truncate_recover.test
@@ -38,13 +38,14 @@ update t1 set c = 'MariaDB';
update t1 set c = 'InnoDB';
eval set global debug_dbug = '+d,$SEARCH_PATTERN';
commit;
+call mtr.add_suppression("InnoDB: innodb_undo_tablespaces=0 disables dedicated undo log tablespaces");
# FIXME: remove this work-around, and generate less log!
call mtr.add_suppression("InnoDB: The redo log transaction size ");
SET GLOBAL innodb_fast_shutdown=0;
--source include/shutdown_mysqld.inc
--source include/search_pattern_in_file.inc
# FIXME: remove this work-around, and generate less log!
---let $restart_parameters= --innodb-buffer-pool-size=16m
+--let $restart_parameters= --innodb-buffer-pool-size=16m --innodb-undo-tablespaces=1
--source include/start_mysqld.inc
drop table t1;
diff --git a/mysql-test/suite/mariabackup/huge_lsn.test b/mysql-test/suite/mariabackup/huge_lsn.test
index 9e72f0ad8d0..dcdc118df6f 100644
--- a/mysql-test/suite/mariabackup/huge_lsn.test
+++ b/mysql-test/suite/mariabackup/huge_lsn.test
@@ -11,6 +11,7 @@ let MYSQLD_DATADIR=`select @@datadir`;
--source include/shutdown_mysqld.inc
perl;
+do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
my $file= "$ENV{MYSQLD_DATADIR}/ibdata1";
open(FILE, "+<", $file) or die "Unable to open $file\n";
binmode FILE;
@@ -18,8 +19,11 @@ my $ps= $ENV{INNODB_PAGE_SIZE};
my $page;
die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
substr($page,26,8) = pack("NN", 4096, ~1024);
-substr($page,0,4)=pack("N",0xdeadbeef);
-substr($page,$ps-8,4)=pack("N",0xdeadbeef);
+my $polynomial = 0x82f63b78; # CRC-32C
+my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
+ mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
+substr($page,0,4)=$ck;
+substr($page,$ps-8,4)=$ck;
sysseek(FILE, 0, 0) || die "Unable to rewind $file\n";
syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file\n";
diff --git a/mysql-test/suite/mariabackup/incremental_rocksdb.opt b/mysql-test/suite/mariabackup/incremental_rocksdb.opt
new file mode 100644
index 00000000000..e582413e5b5
--- /dev/null
+++ b/mysql-test/suite/mariabackup/incremental_rocksdb.opt
@@ -0,0 +1 @@
+--plugin-load=$HA_ROCKSDB_SO \ No newline at end of file
diff --git a/mysql-test/suite/mariabackup/incremental_rocksdb.result b/mysql-test/suite/mariabackup/incremental_rocksdb.result
new file mode 100644
index 00000000000..4e5b9c43389
--- /dev/null
+++ b/mysql-test/suite/mariabackup/incremental_rocksdb.result
@@ -0,0 +1,19 @@
+call mtr.add_suppression("InnoDB: New log files created");
+CREATE TABLE t(i INT PRIMARY KEY) ENGINE ROCKSDB;
+INSERT INTO t VALUES(1);
+# Create full backup , modify table, then create incremental/differential backup
+DROP TABLE t;
+CREATE TABLE t2(i INT PRIMARY KEY) ENGINE ROCKSDB;
+INSERT INTO t2 VALUES(2);
+# Prepare full backup, apply incremental one
+# Restore and check results
+# shutdown server
+# remove datadir
+# xtrabackup move back
+# restart server
+SELECT * FROM t2;
+i
+2
+DROP TABLE t2;
+DROP TABLE t;
+ERROR 42S02: Unknown table 'test.t'
diff --git a/mysql-test/suite/mariabackup/incremental_rocksdb.test b/mysql-test/suite/mariabackup/incremental_rocksdb.test
new file mode 100644
index 00000000000..32bce885c32
--- /dev/null
+++ b/mysql-test/suite/mariabackup/incremental_rocksdb.test
@@ -0,0 +1,38 @@
+--source include/have_rocksdb.inc
+call mtr.add_suppression("InnoDB: New log files created");
+
+let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
+let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1;
+
+CREATE TABLE t(i INT PRIMARY KEY) ENGINE ROCKSDB;
+INSERT INTO t VALUES(1);
+
+echo # Create full backup , modify table, then create incremental/differential backup;
+--disable_result_log
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir;
+--enable_result_log
+DROP TABLE t;
+CREATE TABLE t2(i INT PRIMARY KEY) ENGINE ROCKSDB;
+INSERT INTO t2 VALUES(2);
+exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir;
+
+--disable_result_log
+echo # Prepare full backup, apply incremental one;
+exec $XTRABACKUP --prepare --target-dir=$basedir;
+
+exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir ;
+
+echo # Restore and check results;
+let $targetdir=$basedir;
+-- source include/restart_and_restore.inc
+--enable_result_log
+
+SELECT * FROM t2;
+DROP TABLE t2;
+--error ER_BAD_TABLE_ERROR
+DROP TABLE t;
+
+# Cleanup
+rmdir $basedir;
+rmdir $incremental_dir;
+
diff --git a/mysys/my_delete.c b/mysys/my_delete.c
index beece473a01..c7023b61df0 100644
--- a/mysys/my_delete.c
+++ b/mysys/my_delete.c
@@ -18,6 +18,7 @@
#include <my_sys.h>
#ifdef _WIN32
+#include <direct.h> /* rmdir */
static int my_win_unlink(const char *name);
#endif
@@ -160,3 +161,63 @@ error:
DBUG_RETURN(-1);
}
#endif
+
+/*
+ Remove directory recursively.
+*/
+int my_rmtree(const char *dir, myf MyFlags)
+{
+ char path[FN_REFLEN];
+ char sep[] = { FN_LIBCHAR, 0 };
+ int err = 0;
+ uint i;
+
+ MY_DIR *dir_info = my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT));
+ if (!dir_info)
+ return 1;
+
+ for (i = 0; i < dir_info->number_of_files; i++)
+ {
+ FILEINFO *file = dir_info->dir_entry + i;
+ /* Skip "." and ".." */
+ if (!strcmp(file->name, ".") || !strcmp(file->name, ".."))
+ continue;
+
+ strxnmov(path, sizeof(path), dir, sep, file->name, NULL);
+
+ if (!MY_S_ISDIR(file->mystat->st_mode))
+ {
+ err = my_delete(path, MyFlags);
+#ifdef _WIN32
+ /*
+ On Windows, check and possible reset readonly attribute.
+ my_delete(), or DeleteFile does not remove theses files.
+ */
+ if (err)
+ {
+ DWORD attr = GetFileAttributes(path);
+ if (attr != INVALID_FILE_ATTRIBUTES &&
+ (attr & FILE_ATTRIBUTE_READONLY))
+ {
+ SetFileAttributes(path, attr &~FILE_ATTRIBUTE_READONLY);
+ err = my_delete(path, MyFlags);
+ }
+ }
+#endif
+ }
+ else
+ err = my_rmtree(path, MyFlags);
+
+ if (err)
+ break;
+ }
+
+ my_dirend(dir_info);
+
+ if (!err)
+ err = rmdir(dir);
+
+ return err;
+}
+
+
diff --git a/mysys/my_open.c b/mysys/my_open.c
index 54e53089da9..92e46610100 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -89,10 +89,7 @@ int my_close(File fd, myf MyFlags)
my_file_info[fd].type= UNOPEN;
}
#ifndef _WIN32
- do
- {
- err= close(fd);
- } while (err == -1 && errno == EINTR);
+ err= close(fd);
#else
err= my_win_close(fd);
#endif
diff --git a/sql/field.cc b/sql/field.cc
index 4dfc671609f..61213fa8569 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -11047,6 +11047,7 @@ Column_definition::redefine_stage1_common(const Column_definition *dup_field,
interval= dup_field->interval;
vcol_info= dup_field->vcol_info;
invisible= dup_field->invisible;
+ check_constraint= dup_field->check_constraint;
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 3c299ebabbe..9fcde96c58e 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6515,17 +6515,17 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (m_sp->agg_type() == GROUP_AGGREGATE)
{
- List<Item> list;
- list.empty();
- for (uint i=0; i < arg_count; i++)
- list.push_back(*(args+i));
-
Item_sum_sp *item_sp;
Query_arena *arena, backup;
arena= thd->activate_stmt_arena_if_needed(&backup);
if (arg_count)
+ {
+ List<Item> list;
+ for (uint i= 0; i < arg_count; i++)
+ list.push_back(args[i]);
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp, list);
+ }
else
item_sp= new (thd->mem_root) Item_sum_sp(thd, context, m_name, sp);
@@ -6539,7 +6539,6 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
if (err)
DBUG_RETURN(TRUE);
- list.empty();
DBUG_RETURN(FALSE);
}
diff --git a/sql/table.cc b/sql/table.cc
index 8660575ef4b..10543a1b4f0 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -51,7 +51,8 @@
static Virtual_column_info * unpack_vcol_info_from_frm(THD *, MEM_ROOT *,
TABLE *, String *, Virtual_column_info **, bool *);
-static bool check_vcol_forward_refs(Field *, Virtual_column_info *);
+static bool check_vcol_forward_refs(Field *, Virtual_column_info *,
+ bool check_constraint);
/* INFORMATION_SCHEMA name */
LEX_CSTRING INFORMATION_SCHEMA_NAME= {STRING_WITH_LEN("information_schema")};
@@ -1135,9 +1136,9 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
Field *field= *field_ptr;
- if (check_vcol_forward_refs(field, field->vcol_info) ||
- check_vcol_forward_refs(field, field->check_constraint) ||
- check_vcol_forward_refs(field, field->default_value))
+ if (check_vcol_forward_refs(field, field->vcol_info, 0) ||
+ check_vcol_forward_refs(field, field->check_constraint, 1) ||
+ check_vcol_forward_refs(field, field->default_value, 0))
goto end;
}
@@ -3087,11 +3088,19 @@ end:
DBUG_RETURN(vcol_info);
}
-static bool check_vcol_forward_refs(Field *field, Virtual_column_info *vcol)
+static bool check_vcol_forward_refs(Field *field, Virtual_column_info *vcol,
+ bool check_constraint)
{
- bool res= vcol &&
- vcol->expr->walk(&Item::check_field_expression_processor, 0,
- field);
+ bool res;
+ uint32 flags= field->flags;
+ if (check_constraint)
+ {
+ /* Check constraints can refer it itself */
+ field->flags|= NO_DEFAULT_VALUE_FLAG;
+ }
+ res= (vcol &&
+ vcol->expr->walk(&Item::check_field_expression_processor, 0, field));
+ field->flags= flags;
return res;
}
diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h
index 4fcdffb66b1..fa1f559e211 100644
--- a/storage/heap/heapdef.h
+++ b/storage/heap/heapdef.h
@@ -81,7 +81,6 @@ extern uchar *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const uchar *key,
uint nextflag);
extern uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo,
const uchar *key, HASH_INFO *pos);
-extern ulong hp_hashnr(HP_KEYDEF *keyinfo,const uchar *key);
extern ulong hp_rec_hashnr(HP_KEYDEF *keyinfo,const uchar *rec);
extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link,
HASH_INFO *newlink);
diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c
index 46ac0270300..d90b7731600 100644
--- a/storage/heap/hp_hash.c
+++ b/storage/heap/hp_hash.c
@@ -19,6 +19,7 @@
#include "heapdef.h"
#include <m_ctype.h>
+static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key);
/*
Find out how many rows there is in the given range
@@ -209,11 +210,9 @@ void hp_movelink(HASH_INFO *pos, HASH_INFO *next_link, HASH_INFO *newlink)
return;
}
-#ifndef NEW_HASH_FUNCTION
-
/* Calc hashvalue for a key */
-ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key)
+static ulong hp_hashnr(HP_KEYDEF *keydef, const uchar *key)
{
/*register*/
ulong nr=1, nr2=4;
@@ -350,136 +349,6 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
return(nr);
}
-#else
-
-/*
- * Fowler/Noll/Vo hash
- *
- * The basis of the hash algorithm was taken from an idea sent by email to the
- * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and
- * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com)
- * later improved on their algorithm.
- *
- * The magic is in the interesting relationship between the special prime
- * 16777619 (2^24 + 403) and 2^32 and 2^8.
- *
- * This hash produces the fewest collisions of any function that we've seen so
- * far, and works well on both numbers and strings.
- */
-
-ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key)
-{
- /*
- Note, if a key consists of a combination of numeric and
- a text columns, it most likely won't work well.
- Making text columns work with NEW_HASH_FUNCTION
- needs also changes in strings/ctype-xxx.c.
- */
- ulong nr= 1, nr2= 4;
- HA_KEYSEG *seg,*endseg;
-
- for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
- {
- uchar *pos=(uchar*) key;
- key+=seg->length;
- if (seg->null_bit)
- {
- key++;
- if (*pos)
- {
- nr^= (nr << 1) | 1;
- /* Add key pack length (2) to key for VARCHAR segments */
- if (seg->type == HA_KEYTYPE_VARTEXT1)
- key+= 2;
- continue;
- }
- pos++;
- }
- if (seg->type == HA_KEYTYPE_TEXT)
- {
- seg->charset->coll->hash_sort(seg->charset, pos, ((uchar*)key)-pos,
- &nr, &nr2);
- }
- else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
- {
- uint pack_length= 2; /* Key packing is constant */
- uint length= uint2korr(pos);
- seg->charset->coll->hash_sort(seg->charset, pos+pack_length, length,
- &nr, &nr2);
- key+= pack_length;
- }
- else
- {
- for ( ; pos < (uchar*) key ; pos++)
- {
- nr *=16777619;
- nr ^=(uint) *pos;
- }
- }
- }
-#ifdef ONLY_FOR_HASH_DEBUGGING
- DBUG_PRINT("exit", ("hash: 0x%lx", nr));
-#endif
- return(nr);
-}
-
- /* Calc hashvalue for a key in a record */
-
-ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec)
-{
- ulong nr= 1, nr2= 4;
- HA_KEYSEG *seg,*endseg;
-
- for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++)
- {
- uchar *pos=(uchar*) rec+seg->start;
- if (seg->null_bit)
- {
- if (rec[seg->null_pos] & seg->null_bit)
- {
- nr^= (nr << 1) | 1;
- continue;
- }
- }
- if (seg->type == HA_KEYTYPE_TEXT)
- {
- uint char_length= seg->length; /* TODO: fix to use my_charpos() */
- seg->charset->coll->hash_sort(seg->charset, pos, char_length,
- &nr, &nr2);
- }
- else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */
- {
- uint pack_length= seg->bit_start;
- uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos));
- seg->charset->coll->hash_sort(seg->charset, pos+pack_length,
- length, &nr, &nr2);
- }
- else
- {
- uchar *end= pos+seg->length;
- if (seg->type == HA_KEYTYPE_BIT && seg->bit_length)
- {
- uchar bits= get_rec_bits(rec + seg->bit_pos,
- seg->bit_start, seg->bit_length);
- nr *=16777619;
- nr ^=(uint) bits;
- end--;
- }
- for ( ; pos < end ; pos++)
- {
- nr *=16777619;
- nr ^=(uint) *pos;
- }
- }
- }
-#ifdef ONLY_FOR_HASH_DEBUGGING
- DBUG_PRINT("exit", ("hash: 0x%lx", nr));
-#endif
- return(nr);
-}
-
-#endif
-
/*
Compare keys for two records. Returns 0 if they are identical
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index d123ed8db03..0da8f178d5d 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -4305,7 +4305,6 @@ dict_create_foreign_constraints_low(
const char* create_table_name;
const char* orig;
char create_name[MAX_TABLE_NAME_LEN + 1];
- char operation[8];
ut_ad(!srv_read_only_mode);
ut_ad(mutex_own(&dict_sys->mutex));
@@ -4316,41 +4315,33 @@ dict_create_foreign_constraints_low(
orig = ptr;
ptr = dict_accept(cs, ptr, "ALTER", &success);
- strcpy((char *)operation, success ? "Alter " : "Create ");
+ const char* const operation = success ? "Alter " : "Create ";
if (!success) {
orig = ptr;
ptr = dict_scan_to(ptr, "CREATE");
ptr = dict_scan_to(ptr, "TABLE");
ptr = dict_accept(cs, ptr, "TABLE", &success);
+ create_table_name = NULL;
if (success) {
ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
- &success, heap, &create_table_name);
+ &success, heap, &create_table_name);
}
- if (success) {
- char *bufend;
- bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
- create_table_name, strlen(create_table_name),
- trx->mysql_thd);
- create_name[bufend-create_name]='\0';
- ptr = orig;
- } else {
- char *bufend;
- ptr = orig;
- bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
- name, strlen(name), trx->mysql_thd);
- create_name[bufend-create_name]='\0';
- }
-
- goto loop;
+ ptr = orig;
+ const char* n = create_table_name ? create_table_name : name;
+ char *bufend = innobase_convert_name(create_name, MAX_TABLE_NAME_LEN,
+ n, strlen(n), trx->mysql_thd);
+ create_name[bufend-create_name] = '\0';
+ } else {
+ strncpy(create_name, name, sizeof create_name);
+ create_name[(sizeof create_name) - 1] = '\0';
}
if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, create_name);
- dict_foreign_error_report_low(ef, create_name);
fprintf(ef, "%s table %s with foreign key constraint"
" failed. Table %s not found from data dictionary."
" Error close to %s.\n",
@@ -4385,19 +4376,13 @@ dict_create_foreign_constraints_low(
ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
&success, heap, &referenced_table_name);
- if (table_to_alter) {
- char *bufend;
- bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
- table_to_alter->name.m_name, strlen(table_to_alter->name.m_name),
- trx->mysql_thd);
- create_name[bufend-create_name]='\0';
- } else {
- char *bufend;
- bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
- referenced_table_name, strlen(referenced_table_name),
- trx->mysql_thd);
+ {
+ const char* n = table_to_alter
+ ? table_to_alter->name.m_name : referenced_table_name;
+ char* bufend = innobase_convert_name(
+ create_name, MAX_TABLE_NAME_LEN, n, strlen(n),
+ trx->mysql_thd);
create_name[bufend-create_name]='\0';
-
}
if (!success) {
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index dbd80486b71..a89b82c7a43 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -194,7 +194,7 @@ struct trx_rseg_t {
|| (srv_undo_space_id_start > 0
&& space->id >= srv_undo_space_id_start
&& space->id <= srv_undo_space_id_start
- + srv_undo_tablespaces_active)
+ + srv_undo_tablespaces_open)
|| !srv_was_started);
return(space->id != SRV_TMP_SPACE_ID);
}
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index bca05fb3681..2a303bd4419 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -2,7 +2,7 @@
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2018, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -800,7 +800,9 @@ loop:
happen when InnoDB was killed while it was
writing redo log. We simply treat this as an
abrupt end of the redo log. */
+fail:
end_lsn = *start_lsn;
+ success = false;
break;
}
@@ -822,9 +824,7 @@ loop:
<< log_block_get_checkpoint_no(buf)
<< " expected: " << crc
<< " found: " << cksum;
- end_lsn = *start_lsn;
- success = false;
- break;
+ goto fail;
}
if (is_encrypted()) {
@@ -838,8 +838,7 @@ loop:
|| (dl > OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE
&& dl != OS_FILE_LOG_BLOCK_SIZE)) {
recv_sys->found_corrupt_log = true;
- end_lsn = *start_lsn;
- break;
+ goto fail;
}
}
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 9faf1509c10..d733cabf2b0 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -3,7 +3,7 @@
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2018, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -2323,6 +2323,7 @@ files_checked:
thread_started[2 + SRV_MAX_N_IO_THREADS] = true;
lock_sys.timeout_thread_active = true;
+ DBUG_EXECUTE_IF("innodb_skip_monitors", goto skip_monitors;);
/* Create the thread which warns of long semaphore waits */
srv_error_monitor_active = true;
thread_handles[3 + SRV_MAX_N_IO_THREADS] = os_thread_create(
@@ -2339,6 +2340,9 @@ files_checked:
srv_start_state |= SRV_START_STATE_LOCK_SYS
| SRV_START_STATE_MONITOR;
+#ifndef DBUG_OFF
+skip_monitors:
+#endif
ut_ad(srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN
|| !purge_sys.enabled());
diff --git a/storage/maria/ma_delete.c b/storage/maria/ma_delete.c
index b4b02212a16..2fe20d09bab 100644
--- a/storage/maria/ma_delete.c
+++ b/storage/maria/ma_delete.c
@@ -695,9 +695,7 @@ static int del(MARIA_HA *info, MARIA_KEY *key,
key_start= keypos;
if (tmp_key.flag & (SEARCH_USER_KEY_HAS_TRANSID |
SEARCH_PAGE_KEY_HAS_TRANSID))
- {
_ma_mark_page_with_transid(share, anc_page);
- }
/* Save pointer to next leaf on parent page */
if (!(*keyinfo->get_key)(&ret_key, page_flag, share->base.key_reflength,
diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c
index c2b521e3c02..52eefa33bc3 100644
--- a/storage/maria/ma_write.c
+++ b/storage/maria/ma_write.c
@@ -844,9 +844,8 @@ int _ma_insert(register MARIA_HA *info, MARIA_KEY *key,
a_length+=t_length;
if (key->flag & (SEARCH_USER_KEY_HAS_TRANSID | SEARCH_PAGE_KEY_HAS_TRANSID))
- {
_ma_mark_page_with_transid(share, anc_page);
- }
+
anc_page->size= a_length;
page_store_size(share, anc_page);
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index dd2e2949856..519beb0a7c9 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -779,8 +779,8 @@ struct st_maria_handler
transid_korr((buff) + LSN_STORE_SIZE)
#define _ma_store_keypage_flag(share,x,flag) x[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (flag)
#define _ma_mark_page_with_transid(share, page) \
- (page)->flag|= KEYPAGE_FLAG_HAS_TRANSID; \
- (page)->buff[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (page)->flag;
+ do { (page)->flag|= KEYPAGE_FLAG_HAS_TRANSID; \
+ (page)->buff[(share)->keypage_header - KEYPAGE_USED_SIZE - KEYPAGE_FLAG_SIZE]= (page)->flag; } while (0)
#define KEYPAGE_KEY_VERSION(share, x) ((x) + \
(share)->keypage_header - \