diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-05-25 09:15:08 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-05-25 09:15:08 +0300 |
commit | 3cc8539d84f569f4829874bf36f4b44b0ceb030c (patch) | |
tree | cc4cf6561f81b4d6b33af1dc5da888e6baff59af | |
parent | 956d93b581b704fa56b0b6469ae35a2e79850ef4 (diff) | |
parent | 1ace1075dc6bb02fe19802334f9d47446a17a79a (diff) | |
download | mariadb-git-3cc8539d84f569f4829874bf36f4b44b0ceb030c.tar.gz |
Merge 10.9 into 10.10
457 files changed, 14586 insertions, 3138 deletions
diff --git a/.travis.compiler.sh b/.travis.compiler.sh deleted file mode 100755 index c140f15d66d..00000000000 --- a/.travis.compiler.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -set -v -x - -# Exclude modules from build not directly affecting the current -# test suites found in $MYSQL_TEST_SUITES, to conserve job time -# as well as disk usage - -function exclude_modules() { -# excludes for all -CMAKE_OPT="${CMAKE_OPT} -DPLUGIN_MROONGA=NO -DPLUGIN_SPIDER=NO -DPLUGIN_OQGRAPH=NO -DPLUGIN_PERFSCHEMA=NO -DPLUGIN_SPHINX=NO" -# exclude storage engines not being tested in current job -if [[ ! "${MYSQL_TEST_SUITES}" =~ "archive" ]]; then - CMAKE_OPT="${CMAKE_OPT} -DPLUGIN_ARCHIVE=NO" -fi -if [[ ! "${MYSQL_TEST_SUITES}" =~ "rocksdb" ]]; then - CMAKE_OPT="${CMAKE_OPT} -DPLUGIN_ROCKSDB=NO" -fi -} - -if [[ "${TRAVIS_OS_NAME}" == 'linux' ]]; then - TEST_CASE_TIMEOUT=2 - exclude_modules; - if which ccache ; then - CMAKE_OPT="${CMAKE_OPT} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" - fi - if [[ "${CXX}" == 'clang++' ]]; then - if [[ "${CC_VERSION}" == '6' ]]; then - export CXX=${CXX}-${CC_VERSION}.0 - else - export CXX=${CXX}-${CC_VERSION} - fi - export CC=${CXX/++/} - # excess warnings about unused include path - export CFLAGS='-Wno-unused-command-line-argument' - export CXXFLAGS='-Wno-unused-command-line-argument' - elif [[ "${CXX}" == 'g++' ]]; then - export CXX=g++-${CC_VERSION} - export CC=gcc-${CC_VERSION} - fi - if [[ ${CC_VERSION} == 7 ]]; then - export WSREP_PROVIDER=/usr/lib/galera/libgalera_smm.so - MYSQL_TEST_SUITES="${MYSQL_TEST_SUITES},wsrep" - fi -fi - -if [[ "${TRAVIS_OS_NAME}" == 'osx' ]]; then - TEST_CASE_TIMEOUT=20 - exclude_modules; - CMAKE_OPT="${CMAKE_OPT} -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" - if which ccache ; then - CMAKE_OPT="${CMAKE_OPT} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" - fi -fi - -set +v +x diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5c227b49b09..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,240 +0,0 @@ -# vim ft=yaml -# travis-ci.org definition - -# NOTE TO MERGERS: Most of the contents in the Travis-CI configuration has been -# tailored for a specific release or MariaDB. As a general rule, do not merge -# changes in this file across MariaDB branches to avoid breaking the CI. Updates -# the the Travis-CI pipeline are most of the time better done manually. - -dist: focal - -git: - depth: 2 - -language: cpp - -cache: - timeout: 500 - apt: true - ccache: true - -addons: - apt: - sources: &add-sources - # Remember to document well what packages each extra repository is used for - - ubuntu-toolchain-r-test - # => gcc-9 and gcc-10 for Ubuntu Bionic - # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test/+packages?field.name_filter=&field.status_filter=published&field.series_filter=bionic - - sourceline: 'ppa:maria-captains/travis-ci-helper-repo' - # => galera-4 for Ubuntu Bionic - # https://launchpad.net/~maria-captains/+archive/ubuntu/travis-ci-helper-repo/+packages?field.name_filter=&field.status_filter=published&field.series_filter=bionic - packages: &common-packages - # Remember to update this list if the Debian build dependencies are updated - - bison - - chrpath - - clang-7 # In suites: focal, bionic-updates - - clang-10 # In suites: focal, bionic - - cmake - - cracklib-runtime - - galera-4 # In suites: focal, bionic (via ppa:maria-captains/travis-ci-helper-repo) - - g++-7 # In suites: focal, bionic - - g++-10 # In suites: focal, bionic (via ppa:ubuntu-toolchain-r/test) - - gdb - - libaio-dev - - libarchive-dev - - libboost-atomic-dev - - libboost-chrono-dev - - libboost-date-time-dev - - libboost-dev - - libboost-filesystem-dev - - libboost-regex-dev - - libboost-system-dev - - libboost-thread-dev - - libcrack2-dev - - libcurl4-openssl-dev - - libdbd-mysql - - libedit-dev - - libjemalloc-dev - - libjudy-dev - - libkrb5-dev - - liblz4-dev - - libncurses5-dev - - libnuma-dev - - libpam0g-dev - - libpcre2-dev - - libpmem-dev - - libreadline-gplv2-dev - - libsnappy-dev - - libssl-dev - - libxml2-dev - - lsb-release - - perl - - psmisc - - uuid-dev - - zlib1g-dev - # libsystemd-daemon-dev # https://github.com/travis-ci/apt-package-whitelist/issues/3882 - homebrew: - # OSX builds are not properly maintained on Travis-CI nor buildbot and - # thus this list of dependencies is likely to be inaccurate. - packages: - - bison - - boost - - ccache - - cmake - - cracklib - - curl - - gnutls - - groonga - - jemalloc - - libxml2 - - lz4 - - lzo - - ncurses - - openssl@1.1 - - ossp-uuid - - pcre2 - - perl - - pkg-config - - readline - - snappy - - xz - - zlib - - zstd - -## Build jobs matrix -# The jobs matrix consists of all the combinations of 'arch', 'os', 'compiler' -# and 'env'. Ensure there is a good variation of architectures and at least the -# main suite is run on all architectures, as the main test suite needs to pass -# on all architectures (amd64, arm64, ppc64le, s390x) before a release is made. -# -# In gcc and clang use a fairly old version and one very recent and assume that -# if both of them built successfully all the intermediate version work as well. -arch: amd64 -os: linux -compiler: - - gcc - - clang -env: - - CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=archive,optimizer_unfixed_bugs,parts,sys_vars,unit,vcol,innodb,innodb_gis,innodb_zip,innodb_fts - - CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=binlog,binlog_encryption,rocksdb,versioning,rpl - - CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=csv,federated,funcs_1,funcs_2,gcol,handler,heap,json,maria,perfschema,plugins,multi_source,roles,encryption - - CC_VERSION=10 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main - -jobs: - # Define extra jobs that are run in addition to the main jobs matrix - include: - - os: linux - compiler: gcc - env: DebPackages=focal - addons: &deb-addons - apt: - sources: *add-sources - # make sure these match debian/control contents - packages: - - *common-packages - - debhelper - - devscripts - - dh-apparmor - - dh-exec - - dh-systemd - - fakeroot - - libsystemd-dev - - libzstd-dev - - po-debconf - - unixodbc-dev - script: &deb-script - - ${CC} --version ; ${CXX} --version - - apt-cache policy - - env DEB_BUILD_OPTIONS="parallel=4" debian/autobake-deb.sh; - - os: linux - dist: bionic - arch: s390x - compiler: gcc - env: DebPackages=bionic - addons: *deb-addons - script: *deb-script - # Just one OS X build is enough - - os: osx - osx_image: xcode12u - compiler: clang - env: CC_VERSION=10 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main - # Some chosen ones with s390x and gcc - - os: linux - arch: s390x - compiler: gcc - env: CC_VERSION=10 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main - - os: linux - arch: s390x - compiler: gcc - env: CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=binlog,binlog_encryption,encryption,rocksdb,versioning,rpl - # Some chosen ones with s390x and clang - - os: linux - arch: s390x - compiler: clang - env: CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=archive,optimizer_unfixed_bugs,parts,sys_vars,unit,vcol,innodb,innodb_gis,innodb_zip,innodb_fts - - os: linux - arch: s390x - compiler: clang - env: CC_VERSION=10 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=csv,federated,funcs_1,funcs_2,gcol,handler,heap,json,maria,perfschema,plugins,multi_source,roles - # Extra tests to ensure IBM Power and ARM 64 work - - os: linux - arch: ppc64le - compiler: gcc - env: CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main - - os: linux - arch: arm64 - compiler: gcc - env: CC_VERSION=7 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main - - allow_failures: - # Permanently fails on main.column_compression 'innodb' test (MDEV-23954) - - os: linux - arch: s390x - compiler: gcc - env: CC_VERSION=10 TYPE=RelWithDebInfo MYSQL_TEST_SUITES=main - # Until OSX becomes a bit more stable - - os: osx - # ppc64el builder frequently runs out of memory - - arch: ppc64le - -before_install: - - if [[ "${TRAVIS_OS_NAME}" == 'osx' ]]; then - brew update; - brew install gnutls lz4 lzo xz snappy ccache jemalloc curl ossp-uuid pcre zstd; - brew link ccache; - export PATH="/usr/local/opt/ccache/libexec:$PATH"; - fi - -before_script: - - df -h - - ccache --version - - ccache --show-stats - - ccache --max-size=5G - -script: -# following modules are disabled after sourcing .travis.compiler.sh: -# clang disabled: mroonga just generates too many warnings with clang and travis stops the job -# gcc/rpl: mroonga - - source .travis.compiler.sh - - cmake . - -DCMAKE_BUILD_TYPE=${TYPE} - ${CMAKE_OPT} - -DWITH_SSL=system -DWITH_ZLIB=system - - make -j 4 - - cd mysql-test - - travis_wait 30 ./mtr --force --max-test-fail=20 --parallel=4 --testcase-timeout=${TEST_CASE_TIMEOUT} - --suite=${MYSQL_TEST_SUITES} - --skip-test=binlog.binlog_unsafe - -after_script: - - ccache --show-stats - - df -h - -notifications: - irc: - channels: - - "chat.freenode.net#maria" - on_success: never # [always|never|change] - on_failure: never - template: - - "%{repository}/%{branch} (%{commit} - %{author}): %{build_url}: %{message}" diff --git a/client/mysqldump.c b/client/mysqldump.c index 1ba7545fac3..9c796cf0bac 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2883,6 +2883,9 @@ static uint dump_routines_for_db(char *db) create_caption_xml[i]); continue; } + + switch_sql_mode(sql_file, ";", row[1]); + if (opt_drop) fprintf(sql_file, "/*!50003 DROP %s IF EXISTS %s */;\n", routine_type[i], routine_name); @@ -2922,9 +2925,6 @@ static uint dump_routines_for_db(char *db) "--\n"); } - - switch_sql_mode(sql_file, ";", row[1]); - fprintf(sql_file, "DELIMITER ;;\n" "%s ;;\n" @@ -5442,6 +5442,55 @@ int init_dumping_views(char *qdatabase __attribute__((unused))) /* +mysql specific database initialization. + +SYNOPSIS + init_dumping_mysql_tables + + protections around dumping general/slow query log + qdatabase quoted name of the "mysql" database + +RETURN VALUES + 0 Success. + 1 Failure. +*/ +static int init_dumping_mysql_tables(char *qdatabase) +{ + DBUG_ENTER("init_dumping_mysql_tables"); + + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!50106 SET @save_log_output=@@LOG_OUTPUT*/;\n" + "/*M!100203 EXECUTE IMMEDIATE IF(@@LOG_OUTPUT='TABLE' AND (@@SLOW_QUERY_LOG=1 OR @@GENERAL_LOG=1)," + "\"SET GLOBAL LOG_OUTPUT='NONE'\", \"DO 0\") */;\n"); + + DBUG_RETURN(init_dumping_tables(qdatabase)); +} + + +static void dump_first_mysql_tables(char *database) +{ + char table_type[NAME_LEN]; + char ignore_flag; + DBUG_ENTER("dump_first_mysql_tables"); + + if (!get_table_structure((char *) "general_log", + database, table_type, &ignore_flag, NULL) ) + verbose_msg("-- Warning: get_table_structure() failed with some internal " + "error for 'general_log' table\n"); + if (!get_table_structure((char *) "slow_log", + database, table_type, &ignore_flag, NULL) ) + verbose_msg("-- Warning: get_table_structure() failed with some internal " + "error for 'slow_log' table\n"); + /* general and slow query logs exist now */ + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!50106 SET GLOBAL LOG_OUTPUT=@save_log_output*/;\n\n"); + DBUG_VOID_RETURN; +} + + +/* Table Specific database initialization. SYNOPSIS @@ -5547,7 +5596,6 @@ static int dump_all_tables_in_db(char *database) char table_buff[NAME_LEN*2+3]; char hash_key[2*NAME_LEN+2]; /* "db.tablename" */ char *afterdot; - my_bool general_log_table_exists= 0, slow_log_table_exists=0; my_bool transaction_registry_table_exists= 0; int using_mysql_db= !my_strcasecmp(charset_info, database, "mysql"); DBUG_ENTER("dump_all_tables_in_db"); @@ -5555,11 +5603,15 @@ static int dump_all_tables_in_db(char *database) afterdot= strmov(hash_key, database); *afterdot++= '.'; - if (init_dumping(database, init_dumping_tables)) + if (init_dumping(database, using_mysql_db ? init_dumping_mysql_tables + : init_dumping_tables)) DBUG_RETURN(1); if (opt_xml) print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS); + if (using_mysql_db) + dump_first_mysql_tables(database); + if (lock_tables) { DYNAMIC_STRING query; @@ -5648,24 +5700,16 @@ static int dump_all_tables_in_db(char *database) else { /* - If general_log and slow_log exists in the 'mysql' database, + If transaction_registry exists in the 'mysql' database, we should dump the table structure. But we cannot call get_table_structure() here as 'LOCK TABLES' query got executed above on the session and that 'LOCK TABLES' query does not contain - 'general_log' and 'slow_log' tables. (you cannot acquire lock - on log tables). Hence mark the existence of these log tables here and + 'transaction_registry'. Hence mark the existence of the table here and after 'UNLOCK TABLES' query is executed on the session, get the table structure from server and dump it in the file. */ - if (using_mysql_db) - { - if (!my_strcasecmp(charset_info, table, "general_log")) - general_log_table_exists= 1; - else if (!my_strcasecmp(charset_info, table, "slow_log")) - slow_log_table_exists= 1; - else if (!my_strcasecmp(charset_info, table, "transaction_registry")) - transaction_registry_table_exists= 1; - } + if (using_mysql_db && !my_strcasecmp(charset_info, table, "transaction_registry")) + transaction_registry_table_exists= 1; } } @@ -5686,39 +5730,25 @@ static int dump_all_tables_in_db(char *database) DBUG_PRINT("info", ("Dumping routines for database %s", database)); dump_routines_for_db(database); } - if (opt_xml) - { - fputs("</database>\n", md_result_file); - check_io(md_result_file); - } if (lock_tables) (void) mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES"); if (using_mysql_db) { - char table_type[NAME_LEN]; - char ignore_flag; - if (general_log_table_exists) - { - if (!get_table_structure((char *) "general_log", - database, table_type, &ignore_flag, NULL) ) - verbose_msg("-- Warning: get_table_structure() failed with some internal " - "error for 'general_log' table\n"); - } - if (slow_log_table_exists) - { - if (!get_table_structure((char *) "slow_log", - database, table_type, &ignore_flag, NULL) ) - verbose_msg("-- Warning: get_table_structure() failed with some internal " - "error for 'slow_log' table\n"); - } if (transaction_registry_table_exists) { + char table_type[NAME_LEN]; + char ignore_flag; if (!get_table_structure((char *) "transaction_registry", database, table_type, &ignore_flag, NULL) ) verbose_msg("-- Warning: get_table_structure() failed with some internal " "error for 'transaction_registry' table\n"); } } + if (opt_xml) + { + fputs("</database>\n", md_result_file); + check_io(md_result_file); + } if (flush_privileges && using_mysql_db) { fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n"); diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 038251c40e2..c3ade74b3b3 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -23,6 +23,8 @@ ENDIF() SET(MY_WARNING_FLAGS -Wall -Wdeclaration-after-statement + -Wenum-compare + -Wenum-conversion -Wextra -Wformat-security -Wno-format-truncation diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index b0c6b81e630..0ac834f44a6 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -43,6 +43,7 @@ MACRO(BUNDLE_PCRE2) ENDFOREACH() FOREACH(v "" "_DEBUG" "_RELWITHDEBINFO" "_RELEASE" "_MINSIZEREL") STRING(REPLACE "/WX" "" pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") + SET(pcre2_flags${v} "${pcre2_flags${v}} -std=c99 ") IF(MSVC) # Suppress a warning STRING(APPEND pcre2_flags${v} " /wd4244 " ) @@ -53,8 +54,8 @@ MACRO(BUNDLE_PCRE2) ExternalProject_Add( pcre2 PREFIX "${dir}" - URL "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.zip" - URL_MD5 e101c0ca9edb4b0af103bebe78ba52b0 + URL "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.40/pcre2-10.40.zip" + URL_MD5 798698846982ce171d881ed0d7535c2a INSTALL_COMMAND "" CMAKE_ARGS "-DCMAKE_WARN_DEPRECATED=FALSE" diff --git a/config.h.cmake b/config.h.cmake index 44ae067daad..99acaf71bee 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -561,3 +561,5 @@ #endif // !defined(__STDC_FORMAT_MACROS) #endif + +#cmakedefine HAVE_VFORK 1 diff --git a/configure.cmake b/configure.cmake index 3996b4fbac0..2e0d7ed089e 100644 --- a/configure.cmake +++ b/configure.cmake @@ -983,3 +983,19 @@ IF(NOT MSVC) HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE ) ENDIF() + +MY_CHECK_C_COMPILER_FLAG("-Werror") +IF(have_C__Werror) + SET(SAVE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") + CHECK_C_SOURCE_COMPILES(" + #include <unistd.h> + int main() + { + pid_t pid=vfork(); + return (int)pid; + }" + HAVE_VFORK + ) + SET(CMAKE_REQUIRED_FLAGS ${SAVE_CMAKE_REQUIRED_FLAGS}) +ENDIF() diff --git a/debian/additions/debian-start b/debian/additions/debian-start index ffe635dc883..986fa80fd57 100755 --- a/debian/additions/debian-start +++ b/debian/additions/debian-start @@ -20,7 +20,7 @@ fi MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" # Don't run full mysql_upgrade on every server restart, use --version-check to do it only once -MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check" +MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check --silent" MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf" MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables" MYCHECK_PARAMS="--all-databases --fast --silent" diff --git a/debian/additions/mariadb-report b/debian/additions/mariadb-report index 5c9761e0710..ff73bb0e17e 100755 --- a/debian/additions/mariadb-report +++ b/debian/additions/mariadb-report @@ -239,26 +239,56 @@ sub get_user_mycnf sub connect_to_MySQL { - print "connect_to_MySQL\n" if $op{debug}; - - my $dsn; - - if($mycnf{'socket'} && -S $mycnf{'socket'}) - { - $dsn = "DBI:MariaDB:mariadb_socket=$mycnf{socket}"; - } - elsif($mycnf{'host'}) - { - $dsn = "DBI:MariaDB:host=$mycnf{host}" . ($mycnf{port} ? ";port=$mycnf{port}" : ""); - } - else - { - $dsn = "DBI:MariaDB:host=localhost"; - } - - print "connect_to_MySQL: DBI DSN: $dsn\n" if $op{debug}; - - $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die; + print "connect_to_MySQL\n" if $op{debug}; + + if(my @driverList = grep {/mariadb|mysql/i} DBI->available_drivers()) { + my $dsn; + my $driver = undef; + + if(grep {/mariadb/i} @driverList) + { + $driver = "DBI:MariaDB"; + } + elsif(grep {/mysql/i} @driverList) + { + $driver = "DBI:mysql"; + } + + if($mycnf{'socket'} && -S $mycnf{'socket'}) + { + if(grep {/mariadb/i} @driverList) + { + $dsn = $driver . ":mariadb_socket=$mycnf{socket}"; + } + elsif(grep {/mysql/i} @driverList) + { + $dsn = $driver . ":mysql_socket=$mycnf{socket}"; + } + } + elsif($mycnf{'host'}) + { + $dsn = $driver . ":host=$mycnf{host}" . ($mycnf{port} ? ";port=$mycnf{port}" : ""); + } + else + { + $dsn = $driver . ":host=localhost"; + } + + print "connect_to_MySQL: DBI DSN: " . $dsn . "\n" if $op{debug}; + + $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die; + } + else + { + print STDERR "Install Perl 5.x driver: DBD:mysql or DBD:MariaDB\n"; + print STDERR "currently installed Perl DBD drivers:\n"; + foreach my $driver (DBI->available_drivers()) + { + print STDERR " * " . $driver . "\n"; + } + print STDERR "\n"; + die("Exit as no MariaDB DBI driver found!\n"); + } } sub collect_reports diff --git a/debian/mariadb-server-core.install b/debian/mariadb-server-core.install index 93acce6cc7d..1a07a3fea94 100644 --- a/debian/mariadb-server-core.install +++ b/debian/mariadb-server-core.install @@ -14,6 +14,8 @@ usr/share/man/man1/mysql_upgrade.1 usr/share/man/man1/resolveip.1 usr/share/man/man8/mariadbd.8 usr/share/man/man8/mysqld.8 +usr/share/mysql/bulgarian +usr/share/mysql/chinese usr/share/mysql/charsets usr/share/mysql/czech usr/share/mysql/danish diff --git a/debian/mariadb-server.postrm b/debian/mariadb-server.postrm index 0d21955439f..035f10bbb8a 100644 --- a/debian/mariadb-server.postrm +++ b/debian/mariadb-server.postrm @@ -12,11 +12,9 @@ MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" # do it himself. No database directories should be removed while the server # is running! Another mariadbd in e.g. a different chroot is fine for us. stop_server() { - # Return immediately if there are no mysql processes running + # Return immediately if there are no mysqld processes running # as there is no point in trying to shutdown in that case. - if ! pgrep -x mariadbd > /dev/null; then return; fi - # Compatibility with versions that ran 'mysqld' - if ! pgrep -x mysqld > /dev/null; then return; fi + if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null; then return; fi set +e invoke-rc.d mariadb stop diff --git a/debian/mariadb-server.preinst b/debian/mariadb-server.preinst index 313a12ab5e7..755815eaeed 100644 --- a/debian/mariadb-server.preinst +++ b/debian/mariadb-server.preinst @@ -25,11 +25,10 @@ mysql_upgradedir=/var/lib/mysql-upgrade # do it himself. No database directories should be removed while the server # is running! Another mariadbd in e.g. a different chroot is fine for us. stop_server() { - # Return immediately if there are no mysql processes running + # Return immediately if there are no mysqld processes running on a host + # (leave containerized processes with the same name in other namespaces) # as there is no point in trying to shutdown in that case. - if ! pgrep -x --ns $$ mariadbd > /dev/null; then return; fi - # Compatibility with versions that ran 'mysqld' - if ! pgrep -x --ns $$ mysqld > /dev/null; then return; fi + if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null; then return; fi set +e invoke-rc.d mariadb stop diff --git a/debian/mariadb-test-data.lintian-overrides b/debian/mariadb-test-data.lintian-overrides index 4ff05a3be2a..630e9fcab1e 100644 --- a/debian/mariadb-test-data.lintian-overrides +++ b/debian/mariadb-test-data.lintian-overrides @@ -1,3 +1,25 @@ # These should be moved, see https://jira.mariadb.org/browse/MDEV-21654 arch-dependent-file-in-usr-share usr/share/mysql/mysql-test/suite/plugins/pam/pam_mariadb_mtr.so arch-independent-package-contains-binary-or-object usr/share/mysql/mysql-test/suite/plugins/pam/pam_mariadb_mtr.so +# Intentional for test files +national-encoding usr/share/mysql/mysql-test/* +# Extra test documentation files that really need to be kept in context in test directory +package-contains-documentation-outside-usr-share-doc usr/share/mysql/mysql-test/* +# Intentional directory structure +repeated-path-segment auth_gssapi usr/share/mysql/mysql-test/plugin/auth_gssapi/auth_gssapi/ +repeated-path-segment connect usr/share/mysql/mysql-test/plugin/connect/connect/ +repeated-path-segment disks usr/share/mysql/mysql-test/plugin/disks/disks/ +repeated-path-segment func_test usr/share/mysql/mysql-test/plugin/func_test/func_test/ +repeated-path-segment metadata_lock_info usr/share/mysql/mysql-test/plugin/metadata_lock_info/metadata_lock_info/ +repeated-path-segment mroonga usr/share/mysql/mysql-test/plugin/mroonga/mroonga/ +repeated-path-segment mroonga usr/share/mysql/mysql-test/plugin/mroonga/mroonga/include/mroonga/ +repeated-path-segment oqgraph usr/share/mysql/mysql-test/plugin/oqgraph/oqgraph/ +repeated-path-segment query_response_time usr/share/mysql/mysql-test/plugin/query_response_time/query_response_time/ +repeated-path-segment rocksdb usr/share/mysql/mysql-test/plugin/rocksdb/rocksdb/ +repeated-path-segment sequence usr/share/mysql/mysql-test/plugin/sequence/sequence/ +repeated-path-segment sphinx usr/share/mysql/mysql-test/plugin/sphinx/sphinx/ +repeated-path-segment spider usr/share/mysql/mysql-test/plugin/spider/spider/ +repeated-path-segment type_inet usr/share/mysql/mysql-test/plugin/type_inet/type_inet/ +repeated-path-segment type_test usr/share/mysql/mysql-test/plugin/type_test/type_test/ +repeated-path-segment user_variables usr/share/mysql/mysql-test/plugin/user_variables/user_variables/ +repeated-path-segment wsrep_info usr/share/mysql/mysql-test/plugin/wsrep_info/wsrep_info/ diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 6d980d662de..2065711b9c2 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -266,7 +266,8 @@ free_mysql_variables(mysql_variable *vars) static char * -read_mysql_one_value(MYSQL *connection, const char *query) +read_mysql_one_value(MYSQL *connection, const char *query, + uint column, uint expect_columns) { MYSQL_RES *mysql_result; MYSQL_ROW row; @@ -274,10 +275,10 @@ read_mysql_one_value(MYSQL *connection, const char *query) mysql_result = xb_mysql_query(connection, query, true); - ut_ad(mysql_num_fields(mysql_result) == 1); + ut_ad(mysql_num_fields(mysql_result) == expect_columns); if ((row = mysql_fetch_row(mysql_result))) { - result = strdup(row[0]); + result = strdup(row[column]); } mysql_free_result(mysql_result); @@ -285,6 +286,15 @@ read_mysql_one_value(MYSQL *connection, const char *query) return(result); } + +static +char * +read_mysql_one_value(MYSQL *mysql, const char *query) +{ + return read_mysql_one_value(mysql, query, 0/*offset*/, 1/*total columns*/); +} + + static bool check_server_version(unsigned long version_number, @@ -1078,92 +1088,327 @@ cleanup: } +class Var +{ + const char *m_name; + char *m_value; + /* + Disable copying constructors for safety, as the default binary copying + which would be wrong. If we ever want them, the m_value + member should be copied using an strdup()-alike function. + */ + Var(const Var &); // Disabled + Var(Var &); // Disabled +public: + ~Var() + { + free(m_value); + } + Var(const char *name) + :m_name(name), + m_value(NULL) + { } + // Init using a SHOW VARIABLES LIKE 'name' query + Var(const char *name, MYSQL *mysql) + :m_name(name) + { + char buf[128]; + my_snprintf(buf, sizeof(buf), "SHOW VARIABLES LIKE '%s'", m_name); + m_value= read_mysql_one_value(mysql, buf, 1/*offset*/, 2/*total columns*/); + } + /* + Init by name from a result set. + If the variable name is not found in the result set metadata field names, + it's value stays untouched. + */ + bool init(MYSQL_RES *mysql_result, MYSQL_ROW row) + { + MYSQL_FIELD *field= mysql_fetch_fields(mysql_result); + for (uint i= 0; i < mysql_num_fields(mysql_result); i++) + { + if (!strcmp(field[i].name, m_name)) + { + free(m_value); // In case it was initialized earlier + m_value= row[i] ? strdup(row[i]) : NULL; + return false; + } + } + return true; + } + void replace(char from, char to) + { + ut_ad(m_value); + for (char *ptr= strchr(m_value, from); ptr; ptr= strchr(ptr, from)) + *ptr= to; + } + + const char *value() const { return m_value; } + bool eq_value(const char *str, size_t length) const + { + return m_value && !strncmp(m_value, str, length) && m_value[length] == '\0'; + } + bool is_null_or_empty() const { return !m_value || !m_value[0]; } + bool print(String *to) const + { + ut_ad(m_value); + return to->append(m_value, strlen(m_value)); + } + bool print_quoted(String *to) const + { + ut_ad(m_value); + return to->append('\'') || to->append(m_value, strlen(m_value)) || + to->append('\''); + } + bool print_set_global(String *to) const + { + ut_ad(m_value); + return + to->append(STRING_WITH_LEN("SET GLOBAL ")) || + to->append(m_name, strlen(m_name)) || + to->append(STRING_WITH_LEN(" = '")) || + to->append(m_value, strlen(m_value)) || + to->append(STRING_WITH_LEN("';\n")); + } +}; + + +class Show_slave_status +{ + Var m_mariadb_connection_name; // MariaDB: e.g. 'master1' + Var m_master; // e.g. 'localhost' + Var m_filename; // e.g. 'source-bin.000002' + Var m_position; // a number + Var m_mysql_gtid_executed; // MySQL56: e.g. single '<UUID>:1-5" or multiline + // '<UUID1>:1-10,\n<UUID2>:1-20\n<UUID3>:1-30' + Var m_mariadb_using_gtid; // MariaDB: 'No','Slave_Pos','Current_Pos' + +public: + + Show_slave_status() + :m_mariadb_connection_name("Connection_name"), + m_master("Master_Host"), + m_filename("Relay_Master_Log_File"), + m_position("Exec_Master_Log_Pos"), + m_mysql_gtid_executed("Executed_Gtid_Set"), + m_mariadb_using_gtid("Using_Gtid") + { } + + void init(MYSQL_RES *res, MYSQL_ROW row) + { + m_mariadb_connection_name.init(res, row); + m_master.init(res, row); + m_filename.init(res, row); + m_position.init(res, row); + m_mysql_gtid_executed.init(res, row); + m_mariadb_using_gtid.init(res, row); + // Normalize + if (m_mysql_gtid_executed.value()) + m_mysql_gtid_executed.replace('\n', ' '); + } + + static void msg_is_not_slave() + { + msg("Failed to get master binlog coordinates " + "from SHOW SLAVE STATUS.This means that the server is not a " + "replication slave. Ignoring the --slave-info option"); + } + + bool is_mariadb_using_gtid() const + { + return !m_mariadb_using_gtid.eq_value("No", 2); + } + + static bool start_comment_chunk(String *to) + { + return to->length() ? to->append(STRING_WITH_LEN("; ")) : false; + } + + bool print_connection_name_if_set(String *to) const + { + if (!m_mariadb_connection_name.is_null_or_empty()) + return m_mariadb_connection_name.print_quoted(to) || to->append(' '); + return false; + } + + bool print_comment_master_identity(String *comment) const + { + if (comment->append(STRING_WITH_LEN("master "))) + return true; + if (!m_mariadb_connection_name.is_null_or_empty()) + return m_mariadb_connection_name.print_quoted(comment); + return comment->append(STRING_WITH_LEN("''")); // Default not named master + } + + bool print_using_master_log_pos(String *sql, String *comment) const + { + return + sql->append(STRING_WITH_LEN("CHANGE MASTER ")) || + print_connection_name_if_set(sql) || + sql->append(STRING_WITH_LEN("TO MASTER_LOG_FILE=")) || + m_filename.print_quoted(sql) || + sql->append(STRING_WITH_LEN(", MASTER_LOG_POS=")) || + m_position.print(sql) || + sql->append(STRING_WITH_LEN(";\n")) || + print_comment_master_identity(comment) || + comment->append(STRING_WITH_LEN(" filename ")) || + m_filename.print_quoted(comment) || + comment->append(STRING_WITH_LEN(" position ")) || + m_position.print_quoted(comment); + } + + bool print_mysql56(String *sql, String *comment) const + { + /* + SET @@GLOBAL.gtid_purged = '2174B383-5441-11E8-B90A-C80AA9429562:1-1029, ' + '224DA167-0C0C-11E8-8442-00059A3C7B00:1-2695'; + CHANGE MASTER TO MASTER_AUTO_POSITION=1; + */ + return + sql->append(STRING_WITH_LEN("SET GLOBAL gtid_purged=")) || + m_mysql_gtid_executed.print_quoted(sql) || + sql->append(STRING_WITH_LEN(";\n")) || + sql->append(STRING_WITH_LEN("CHANGE MASTER TO MASTER_AUTO_POSITION=1;\n")) || + print_comment_master_identity(comment) || + comment->append(STRING_WITH_LEN(" purge list ")) || + m_mysql_gtid_executed.print_quoted(comment); + } + + bool print_mariadb10_using_gtid(String *sql, String *comment) const + { + return + sql->append(STRING_WITH_LEN("CHANGE MASTER ")) || + print_connection_name_if_set(sql) || + sql->append(STRING_WITH_LEN("TO master_use_gtid = slave_pos;\n")) || + print_comment_master_identity(comment) || + comment->append(STRING_WITH_LEN(" master_use_gtid = slave_pos")); + } + + bool print(String *sql, String *comment, const Var >id_slave_pos) const + { + if (!m_mysql_gtid_executed.is_null_or_empty()) + { + /* MySQL >= 5.6 with GTID enabled */ + return print_mysql56(sql, comment); + } + + if (!gtid_slave_pos.is_null_or_empty() && is_mariadb_using_gtid()) + { + /* MariaDB >= 10.0 with GTID enabled */ + return print_mariadb10_using_gtid(sql, comment); + } + + return print_using_master_log_pos(sql, comment); + } + + /* + Get master info into strings "sql" and "comment" from a MYSQL_RES. + @return false on success + @return true on error + */ + static bool get_slave_info(MYSQL_RES *show_slave_info_result, + const Var >id_slave_pos, + String *sql, String *comment) + { + if (!gtid_slave_pos.is_null_or_empty()) + { + // Print gtid_slave_pos if any of the masters really needs it. + while (MYSQL_ROW row= mysql_fetch_row(show_slave_info_result)) + { + Show_slave_status status; + status.init(show_slave_info_result, row); + if (status.is_mariadb_using_gtid()) + { + if (gtid_slave_pos.print_set_global(sql) || + comment->append(STRING_WITH_LEN("gtid_slave_pos ")) || + gtid_slave_pos.print_quoted(comment)) + return true; // Error + break; + } + } + } + + // Print the list of masters + mysql_data_seek(show_slave_info_result, 0); + while (MYSQL_ROW row= mysql_fetch_row(show_slave_info_result)) + { + Show_slave_status status; + status.init(show_slave_info_result, row); + if (start_comment_chunk(comment) || + status.print(sql, comment, gtid_slave_pos)) + return true; // Error + } + return false; // Success + } + + /* + Get master info into strings "sql" and "comment". + @return false on success + @return true on error + */ + static bool get_slave_info(MYSQL *mysql, bool show_all_slave_status, + String *sql, String *comment) + { + bool rc= false; // Success + // gtid_slave_pos - MariaDB variable : e.g. "0-1-1" or "1-10-100,2-20-500" + Var gtid_slave_pos("gtid_slave_pos", mysql); + const char *query= show_all_slave_status ? "SHOW ALL SLAVES STATUS" : + "SHOW SLAVE STATUS"; + MYSQL_RES *mysql_result= xb_mysql_query(mysql, query, true); + if (!mysql_num_rows(mysql_result)) + { + msg_is_not_slave(); + // Don't change rc, we still want to continue the backup + } + else + { + rc= get_slave_info(mysql_result, gtid_slave_pos, sql, comment); + } + mysql_free_result(mysql_result); + return rc; + } +}; + + + /*********************************************************************//** Retrieves MySQL binlog position of the master server in a replication setup and saves it in a file. It also saves it in mysql_slave_position -variable. */ +variable. +@returns false on error +@returns true on success +*/ bool write_slave_info(MYSQL *connection) { - char *master = NULL; - char *filename = NULL; - char *gtid_executed = NULL; - char *using_gtid = NULL; - char *position = NULL; - char *gtid_slave_pos = NULL; - char *ptr; - bool result = false; - - mysql_variable status[] = { - {"Master_Host", &master}, - {"Relay_Master_Log_File", &filename}, - {"Exec_Master_Log_Pos", &position}, - {"Executed_Gtid_Set", >id_executed}, - {"Using_Gtid", &using_gtid}, - {NULL, NULL} - }; - - mysql_variable variables[] = { - {"gtid_slave_pos", >id_slave_pos}, - {NULL, NULL} - }; - - read_mysql_variables(connection, "SHOW SLAVE STATUS", status, false); - read_mysql_variables(connection, "SHOW VARIABLES", variables, true); - - if (master == NULL || filename == NULL || position == NULL) { - msg("Failed to get master binlog coordinates " - "from SHOW SLAVE STATUS.This means that the server is not a " - "replication slave. Ignoring the --slave-info option"); - /* we still want to continue the backup */ - result = true; - goto cleanup; - } - - /* Print slave status to a file. - If GTID mode is used, construct a CHANGE MASTER statement with - MASTER_AUTO_POSITION and correct a gtid_purged value. */ - if (gtid_executed != NULL && *gtid_executed) { - /* MySQL >= 5.6 with GTID enabled */ + String sql, comment; + bool show_all_slaves_status= false; - for (ptr = strchr(gtid_executed, '\n'); - ptr; - ptr = strchr(ptr, '\n')) { - *ptr = ' '; - } + switch (server_flavor) + { + case FLAVOR_MARIADB: + show_all_slaves_status= mysql_server_version >= 100000; + break; + case FLAVOR_UNKNOWN: + case FLAVOR_MYSQL: + case FLAVOR_PERCONA_SERVER: + break; + } - result = backup_file_printf(XTRABACKUP_SLAVE_INFO, - "SET GLOBAL gtid_purged='%s';\n" - "CHANGE MASTER TO MASTER_AUTO_POSITION=1\n", - gtid_executed); - - ut_a(asprintf(&mysql_slave_position, - "master host '%s', purge list '%s'", - master, gtid_executed) != -1); - } else if (gtid_slave_pos && *gtid_slave_pos && - !(using_gtid && !strncmp(using_gtid, "No", 2))) { - /* MariaDB >= 10.0 with GTID enabled */ - result = backup_file_printf(XTRABACKUP_SLAVE_INFO, - "SET GLOBAL gtid_slave_pos = '%s';\n" - "CHANGE MASTER TO master_use_gtid = slave_pos\n", - gtid_slave_pos); - ut_a(asprintf(&mysql_slave_position, - "master host '%s', gtid_slave_pos %s", - master, gtid_slave_pos) != -1); - } else { - result = backup_file_printf(XTRABACKUP_SLAVE_INFO, - "CHANGE MASTER TO MASTER_LOG_FILE='%s', " - "MASTER_LOG_POS=%s\n", filename, position); - ut_a(asprintf(&mysql_slave_position, - "master host '%s', filename '%s', position '%s'", - master, filename, position) != -1); - } + if (Show_slave_status::get_slave_info(connection, show_all_slaves_status, + &sql, &comment)) + return false; // Error -cleanup: - free_mysql_variables(status); - free_mysql_variables(variables); + if (!sql.length()) + { + /* + SHOW [ALL] SLAVE STATUS returned no rows. + Don't create the file, but return success to continue the backup. + */ + return true; // Success + } - return(result); + mysql_slave_position= strdup(comment.c_ptr()); + return backup_file_print_buf(XTRABACKUP_SLAVE_INFO, sql.ptr(), sql.length()); } diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 835609795b1..2b782fb377b 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -51,6 +51,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA #include <my_getopt.h> #include <mysql_com.h> #include <my_default.h> +#include <scope.h> #include <sql_class.h> #include <fcntl.h> @@ -4689,13 +4690,6 @@ fail: goto fail; } - if (auto b = aligned_malloc(UNIV_PAGE_SIZE_MAX, 4096)) { - field_ref_zero = static_cast<byte*>( - memset_aligned<4096>(b, 0, UNIV_PAGE_SIZE_MAX)); - } else { - goto fail; - } - log_sys.create(); /* get current checkpoint_lsn */ @@ -4705,10 +4699,6 @@ fail: msg("Error: cannot read redo log header"); unlock_and_fail: mysql_mutex_unlock(&recv_sys.mutex); -free_and_fail: - aligned_free(const_cast<byte*>(field_ref_zero)); - field_ref_zero = nullptr; - goto fail; } if (!log_sys.is_latest()) { @@ -4725,7 +4715,7 @@ free_and_fail: && (my_mkdir(xtrabackup_extra_lsndir,0777,MYF(0)) < 0)) { msg("Error: cannot mkdir %d: %s\n", my_errno, xtrabackup_extra_lsndir); - goto free_and_fail; + goto fail; } /* create target dir if not exist */ @@ -4733,13 +4723,13 @@ free_and_fail: && (my_mkdir(xtrabackup_target_dir,0777,MYF(0)) < 0)){ msg("Error: cannot mkdir %d: %s\n", my_errno, xtrabackup_target_dir); - goto free_and_fail; + goto fail; } xtrabackup_init_datasinks(); if (!select_history()) { - goto free_and_fail; + goto fail; } /* open the log file */ @@ -4748,7 +4738,7 @@ free_and_fail: if (dst_log_file == NULL) { msg("Error: failed to open the target stream for '%s'.", LOG_FILE_NAME); - goto free_and_fail; + goto fail; } /* label it */ @@ -4757,7 +4747,7 @@ free_and_fail: /* Write log header*/ if (ds_write(dst_log_file, log_hdr_buf, 12288)) { msg("error: write to logfile failed"); - goto free_and_fail; + goto fail; } log_copying_running = true; /* start io throttle */ @@ -4774,7 +4764,7 @@ free_and_fail: msg("merror: xb_load_tablespaces() failed with" " error %s.", ut_strerr(err)); log_copying_running = false; - goto free_and_fail; + goto fail; } /* copy log file by current position */ @@ -4788,7 +4778,7 @@ free_and_fail: if (log_copy_failed) { log_copying_running = false; - goto free_and_fail; + goto fail; } DBUG_MARIABACKUP_EVENT("before_innodb_log_copy_thread_started", {}); @@ -4798,7 +4788,7 @@ free_and_fail: /* FLUSH CHANGED_PAGE_BITMAPS call */ if (!flush_changed_page_bitmaps()) { - goto free_and_fail; + goto fail; } ut_a(xtrabackup_parallel > 0); @@ -4865,9 +4855,6 @@ free_and_fail: if (opt_log_innodb_page_corruption) ok = corrupted_pages.print_to_file(MB_CORRUPTED_PAGES_FILE); - aligned_free(const_cast<byte*>(field_ref_zero)); - field_ref_zero = nullptr; - if (!ok) { goto fail; } @@ -5611,11 +5598,23 @@ static ibool prepare_handle_new_files(const char *data_home_dir, const char *file_name, void *arg) { const char *dest_dir = static_cast<const char *>(arg); - std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/' + file_name; + std::string src_path = std::string(data_home_dir) + '/' + std::string(db_name) + '/'; /* Copy "*.new" files from incremental to base dir for incremental backup */ std::string dest_path= dest_dir ? std::string(dest_dir) + '/' + std::string(db_name) + - '/' + file_name : src_path; + '/' : src_path; + + /* + A CREATE DATABASE could have happened during the base mariabackup run. + In case if the current table file (e.g. `t1.new`) is from such + a new database, the database directory may not exist yet in + the base backup directory. Let's make sure to check if the directory + exists (and create if needed). + */ + if (!directory_exists(dest_path.c_str(), true/*create if not exists*/)) + return FALSE; + src_path+= file_name; + dest_path+= file_name; size_t index = dest_path.find(".new"); DBUG_ASSERT(index != std::string::npos); @@ -7043,6 +7042,20 @@ static int main_low(char** argv) } } + ut_ad(!field_ref_zero); + if (auto b = aligned_malloc(UNIV_PAGE_SIZE_MAX, 4096)) { + field_ref_zero = static_cast<byte*>( + memset_aligned<4096>(b, 0, UNIV_PAGE_SIZE_MAX)); + } else { + msg("Can't allocate memory for field_ref_zero"); + return EXIT_FAILURE; + } + + auto _ = make_scope_exit([]() { + aligned_free(const_cast<byte*>(field_ref_zero)); + field_ref_zero = nullptr; + }); + /* --backup */ if (xtrabackup_backup && !xtrabackup_backup_func()) { return(EXIT_FAILURE); diff --git a/extra/wolfssl/wolfssl b/extra/wolfssl/wolfssl -Subproject c3513bf2573c30f6d2df815de216120e9214202 +Subproject e6c07a296d2996e8d5c3cc615dfc50013bbcc79 diff --git a/libmariadb b/libmariadb -Subproject e10c10f05b2215d08a4d247c1a37d78a8b5083c +Subproject 4fc7903cf3b761492243b5562ba4141a1c02651 diff --git a/man/comp_err.1 b/man/comp_err.1 index 7e401867906..1603ddf51de 100644 --- a/man/comp_err.1 +++ b/man/comp_err.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBCOMP_ERR\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBCOMP_ERR\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/galera_new_cluster.1 b/man/galera_new_cluster.1 index def5faeb935..d7efa7c84be 100644 --- a/man/galera_new_cluster.1 +++ b/man/galera_new_cluster.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBGALERA_NEW_CLUSTER\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBGALERA_NEW_CLUSTER\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/galera_recovery.1 b/man/galera_recovery.1 index 6ada4367d83..90fbe67cbc0 100644 --- a/man/galera_recovery.1 +++ b/man/galera_recovery.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBGALERA_RECOVERY\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBGALERA_RECOVERY\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/innochecksum.1 b/man/innochecksum.1 index 5a56dada985..56e4f43dbd4 100644 --- a/man/innochecksum.1 +++ b/man/innochecksum.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBINNOCHECKSUM\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBINNOCHECKSUM\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mariabackup.1 b/man/mariabackup.1 index af72f293488..4ee0a2f09d4 100644 --- a/man/mariabackup.1 +++ b/man/mariabackup.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMARIABACKUP\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIABACKUP\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mariadb-conv.1 b/man/mariadb-conv.1 index 1e0385f4fd3..c47e08c99a7 100644 --- a/man/mariadb-conv.1 +++ b/man/mariadb-conv.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMARIADB-CONV" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-CONV" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mariadb-service-convert.1 b/man/mariadb-service-convert.1 index 7c5291c3afd..6694145e491 100644 --- a/man/mariadb-service-convert.1 +++ b/man/mariadb-service-convert.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMARIADB-SERVICE-CONVERT\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SERVICE-CONVERT\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mbstream.1 b/man/mbstream.1 index 16cf5b180f2..ed9d0036381 100644 --- a/man/mbstream.1 +++ b/man/mbstream.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMBSTREAM\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMBSTREAM\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/msql2mysql.1 b/man/msql2mysql.1 index 503b8b194ab..4aecf1eb077 100644 --- a/man/msql2mysql.1 +++ b/man/msql2mysql.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMSQL2MYSQL\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMSQL2MYSQL\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/my_print_defaults.1 b/man/my_print_defaults.1 index d7b81cc73b2..e3d1c7ac06d 100644 --- a/man/my_print_defaults.1 +++ b/man/my_print_defaults.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMY_PRINT_DEFAULTS" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMY_PRINT_DEFAULTS" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/my_safe_process.1 b/man/my_safe_process.1 index b265352fb86..faa81190b0a 100644 --- a/man/my_safe_process.1 +++ b/man/my_safe_process.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMY_SAFE_PROCESS\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMY_SAFE_PROCESS\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/myisam_ftdump.1 b/man/myisam_ftdump.1 index 4af8280d2d8..a14722f3625 100644 --- a/man/myisam_ftdump.1 +++ b/man/myisam_ftdump.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYISAM_FTDUMP\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYISAM_FTDUMP\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/myisamchk.1 b/man/myisamchk.1 index e059cf11036..a6a274ed2be 100644 --- a/man/myisamchk.1 +++ b/man/myisamchk.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYISAMCHK\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYISAMCHK\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/myisamlog.1 b/man/myisamlog.1 index 0d063e0a046..a907a9f6b99 100644 --- a/man/myisamlog.1 +++ b/man/myisamlog.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYISAMLOG\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYISAMLOG\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/myisampack.1 b/man/myisampack.1 index b46fef85f38..a27b62150cb 100644 --- a/man/myisampack.1 +++ b/man/myisampack.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYISAMPACK\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYISAMPACK\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/myrocks_hotbackup.1 b/man/myrocks_hotbackup.1 index b5f07a3a913..4237c452f76 100644 --- a/man/myrocks_hotbackup.1 +++ b/man/myrocks_hotbackup.1 @@ -1,4 +1,4 @@ -.TH MYROCKS_HOTBACKUP "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH MYROCKS_HOTBACKUP "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .SH NAME myrocks_hotbackup \- streaming backup for MariaDB MyRocks .SH DESCRIPTION diff --git a/man/mysql-stress-test.pl.1 b/man/mysql-stress-test.pl.1 index d69f6123488..c9cf6cb1069 100644 --- a/man/mysql-stress-test.pl.1 +++ b/man/mysql-stress-test.pl.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL\-STRESS\-TE" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYSQL\-STRESS\-TE" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql-test-run.pl.1 b/man/mysql-test-run.pl.1 index b13727c3298..618fadb0ba0 100644 --- a/man/mysql-test-run.pl.1 +++ b/man/mysql-test-run.pl.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL\-TEST\-RUN\" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYSQL\-TEST\-RUN\" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql.1 b/man/mysql.1 index 4bc35938f6c..4685225d3ed 100644 --- a/man/mysql.1 +++ b/man/mysql.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql.server.1 b/man/mysql.server.1 index 4b99aadb0b3..43062e8f88f 100644 --- a/man/mysql.server.1 +++ b/man/mysql.server.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL\&.SERVER\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYSQL\&.SERVER\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_client_test.1 b/man/mysql_client_test.1 index 70ce1f720b7..4615ff92fdc 100644 --- a/man/mysql_client_test.1 +++ b/man/mysql_client_test.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_CLIENT_TEST" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-CLIENT-TEST" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_config.1 b/man/mysql_config.1 index 90b09cb5d4b..334478ce32c 100644 --- a/man/mysql_config.1 +++ b/man/mysql_config.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_CONFIG\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMYSQL_CONFIG\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_convert_table_format.1 b/man/mysql_convert_table_format.1 index 2d31bdcb0fb..ff3375de055 100644 --- a/man/mysql_convert_table_format.1 +++ b/man/mysql_convert_table_format.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_CONVERT_TAB" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-CONVERT-TAB" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_find_rows.1 b/man/mysql_find_rows.1 index b69322e4abb..1172700df50 100644 --- a/man/mysql_find_rows.1 +++ b/man/mysql_find_rows.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_FIND_ROWS\F" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-FIND-ROWS\F" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_fix_extensions.1 b/man/mysql_fix_extensions.1 index bad341ab694..a851180128a 100644 --- a/man/mysql_fix_extensions.1 +++ b/man/mysql_fix_extensions.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_FIX_EXTENSI" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-FIX-EXTENSI" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_install_db.1 b/man/mysql_install_db.1 index 237efaef9df..49e784fb006 100644 --- a/man/mysql_install_db.1 +++ b/man/mysql_install_db.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_INSTALL_DB\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-INSTALL-DB\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_ldb.1 b/man/mysql_ldb.1 index 8595ab5e319..e16aa8c1f78 100644 --- a/man/mysql_ldb.1 +++ b/man/mysql_ldb.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_LDB\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-LDB\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_plugin.1 b/man/mysql_plugin.1 index 6e002f2021d..e37c8e94a75 100644 --- a/man/mysql_plugin.1 +++ b/man/mysql_plugin.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_PLUGIN\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-PLUGIN\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff --git a/man/mysql_secure_installation.1 b/man/mysql_secure_installation.1 index ca7f52cd30e..019a9d82edc 100644 --- a/man/mysql_secure_installation.1 +++ b/man/mysql_secure_installation.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_SECURE_INST" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SECURE-INST" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_setpermission.1 b/man/mysql_setpermission.1 index 4ab0ba5ff1e..a52264c36a2 100644 --- a/man/mysql_setpermission.1 +++ b/man/mysql_setpermission.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_SETPERMISSI" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SETPERMISSI" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_tzinfo_to_sql.1 b/man/mysql_tzinfo_to_sql.1 index 544180a42ec..5c118a24c7f 100644 --- a/man/mysql_tzinfo_to_sql.1 +++ b/man/mysql_tzinfo_to_sql.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_TZINFO_TO_S" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-TZINFO-TO-S" "1" "22 April 2022" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- @@ -41,6 +41,7 @@ can be invoked several ways: shell> \fBmysql_tzinfo_to_sql \fR\fB\fItz_dir\fR\fR shell> \fBmysql_tzinfo_to_sql \fR\fB\fItz_file tz_name\fR\fR shell> \fBmysql_tzinfo_to_sql \-\-leap \fR\fB\fItz_file\fR\fR +shell> \fBmysql_tzinfo_to_sql \-\-skip\-write\-binlog \fR\fB\fItz_dir\fR\fR .fi .if n \{\ .RE @@ -100,6 +101,9 @@ shell> \fBmysql_tzinfo_to_sql \-\-leap \fR\fB\fItz_file\fR\fR\fB | mysql \-u roo .RE .\} .PP +Using the \-\-skip\-write\-binlog option prevents writing of changes to the binary log or to other Galera +cluster members. This can be used with any form of running \fBmysql_tzinfo_to_sql\fR. +.PP After running \fBmysql_tzinfo_to_sql\fR, it is best to restart the server so that it does not continue to use any previously cached time zone data\&. .SH "COPYRIGHT" diff --git a/man/mysql_upgrade.1 b/man/mysql_upgrade.1 index d47c3c70b85..ef38712f2ab 100644 --- a/man/mysql_upgrade.1 +++ b/man/mysql_upgrade.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_UPGRADE\FR" "1" "20 July 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-UPGRADE\FR" "1" "20 July 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysql_waitpid.1 b/man/mysql_waitpid.1 index 330687ea3e4..f5771ed6d25 100644 --- a/man/mysql_waitpid.1 +++ b/man/mysql_waitpid.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQL_WAITPID\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-WAITPID\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqlaccess.1 b/man/mysqlaccess.1 index e14de4791e2..3716e3601a2 100644 --- a/man/mysqlaccess.1 +++ b/man/mysqlaccess.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLACCESS\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-ACCESS\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqladmin.1 b/man/mysqladmin.1 index 2b6fab12f0e..85c1d70601d 100644 --- a/man/mysqladmin.1 +++ b/man/mysqladmin.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLADMIN\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-ADMIN\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqlbinlog.1 b/man/mysqlbinlog.1 index 5430c80ddc6..4d989a541e1 100644 --- a/man/mysqlbinlog.1 +++ b/man/mysqlbinlog.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLBINLOG\FR" "1" "14 April 2021" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-BINLOG\FR" "1" "14 April 2021" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- @@ -882,78 +882,11 @@ quote the value (e.g. \fB--rewrite-db="oldname->newname"\fR\&. .sp -1 .IP \(bu 2.3 .\} -.\" mysqlbinlog: ignore-domain-ids option -.\" ignore-domain-ids option: mysqlbinlog -\fB\-\-ignore\-domain\-ids=\fR\fB\fIIDs\fR\fR -.sp -Hide events which are a part of any stream identified by the domain ID -list \fIIDs\fR\&. Cannot be used with \-\-do\-domain\-ids\&. -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -.\" mysqlbinlog: do-domain-ids option -.\" do-domain-ids option: mysqlbinlog -\fB\-\-do\-domain\-ids=\fR\fB\fIIDs\fR\fR -.sp -Display only the events which exist in a stream identified by \fIIDs\fR\&. -Cannot be used with \-\-ignore\-domain\-ids\&. -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -.\" mysqlbinlog: ignore-server-ids option -.\" ignore-server-ids option: mysqlbinlog -\fB\-\-ignore\-server\-ids=\fR\fB\fIIDs\fR\fR -.sp -Hide events which originated from any server whose ID is specified in -\fIIDs\fR\&. Cannot be used with \-\-do\-server\-ids\ or \-\-server\-id\&. -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} -.\" mysqlbinlog: do-server-ids option -.\" do-server-ids option: mysqlbinlog -\fB\-\-do\-server\-ids=\fR\fB\fIIDs\fR\fR -.sp -Display only the events that originated from a server identified in -\fIIDs\fR\&. Cannot be used with \-\-ignore\-server\-ids, and -is an alias for \-\-server\-id\&. -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} .\" mysqlbinlog: server-id option .\" server-id option: mysqlbinlog \fB\-\-server\-id=\fR\fB\fIid\fR\fR .sp Display only those events created by the server having the given server ID\&. -Cannot be used with \-\-ignore\-server\-ids, and is an alias for -\-\-do\-server\-ids\&. .RE .sp .RS 4 diff --git a/man/mysqlcheck.1 b/man/mysqlcheck.1 index b8f102a27a4..c41ff535f8a 100644 --- a/man/mysqlcheck.1 +++ b/man/mysqlcheck.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLCHECK\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-CHECK\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqld.8 b/man/mysqld.8 index ffa746edd64..d1cf438010c 100644 --- a/man/mysqld.8 +++ b/man/mysqld.8 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLD\FR" "8" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADBD\FR" "8" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqld_multi.1 b/man/mysqld_multi.1 index d4e5e08efa9..2649e5e00a4 100644 --- a/man/mysqld_multi.1 +++ b/man/mysqld_multi.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLD_MULTI\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-MULTI\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqld_safe.1 b/man/mysqld_safe.1 index ff3b8356095..ba351c6de46 100644 --- a/man/mysqld_safe.1 +++ b/man/mysqld_safe.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLD_SAFE\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SAFE\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqld_safe_helper.1 b/man/mysqld_safe_helper.1 index f8fc0fc4668..c3afdb65296 100644 --- a/man/mysqld_safe_helper.1 +++ b/man/mysqld_safe_helper.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLD_SAFE_HELPER\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SAFE-HELPER\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqldump.1 b/man/mysqldump.1 index cd9c1dc83e1..a9d5b2f39f4 100644 --- a/man/mysqldump.1 +++ b/man/mysqldump.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLDUMP\FR" "1" "24 October 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-DUMP\FR" "1" "24 October 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- @@ -1549,24 +1549,6 @@ table, but will make the dump operation take considerably longer\&. .sp -1 .IP \(bu 2.3 .\} -.\" mysqldump: order-by-size option -.\" order-by-size option: mysqldump -\fB\-\-order\-by\-size\fR -.sp -Dump each table according to their size, smallest first\&. Useful when using \-\-single\-transaction on tables which get truncated/altered often\&. -.sp -The assumption here is that smaller tables get truncated more often, and by doing dumping those first, this reduces the chance that a \-\-single\-transaction -dump will fail with with 'Table definition has changed, please retry transaction'\&. -.RE -.sp -.RS 4 -.ie n \{\ -\h'-04'\(bu\h'+03'\c -.\} -.el \{\ -.sp -1 -.IP \(bu 2.3 -.\} .\" mysqldump: password option .\" password option: mysqldump \fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR, diff --git a/man/mysqldumpslow.1 b/man/mysqldumpslow.1 index d5da746a293..b8db58d9b66 100644 --- a/man/mysqldumpslow.1 +++ b/man/mysqldumpslow.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLDUMPSLOW\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-DUMPSLOW\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqlhotcopy.1 b/man/mysqlhotcopy.1 index 462e2f97062..a3af3850a50 100644 --- a/man/mysqlhotcopy.1 +++ b/man/mysqlhotcopy.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLHOTCOPY\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-HOTCOPY\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqlimport.1 b/man/mysqlimport.1 index b7999166d32..33fb15bbb44 100644 --- a/man/mysqlimport.1 +++ b/man/mysqlimport.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLIMPORT\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-IMPORT\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqlshow.1 b/man/mysqlshow.1 index f20ac9fed63..77dc4c9be72 100644 --- a/man/mysqlshow.1 +++ b/man/mysqlshow.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLSHOW\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SHOW\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqlslap.1 b/man/mysqlslap.1 index 4f31489dead..f58cbc70d72 100644 --- a/man/mysqlslap.1 +++ b/man/mysqlslap.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLSLAP\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-SLAP\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mysqltest.1 b/man/mysqltest.1 index 57a05521498..f96c7a9ecda 100644 --- a/man/mysqltest.1 +++ b/man/mysqltest.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBMYSQLTEST\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBMARIADB-TEST\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/mytop.1 b/man/mytop.1 index a68413b5af0..9594caade78 100644 --- a/man/mytop.1 +++ b/man/mytop.1 @@ -1,4 +1,4 @@ -.TH MYTOP "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH MYTOP "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .SH NAME mytop \- display MariaDB server performance info like 'top' .SH "SEE ALSO" diff --git a/man/perror.1 b/man/perror.1 index 2094608d0a2..f225e074f10 100644 --- a/man/perror.1 +++ b/man/perror.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBPERROR\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBPERROR\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/replace.1 b/man/replace.1 index 701a72ac360..d8cc27e0bab 100644 --- a/man/replace.1 +++ b/man/replace.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBREPLACE\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBREPLACE\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/resolve_stack_dump.1 b/man/resolve_stack_dump.1 index ad61f45fd09..6f59e8ef4b4 100644 --- a/man/resolve_stack_dump.1 +++ b/man/resolve_stack_dump.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBRESOLVE_STACK_DUM" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBRESOLVE_STACK_DUM" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/resolveip.1 b/man/resolveip.1 index cc13e58b70f..56895b50bfc 100644 --- a/man/resolveip.1 +++ b/man/resolveip.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBRESOLVEIP\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBRESOLVEIP\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/wsrep_sst_common.1 b/man/wsrep_sst_common.1 index 8323011aaa1..7b3ac5dd244 100644 --- a/man/wsrep_sst_common.1 +++ b/man/wsrep_sst_common.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBWSREP_SST_COMMON\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBWSREP_SST_COMMON\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/wsrep_sst_mariabackup.1 b/man/wsrep_sst_mariabackup.1 index 83e4e43907e..21a73de16db 100644 --- a/man/wsrep_sst_mariabackup.1 +++ b/man/wsrep_sst_mariabackup.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBWSREP_SST_MARIABACKUP\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBWSREP_SST_MARIABACKUP\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/wsrep_sst_mysqldump.1 b/man/wsrep_sst_mysqldump.1 index 78eef3bd0f3..55a859bf979 100644 --- a/man/wsrep_sst_mysqldump.1 +++ b/man/wsrep_sst_mysqldump.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBWSREP_SST_MYSQLDUMP\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBWSREP_SST_MYSQLDUMP\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/wsrep_sst_rsync.1 b/man/wsrep_sst_rsync.1 index c3225d58d9f..02862256f1c 100644 --- a/man/wsrep_sst_rsync.1 +++ b/man/wsrep_sst_rsync.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBWSREP_SST_RSYNC\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBWSREP_SST_RSYNC\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/man/wsrep_sst_rsync_wan.1 b/man/wsrep_sst_rsync_wan.1 index a81933449ea..0736c03f9e9 100644 --- a/man/wsrep_sst_rsync_wan.1 +++ b/man/wsrep_sst_rsync_wan.1 @@ -1,6 +1,6 @@ '\" t .\" -.TH "\FBWSREP_SST_RSYNC_WAN\FR" "1" "15 May 2020" "MariaDB 10\&.6" "MariaDB Database System" +.TH "\FBWSREP_SST_RSYNC_WAN\FR" "1" "15 May 2020" "MariaDB 10\&.10" "MariaDB Database System" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- diff --git a/mysql-test/include/grep.inc b/mysql-test/include/grep.inc new file mode 100644 index 00000000000..9ce7cddb7b7 --- /dev/null +++ b/mysql-test/include/grep.inc @@ -0,0 +1,16 @@ +# Grep file for regular expression and output to STDOUT +# +# Usage: +# --let $grep_file= /path/to/your/file +# --let $grep_regex= your_regex_string +# --source include/grep.inc + +--perl + open (my $fh, "<", "$ENV{grep_file}") or die $!; + while (<$fh>) + { + /$ENV{grep_regex}/ && + print; + } + close $fh; +EOF diff --git a/mysql-test/include/have_log_bin.inc b/mysql-test/include/have_log_bin.inc index eb2529dae3b..fd5dc66e416 100644 --- a/mysql-test/include/have_log_bin.inc +++ b/mysql-test/include/have_log_bin.inc @@ -8,7 +8,6 @@ source include/not_embedded.inc; --- require include/have_log_bin.require -disable_query_log; -show variables like 'log_bin'; -enable_query_log; +if (`select not @@log_bin`) { + skip Test requires: 'have_log_bin'; +} diff --git a/mysql-test/include/have_log_bin.require b/mysql-test/include/have_log_bin.require deleted file mode 100644 index d4fd77e4f8d..00000000000 --- a/mysql-test/include/have_log_bin.require +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -log_bin ON diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index ae30f4f6074..3f983b8e72f 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -78,7 +78,10 @@ sub _gdb { my ($tmp, $tmp_name) = tempfile(); print $tmp "bt\n", - "thread apply all bt\n", + "set print sevenbit on\n", + "set print static-members off\n", + "set print frame-arguments all\n", + "thread apply all bt full\n", "quit\n"; close $tmp or die "Error closing $tmp_name: $!"; diff --git a/mysql-test/main/alter_table_lock.result b/mysql-test/main/alter_table_lock.result index ce6097c9ada..620fca23315 100644 --- a/mysql-test/main/alter_table_lock.result +++ b/mysql-test/main/alter_table_lock.result @@ -11,8 +11,6 @@ ERROR 42S02: Table 'test.x' doesn't exist SET SESSION max_session_mem_used= 8192; LOCK TABLE t1 WRITE; ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; -Warnings: -Note 1054 Unknown column 'b' in 't1' SET SESSION max_session_mem_used = @max_session_mem_used_save; UNLOCK TABLES; DROP TABLE t1; diff --git a/mysql-test/main/alter_table_lock.test b/mysql-test/main/alter_table_lock.test index f1f60e38b61..bd26c1ac7d0 100644 --- a/mysql-test/main/alter_table_lock.test +++ b/mysql-test/main/alter_table_lock.test @@ -14,9 +14,13 @@ SELECT * FROM t1; ALTER TABLE x MODIFY xx INT; SET SESSION max_session_mem_used= 8192; +--error 0,ER_OPTION_PREVENTS_STATEMENT LOCK TABLE t1 WRITE; +--disable_warnings +--error 0,ER_OPTION_PREVENTS_STATEMENT ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT; +--enable_warnings SET SESSION max_session_mem_used = @max_session_mem_used_save; UNLOCK TABLES; diff --git a/mysql-test/main/check_constraint.result b/mysql-test/main/check_constraint.result index f851b99e5c1..dab1d61cdb9 100644 --- a/mysql-test/main/check_constraint.result +++ b/mysql-test/main/check_constraint.result @@ -236,6 +236,66 @@ insert t1 (b) values (1); ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` drop table t1; # +# MDEV-25638 Assertion `!result' failed in convert_const_to_int +# +create table t1 (v1 bigint check (v1 not in ('x' , 'x111'))) ; +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'x111' +select * from t1; +v1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'x111' +select v1 from t1; +v1 +select * from t1; +v1 +prepare stmt from "select * from t1"; +execute stmt; +v1 +execute stmt; +v1 +flush tables; +select * from t1; +v1 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'x111' +select * from t1; +v1 +deallocate prepare stmt; +drop table t1; +# +# MDEV-26061 MariaDB server crash at Field::set_default +# +create table t1 (v2 date check (v1 like default (v1)), v1 date default (from_days ('x'))); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'x' +insert ignore into t1 values ( 'x' , 'x' ) ; +Warnings: +Warning 1265 Data truncated for column 'v2' at row 1 +Warning 1265 Data truncated for column 'v1' at row 1 +Warning 1292 Truncated incorrect INTEGER value: 'x' +drop table t1; +# +# End of 10.2 tests +# +# +# MDEV-26061 MariaDB server crash at Field::set_default +# +create table t1 (d timestamp check (default (d) is true)) as select 1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `d` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() CHECK (default(`d`) is true), + `1` int(1) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# +# End of 10.3 tests +# +# # MDEV-24274 ALTER TABLE with CHECK CONSTRAINTS gives "Out of Memory" error # create table t1 (id varchar(2), constraint id check (id regexp '[a-z]')); @@ -247,3 +307,6 @@ t1 CREATE TABLE `t1` ( CONSTRAINT `id` CHECK (`id` regexp '[a-z]') ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/check_constraint.test b/mysql-test/main/check_constraint.test index 1258a9e3be6..194fdc04399 100644 --- a/mysql-test/main/check_constraint.test +++ b/mysql-test/main/check_constraint.test @@ -178,9 +178,56 @@ insert t1 (b) values (1); drop table t1; --echo # +--echo # MDEV-25638 Assertion `!result' failed in convert_const_to_int +--echo # + +--enable_prepare_warnings +create table t1 (v1 bigint check (v1 not in ('x' , 'x111'))) ; +select * from t1; +select v1 from t1; +select * from t1; +prepare stmt from "select * from t1"; +execute stmt; +execute stmt; +flush tables; +select * from t1; +select * from t1; +deallocate prepare stmt; +drop table t1; +--disable_prepare_warnings + +--echo # +--echo # MDEV-26061 MariaDB server crash at Field::set_default +--echo # + +create table t1 (v2 date check (v1 like default (v1)), v1 date default (from_days ('x'))); +insert ignore into t1 values ( 'x' , 'x' ) ; +drop table t1; + +--echo # +--echo # End of 10.2 tests +--echo # + +--echo # +--echo # MDEV-26061 MariaDB server crash at Field::set_default +--echo # + +create table t1 (d timestamp check (default (d) is true)) as select 1; +show create table t1; +drop table t1; + +--echo # +--echo # End of 10.3 tests +--echo # + +--echo # --echo # MDEV-24274 ALTER TABLE with CHECK CONSTRAINTS gives "Out of Memory" error --echo # create table t1 (id varchar(2), constraint id check (id regexp '[a-z]')); alter table t1 force; show create table t1; drop table t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/create_drop_binlog.result b/mysql-test/main/create_drop_binlog.result index 4a8c75a3dae..30ccc116a85 100644 --- a/mysql-test/main/create_drop_binlog.result +++ b/mysql-test/main/create_drop_binlog.result @@ -142,7 +142,7 @@ DROP SERVER s1; CREATE SERVER IF NOT EXISTS s1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test'); CREATE SERVER IF NOT EXISTS s1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test'); Warnings: -Note 1476 The foreign server, s1, you are trying to create already exists +Note 1476 Cannot create foreign server 's1' as it already exists DROP SERVER IF EXISTS s1; DROP SERVER IF EXISTS s1; SHOW BINLOG EVENTS; diff --git a/mysql-test/main/create_drop_server.result b/mysql-test/main/create_drop_server.result index 4f5d13b3541..dc3c5eefbf8 100644 --- a/mysql-test/main/create_drop_server.result +++ b/mysql-test/main/create_drop_server.result @@ -7,7 +7,7 @@ server_name username db server1 user1 test0 CREATE SERVER IF NOT EXISTS server1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'user2', HOST 'localhost', DATABASE 'test1'); Warnings: -Note 1476 The foreign server, server1, you are trying to create already exists +Note 1476 Cannot create foreign server 'server1' as it already exists SELECT server_name, username, db FROM mysql.servers; server_name username db server1 user1 test0 @@ -21,10 +21,10 @@ server_name username db DROP SERVER IF EXISTS server1; CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test0'); CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test1'); -ERROR HY000: The foreign server, server_1, you are trying to create already exists +ERROR HY000: Cannot create foreign server 'server_1' as it already exists CREATE SERVER IF NOT EXISTS server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'mysqltest_1', HOST 'localhost', DATABASE 'test2'); Warnings: -Note 1476 The foreign server, server_1, you are trying to create already exists +Note 1476 Cannot create foreign server 'server_1' as it already exists SELECT server_name, username, db FROM mysql.servers; server_name username db server_1 mysqltest_1 test0 diff --git a/mysql-test/main/create_select_tmp.result b/mysql-test/main/create_select.result index 2842ab26c42..803f9a06213 100644 --- a/mysql-test/main/create_select_tmp.result +++ b/mysql-test/main/create_select.result @@ -1,4 +1,7 @@ -drop table if exists t1, t2; +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +# +# Testcase for BUG#4551 +# CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; @@ -18,6 +21,20 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' select * from t2; ERROR 42S02: Table 'test.t2' doesn't exist drop table t1; +# +# End of 4.1 tests +# +# +# MDEV-28393 Server crashes in TABLE::mark_default_fields_for_write +# +create table t1 (a int, b text not null default ''); +alter table t1 character set = utf8; +create table t2 select * from t1; +insert into t1 values (1,''); +drop table t1, t2; +# +# End of 10.2 tests +# set sql_mode='ignore_bad_table_options'; create table t1 ( f1 int invisible, @@ -39,3 +56,6 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING drop table t1; set sql_mode=default; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/create_select_tmp.test b/mysql-test/main/create_select.test index 3ed885ea382..d91f71133a0 100644 --- a/mysql-test/main/create_select_tmp.test +++ b/mysql-test/main/create_select.test @@ -1,42 +1,55 @@ -# Testcase for BUG#4551 +# This does not work for RBR yet. +--source include/have_innodb.inc +--source include/have_binlog_format_mixed_or_statement.inc + +CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + +--echo # +--echo # Testcase for BUG#4551 +--echo # + # The bug was that when the table was TEMPORARY, it was not deleted if # the CREATE SELECT failed (the code intended too, but it actually # didn't). And as the CREATE TEMPORARY TABLE was not written to the # binlog if it was a transactional table, it resulted in an # inconsistency between binlog and the internal list of temp tables. -# This does not work for RBR yet. ---source include/have_binlog_format_mixed_or_statement.inc - ---disable_query_log -CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); ---enable_query_log - --- source include/have_innodb.inc ---disable_warnings -drop table if exists t1, t2; ---enable_warnings CREATE TABLE t1 ( a int ); INSERT INTO t1 VALUES (1),(2),(1); --error ER_DUP_ENTRY CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; --error ER_DUP_ENTRY CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=INNODB SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; --error ER_DUP_ENTRY CREATE TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; --error ER_DUP_ENTRY CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; ---error 1146 +--error ER_NO_SUCH_TABLE select * from t2; drop table t1; -# End of 4.1 tests +--echo # +--echo # End of 4.1 tests +--echo # + +--echo # +--echo # MDEV-28393 Server crashes in TABLE::mark_default_fields_for_write +--echo # +create table t1 (a int, b text not null default ''); +alter table t1 character set = utf8; +create table t2 select * from t1; +insert into t1 values (1,''); +drop table t1, t2; + +--echo # +--echo # End of 10.2 tests +--echo # set sql_mode='ignore_bad_table_options'; create table t1 ( @@ -50,4 +63,6 @@ show create table t1; drop table t1; set sql_mode=default; -# End of 10.4 tests +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/ctype_collate_context.result b/mysql-test/main/ctype_collate_context.result new file mode 100644 index 00000000000..5be0de3fcad --- /dev/null +++ b/mysql-test/main/ctype_collate_context.result @@ -0,0 +1,1960 @@ +CREATE TABLE t0 (a VARCHAR(64)); +INSERT INTO t0 VALUES +('CHARACTER SET DEFAULT'), +('CHARACTER SET latin1'), +('CHARACTER SET utf8mb4'), +('COLLATE DEFAULT'), +('COLLATE utf8mb4_bin'), +('COLLATE latin1_swedish_ci'), +('COLLATE latin1_bin'); +CREATE TABLE clauses +( +id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +cl1 VARCHAR(64) NOT NULL, +cl2 VARCHAR(64) NOT NULL, +cl3 VARCHAR(64) NOT NULL, +clause_count INT GENERATED ALWAYS AS ((cl1<>'') + (cl2<>'') + (cl3<>'')), +clauses TEXT GENERATED ALWAYS AS (CONCAT(cl1, +IF(cl2='','',' '), cl2, +IF(cl3='','',' '), cl3)) +); +INSERT INTO clauses (cl1, cl2, cl3) +SELECT '' AS cl1, '' AS cl2, '' AS cl3; +INSERT INTO clauses (cl1, cl2, cl3) +SELECT t0.a AS cl1, '' AS cl2, '' AS cl3 +FROM t0; +INSERT INTO clauses (cl1, cl2, cl3) +SELECT t0.a AS cl1, t2.a AS cl2, '' AS cl3 +FROM t0 t0, t0 t2; +INSERT INTO clauses (cl1, cl2, cl3) +SELECT t0.a AS cl1, t2.a AS cl2, t3.a AS cl3 +FROM t0 t0, t0 t2, t0 t3; +DROP TABLE t0; +CREATE TABLE results_template +( +id INT NOT NULL PRIMARY KEY, +result TEXT NOT NULL +); +CREATE PROCEDURE diff_result_tables_stat(table1 VARCHAR(64), +table2 VARCHAR(64), +cond VARCHAR(128)) +BEGIN +DECLARE query_counts TEXT DEFAULT +'SELECT ' + ' COUNT(*),' + ' SUM(t1.result=t2.result),' + ' SUM(t1.result<>t2.result) ' + 'FROM table1 t1 JOIN table2 t2 USING (id)/*$(WHERE)*/'; +SET query_counts=REPLACE(query_counts, 'table1', table1); +SET query_counts=REPLACE(query_counts, 'table2', table2); +IF (cond<>'') +THEN +SET query_counts=REPLACE(query_counts, '/*$(WHERE)*/', CONCAT('WHERE ',cond)); +END IF; +EXECUTE IMMEDIATE query_counts; +END; +$$ +CREATE PROCEDURE diff_result_tables_records(table1 VARCHAR(64), +table2 VARCHAR(64), +cond VARCHAR(128)) +BEGIN +DECLARE query_records TEXT DEFAULT +'SELECT ' + ' '''' AS ``,' + ' clauses.clauses AS attrs,' + ' t1.result AS `aaa`,' + ' t2.result AS `bbb` ' + ' FROM table1 t1' + ' JOIN table2 t2 USING (id)' + ' JOIN clauses USING (id) ' + ' WHERE t1.result<>t2.result /*$(COND)*/ ORDER BY t1.id'; +SET query_records=REPLACE(query_records, 'table1', table1); +SET query_records=REPLACE(query_records, 'table2', table2); +IF (cond<>'') +THEN +SET query_records=REPLACE(query_records, '/*$(COND)*/', CONCAT('AND ',cond)); +END IF; +EXECUTE IMMEDIATE query_records; +END; +$$ +CREATE PROCEDURE diff_result_tables(table1 VARCHAR(64), +table2 VARCHAR(64), +cond VARCHAR(128)) +BEGIN +CALL diff_result_tables_stat(table1, table2, cond); +CALL diff_result_tables_records(table1, table2, cond); +END; +$$ +CREATE PROCEDURE exec(query_bootstrap TEXT, +query_pattern TEXT, +query_cleanup TEXT, +id INT, +clauses TEXT) +BEGIN +DECLARE query TEXT DEFAULT REPLACE(query_pattern, '/*CSCL*/',clauses); +DECLARE result TEXT DEFAULT NULL; +DECLARE CONTINUE HANDLER FOR +1064, /*ER_PARSE_ERROR*/ +1302, /*ER_CONFLICTING_DECLARATIONS*/ +1253 /*ER_COLLATION_CHARSET_MISMATCH*/ +BEGIN +GET DIAGNOSTICS CONDITION 1 result=MESSAGE_TEXT; +SET result=CONCAT('ERROR: ', result); +END; +IF query_bootstrap<>'' + THEN +EXECUTE IMMEDIATE query_bootstrap; +END IF; +EXECUTE IMMEDIATE query; +IF result IS NULL +THEN +IF query_pattern LIKE '%DATABASE%' + THEN +SET result=(SELECT CONCAT('CHARACTER SET ', DEFAULT_CHARACTER_SET_NAME, +' COLLATE ', DEFAULT_COLLATION_NAME) +FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='db1'); +ELSE +SET result=(SELECT CONCAT('CHARACTER SET ', SUBSTRING_INDEX(TABLE_COLLATION,'_',1), +' COLLATE ', TABLE_COLLATION) +FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test1'); +END IF; +END IF; +INSERT INTO results (id, result) VALUES (id, result); +IF query_cleanup<>'' + THEN +EXECUTE IMMEDIATE query_cleanup; +END IF; +END; +$$ +CREATE PROCEDURE show_results(query TEXT, clause_count_arg INT) +BEGIN +SELECT '' AS ``, CONCAT(clause_count_arg, ' clauses') AS `TEST:`; +SELECT '' AS ``, COUNT(*) AS `TOTAL` + FROM results JOIN clauses USING (id) +WHERE clauses.clause_count=clause_count_arg; +-- Display erroneous results +SELECT '' AS ``, COUNT(*) AS `ERROR` + FROM results JOIN clauses USING (id) +WHERE clauses.clause_count=clause_count_arg +AND result RLIKE '^ERROR'; +SELECT '' AS ``, query, clauses AS attrs, result +FROM results JOIN clauses USING (id) +WHERE clauses.clause_count=clause_count_arg +AND result RLIKE '^ERROR' ORDER BY id; +-- Display successfull results +SELECT '' AS ``, COUNT(*) AS `OK` + FROM results JOIN clauses USING (id) +WHERE clauses.clause_count=clause_count_arg +AND result NOT RLIKE '^ERROR'; +SELECT '' AS ``, query, clauses AS attrs, result +FROM results JOIN clauses USING (id) +WHERE clauses.clause_count=clause_count_arg +AND result NOT RLIKE '^ERROR' ORDER BY id; +END; +$$ +CREATE PROCEDURE run(query_bootstrap TEXT, +query TEXT, +query_cleanup TEXT, +clause_count_arg INT) +BEGIN +FOR rec IN (SELECT * FROM clauses WHERE clause_count=clause_count_arg) +DO +CALL exec(query_bootstrap, query, query_cleanup, rec.id, rec.clauses); +END FOR; +END; +$$ +CREATE PROCEDURE run_all(query_bootstrap TEXT, query TEXT, query_cleanup TEXT) +BEGIN +DECLARE msg TEXT; +DECLARE count_results INT; +DECLARE count_clauses INT; +FOR i IN 0..3 +DO +CALL run(query_bootstrap, query, query_cleanup, i); +END FOR; +SET count_clauses=(SELECT COUNT(*) FROM clauses); +SET count_results=(SELECT COUNT(*) FROM results); +IF (count_results<>count_clauses) +THEN +SET msg=CONCAT('Got ', count_results,' rows in `results`; ', +'Expected ', count_clauses, ' rows'); +SIGNAL SQLSTATE '45000' + SET MYSQL_ERRNO=30001, +MESSAGE_TEXT=msg; +END IF; +END; +$$ +CREATE PROCEDURE show_results_all(query TEXT) +BEGIN +FOR i IN 0..3 +DO +CALL show_results(query, i); +END FOR; +END; +$$ +# +# Running CREATE DATABASE tests +# Displaying all results +# +SET @@collation_server=utf8mb4_unicode_ci; +CREATE TABLE results LIKE results_template; +CALL run_all('','CREATE DATABASE db1 /*CSCL*/', 'DROP DATABASE IF EXISTS db1'); +CALL show_results_all('CREATE DATABASE'); + +TEST: 0 clauses + +TOTAL 1 + +ERROR 0 + +OK 1 + +query CREATE DATABASE +attrs +result CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci + +TEST: 1 clauses + +TOTAL 7 + +ERROR 0 + +OK 7 + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin + +TEST: 2 clauses + +TOTAL 49 + +ERROR 24 + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +OK 25 + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin + +TEST: 3 clauses + +TOTAL 343 + +ERROR 264 + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin CHARACTER SET DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 CHARACTER SET latin1 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci CHARACTER SET latin1 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin CHARACTER SET latin1 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin CHARACTER SET latin1 +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin CHARACTER SET utf8mb4 +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT COLLATE DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT COLLATE DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 COLLATE DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 COLLATE DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 COLLATE DEFAULT +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 COLLATE DEFAULT +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 COLLATE DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 COLLATE DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci COLLATE DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci COLLATE DEFAULT +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin COLLATE DEFAULT +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin COLLATE DEFAULT +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_general_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_general_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin COLLATE utf8mb4_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 COLLATE latin1_swedish_ci +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_general_ci' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_general_ci' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin COLLATE latin1_swedish_ci +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET DEFAULT COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET latin1 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET latin1 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'CHARACTER SET utf8mb4' and 'CHARACTER SET latin1' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET latin1 COLLATE latin1_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_general_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET utf8mb4 COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_general_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE DEFAULT COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE DEFAULT' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE utf8mb4_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE utf8mb4_bin' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_swedish_ci COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_bin' and 'COLLATE latin1_swedish_ci' + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE latin1_bin COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE latin1_bin COLLATE latin1_bin +result ERROR: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE DEFAULT' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE latin1_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE utf8mb4_bin' and 'COLLATE latin1_bin' + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_bin COLLATE latin1_bin +result ERROR: Conflicting declarations: 'COLLATE latin1_swedish_ci' and 'COLLATE latin1_bin' + +OK 79 + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin CHARACTER SET DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin CHARACTER SET latin1 +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin CHARACTER SET utf8mb4 +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET utf8mb4 COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT COLLATE DEFAULT +result CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci COLLATE DEFAULT +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET DEFAULT COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin CHARACTER SET utf8mb4 COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET DEFAULT COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs COLLATE utf8mb4_bin COLLATE utf8mb4_bin COLLATE utf8mb4_bin +result CHARACTER SET utf8mb4 COLLATE utf8mb4_bin + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci CHARACTER SET latin1 COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE DEFAULT COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE DEFAULT COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE DEFAULT COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE DEFAULT COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci COLLATE latin1_swedish_ci +result CHARACTER SET latin1 COLLATE latin1_swedish_ci + +query CREATE DATABASE +attrs CHARACTER SET latin1 CHARACTER SET latin1 COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs COLLATE latin1_bin CHARACTER SET latin1 COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs CHARACTER SET latin1 COLLATE latin1_bin COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin + +query CREATE DATABASE +attrs COLLATE latin1_bin COLLATE latin1_bin COLLATE latin1_bin +result CHARACTER SET latin1 COLLATE latin1_bin +ALTER TABLE results RENAME TO results_create_db; +# +# Running ALTER DATABASE tests +# +CREATE TABLE results LIKE results_template; +CALL run_all('CREATE DATABASE db1 CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci', +'ALTER DATABASE db1 COMMENT '''' /*CSCL*/', +'DROP DATABASE db1'); +ALTER TABLE results RENAME TO results_alter_db; +# Displaying results that differ in CREATE DATABASE and ALTER DATABASE +# Only queries with no clauses or with COLLATE DEFAULT alone +# (without any other COLLATE or CHARACTER SET clauses) +# should differ: +# CREATE DATABASE db1 COMMENT '' [COLLATE DEFAULT]; -- means @@collation_server +# ALTER DATABASE db1 COMMENT '' COLLATE DEFAULT; -- means "the default collation of the current character set of db1" +# ALTER DATABASE db1 COMMENT ''; -- means "keep the current db1 collation" +CALL diff_result_tables('results_create_db', 'results_alter_db', ''); +COUNT(*) 400 +SUM(t1.result=t2.result) 396 +SUM(t1.result<>t2.result) 4 + +attrs +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci + +attrs COLLATE DEFAULT +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci + +attrs COLLATE DEFAULT COLLATE DEFAULT +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci + +attrs COLLATE DEFAULT COLLATE DEFAULT COLLATE DEFAULT +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci +# +# Running CREATE TABLE tests +# +CREATE DATABASE test1 COLLATE utf8mb4_unicode_ci; +CREATE TABLE results LIKE results_template; +CALL run_all('', +'CREATE TABLE test1.t1 (a int) /*CSCL*/', +'DROP TABLE IF EXISTS test1.t1'); +ALTER TABLE results RENAME TO results_create_table; +# Expect no difference to CREATE DATABASE +CALL diff_result_tables('results_create_db', 'results_create_table', ''); +COUNT(*) 400 +SUM(t1.result=t2.result) 400 +SUM(t1.result<>t2.result) 0 +DROP DATABASE test1; +# +# Running ALTER TABLE tests +# +CREATE DATABASE test1 COLLATE utf8mb4_unicode_ci; +CREATE TABLE results LIKE results_template; +CALL run_all('CREATE TABLE test1.t1(a INT) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci', +'ALTER TABLE test1.t1 COMMENT '''' /*CSCL*/', +'DROP TABLE test1.t1'); +ALTER TABLE results RENAME TO results_alter_table; +# Only queries with no clauses or with COLLATE DEFAULT alone +# (without any other COLLATE or CHARACTER SET clauses) +# should differ: +# CREATE TABLE test1.t1 COMMENT '' [COLLATE DEFAULT]; -- means "the default collation of the database test1" +# ALTER TABLE test1.t1 COMMENT '' COLLATE DEFAULT; -- means "the default collation of the current character set of test1.t1" +# ALTER TABLE test1.t1 COMMENT ''; -- means "keep the current collation of test.t1" +CALL diff_result_tables('results_create_table', 'results_alter_table', ''); +COUNT(*) 400 +SUM(t1.result=t2.result) 396 +SUM(t1.result<>t2.result) 4 + +attrs +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci + +attrs COLLATE DEFAULT +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci + +attrs COLLATE DEFAULT COLLATE DEFAULT +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci + +attrs COLLATE DEFAULT COLLATE DEFAULT COLLATE DEFAULT +aaa CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci +bbb CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci +DROP DATABASE test1; +# +# Running ALTER TABLE CONVERT TO tests +# +CREATE DATABASE test1 COLLATE utf8mb4_unicode_ci; +CREATE TABLE results LIKE results_template; +CALL run_all('CREATE TABLE test1.t1(a INT) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci', +'ALTER TABLE test1.t1 CONVERT TO /*CSCL*/', +'DROP TABLE test1.t1'); +ALTER TABLE results RENAME TO results_convert_table; +# CONVERT TO COLLATE (without CHARACTER SET) is not supported yet +CALL diff_result_tables_stat('results_alter_table', 'results_convert_table',''); +COUNT(*) 400 +SUM(t1.result=t2.result) 36 +SUM(t1.result<>t2.result) 364 +# Everything that did not fail on syntax error +# should give equal results with ALTER TABLE DEFAULT CHARACTER SET +# Expect 0 non-equal results: +CALL diff_result_tables('results_alter_table', 'results_convert_table', +'t2.result NOT RLIKE ''SQL syntax'''); +COUNT(*) 36 +SUM(t1.result=t2.result) 36 +SUM(t1.result<>t2.result) 0 +DROP DATABASE test1; +DROP PROCEDURE show_results_all; +DROP PROCEDURE run_all; +DROP PROCEDURE show_results; +DROP PROCEDURE exec; +DROP PROCEDURE run; +DROP PROCEDURE diff_result_tables; +DROP PROCEDURE diff_result_tables_stat; +DROP PROCEDURE diff_result_tables_records; +DROP TABLE clauses; +DROP TABLE results_template; +DROP TABLE results_create_db; +DROP TABLE results_alter_db; +DROP TABLE results_create_table; +DROP TABLE results_alter_table; +DROP TABLE results_convert_table; diff --git a/mysql-test/main/ctype_collate_context.test b/mysql-test/main/ctype_collate_context.test new file mode 100644 index 00000000000..0867237a223 --- /dev/null +++ b/mysql-test/main/ctype_collate_context.test @@ -0,0 +1,366 @@ +--source include/have_utf8mb4.inc + + +CREATE TABLE t0 (a VARCHAR(64)); +INSERT INTO t0 VALUES +('CHARACTER SET DEFAULT'), +('CHARACTER SET latin1'), +('CHARACTER SET utf8mb4'), +('COLLATE DEFAULT'), +('COLLATE utf8mb4_bin'), +('COLLATE latin1_swedish_ci'), +('COLLATE latin1_bin'); + +CREATE TABLE clauses +( + id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + cl1 VARCHAR(64) NOT NULL, + cl2 VARCHAR(64) NOT NULL, + cl3 VARCHAR(64) NOT NULL, + clause_count INT GENERATED ALWAYS AS ((cl1<>'') + (cl2<>'') + (cl3<>'')), + clauses TEXT GENERATED ALWAYS AS (CONCAT(cl1, + IF(cl2='','',' '), cl2, + IF(cl3='','',' '), cl3)) +); + +# No clauses +INSERT INTO clauses (cl1, cl2, cl3) + SELECT '' AS cl1, '' AS cl2, '' AS cl3; + +# One clause +INSERT INTO clauses (cl1, cl2, cl3) + SELECT t0.a AS cl1, '' AS cl2, '' AS cl3 + FROM t0; + +# Two clauses +INSERT INTO clauses (cl1, cl2, cl3) + SELECT t0.a AS cl1, t2.a AS cl2, '' AS cl3 + FROM t0 t0, t0 t2; + +# Three clauses +INSERT INTO clauses (cl1, cl2, cl3) + SELECT t0.a AS cl1, t2.a AS cl2, t3.a AS cl3 + FROM t0 t0, t0 t2, t0 t3; + +DROP TABLE t0; + + +CREATE TABLE results_template +( + id INT NOT NULL PRIMARY KEY, + result TEXT NOT NULL +); + + +DELIMITER $$; +CREATE PROCEDURE diff_result_tables_stat(table1 VARCHAR(64), + table2 VARCHAR(64), + cond VARCHAR(128)) +BEGIN + DECLARE query_counts TEXT DEFAULT + 'SELECT ' + ' COUNT(*),' + ' SUM(t1.result=t2.result),' + ' SUM(t1.result<>t2.result) ' + 'FROM table1 t1 JOIN table2 t2 USING (id)/*$(WHERE)*/'; + + SET query_counts=REPLACE(query_counts, 'table1', table1); + SET query_counts=REPLACE(query_counts, 'table2', table2); + IF (cond<>'') + THEN + SET query_counts=REPLACE(query_counts, '/*$(WHERE)*/', CONCAT('WHERE ',cond)); + END IF; + EXECUTE IMMEDIATE query_counts; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +CREATE PROCEDURE diff_result_tables_records(table1 VARCHAR(64), + table2 VARCHAR(64), + cond VARCHAR(128)) +BEGIN + DECLARE query_records TEXT DEFAULT + 'SELECT ' + ' '''' AS ``,' + ' clauses.clauses AS attrs,' + ' t1.result AS `aaa`,' + ' t2.result AS `bbb` ' + ' FROM table1 t1' + ' JOIN table2 t2 USING (id)' + ' JOIN clauses USING (id) ' + ' WHERE t1.result<>t2.result /*$(COND)*/ ORDER BY t1.id'; + + SET query_records=REPLACE(query_records, 'table1', table1); + SET query_records=REPLACE(query_records, 'table2', table2); + IF (cond<>'') + THEN + SET query_records=REPLACE(query_records, '/*$(COND)*/', CONCAT('AND ',cond)); + END IF; + EXECUTE IMMEDIATE query_records; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +CREATE PROCEDURE diff_result_tables(table1 VARCHAR(64), + table2 VARCHAR(64), + cond VARCHAR(128)) +BEGIN + CALL diff_result_tables_stat(table1, table2, cond); + CALL diff_result_tables_records(table1, table2, cond); +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +CREATE PROCEDURE exec(query_bootstrap TEXT, + query_pattern TEXT, + query_cleanup TEXT, + id INT, + clauses TEXT) +BEGIN + DECLARE query TEXT DEFAULT REPLACE(query_pattern, '/*CSCL*/',clauses); + DECLARE result TEXT DEFAULT NULL; + DECLARE CONTINUE HANDLER FOR + 1064, /*ER_PARSE_ERROR*/ + 1302, /*ER_CONFLICTING_DECLARATIONS*/ + 1253 /*ER_COLLATION_CHARSET_MISMATCH*/ + BEGIN + GET DIAGNOSTICS CONDITION 1 result=MESSAGE_TEXT; + SET result=CONCAT('ERROR: ', result); + END; + IF query_bootstrap<>'' + THEN + EXECUTE IMMEDIATE query_bootstrap; + END IF; + EXECUTE IMMEDIATE query; + IF result IS NULL + THEN + IF query_pattern LIKE '%DATABASE%' + THEN + SET result=(SELECT CONCAT('CHARACTER SET ', DEFAULT_CHARACTER_SET_NAME, + ' COLLATE ', DEFAULT_COLLATION_NAME) + FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='db1'); + ELSE + SET result=(SELECT CONCAT('CHARACTER SET ', SUBSTRING_INDEX(TABLE_COLLATION,'_',1), + ' COLLATE ', TABLE_COLLATION) + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test1'); + END IF; + END IF; + INSERT INTO results (id, result) VALUES (id, result); + IF query_cleanup<>'' + THEN + EXECUTE IMMEDIATE query_cleanup; + END IF; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +CREATE PROCEDURE show_results(query TEXT, clause_count_arg INT) +BEGIN + SELECT '' AS ``, CONCAT(clause_count_arg, ' clauses') AS `TEST:`; + SELECT '' AS ``, COUNT(*) AS `TOTAL` + FROM results JOIN clauses USING (id) + WHERE clauses.clause_count=clause_count_arg; + + -- Display erroneous results + SELECT '' AS ``, COUNT(*) AS `ERROR` + FROM results JOIN clauses USING (id) + WHERE clauses.clause_count=clause_count_arg + AND result RLIKE '^ERROR'; + + SELECT '' AS ``, query, clauses AS attrs, result + FROM results JOIN clauses USING (id) + WHERE clauses.clause_count=clause_count_arg + AND result RLIKE '^ERROR' ORDER BY id; + + -- Display successfull results + SELECT '' AS ``, COUNT(*) AS `OK` + FROM results JOIN clauses USING (id) + WHERE clauses.clause_count=clause_count_arg + AND result NOT RLIKE '^ERROR'; + + SELECT '' AS ``, query, clauses AS attrs, result + FROM results JOIN clauses USING (id) + WHERE clauses.clause_count=clause_count_arg + AND result NOT RLIKE '^ERROR' ORDER BY id; +END; +$$ +DELIMITER ;$$ + + +DELIMITER $$; +CREATE PROCEDURE run(query_bootstrap TEXT, + query TEXT, + query_cleanup TEXT, + clause_count_arg INT) +BEGIN + FOR rec IN (SELECT * FROM clauses WHERE clause_count=clause_count_arg) + DO + CALL exec(query_bootstrap, query, query_cleanup, rec.id, rec.clauses); + END FOR; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +CREATE PROCEDURE run_all(query_bootstrap TEXT, query TEXT, query_cleanup TEXT) +BEGIN + DECLARE msg TEXT; + DECLARE count_results INT; + DECLARE count_clauses INT; + FOR i IN 0..3 + DO + CALL run(query_bootstrap, query, query_cleanup, i); + END FOR; + SET count_clauses=(SELECT COUNT(*) FROM clauses); + SET count_results=(SELECT COUNT(*) FROM results); + IF (count_results<>count_clauses) + THEN + SET msg=CONCAT('Got ', count_results,' rows in `results`; ', + 'Expected ', count_clauses, ' rows'); + SIGNAL SQLSTATE '45000' + SET MYSQL_ERRNO=30001, + MESSAGE_TEXT=msg; + END IF; +END; +$$ +DELIMITER ;$$ + +DELIMITER $$; +CREATE PROCEDURE show_results_all(query TEXT) +BEGIN + FOR i IN 0..3 + DO + CALL show_results(query, i); + END FOR; +END; +$$ +DELIMITER ;$$ + + +--vertical_results + +--echo # +--echo # Running CREATE DATABASE tests +--echo # Displaying all results +--echo # + +SET @@collation_server=utf8mb4_unicode_ci; +CREATE TABLE results LIKE results_template; +CALL run_all('','CREATE DATABASE db1 /*CSCL*/', 'DROP DATABASE IF EXISTS db1'); +CALL show_results_all('CREATE DATABASE'); +ALTER TABLE results RENAME TO results_create_db; + +--echo # +--echo # Running ALTER DATABASE tests +--echo # + +CREATE TABLE results LIKE results_template; +CALL run_all('CREATE DATABASE db1 CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci', + 'ALTER DATABASE db1 COMMENT '''' /*CSCL*/', + 'DROP DATABASE db1'); +ALTER TABLE results RENAME TO results_alter_db; + +--echo # Displaying results that differ in CREATE DATABASE and ALTER DATABASE +--echo # Only queries with no clauses or with COLLATE DEFAULT alone +--echo # (without any other COLLATE or CHARACTER SET clauses) +--echo # should differ: +--echo # CREATE DATABASE db1 COMMENT '' [COLLATE DEFAULT]; -- means @@collation_server +--echo # ALTER DATABASE db1 COMMENT '' COLLATE DEFAULT; -- means "the default collation of the current character set of db1" +--echo # ALTER DATABASE db1 COMMENT ''; -- means "keep the current db1 collation" + +CALL diff_result_tables('results_create_db', 'results_alter_db', ''); + + +--echo # +--echo # Running CREATE TABLE tests +--echo # + +CREATE DATABASE test1 COLLATE utf8mb4_unicode_ci; + +CREATE TABLE results LIKE results_template; +CALL run_all('', + 'CREATE TABLE test1.t1 (a int) /*CSCL*/', + 'DROP TABLE IF EXISTS test1.t1'); +ALTER TABLE results RENAME TO results_create_table; +--echo # Expect no difference to CREATE DATABASE +CALL diff_result_tables('results_create_db', 'results_create_table', ''); + +DROP DATABASE test1; + + +--echo # +--echo # Running ALTER TABLE tests +--echo # + +CREATE DATABASE test1 COLLATE utf8mb4_unicode_ci; + +CREATE TABLE results LIKE results_template; +CALL run_all('CREATE TABLE test1.t1(a INT) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci', + 'ALTER TABLE test1.t1 COMMENT '''' /*CSCL*/', + 'DROP TABLE test1.t1'); +ALTER TABLE results RENAME TO results_alter_table; +--echo # Only queries with no clauses or with COLLATE DEFAULT alone +--echo # (without any other COLLATE or CHARACTER SET clauses) +--echo # should differ: +--echo # CREATE TABLE test1.t1 COMMENT '' [COLLATE DEFAULT]; -- means "the default collation of the database test1" +--echo # ALTER TABLE test1.t1 COMMENT '' COLLATE DEFAULT; -- means "the default collation of the current character set of test1.t1" +--echo # ALTER TABLE test1.t1 COMMENT ''; -- means "keep the current collation of test.t1" +CALL diff_result_tables('results_create_table', 'results_alter_table', ''); +#SELECT result FROM ( +#(SELECT * FROM results_create_table) +#EXCEPT +#(SELECT * FROM results_alter_table)) t1; + +DROP DATABASE test1; + +--echo # +--echo # Running ALTER TABLE CONVERT TO tests +--echo # + +CREATE DATABASE test1 COLLATE utf8mb4_unicode_ci; + +CREATE TABLE results LIKE results_template; +CALL run_all('CREATE TABLE test1.t1(a INT) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci', + 'ALTER TABLE test1.t1 CONVERT TO /*CSCL*/', + 'DROP TABLE test1.t1'); +ALTER TABLE results RENAME TO results_convert_table; + +--echo # CONVERT TO COLLATE (without CHARACTER SET) is not supported yet + +CALL diff_result_tables_stat('results_alter_table', 'results_convert_table',''); + +--echo # Everything that did not fail on syntax error +--echo # should give equal results with ALTER TABLE DEFAULT CHARACTER SET +--echo # Expect 0 non-equal results: +CALL diff_result_tables('results_alter_table', 'results_convert_table', + 't2.result NOT RLIKE ''SQL syntax'''); + +DROP DATABASE test1; + +--horizontal_results + + +DROP PROCEDURE show_results_all; +DROP PROCEDURE run_all; +DROP PROCEDURE show_results; +DROP PROCEDURE exec; +DROP PROCEDURE run; +DROP PROCEDURE diff_result_tables; +DROP PROCEDURE diff_result_tables_stat; +DROP PROCEDURE diff_result_tables_records; +DROP TABLE clauses; +DROP TABLE results_template; +DROP TABLE results_create_db; +DROP TABLE results_alter_db; +DROP TABLE results_create_table; +DROP TABLE results_alter_table; +DROP TABLE results_convert_table; diff --git a/mysql-test/main/ctype_collate_database.result b/mysql-test/main/ctype_collate_database.result new file mode 100644 index 00000000000..7a4f1ef8c60 --- /dev/null +++ b/mysql-test/main/ctype_collate_database.result @@ -0,0 +1,106 @@ +# +# MDEV-27896 Wrong result upon COLLATE latin1_bin CHARACTER SET latin1 on the table or the database level +# +CREATE DATABASE db1 COLLATE latin1_bin CHARACTER SET latin1; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_bin */ +DROP DATABASE db1; +CREATE VIEW cscl AS +SELECT +DEFAULT_CHARACTER_SET_NAME, +DEFAULT_COLLATION_NAME +FROM +INFORMATION_SCHEMA.SCHEMATA +WHERE +SCHEMA_NAME='db1'; +SET collation_server=utf8mb4_unicode_ci; +CREATE DATABASE db1 COMMENT 'test'; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_unicode_ci +DROP DATABASE db1; +CREATE DATABASE db1 COLLATE DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 COLLATE latin1_bin; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +latin1 latin1_bin +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET latin1; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +latin1 latin1_swedish_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET latin1 COLLATE DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +latin1 latin1_swedish_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET latin1 COLLATE latin1_bin; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +latin1 latin1_bin +DROP DATABASE db1; +CREATE DATABASE db1 COLLATE DEFAULT CHARACTER SET latin1; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +latin1 latin1_swedish_ci +DROP DATABASE db1; +CREATE DATABASE db1 COLLATE latin1_bin CHARACTER SET latin1; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +latin1 latin1_bin +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET DEFAULT CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET DEFAULT COLLATE DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 COLLATE DEFAULT CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET DEFAULT CHARACTER SET utf8mb4; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET utf8mb4 CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_general_ci +DROP DATABASE db1; +CREATE DATABASE db1 CHARACTER SET DEFAULT CHARACTER SET latin1; +ERROR HY000: Conflicting declarations: 'CHARACTER SET DEFAULT (utf8mb4)' and 'CHARACTER SET latin1' +CREATE DATABASE db1 CHARACTER SET latin1 CHARACTER SET DEFAULT; +ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT (utf8mb4)' +CREATE DATABASE db1 CHARACTER SET DEFAULT COLLATE latin1_bin; +ERROR 42000: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' +CREATE DATABASE db1 COLLATE latin1_bin CHARACTER SET DEFAULT; +ERROR 42000: COLLATION 'latin1_bin' is not valid for CHARACTER SET 'utf8mb4' +CREATE DATABASE db1 CHARACTER SET DEFAULT COLLATE utf8mb4_bin; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_bin +DROP DATABASE db1; +CREATE DATABASE db1 COLLATE utf8mb4_bin CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME +utf8mb4 utf8mb4_bin +DROP DATABASE db1; +DROP VIEW cscl; diff --git a/mysql-test/main/ctype_collate_database.test b/mysql-test/main/ctype_collate_database.test new file mode 100644 index 00000000000..64d3c2fddb8 --- /dev/null +++ b/mysql-test/main/ctype_collate_database.test @@ -0,0 +1,96 @@ +--source include/have_utf8mb4.inc + +--echo # +--echo # MDEV-27896 Wrong result upon COLLATE latin1_bin CHARACTER SET latin1 on the table or the database level +--echo # + +CREATE DATABASE db1 COLLATE latin1_bin CHARACTER SET latin1; +SHOW CREATE DATABASE db1; +DROP DATABASE db1; + + +CREATE VIEW cscl AS +SELECT + DEFAULT_CHARACTER_SET_NAME, + DEFAULT_COLLATION_NAME +FROM + INFORMATION_SCHEMA.SCHEMATA +WHERE + SCHEMA_NAME='db1'; + +SET collation_server=utf8mb4_unicode_ci; +CREATE DATABASE db1 COMMENT 'test'; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 COLLATE DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 COLLATE latin1_bin; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET latin1; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET latin1 COLLATE DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET latin1 COLLATE latin1_bin; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 COLLATE DEFAULT CHARACTER SET latin1; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 COLLATE latin1_bin CHARACTER SET latin1; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET DEFAULT CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET DEFAULT COLLATE DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 COLLATE DEFAULT CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET DEFAULT CHARACTER SET utf8mb4; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 CHARACTER SET utf8mb4 CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +--error ER_CONFLICTING_DECLARATIONS +CREATE DATABASE db1 CHARACTER SET DEFAULT CHARACTER SET latin1; +--error ER_CONFLICTING_DECLARATIONS +CREATE DATABASE db1 CHARACTER SET latin1 CHARACTER SET DEFAULT; + +--error ER_COLLATION_CHARSET_MISMATCH +CREATE DATABASE db1 CHARACTER SET DEFAULT COLLATE latin1_bin; +--error ER_COLLATION_CHARSET_MISMATCH +CREATE DATABASE db1 COLLATE latin1_bin CHARACTER SET DEFAULT; + +CREATE DATABASE db1 CHARACTER SET DEFAULT COLLATE utf8mb4_bin; +SELECT * FROM cscl; +DROP DATABASE db1; + +CREATE DATABASE db1 COLLATE utf8mb4_bin CHARACTER SET DEFAULT; +SELECT * FROM cscl; +DROP DATABASE db1; + +DROP VIEW cscl; diff --git a/mysql-test/main/ctype_collate_table.result b/mysql-test/main/ctype_collate_table.result new file mode 100644 index 00000000000..15b9360e748 --- /dev/null +++ b/mysql-test/main/ctype_collate_table.result @@ -0,0 +1,27 @@ +# +# MDEV-27896 Wrong result upon `COLLATE latin1_bin CHARACTER SET latin1` on the table or the database level +# +CREATE TABLE t1 (a CHAR) COLLATE latin1_bin CHARACTER SET latin1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) COLLATE latin1_bin DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin +DROP TABLE t1; +# +# MDEV-27782 Wrong columns when using table level `CHARACTER SET utf8mb4 COLLATE DEFAULT` +# +CREATE TABLE t1 (a CHAR(10)) CHARACTER SET latin1 COLLATE DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf8mb4 COLLATE DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 +DROP TABLE t1; diff --git a/mysql-test/main/ctype_collate_table.test b/mysql-test/main/ctype_collate_table.test new file mode 100644 index 00000000000..1aeb0d6bebd --- /dev/null +++ b/mysql-test/main/ctype_collate_table.test @@ -0,0 +1,22 @@ +--source include/have_utf8mb4.inc + +--echo # +--echo # MDEV-27896 Wrong result upon `COLLATE latin1_bin CHARACTER SET latin1` on the table or the database level +--echo # + +CREATE TABLE t1 (a CHAR) COLLATE latin1_bin CHARACTER SET latin1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + + +--echo # +--echo # MDEV-27782 Wrong columns when using table level `CHARACTER SET utf8mb4 COLLATE DEFAULT` +--echo # + +CREATE TABLE t1 (a CHAR(10)) CHARACTER SET latin1 COLLATE DEFAULT; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR(10)) CHARACTER SET utf8mb4 COLLATE DEFAULT; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/main/ctype_create.result b/mysql-test/main/ctype_create.result index 4e8289a8ad6..ac2dacf1954 100644 --- a/mysql-test/main/ctype_create.result +++ b/mysql-test/main/ctype_create.result @@ -78,37 +78,113 @@ ALTER DATABASE `` DEFAULT CHARACTER SET latin2; ERROR 42000: Incorrect database name '' USE test; # -# Start of 10.0 tests +# End of 10.0 tests +# +# +# Start of 10.9 tests # # # MDEV-7387 Alter table xxx CHARACTER SET utf8, CONVERT TO CHARACTER SET latin1 should fail +# MDEV-28644 Unexpected error on ALTER TABLE t1 CONVERT TO CHARACTER SET utf8mb3, DEFAULT CHARACTER SET utf8mb4 # CREATE DATABASE tmp DEFAULT CHARACTER SET latin5; USE tmp; CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET DEFAULT, CHARACTER SET utf8; -ERROR HY000: Conflicting declarations: 'CHARACTER SET DEFAULT' and 'CHARACTER SET utf8mb3' +ERROR HY000: Conflicting declarations: 'CHARACTER SET DEFAULT (latin5)' and 'CHARACTER SET utf8mb3' CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8, CHARACTER SET DEFAULT; -ERROR HY000: Conflicting declarations: 'CHARACTER SET utf8mb3' and 'CHARACTER SET DEFAULT' +ERROR HY000: Conflicting declarations: 'CHARACTER SET utf8mb3' and 'CHARACTER SET DEFAULT (latin5)' CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET utf8, CHARACTER SET utf8; DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET DEFAULT, CHARACTER SET DEFAULT; DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, b VARCHAR(10) CHARACTER SET utf8); ALTER TABLE t1 CONVERT TO CHARACTER SET utf8, CHARACTER SET latin1; -ERROR HY000: Conflicting declarations: 'CHARACTER SET utf8mb3' and 'CHARACTER SET latin1' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `b` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 ALTER TABLE t1 CONVERT TO CHARACTER SET utf8, CHARACTER SET DEFAULT; -ERROR HY000: Conflicting declarations: 'CHARACTER SET utf8mb3' and 'CHARACTER SET DEFAULT' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `b` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 CONVERT TO CHARACTER SET latin1, CHARACTER SET utf8; -ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET utf8mb3' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 ALTER TABLE t1 CONVERT TO CHARACTER SET latin1, CHARACTER SET DEFAULT; -ERROR HY000: Conflicting declarations: 'CHARACTER SET latin1' and 'CHARACTER SET DEFAULT' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin5 ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT, CHARACTER SET utf8; -ERROR HY000: Conflicting declarations: 'CHARACTER SET latin5' and 'CHARACTER SET utf8mb3' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin5 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin5 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT, CHARACTER SET latin1; -ERROR HY000: Conflicting declarations: 'CHARACTER SET latin5' and 'CHARACTER SET latin1' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin5 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin5 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHARACTER SET latin1, CONVERT TO CHARACTER SET utf8; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `b` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHARACTER SET DEFAULT, CONVERT TO CHARACTER SET utf8; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL, + `b` varchar(10) CHARACTER SET utf8mb3 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin5 +ALTER TABLE t1 CHARACTER SET utf8, CONVERT TO CHARACTER SET latin1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 +ALTER TABLE t1 CHARACTER SET DEFAULT, CONVERT TO CHARACTER SET latin1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin1 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin1 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin5 +ALTER TABLE t1 CHARACTER SET utf8, CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin5 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin5 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 +ALTER TABLE t1 CHARACTER SET latin1, CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) CHARACTER SET latin5 DEFAULT NULL, + `b` varchar(10) CHARACTER SET latin5 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; DROP DATABASE tmp; USE test; # -# End of 10.0 tests +# End of 10.9 tests # diff --git a/mysql-test/main/ctype_create.test b/mysql-test/main/ctype_create.test index 6ccc83521bd..ec36d6b4dde 100644 --- a/mysql-test/main/ctype_create.test +++ b/mysql-test/main/ctype_create.test @@ -108,11 +108,16 @@ ALTER DATABASE `` DEFAULT CHARACTER SET latin2; USE test; --echo # ---echo # Start of 10.0 tests +--echo # End of 10.0 tests +--echo # + +--echo # +--echo # Start of 10.9 tests --echo # --echo # --echo # MDEV-7387 Alter table xxx CHARACTER SET utf8, CONVERT TO CHARACTER SET latin1 should fail +--echo # MDEV-28644 Unexpected error on ALTER TABLE t1 CONVERT TO CHARACTER SET utf8mb3, DEFAULT CHARACTER SET utf8mb4 --echo # CREATE DATABASE tmp DEFAULT CHARACTER SET latin5; USE tmp; @@ -125,23 +130,48 @@ DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(10)) CHARACTER SET DEFAULT, CHARACTER SET DEFAULT; DROP TABLE t1; + CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, b VARCHAR(10) CHARACTER SET utf8); ---error ER_CONFLICTING_DECLARATIONS ALTER TABLE t1 CONVERT TO CHARACTER SET utf8, CHARACTER SET latin1; ---error ER_CONFLICTING_DECLARATIONS +SHOW CREATE TABLE t1; + ALTER TABLE t1 CONVERT TO CHARACTER SET utf8, CHARACTER SET DEFAULT; ---error ER_CONFLICTING_DECLARATIONS +SHOW CREATE TABLE t1; + ALTER TABLE t1 CONVERT TO CHARACTER SET latin1, CHARACTER SET utf8; ---error ER_CONFLICTING_DECLARATIONS +SHOW CREATE TABLE t1; + ALTER TABLE t1 CONVERT TO CHARACTER SET latin1, CHARACTER SET DEFAULT; ---error ER_CONFLICTING_DECLARATIONS +SHOW CREATE TABLE t1; + ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT, CHARACTER SET utf8; ---error ER_CONFLICTING_DECLARATIONS +SHOW CREATE TABLE t1; + ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT, CHARACTER SET latin1; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 CHARACTER SET latin1, CONVERT TO CHARACTER SET utf8; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 CHARACTER SET DEFAULT, CONVERT TO CHARACTER SET utf8; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 CHARACTER SET utf8, CONVERT TO CHARACTER SET latin1; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 CHARACTER SET DEFAULT, CONVERT TO CHARACTER SET latin1; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 CHARACTER SET utf8, CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t1; + +ALTER TABLE t1 CHARACTER SET latin1, CONVERT TO CHARACTER SET DEFAULT; +SHOW CREATE TABLE t1; + DROP TABLE t1; DROP DATABASE tmp; USE test; --echo # ---echo # End of 10.0 tests +--echo # End of 10.9 tests --echo # diff --git a/mysql-test/main/ddl_i18n_koi8r.result b/mysql-test/main/ddl_i18n_koi8r.result index 074fb4c6fd8..feeab292da0 100644 --- a/mysql-test/main/ddl_i18n_koi8r.result +++ b/mysql-test/main/ddl_i18n_koi8r.result @@ -723,6 +723,8 @@ utf8mb3_general_ci utf8mb3_general_ci CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */; USE `mysqltest1`; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -730,8 +732,6 @@ ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = koi8r */ ; /*!50003 SET character_set_results = koi8r */ ; /*!50003 SET collation_connection = koi8r_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`( INOUT ÐÁÒÁÍ1 CHAR(10), @@ -757,6 +757,8 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -764,8 +766,6 @@ ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = koi8r */ ; /*!50003 SET character_set_results = koi8r */ ; /*!50003 SET collation_connection = koi8r_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`( INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8, @@ -799,6 +799,8 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */; USE `mysqltest2`; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -806,8 +808,6 @@ ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = koi8r */ ; /*!50003 SET character_set_results = koi8r */ ; /*!50003 SET collation_connection = koi8r_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`( INOUT ÐÁÒÁÍ1 CHAR(10), @@ -833,6 +833,8 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -840,8 +842,6 @@ ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = koi8r */ ; /*!50003 SET character_set_results = koi8r */ ; /*!50003 SET collation_connection = koi8r_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`( INOUT ÐÁÒÁÍ1 CHAR(10) CHARACTER SET utf8, diff --git a/mysql-test/main/ddl_i18n_utf8.result b/mysql-test/main/ddl_i18n_utf8.result index 53190dcc22e..312c77988ee 100644 --- a/mysql-test/main/ddl_i18n_utf8.result +++ b/mysql-test/main/ddl_i18n_utf8.result @@ -723,6 +723,8 @@ utf8mb3_general_ci utf8mb3_general_ci CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 */; USE `mysqltest1`; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -730,8 +732,6 @@ ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = utf8mb3 */ ; /*!50003 SET character_set_results = utf8mb3 */ ; /*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`( INOUT парам1 CHAR(10), @@ -757,6 +757,8 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -764,8 +766,6 @@ ALTER DATABASE `mysqltest1` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = utf8mb3 */ ; /*!50003 SET character_set_results = utf8mb3 */ ; /*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p2`( INOUT парам1 CHAR(10) CHARACTER SET utf8, @@ -799,6 +799,8 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ; CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 */; USE `mysqltest2`; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -806,8 +808,6 @@ ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = utf8mb3 */ ; /*!50003 SET character_set_results = utf8mb3 */ ; /*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p3`( INOUT парам1 CHAR(10), @@ -833,6 +833,8 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `mysqltest2` CHARACTER SET cp866 COLLATE cp866_general_ci ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -840,8 +842,6 @@ ALTER DATABASE `mysqltest2` CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci ; /*!50003 SET character_set_client = utf8mb3 */ ; /*!50003 SET character_set_results = utf8mb3 */ ; /*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p4`( INOUT парам1 CHAR(10) CHARACTER SET utf8, diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result index 493101f10ee..d840731c79d 100644 --- a/mysql-test/main/default.result +++ b/mysql-test/main/default.result @@ -1,5 +1,3 @@ -drop table if exists t1,t2,t3,t4,t5,t6; -drop database if exists mysqltest; set sql_mode=""; CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', b varchar(1) binary NOT NULL DEFAULT ' ', @@ -3135,7 +3133,9 @@ t3 CREATE TABLE `t3` ( `max(c)` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2, t3; +# # MDEV-11359: Implement IGNORE for bulk operation +# create table t1 (a int primary key default 0, b int default 3); insert into t1 values (1, ignore); insert into t1 values (2, ignore); @@ -3354,6 +3354,9 @@ a b 30 31 drop table t1; set sql_mode=default; +# +# MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4) +# create table t1 (a int default b, b int default 4, t text); insert t1 (b, t) values (5, '1 column is omitted'); insert t1 values (default, 5, '2 column gets DEFAULT, keyword'); @@ -3376,8 +3379,14 @@ a b t 5 5 8 reversed, also expression DEFAULT(0)+0 5 5 9 reversed, the value of the DEFAULT(a), that is b drop table t1; +# +# MDEV-10352 Server crashes in Field::set_default on CREATE TABLE +# create table t1 (col1 int default(-(default(col1)))); ERROR 01000: Expression for field `col1` is referring to uninitialized field `col1` +# +# MDEV-10354 Assertion `! is_set()' failed in Diagnostics_area::set_ok_status on CREATE TABLE with invalid default +# create table t1 (col int default (yearweek((exp(710))))); ERROR 22003: DOUBLE value is out of range in 'exp(710)' # @@ -3395,7 +3404,37 @@ ERROR 01000: Expression for field `a` is referring to uninitialized field `a` show warnings; Level Code Message Error 4029 Expression for field `a` is referring to uninitialized field `a` -# end of 10.2 test +# +# MDEV-26423: MariaDB server crash in Create_tmp_table::finalize +# +CREATE TABLE t1 (pk varchar(36) DEFAULT uuid()); +INSERT INTO t1 VALUES (),(); +SELECT 1 FROM t1 GROUP BY DEFAULT(pk); +1 +1 +1 +DROP TABLE t1; +# +# MDEV-28402: ASAN heap-use-after-free in create_tmp_table, +# Assertion `l_offset >= 0 && table->s->rec_buff_length - l_offset > 0' +# +CREATE TABLE t (a INT, KEY (a)); +INSERT INTO t VALUES (1),(2); +SELECT DISTINCT DEFAULT(a), CASE a WHEN 0 THEN 1 ELSE 2 END FROM t GROUP BY a WITH ROLLUP; +DEFAULT(a) CASE a WHEN 0 THEN 1 ELSE 2 END +NULL 2 +DROP TABLE t; +CREATE TABLE t (a INT, KEY (a)); +INSERT INTO t VALUES (1),(2); +CREATE ALGORITHM=TEMPTABLE VIEW v AS SELECT * FROM t; +SELECT DISTINCT DEFAULT(a), CASE a WHEN 0 THEN 1 ELSE 2 END FROM v GROUP BY a WITH ROLLUP; +DEFAULT(a) CASE a WHEN 0 THEN 1 ELSE 2 END +NULL 2 +DROP TABLE t; +DROP VIEW v; +# +# End of 10.2 test +# # # MDEV-22703 DEFAULT() on a BLOB column can overwrite the default # record, which can cause crashes when accessing already released @@ -3411,4 +3450,18 @@ length(DEFAULT(h)) 25 INSERT INTO t1 () VALUES (); drop table t1; -# end of 10.3 test +# +# End of 10.3 test +# +# +# MDEV-26423: MariaDB server crash in Create_tmp_table::finalize +# +CREATE TABLE t1 (pk text DEFAULT length(uuid())); +INSERT INTO t1 VALUES (),(); +SELECT 1 FROM t1 GROUP BY DEFAULT(pk); +1 +1 +DROP TABLE t1; +# +# End of 10.4 test +# diff --git a/mysql-test/main/default.test b/mysql-test/main/default.test index bcd6ef7a9fb..3064209a4a2 100644 --- a/mysql-test/main/default.test +++ b/mysql-test/main/default.test @@ -1,16 +1,10 @@ --source include/have_innodb.inc # -# test of already fixed bugs -# ---disable_warnings -drop table if exists t1,t2,t3,t4,t5,t6; -drop database if exists mysqltest; - -# # Bug 10838 # Insert causes warnings for no default values and corrupts tables # +--disable_warnings set sql_mode=""; CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', b varchar(1) binary NOT NULL DEFAULT ' ', @@ -1891,7 +1885,9 @@ show create table t2; show create table t3; drop table t1, t2, t3; +--echo # --echo # MDEV-11359: Implement IGNORE for bulk operation +--echo # create table t1 (a int primary key default 0, b int default 3); insert into t1 values (1, ignore); insert into t1 values (2, ignore); @@ -2071,9 +2067,9 @@ select * from t1; drop table t1; set sql_mode=default; -# -# MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4) -# +--echo # +--echo # MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4) +--echo # create table t1 (a int default b, b int default 4, t text); insert t1 (b, t) values (5, '1 column is omitted'); insert t1 values (default, 5, '2 column gets DEFAULT, keyword'); @@ -2088,15 +2084,15 @@ insert t1 (t,b,a) values ('9 reversed, the value of the DEFAULT(a), that is b', select * from t1 order by t; drop table t1; -# -# MDEV-10352 Server crashes in Field::set_default on CREATE TABLE -# +--echo # +--echo # MDEV-10352 Server crashes in Field::set_default on CREATE TABLE +--echo # --error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD create table t1 (col1 int default(-(default(col1)))); -# -# MDEV-10354 Assertion `! is_set()' failed in Diagnostics_area::set_ok_status on CREATE TABLE with invalid default -# +--echo # +--echo # MDEV-10354 Assertion `! is_set()' failed in Diagnostics_area::set_ok_status on CREATE TABLE with invalid default +--echo # --error ER_DATA_OUT_OF_RANGE create table t1 (col int default (yearweek((exp(710))))); @@ -2116,7 +2112,34 @@ DROP TABLE t1; create table t1 (a int as (a)); show warnings; ---echo # end of 10.2 test + +--echo # +--echo # MDEV-26423: MariaDB server crash in Create_tmp_table::finalize +--echo # + +CREATE TABLE t1 (pk varchar(36) DEFAULT uuid()); +INSERT INTO t1 VALUES (),(); +SELECT 1 FROM t1 GROUP BY DEFAULT(pk); +DROP TABLE t1; + +--echo # +--echo # MDEV-28402: ASAN heap-use-after-free in create_tmp_table, +--echo # Assertion `l_offset >= 0 && table->s->rec_buff_length - l_offset > 0' +--echo # +CREATE TABLE t (a INT, KEY (a)); +INSERT INTO t VALUES (1),(2); +SELECT DISTINCT DEFAULT(a), CASE a WHEN 0 THEN 1 ELSE 2 END FROM t GROUP BY a WITH ROLLUP; +DROP TABLE t; + +CREATE TABLE t (a INT, KEY (a)); +INSERT INTO t VALUES (1),(2); +CREATE ALGORITHM=TEMPTABLE VIEW v AS SELECT * FROM t; +SELECT DISTINCT DEFAULT(a), CASE a WHEN 0 THEN 1 ELSE 2 END FROM v GROUP BY a WITH ROLLUP; +DROP TABLE t; +DROP VIEW v; +--echo # +--echo # End of 10.2 test +--echo # --echo # --echo # MDEV-22703 DEFAULT() on a BLOB column can overwrite the default @@ -2134,4 +2157,18 @@ SELECT length(DEFAULT(h)) FROM t1; INSERT INTO t1 () VALUES (); drop table t1; ---echo # end of 10.3 test +--echo # +--echo # End of 10.3 test +--echo # + +--echo # +--echo # MDEV-26423: MariaDB server crash in Create_tmp_table::finalize +--echo # +CREATE TABLE t1 (pk text DEFAULT length(uuid())); +INSERT INTO t1 VALUES (),(); +SELECT 1 FROM t1 GROUP BY DEFAULT(pk); +DROP TABLE t1; + +--echo # +--echo # End of 10.4 test +--echo # diff --git a/mysql-test/main/default_innodb.result b/mysql-test/main/default_innodb.result new file mode 100644 index 00000000000..81e9672df24 --- /dev/null +++ b/mysql-test/main/default_innodb.result @@ -0,0 +1,18 @@ +# +# MDEV-26423: MariaDB server crash in Create_tmp_table::finalize +# +CREATE TABLE v0 ( +v2 DATE DEFAULT ( v1 MOD 68321183.000000 ) , +v1 DATETIME NULL ) engine=innodb; +SHOW DATABASES LIKE 'x'; +Database (x) +SELECT DISTINCT v2 , v1 , DEFAULT ( v2 ) FROM v0; +v2 v1 DEFAULT ( v2 ) +DROP TABLE v0; +CREATE TABLE t1 (v1 DATE, v2 DATE DEFAULT(v1)) engine=innodb; +SELECT DISTINCT DEFAULT(v2) FROM t1 ; +DEFAULT(v2) +DROP TABLE t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/default_innodb.test b/mysql-test/main/default_innodb.test new file mode 100644 index 00000000000..2fc74950845 --- /dev/null +++ b/mysql-test/main/default_innodb.test @@ -0,0 +1,22 @@ + +--source include/have_innodb.inc + +--echo # +--echo # MDEV-26423: MariaDB server crash in Create_tmp_table::finalize +--echo # + +CREATE TABLE v0 ( + v2 DATE DEFAULT ( v1 MOD 68321183.000000 ) , + v1 DATETIME NULL ) engine=innodb; +SHOW DATABASES LIKE 'x'; +SELECT DISTINCT v2 , v1 , DEFAULT ( v2 ) FROM v0; +DROP TABLE v0; + +CREATE TABLE t1 (v1 DATE, v2 DATE DEFAULT(v1)) engine=innodb; +SELECT DISTINCT DEFAULT(v2) FROM t1 ; +DROP TABLE t1; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index ed596d10205..c73bc43a2a4 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -3704,4 +3704,64 @@ f2 f3 DROP PROCEDURE p1; DROP VIEW v1,v2,v3; DROP TABLE t1; +# +# MDEV-27212: 2-nd execution of PS for select with embedded derived tables +# and correlated subquery in select list of outer derived +# +create table t1 ( id int, id2 int ) engine=myisam; +create table t2 ( x3 int , x1 int , x2 int, a1 int) engine=myisam; +insert into t1 values (3, 2), (4, 2), (3, 4); +insert into t2 values (1, 2, 2, 1), (1, 3, 3, 2), (2, 3, 3, 1); +prepare stmt from "select id from t1 +join +( select dt2.x1, +( select sum(a1) from t2 where t2.x1 = dt2.x1 ) m +from ( select x1 from t2 u where x3 = 1 ) dt2 +) dt +on t1.id = dt.x1 +where t1.id2 < dt.m"; +execute stmt; +id +3 +execute stmt; +id +3 +deallocate prepare stmt; +create procedure sp1() select id from t1 +join +( select dt2.x1, +( select sum(a1) from t2 where t2.x1 = dt2.x1 ) m +from ( select x1 from t2 u where x3 = 1 ) dt2 +) dt +on t1.id = dt.x1 +where t1.id2 < dt.m; +call sp1(); +id +3 +call sp1(); +id +3 +create view v2 as select x1 from t2 u where x3 = 1; +create view v as +select v2.x1, +( select sum(a1) from t2 where t2.x1 = v2.x1 ) m from v2; +prepare stmt from "select id from t1 join v on t1.id = v.x1 where t1.id2 < v.m"; +execute stmt; +id +3 +execute stmt; +id +3 +deallocate prepare stmt; +create procedure sp2() select id from t1 join v on t1.id = v.x1 where t1.id2 < v.m; +call sp2(); +id +3 +call sp2(); +id +3 +drop procedure sp1; +drop procedure sp2; +drop view v, v2; +drop table t1,t2; # End of 10.2 tests diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 584bde2d75d..006bdaea5ef 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -2400,4 +2400,56 @@ DROP PROCEDURE p1; DROP VIEW v1,v2,v3; DROP TABLE t1; +--echo # +--echo # MDEV-27212: 2-nd execution of PS for select with embedded derived tables +--echo # and correlated subquery in select list of outer derived +--echo # +create table t1 ( id int, id2 int ) engine=myisam; +create table t2 ( x3 int , x1 int , x2 int, a1 int) engine=myisam; +insert into t1 values (3, 2), (4, 2), (3, 4); +insert into t2 values (1, 2, 2, 1), (1, 3, 3, 2), (2, 3, 3, 1); + +let $q= +select id from t1 + join + ( select dt2.x1, + ( select sum(a1) from t2 where t2.x1 = dt2.x1 ) m + from ( select x1 from t2 u where x3 = 1 ) dt2 + ) dt + on t1.id = dt.x1 +where t1.id2 < dt.m; + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval create procedure sp1() $q; +call sp1(); +call sp1(); + +create view v2 as select x1 from t2 u where x3 = 1; +create view v as +select v2.x1, + ( select sum(a1) from t2 where t2.x1 = v2.x1 ) m from v2; + +let $q= +select id from t1 join v on t1.id = v.x1 where t1.id2 < v.m; + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval create procedure sp2() $q; +call sp2(); +call sp2(); + +drop procedure sp1; +drop procedure sp2; + +drop view v, v2; + +drop table t1,t2; + --echo # End of 10.2 tests diff --git a/mysql-test/main/func_default.result b/mysql-test/main/func_default.result index 8721270ca1c..55efbda546d 100644 --- a/mysql-test/main/func_default.result +++ b/mysql-test/main/func_default.result @@ -159,5 +159,57 @@ a 10 DROP TABLE t1; # +# MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view +# +create table t1 (a datetime default current_timestamp); +insert into t1 () values (),(); +create algorithm=temptable view v1 as select * from t1; +create algorithm=merge view v2 as select * from t1; +select default(a) = now() from v1; +default(a) = now() +1 +1 +select default(a) = now() from v2; +default(a) = now() +1 +1 +drop view v1, v2; +drop table t1; +create table t1 (v1 timestamp) select 'x'; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `v1` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `x` varchar(1) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select default(v1) from (select v1 from t1) dt; +default(v1) +2001-01-01 10:20:30 +select default(v1) from (select v1 from t1 group by v1) dt; +default(v1) +2001-01-01 10:20:30 +drop table t1; +create table t1 (a text default ''); +create algorithm=temptable view v1 as select * from t1; +insert into t1 values ('a'); +select default(a) from v1; +default(a) + +drop view v1; +drop table t1; +# +# MDEV-28403 ASAN heap-use-after-free in String::copy / get_field_default_value +# +create table t (a blob default 'x'); +create view v as select * from t; +insert into t () values (); +update t set a = default; +select table_name,column_name,column_default from information_schema.columns where table_name = 'v'; +table_name v +column_name a +column_default 'x' +drop view v; +drop table t; +# # End of 10.2 tests # diff --git a/mysql-test/main/func_default.test b/mysql-test/main/func_default.test index cba7842c68f..d2099d3ef4c 100644 --- a/mysql-test/main/func_default.test +++ b/mysql-test/main/func_default.test @@ -140,5 +140,41 @@ SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END IS FALSE; DROP TABLE t1; --echo # +--echo # MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view +--echo # +create table t1 (a datetime default current_timestamp); +insert into t1 () values (),(); +create algorithm=temptable view v1 as select * from t1; +create algorithm=merge view v2 as select * from t1; +select default(a) = now() from v1; +select default(a) = now() from v2; +drop view v1, v2; +drop table t1; + +create table t1 (v1 timestamp) select 'x'; +show create table t1; +select default(v1) from (select v1 from t1) dt; +select default(v1) from (select v1 from t1 group by v1) dt; +drop table t1; + +create table t1 (a text default ''); +create algorithm=temptable view v1 as select * from t1; +insert into t1 values ('a'); +select default(a) from v1; +drop view v1; +drop table t1; + +--echo # +--echo # MDEV-28403 ASAN heap-use-after-free in String::copy / get_field_default_value +--echo # +create table t (a blob default 'x'); +create view v as select * from t; +insert into t () values (); +update t set a = default; +query_vertical select table_name,column_name,column_default from information_schema.columns where table_name = 'v'; +drop view v; +drop table t; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index c1cc5dd19e6..f545a0cacbc 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -991,6 +991,12 @@ ADDTIME('916:40:00', '416:40:00') Warnings: Warning 1292 Truncated incorrect time value: '916:40:00' Warning 1292 Truncated incorrect time value: '1255:39:59.999999' +SELECT ADDTIME(20010101,1e0), ADDTIME(20010101,1.1e0); +ADDTIME(20010101,1e0) ADDTIME(20010101,1.1e0) +2001-01-01 00:00:01.000000 2001-01-01 00:00:01.100000 +SELECT ADDTIME(ADDTIME(20010101,1e0), 0); +ADDTIME(ADDTIME(20010101,1e0), 0) +2001-01-01 00:00:01.000000 SELECT SUBTIME('916:40:00', '416:40:00'); SUBTIME('916:40:00', '416:40:00') 422:19:59.999999 diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 359b1ac8698..7135ae4cc87 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -513,6 +513,10 @@ SELECT TIME_TO_SEC('916:40:00'); SELECT ADDTIME('500:00:00', '416:40:00'); SELECT ADDTIME('916:40:00', '416:40:00'); +# check if ADDTIME() handles NOT_FIXED_DEC correctly +SELECT ADDTIME(20010101,1e0), ADDTIME(20010101,1.1e0); +SELECT ADDTIME(ADDTIME(20010101,1e0), 0); + # check if SUBTIME() handles out-of-range values correctly SELECT SUBTIME('916:40:00', '416:40:00'); SELECT SUBTIME('-916:40:00', '416:40:00'); diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index 9f57ef4cabf..47fd30f0dc7 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -790,6 +790,19 @@ SHOW STATUS LIKE 'Com%get_diagnostics'; Variable_name Value Com_get_diagnostics 1 # +# MDEV-26695: Number of an invalid row is not calculated for table value constructor +# +CREATE TABLE t1 (a CHAR(1)) VALUES ('a'),('b'),('foo'); +Warnings: +Warning 1406 Data too long for column 'a' at row 3 +CREATE TABLE t2 (a char(1)) VALUES ('a'),('b') UNION VALUES ('foo'); +Warnings: +Warning 1406 Data too long for column 'a' at row 3 +DROP TABLE t1, t2; +# +# End of 10.6 tests +# +# # MDEV-10075: Provide index of error causing error in array INSERT # # @@ -1846,3 +1859,6 @@ B C D DROP TABLE t1,t2; +# +# End of 10.7 tests +# diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index 7292443a8b5..8576d2ed8c1 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -855,6 +855,19 @@ GET DIAGNOSTICS @var1 = NUMBER; SHOW STATUS LIKE 'Com%get_diagnostics'; --echo # +--echo # MDEV-26695: Number of an invalid row is not calculated for table value constructor +--echo # + +CREATE TABLE t1 (a CHAR(1)) VALUES ('a'),('b'),('foo'); +CREATE TABLE t2 (a char(1)) VALUES ('a'),('b') UNION VALUES ('foo'); + +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.6 tests +--echo # + +--echo # --echo # MDEV-10075: Provide index of error causing error in array INSERT --echo # @@ -1711,3 +1724,8 @@ SELECT @n; SELECT * FROM t2; DROP TABLE t1,t2; + +--echo # +--echo # End of 10.7 tests +--echo # + diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index 17a1a114575..d8f369ed3e7 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -3,8 +3,6 @@ set LOCAL sql_mode=""; SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; SET GLOBAL log_bin_trust_function_creators = 1; select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; -drop table if exists t1; -drop database if exists mysqltest; connect master,localhost,root,,; connection master; SET NAMES binary; @@ -2794,6 +2792,14 @@ DROP USER foo; DROP TABLE db.t; DROP DATABASE db; # +# Bug#33578113: DROP privilege on performance_schema.* can't be revoked +# +connection default; +CREATE USER bug33578113; +GRANT DROP ON performance_schema.* TO bug33578113; +REVOKE DROP ON performance_schema.* FROM bug33578113; +DROP USER bug33578113; +# # End of 10.2 tests # # diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index c8ca440b3e8..a243967a9c7 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -1,7 +1,7 @@ # Test of GRANT commands # Grant tests not performed with embedded server --- source include/not_embedded.inc +--source include/not_embedded.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -12,12 +12,6 @@ SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creato SET GLOBAL log_bin_trust_function_creators = 1; select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; -# Cleanup ---disable_warnings -drop table if exists t1; -drop database if exists mysqltest; ---enable_warnings - connect (master,localhost,root,,); connection master; SET NAMES binary; @@ -2288,6 +2282,16 @@ DROP TABLE db.t; DROP DATABASE db; --echo # +--echo # Bug#33578113: DROP privilege on performance_schema.* can't be revoked +--echo # +connection default; +CREATE USER bug33578113; +GRANT DROP ON performance_schema.* TO bug33578113; +REVOKE DROP ON performance_schema.* FROM bug33578113; +DROP USER bug33578113; +--source include/wait_until_count_sessions.inc + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/having.result b/mysql-test/main/having.result index 7106b42fc8d..d1e8ec56670 100644 --- a/mysql-test/main/having.result +++ b/mysql-test/main/having.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2,t3; create table t1 (a int); select count(a) as b from t1 where a=0 having b > 0; b @@ -280,11 +279,7 @@ select t1.col1 as tmp_col from t1 where t1.col2 in (select t2.col2 from t2 group by t2.col1, t2.col2 having tmp_col <= 10); -tmp_col -10 -10 -10 -10 +ERROR 42S22: Unknown column 'tmp_col' in 'having clause' select t1.col1 from t1 where t1.col2 in (select t2.col2 from t2 @@ -882,8 +877,10 @@ h # # drop table t1; +# # End of 10.3 tests # +# # MDEV-18681: AND formula in HAVING with several occurances # of the same field f in different conjuncts + f=constant # @@ -908,4 +905,6 @@ INSERT INTO t VALUES ('a'),('b'); SELECT * FROM t HAVING f = 'foo'; f DROP TABLE t; +# # End of 10.4 tests +# diff --git a/mysql-test/main/having.test b/mysql-test/main/having.test index 5e091afec1e..f69f5b8fd19 100644 --- a/mysql-test/main/having.test +++ b/mysql-test/main/having.test @@ -1,10 +1,6 @@ # test of problems with having (Reported by Mark Rogers) # ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings - create table t1 (a int); select count(a) as b from t1 where a=0 having b > 0; insert into t1 values (null); @@ -207,7 +203,7 @@ select count(*) from t1 group by col1 having col1 = 10; select count(*) as count_col1 from t1 group by col1 having col1 = 10; select count(*) as count_col1 from t1 as tmp1 group by col1 having col1 = 10; select count(*) from t1 group by col2 having col2 = 'hello'; ---error 1054 +--error ER_BAD_FIELD_ERROR select count(*) from t1 group by col2 having col1 = 10; select col1 as count_col1 from t1 as tmp1 group by col1 having col1 = 10; select col1 as count_col1 from t1 as tmp1 group by col1 having count_col1 = 10; @@ -221,10 +217,10 @@ select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col1 = select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having count_col1 = 10; select col1 as count_col1,col2 from t1 as tmp1 group by col1,col2 having col2 = 'hello'; select col1 as count_col1,col2 as group_col2 from t1 as tmp1 group by col1,col2 having group_col2 = 'hello'; ---error 1064 +--error ER_PARSE_ERROR select sum(col1) as co12 from t1 group by col2 having col2 10; select sum(col1) as co2, count(col2) as cc from t1 group by col1 having col1 =10; ---error 1054 +--error ER_BAD_FIELD_ERROR select t2.col2 from t2 group by t2.col1, t2.col2 having t1.col1 <= 10; @@ -253,7 +249,8 @@ where t1.col2 in group by t2.col1, t2.col2 having t1.col1 <= 10); # the having column is resolved in the SELECT clause of the outer query - -# error in ANSI, works with MySQL extension +# error in ANSI +--error ER_BAD_FIELD_ERROR select t1.col1 as tmp_col from t1 where t1.col2 in (select t2.col2 from t2 @@ -273,7 +270,7 @@ having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1); # nested queries with HAVING, inner having column resolved in outer FROM clause # the outer having column is not referenced in GROUP BY which results in an error ---error 1054 +--error ER_BAD_FIELD_ERROR select t1.col1 from t1 where t1.col2 in (select t2.col2 from t2 @@ -302,7 +299,7 @@ having col_t1 > 10 and # correlated subqueries - inner having column 't1.col2' resolves to # the outer FROM clause, which cannot be used because the outer query # is grouped ---error 1054 +--error ER_BAD_FIELD_ERROR select sum(col1) from t1 group by col_t1 having col_t1 in (select sum(t2.col1) from t2 @@ -318,11 +315,11 @@ having col_t1 in (select sum(t2.col1) from t2 # # queries with joins and ambiguous column names # ---error 1052 +--error ER_NON_UNIQ_ERROR select t1.col1, t2.col1 from t1, t2 where t1.col1 = t2.col1 group by t1.col1, t2.col1 having col1 = 2; ---error 1052 +--error ER_NON_UNIQ_ERROR select t1.col1*10+t2.col1 from t1,t2 where t1.col1=t2.col1 group by t1.col1, t2.col1 having col1 = 2; @@ -352,7 +349,7 @@ select count(s1) from t1 group by s1 having count(1+1)=2; select count(s1) from t1 group by s1 having s1*0=0; --- error 1052 +-- error ER_NON_UNIQ_ERROR select * from t1 a, t1 b group by a.s1 having s1 is null; # ANSI requires: 0 rows # MySQL returns: @@ -912,7 +909,9 @@ alter table t1 add column b int default (rand()+1+3); select default(b) AS h FROM t1 HAVING h > "2"; drop table t1; +--echo # --echo # End of 10.3 tests +--echo # --echo # --echo # MDEV-18681: AND formula in HAVING with several occurances @@ -930,7 +929,6 @@ HAVING t.f != 112 AND t.f = 'x' AND t.f != 'a'; DROP TABLE t1,t2; - --echo # --echo # MDEV-20200: AddressSanitizer: use-after-poison in --echo # Item_direct_view_ref::get_null_ref_table @@ -943,4 +941,6 @@ SELECT * FROM t HAVING f = 'foo'; # Cleanup DROP TABLE t; +--echo # --echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result index 443745db643..63a1bb3681e 100644 --- a/mysql-test/main/having_cond_pushdown.result +++ b/mysql-test/main/having_cond_pushdown.result @@ -5524,3 +5524,49 @@ SELECT a FROM t1 GROUP BY a HAVING a = ( SELECT MIN(c) FROM t2 ); a 2 DROP TABLE t1,t2; +# +# MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order or Assertion `fixed == 1' +# +CREATE TABLE t1 (i int NOT NULL); +SELECT * FROM t1 GROUP BY i HAVING i IN ( i IS NULL); +i +SELECT * FROM t1 GROUP BY i HAVING i IN ( i IS NULL AND 'x' = 0); +i +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +SELECT * FROM t1 GROUP BY i HAVING i='1' IN ( i IS NULL AND 'x' = 0); +i +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +DROP TABLE t1; +# +# MDEV-28080: HAVING with NOT EXIST predicate in an equality +# (fixed by the patch for MDEV-26402) +# +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (0), (1), (1), (0); +INSERT INTO t2 VALUES (3), (7); +SELECT a FROM t1 +GROUP BY a HAVING a= (NOT EXISTS (SELECT b FROM t2 WHERE b = 1)); +a +1 +SELECT a FROM t1 +GROUP BY a HAVING a= (NOT EXISTS (SELECT b FROM t2 WHERE b = 7)); +a +0 +DROP TABLE t1, t2; +# +# MDEV-28082: HAVING with IS NULL predicate in an equality +# (fixed by the patch for MDEV-26402) +# +CREATE TABLE t1 (a int, b int NOT NULL) ; +INSERT INTO t1 VALUES (1,10), (0,11), (0,11), (1,10); +SELECT a,b FROM t1 GROUP BY a HAVING a = (b IS NULL); +a b +0 11 +SELECT a,b FROM t1 GROUP BY a,b HAVING a = (b IS NULL); +a b +0 11 +DROP TABLE t1; +End of 10.4 tests diff --git a/mysql-test/main/having_cond_pushdown.test b/mysql-test/main/having_cond_pushdown.test index 60ed7ebb660..8225bdec906 100644 --- a/mysql-test/main/having_cond_pushdown.test +++ b/mysql-test/main/having_cond_pushdown.test @@ -1444,3 +1444,46 @@ eval EXPLAIN FORMAT=JSON $q; eval $q; DROP TABLE t1,t2; + +--echo # +--echo # MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order or Assertion `fixed == 1' +--echo # + +CREATE TABLE t1 (i int NOT NULL); +SELECT * FROM t1 GROUP BY i HAVING i IN ( i IS NULL); +SELECT * FROM t1 GROUP BY i HAVING i IN ( i IS NULL AND 'x' = 0); +SELECT * FROM t1 GROUP BY i HAVING i='1' IN ( i IS NULL AND 'x' = 0); +DROP TABLE t1; + +--echo # +--echo # MDEV-28080: HAVING with NOT EXIST predicate in an equality +--echo # (fixed by the patch for MDEV-26402) +--echo # + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); +INSERT INTO t1 VALUES (0), (1), (1), (0); +INSERT INTO t2 VALUES (3), (7); + +SELECT a FROM t1 + GROUP BY a HAVING a= (NOT EXISTS (SELECT b FROM t2 WHERE b = 1)); +SELECT a FROM t1 + GROUP BY a HAVING a= (NOT EXISTS (SELECT b FROM t2 WHERE b = 7)); + +DROP TABLE t1, t2; + +--echo # +--echo # MDEV-28082: HAVING with IS NULL predicate in an equality +--echo # (fixed by the patch for MDEV-26402) +--echo # + +CREATE TABLE t1 (a int, b int NOT NULL) ; +INSERT INTO t1 VALUES (1,10), (0,11), (0,11), (1,10); + +SELECT a,b FROM t1 GROUP BY a HAVING a = (b IS NULL); + +SELECT a,b FROM t1 GROUP BY a,b HAVING a = (b IS NULL); + +DROP TABLE t1; + +--echo End of 10.4 tests diff --git a/mysql-test/main/information_schema_columns.result b/mysql-test/main/information_schema_columns.result new file mode 100644 index 00000000000..3624a6db368 --- /dev/null +++ b/mysql-test/main/information_schema_columns.result @@ -0,0 +1,47 @@ +# +# Start of 10.2 tests +# +# +# MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +# +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); +connect con1,localhost,root,,; +SELECT GET_LOCK('v01',30); +GET_LOCK('v01',30) +1 +SELECT GET_LOCK('v02',30); +GET_LOCK('v02',30) +1 +connection default; +SELECT * FROM INFORMATION_SCHEMA.COLUMNS +WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) +AND RELEASE_LOCK(TABLE_NAME) +AND f1()=1 +ORDER BY TABLE_NAME; +connection con1; +connection con1; +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +RELEASE_LOCK('v01') +1 +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +RELEASE_LOCK('v02') +1 +DROP FUNCTION f2; +disconnect con1; +connection default; +SELECT RELEASE_LOCK('v01'); +RELEASE_LOCK('v01') +NULL +SELECT RELEASE_LOCK('v02'); +RELEASE_LOCK('v02') +NULL +DROP VIEW v01, v02; +DROP FUNCTION f1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/information_schema_columns.test b/mysql-test/main/information_schema_columns.test new file mode 100644 index 00000000000..0171b221110 --- /dev/null +++ b/mysql-test/main/information_schema_columns.test @@ -0,0 +1,48 @@ +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +--echo # + + +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); + +--connect(con1,localhost,root,,) +SELECT GET_LOCK('v01',30); +SELECT GET_LOCK('v02',30); +--connection default + +--send + SELECT * FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) + AND RELEASE_LOCK(TABLE_NAME) + AND f1()=1 + ORDER BY TABLE_NAME; + +--connection con1 +--connection con1 +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +DROP FUNCTION f2; +--disconnect con1 + +--connection default +--disable_result_log +--reap +--enable_result_log +SELECT RELEASE_LOCK('v01'); +SELECT RELEASE_LOCK('v02'); + +DROP VIEW v01, v02; +DROP FUNCTION f1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/information_schema_tables.result b/mysql-test/main/information_schema_tables.result new file mode 100644 index 00000000000..a3dd068831c --- /dev/null +++ b/mysql-test/main/information_schema_tables.result @@ -0,0 +1,77 @@ +# +# Start of 10.2 tests +# +# +# MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +# +# The originally reported non-deterministic test. +# It did not fail reliably on every run. +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +CREATE FUNCTION f(b INT) RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f(SUM(a)) FROM t; +connect con1,localhost,root,,test; +LOOP +CREATE OR REPLACE VIEW vv AS SELECT 1; +END LOOP $ +connection default; +SELECT v.* FROM v JOIN INFORMATION_SCHEMA.TABLES WHERE DATA_LENGTH = -1; +f(SUM(a)) +KILL CONID; +disconnect con1; +connection default; +DROP VIEW IF EXISTS vv; +DROP VIEW v; +DROP FUNCTION f; +DROP TABLE t; +# The second test version from the MDEV. +# It failed more reliably, but still was not deterministic. +CREATE FUNCTION f() RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f() FROM seq_1_to_10; +SELECT * FROM INFORMATION_SCHEMA.TABLES, v;; +connect con1,localhost,root,,; +CREATE VIEW v2 AS SELECT 1; +connection default; +disconnect con1; +DROP VIEW v; +DROP VIEW v2; +DROP FUNCTION f; +# The third test version from the MDEV. +# It failed reliably, and should be deterninistic. +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); +connect con1,localhost,root,,; +SELECT GET_LOCK('v01',30); +GET_LOCK('v01',30) +1 +SELECT GET_LOCK('v02',30); +GET_LOCK('v02',30) +1 +connection default; +SELECT * FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) +AND RELEASE_LOCK(TABLE_NAME) +AND f1()=1 +ORDER BY TABLE_NAME; +connection con1; +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +RELEASE_LOCK('v01') +1 +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +RELEASE_LOCK('v02') +1 +DROP FUNCTION f2; +disconnect con1; +connection default; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT MAX_INDEX_LENGTH TEMPORARY +def test v01 VIEW NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL VIEW NULL NULL +def test v02 VIEW NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL VIEW NULL NULL +DROP VIEW v01, v02; +DROP FUNCTION f1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/information_schema_tables.test b/mysql-test/main/information_schema_tables.test new file mode 100644 index 00000000000..bc4f269a3fb --- /dev/null +++ b/mysql-test/main/information_schema_tables.test @@ -0,0 +1,100 @@ +--source include/have_sequence.inc + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-25243 ASAN heap-use-after-free in Item_func_sp::execute_impl upon concurrent view DDL and I_S query with view and function +--echo # + +--echo # The originally reported non-deterministic test. +--echo # It did not fail reliably on every run. + +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +CREATE FUNCTION f(b INT) RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f(SUM(a)) FROM t; +--connect (con1,localhost,root,,test) +--let $conid= `SELECT CONNECTION_ID()` +--delimiter $ +--send +LOOP + CREATE OR REPLACE VIEW vv AS SELECT 1; +END LOOP $ +--delimiter ; +--connection default +# Avoid "Prepared statement needs to be re-prepared" +# Note, the code could probably eventually fixed to avoid forcing re-pepare if +# the *temporary* instance of Sp_caches (not the permanent one) was invalidated. +--disable_ps_protocol +--disable_warnings +SELECT v.* FROM v JOIN INFORMATION_SCHEMA.TABLES WHERE DATA_LENGTH = -1; +--enable_warnings +--enable_ps_protocol +# Cleanup +--replace_result $conid CONID +--eval KILL $conid +--disconnect con1 +--connection default +DROP VIEW IF EXISTS vv; +DROP VIEW v; +DROP FUNCTION f; +DROP TABLE t; + + +--echo # The second test version from the MDEV. +--echo # It failed more reliably, but still was not deterministic. + + +CREATE FUNCTION f() RETURNS INT RETURN 1; +CREATE VIEW v AS SELECT f() FROM seq_1_to_10; +--send SELECT * FROM INFORMATION_SCHEMA.TABLES, v; +--connect(con1,localhost,root,,) +CREATE VIEW v2 AS SELECT 1; +--connection default +--disable_result_log +--reap +--enable_result_log +--disconnect con1 +DROP VIEW v; +DROP VIEW v2; +DROP FUNCTION f; + +--echo # The third test version from the MDEV. +--echo # It failed reliably, and should be deterninistic. + +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE VIEW v01 AS SELECT f1(); +CREATE VIEW v02 AS SELECT f1(); + +--connect(con1,localhost,root,,) +SELECT GET_LOCK('v01',30); +SELECT GET_LOCK('v02',30); +--connection default + +--send + SELECT * FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' + AND TABLE_NAME LIKE 'v0%' + AND GET_LOCK(TABLE_NAME,30) + AND RELEASE_LOCK(TABLE_NAME) + AND f1()=1 + ORDER BY TABLE_NAME; + +--connection con1 +SELECT RELEASE_LOCK('v01') /* Let the first row evaluate f1 */; +CREATE FUNCTION f2() RETURNS INT RETURN 1 /* Invalidate SP cache*/; +SELECT RELEASE_LOCK('v02') /* Let the second row evaluate f1() */; +DROP FUNCTION f2; +--disconnect con1 +--connection default +--reap + + +DROP VIEW v01, v02; +DROP FUNCTION f1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/insert.result b/mysql-test/main/insert.result index d8f40b7383a..22682e180c6 100644 --- a/mysql-test/main/insert.result +++ b/mysql-test/main/insert.result @@ -745,12 +745,50 @@ f1 f2 drop view v1; drop table t1; SET @@sql_mode= @save_mode; +# +# MDEV-13861 Assertion `0' failed in Protocol::end_statement +# CREATE TABLE t1 (f INT); CREATE VIEW v1 AS SELECT * FROM t1 WHERE f <=> 'foo' WITH CHECK OPTION; REPLACE INTO v1 SET f = NULL; ERROR 22007: Truncated incorrect DOUBLE value: 'foo' DROP VIEW v1; DROP TABLE t1; +# +# End of 10.0 tests +# +# +# MDEV-26412: INSERT CREATE with subquery in ON expression +# +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +create table t4 (d1 int, d2 int); +insert into t4 +select * from t1 left join t2 on (select t1.i from t3); +ERROR 42S22: Unknown column 't1.i' in 'field list' +replace t4 +select * from t1 left join t2 on (select t1.i from t3); +ERROR 42S22: Unknown column 't1.i' in 'field list' +drop table t1,t2,t3,t4; +create table t (a int); +select 1 in (select count(*) from t t1 join (t t2 join t t3 on (t1.a != 0))); +ERROR 42S22: Unknown column 't1.a' in 'on clause' +drop table t; +# +# MDEV-28578 Server crashes in Item_field::fix_outer_field after CREATE SELECT +# +create table t1 (i int) ; +create table t2 (j int) ; +create table t4 select * from t1 join t2 on (select t3.i); +ERROR 42S22: Unknown column 't3.i' in 'field list' +drop table t1, t2; +# +# End of 10.4 tests +# +# +# outer references in subqueries in INSERT +# create table t1 (a int default 5); insert t1 values (1); insert t1 values (a); @@ -767,3 +805,6 @@ a 7 8 drop table t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/insert.test b/mysql-test/main/insert.test index 4ccaa20ece8..e5cb2bac6f8 100644 --- a/mysql-test/main/insert.test +++ b/mysql-test/main/insert.test @@ -603,9 +603,9 @@ drop view v1; drop table t1; SET @@sql_mode= @save_mode; -# -# MDEV-13861 Assertion `0' failed in Protocol::end_statement -# +--echo # +--echo # MDEV-13861 Assertion `0' failed in Protocol::end_statement +--echo # CREATE TABLE t1 (f INT); CREATE VIEW v1 AS SELECT * FROM t1 WHERE f <=> 'foo' WITH CHECK OPTION; --error ER_TRUNCATED_WRONG_VALUE @@ -613,9 +613,49 @@ REPLACE INTO v1 SET f = NULL; DROP VIEW v1; DROP TABLE t1; -# -# outer referencesin subqueries in INSERT -# +--echo # +--echo # End of 10.0 tests +--echo # + +--echo # +--echo # MDEV-26412: INSERT CREATE with subquery in ON expression +--echo # + +create table t1 (a int); +create table t2 (b int); +create table t3 (c int); +create table t4 (d1 int, d2 int); + +--error ER_BAD_FIELD_ERROR +insert into t4 + select * from t1 left join t2 on (select t1.i from t3); +--error ER_BAD_FIELD_ERROR +replace t4 + select * from t1 left join t2 on (select t1.i from t3); + +drop table t1,t2,t3,t4; + +create table t (a int); +--error ER_BAD_FIELD_ERROR +select 1 in (select count(*) from t t1 join (t t2 join t t3 on (t1.a != 0))); +drop table t; + +--echo # +--echo # MDEV-28578 Server crashes in Item_field::fix_outer_field after CREATE SELECT +--echo # +create table t1 (i int) ; +create table t2 (j int) ; +--error ER_BAD_FIELD_ERROR +create table t4 select * from t1 join t2 on (select t3.i); +drop table t1, t2; + +--echo # +--echo # End of 10.4 tests +--echo # + +--echo # +--echo # outer references in subqueries in INSERT +--echo # create table t1 (a int default 5); insert t1 values (1); insert t1 values (a); @@ -625,3 +665,7 @@ insert t1 set a=a+2; insert t1 set a=(select a+3); select * from t1; drop table t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index ae736d625b2..659fdde236b 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -305,7 +305,24 @@ c 1 DELETE FROM t; DROP TABLE t; +# +# MDEV-28098 incorrect key in "dup value" error after long unique +# +create table t1 (v3 int primary key, v2 text(100) unique not null, v1 int unique) engine=innodb; +insert into t1 values ( -32768 , -128 , 58 ) , ( -1 , 44 , -128 ); +create table t2 (v6 int primary key, v5 text, a int not null) engine=innodb; +insert into t2 values ( 50 , 61 , -1 ) , ( -2147483648 , -128 , 0 ); +update t1 set v2 = 1, v3 = -128; +ERROR 23000: Duplicate entry '1' for key 'v2' +update t1,t2 set v1 = v2 , v5 = 0; +ERROR 23000: Duplicate entry '-128' for key 'v1' +drop table t1, t2; +# # End of 10.4 tests +# +# +# MDEV-22113 SIGSEGV, ASAN use-after-poison, Assertion `next_insert_id == 0' in handler::ha_external_lock +# create temporary table tmp ( a int, b int, c blob not null, d int, e int default 0, f int, unique key (c)) engine=innodb; create table t2 (x int); lock table t2 write; @@ -314,6 +331,9 @@ start transaction; alter table tmp alter column a set default 8; unlock tables; drop table t2; +# +# MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table +# create table t1 (pk int primary key, f blob, unique(f)) engine=innodb; insert t1 values (1, null); select * into outfile 't1.data' from t1; @@ -372,8 +392,13 @@ a b 1 foo 3 bar drop table if exists t1, t2; +# +# MDEV-22185 Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON or ER_KEY_NOT_FOUND or Assertion `inited==NONE' failed in handler::ha_index_init +# create table t1 (a int, b int, unique (b) using hash) engine=innodb partition by key (a) partitions 2; insert into t1 values (1,10),(2,20); update t1 set b = 30 limit 1; drop table t1; +# # End of 10.5 tests +# diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 18bad7deac9..8e54782db30 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -234,7 +234,6 @@ DROP TABLE t1; # # MDEV-18901 Wrong results after ADD UNIQUE INDEX(blob_column) # ---source include/have_innodb.inc CREATE TABLE t1 (data VARCHAR(7961)) ENGINE=InnoDB; INSERT INTO t1 VALUES ('f'), ('o'), ('o'); @@ -280,7 +279,6 @@ DROP TABLE t1; # MDEV-18820 Assertion `lock_table_has(trx, index->table, LOCK_IX)' failed in lock_rec_insert_check_and_lock upon INSERT into table with blob key' # ---source include/have_innodb.inc set innodb_lock_wait_timeout= 10; CREATE TABLE t1 ( @@ -386,11 +384,26 @@ DELETE FROM t; DROP TABLE t; +--echo # +--echo # MDEV-28098 incorrect key in "dup value" error after long unique +--echo # +create table t1 (v3 int primary key, v2 text(100) unique not null, v1 int unique) engine=innodb; +insert into t1 values ( -32768 , -128 , 58 ) , ( -1 , 44 , -128 ); +create table t2 (v6 int primary key, v5 text, a int not null) engine=innodb; +insert into t2 values ( 50 , 61 , -1 ) , ( -2147483648 , -128 , 0 ); +--error ER_DUP_ENTRY +update t1 set v2 = 1, v3 = -128; +--error ER_DUP_ENTRY +update t1,t2 set v1 = v2 , v5 = 0; +drop table t1, t2; + +--echo # --echo # End of 10.4 tests +--echo # -# -# MDEV-22113 SIGSEGV, ASAN use-after-poison, Assertion `next_insert_id == 0' in handler::ha_external_lock -# +--echo # +--echo # MDEV-22113 SIGSEGV, ASAN use-after-poison, Assertion `next_insert_id == 0' in handler::ha_external_lock +--echo # create temporary table tmp ( a int, b int, c blob not null, d int, e int default 0, f int, unique key (c)) engine=innodb; create table t2 (x int); lock table t2 write; @@ -401,9 +414,9 @@ unlock tables; drop table t2; --source include/have_innodb.inc -# -# MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table -# +--echo # +--echo # MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table +--echo # create table t1 (pk int primary key, f blob, unique(f)) engine=innodb; insert t1 values (1, null); select * into outfile 't1.data' from t1; @@ -449,12 +462,14 @@ create or replace table t2 (a int, b blob, unique(b)) replace as select * from t drop table if exists t1, t2; -# -# MDEV-22185 Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON or ER_KEY_NOT_FOUND or Assertion `inited==NONE' failed in handler::ha_index_init -# +--echo # +--echo # MDEV-22185 Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON or ER_KEY_NOT_FOUND or Assertion `inited==NONE' failed in handler::ha_index_init +--echo # create table t1 (a int, b int, unique (b) using hash) engine=innodb partition by key (a) partitions 2; insert into t1 values (1,10),(2,20); update t1 set b = 30 limit 1; drop table t1; +--echo # --echo # End of 10.5 tests +--echo # diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result index 3ec9ea0caa5..674dc79fe12 100644 --- a/mysql-test/main/multi_update.result +++ b/mysql-test/main/multi_update.result @@ -1161,3 +1161,111 @@ ERROR 21000: Subquery returns more than 1 row update t1 set a= (select 2 from t1 having (a = 3)); ERROR 21000: Subquery returns more than 1 row drop tables t1; +# +# MDEV-28246 Optimizer uses all partitions during an update in MariaDB 10.6.x but not in 10.2.x +# +CREATE TABLE t1 ( +part INT(1), +a INT(1), +b INT(1), +PRIMARY KEY (a,part), +INDEX b (b,part) +) PARTITION BY LIST (part) ( +PARTITION Current VALUES IN (0), +PARTITION Relevant VALUES IN (1), +PARTITION Archive VALUES IN (2) +); +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2); +INSERT INTO t2 (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2); +# Expecting partition "Current" +EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=3 WHERE t2.part=0 AND t1.part=0; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "partitions": ["Current"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "partitions": ["Current"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + } + ] + } +} +# Expecting partition "Relevant" +EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=2 WHERE t2.part=1 AND t1.part=1; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "partitions": ["Relevant"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "partitions": ["Relevant"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + } + ] + } +} +# Expecting partition "Archive" +EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=3 WHERE t2.part=2 AND t1.part=2; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "nested_loop": [ + { + "table": { + "table_name": "t2", + "partitions": ["Archive"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + }, + { + "table": { + "table_name": "t1", + "partitions": ["Archive"], + "access_type": "system", + "possible_keys": ["PRIMARY"], + "rows": 1, + "filtered": 100 + } + } + ] + } +} +DROP TABLES t1, t2; diff --git a/mysql-test/main/multi_update.test b/mysql-test/main/multi_update.test index 3ee36f97fc5..5f4b5fc8ec3 100644 --- a/mysql-test/main/multi_update.test +++ b/mysql-test/main/multi_update.test @@ -1098,3 +1098,34 @@ select a from t1 where a= (select 2 from t1 having (a = 3)); --error ER_SUBQUERY_NO_1_ROW update t1 set a= (select 2 from t1 having (a = 3)); drop tables t1; + +--echo # +--echo # MDEV-28246 Optimizer uses all partitions during an update in MariaDB 10.6.x but not in 10.2.x +--echo # +--source include/have_partition.inc +CREATE TABLE t1 ( + part INT(1), + a INT(1), + b INT(1), + PRIMARY KEY (a,part), + INDEX b (b,part) +) PARTITION BY LIST (part) ( + PARTITION Current VALUES IN (0), + PARTITION Relevant VALUES IN (1), + PARTITION Archive VALUES IN (2) +); + +CREATE TABLE t2 LIKE t1; +INSERT INTO t1 (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2); +INSERT INTO t2 (part,a,b) VALUES (0,0,0),(1,1,1),(2,2,2); + +--echo # Expecting partition "Current" +EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=3 WHERE t2.part=0 AND t1.part=0; + +--echo # Expecting partition "Relevant" +EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=2 WHERE t2.part=1 AND t1.part=1; + +--echo # Expecting partition "Archive" +EXPLAIN FORMAT=JSON UPDATE t2 JOIN t1 USING(a) SET t2.part=3 WHERE t2.part=2 AND t1.part=2; + +DROP TABLES t1, t2; diff --git a/mysql-test/main/mysql_client_test_comp.test b/mysql-test/main/mysql_client_test_comp.test index 13a9d4944a4..f8bd80fc48a 100644 --- a/mysql-test/main/mysql_client_test_comp.test +++ b/mysql-test/main/mysql_client_test_comp.test @@ -1,7 +1,8 @@ # run mysql_client_test with performance schema # No need to run this with embedded server --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/check_ipv6.inc # need to have the dynamic loading turned on for the client plugin tests --source include/have_plugin_auth.inc diff --git a/mysql-test/main/mysql_client_test_nonblock.test b/mysql-test/main/mysql_client_test_nonblock.test index 19489bf9e0e..73e7a6d378d 100644 --- a/mysql-test/main/mysql_client_test_nonblock.test +++ b/mysql-test/main/mysql_client_test_nonblock.test @@ -2,7 +2,8 @@ # This runs the mysql_client_test using the non-blocking API. # The non-blocking API is not supported in the embedded server. --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/check_ipv6.inc # This test is slow on buildbot. --source include/big_test.inc diff --git a/mysql-test/main/mysql_install_db_win.test b/mysql-test/main/mysql_install_db_win.test index ceb7293f611..c400dbf3fb9 100644 --- a/mysql-test/main/mysql_install_db_win.test +++ b/mysql-test/main/mysql_install_db_win.test @@ -42,6 +42,13 @@ remove_file $log; rmdir $ddir; +# MDEV-28471 - mysql_install_db.exe fails with --innodb-page-size=64K +--disable_result_log +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R --innodb-page-size=64K --verbose +--enable_result_log +rmdir $ddir; + +# Tests with config file let $restart_parameters=; connection default; diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result index e9bfef604e8..c87aedcc247 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result @@ -420,6 +420,55 @@ COM_INSERT 0 COM_LOCK_TABLES 1 COM_TRUNCATE 1 # +# MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +# +# +# Testing --skip-write-binlog +# +set @wsrep_is_on=(select sum(VARIABLE_NAME='wsrep_on' AND SESSION_VALUE='ON') from information_schema.SYSTEM_VARIABLES); +SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; +set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select sum(VARIABLE_NAME='wsrep_mode' and GLOBAL_VALUE NOT LIKE @replicate_opt) from information_schema.SYSTEM_VARIABLES); +execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF', 'do 0'); +SET @save_sql_log_bin=@@SQL_LOG_BIN; +SET SESSION SQL_LOG_BIN=0; +SET @wsrep_cannot_replicate_tz=0; +LOCK TABLES time_zone WRITE, + time_zone_leap_second WRITE, + time_zone_name WRITE, + time_zone_transition WRITE, + time_zone_transition_type WRITE; +INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); +SET @time_zone_id= LAST_INSERT_ID(); +INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); +INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES + (@time_zone_id, 0, 0, 0, 'GMT') +; +UNLOCK TABLES; +COMMIT; +SET SESSION SQL_LOG_BIN=@save_sql_log_bin; +execute immediate if(@wsrep_is_on, 'SET SESSION WSREP_ON=@save_wsrep_on', 'do 0'); +set @wsrep_is_on=(select sum(VARIABLE_NAME='wsrep_on' AND SESSION_VALUE='ON') from information_schema.SYSTEM_VARIABLES); +SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; +set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select sum(VARIABLE_NAME='wsrep_mode' and GLOBAL_VALUE NOT LIKE @replicate_opt) from information_schema.SYSTEM_VARIABLES); +execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF', 'do 0'); +SET @save_sql_log_bin=@@SQL_LOG_BIN; +SET SESSION SQL_LOG_BIN=0; +SET @wsrep_cannot_replicate_tz=0; +LOCK TABLES time_zone WRITE, + time_zone_leap_second WRITE, + time_zone_name WRITE, + time_zone_transition WRITE, + time_zone_transition_type WRITE; +TRUNCATE TABLE time_zone_leap_second; +ALTER TABLE time_zone_leap_second ORDER BY Transition_time; +UNLOCK TABLES; +COMMIT; +SET SESSION SQL_LOG_BIN=@save_sql_log_bin; +execute immediate if(@wsrep_is_on, 'SET SESSION WSREP_ON=@save_wsrep_on', 'do 0'); +# +# End of 10.2 tests +# +# # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL # set @wsrep_is_on=(select sum(VARIABLE_NAME='wsrep_on' AND SESSION_VALUE='ON') from information_schema.SYSTEM_VARIABLES); diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.test b/mysql-test/main/mysql_tzinfo_to_sql_symlink.test index a2ce9e8f9b9..34df1281c38 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.test +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.test @@ -198,6 +198,23 @@ SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff ORDER BY g.VARIABLE_NAME; --echo # +--echo # MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +--echo # + +--echo # +--echo # Testing --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1 + +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1 + +--echo # +--echo # End of 10.2 tests +--echo # + +--echo # --echo # MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL --echo # --exec rm -rf $MYSQLTEST_VARDIR/zoneinfo @@ -208,7 +225,6 @@ SELECT g.VARIABLE_NAME, g.VARIABLE_VALUE - b.VARIABLE_VALUE AS diff --exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1 # -# # Cleanup # diff --git a/mysql-test/main/mysqldump-compat-102.result b/mysql-test/main/mysqldump-compat-102.result index aa8fe5a4de3..86a2ebc47e0 100644 --- a/mysql-test/main/mysqldump-compat-102.result +++ b/mysql-test/main/mysqldump-compat-102.result @@ -77,6 +77,8 @@ $$ -- -- Dumping routines for database 'db1_mdev17429' -- +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; /*!50003 DROP PROCEDURE IF EXISTS `p1` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -84,8 +86,6 @@ $$ /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; DELIMITER ;; CREATE DEFINER="root"@"localhost" PROCEDURE "p1"(a INT) AS BEGIN diff --git a/mysql-test/main/mysqldump-nl.result b/mysql-test/main/mysqldump-nl.result index d2d0e09546b..89fb3144867 100644 --- a/mysql-test/main/mysqldump-nl.result +++ b/mysql-test/main/mysqldump-nl.result @@ -64,14 +64,14 @@ SET character_set_client = @saved_cs_client; -- Dumping routines for database 'mysqltest1 -- 1tsetlqsym' -- +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sp`() select * from `v1 diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index 8b2550d4d51..1b4c8775448 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -2871,6 +2871,8 @@ INSERT INTO `t1` VALUES (5); /*!40000 ALTER TABLE `t1` ENABLE KEYS */; UNLOCK TABLES; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2878,8 +2880,6 @@ UNLOCK TABLES; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `bug9056_func1`(a INT, b INT) RETURNS int(11) RETURN a+b ;; @@ -2888,6 +2888,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2895,8 +2897,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1) CHARSET latin1 begin @@ -2908,6 +2908,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI' */ ; /*!50003 DROP PROCEDURE IF EXISTS `a'b` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2915,8 +2917,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI' */ ; DELIMITER ;; CREATE DEFINER="root"@"localhost" PROCEDURE "a'b"() select 1 ;; @@ -2925,6 +2925,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc1` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2932,8 +2934,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug9056_proc1`(IN a INT, IN b INT, OUT c INT) BEGIN SELECT a+b INTO c; end ;; @@ -2942,6 +2942,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `bug9056_proc2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2949,8 +2951,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug9056_proc2`(OUT a INT) BEGIN @@ -3964,14 +3964,14 @@ create procedure mysqldump_test_db.sp1() select 'hello'; -- insufficient privileges to SHOW CREATE PROCEDURE `sp1` -- does user2 have permissions on mysql.proc? +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`user1`@`%` PROCEDURE `sp1`() select 'hello' ;; @@ -5548,6 +5548,8 @@ CREATE DATABASE `a\"'``b`; USE `a\"'``b`; CREATE PROCEDURE p1() BEGIN END; ALTER DATABASE `a\"'``b` COLLATE utf8_general_ci; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; ALTER DATABASE `a\"'``b` CHARACTER SET latin1 COLLATE latin1_swedish_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5555,8 +5557,6 @@ ALTER DATABASE `a\"'``b` CHARACTER SET latin1 COLLATE latin1_swedish_ci ; /*!50003 SET character_set_client = utf8mb3 */ ; /*!50003 SET character_set_results = utf8mb3 */ ; /*!50003 SET collation_connection = utf8mb3_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() BEGIN END ;; @@ -5877,34 +5877,6 @@ DROP TABLE t1; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -DROP TABLE IF EXISTS `innodb_index_stats`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `innodb_index_stats` ( - `database_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, - `table_name` varchar(199) COLLATE utf8mb3_bin NOT NULL, - `index_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, - `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `stat_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, - `stat_value` bigint(20) unsigned NOT NULL, - `sample_size` bigint(20) unsigned DEFAULT NULL, - `stat_description` varchar(1024) COLLATE utf8mb3_bin NOT NULL, - PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `innodb_table_stats`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `innodb_table_stats` ( - `database_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, - `table_name` varchar(199) COLLATE utf8mb3_bin NOT NULL, - `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `n_rows` bigint(20) unsigned NOT NULL, - `clustered_index_size` bigint(20) unsigned NOT NULL, - `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL, - PRIMARY KEY (`database_name`,`table_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0; -/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE IF NOT EXISTS `general_log` ( @@ -5934,6 +5906,34 @@ CREATE TABLE IF NOT EXISTS `slow_log` ( `rows_affected` int(11) NOT NULL ) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='Slow log'; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `innodb_index_stats`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `innodb_index_stats` ( + `database_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `table_name` varchar(199) COLLATE utf8mb3_bin NOT NULL, + `index_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `stat_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `stat_value` bigint(20) unsigned NOT NULL, + `sample_size` bigint(20) unsigned DEFAULT NULL, + `stat_description` varchar(1024) COLLATE utf8mb3_bin NOT NULL, + PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `innodb_table_stats`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `innodb_table_stats` ( + `database_name` varchar(64) COLLATE utf8mb3_bin NOT NULL, + `table_name` varchar(199) COLLATE utf8mb3_bin NOT NULL, + `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `n_rows` bigint(20) unsigned NOT NULL, + `clustered_index_size` bigint(20) unsigned NOT NULL, + `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL, + PRIMARY KEY (`database_name`,`table_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0; +/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE IF NOT EXISTS `transaction_registry` ( @@ -5972,6 +5972,35 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` ( /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `general_log` ( + `event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `command_type` varchar(64) NOT NULL, + `argument` mediumtext NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='General log'; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `slow_log` ( + `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `query_time` time(6) NOT NULL, + `lock_time` time(6) NOT NULL, + `rows_sent` int(11) NOT NULL, + `rows_examined` int(11) NOT NULL, + `db` varchar(512) NOT NULL, + `last_insert_id` int(11) NOT NULL, + `insert_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `sql_text` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `rows_affected` int(11) NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='Slow log'; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `innodb_index_stats`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -6012,35 +6041,6 @@ LOCK TABLES `innodb_table_stats` WRITE; UNLOCK TABLES; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE IF NOT EXISTS `general_log` ( - `event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), - `user_host` mediumtext NOT NULL, - `thread_id` bigint(21) unsigned NOT NULL, - `server_id` int(10) unsigned NOT NULL, - `command_type` varchar(64) NOT NULL, - `argument` mediumtext NOT NULL -) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='General log'; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE IF NOT EXISTS `slow_log` ( - `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), - `user_host` mediumtext NOT NULL, - `query_time` time(6) NOT NULL, - `lock_time` time(6) NOT NULL, - `rows_sent` int(11) NOT NULL, - `rows_examined` int(11) NOT NULL, - `db` varchar(512) NOT NULL, - `last_insert_id` int(11) NOT NULL, - `insert_id` int(11) NOT NULL, - `server_id` int(10) unsigned NOT NULL, - `sql_text` mediumtext NOT NULL, - `thread_id` bigint(21) unsigned NOT NULL, - `rows_affected` int(11) NOT NULL -) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='Slow log'; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; CREATE TABLE IF NOT EXISTS `transaction_registry` ( `transaction_id` bigint(20) unsigned NOT NULL, `commit_id` bigint(20) unsigned NOT NULL, @@ -6077,6 +6077,35 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` ( /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `general_log` ( + `event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `command_type` varchar(64) NOT NULL, + `argument` mediumtext NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='General log'; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE IF NOT EXISTS `slow_log` ( + `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `query_time` time(6) NOT NULL, + `lock_time` time(6) NOT NULL, + `rows_sent` int(11) NOT NULL, + `rows_examined` int(11) NOT NULL, + `db` varchar(512) NOT NULL, + `last_insert_id` int(11) NOT NULL, + `insert_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `sql_text` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `rows_affected` int(11) NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='Slow log'; +/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `innodb_index_stats`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -6117,35 +6146,6 @@ LOCK TABLES `innodb_table_stats` WRITE; UNLOCK TABLES; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE IF NOT EXISTS `general_log` ( - `event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), - `user_host` mediumtext NOT NULL, - `thread_id` bigint(21) unsigned NOT NULL, - `server_id` int(10) unsigned NOT NULL, - `command_type` varchar(64) NOT NULL, - `argument` mediumtext NOT NULL -) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='General log'; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE IF NOT EXISTS `slow_log` ( - `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), - `user_host` mediumtext NOT NULL, - `query_time` time(6) NOT NULL, - `lock_time` time(6) NOT NULL, - `rows_sent` int(11) NOT NULL, - `rows_examined` int(11) NOT NULL, - `db` varchar(512) NOT NULL, - `last_insert_id` int(11) NOT NULL, - `insert_id` int(11) NOT NULL, - `server_id` int(10) unsigned NOT NULL, - `sql_text` mediumtext NOT NULL, - `thread_id` bigint(21) unsigned NOT NULL, - `rows_affected` int(11) NOT NULL -) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COMMENT='Slow log'; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; CREATE TABLE IF NOT EXISTS `transaction_registry` ( `transaction_id` bigint(20) unsigned NOT NULL, `commit_id` bigint(20) unsigned NOT NULL, @@ -6479,4 +6479,119 @@ SETVAL(`seq_t_i`, 1, 0) 1 DROP DATABASE IF EXISTS test1; DROP DATABASE IF EXISTS test2; +# +# MDEV-27186 Server fails to load a dump, taken on the same version +# Oracle mode with packages +# +CREATE DATABASE test1; +CREATE DATABASE test2; +USE test1; +SET @save_sql_mode=@@sql_mode; +SET sql_mode=ORACLE; +CREATE OR REPLACE PACKAGE pkg AS +END; +$$ +# Dump database 1 +# Restore from database 1 to database 2 +use test2; +SHOW CREATE PACKAGE pkg; +Package sql_mode Create Package character_set_client collation_connection Database Collation +pkg PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT CREATE DEFINER="root"@"localhost" PACKAGE "pkg" AS +END utf8mb3 utf8mb3_general_ci latin1_swedish_ci +DROP DATABASE test1; +DROP DATABASE test2; +SET sql_mode=@save_sql_mode; +# +# MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log +# +CREATE DATABASE test1; +# Dump mysql database +DROP VIEW IF EXISTS mysql.user; +DROP TABLE IF EXISTS mysql.global_priv; +DROP TABLE IF EXISTS mysql.user; +DROP TABLE IF EXISTS mysql.time_zone_transition_type; +DROP TABLE IF EXISTS mysql.time_zone_transition; +DROP TABLE IF EXISTS mysql.time_zone_name; +DROP TABLE IF EXISTS mysql.time_zone_leap_second; +DROP TABLE IF EXISTS mysql.time_zone; +DROP TABLE IF EXISTS mysql.tables_priv; +DROP TABLE IF EXISTS mysql.table_stats; +DROP TABLE IF EXISTS mysql.servers; +DROP TABLE IF EXISTS mysql.roles_mapping; +DROP TABLE IF EXISTS mysql.proxies_priv; +DROP TABLE IF EXISTS mysql.procs_priv; +DROP TABLE IF EXISTS mysql.proc; +DROP TABLE IF EXISTS mysql.plugin; +DROP TABLE IF EXISTS mysql.innodb_table_stats; +DROP TABLE IF EXISTS mysql.innodb_index_stats; +DROP TABLE IF EXISTS mysql.index_stats; +DROP TABLE IF EXISTS mysql.help_topic; +DROP TABLE IF EXISTS mysql.help_relation; +DROP TABLE IF EXISTS mysql.help_keyword; +DROP TABLE IF EXISTS mysql.help_category; +DROP TABLE IF EXISTS mysql.gtid_slave_pos; +DROP TABLE IF EXISTS mysql.func; +DROP TABLE IF EXISTS mysql.event; +DROP TABLE IF EXISTS mysql.db; +DROP TABLE IF EXISTS mysql.columns_priv; +DROP TABLE IF EXISTS mysql.column_stats; +# Abbreviated contents +<?xml version="1.0"?> +<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<database name="mysql"> + <table_structure name="general_log"> + <field Field="event_time" Type="timestamp(6)" Null="NO" Key="" Default="current_timestamp(6)" Extra="on update current_timestamp(6)" Comment="" /> + <field Field="user_host" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" /> + <field Field="thread_id" Type="bigint(21) unsigned" Null="NO" Key="" Extra="" Comment="" /> + <field Field="server_id" Type="int(10) unsigned" Null="NO" Key="" Extra="" Comment="" /> + <field Field="command_type" Type="varchar(64)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="argument" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" /> + <options Name="general_log" Engine="CSV" Version="10" Row_format="Dynamic" Rows="2" Avg_row_length="0" Data_length="0" Max_data_length="0" Index_length="0" Data_free="0" Collation="utf8mb3_general_ci" Create_options="" Comment="General log" Max_index_length="0" Temporary="N" /> + </table_structure> + <table_structure name="slow_log"> + <field Field="start_time" Type="timestamp(6)" Null="NO" Key="" Default="current_timestamp(6)" Extra="on update current_timestamp(6)" Comment="" /> + <field Field="user_host" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" /> + <field Field="query_time" Type="time(6)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="lock_time" Type="time(6)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="rows_sent" Type="int(11)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="rows_examined" Type="int(11)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="db" Type="varchar(512)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="last_insert_id" Type="int(11)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="insert_id" Type="int(11)" Null="NO" Key="" Extra="" Comment="" /> + <field Field="server_id" Type="int(10) unsigned" Null="NO" Key="" Extra="" Comment="" /> + <field Field="sql_text" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" /> + <field Field="thread_id" Type="bigint(21) unsigned" Null="NO" Key="" Extra="" Comment="" /> + <field Field="rows_affected" Type="int(11)" Null="NO" Key="" Extra="" Comment="" /> + <options Name="slow_log" Engine="CSV" Version="10" Row_format="Dynamic" Rows="2" Avg_row_length="0" Data_length="0" Max_data_length="0" Index_length="0" Data_free="0" Collation="utf8mb3_general_ci" Create_options="" Comment="Slow log" Max_index_length="0" Temporary="N" /> + </table_structure> + +/*!50106 SET GLOBAL LOG_OUTPUT=@save_log_output*/; + + <table_structure name="transaction_registry"> + <field Field="transaction_id" Type="bigint(20) unsigned" Null="NO" Key="PRI" Extra="" Comment="" /> + <field Field="commit_id" Type="bigint(20) unsigned" Null="NO" Key="UNI" Extra="" Comment="" /> + <field Field="begin_timestamp" Type="timestamp(6)" Null="NO" Key="MUL" Default="'0000-00-00 00:00:00.000000'" Extra="" Comment="" /> + <field Field="commit_timestamp" Type="timestamp(6)" Null="NO" Key="MUL" Default="'0000-00-00 00:00:00.000000'" Extra="" Comment="" /> + <field Field="isolation_level" Type="enum('READ-UNCOMMITTED','READ-COMMITTED','REPEATABLE-READ','SERIALIZABLE')" Null="NO" Key="" Extra="" Comment="" /> + <key Table="transaction_registry" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="transaction_id" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" /> + <key Table="transaction_registry" Non_unique="0" Key_name="commit_id" Seq_in_index="1" Column_name="commit_id" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" /> + <key Table="transaction_registry" Non_unique="1" Key_name="begin_timestamp" Seq_in_index="1" Column_name="begin_timestamp" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" /> + <key Table="transaction_registry" Non_unique="1" Key_name="commit_timestamp" Seq_in_index="1" Column_name="commit_timestamp" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" /> + <key Table="transaction_registry" Non_unique="1" Key_name="commit_timestamp" Seq_in_index="2" Column_name="transaction_id" Collation="A" Cardinality="0" Null="" Index_type="BTREE" Comment="" Index_comment="" Ignored="NO" /> + <options Name="transaction_registry" Engine="InnoDB" Version="10" Row_format="Dynamic" Rows="0" Avg_row_length="0" Data_length="16384" Max_data_length="0" Index_length="49152" Data_free="0" Create_time="TIMESTAMP" Collation="utf8mb3_bin" Create_options="stats_persistent=0" Comment="" Max_index_length="0" Temporary="N" /> + </table_structure> +</database> +<database name="test1"> +</database> +</mysqldump> +SET @save_general_log=@@GENERAL_LOG; +SET GLOBAL LOG_OUTPUT='TABLE', GLOBAL GENERAL_LOG=1; +# Restore mysql database while general log is active +# No failure at this stage is the object of the test +SELECT @@GLOBAL.LOG_OUTPUT, @@GLOBAL.GENERAL_LOG; +@@GLOBAL.LOG_OUTPUT @@GLOBAL.GENERAL_LOG +TABLE 1 +SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log; +TRUNCATE TABLE mysql.general_log; +DROP DATABASE test1; # End of 10.3 tests diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index 0786cf6f803..fc6a426d554 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -2887,4 +2887,94 @@ INSERT INTO t VALUES (1,1),(2,2),(3,3),(4,4); DROP DATABASE IF EXISTS test1; DROP DATABASE IF EXISTS test2; +--echo # +--echo # MDEV-27186 Server fails to load a dump, taken on the same version +--echo # Oracle mode with packages +--echo # + +CREATE DATABASE test1; +CREATE DATABASE test2; +USE test1; +SET @save_sql_mode=@@sql_mode; +SET sql_mode=ORACLE; + +DELIMITER $$; +CREATE OR REPLACE PACKAGE pkg AS +END; +$$ + +DELIMITER ;$$ + +--echo # Dump database 1 +--exec $MYSQL_DUMP --routines test1 > $MYSQLTEST_VARDIR/tmp/dumptest1.sql +--echo # Restore from database 1 to database 2 + +--exec $MYSQL test2 < $MYSQLTEST_VARDIR/tmp/dumptest1.sql +use test2; +SHOW CREATE PACKAGE pkg; + +DROP DATABASE test1; +DROP DATABASE test2; +SET sql_mode=@save_sql_mode; +--remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql + +--echo # +--echo # MDEV-4875 Can't restore a mysqldump if --add-drop-database meets general_log +--echo # + +CREATE DATABASE test1; +--echo # Dump mysql database +--exec $MYSQL_DUMP --add-drop-database --databases mysql test1 > $MYSQLTEST_VARDIR/tmp/dumptest1.sql + +--disable_warnings +DROP VIEW IF EXISTS mysql.user; +DROP TABLE IF EXISTS mysql.global_priv; +DROP TABLE IF EXISTS mysql.user; +--enable_warnings +#DROP TABLE IF EXISTS mysql.transaction_registry; +#DROP TABLE IF EXISTS mysql.slow_log; +#DROP TABLE IF EXISTS mysql.general_log; +DROP TABLE IF EXISTS mysql.time_zone_transition_type; +DROP TABLE IF EXISTS mysql.time_zone_transition; +DROP TABLE IF EXISTS mysql.time_zone_name; +DROP TABLE IF EXISTS mysql.time_zone_leap_second; +DROP TABLE IF EXISTS mysql.time_zone; +DROP TABLE IF EXISTS mysql.tables_priv; +DROP TABLE IF EXISTS mysql.table_stats; +DROP TABLE IF EXISTS mysql.servers; +DROP TABLE IF EXISTS mysql.roles_mapping; +DROP TABLE IF EXISTS mysql.proxies_priv; +DROP TABLE IF EXISTS mysql.procs_priv; +DROP TABLE IF EXISTS mysql.proc; +DROP TABLE IF EXISTS mysql.plugin; +DROP TABLE IF EXISTS mysql.innodb_table_stats; +DROP TABLE IF EXISTS mysql.innodb_index_stats; +DROP TABLE IF EXISTS mysql.index_stats; +DROP TABLE IF EXISTS mysql.help_topic; +DROP TABLE IF EXISTS mysql.help_relation; +DROP TABLE IF EXISTS mysql.help_keyword; +DROP TABLE IF EXISTS mysql.help_category; +DROP TABLE IF EXISTS mysql.gtid_slave_pos; +DROP TABLE IF EXISTS mysql.func; +DROP TABLE IF EXISTS mysql.event; +DROP TABLE IF EXISTS mysql.db; +DROP TABLE IF EXISTS mysql.columns_priv; +DROP TABLE IF EXISTS mysql.column_stats; + +--echo # Abbreviated contents +--replace_regex /Create_time="[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}"/Create_time="TIMESTAMP"/ +--exec $MYSQL_DUMP --xml --skip-comments --no-data --add-drop-database --databases mysql test1 + +SET @save_general_log=@@GENERAL_LOG; +SET GLOBAL LOG_OUTPUT='TABLE', GLOBAL GENERAL_LOG=1; + +--echo # Restore mysql database while general log is active +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/dumptest1.sql +--echo # No failure at this stage is the object of the test +SELECT @@GLOBAL.LOG_OUTPUT, @@GLOBAL.GENERAL_LOG; +SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log; +TRUNCATE TABLE mysql.general_log; +DROP DATABASE test1; +--remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql + --echo # End of 10.3 tests diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 54ec5edd0c4..69fc5c8cf4f 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -145,8 +145,7 @@ select * from v1 { } }, "rows_for_plan": 1, - "cost_for_plan": 2.404394531, - "estimated_join_cardinality": 1 + "cost_for_plan": 2.404394531 } ] }, @@ -296,8 +295,7 @@ select * from (select * from t1 where t1.a=1)q { } }, "rows_for_plan": 1, - "cost_for_plan": 2.404394531, - "estimated_join_cardinality": 1 + "cost_for_plan": 2.404394531 } ] }, @@ -454,8 +452,7 @@ select * from v2 { }, "rows_for_plan": 1, "cost_for_plan": 2.404394531, - "cost_for_sorting": 1, - "estimated_join_cardinality": 1 + "cost_for_sorting": 1 } ] }, @@ -525,8 +522,7 @@ select * from v2 { } }, "rows_for_plan": 2, - "cost_for_plan": 2.4, - "estimated_join_cardinality": 2 + "cost_for_plan": 2.4 } ] }, @@ -662,8 +658,7 @@ explain select * from v2 { } }, "rows_for_plan": 10, - "cost_for_plan": 4.021972656, - "estimated_join_cardinality": 10 + "cost_for_plan": 4.021972656 } ] }, @@ -780,8 +775,7 @@ explain select * from v1 { }, "rows_for_plan": 10, "cost_for_plan": 4.021972656, - "cost_for_sorting": 10, - "estimated_join_cardinality": 10 + "cost_for_sorting": 10 } ] }, @@ -845,8 +839,7 @@ explain select * from v1 { } }, "rows_for_plan": 10, - "cost_for_plan": 12, - "estimated_join_cardinality": 10 + "cost_for_plan": 12 } ] }, @@ -1049,7 +1042,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b { }, "rows_for_plan": 100, "cost_for_plan": 242.3759623, - "estimated_join_cardinality": 100 + "pruned_by_hanging_leaf": true } ] }, @@ -1280,8 +1273,7 @@ EXPLAIN SELECT DISTINCT a FROM t1 { } }, "rows_for_plan": 5, - "cost_for_plan": 7.25, - "estimated_join_cardinality": 5 + "cost_for_plan": 7.25 } ] }, @@ -1472,8 +1464,7 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a { }, "rows_for_plan": 8, "cost_for_plan": 3.8, - "cost_for_sorting": 8, - "estimated_join_cardinality": 8 + "cost_for_sorting": 8 } ] }, @@ -1671,8 +1662,7 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id { }, "rows_for_plan": 9, "cost_for_plan": 4.15, - "cost_for_sorting": 9, - "estimated_join_cardinality": 9 + "cost_for_sorting": 9 } ] }, @@ -1859,8 +1849,7 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id { }, "rows_for_plan": 9, "cost_for_plan": 4.15, - "cost_for_sorting": 9, - "estimated_join_cardinality": 9 + "cost_for_sorting": 9 } ] }, @@ -2145,8 +2134,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { } }, "rows_for_plan": 21, - "cost_for_plan": 25.34242739, - "estimated_join_cardinality": 21 + "cost_for_plan": 25.34242739 } ] }, @@ -2400,8 +2388,7 @@ select t1.a from t1 left join t2 on t1.a=t2.a { } }, "rows_for_plan": 4, - "cost_for_plan": 2.806835937, - "estimated_join_cardinality": 4 + "cost_for_plan": 2.806835937 } ] }, @@ -2570,7 +2557,7 @@ explain select * from t1 left join t2 on t2.a=t1.a { }, "rows_for_plan": 4, "cost_for_plan": 7.606835937, - "estimated_join_cardinality": 4 + "pruned_by_hanging_leaf": true } ] } @@ -2753,8 +2740,7 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and } }, "rows_for_plan": 4, - "cost_for_plan": 2.806835937, - "estimated_join_cardinality": 4 + "cost_for_plan": 2.806835937 } ] }, @@ -2961,8 +2947,7 @@ explain extended select * from t1 where a in (select pk from t10) { } }, "rows_for_plan": 10, - "cost_for_plan": 4.021972656, - "estimated_join_cardinality": 10 + "cost_for_plan": 4.021972656 } ] } @@ -3034,8 +3019,7 @@ explain extended select * from t1 where a in (select pk from t10) { { "chosen_strategy": "SJ-Materialization" } - ], - "estimated_join_cardinality": 3 + ] } ] }, @@ -3446,7 +3430,7 @@ explain select * from t1 where pk = 2 and a=5 and b=1 { }, "rows_for_plan": 1, "cost_for_plan": 0.326073957, - "estimated_join_cardinality": 1 + "pruned_by_hanging_leaf": true } ] }, @@ -3574,8 +3558,7 @@ select f1(a) from t1 { } }, "rows_for_plan": 4, - "cost_for_plan": 2.806835937, - "estimated_join_cardinality": 4 + "cost_for_plan": 2.806835937 } ] }, @@ -3671,8 +3654,7 @@ select f2(a) from t1 { } }, "rows_for_plan": 4, - "cost_for_plan": 2.806835937, - "estimated_join_cardinality": 4 + "cost_for_plan": 2.806835937 } ] }, @@ -3718,7 +3700,7 @@ a 2 select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; length(trace) -2141 +2092 set optimizer_trace_max_mem_size=100; select * from t1; a @@ -3732,7 +3714,7 @@ select * from t1 { "join_preparation": { "select_id": 1, "steps": [ - 2041 0 + 1992 0 set optimizer_trace_max_mem_size=0; select * from t1; a @@ -3740,7 +3722,7 @@ a 2 select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE; QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES -select * from t1 2141 0 +select * from t1 2092 0 drop table t1; set optimizer_trace='enabled=off'; set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size; @@ -4085,7 +4067,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { }, "rows_for_plan": 3, "cost_for_plan": 4.948514767, - "estimated_join_cardinality": 3 + "pruned_by_hanging_leaf": true } ] }, @@ -4284,8 +4266,7 @@ explain select * from (select rand() from t1)q { } }, "rows_for_plan": 3, - "cost_for_plan": 2.605126953, - "estimated_join_cardinality": 3 + "cost_for_plan": 2.605126953 } ] }, @@ -4349,8 +4330,7 @@ explain select * from (select rand() from t1)q { } }, "rows_for_plan": 3, - "cost_for_plan": 3.6, - "estimated_join_cardinality": 3 + "cost_for_plan": 3.6 } ] }, @@ -4578,8 +4558,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ } }, "rows_for_plan": 9, - "cost_for_plan": 6.410253906, - "estimated_join_cardinality": 9 + "cost_for_plan": 6.410253906 } ] }, @@ -4699,8 +4678,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_ { "chosen_strategy": "SJ-Materialization" } - ], - "estimated_join_cardinality": 3 + ] } ] }, @@ -5243,8 +5221,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "chosen_strategy": "DuplicateWeedout" } - ], - "estimated_join_cardinality": 27 + ] } ] }, @@ -5366,8 +5343,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "chosen_strategy": "DuplicateWeedout" } - ], - "estimated_join_cardinality": 27 + ] } ] }, @@ -6688,8 +6664,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { } }, "rows_for_plan": 27, - "cost_for_plan": 10.02050781, - "estimated_join_cardinality": 27 + "cost_for_plan": 10.02050781 } ] }, @@ -6762,8 +6737,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { } }, "rows_for_plan": 27, - "cost_for_plan": 10.02050781, - "estimated_join_cardinality": 27 + "cost_for_plan": 10.02050781 } ] }, @@ -6982,8 +6956,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) { { "chosen_strategy": "SJ-Materialization" } - ], - "estimated_join_cardinality": 27 + ] } ] }, @@ -8149,8 +8122,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) } }, "rows_for_plan": 4000, - "cost_for_plan": 1025.003418, - "estimated_join_cardinality": 4000 + "cost_for_plan": 1025.003418 } ] }, @@ -8491,7 +8463,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) "rows_for_plan": 10, "cost_for_plan": 26.0278306, "cost_for_sorting": 10, - "estimated_join_cardinality": 10 + "pruned_by_hanging_leaf": true } ] }, @@ -8811,8 +8783,7 @@ select count(*) from seq_1_to_10000000 { } }, "rows_for_plan": 10000000, - "cost_for_plan": 12000000, - "estimated_join_cardinality": 10000000 + "cost_for_plan": 12000000 } ] }, @@ -9216,8 +9187,7 @@ json_detailed(json_extract(trace, '$**.choose_best_splitting')) }, "rows_for_plan": 1.8367, "cost_for_plan": 2.367925794, - "cost_for_sorting": 1.8367, - "estimated_join_cardinality": 1.8367 + "cost_for_sorting": 1.8367 } ] }, diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result index f1e13586eda..335e408bddd 100644 --- a/mysql-test/main/opt_trace_index_merge.result +++ b/mysql-test/main/opt_trace_index_merge.result @@ -221,8 +221,7 @@ explain select * from t1 where a=1 or b=1 { } }, "rows_for_plan": 2, - "cost_for_plan": 2.884903732, - "estimated_join_cardinality": 2 + "cost_for_plan": 2.884903732 } ] }, diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result index 57a6c72e52f..590b659f40d 100644 --- a/mysql-test/main/opt_trace_index_merge_innodb.result +++ b/mysql-test/main/opt_trace_index_merge_innodb.result @@ -228,7 +228,7 @@ explain select * from t1 where pk1 != 0 and key1 = 1 { }, "rows_for_plan": 1, "cost_for_plan": 1.325146475, - "estimated_join_cardinality": 1 + "pruned_by_hanging_leaf": true } ] }, diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result index e1937e744a4..83d98c4c183 100644 --- a/mysql-test/main/opt_trace_security.result +++ b/mysql-test/main/opt_trace_security.result @@ -107,8 +107,7 @@ select * from db1.t1 { } }, "rows_for_plan": 3, - "cost_for_plan": 2.605126953, - "estimated_join_cardinality": 3 + "cost_for_plan": 2.605126953 } ] }, @@ -229,8 +228,7 @@ select * from db1.v1 { } }, "rows_for_plan": 3, - "cost_for_plan": 2.605126953, - "estimated_join_cardinality": 3 + "cost_for_plan": 2.605126953 } ] }, diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 3735700f315..b6345cd142e 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3588,6 +3588,26 @@ DELETE FROM t1 ORDER BY c; DROP TABLE t1; SET @@SESSION.max_sort_length=DEFAULT; SET sql_mode=DEFAULT; +# +# MDEV-25994 Crash with union of my_decimal type in ORDER BY clause +# +CREATE TABLE t1 (v1 INTEGER) ; +INSERT INTO t1 (v1) VALUES (8); +UPDATE t1 SET v1 = 1 ORDER BY (SELECT 1.1 UNION SELECT -1); +ERROR 21000: Subquery returns more than 1 row +# This one must be successful +UPDATE t1 SET v1 = 2 ORDER BY (SELECT 1 UNION SELECT 1); +UPDATE t1 SET v1 = 3 ORDER BY (SELECT 'a' UNION SELECT 'b'); +ERROR 21000: Subquery returns more than 1 row +# Insert some more data +INSERT INTO t1 (v1) VALUES (8),(9),(100),(-234),(46584),(0); +UPDATE t1 SET v1 = v1+1 ORDER BY (SELECT 100.122 UNION SELECT -189.2); +ERROR 21000: Subquery returns more than 1 row +# This one must be successful +UPDATE t1 SET v1 = v1-200 ORDER BY (SELECT 1 UNION SELECT 1); +UPDATE t1 SET v1 = v1 ORDER BY (SELECT 'abc' UNION SELECT 'bbb'); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; # End of 10.2 tests # # MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 5ff1dc4ad3b..2d001c2f1eb 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -2326,6 +2326,31 @@ DROP TABLE t1; SET @@SESSION.max_sort_length=DEFAULT; SET sql_mode=DEFAULT; +--echo # +--echo # MDEV-25994 Crash with union of my_decimal type in ORDER BY clause +--echo # + +CREATE TABLE t1 (v1 INTEGER) ; +INSERT INTO t1 (v1) VALUES (8); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = 1 ORDER BY (SELECT 1.1 UNION SELECT -1); +--echo # This one must be successful +UPDATE t1 SET v1 = 2 ORDER BY (SELECT 1 UNION SELECT 1); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = 3 ORDER BY (SELECT 'a' UNION SELECT 'b'); + +-- echo # Insert some more data +INSERT INTO t1 (v1) VALUES (8),(9),(100),(-234),(46584),(0); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = v1+1 ORDER BY (SELECT 100.122 UNION SELECT -189.2); +--echo # This one must be successful +UPDATE t1 SET v1 = v1-200 ORDER BY (SELECT 1 UNION SELECT 1); +--error ER_SUBQUERY_NO_1_ROW +UPDATE t1 SET v1 = v1 ORDER BY (SELECT 'abc' UNION SELECT 'bbb'); + + +DROP TABLE t1; + --echo # End of 10.2 tests diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 6a24e435878..0a640d6c7ac 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1364,6 +1364,48 @@ SELECT tmp 1.e.test FROM scientific_notation AS tmp; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1.e.test FROM scientific_notation AS tmp' at line 1 DROP TABLE scientific_notation; # +# MDEV-6899 extra semicolon in show create event syntax +# +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +create table t1 (a int); +create trigger a before insert on t1 for each row set @a:=1;select 2$ +2 +2 +show create trigger a; +Trigger a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +SQL Original Statement CREATE DEFINER=`root`@`localhost` trigger a before insert on t1 for each row set @a:=1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +Created 2020-10-10 05:05:05.00 +drop table t1; +create procedure a() select 1;select 2$ +2 +2 +show create procedure a; +Procedure a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +Create Procedure CREATE DEFINER=`root`@`localhost` PROCEDURE `a`() +select 1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +drop procedure a; +create function a() returns int return 1;select 2$ +2 +2 +show create function a; +Function a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +Create Function CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11) +return 1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +drop function a; +set timestamp=default; +# # End of 10.2 tests # # diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index cbd3274113a..6271577c614 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1405,6 +1405,32 @@ SELECT tmp 1.e.test FROM scientific_notation AS tmp; DROP TABLE scientific_notation; --echo # +--echo # MDEV-6899 extra semicolon in show create event syntax +--echo # +--disable_ps_protocol +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +create table t1 (a int); +delimiter $; +create trigger a before insert on t1 for each row set @a:=1;select 2$ +delimiter ;$ +query_vertical show create trigger a; +drop table t1; + +delimiter $; +create procedure a() select 1;select 2$ +delimiter ;$ +query_vertical show create procedure a; +drop procedure a; + +delimiter $; +create function a() returns int return 1;select 2$ +delimiter ;$ +query_vertical show create function a; +drop function a; +set timestamp=default; +--enable_ps_protocol + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/parser_not_embedded.result b/mysql-test/main/parser_not_embedded.result index 25349e51577..2147e25b3b1 100644 --- a/mysql-test/main/parser_not_embedded.result +++ b/mysql-test/main/parser_not_embedded.result @@ -102,3 +102,23 @@ ROLLBACK AND NO CHAIN NO RELEASE; # # End of 5.5 tests # +# +# MDEV-6899 extra semicolon in show create event syntax +# +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +create event a on schedule every 1 day do set @a:=1;select 2$ +2 +2 +show create event a; +Event a +sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +time_zone SYSTEM +Create Event CREATE DEFINER=`root`@`localhost` EVENT `a` ON SCHEDULE EVERY 1 DAY STARTS '2020-10-10 05:05:05' ON COMPLETION NOT PRESERVE ENABLE DO set @a:=1 +character_set_client latin1 +collation_connection latin1_swedish_ci +Database Collation latin1_swedish_ci +drop event a; +set timestamp=default; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/parser_not_embedded.test b/mysql-test/main/parser_not_embedded.test index 3af1260f4ad..0208ee57a2e 100644 --- a/mysql-test/main/parser_not_embedded.test +++ b/mysql-test/main/parser_not_embedded.test @@ -99,3 +99,20 @@ ROLLBACK AND NO CHAIN NO RELEASE; --echo # --echo # End of 5.5 tests --echo # + +--echo # +--echo # MDEV-6899 extra semicolon in show create event syntax +--echo # +--disable_ps_protocol +set timestamp=unix_timestamp('2020-10-10 5:5:5'); +delimiter $; +create event a on schedule every 1 day do set @a:=1;select 2$ +delimiter ;$ +query_vertical show create event a; +drop event a; +set timestamp=default; +--enable_ps_protocol + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/partition_exchange.result b/mysql-test/main/partition_exchange.result index 2b69e2fff43..ac38b189800 100644 --- a/mysql-test/main/partition_exchange.result +++ b/mysql-test/main/partition_exchange.result @@ -1237,8 +1237,18 @@ ALTER TABLE t2 REMOVE PARTITIONING; ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2; DROP TABLE t1, t2; # -# End of 10.3 tests +# MDEV-14642 Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition # +CREATE TABLE t1 (a INT) ROW_FORMAT=DYNAMIC PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT) ; +ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; +ERROR HY000: Tables have different definitions +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB; +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; +ERROR HY000: Tables have different definitions +DROP TABLE t1, t2; # # MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errors # diff --git a/mysql-test/main/partition_exchange.test b/mysql-test/main/partition_exchange.test index 3383ebb01e3..82ccc29e00e 100644 --- a/mysql-test/main/partition_exchange.test +++ b/mysql-test/main/partition_exchange.test @@ -533,8 +533,23 @@ ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2; DROP TABLE t1, t2; --echo # ---echo # End of 10.3 tests +--echo # MDEV-14642 Assertion `table->s->db_create_options == part_table->s->db_create_options' failed in compare_table_with_partition --echo # +CREATE TABLE t1 (a INT) ROW_FORMAT=DYNAMIC PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT) ; +--error ER_TABLES_DIFFERENT_METADATA +ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2; + +# Cleanup +DROP TABLE t1, t2; + +CREATE TABLE t1 (a INT, PRIMARY KEY(a)) ENGINE=InnoDB PARTITION BY KEY(a) PARTITIONS 2; +CREATE TABLE t2 (a INT, PRIMARY KEY(a)) CHECKSUM=1, ENGINE=InnoDB; +--error ER_TABLES_DIFFERENT_METADATA +ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2; + +# Cleanup +DROP TABLE t1, t2; --echo # --echo # MDEV-27683 EXCHANGE PARTITION allows different index direction, but causes further errors diff --git a/mysql-test/main/plugin.result b/mysql-test/main/plugin.result index f16b72f0564..cd1cf28c28e 100644 --- a/mysql-test/main/plugin.result +++ b/mysql-test/main/plugin.result @@ -357,6 +357,15 @@ select * from mysql.plugin WHERE name='unexisting_plugin'; name dl UNINSTALL PLUGIN unexisting_plugin; ERROR 42000: PLUGIN unexisting_plugin does not exist +# +# MDEV-26323 use-after-poison issue of MariaDB server +# +INSTALL PLUGIN DEALLOCATE SONAME ''; +ERROR HY000: Can't open shared library '.so' +INSTALL PLUGIN DEALLOCATE SONAME 'x'; +ERROR HY000: Can't open shared library 'x.so' +INSTALL PLUGIN DEALLOCATE SONAME 'xx'; +ERROR HY000: Can't open shared library 'xx.so' # End of 10.2 tests # # MDEV-16294: INSTALL PLUGIN IF NOT EXISTS / UNINSTALL PLUGIN IF EXISTS diff --git a/mysql-test/main/plugin.test b/mysql-test/main/plugin.test index 60773c3e190..967364a3e03 100644 --- a/mysql-test/main/plugin.test +++ b/mysql-test/main/plugin.test @@ -296,6 +296,23 @@ select * from mysql.plugin WHERE name='unexisting_plugin'; --error ER_SP_DOES_NOT_EXIST UNINSTALL PLUGIN unexisting_plugin; +--echo # +--echo # MDEV-26323 use-after-poison issue of MariaDB server +--echo # + +--replace_regex /library '.*[\\/].(dll|so)' [(].*[)]/library '.so'/ +--error ER_CANT_OPEN_LIBRARY +INSTALL PLUGIN DEALLOCATE SONAME ''; + +--replace_regex /library '.*[\\/]x.(dll|so)' [(].*[)]/library 'x.so'/ +--error ER_CANT_OPEN_LIBRARY +INSTALL PLUGIN DEALLOCATE SONAME 'x'; + +--replace_regex /library '.*[\\/]xx.(dll|so)' [(].*[)]/library 'xx.so'/ +--error ER_CANT_OPEN_LIBRARY +INSTALL PLUGIN DEALLOCATE SONAME 'xx'; + + --echo # End of 10.2 tests --source include/install_plugin_if_exists.inc diff --git a/mysql-test/main/ps_missed_cmds.result b/mysql-test/main/ps_missed_cmds.result index ce3b6acc898..d377a359666 100644 --- a/mysql-test/main/ps_missed_cmds.result +++ b/mysql-test/main/ps_missed_cmds.result @@ -694,7 +694,7 @@ EXECUTE stmt_1; # results in emitting the error ER_FOREIGN_SERVER_EXISTS # since a server with same has just been created. EXECUTE stmt_1; -ERROR HY000: The foreign server, s, you are trying to create already exists +ERROR HY000: Cannot create foreign server 's' as it already exists EXECUTE stmt_2; # Execute the same prepared statement the second time to check that # no internal structures used for handling the 'ALTER SERVER' statement diff --git a/mysql-test/main/repair_symlink-5543.result b/mysql-test/main/repair_symlink-5543.result index 2024c9f5684..e99bd4ea312 100644 --- a/mysql-test/main/repair_symlink-5543.result +++ b/mysql-test/main/repair_symlink-5543.result @@ -1,7 +1,5 @@ create table t1 (a int) engine=myisam data directory='MYSQL_TMP_DIR'; insert t1 values (1); -# Some systems fail with errcode 40, or 90 (MIPS) when doing openat, -# while others don't have openat and fail with errcode 20. repair table t1; Table Op Msg_type Msg_text test.t1 repair error 20 for record at pos 0 diff --git a/mysql-test/main/repair_symlink-5543.test b/mysql-test/main/repair_symlink-5543.test index 7c4ad7db0dc..002b8d8023b 100644 --- a/mysql-test/main/repair_symlink-5543.test +++ b/mysql-test/main/repair_symlink-5543.test @@ -9,9 +9,10 @@ eval create table t1 (a int) engine=myisam data directory='$MYSQL_TMP_DIR'; insert t1 values (1); --system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t1.TMD ---echo # Some systems fail with errcode 40, or 90 (MIPS) when doing openat, ---echo # while others don't have openat and fail with errcode 20. ---replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/ /[49]0/20/ /85/20/ /".*"/"<errmsg>"/ +# Some systems fail with errcode 31 (FreeBSD), 40 (Linux), 85 (AIX), +# or 90 (MIPS) when doing openat, +# while others don't have openat and fail with errcode 20. +--replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/ /[49]0|31|85/20/ /".*"/"<errmsg>"/ repair table t1; drop table t1; @@ -19,7 +20,7 @@ drop table t1; eval create table t2 (a int) engine=aria data directory='$MYSQL_TMP_DIR'; insert t2 values (1); --system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t2.TMD ---replace_regex / '.*\/t2/ 'MYSQL_TMP_DIR\/t2/ /[49]0/20/ /85/20/ /".*"/"<errmsg>"/ +--replace_regex / '.*\/t2/ 'MYSQL_TMP_DIR\/t2/ /[49]0|31|85/20/ /".*"/"<errmsg>"/ repair table t2; drop table t2; diff --git a/mysql-test/main/row-checksum-old.result b/mysql-test/main/row-checksum-old.result index d374013f61c..7caed4fc7dc 100644 --- a/mysql-test/main/row-checksum-old.result +++ b/mysql-test/main/row-checksum-old.result @@ -1,4 +1,3 @@ -drop table if exists t1; create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; insert into t1 values(null, null), (1, "hello"); checksum table t1; @@ -98,4 +97,48 @@ CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 2326430205 drop table t1; +# # End of 5.5 tests +# +# +# MDEV-28020 CHECKSUM TABLE calculates different checksums +# +create table t1 ( a int, b int as (a) virtual, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) virtual, c text, key(b)) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) stored, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 2897795735 +checksum table t1; +Table Checksum +test.t1 2897795735 +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/row-checksum.result b/mysql-test/main/row-checksum.result index 4625e09c060..c80ca4eed9a 100644 --- a/mysql-test/main/row-checksum.result +++ b/mysql-test/main/row-checksum.result @@ -1,4 +1,3 @@ -drop table if exists t1; create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; insert into t1 values(null, null), (1, "hello"); checksum table t1; @@ -98,4 +97,48 @@ CHECKSUM TABLE t1 EXTENDED; Table Checksum test.t1 2326430205 drop table t1; +# # End of 5.5 tests +# +# +# MDEV-28020 CHECKSUM TABLE calculates different checksums +# +create table t1 ( a int, b int as (a) virtual, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) virtual, c text, key(b)) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 4101438232 +checksum table t1; +Table Checksum +test.t1 4101438232 +drop table t1; +create table t1 ( a int, b int as (a) stored, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +Warnings: +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored +checksum table t1 extended; +Table Checksum +test.t1 2897795735 +checksum table t1; +Table Checksum +test.t1 2897795735 +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/main/row-checksum.test b/mysql-test/main/row-checksum.test index 5acfda45f75..3b510abba84 100644 --- a/mysql-test/main/row-checksum.test +++ b/mysql-test/main/row-checksum.test @@ -2,12 +2,8 @@ # Test checksum # --- source include/have_innodb.inc --- source include/have_maria.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings +--source include/have_innodb.inc +--source include/have_maria.inc create table t1 (a int null, v varchar(100)) engine=myisam checksum=0; insert into t1 values(null, null), (1, "hello"); @@ -76,4 +72,31 @@ CHECKSUM TABLE t1 EXTENDED; drop table t1; +--echo # --echo # End of 5.5 tests +--echo # + +--echo # +--echo # MDEV-28020 CHECKSUM TABLE calculates different checksums +--echo # +create table t1 ( a int, b int as (a) virtual, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +checksum table t1 extended; +checksum table t1; +drop table t1; + +create table t1 ( a int, b int as (a) virtual, c text, key(b)) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +checksum table t1 extended; +checksum table t1; +drop table t1; + +create table t1 ( a int, b int as (a) stored, c text) engine=myisam checksum=1; +insert ignore t1 values (1,2,'foo'),(2,3,'bar'); +checksum table t1 extended; +checksum table t1; +drop table t1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/main/ssl_timeout.result b/mysql-test/main/ssl_timeout.result index e0d1dbed69f..208be527a6b 100644 --- a/mysql-test/main/ssl_timeout.result +++ b/mysql-test/main/ssl_timeout.result @@ -5,6 +5,6 @@ SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS have_ssl 1 SELECT SLEEP(600); -ERROR HY000: Lost connection to server during query +Got one of the listed errors connection default; disconnect ssl_con; diff --git a/mysql-test/main/ssl_timeout.test b/mysql-test/main/ssl_timeout.test index 430fe7130de..f5965f874ff 100644 --- a/mysql-test/main/ssl_timeout.test +++ b/mysql-test/main/ssl_timeout.test @@ -10,7 +10,7 @@ connect (ssl_con,localhost,root,,,,,SSL read_timeout=5); SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; # --error CR_SERVER_LOST ---error 2013 +--error 2013,2026 SELECT SLEEP(600); connection default; diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index 167382fc328..22a814c1756 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -1259,7 +1259,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index abc429fb550..90976963b00 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -155,6 +155,9 @@ EXECUTE my_stmt; b count(*) deallocate prepare my_stmt; drop table t1,t2; +# +# End of 4.1 tests +# CREATE TABLE t1 ( school_name varchar(45) NOT NULL, country varchar(45) NOT NULL, @@ -288,7 +291,6 @@ LIMIT 10; col_time_key col_datetime_key DROP TABLE t1; DROP TABLE t2; -# End of Bug #58756 # # Bug#60085 crash in Item::save_in_field() with time data type # @@ -357,7 +359,9 @@ LIMIT 1; maxkey NULL DROP TABLE t1,t2; -End of 5.1 tests +# +# End of 5.1 tests +# # # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries # @@ -578,7 +582,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ref key1 key1 5 test.t1.a # Using where; Using filesort drop table t1,t2; # -# mdev-12931: semi-join in ON expression of STRAIGHT_JOIN +# MDEV-12931: semi-join in ON expression of STRAIGHT_JOIN # joining a base table and a mergeable derived table # CREATE TABLE t1 (f1 int) ENGINE=InnoDB; @@ -630,6 +634,52 @@ a b 2019-03-10 02:55:05 2019-03-10 02:55:05 DROP TABLE t1,t2; set character_set_connection=@save_character_set_connection; +# +# MDEV-26047: MariaDB server crash at Item_subselect::init_expr_cache_tracker +# +CREATE TABLE t1 (a int) engine=innodb; +SELECT 1 IN ( +SELECT NULL +FROM t1 +WHERE +a IS NOT NULL +GROUP BY +(SELECT NULL from dual WHERE a = 1) +); +1 IN ( +SELECT NULL +FROM t1 +WHERE +a IS NOT NULL +GROUP BY +(SELECT NULL from dual WHERE a = 1) +) +0 +drop table t1; +# Testcase from MDEV-26164 +create table t1(a int); +# Disable the warning as it includes current time and changes for every test run. +select 1 from t1 where not exists +( +select 1 from t1 where binary current_time() +group by (select a),(select 1) +); +1 +drop table t1; +# +# MDEV-28437: Assertion `!eliminated' failed in Item_subselect::exec +# +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3),(4); +SELECT 1 IN (SELECT a FROM t1 LEFT JOIN t2 ON (a = b AND EXISTS (SELECT * FROM t1))); +1 IN (SELECT a FROM t1 LEFT JOIN t2 ON (a = b AND EXISTS (SELECT * FROM t1))) +1 +drop table t1,t2; +# +# End of 10.2 tests +# # # MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' # failed in Item_equal::fix_fields, server crashes after 2nd execution @@ -663,5 +713,19 @@ a b execute stmt; a b drop table t1,t2; +# +# MDEV-28097 use-after-free when WHERE has subquery with an outer reference in HAVING +# +create table t1 (a text(60) not null) engine=innodb; +insert into t1 values ('1'),('0'); +select distinct a from t1 where '' in (select 'x' like a having a like a); +a +1 +0 +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: '' +drop table t1; +# # End of 10.4 tests +# SET GLOBAL innodb_stats_persistent = @saved_stats_persistent; diff --git a/mysql-test/main/subselect_innodb.test b/mysql-test/main/subselect_innodb.test index 19871e14008..493a7425ea8 100644 --- a/mysql-test/main/subselect_innodb.test +++ b/mysql-test/main/subselect_innodb.test @@ -163,7 +163,9 @@ EXECUTE my_stmt; deallocate prepare my_stmt; drop table t1,t2; -# End of 4.1 tests +--echo # +--echo # End of 4.1 tests +--echo # CREATE TABLE t1 ( school_name varchar(45) NOT NULL, @@ -288,8 +290,6 @@ LIMIT 10; DROP TABLE t1; DROP TABLE t2; ---echo # End of Bug #58756 - --echo # --echo # Bug#60085 crash in Item::save_in_field() with time data type --echo # @@ -353,7 +353,9 @@ eval $query; DROP TABLE t1,t2; ---echo End of 5.1 tests +--echo # +--echo # End of 5.1 tests +--echo # --echo # --echo # lp:827416 Crash in select_describe() on EXPLAIN with DISTINCT in nested subqueries @@ -506,8 +508,6 @@ drop table t1,t2; --echo # for a subquery from the expression used in ref access --echo # ---source include/have_innodb.inc - CREATE TABLE t1 (i1 INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1),(2); @@ -577,7 +577,7 @@ from drop table t1,t2; --echo # ---echo # mdev-12931: semi-join in ON expression of STRAIGHT_JOIN +--echo # MDEV-12931: semi-join in ON expression of STRAIGHT_JOIN --echo # joining a base table and a mergeable derived table --echo # @@ -627,6 +627,49 @@ DROP TABLE t1,t2; set character_set_connection=@save_character_set_connection; +--echo # +--echo # MDEV-26047: MariaDB server crash at Item_subselect::init_expr_cache_tracker +--echo # +CREATE TABLE t1 (a int) engine=innodb; + +SELECT 1 IN ( + SELECT NULL + FROM t1 + WHERE + a IS NOT NULL + GROUP BY + (SELECT NULL from dual WHERE a = 1) +); +drop table t1; + +--echo # Testcase from MDEV-26164 +create table t1(a int); +--echo # Disable the warning as it includes current time and changes for every test run. +--disable_warnings +select 1 from t1 where not exists +( + select 1 from t1 where binary current_time() + group by (select a),(select 1) +); +--enable_warnings +drop table t1; + +--echo # +--echo # MDEV-28437: Assertion `!eliminated' failed in Item_subselect::exec +--echo # +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (3),(4); + +SELECT 1 IN (SELECT a FROM t1 LEFT JOIN t2 ON (a = b AND EXISTS (SELECT * FROM t1))); + +drop table t1,t2; + +--echo # +--echo # End of 10.2 tests +--echo # + --echo # --echo # MDEV-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' --echo # failed in Item_equal::fix_fields, server crashes after 2nd execution @@ -660,6 +703,16 @@ execute stmt; drop table t1,t2; +--echo # +--echo # MDEV-28097 use-after-free when WHERE has subquery with an outer reference in HAVING +--echo # +create table t1 (a text(60) not null) engine=innodb; +insert into t1 values ('1'),('0'); +select distinct a from t1 where '' in (select 'x' like a having a like a); +drop table t1; + +--echo # --echo # End of 10.4 tests +--echo # SET GLOBAL innodb_stats_persistent = @saved_stats_persistent; diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 70add4d1740..def116c0f52 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -1263,7 +1263,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index f0c7033803c..7eb37343051 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -1266,7 +1266,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 8ff79c1790b..f2981c0c25f 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -1262,7 +1262,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 37ca0d4c030..17bec03c53d 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -1265,7 +1265,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index d4aad3e1d32..cb3620f4756 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -1262,7 +1262,7 @@ a SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` int(3) NOT NULL + `a` int(3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (a int); diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index 2d0df9a05d0..cdf9707dcbd 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -466,11 +466,11 @@ where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and t1.b=t2.b); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 -1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using where; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary Warnings: Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where `test`.`t2`.`a` = `test`.`t0`.`a` and `test`.`t1`.`a` = `test`.`t0`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b` +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where `test`.`t1`.`a` = `test`.`t0`.`a` and `test`.`t2`.`a` = `test`.`t0`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` update t1 set a=3, b=11 where a=4; update t2 set b=11 where a=3; select * from t0 where t0.a in diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index f0e8e9b4881..84317467e8a 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -477,11 +477,11 @@ where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and t1.b=t2.b); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan -1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using where; FirstMatch(t2); Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan Warnings: Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where `test`.`t2`.`a` = `test`.`t0`.`a` and `test`.`t1`.`a` = `test`.`t0`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b` +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where `test`.`t1`.`a` = `test`.`t0`.`a` and `test`.`t2`.`a` = `test`.`t0`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` update t1 set a=3, b=11 where a=4; update t2 set b=11 where a=3; # Not anymore: diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index 9b497ade58b..54286f1fa82 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -468,11 +468,11 @@ where t0.a in ( select t1.a from t1,t2 where t2.a=t0.a and t1.b=t2.b); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t0 ALL NULL NULL NULL NULL 5 100.00 Using where -1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 -1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Using where; FirstMatch(t2) +1 PRIMARY t1 ref a a 5 test.t0.a 1 100.00 Start temporary +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 100.00 Using where; End temporary Warnings: Note 1276 Field or reference 'test.t0.a' of SELECT #2 was resolved in SELECT #1 -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where `test`.`t2`.`a` = `test`.`t0`.`a` and `test`.`t1`.`a` = `test`.`t0`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b` +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t2` semi join (`test`.`t1`) join `test`.`t0` where `test`.`t1`.`a` = `test`.`t0`.`a` and `test`.`t2`.`a` = `test`.`t0`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` update t1 set a=3, b=11 where a=4; update t2 set b=11 where a=3; select * from t0 where t0.a in diff --git a/mysql-test/main/type_newdecimal.result b/mysql-test/main/type_newdecimal.result index ea2ef37cb34..a97e6b21f47 100644 --- a/mysql-test/main/type_newdecimal.result +++ b/mysql-test/main/type_newdecimal.result @@ -2456,6 +2456,30 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; # +# MDEV-25317 Assertion `scale <= precision' failed in +# decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' +# failed in decimal_bin_size_inline/decimal_bin_size. +# +SELECT AVG(DISTINCT 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001); +AVG(DISTINCT 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0.00000000000000000000000000000000000000 +CREATE TABLE t1 AS SELECT NULL AS v1; +SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) ) ; +1 +1 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '' +DROP TABLE t1; +SELECT SUM(DISTINCT 0.000000000000000000000000000000000000001); +SUM(DISTINCT 0.000000000000000000000000000000000000001) +0.00000000000000000000000000000000000000 +CREATE TABLE t1 AS SELECT 1.000000000000000000000000000000000 AS a; +ALTER TABLE t1 ADD COLUMN b INT; +SELECT ROUND (a,b) AS c FROM t1 ORDER BY c; +c +NULL +DROP TABLE t1; +# # End of 10.2 tests # # diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test index 5e4d3b4b84b..873a2ef72c8 100644 --- a/mysql-test/main/type_newdecimal.test +++ b/mysql-test/main/type_newdecimal.test @@ -1897,6 +1897,25 @@ show create table t1; drop table t1; --echo # +--echo # MDEV-25317 Assertion `scale <= precision' failed in +--echo # decimal_bin_size And Assertion `scale >= 0 && precision > 0 && scale <= precision' +--echo # failed in decimal_bin_size_inline/decimal_bin_size. +--echo # + +SELECT AVG(DISTINCT 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001); + +CREATE TABLE t1 AS SELECT NULL AS v1; +SELECT 1 FROM t1 GROUP BY v1 ORDER BY AVG ( from_unixtime ( '' ) ) ; +DROP TABLE t1; + +SELECT SUM(DISTINCT 0.000000000000000000000000000000000000001); + +CREATE TABLE t1 AS SELECT 1.000000000000000000000000000000000 AS a; +ALTER TABLE t1 ADD COLUMN b INT; +SELECT ROUND (a,b) AS c FROM t1 ORDER BY c; +DROP TABLE t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 3a5434cda59..c8be04023ea 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -4317,6 +4317,51 @@ SELECT 1 UNION SELECT a FROM t1 ORDER BY (row_number() over ()); ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION DROP TABLE t1; # +# MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM && +# item2->type() == Item::FIELD_ITEM' failed in compare_order_elements +# +CREATE TABLE t1 ( id varchar(10)); +INSERT INTO t1 values (1),(2),(3); +SELECT +dense_rank() over (ORDER BY avg(1)+3), +rank() over (ORDER BY avg(1)) +FROM t1 +GROUP BY nullif(id, 15532); +dense_rank() over (ORDER BY avg(1)+3) rank() over (ORDER BY avg(1)) +1 1 +1 1 +1 1 +SELECT +dense_rank() over (ORDER BY avg(1)), +rank() over (ORDER BY avg(1)) +FROM t1 +GROUP BY nullif(id, 15532); +dense_rank() over (ORDER BY avg(1)) rank() over (ORDER BY avg(1)) +1 1 +1 1 +1 1 +drop table t1; +CREATE TABLE t1 ( a char(25), b text); +INSERT INTO t1 VALUES ('foo','bar'); +SELECT +SUM(b) OVER (PARTITION BY a), +ROW_NUMBER() OVER (PARTITION BY b) +FROM t1 +GROUP BY +LEFT((SYSDATE()), 'foo') +WITH ROLLUP; +SUM(b) OVER (PARTITION BY a) ROW_NUMBER() OVER (PARTITION BY b) +0 1 +0 2 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +Warning 1292 Truncated incorrect INTEGER value: 'foo' +Warning 1292 Truncated incorrect INTEGER value: 'foo' +Warning 1292 Truncated incorrect DOUBLE value: 'bar' +Warning 1292 Truncated incorrect DOUBLE value: 'bar' +drop table t1; +# +# # End of 10.2 tests # # diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test index 56e7b4baf8c..d5fdd1e79f0 100644 --- a/mysql-test/main/win.test +++ b/mysql-test/main/win.test @@ -2740,6 +2740,39 @@ SELECT 1 UNION SELECT a FROM t1 ORDER BY (row_number() over ()); DROP TABLE t1; --echo # +--echo # MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM && +--echo # item2->type() == Item::FIELD_ITEM' failed in compare_order_elements +--echo # +CREATE TABLE t1 ( id varchar(10)); +INSERT INTO t1 values (1),(2),(3); + +SELECT + dense_rank() over (ORDER BY avg(1)+3), + rank() over (ORDER BY avg(1)) +FROM t1 +GROUP BY nullif(id, 15532); + +SELECT + dense_rank() over (ORDER BY avg(1)), + rank() over (ORDER BY avg(1)) +FROM t1 +GROUP BY nullif(id, 15532); +drop table t1; + +CREATE TABLE t1 ( a char(25), b text); +INSERT INTO t1 VALUES ('foo','bar'); + +SELECT + SUM(b) OVER (PARTITION BY a), + ROW_NUMBER() OVER (PARTITION BY b) +FROM t1 +GROUP BY + LEFT((SYSDATE()), 'foo') +WITH ROLLUP; +drop table t1; + +--echo # +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/win_sum.result b/mysql-test/main/win_sum.result index 66a48fe8293..71d87bd6eca 100644 --- a/mysql-test/main/win_sum.result +++ b/mysql-test/main/win_sum.result @@ -93,3 +93,15 @@ pk a c sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FO 126 6 NULL NULL 127 6 NULL NULL drop table t1; +# +# End of 10.2 tests +# +# +# MDEV-28094 Window function in expression in ORDER BY +# +SELECT EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ()); +EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ()) +1 +# +# End of 10.4 tests +# diff --git a/mysql-test/main/win_sum.test b/mysql-test/main/win_sum.test index aa4965bfd5a..640576acc53 100644 --- a/mysql-test/main/win_sum.test +++ b/mysql-test/main/win_sum.test @@ -45,3 +45,16 @@ select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDIN from t1; drop table t1; + +--echo # +--echo # End of 10.2 tests +--echo # + +--echo # +--echo # MDEV-28094 Window function in expression in ORDER BY +--echo # +SELECT EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ()); + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/suite/binlog/r/binlog_truncate_active_log.result b/mysql-test/suite/binlog/r/binlog_truncate_active_log.result index e76c3c3911b..85d37534c0b 100644 --- a/mysql-test/suite/binlog/r/binlog_truncate_active_log.result +++ b/mysql-test/suite/binlog/r/binlog_truncate_active_log.result @@ -4,11 +4,13 @@ RESET MASTER; SET @@global.sync_binlog=1; CREATE TABLE t (f INT) ENGINE=INNODB; CREATE TABLE t2 (f INT) ENGINE=INNODB; +CREATE TABLE t4 (f INT) ENGINE=INNODB; CREATE TABLE tm (f INT) ENGINE=Aria; # Case A. connect master1,localhost,root,,; connect master2,localhost,root,,; connect master3,localhost,root,,; +connect master4,localhost,root,,; connection default; INSERT INTO t VALUES (10); INSERT INTO tm VALUES (10); @@ -23,14 +25,23 @@ connection master3; SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; SELECT @@global.gtid_binlog_pos as 'Before the crash'; Before the crash -0-1-7 +0-1-8 +connection master4; +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master4_ready WAIT_FOR signal_never_arrives"; +INSERT INTO t4 VALUES (13); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master4_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash and never logged trx'; +Before the crash and never logged trx +0-1-8 connection default; # Kill the server disconnect master1; disconnect master2; disconnect master3; -# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 -FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-6/ in mysqld.1.err +disconnect master4; +# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-7/ in mysqld.1.err Pre-crash binlog file content: include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info @@ -39,6 +50,8 @@ master-bin.000001 # Query # # use `test`; CREATE TABLE t (f INT) ENGINE=INNODB master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (f INT) ENGINE=INNODB master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t4 (f INT) ENGINE=INNODB +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE tm (f INT) ENGINE=Aria master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (10) @@ -48,16 +61,20 @@ master-bin.000001 # Query # # use `test`; INSERT INTO tm VALUES (10) master-bin.000001 # Query # # COMMIT SELECT @@global.gtid_binlog_pos as 'After the crash'; After the crash -0-1-5 +0-1-6 "One row should be present in table 't'" SELECT * FROM t; f 10 +"No row should be present in table 't4'" +SELECT * FROM t4; +f DELETE FROM t; # Case B. connect master1,localhost,root,,; connect master2,localhost,root,,; connect master3,localhost,root,,; +connect master4,localhost,root,,; connection default; INSERT INTO t VALUES (10); INSERT INTO tm VALUES (10); @@ -72,14 +89,23 @@ connection master3; SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; SELECT @@global.gtid_binlog_pos as 'Before the crash'; Before the crash -0-1-10 +0-1-11 +connection master4; +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master4_ready WAIT_FOR signal_never_arrives"; +INSERT INTO t4 VALUES (13); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master4_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash and never logged trx'; +Before the crash and never logged trx +0-1-11 connection default; # Kill the server disconnect master1; disconnect master2; disconnect master3; -# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 -FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-10/ in mysqld.1.err +disconnect master4; +# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-11/ in mysqld.1.err Pre-crash binlog file content: include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info @@ -97,11 +123,14 @@ master-bin.000002 # Query # # use `test`; DELETE FROM t2 WHERE f = 0 master-bin.000002 # Query # # COMMIT SELECT @@global.gtid_binlog_pos as 'After the crash'; After the crash -0-1-9 +0-1-10 "One row should be present in table 't'" SELECT * FROM t; f 10 +"No row should be present in table 't4'" +SELECT * FROM t4; +f DELETE FROM t; # Case C. CREATE PROCEDURE sp_blank_xa() @@ -114,6 +143,7 @@ END| connect master1,localhost,root,,; connect master2,localhost,root,,; connect master3,localhost,root,,; +connect master4,localhost,root,,; connection default; INSERT INTO t VALUES (10); INSERT INTO tm VALUES (10); @@ -128,14 +158,23 @@ connection master3; SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; SELECT @@global.gtid_binlog_pos as 'Before the crash'; Before the crash -0-1-15 +0-1-16 +connection master4; +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master4_ready WAIT_FOR signal_never_arrives"; +INSERT INTO t4 VALUES (13); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master4_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash and never logged trx'; +Before the crash and never logged trx +0-1-16 connection default; # Kill the server disconnect master1; disconnect master2; disconnect master3; -# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 -FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-14/ in mysqld.1.err +disconnect master4; +# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-15/ in mysqld.1.err Pre-crash binlog file content: include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info @@ -158,11 +197,14 @@ master-bin.000003 # Query # # use `test`; INSERT INTO tm VALUES (10) master-bin.000003 # Query # # COMMIT SELECT @@global.gtid_binlog_pos as 'After the crash'; After the crash -0-1-13 +0-1-14 "One row should be present in table 't'" SELECT * FROM t; f 10 +"No row should be present in table 't4'" +SELECT * FROM t4; +f DELETE FROM t; DROP PROCEDURE sp_blank_xa; # Case D. @@ -176,6 +218,7 @@ END| connect master1,localhost,root,,; connect master2,localhost,root,,; connect master3,localhost,root,,; +connect master4,localhost,root,,; connection default; INSERT INTO t VALUES (10); INSERT INTO tm VALUES (10); @@ -190,14 +233,23 @@ connection master3; SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; SELECT @@global.gtid_binlog_pos as 'Before the crash'; Before the crash -0-1-20 +0-1-21 +connection master4; +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master4_ready WAIT_FOR signal_never_arrives"; +INSERT INTO t4 VALUES (13); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master4_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash and never logged trx'; +Before the crash and never logged trx +0-1-21 connection default; # Kill the server disconnect master1; disconnect master2; disconnect master3; -# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 -FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-20/ in mysqld.1.err +disconnect master4; +# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-21/ in mysqld.1.err Pre-crash binlog file content: include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info @@ -226,11 +278,14 @@ master-bin.000004 # Query # # XA END X'786964',X'',1 master-bin.000004 # XA_prepare # # XA PREPARE X'786964',X'',1 SELECT @@global.gtid_binlog_pos as 'After the crash'; After the crash -0-1-19 +0-1-20 "One row should be present in table 't'" SELECT * FROM t; f 10 +"No row should be present in table 't4'" +SELECT * FROM t4; +f DELETE FROM t; DROP PROCEDURE sp_xa; # Cleanup diff --git a/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result b/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result index ae292c04c32..271e3c50b19 100644 --- a/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result +++ b/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result @@ -22,6 +22,11 @@ SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master2_ready WAIT INSERT INTO ti VALUES (3, "not gonna survive"); connection default; SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +connect master3,localhost,root,,; +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master3_ready WAIT_FOR master3_go_never_arrives"; +INSERT INTO ti VALUES (4, "not gonna be log therefore survive"),(5, "ditto"); +connection default; +SET DEBUG_SYNC= "now WAIT_FOR master3_ready"; "List of binary logs before crash" show binary logs; Log_name File_size @@ -36,7 +41,8 @@ connection default; # Kill the server disconnect master1; disconnect master2; -# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 +disconnect master3; +# restart: --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 FOUND 1 /truncated binlog file:.*master.*000002/ in mysqld.1.err "One record should be present in table" SELECT * FROM ti; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test index d73e453ce96..b6a95c2c9be 100644 --- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test @@ -43,10 +43,7 @@ DROP TABLE t1; set @@SESSION.SQL_LOG_BIN = 1; --echo # Step-3: Execute MYSQL_BINLOG with --stop-never and source it to mysql client. ---write_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh -(`$MYSQL_BINLOG --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT`) < /dev/null > /dev/null 2>&1 & -EOF ---exec /bin/bash $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh +--exec ($MYSQL_BINLOG --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT) < /dev/null > /dev/null 2>&1 & --echo # Step-4: Wait till dump thread transfer is completed. let $wait_condition= SELECT id from information_schema.processlist where processlist.command like '%Binlog%' and state like '%Master has sent%'; @@ -62,5 +59,3 @@ source include/wait_until_rows_count.inc; --source include/stop_dump_threads.inc DROP TABLE t1; ---remove_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh - diff --git a/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc b/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc index 75a8310c220..68ac752725e 100644 --- a/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc +++ b/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc @@ -1,6 +1,7 @@ connect(master1,localhost,root,,); connect(master2,localhost,root,,); connect(master3,localhost,root,,); +connect(master4,localhost,root,,); --connection default @@ -22,16 +23,26 @@ SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master2_ready"; SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; SELECT @@global.gtid_binlog_pos as 'Before the crash'; +--connection master4 +# Simulate prepared & not-logged trx; it will never recover. +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master4_ready WAIT_FOR signal_never_arrives"; +--send INSERT INTO t4 VALUES (13) + +--connection master3 +SET DEBUG_SYNC= "now WAIT_FOR master4_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash and never logged trx'; + --connection default --source include/kill_mysqld.inc --disconnect master1 --disconnect master2 --disconnect master3 +--disconnect master4 # # Server restart # ---let $restart_parameters= --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 +--let $restart_parameters= --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 --source include/start_mysqld.inc # Check error log for a successful truncate message. @@ -49,6 +60,8 @@ SELECT @@global.gtid_binlog_pos as 'Before the crash'; SELECT @@global.gtid_binlog_pos as 'After the crash'; --echo "One row should be present in table 't'" SELECT * FROM t; +--echo "No row should be present in table 't4'" +SELECT * FROM t4; # prepare binlog file index for the next test --inc $binlog_file_index diff --git a/mysql-test/suite/binlog/t/binlog_truncate_active_log.test b/mysql-test/suite/binlog/t/binlog_truncate_active_log.test index 920679e99e9..7c63a853da6 100644 --- a/mysql-test/suite/binlog/t/binlog_truncate_active_log.test +++ b/mysql-test/suite/binlog/t/binlog_truncate_active_log.test @@ -25,6 +25,7 @@ RESET MASTER; SET @@global.sync_binlog=1; CREATE TABLE t (f INT) ENGINE=INNODB; CREATE TABLE t2 (f INT) ENGINE=INNODB; +CREATE TABLE t4 (f INT) ENGINE=INNODB; CREATE TABLE tm (f INT) ENGINE=Aria; # Old (pre-crash) binlog file index initial value. @@ -42,14 +43,14 @@ CREATE TABLE tm (f INT) ENGINE=Aria; # 'query1' onwards will be removed from the binary log. # Show-binlog-events is to prove that. ---let $truncate_gtid_pos = 0-1-6 +--let $truncate_gtid_pos = 0-1-7 --let $query1 = INSERT INTO t VALUES (20) --let $query2 = DELETE FROM t2 WHERE f = 0 /* no such record */ --source binlog_truncate_active_log.inc --echo # Case B. # The inverted sequence ends up to truncate starting from $query2 ---let $truncate_gtid_pos = 0-1-10 +--let $truncate_gtid_pos = 0-1-11 --let $query1 = DELETE FROM t2 WHERE f = 0 --let $query2 = INSERT INTO t VALUES (20) --source binlog_truncate_active_log.inc @@ -68,7 +69,7 @@ delimiter ;| # The same as in A with $query2 being the zero-engine XA transaction. # Both $query1 and $query2 are going to be truncated. ---let $truncate_gtid_pos = 0-1-14 +--let $truncate_gtid_pos = 0-1-15 --let $query1 = INSERT INTO t VALUES (20) --let $query2 = CALL sp_blank_xa --source binlog_truncate_active_log.inc @@ -89,7 +90,7 @@ delimiter ;| # The same as in B with $query1 being the prepared XA transaction. # Truncation must occurs at $query2. ---let $truncate_gtid_pos = 0-1-20 +--let $truncate_gtid_pos = 0-1-21 --let $query1 = CALL sp_xa --let $query2 = INSERT INTO t2 VALUES (20) --source binlog_truncate_active_log.inc diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test b/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test index a7068885871..079c79b2984 100644 --- a/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test +++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test @@ -40,6 +40,15 @@ SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master2_ready WAIT --connection default SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; + +connect(master3,localhost,root,,); +# The 3nd trx for recovery, it won't get into binlog nor therefore recover +SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL master3_ready WAIT_FOR master3_go_never_arrives"; +--send INSERT INTO ti VALUES (4, "not gonna be log therefore survive"),(5, "ditto") + +--connection default +SET DEBUG_SYNC= "now WAIT_FOR master3_ready"; + --echo "List of binary logs before crash" --source include/show_binary_logs.inc --echo # The gtid binlog state prior the crash will be truncated at the end of the test @@ -49,11 +58,12 @@ SELECT @@global.gtid_binlog_state; --source include/kill_mysqld.inc --disconnect master1 --disconnect master2 +--disconnect master3 # # Server restart # ---let $restart_parameters= --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 +--let $restart_parameters= --rpl-semi-sync-slave-enabled=1 --sync-binlog=1 --log-warnings=3 --source include/start_mysqld.inc # Check error log for a successful truncate message. diff --git a/mysql-test/suite/binlog_encryption/rpl_parallel_deadlock_corrupt_binlog.result b/mysql-test/suite/binlog_encryption/rpl_parallel_deadlock_corrupt_binlog.result index 74d1d53b67c..f3203cfe8e6 100644 --- a/mysql-test/suite/binlog_encryption/rpl_parallel_deadlock_corrupt_binlog.result +++ b/mysql-test/suite/binlog_encryption/rpl_parallel_deadlock_corrupt_binlog.result @@ -15,6 +15,7 @@ include/stop_slave.inc SET GLOBAL slave_parallel_threads=1; SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +CALL mtr.add_suppression("Unexpected break of being relay-logged GTID"); connection server_1; INSERT INTO t2 VALUES (101); INSERT INTO t2 VALUES (102); diff --git a/mysql-test/suite/binlog_encryption/rpl_ssl.result b/mysql-test/suite/binlog_encryption/rpl_ssl.result index 0b3a6cd0eca..ce9e4d486cf 100644 --- a/mysql-test/suite/binlog_encryption/rpl_ssl.result +++ b/mysql-test/suite/binlog_encryption/rpl_ssl.result @@ -23,6 +23,8 @@ t Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc @@ -37,6 +39,8 @@ include/wait_for_slave_to_start.inc Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc diff --git a/mysql-test/suite/compat/oracle/r/events.result b/mysql-test/suite/compat/oracle/r/events.result index ef9c50115ae..1f62e2e5ee2 100644 --- a/mysql-test/suite/compat/oracle/r/events.result +++ b/mysql-test/suite/compat/oracle/r/events.result @@ -16,3 +16,12 @@ COUNT(*) 1 DROP TABLE t1; SET GLOBAL event_scheduler=off; +# +# MDEV-28588 SIGSEGV in __memmove_avx_unaligned_erms, strmake_root +# +CREATE EVENT ev ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO BEGIN END; +Warnings: +Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. +SELECT EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='test' AND EVENT_NAME='ev'; +EVENT_DEFINITION BEGIN END +DROP EVENT ev; diff --git a/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result b/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result index 21bead42b0a..24211c6318e 100644 --- a/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result +++ b/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result @@ -45,6 +45,8 @@ $$ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; /*!50003 DROP PROCEDURE IF EXISTS `p1` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -52,8 +54,6 @@ $$ /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; DELIMITER ;; CREATE DEFINER="root"@"localhost" PROCEDURE "p1"() AS @@ -65,6 +65,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; /*!50003 DROP PACKAGE IF EXISTS `pkg1` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72,8 +74,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; DELIMITER ;; CREATE DEFINER="root"@"localhost" PACKAGE "pkg1" AS PROCEDURE p1; @@ -84,6 +84,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; /*!50003 DROP PACKAGE IF EXISTS `pkg2` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -91,8 +93,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; DELIMITER ;; CREATE DEFINER="root"@"localhost" PACKAGE "pkg2" AS PROCEDURE p1; @@ -103,6 +103,8 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; /*!50003 DROP PACKAGE BODY IF EXISTS `pkg1` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -110,8 +112,6 @@ DELIMITER ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER,SIMULTANEOUS_ASSIGNMENT' */ ; DELIMITER ;; CREATE DEFINER="root"@"localhost" PACKAGE BODY "pkg1" AS PROCEDURE p1 AS diff --git a/mysql-test/suite/compat/oracle/r/sp.result b/mysql-test/suite/compat/oracle/r/sp.result index a9a97769333..44092c0be30 100644 --- a/mysql-test/suite/compat/oracle/r/sp.result +++ b/mysql-test/suite/compat/oracle/r/sp.result @@ -2549,7 +2549,18 @@ idx 1 DROP PROCEDURE p1; # -# Start of 10.4 tests +# MDEV-28588 SIGSEGV in __memmove_avx_unaligned_erms, strmake_root +# +SET sql_mode=ORACLE; +BEGIN END; +CREATE TABLE t1 (a INT); +CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW BEGIN END; +SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA='test' AND TRIGGER_NAME='tr'; +ACTION_STATEMENT BEGIN END +DROP TRIGGER tr; +DROP TABLE t1; +# +# End of 10.3 tests # # # MDEV-19637 Crash on an SP variable assignment to a wrong subselect diff --git a/mysql-test/suite/compat/oracle/t/events.test b/mysql-test/suite/compat/oracle/t/events.test index e898528636a..fb56af51d87 100644 --- a/mysql-test/suite/compat/oracle/t/events.test +++ b/mysql-test/suite/compat/oracle/t/events.test @@ -25,5 +25,13 @@ let $wait_condition = SELECT COUNT(*) FROM t1; DROP TABLE t1; - SET GLOBAL event_scheduler=off; + +--echo # +--echo # MDEV-28588 SIGSEGV in __memmove_avx_unaligned_erms, strmake_root +--echo # +CREATE EVENT ev ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO BEGIN END; +--vertical_results +SELECT EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='test' AND EVENT_NAME='ev'; +--horizontal_results +DROP EVENT ev; diff --git a/mysql-test/suite/compat/oracle/t/sp.test b/mysql-test/suite/compat/oracle/t/sp.test index 99bdc7166e0..69b8608b19a 100644 --- a/mysql-test/suite/compat/oracle/t/sp.test +++ b/mysql-test/suite/compat/oracle/t/sp.test @@ -2392,9 +2392,23 @@ DROP PROCEDURE p1; --echo # ---echo # Start of 10.4 tests +--echo # MDEV-28588 SIGSEGV in __memmove_avx_unaligned_erms, strmake_root --echo # +SET sql_mode=ORACLE; +BEGIN END; + +CREATE TABLE t1 (a INT); +CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW BEGIN END; +--vertical_results +SELECT ACTION_STATEMENT FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA='test' AND TRIGGER_NAME='tr'; +--horizontal_results +DROP TRIGGER tr; +DROP TABLE t1; + +--echo # +--echo # End of 10.3 tests +--echo # --echo # --echo # MDEV-19637 Crash on an SP variable assignment to a wrong subselect diff --git a/mysql-test/suite/encryption/r/innodb_encrypt_key_rotation_age.result b/mysql-test/suite/encryption/r/innodb_encrypt_key_rotation_age.result index be5a4c3f8ac..3dfa449daf8 100644 --- a/mysql-test/suite/encryption/r/innodb_encrypt_key_rotation_age.result +++ b/mysql-test/suite/encryption/r/innodb_encrypt_key_rotation_age.result @@ -67,13 +67,13 @@ test/t2 test/t3 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME -innodb_system -mysql/innodb_table_stats -mysql/innodb_index_stats -mysql/transaction_registry test/t4 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; NAME +innodb_system +mysql/innodb_index_stats +mysql/innodb_table_stats +mysql/transaction_registry test/t1 test/t2 test/t3 diff --git a/mysql-test/suite/encryption/r/innodb_encryption.result b/mysql-test/suite/encryption/r/innodb_encryption.result index a073a438942..3b1552be4be 100644 --- a/mysql-test/suite/encryption/r/innodb_encryption.result +++ b/mysql-test/suite/encryption/r/innodb_encryption.result @@ -66,7 +66,7 @@ innodb_encryption_threads 0 SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats' AND NAME NOT LIKE 'mysql/transaction_registry'; NAME +innodb_system SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats' AND NAME NOT LIKE 'mysql/transaction_registry'; NAME -innodb_system diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index f68aaf9d10c..87f36345027 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -4323,6 +4323,51 @@ SELECT 1 UNION SELECT a FROM t1 ORDER BY (row_number() over ()); ERROR HY000: Expression #1 of ORDER BY contains aggregate function and applies to a UNION DROP TABLE t1; # +# MDEV-19398: Assertion `item1->type() == Item::FIELD_ITEM && +# item2->type() == Item::FIELD_ITEM' failed in compare_order_elements +# +CREATE TABLE t1 ( id varchar(10)); +INSERT INTO t1 values (1),(2),(3); +SELECT +dense_rank() over (ORDER BY avg(1)+3), +rank() over (ORDER BY avg(1)) +FROM t1 +GROUP BY nullif(id, 15532); +dense_rank() over (ORDER BY avg(1)+3) rank() over (ORDER BY avg(1)) +1 1 +1 1 +1 1 +SELECT +dense_rank() over (ORDER BY avg(1)), +rank() over (ORDER BY avg(1)) +FROM t1 +GROUP BY nullif(id, 15532); +dense_rank() over (ORDER BY avg(1)) rank() over (ORDER BY avg(1)) +1 1 +1 1 +1 1 +drop table t1; +CREATE TABLE t1 ( a char(25), b text); +INSERT INTO t1 VALUES ('foo','bar'); +SELECT +SUM(b) OVER (PARTITION BY a), +ROW_NUMBER() OVER (PARTITION BY b) +FROM t1 +GROUP BY +LEFT((SYSDATE()), 'foo') +WITH ROLLUP; +SUM(b) OVER (PARTITION BY a) ROW_NUMBER() OVER (PARTITION BY b) +0 1 +0 2 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +Warning 1292 Truncated incorrect INTEGER value: 'foo' +Warning 1292 Truncated incorrect INTEGER value: 'foo' +Warning 1292 Truncated incorrect DOUBLE value: 'bar' +Warning 1292 Truncated incorrect DOUBLE value: 'bar' +drop table t1; +# +# # End of 10.2 tests # # diff --git a/mysql-test/suite/encryption/t/innodb_encryption.test b/mysql-test/suite/encryption/t/innodb_encryption.test index 7c28b42fdc7..2b0b2b8d7fb 100644 --- a/mysql-test/suite/encryption/t/innodb_encryption.test +++ b/mysql-test/suite/encryption/t/innodb_encryption.test @@ -90,9 +90,6 @@ AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats' AND NA SHOW VARIABLES LIKE 'innodb_encrypt%'; ---let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; ---source include/wait_condition.inc - --sorted_result SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 AND NAME NOT LIKE 'innodb_undo%' AND NAME NOT LIKE 'mysql/innodb_%_stats' AND NAME NOT LIKE 'mysql/transaction_registry'; diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index db78d9a77c2..35e8a3c725e 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -12,8 +12,6 @@ GCF-1081 : MDEV-18283 Galera test failure on galera.GCF-1081 GCF-939 : MDEV-21520 galera.GCF-939 -MW-328A : MDEV-22666 galera.MW-328A MTR failed: "Semaphore wait has lasted > 600 seconds" and do not release port 16002 -MW-328B : MDEV-22666 galera.MW-328A MTR failed: "Semaphore wait has lasted > 600 seconds" and do not release port 16002 MW-329 : MDEV-19962 Galera test failure on MW-329 galera_as_slave_ctas : MDEV-28378 timeout galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event() @@ -21,10 +19,8 @@ galera_bf_abort_group_commit : MDEV-18282 Galera test failure on galera.galera_b galera_bf_kill_debug : MDEV-24485 wsrep::client_state::do_acquire_ownership(): Assertion `state_ == s_idle || mode_ != m_local' failed galera_bf_lock_wait : MDEV-21597 wsrep::transaction::start_transaction(): Assertion `active() == false' failed galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files -galera_ftwrl : MDEV-21525 galera.galera_ftwrl galera_gcache_recover_manytrx : MDEV-18834 Galera test failure galera_kill_largechanges : MDEV-18179 Galera test failure on galera.galera_kill_largechanges -galera_many_tables_nopk : MDEV-18182 Galera test failure on galera.galera_many_tables_nopk galera_mdl_race : MDEV-21524 galera.galera_mdl_race galera_parallel_simple : MDEV-20318 galera.galera_parallel_simple fails galera_pc_ignore_sb : MDEV-20888 galera.galera_pc_ignore_sb diff --git a/mysql-test/suite/galera/r/MDEV-26575.result b/mysql-test/suite/galera/r/MDEV-26575.result index b8d5d431aaa..5b447e1ae20 100644 --- a/mysql-test/suite/galera/r/MDEV-26575.result +++ b/mysql-test/suite/galera/r/MDEV-26575.result @@ -1,5 +1,8 @@ connection node_2; connection node_1; +connection node_2; +call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*"); +connection node_1; connection node_1; connection node_2; connection node_2; diff --git a/mysql-test/suite/galera/r/MDEV-28053.result b/mysql-test/suite/galera/r/MDEV-28053.result new file mode 100644 index 00000000000..b3f93688dd0 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-28053.result @@ -0,0 +1,14 @@ +connection node_2; +connection node_1; +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +connection node_2; +connection node_3; +DROP TABLE t1; +connection node_2; +connection node_2; +STOP SLAVE; +RESET SLAVE ALL; +connection node_3; +RESET MASTER; diff --git a/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result b/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result index f6f0803227f..71eeb6861ea 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_at_after_statement.result @@ -12,6 +12,8 @@ connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; SET DEBUG_SYNC = 'now WAIT_FOR blocked'; connection node_1; UPDATE t1 SET val=3 WHERE id=1; +connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2; +set session wsrep_sync_wait=0; connection node_2a; SET DEBUG_SYNC = 'now SIGNAL continue'; connection node_2; @@ -21,3 +23,5 @@ SET DEBUG_SYNC = 'RESET'; connection node_1; SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; +disconnect node_2a; +disconnect node_2b; diff --git a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result index 8d0734f9df8..4fe33674701 100644 --- a/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result +++ b/mysql-test/suite/galera/r/galera_binlog_stmt_autoinc.result @@ -1,33 +1,44 @@ connection node_2; connection node_1; connection node_1; +SET GLOBAL auto_increment_offset=1; +connection node_2; +SET GLOBAL auto_increment_offset=2; +connection node_1; connection node_2; connection node_2; SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; connection node_1; SET GLOBAL wsrep_forced_binlog_format='STATEMENT'; CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) +i int(11) NOT NULL primary key AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 1 insert into t1(i) values(null); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave -select * from t1; +select * from t1 order by i; i c 1 dummy_text insert into t1(i) values(null), (null), (null); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave -select * from t1; +select * from t1 order by i; i c 1 dummy_text 3 dummy_text 5 dummy_text 7 dummy_text connection node_2; -select * from t1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 2 +select * from t1 order by i; i c 1 dummy_text 3 dummy_text @@ -45,27 +56,34 @@ SET GLOBAL wsrep_auto_increment_control='OFF'; SET SESSION auto_increment_increment = 3; SET SESSION auto_increment_offset = 1; CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) +i int(11) NOT NULL primary key AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 3 +auto_increment_offset 1 insert into t1(i) values(null); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave -select * from t1; +select * from t1 order by i; i c 1 dummy_text insert into t1(i) values(null), (null), (null); Warnings: Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave -select * from t1; +select * from t1 order by i; i c 1 dummy_text 4 dummy_text 7 dummy_text 10 dummy_text connection node_2; -select * from t1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 2 +select * from t1 order by i; i c 1 dummy_text 4 dummy_text @@ -74,6 +92,7 @@ i c connection node_1; SET GLOBAL wsrep_auto_increment_control='ON'; SET SESSION binlog_format='ROW'; +connection node_1; show variables like 'binlog_format'; Variable_name Value binlog_format ROW @@ -89,29 +108,37 @@ auto_increment_increment 3 auto_increment_offset 1 wsrep_auto_increment_control OFF SET GLOBAL wsrep_auto_increment_control='ON'; +connection node_1; drop table t1; connection node_2; SET GLOBAL wsrep_forced_binlog_format='ROW'; connection node_1; SET GLOBAL wsrep_forced_binlog_format='ROW'; CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) +i int(11) NOT NULL primary key AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 1 insert into t1(i) values(null); -select * from t1; +select * from t1 order by i; i c 1 dummy_text insert into t1(i) values(null), (null), (null); -select * from t1; +select * from t1 order by i; i c 1 dummy_text 3 dummy_text 5 dummy_text 7 dummy_text connection node_2; -select * from t1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 2 +select * from t1 order by i; i c 1 dummy_text 3 dummy_text @@ -129,23 +156,30 @@ SET GLOBAL wsrep_auto_increment_control='OFF'; SET SESSION auto_increment_increment = 3; SET SESSION auto_increment_offset = 1; CREATE TABLE t1 ( -i int(11) NOT NULL AUTO_INCREMENT, -c char(32) DEFAULT 'dummy_text', -PRIMARY KEY (i) +i int(11) NOT NULL primary key AUTO_INCREMENT, +c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 3 +auto_increment_offset 1 insert into t1(i) values(null); -select * from t1; +select * from t1 order by i; i c 1 dummy_text insert into t1(i) values(null), (null), (null); -select * from t1; +select * from t1 order by i; i c 1 dummy_text 4 dummy_text 7 dummy_text 10 dummy_text connection node_2; -select * from t1; +show variables like 'auto_increment%'; +Variable_name Value +auto_increment_increment 2 +auto_increment_offset 2 +select * from t1 order by i; i c 1 dummy_text 4 dummy_text @@ -159,13 +193,13 @@ binlog_format ROW show variables like '%auto_increment%'; Variable_name Value auto_increment_increment 2 -auto_increment_offset 1 +auto_increment_offset 2 wsrep_auto_increment_control ON SET GLOBAL wsrep_auto_increment_control='OFF'; show variables like '%auto_increment%'; Variable_name Value -auto_increment_increment 3 -auto_increment_offset 1 +auto_increment_increment 1 +auto_increment_offset 2 wsrep_auto_increment_control OFF SET GLOBAL wsrep_auto_increment_control='ON'; drop table t1; diff --git a/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff new file mode 100644 index 00000000000..8c84321e774 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_MDEV-28423,debug.rdiff @@ -0,0 +1,190 @@ +--- r/galera_ist_MDEV-28423.result ++++ r/galera_ist_MDEV-28423,debug.reject +@@ -517,3 +517,187 @@ + 1 + DROP TABLE t1; + COMMIT; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++connection node_1; ++CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES (1,'node1_committed_before'); ++INSERT INTO t1 VALUES (2,'node1_committed_before'); ++INSERT INTO t1 VALUES (3,'node1_committed_before'); ++INSERT INTO t1 VALUES (4,'node1_committed_before'); ++INSERT INTO t1 VALUES (5,'node1_committed_before'); ++connection node_2; ++START TRANSACTION; ++INSERT INTO t1 VALUES (6,'node2_committed_before'); ++INSERT INTO t1 VALUES (7,'node2_committed_before'); ++INSERT INTO t1 VALUES (8,'node2_committed_before'); ++INSERT INTO t1 VALUES (9,'node2_committed_before'); ++INSERT INTO t1 VALUES (10,'node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++connection node_1; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++connection node_2; ++SET wsrep_sync_wait = 0; ++Killing server ... ++connection node_1; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (11,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (12,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (13,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (14,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (15,'node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (16,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (17,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (18,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (19,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (20,'node1_to_be_committed_after'); ++connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (21,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (22,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (23,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (24,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (25,'node1_to_be_rollbacked_after'); ++connection node_2; ++Performing --wsrep-recover ... ++connection node_2; ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (26,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (27,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (28,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (29,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (30,'node2_committed_after'); ++COMMIT; ++connection node_1; ++INSERT INTO t1 (id,f1) VALUES (31,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (32,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (33,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (34,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (35,'node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (36,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (37,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (38,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (39,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (40,'node1_committed_after'); ++COMMIT; ++connection node_1a_galera_st_kill_slave_ddl; ++INSERT INTO t1 (id,f1) VALUES (41,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (42,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (43,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (44,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (45,'node1_to_be_rollbacked_after'); ++ROLLBACK; ++SET AUTOCOMMIT=ON; ++SET SESSION wsrep_sync_wait=15; ++SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++EXPECT_3 ++3 ++SELECT COUNT(*) AS EXPECT_35 FROM t1; ++EXPECT_35 ++35 ++SELECT * FROM t1; ++id f1 f2 ++1 node1_committed_before NULL ++2 node1_committed_before NULL ++3 node1_committed_before NULL ++4 node1_committed_before NULL ++5 node1_committed_before NULL ++6 node2_committed_before NULL ++7 node2_committed_before NULL ++8 node2_committed_before NULL ++9 node2_committed_before NULL ++10 node2_committed_before NULL ++11 node1_committed_during NULL ++12 node1_committed_during NULL ++13 node1_committed_during NULL ++14 node1_committed_during NULL ++15 node1_committed_during NULL ++16 node1_to_be_committed_after NULL ++17 node1_to_be_committed_after NULL ++18 node1_to_be_committed_after NULL ++19 node1_to_be_committed_after NULL ++20 node1_to_be_committed_after NULL ++26 node2_committed_after NULL ++27 node2_committed_after NULL ++28 node2_committed_after NULL ++29 node2_committed_after NULL ++30 node2_committed_after NULL ++31 node1_to_be_committed_after NULL ++32 node1_to_be_committed_after NULL ++33 node1_to_be_committed_after NULL ++34 node1_to_be_committed_after NULL ++35 node1_to_be_committed_after NULL ++36 node1_committed_after NULL ++37 node1_committed_after NULL ++38 node1_committed_after NULL ++39 node1_committed_after NULL ++40 node1_committed_after NULL ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++connection node_1; ++SET AUTOCOMMIT=ON; ++SET SESSION wsrep_sync_wait=15; ++SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++EXPECT_3 ++3 ++SELECT COUNT(*) AS EXPECT_35 FROM t1; ++EXPECT_35 ++35 ++SELECT * FROM t1; ++id f1 f2 ++1 node1_committed_before NULL ++2 node1_committed_before NULL ++3 node1_committed_before NULL ++4 node1_committed_before NULL ++5 node1_committed_before NULL ++6 node2_committed_before NULL ++7 node2_committed_before NULL ++8 node2_committed_before NULL ++9 node2_committed_before NULL ++10 node2_committed_before NULL ++11 node1_committed_during NULL ++12 node1_committed_during NULL ++13 node1_committed_during NULL ++14 node1_committed_during NULL ++15 node1_committed_during NULL ++16 node1_to_be_committed_after NULL ++17 node1_to_be_committed_after NULL ++18 node1_to_be_committed_after NULL ++19 node1_to_be_committed_after NULL ++20 node1_to_be_committed_after NULL ++26 node2_committed_after NULL ++27 node2_committed_after NULL ++28 node2_committed_after NULL ++29 node2_committed_after NULL ++30 node2_committed_after NULL ++31 node1_to_be_committed_after NULL ++32 node1_to_be_committed_after NULL ++33 node1_to_be_committed_after NULL ++34 node1_to_be_committed_after NULL ++35 node1_to_be_committed_after NULL ++36 node1_committed_after NULL ++37 node1_committed_after NULL ++38 node1_committed_after NULL ++39 node1_committed_after NULL ++40 node1_committed_after NULL ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_ist_MDEV-28423.result b/mysql-test/suite/galera/r/galera_ist_MDEV-28423.result new file mode 100644 index 00000000000..5a71b490a80 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_MDEV-28423.result @@ -0,0 +1,519 @@ +connection node_2; +connection node_1; +connection node_1; +connection node_2; +Performing State Transfer on a server that has been temporarily disconnected +connection node_1; +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; +Unloading wsrep provider ... +SET GLOBAL wsrep_cluster_address = ''; +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); +connect node_1a_galera_st_disconnect_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); +connection node_2; +Loading wsrep provider ... +disconnect node_2; +connect node_2, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; +connection node_1a_galera_st_disconnect_slave; +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +connection node_1; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +Performing State Transfer on a server that has been shut down cleanly and restarted +connection node_1; +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; +Shutting down server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); +connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); +connection node_2; +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; +connection node_1a_galera_st_shutdown_slave; +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +connection node_1; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +Performing State Transfer on a server that has been killed and restarted +connection node_1; +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; +Killing server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); +connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); +connection node_2; +Performing --wsrep-recover ... +Starting server ... +Using --wsrep-start-position when starting mysqld ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; +connection node_1a_galera_st_kill_slave; +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (46,'node1_to_be_rollbacked_after'); +ROLLBACK; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +connection node_1; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; diff --git a/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff b/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff new file mode 100644 index 00000000000..51d2a6bf157 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_MDEV-28583,debug.rdiff @@ -0,0 +1,190 @@ +--- r/galera_ist_MDEV-28583.result ++++ r/galera_ist_MDEV-28583,debug.reject +@@ -517,3 +517,187 @@ + 1 + DROP TABLE t1; + COMMIT; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++connection node_1; ++CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES (1,'node1_committed_before'); ++INSERT INTO t1 VALUES (2,'node1_committed_before'); ++INSERT INTO t1 VALUES (3,'node1_committed_before'); ++INSERT INTO t1 VALUES (4,'node1_committed_before'); ++INSERT INTO t1 VALUES (5,'node1_committed_before'); ++connection node_2; ++START TRANSACTION; ++INSERT INTO t1 VALUES (6,'node2_committed_before'); ++INSERT INTO t1 VALUES (7,'node2_committed_before'); ++INSERT INTO t1 VALUES (8,'node2_committed_before'); ++INSERT INTO t1 VALUES (9,'node2_committed_before'); ++INSERT INTO t1 VALUES (10,'node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++connection node_1; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++connection node_2; ++SET wsrep_sync_wait = 0; ++Killing server ... ++connection node_1; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (11,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (12,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (13,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (14,'node1_committed_during'); ++INSERT INTO t1 (id,f1) VALUES (15,'node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (16,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (17,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (18,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (19,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (20,'node1_to_be_committed_after'); ++connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (21,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (22,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (23,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (24,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (25,'node1_to_be_rollbacked_after'); ++connection node_2; ++Performing --wsrep-recover ... ++connection node_2; ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (26,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (27,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (28,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (29,'node2_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (30,'node2_committed_after'); ++COMMIT; ++connection node_1; ++INSERT INTO t1 (id,f1) VALUES (31,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (32,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (33,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (34,'node1_to_be_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (35,'node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (id,f1) VALUES (36,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (37,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (38,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (39,'node1_committed_after'); ++INSERT INTO t1 (id,f1) VALUES (40,'node1_committed_after'); ++COMMIT; ++connection node_1a_galera_st_kill_slave_ddl; ++INSERT INTO t1 (id,f1) VALUES (41,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (42,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (43,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (44,'node1_to_be_rollbacked_after'); ++INSERT INTO t1 (id,f1) VALUES (45,'node1_to_be_rollbacked_after'); ++ROLLBACK; ++SET AUTOCOMMIT=ON; ++SET SESSION wsrep_sync_wait=15; ++SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++EXPECT_3 ++3 ++SELECT COUNT(*) AS EXPECT_35 FROM t1; ++EXPECT_35 ++35 ++SELECT * FROM t1; ++id f1 f2 ++1 node1_committed_before NULL ++2 node1_committed_before NULL ++3 node1_committed_before NULL ++4 node1_committed_before NULL ++5 node1_committed_before NULL ++6 node2_committed_before NULL ++7 node2_committed_before NULL ++8 node2_committed_before NULL ++9 node2_committed_before NULL ++10 node2_committed_before NULL ++11 node1_committed_during NULL ++12 node1_committed_during NULL ++13 node1_committed_during NULL ++14 node1_committed_during NULL ++15 node1_committed_during NULL ++16 node1_to_be_committed_after NULL ++17 node1_to_be_committed_after NULL ++18 node1_to_be_committed_after NULL ++19 node1_to_be_committed_after NULL ++20 node1_to_be_committed_after NULL ++26 node2_committed_after NULL ++27 node2_committed_after NULL ++28 node2_committed_after NULL ++29 node2_committed_after NULL ++30 node2_committed_after NULL ++31 node1_to_be_committed_after NULL ++32 node1_to_be_committed_after NULL ++33 node1_to_be_committed_after NULL ++34 node1_to_be_committed_after NULL ++35 node1_to_be_committed_after NULL ++36 node1_committed_after NULL ++37 node1_committed_after NULL ++38 node1_committed_after NULL ++39 node1_committed_after NULL ++40 node1_committed_after NULL ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++connection node_1; ++SET AUTOCOMMIT=ON; ++SET SESSION wsrep_sync_wait=15; ++SELECT COUNT(*) AS EXPECT_3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++EXPECT_3 ++3 ++SELECT COUNT(*) AS EXPECT_35 FROM t1; ++EXPECT_35 ++35 ++SELECT * FROM t1; ++id f1 f2 ++1 node1_committed_before NULL ++2 node1_committed_before NULL ++3 node1_committed_before NULL ++4 node1_committed_before NULL ++5 node1_committed_before NULL ++6 node2_committed_before NULL ++7 node2_committed_before NULL ++8 node2_committed_before NULL ++9 node2_committed_before NULL ++10 node2_committed_before NULL ++11 node1_committed_during NULL ++12 node1_committed_during NULL ++13 node1_committed_during NULL ++14 node1_committed_during NULL ++15 node1_committed_during NULL ++16 node1_to_be_committed_after NULL ++17 node1_to_be_committed_after NULL ++18 node1_to_be_committed_after NULL ++19 node1_to_be_committed_after NULL ++20 node1_to_be_committed_after NULL ++26 node2_committed_after NULL ++27 node2_committed_after NULL ++28 node2_committed_after NULL ++29 node2_committed_after NULL ++30 node2_committed_after NULL ++31 node1_to_be_committed_after NULL ++32 node1_to_be_committed_after NULL ++33 node1_to_be_committed_after NULL ++34 node1_to_be_committed_after NULL ++35 node1_to_be_committed_after NULL ++36 node1_committed_after NULL ++37 node1_committed_after NULL ++38 node1_committed_after NULL ++39 node1_committed_after NULL ++40 node1_committed_after NULL ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET GLOBAL debug_dbug = $debug_orig; diff --git a/mysql-test/suite/galera/r/galera_ist_MDEV-28583.result b/mysql-test/suite/galera/r/galera_ist_MDEV-28583.result new file mode 100644 index 00000000000..5a71b490a80 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_ist_MDEV-28583.result @@ -0,0 +1,519 @@ +connection node_2; +connection node_1; +connection node_1; +connection node_2; +Performing State Transfer on a server that has been temporarily disconnected +connection node_1; +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; +Unloading wsrep provider ... +SET GLOBAL wsrep_cluster_address = ''; +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); +connect node_1a_galera_st_disconnect_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); +connection node_2; +Loading wsrep provider ... +disconnect node_2; +connect node_2, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; +connection node_1a_galera_st_disconnect_slave; +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +connection node_1; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +Performing State Transfer on a server that has been shut down cleanly and restarted +connection node_1; +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; +Shutting down server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); +connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); +connection node_2; +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; +connection node_1a_galera_st_shutdown_slave; +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +ROLLBACK; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +connection node_1; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +Performing State Transfer on a server that has been killed and restarted +connection node_1; +CREATE TABLE t1 (id int not null primary key,f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'node2_committed_before'); +COMMIT; +Killing server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'node1_to_be_committed_after'); +connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'node1_to_be_rollbacked_after'); +connection node_2; +Performing --wsrep-recover ... +Starting server ... +Using --wsrep-start-position when starting mysqld ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'node1_committed_after'); +COMMIT; +connection node_1a_galera_st_kill_slave; +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (46,'node1_to_be_rollbacked_after'); +ROLLBACK; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +connection node_1; +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_35 FROM t1; +EXPECT_35 +35 +SELECT * FROM t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; diff --git a/mysql-test/suite/galera/r/galera_ist_progress.result b/mysql-test/suite/galera/r/galera_ist_progress.result index 9233d95b970..16772271b72 100644 --- a/mysql-test/suite/galera/r/galera_ist_progress.result +++ b/mysql-test/suite/galera/r/galera_ist_progress.result @@ -7,7 +7,7 @@ connection node_2; SET SESSION wsrep_on = OFF; SET SESSION wsrep_on = ON; connection node_1; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); @@ -23,8 +23,7 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; connection node_1; connection node_2; connection node_1; -include/assert_grep.inc [Receiving IST: 13 writesets, seqnos 3-15] -include/assert_grep.inc [Receiving IST\.\.\. 0\.0% \( 0/13 events\) complete] -include/assert_grep.inc [Receiving IST\.\.\.100\.0% \(13/13 events\) complete] +"Trying to find IST progress reporting" +found connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_many_tables_nopk.result b/mysql-test/suite/galera/r/galera_many_tables_nopk.result index 2a226defcc7..d341a1816e5 100644 --- a/mysql-test/suite/galera/r/galera_many_tables_nopk.result +++ b/mysql-test/suite/galera/r/galera_many_tables_nopk.result @@ -6,8 +6,8 @@ START TRANSACTION; COMMIT; connection node_2; CREATE TABLE sum_table (f1 INTEGER); -SELECT SUM(f1) = 900 FROM sum_table; -SUM(f1) = 900 +SELECT SUM(f1) = 100 FROM sum_table; +SUM(f1) = 100 1 connection node_1; SET AUTOCOMMIT=OFF; @@ -15,7 +15,7 @@ START TRANSACTION; connection node_2; SET AUTOCOMMIT=OFF; START TRANSACTION; -UPDATE t900 SET f1 = 3; +UPDATE t100 SET f1 = 3; connection node_1; COMMIT; connection node_2; diff --git a/mysql-test/suite/galera/r/galera_read_only.result b/mysql-test/suite/galera/r/galera_read_only.result index fe8b45fa596..e7e18ca8145 100644 --- a/mysql-test/suite/galera/r/galera_read_only.result +++ b/mysql-test/suite/galera/r/galera_read_only.result @@ -17,10 +17,18 @@ connect foo_node_2,127.0.0.1,foo,,test,$port_2,; connection foo_node_2; INSERT INTO t1 VALUES (2); ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb; +INSERT INTO t2 values (1); +DROP TABLE t2; connection node_2; -SELECT COUNT(*) = 1 FROM t1; -COUNT(*) = 1 +SELECT COUNT(*) AS EXPECT_1 FROM t1; +EXPECT_1 1 +connection node_2; +SET GLOBAL read_only=TRUE; +CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb; +INSERT INTO t2 values (1); +DROP TABLE t2; SET GLOBAL read_only=FALSE; DROP TABLE t1; DROP USER foo@localhost; diff --git a/mysql-test/suite/galera/r/mysql_tzinfo_to_sql.result b/mysql-test/suite/galera/r/mysql_tzinfo_to_sql.result new file mode 100644 index 00000000000..e0cee3a50bf --- /dev/null +++ b/mysql-test/suite/galera/r/mysql_tzinfo_to_sql.result @@ -0,0 +1,154 @@ +connection node_2; +connection node_1; +# +# MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +# + +# On node_1 +connection node_1; +CREATE TABLE time_zone LIKE mysql.time_zone; +CREATE TABLE time_zone_name LIKE mysql.time_zone_name; +CREATE TABLE time_zone_transition LIKE mysql.time_zone_transition; +CREATE TABLE time_zone_transition_type LIKE mysql.time_zone_transition_type; +CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second; +# +# Run on zoneinfo directory --skip-write-binlog +# + +# Apply on node_1 + +load timezones +'binlog stationary as expected' +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 + +# On node_2 (not replicated) + +connection node_2; +SELECT COUNT(*) FROM time_zone; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 +# +# Run on zoneinfo directory without --skip-write-binlog +# + +# Apply on node_1 + +connection node_1; +load timezones +'binlog advanced as expected' +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 + +# On node_2 (replicated via InnoDB) + +connection node_2; +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +TRUNCATE TABLE time_zone_leap_second; + +# Apply on node_1 (with wsrep_on=OFF) + +connection node_1; +SET GLOBAL WSREP_ON=OFF; +load timezones +SET GLOBAL WSREP_ON=ON; +'binlog advanced as expected' +SELECT COUNT(*) FROM time_zone; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +2 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 + +# On node_2 (Should not have been replicated) + +connection node_2; +SELECT COUNT(*) FROM time_zone; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_name; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_transition_type; +COUNT(*) +0 +SELECT COUNT(*) FROM time_zone_leap_second; +COUNT(*) +0 +connection node_1; +DROP TABLE time_zone; +DROP TABLE time_zone_name; +DROP TABLE time_zone_transition; +DROP TABLE time_zone_transition_type; +DROP TABLE time_zone_leap_second; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/galera/t/MDEV-26575.test b/mysql-test/suite/galera/t/MDEV-26575.test index e714f9fc430..4554f632c6f 100644 --- a/mysql-test/suite/galera/t/MDEV-26575.test +++ b/mysql-test/suite/galera/t/MDEV-26575.test @@ -5,6 +5,10 @@ --source include/galera_cluster.inc +--connection node_2 +call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*"); +--connection node_1 + # Save original auto_increment_offset values. --let $node_1=node_1 --let $node_2=node_2 diff --git a/mysql-test/suite/galera/t/MDEV-28053.cnf b/mysql-test/suite/galera/t/MDEV-28053.cnf new file mode 100644 index 00000000000..2a500639d1d --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-28053.cnf @@ -0,0 +1,6 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +slave_parallel_threads=4 +slave_parallel_mode=optimistic +gtid_strict_mode=1 diff --git a/mysql-test/suite/galera/t/MDEV-28053.test b/mysql-test/suite/galera/t/MDEV-28053.test new file mode 100644 index 00000000000..85cb20c7e10 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-28053.test @@ -0,0 +1,61 @@ +# +# MDEV-28053 - Sysbench data load crashes Galera secondary node in +# async master slave setup +# +# Setup: node 3 is a regular MariaDB server, nodes 1 and 2 are members +# of a Galera cluster. Node 2 connects to node 3 through async replication. +# +# Test uses multiple parallel async applier threads (see MDEV-28053.cnf) +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 + +--connection node_3 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; + +# +# Execute a few INSERTs, to simulate sysbench data load phase +# +--let $counter=100 +--disable_query_log +while ($counter) { + --connection node_3 + INSERT INTO t1 VALUES(); + --dec $counter +} +--enable_query_log +--let gtid = `SELECT @@last_gtid` + +# +# Start async replication on node 2. +# If bug is present, expect a crash when applying +# events concurrently. +# +--connection node_2 +--disable_query_log +--disable_result_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3; +START SLAVE; +--eval SELECT MASTER_GTID_WAIT('$gtid', 600) +--enable_result_log +--enable_query_log + +# +# Cleanup +# +--connection node_3 +DROP TABLE t1; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--connection node_2 +STOP SLAVE; +RESET SLAVE ALL; + +--connection node_3 +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test index 738aedbda9e..224db902569 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_at_after_statement.test @@ -34,6 +34,11 @@ SET DEBUG_SYNC = 'now WAIT_FOR blocked'; # cause BF abort on other node UPDATE t1 SET val=3 WHERE id=1; +--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 +set session wsrep_sync_wait=0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1 where id = 1 and val = 3 +--source include/wait_condition.inc + --connection node_2a SET DEBUG_SYNC = 'now SIGNAL continue'; @@ -47,3 +52,7 @@ SET DEBUG_SYNC = 'RESET'; --connection node_1 SET DEBUG_SYNC = 'RESET'; DROP TABLE t1; + +--disconnect node_2a +--disconnect node_2b + diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf index 889c81b4a0a..91e9199b092 100644 --- a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf +++ b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.cnf @@ -2,6 +2,8 @@ [mysqld.1] auto_increment_offset=1 +auto_increment_increment=1 [mysqld.2] auto_increment_offset=2 +auto_increment_increment=1 diff --git a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test index 431fa90c8e2..994f7695fc6 100644 --- a/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test +++ b/mysql-test/suite/galera/t/galera_binlog_stmt_autoinc.test @@ -3,7 +3,12 @@ ## --source include/galera_cluster.inc ---source include/have_innodb.inc +--source include/force_restart.inc + +--connection node_1 +SET GLOBAL auto_increment_offset=1; +--connection node_2 +SET GLOBAL auto_increment_offset=2; --let $node_1=node_1 --let $node_2=node_2 @@ -30,23 +35,24 @@ call mtr.add_suppression("Unsafe statement written to the binary log"); --enable_query_log CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) + i int(11) NOT NULL primary key AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; insert into t1(i) values(null); -select * from t1; +select * from t1 order by i; insert into t1(i) values(null), (null), (null); -select * from t1; +select * from t1 order by i; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 4 FROM t1; --source include/wait_condition.inc -select * from t1; +show variables like 'auto_increment%'; +select * from t1 order by i; SET GLOBAL wsrep_forced_binlog_format='none'; @@ -80,36 +86,31 @@ SET SESSION auto_increment_increment = 3; SET SESSION auto_increment_offset = 1; CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) + i int(11) NOT NULL primary key AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; insert into t1(i) values(null); -select * from t1; +select * from t1 order by i; insert into t1(i) values(null), (null), (null); -select * from t1; +select * from t1 order by i; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 4 FROM t1; --source include/wait_condition.inc +show variables like 'auto_increment%'; -select * from t1; +select * from t1 order by i; --connection node_1 - -## -## Verify the return to automatic calculation of the step -## and offset of the auto-increment: -## - SET GLOBAL wsrep_auto_increment_control='ON'; - SET SESSION binlog_format='ROW'; - +--source include/auto_increment_offset_restore.inc +--connection node_1 show variables like 'binlog_format'; show variables like '%auto_increment%'; @@ -127,7 +128,8 @@ show variables like '%auto_increment%'; ## SET GLOBAL wsrep_auto_increment_control='ON'; - +--source include/auto_increment_offset_restore.inc +--connection node_1 drop table t1; ## @@ -142,24 +144,25 @@ SET GLOBAL wsrep_forced_binlog_format='ROW'; SET GLOBAL wsrep_forced_binlog_format='ROW'; CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) + i int(11) NOT NULL primary key AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; insert into t1(i) values(null); -select * from t1; +select * from t1 order by i; insert into t1(i) values(null), (null), (null); -select * from t1; +select * from t1 order by i; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 4 FROM t1; --source include/wait_condition.inc -select * from t1; +show variables like 'auto_increment%'; +select * from t1 order by i; SET GLOBAL wsrep_forced_binlog_format='none'; @@ -189,24 +192,25 @@ SET SESSION auto_increment_increment = 3; SET SESSION auto_increment_offset = 1; CREATE TABLE t1 ( - i int(11) NOT NULL AUTO_INCREMENT, - c char(32) DEFAULT 'dummy_text', - PRIMARY KEY (i) + i int(11) NOT NULL primary key AUTO_INCREMENT, + c char(32) DEFAULT 'dummy_text' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +show variables like 'auto_increment%'; insert into t1(i) values(null); -select * from t1; +select * from t1 order by i; insert into t1(i) values(null), (null), (null); -select * from t1; +select * from t1 order by i; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 4 FROM t1; --source include/wait_condition.inc +show variables like 'auto_increment%'; -select * from t1; +select * from t1 order by i; --connection node_1 @@ -216,6 +220,7 @@ select * from t1; ## SET GLOBAL wsrep_auto_increment_control='ON'; +--source include/auto_increment_offset_restore.inc show variables like 'binlog_format'; show variables like '%auto_increment%'; diff --git a/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf b/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf new file mode 100644 index 00000000000..691e52208b1 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_MDEV-28423.cnf @@ -0,0 +1,44 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +# server-id=101 +#wsrep-debug=1 +innodb_file_per_table +innodb_autoinc_lock_mode=2 +#wsrep_sst_method=rsync +wsrep_sst_method=mariabackup +wsrep_sst_auth=root: +binlog_format=ROW +core-file +log-output=none +wsrep_slave_threads=2 +wsrep_on=1 +gtid_strict_mode=1 +log_slave_updates=ON +log_bin=binlog + +[mysqld.2] +# server-id=102 +#wsrep-debug=1 +innodb_file_per_table +innodb_autoinc_lock_mode=2 +#wsrep_sst_method=rsync +wsrep_sst_method=mariabackup +wsrep_sst_auth=root: +binlog_format=ROW +core-file +log-output=none +wsrep_slave_threads=2 +wsrep_on=1 +gtid_strict_mode=1 +log_slave_updates=ON +log_bin=binlog + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + +[sst] +transferfmt=@ENV.MTR_GALERA_TFMT diff --git a/mysql-test/suite/galera/t/galera_ist_MDEV-28423.test b/mysql-test/suite/galera/t/galera_ist_MDEV-28423.test new file mode 100644 index 00000000000..8668c4ce158 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_MDEV-28423.test @@ -0,0 +1,18 @@ +# MDEV-28423: Galera IST is failing on Joiner node + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_mariabackup.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_disconnect_slave.inc +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf b/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf new file mode 100644 index 00000000000..3835cd02a41 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_MDEV-28583.cnf @@ -0,0 +1,44 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +# server-id=101 +#wsrep-debug=1 +innodb_file_per_table +innodb_autoinc_lock_mode=2 +wsrep_sst_method=rsync +#wsrep_sst_method=mariabackup +wsrep_sst_auth=root: +binlog_format=ROW +core-file +log-output=none +wsrep_slave_threads=2 +wsrep_on=1 +gtid_strict_mode=1 +log_slave_updates=ON +log_bin=binlog + +[mysqld.2] +# server-id=102 +#wsrep-debug=1 +innodb_file_per_table +innodb_autoinc_lock_mode=2 +wsrep_sst_method=rsync +#wsrep_sst_method=mariabackup +wsrep_sst_auth=root: +binlog_format=ROW +core-file +log-output=none +wsrep_slave_threads=2 +wsrep_on=1 +gtid_strict_mode=1 +log_slave_updates=ON +log_bin=binlog + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true' + +[sst] +transferfmt=@ENV.MTR_GALERA_TFMT diff --git a/mysql-test/suite/galera/t/galera_ist_MDEV-28583.test b/mysql-test/suite/galera/t/galera_ist_MDEV-28583.test new file mode 100644 index 00000000000..2c8c0bd80da --- /dev/null +++ b/mysql-test/suite/galera/t/galera_ist_MDEV-28583.test @@ -0,0 +1,18 @@ +# MDEV-28583: Galera: binlogs disappear after rsync IST + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_mariabackup.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_disconnect_slave.inc +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_ist_progress.cnf b/mysql-test/suite/galera/t/galera_ist_progress.cnf index 0a26f6d6c83..b37e7f38ce3 100644 --- a/mysql-test/suite/galera/t/galera_ist_progress.cnf +++ b/mysql-test/suite/galera/t/galera_ist_progress.cnf @@ -3,3 +3,5 @@ [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true' + + diff --git a/mysql-test/suite/galera/t/galera_ist_progress.test b/mysql-test/suite/galera/t/galera_ist_progress.test index 3d7c53bd1eb..60034ec0db1 100644 --- a/mysql-test/suite/galera/t/galera_ist_progress.test +++ b/mysql-test/suite/galera/t/galera_ist_progress.test @@ -3,12 +3,11 @@ # --source include/galera_cluster.inc -# This could cause out of storage if run /dev/shm ---source include/big_test.inc ---source include/force_restart.inc # Isolate node #2 --connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; --connection node_1 @@ -24,7 +23,7 @@ SET SESSION wsrep_on = ON; # Node #2 is now isolated. Run some transactions to accumulate writesets for IST --connection node_1 -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; +CREATE TABLE t1 (f1 INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); INSERT INTO t1 VALUES (3); @@ -50,26 +49,15 @@ SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 0'; --source include/wait_condition.inc # -# Grep for expected IST output in joiner log +# sed for expected IST output in joiner log # --connection node_1 ---let $assert_count = 1 ---let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.2.err ---let $assert_only_after = Need state transfer - ---let $assert_text = Receiving IST: 13 writesets, seqnos 3-15 ---let $assert_select = Receiving IST: 13 writesets, seqnos 3-15 ---source include/assert_grep.inc - ---let $assert_text = Receiving IST\.\.\. 0\.0% \( 0/13 events\) complete ---let $assert_select = Receiving IST\.\.\. 0\.0% \( 0/13 events\) complete ---source include/assert_grep.inc - ---let $assert_text = Receiving IST\.\.\.100\.0% \(13/13 events\) complete ---let $assert_select = Receiving IST\.\.\.100\.0% \(13/13 events\) complete ---source include/assert_grep.inc +# Grep is not safe always and we are interested that there is at least one progress report (there can be more) +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo "Trying to find IST progress reporting" +--exec sed -ne 's/.*Receiving IST.*/found/p' $MYSQLD_DATADIR/../../log/mysqld.2.err | tail -1 # Cleanup diff --git a/mysql-test/suite/galera/t/galera_many_tables_nopk.test b/mysql-test/suite/galera/t/galera_many_tables_nopk.test index 98a65b7c660..5bfab686726 100644 --- a/mysql-test/suite/galera/t/galera_many_tables_nopk.test +++ b/mysql-test/suite/galera/t/galera_many_tables_nopk.test @@ -7,18 +7,17 @@ if (!`SELECT @@open_files_limit >= 1024`){ } # -# This test forces 900 tables without a PK to participate in a single -# transaction. The reason for 900 is that some linux system has by default -# a limit of 1024 open files / process +# This test forces 100 tables without a PK to participate in a single +# transaction. # # -# First, create 900 tables +# First, create 100 tables # --connection node_1 ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -28,7 +27,7 @@ while ($count) --dec $count } ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -39,13 +38,13 @@ while ($count) } # -# Second, perform 900 updates +# Second, perform 100 updates # SET AUTOCOMMIT=OFF; START TRANSACTION; ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -63,7 +62,7 @@ COMMIT; --connection node_2 CREATE TABLE sum_table (f1 INTEGER); ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -73,7 +72,7 @@ while ($count) --dec $count } -SELECT SUM(f1) = 900 FROM sum_table; +SELECT SUM(f1) = 100 FROM sum_table; # # Fourth, create a deadlock @@ -83,7 +82,7 @@ SELECT SUM(f1) = 900 FROM sum_table; SET AUTOCOMMIT=OFF; START TRANSACTION; ---let $count = 900 +--let $count = 100 while ($count) { --disable_query_log @@ -96,7 +95,7 @@ while ($count) --connection node_2 SET AUTOCOMMIT=OFF; START TRANSACTION; -UPDATE t900 SET f1 = 3; +UPDATE t100 SET f1 = 3; --connection node_1 COMMIT; diff --git a/mysql-test/suite/galera/t/galera_read_only.test b/mysql-test/suite/galera/t/galera_read_only.test index c0fa4af07e0..56fe2fdd910 100644 --- a/mysql-test/suite/galera/t/galera_read_only.test +++ b/mysql-test/suite/galera/t/galera_read_only.test @@ -28,9 +28,20 @@ CREATE USER foo@localhost; --connection foo_node_2 --error ER_OPTION_PREVENTS_STATEMENT INSERT INTO t1 VALUES (2); +# Writes to temporary tables are allowed +CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb; +INSERT INTO t2 values (1); +DROP TABLE t2; --connection node_2 -SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) AS EXPECT_1 FROM t1; + +--connection node_2 +SET GLOBAL read_only=TRUE; +# Writes to temporary tables are allowed +CREATE TEMPORARY TABLE t2(id int not null primary key) engine=innodb; +INSERT INTO t2 values (1); +DROP TABLE t2; # Cleanup SET GLOBAL read_only=FALSE; diff --git a/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.opt b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.opt new file mode 100644 index 00000000000..beae84b3862 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.opt @@ -0,0 +1 @@ +--log-bin diff --git a/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.test b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.test new file mode 100644 index 00000000000..6bfad2f18b5 --- /dev/null +++ b/mysql-test/suite/galera/t/mysql_tzinfo_to_sql.test @@ -0,0 +1,156 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/not_embedded.inc +# merge note: 10.6 change not_embedded.inc to no_protocol.inc + +# Unlike the similar galera.mariadb_tzinfo_to_sql.test in 10.6+, this +# tests that the output can be parsed by the mysql client. +--echo # +--echo # MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases +--echo # + +--exec mkdir $MYSQLTEST_VARDIR/zoneinfo +--exec ln -s $MYSQLTEST_VARDIR/zoneinfo $MYSQLTEST_VARDIR/zoneinfo/posix +--copy_file std_data/zoneinfo/GMT $MYSQLTEST_VARDIR/zoneinfo/GMT + +--echo +--echo # On node_1 +--connection node_1 + +CREATE TABLE time_zone LIKE mysql.time_zone; +CREATE TABLE time_zone_name LIKE mysql.time_zone_name; +CREATE TABLE time_zone_transition LIKE mysql.time_zone_transition; +CREATE TABLE time_zone_transition_type LIKE mysql.time_zone_transition_type; +CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second; + +--echo # +--echo # Run on zoneinfo directory --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null > $MYSQL_TMP_DIR/tz.sql + +--echo +--echo # Apply on node_1 +--echo +--let $snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) +--echo load timezones +--exec $MYSQL test < "$MYSQL_TMP_DIR/tz.sql" +--let $new_snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) + +if ($snap_pos == $new_snap_pos) +{ +--echo 'binlog stationary as expected' +} + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo +--echo # On node_2 (not replicated) +--echo +--connection node_2 + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo # +--echo # Run on zoneinfo directory without --skip-write-binlog +--echo # + +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null > $MYSQL_TMP_DIR/tz.sql + +--echo +--echo # Apply on node_1 +--echo +--connection node_1 + +--echo load timezones +--exec $MYSQL test < "$MYSQL_TMP_DIR/tz.sql" +--let $new_snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) + +if ($snap_pos < $new_snap_pos) +{ +--echo 'binlog advanced as expected' +} + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo +--echo # On node_2 (replicated via InnoDB) +--echo +--connection node_2 + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +TRUNCATE TABLE time_zone; +TRUNCATE TABLE time_zone_name; +TRUNCATE TABLE time_zone_transition; +TRUNCATE TABLE time_zone_transition_type; +TRUNCATE TABLE time_zone_leap_second; + +--echo +--echo # Apply on node_1 (with wsrep_on=OFF) +--echo +--connection node_1 + +SET GLOBAL WSREP_ON=OFF; +--let $snap_pos= $new_snap_pos +--echo load timezones +--exec $MYSQL test < "$MYSQL_TMP_DIR/tz.sql" +--let $new_snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1) +SET GLOBAL WSREP_ON=ON; + +if ($snap_pos < $new_snap_pos) +{ +--echo 'binlog advanced as expected' +} + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +--echo +--echo # On node_2 (Should not have been replicated) +--echo +--connection node_2 + +SELECT COUNT(*) FROM time_zone; +SELECT COUNT(*) FROM time_zone_name; +SELECT COUNT(*) FROM time_zone_transition; +SELECT COUNT(*) FROM time_zone_transition_type; +SELECT COUNT(*) FROM time_zone_leap_second; + +# +# Cleanup +# + +--connection node_1 +--remove_file $MYSQL_TMP_DIR/tz.sql +--exec rm -rf $MYSQLTEST_VARDIR/zoneinfo +DROP TABLE time_zone; +DROP TABLE time_zone_name; +DROP TABLE time_zone_transition; +DROP TABLE time_zone_transition_type; +DROP TABLE time_zone_leap_second; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/galera_3nodes/r/galera_wsrep_schema.result b/mysql-test/suite/galera_3nodes/r/galera_wsrep_schema.result index f51eb815cd5..deef311b1e4 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_wsrep_schema.result +++ b/mysql-test/suite/galera_3nodes/r/galera_wsrep_schema.result @@ -74,3 +74,4 @@ cluster_uuid = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHER SELECT COUNT(*) AS EXPECT_3 FROM mysql.wsrep_cluster_members; EXPECT_3 3 +disconnect node_3; diff --git a/mysql-test/suite/galera_3nodes/t/galera_wsrep_schema.test b/mysql-test/suite/galera_3nodes/t/galera_wsrep_schema.test index 52bbf3a652c..d6e20d3bbfb 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_wsrep_schema.test +++ b/mysql-test/suite/galera_3nodes/t/galera_wsrep_schema.test @@ -17,6 +17,9 @@ # Make the test fail if table structure has changed +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + SHOW CREATE TABLE mysql.wsrep_cluster; SHOW CREATE TABLE mysql.wsrep_cluster_members; @@ -74,3 +77,5 @@ SELECT cluster_uuid = (SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STAT SELECT COUNT(*) AS EXPECT_3 FROM mysql.wsrep_cluster_members; --source ../galera/include/auto_increment_offset_restore.inc + +--disconnect node_3 diff --git a/mysql-test/suite/galera_sr/disabled.def b/mysql-test/suite/galera_sr/disabled.def index e45118f6f0a..4e77dd50bf7 100644 --- a/mysql-test/suite/galera_sr/disabled.def +++ b/mysql-test/suite/galera_sr/disabled.def @@ -13,6 +13,5 @@ GCF-1018B : MDEV-18534 wsrep::transaction::adopt(): Assertion `transaction.is_streaming()' failed GCF-1060 : MDEV-20848 galera_sr.GCF_1060 GCF-585 : MDEV-24698 galera_sr.GCF-585 MTR failed with SIGABRT: no such a transition REPLICATING -> APPLYING -galera-features#56 : MDEV-24896 GCF-1060 : MDEV-26528 wrong usage of mutex LOCK_thd_kill and LOCK_thd_kill galera_sr_shutdown_master : MDEV-23612: galera_sr.galera_sr_shutdown_master MTR failed: WSREP_SST: [ERROR] Possible timeout in receving first data from donor in gtid stage diff --git a/mysql-test/suite/galera_sr/r/galera_sr_shutdown_slave.result b/mysql-test/suite/galera_sr/r/galera_sr_shutdown_slave.result index 902aa27d5aa..34995d35a4f 100644 --- a/mysql-test/suite/galera_sr/r/galera_sr_shutdown_slave.result +++ b/mysql-test/suite/galera_sr/r/galera_sr_shutdown_slave.result @@ -2,6 +2,8 @@ connection node_2; connection node_1; connection node_1; connection node_2; +connection node_2; +call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*"); connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE = InnoDB; connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; diff --git a/mysql-test/suite/galera_sr/t/galera_sr_shutdown_slave.test b/mysql-test/suite/galera_sr/t/galera_sr_shutdown_slave.test index d1b0d4b8c88..5d4a58b2d03 100644 --- a/mysql-test/suite/galera_sr/t/galera_sr_shutdown_slave.test +++ b/mysql-test/suite/galera_sr/t/galera_sr_shutdown_slave.test @@ -8,6 +8,8 @@ --let $node_1=node_1 --let $node_2=node_2 --source ../galera/include/auto_increment_offset_save.inc +--connection node_2 +call mtr.add_suppression("WSREP: Failed to scan the last segment to the end. Last events may be missing. Last recovered event:.*"); --connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE = InnoDB; diff --git a/mysql-test/suite/handler/aria.result b/mysql-test/suite/handler/aria.result index e34164957a3..b0a4a173289 100644 --- a/mysql-test/suite/handler/aria.result +++ b/mysql-test/suite/handler/aria.result @@ -1690,3 +1690,19 @@ a b HANDLER t1 CLOSE; DROP TABLE t1; End of 5.1 tests +# +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/suite/handler/aria.test b/mysql-test/suite/handler/aria.test index 1913d2b791c..912a9e89721 100644 --- a/mysql-test/suite/handler/aria.test +++ b/mysql-test/suite/handler/aria.test @@ -80,3 +80,23 @@ HANDLER t1 CLOSE; DROP TABLE t1; --echo End of 5.1 tests + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/mysql-test/suite/handler/innodb.result b/mysql-test/suite/handler/innodb.result index dac6b2e997b..5d44642db01 100644 --- a/mysql-test/suite/handler/innodb.result +++ b/mysql-test/suite/handler/innodb.result @@ -1772,3 +1772,19 @@ HANDLER t1 READ `PRIMARY` PREV; f1 f2 3 3 DROP TABLE t1; +# +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/suite/handler/innodb.test b/mysql-test/suite/handler/innodb.test index 5c2dae8a146..8c9844743f4 100644 --- a/mysql-test/suite/handler/innodb.test +++ b/mysql-test/suite/handler/innodb.test @@ -27,3 +27,23 @@ HANDLER t1 OPEN; HANDLER t1 READ FIRST WHERE f2 <= 1; HANDLER t1 READ `PRIMARY` PREV; DROP TABLE t1; + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/mysql-test/suite/handler/interface.result b/mysql-test/suite/handler/interface.result index 5dcb80d2b2f..3758400345b 100644 --- a/mysql-test/suite/handler/interface.result +++ b/mysql-test/suite/handler/interface.result @@ -315,6 +315,22 @@ handler v read next; ERROR 42S02: Unknown table 'v' in HANDLER drop view v; # +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 'test.t1' +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test +# # MDEV-15813 ASAN use-after-poison in hp_hashnr upon # HANDLER READ on a versioned HEAP table # diff --git a/mysql-test/suite/handler/interface.test b/mysql-test/suite/handler/interface.test index 0ecdbf9c5cf..a4ed640dbc0 100644 --- a/mysql-test/suite/handler/interface.test +++ b/mysql-test/suite/handler/interface.test @@ -358,6 +358,26 @@ handler v read next; drop view v; --echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test + +--echo # --echo # MDEV-15813 ASAN use-after-poison in hp_hashnr upon --echo # HANDLER READ on a versioned HEAP table --echo # diff --git a/mysql-test/suite/handler/myisam.result b/mysql-test/suite/handler/myisam.result index 896908e1602..cc817ccd889 100644 --- a/mysql-test/suite/handler/myisam.result +++ b/mysql-test/suite/handler/myisam.result @@ -1776,3 +1776,17 @@ test.t1 preload_keys status OK HANDLER t1 READ FIRST; ERROR 42S02: Unknown table 't1' in HANDLER End of 5.1 tests +# +# 10.2 Test +# +# MDEV-20207: Assertion `! is_set()' failed in +# Diagnostics_area::set_eof_status upon HANDLER READ +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; +HANDLER h READ a = (0); +ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field +HANDLER h CLOSE; +DROP TABLE t1; +# End of 10.2 Test diff --git a/mysql-test/suite/handler/myisam.test b/mysql-test/suite/handler/myisam.test index a2d87630aef..2fce8548322 100644 --- a/mysql-test/suite/handler/myisam.test +++ b/mysql-test/suite/handler/myisam.test @@ -169,3 +169,23 @@ HANDLER t1 READ FIRST; --echo End of 5.1 tests + +--echo # +--echo # 10.2 Test +--echo # +--echo # MDEV-20207: Assertion `! is_set()' failed in +--echo # Diagnostics_area::set_eof_status upon HANDLER READ +--echo # + +DROP TABLE IF EXISTS t1; + +CREATE TABLE t1 (a POINT, KEY(a)); +HANDLER t1 OPEN h; + +--error ER_CANT_CREATE_GEOMETRY_OBJECT +HANDLER h READ a = (0); + +HANDLER h CLOSE; +DROP TABLE t1; + +--echo # End of 10.2 Test diff --git a/mysql-test/suite/innodb/r/alter_persistent_autoinc.result b/mysql-test/suite/innodb/r/alter_persistent_autoinc.result new file mode 100644 index 00000000000..52ac4d83ad9 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_persistent_autoinc.result @@ -0,0 +1,42 @@ +CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t1 MODIFY c INT NULL, ALGORITHM=INSTANT; +INSERT INTO t1 SET c=1; +CREATE TABLE t2 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t2 MODIFY c INT NULL, FORCE, ALGORITHM=INPLACE; +INSERT INTO t2 SET c=1; +CREATE TABLE t3 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t3 MODIFY c INT NULL, ALGORITHM=INPLACE; +INSERT INTO t3 SET c=1; +CREATE TABLE t4 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB; +ALTER TABLE t4 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE; +INSERT INTO t4 SET c1=1; +CREATE TABLE t5 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT, c3 INTEGER GENERATED ALWAYS AS (c2)) ENGINE=InnoDB; +ALTER TABLE t5 MODIFY c1 INT NULL, MODIFY COLUMN c2 INT FIRST, ALGORITHM=INPLACE; +INSERT INTO t5 SET c1=1; +CREATE TABLE t6 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB +PARTITION BY LIST(c) ( +PARTITION p1 VALUES IN (1), +PARTITION p2 VALUES IN (2) +); +ALTER TABLE t6 MODIFY c INT NULL, ALGORITHM=INSTANT; +INSERT INTO t6 SET c=1; +INSERT INTO t6 SET c=2; +CREATE TABLE t7 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB +PARTITION BY LIST(c) ( +PARTITION p1 VALUES IN (1), +PARTITION p2 VALUES IN (2) +); +ALTER TABLE t7 MODIFY c INT NULL, ALGORITHM=INPLACE; +INSERT INTO t7 SET c=1; +INSERT INTO t7 SET c=2; +CREATE TABLE t8 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB +PARTITION BY LIST(c1) ( +PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t8 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE; +INSERT INTO t8 SET c1=1; +INSERT INTO t8 SET c1=2; +FLUSH TABLES t1, t2, t3, t4, t5, t6, t7, t8 FOR EXPORT; +AUTO_INCREMENT not partitioned: 0 0 0 0 0 +AUTO_INCREMENT partitioned: (0, 0) (0, 0) (0, 0) +UNLOCK TABLES; +DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8; diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result index da784ba2acf..376ea821279 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -137,7 +137,34 @@ SELECT unique_constraint_name FROM information_schema.referential_constraints WHERE table_name = 't2'; unique_constraint_name PRIMARY +# +# MDEV-28317 Assertion failure on rollback of FOREIGN KEY operation +# +SET foreign_key_checks=0; +CREATE TABLE parent(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE child(a INT,FOREIGN KEY(a) REFERENCES parent(a) ON DELETE CASCADE) +ENGINE=InnoDB; +INSERT INTO child VALUES(1); +ALTER TABLE child DROP INDEX a; +connect incomplete, localhost, root,,; +BEGIN; +DELETE FROM child; +connection default; +INSERT INTO parent SET a=0; +FLUSH TABLES; # restart +disconnect incomplete; +INSERT INTO child SET a=0; +INSERT INTO child SET a=1; +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE) +DELETE FROM parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE) +ALTER TABLE child ADD INDEX(a); +DELETE FROM parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE) +ALTER TABLE child FORCE; +DELETE FROM parent; +DROP TABLE child,parent; SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; SELECT unique_constraint_name FROM information_schema.referential_constraints diff --git a/mysql-test/suite/innodb/r/gap_lock_split.result b/mysql-test/suite/innodb/r/gap_lock_split.result new file mode 100644 index 00000000000..25a3cf711f9 --- /dev/null +++ b/mysql-test/suite/innodb/r/gap_lock_split.result @@ -0,0 +1,27 @@ +SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency=1; +CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000)) ENGINE=InnoDB; +INSERT INTO t1 (id,val) SELECT 2*seq,'x' FROM seq_0_to_1023; +connect con1,localhost,root,,; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; +DELETE FROM t1 WHERE id=1788; +BEGIN; +SELECT * FROM t1 WHERE id=1788 FOR UPDATE; +id val +connection con1; +COMMIT; +InnoDB 0 transactions not purged +connection default; +INSERT INTO t1 (id,val) VALUES (1787, REPEAT('x',2000)); +connection con1; +SET innodb_lock_wait_timeout=0; +INSERT INTO t1 (id,val) VALUES (1788, 'x'); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SELECT * FROM t1 WHERE id=1788 FOR UPDATE; +id val +disconnect con1; +connection default; +COMMIT; +DROP TABLE t1; +SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/mysql-test/suite/innodb/r/import_bugs.result b/mysql-test/suite/innodb/r/import_bugs.result index 14e4954e79f..98f3e76763b 100644 --- a/mysql-test/suite/innodb/r/import_bugs.result +++ b/mysql-test/suite/innodb/r/import_bugs.result @@ -8,13 +8,19 @@ FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; ALTER TABLE imp_t1 IMPORT TABLESPACE; ERROR HY000: Schema mismatch (ROW_FORMAT mismatch) +CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +ERROR 42S01: Table 'imp_t1' already exists +DROP TABLE imp_t1; +CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB; DROP TABLE imp_t1, t1; SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm; # -# MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' --echo # failed in dberr_t row_discard_tablespace_for_mysql +# MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' +# failed in dberr_t row_discard_tablespace_for_mysql # (dict_table_t*, trx_t*) CREATE TABLE t1 (c INT KEY) ENGINE=INNODB; CREATE TABLE t2 (c INT KEY,FOREIGN KEY(c) REFERENCES t1 (c)) ENGINE=INNODB; ALTER TABLE t1 DISCARD TABLESPACE; ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails DROP TABLE t2, t1; +# End of 10.6 tests diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result index aae9432fc35..8962d6ba400 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-debug.result +++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result @@ -134,7 +134,7 @@ DROP TABLE t1; # CREATE TABLE t1(a INT PRIMARY KEY, b INT, INDEX(b)) ENGINE=InnoDB; SET @save_dbug=@@debug_dbug; -SET debug_dbug='+d,innodb_table_deadlock'; +SET debug_dbug='+d,deadlock_table_fail'; ALTER TABLE t1 DROP INDEX b, ALGORITHM=INPLACE; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction SET debug_dbug=@save_dbug; diff --git a/mysql-test/suite/innodb/r/innodb-autoinc-part.result b/mysql-test/suite/innodb/r/innodb-autoinc-part.result new file mode 100644 index 00000000000..6872b5e02f5 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-autoinc-part.result @@ -0,0 +1,34 @@ +# +# MDEV-28416 Incorrect AUTO_INCREMENT may be issued +# +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; +CREATE TABLE t1 (a SERIAL) ENGINE=innodb +PARTITION BY RANGE (a) ( +PARTITION p0 VALUES LESS THAN (6), +PARTITION p1 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`a`) +(PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB, + PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +INSERT INTO t1 VALUES (NULL); +ERROR 22003: Out of range value for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=298 DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`a`) +(PARTITION `p0` VALUES LESS THAN (6) ENGINE = InnoDB, + PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +DROP TABLE t1; +SET auto_increment_increment=@aii; +# End of 10.2 tests diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result index 1efd5c61af7..b41e1c90a43 100644 --- a/mysql-test/suite/innodb/r/innodb-autoinc.result +++ b/mysql-test/suite/innodb/r/innodb-autoinc.result @@ -1,4 +1,3 @@ -drop table if exists t1; CREATE TABLE t1 (c1 BIGINT PRIMARY KEY AUTO_INCREMENT, c2 VARCHAR(10)) ENGINE=InnoDB; INSERT INTO t1 VALUES (9223372036854775807, null); INSERT INTO t1 (c2) VALUES ('innodb'); @@ -1622,3 +1621,27 @@ id name -1 dog 2 cat DROP PROCEDURE autoinc_mdev15353_one; +# +# MDEV-28416 Incorrect AUTO_INCREMENT may be issued +# +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; +CREATE TABLE t1 (a SERIAL) ENGINE=innodb; +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551614 DEFAULT CHARSET=latin1 +INSERT INTO t1 VALUES (NULL); +ERROR 22003: Out of range value for column 'a' at row 1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + UNIQUE KEY `a` (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=18446744073709551615 DEFAULT CHARSET=latin1 +DROP TABLE t1; +SET auto_increment_increment=@aii; +# End of 10.2 tests diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result index 5e4946bf793..a504bb4aa39 100644 --- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result +++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result @@ -69,8 +69,6 @@ buffer_pool_bytes_dirty buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL buffer_pool_pages_free buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer pages currently free (innodb_buffer_pool_pages_free) buffer_pages_created buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages created (innodb_pages_created) buffer_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages written (innodb_pages_written) -buffer_index_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of index pages written (innodb_index_pages_written) -buffer_non_index_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of non index pages written (innodb_non_index_pages_written) buffer_pages_read buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages read (innodb_pages_read) buffer_index_sec_rec_cluster_reads buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of secondary record reads triggered cluster read buffer_index_sec_rec_cluster_reads_avoided buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of secondary record reads avoided triggering cluster read diff --git a/mysql-test/suite/innodb/r/innodb_status_variables.result b/mysql-test/suite/innodb/r/innodb_status_variables.result index 02f73f37d66..086e4e1d1e7 100644 --- a/mysql-test/suite/innodb/r/innodb_status_variables.result +++ b/mysql-test/suite/innodb/r/innodb_status_variables.result @@ -87,8 +87,6 @@ INNODB_TRUNCATED_STATUS_WRITES INNODB_AVAILABLE_UNDO_LOGS INNODB_UNDO_TRUNCATIONS INNODB_PAGE_COMPRESSION_SAVED -INNODB_NUM_INDEX_PAGES_WRITTEN -INNODB_NUM_NON_INDEX_PAGES_WRITTEN INNODB_NUM_PAGES_PAGE_COMPRESSED INNODB_NUM_PAGE_COMPRESSED_TRIM_OP INNODB_NUM_PAGES_PAGE_DECOMPRESSED @@ -115,7 +113,6 @@ INNODB_ENCRYPTION_ROTATION_PAGES_READ_FROM_DISK INNODB_ENCRYPTION_ROTATION_PAGES_MODIFIED INNODB_ENCRYPTION_ROTATION_PAGES_FLUSHED INNODB_ENCRYPTION_ROTATION_ESTIMATED_IOPS -INNODB_ENCRYPTION_KEY_ROTATION_LIST_LENGTH INNODB_ENCRYPTION_N_MERGE_BLOCKS_ENCRYPTED INNODB_ENCRYPTION_N_MERGE_BLOCKS_DECRYPTED INNODB_ENCRYPTION_N_ROWLOG_BLOCKS_ENCRYPTED diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index ce10aceb51b..922c66a068f 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -35,8 +35,6 @@ buffer_pool_bytes_dirty disabled buffer_pool_pages_free disabled buffer_pages_created disabled buffer_pages_written disabled -buffer_index_pages_written disabled -buffer_non_index_pages_written disabled buffer_pages_read disabled buffer_index_sec_rec_cluster_reads disabled buffer_index_sec_rec_cluster_reads_avoided disabled diff --git a/mysql-test/suite/innodb/t/alter_persistent_autoinc.test b/mysql-test/suite/innodb/t/alter_persistent_autoinc.test new file mode 100644 index 00000000000..dcaea32700c --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_persistent_autoinc.test @@ -0,0 +1,86 @@ +# Test the ability to remove AUTO_INCREMENT attribute +--source include/have_innodb.inc +--source include/have_partition.inc + +CREATE TABLE t1 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t1 MODIFY c INT NULL, ALGORITHM=INSTANT; +INSERT INTO t1 SET c=1; + +CREATE TABLE t2 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t2 MODIFY c INT NULL, FORCE, ALGORITHM=INPLACE; +INSERT INTO t2 SET c=1; + +CREATE TABLE t3 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t3 MODIFY c INT NULL, ALGORITHM=INPLACE; +INSERT INTO t3 SET c=1; + +CREATE TABLE t4 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB; +ALTER TABLE t4 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE; +INSERT INTO t4 SET c1=1; + +CREATE TABLE t5 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT, c3 INTEGER GENERATED ALWAYS AS (c2)) ENGINE=InnoDB; +# ha_innobase::commit_inplace_alter_table() should invoke innobase_reload_table() +ALTER TABLE t5 MODIFY c1 INT NULL, MODIFY COLUMN c2 INT FIRST, ALGORITHM=INPLACE; +INSERT INTO t5 SET c1=1; + +CREATE TABLE t6 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB + PARTITION BY LIST(c) ( + PARTITION p1 VALUES IN (1), + PARTITION p2 VALUES IN (2) + ); +ALTER TABLE t6 MODIFY c INT NULL, ALGORITHM=INSTANT; +INSERT INTO t6 SET c=1; +INSERT INTO t6 SET c=2; + +CREATE TABLE t7 (c INT AUTO_INCREMENT NULL UNIQUE) ENGINE=InnoDB + PARTITION BY LIST(c) ( + PARTITION p1 VALUES IN (1), + PARTITION p2 VALUES IN (2) + ); +ALTER TABLE t7 MODIFY c INT NULL, ALGORITHM=INPLACE; +INSERT INTO t7 SET c=1; +INSERT INTO t7 SET c=2; + +CREATE TABLE t8 (c1 INT AUTO_INCREMENT NULL UNIQUE, c2 INT) ENGINE=InnoDB + PARTITION BY LIST(c1) ( + PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2)); +ALTER TABLE t8 MODIFY c1 INT NULL, CHANGE COLUMN c2 c3 INT, ALGORITHM=INPLACE; +INSERT INTO t8 SET c1=1; +INSERT INTO t8 SET c1=2; + +FLUSH TABLES t1, t2, t3, t4, t5, t6, t7, t8 FOR EXPORT; + +--let INNODB_PAGE_SIZE=`select @@innodb_page_size` +--let MYSQLD_DATADIR = `SELECT @@datadir` + +--perl +my $ps= $ENV{INNODB_PAGE_SIZE}; +my $PAGE_HEADER = 38; +my $PAGE_ROOT_AUTO_INC = 18; +print "AUTO_INCREMENT not partitioned: "; +for (my $i = 1; $i <= 5; ++$i) { + my $autoinc= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i.ibd"); + print "$autoinc "; +} +print "\n"; +print "AUTO_INCREMENT partitioned: "; +for (my $i = 6; $i <= 8; ++$i) { + my $p1= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i#P#p1.ibd"); + my $p2= read_autoinc("$ENV{MYSQLD_DATADIR}/test/t$i#P#p2.ibd"); + print "($p1, $p2) "; +} +print "\n"; +sub read_autoinc { + my $file= shift; + open(FILE, "<", $file) || die "Unable to open $file\n"; + sysseek(FILE, 3*$ps + $PAGE_HEADER + $PAGE_ROOT_AUTO_INC + 4, 0) + || die "Unable to seek $file\n"; + die "Unable to read $file\n" unless sysread(FILE, $_, 4) == 4; + my $t1=unpack("N",$_); + close(FILE); + return $t1; +} +EOF + +UNLOCK TABLES; +DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8; diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test index 6f7e5948b05..93c61dc7648 100644 --- a/mysql-test/suite/innodb/t/foreign_key.test +++ b/mysql-test/suite/innodb/t/foreign_key.test @@ -102,7 +102,41 @@ INSERT INTO t2 VALUES (1); SELECT unique_constraint_name FROM information_schema.referential_constraints WHERE table_name = 't2'; +--echo # +--echo # MDEV-28317 Assertion failure on rollback of FOREIGN KEY operation +--echo # + +SET foreign_key_checks=0; +CREATE TABLE parent(a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE child(a INT,FOREIGN KEY(a) REFERENCES parent(a) ON DELETE CASCADE) +ENGINE=InnoDB; +INSERT INTO child VALUES(1); +ALTER TABLE child DROP INDEX a; + +connect(incomplete, localhost, root,,); +BEGIN; +DELETE FROM child; + +connection default; +INSERT INTO parent SET a=0; +FLUSH TABLES; + +--let $shutdown_timeout=0 --source include/restart_mysqld.inc +--let $shutdown_timeout= +disconnect incomplete; + +INSERT INTO child SET a=0; +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO child SET a=1; +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM parent; +ALTER TABLE child ADD INDEX(a); +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM parent; +ALTER TABLE child FORCE; +DELETE FROM parent; +DROP TABLE child,parent; SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; diff --git a/mysql-test/suite/innodb/t/gap_lock_split.test b/mysql-test/suite/innodb/t/gap_lock_split.test new file mode 100644 index 00000000000..462f073ddce --- /dev/null +++ b/mysql-test/suite/innodb/t/gap_lock_split.test @@ -0,0 +1,39 @@ +--source include/have_innodb.inc +--source include/have_sequence.inc +--source include/have_debug.inc + +SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency=1; + +CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000)) ENGINE=InnoDB; +INSERT INTO t1 (id,val) SELECT 2*seq,'x' FROM seq_0_to_1023; + +connect(con1,localhost,root,,); +# Prevent purge. +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; + +DELETE FROM t1 WHERE id=1788; + +BEGIN; +# This will return no result, but should acquire a gap lock. +SELECT * FROM t1 WHERE id=1788 FOR UPDATE; + +connection con1; +COMMIT; +source include/wait_all_purged.inc; +connection default; + +INSERT INTO t1 (id,val) VALUES (1787, REPEAT('x',2000)); + +connection con1; +SET innodb_lock_wait_timeout=0; +--error ER_LOCK_WAIT_TIMEOUT +INSERT INTO t1 (id,val) VALUES (1788, 'x'); +SELECT * FROM t1 WHERE id=1788 FOR UPDATE; +disconnect con1; + +connection default; +COMMIT; +DROP TABLE t1; +SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/mysql-test/suite/innodb/t/import_bugs.test b/mysql-test/suite/innodb/t/import_bugs.test index 9898d11fc80..7fcab9f9abc 100644 --- a/mysql-test/suite/innodb/t/import_bugs.test +++ b/mysql-test/suite/innodb/t/import_bugs.test @@ -14,16 +14,22 @@ let $datadir=`select @@datadir`; UNLOCK TABLES; --error ER_TABLE_SCHEMA_MISMATCH ALTER TABLE imp_t1 IMPORT TABLESPACE; +--error ER_TABLE_EXISTS_ERROR +CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +DROP TABLE imp_t1; +CREATE TABLE imp_t1 (a INT PRIMARY KEY) ENGINE=InnoDB; DROP TABLE imp_t1, t1; ---remove_file $datadir/test/imp_t1.ibd SET GLOBAL innodb_checksum_algorithm=@save_innodb_checksum_algorithm; --echo # ---echo # MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' --echo # failed in dberr_t row_discard_tablespace_for_mysql +--echo # MDEV-27006 Assertion `!lock_trx_has_sys_table_locks(trx)' +--echo # failed in dberr_t row_discard_tablespace_for_mysql --echo # (dict_table_t*, trx_t*) CREATE TABLE t1 (c INT KEY) ENGINE=INNODB; CREATE TABLE t2 (c INT KEY,FOREIGN KEY(c) REFERENCES t1 (c)) ENGINE=INNODB; --error ER_ROW_IS_REFERENCED_2 ALTER TABLE t1 DISCARD TABLESPACE; DROP TABLE t2, t1; + +--echo # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/import_corrupted.test b/mysql-test/suite/innodb/t/import_corrupted.test index 016b71041f1..3a9b9a40493 100644 --- a/mysql-test/suite/innodb/t/import_corrupted.test +++ b/mysql-test/suite/innodb/t/import_corrupted.test @@ -56,14 +56,10 @@ CREATE TABLE t2 ( ALTER TABLE t2 DISCARD TABLESPACE; ---copy_file $MYSQLD_DATADIR/test/tmp.ibd $MYSQLD_DATADIR/test/t2.ibd ---copy_file $MYSQLD_DATADIR/test/tmp.cfg $MYSQLD_DATADIR/test/t2.cfg +--move_file $MYSQLD_DATADIR/test/tmp.ibd $MYSQLD_DATADIR/test/t2.ibd +--move_file $MYSQLD_DATADIR/test/tmp.cfg $MYSQLD_DATADIR/test/t2.cfg --error ER_NOT_KEYFILE ALTER TABLE t2 IMPORT TABLESPACE; DROP TABLE t2; - ---remove_file $MYSQLD_DATADIR/test/t2.ibd ---remove_file $MYSQLD_DATADIR/test/tmp.ibd ---remove_file $MYSQLD_DATADIR/test/tmp.cfg diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test index 2241ef5d295..c4a68ac71b7 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-debug.test +++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test @@ -180,7 +180,7 @@ DROP TABLE t1; CREATE TABLE t1(a INT PRIMARY KEY, b INT, INDEX(b)) ENGINE=InnoDB; SET @save_dbug=@@debug_dbug; -SET debug_dbug='+d,innodb_table_deadlock'; +SET debug_dbug='+d,deadlock_table_fail'; --error ER_LOCK_DEADLOCK ALTER TABLE t1 DROP INDEX b, ALGORITHM=INPLACE; SET debug_dbug=@save_dbug; diff --git a/mysql-test/suite/innodb/t/innodb-autoinc-part.test b/mysql-test/suite/innodb/t/innodb-autoinc-part.test new file mode 100644 index 00000000000..100546704ce --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-autoinc-part.test @@ -0,0 +1,24 @@ +--source include/have_partition.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued +--echo # + +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; + +CREATE TABLE t1 (a SERIAL) ENGINE=innodb +PARTITION BY RANGE (a) ( + PARTITION p0 VALUES LESS THAN (6), + PARTITION p1 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +--error HA_ERR_AUTOINC_ERANGE +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET auto_increment_increment=@aii; + +--echo # End of 10.2 tests diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index ca7727d4cef..158460558d5 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -1,10 +1,4 @@ --source include/have_innodb.inc -# embedded server ignores 'delayed', so skip this --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings # # Bug #34335 @@ -770,3 +764,20 @@ DROP TABLE t1; SET @engine='INNODB'; --source include/autoinc_mdev15353.inc + +--echo # +--echo # MDEV-28416 Incorrect AUTO_INCREMENT may be issued +--echo # + +SET @aii=@@auto_increment_increment; +SET auto_increment_increment=300; +CREATE TABLE t1 (a SERIAL) ENGINE=innodb; +INSERT INTO t1 VALUES (18446744073709551613); +SHOW CREATE TABLE t1; +--error HA_ERR_AUTOINC_ERANGE +INSERT INTO t1 VALUES (NULL); +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET auto_increment_increment=@aii; + +--echo # End of 10.2 tests diff --git a/mysql-test/suite/innodb/t/innodb-wl5522.test b/mysql-test/suite/innodb/t/innodb-wl5522.test index 80d987fb87f..19652d8e8fd 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522.test @@ -98,10 +98,6 @@ if ($checksum_algorithm == "strict_full_crc32") { ALTER TABLE t2 IMPORT TABLESPACE; DROP TABLE t2; -if ($error_code) { ---remove_file $MYSQLD_DATADIR/test/t2.ibd -} - SET GLOBAL innodb_file_per_table = 1; SELECT @@innodb_file_per_table; @@ -1102,7 +1098,6 @@ DROP TABLE t1, t2; CREATE TABLE t1 ( id INT NOT NULL, i1 INT, i2 INT, PRIMARY KEY (id)) engine=innodb; ---remove_file $MYSQLD_DATADIR/test/t2.ibd CREATE TABLE t2 ( id INT NOT NULL, i1 INT, i2 INT, i3 INT, PRIMARY KEY (id)) engine=innodb; ALTER TABLE t2 DISCARD TABLESPACE; @@ -1114,18 +1109,9 @@ FLUSH TABLES t1 FOR EXPORT; UNLOCK TABLES; --error ER_TABLE_SCHEMA_MISMATCH ALTER TABLE t2 IMPORT TABLESPACE; - ---remove_file $MYSQLD_DATADIR/test/t2.ibd ---remove_file $MYSQLD_DATADIR/test/t2.cfg - - DROP TABLE t1, t2; call mtr.add_suppression("Got error -1 when reading table '.*'"); call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'"); call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded"); - -# cleanup ---remove_file $MYSQLTEST_VARDIR/tmp/t1.cfg ---remove_file $MYSQLTEST_VARDIR/tmp/t1.ibd diff --git a/mysql-test/suite/innodb_gis/r/rtree_split.result b/mysql-test/suite/innodb_gis/r/rtree_split.result index 2d6e8a1dfbe..df88960ba3d 100644 --- a/mysql-test/suite/innodb_gis/r/rtree_split.result +++ b/mysql-test/suite/innodb_gis/r/rtree_split.result @@ -61,10 +61,3 @@ select count(*) from t1 where MBRWithin(t1.c2, @g1); count(*) 57344 drop table t1; -# -# MDEV-27417 Spatial index tries to update -# change buffer bookkeeping page -# -CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB; -INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366; -DROP TABLE t1; diff --git a/mysql-test/suite/innodb_gis/r/rtree_temporary.result b/mysql-test/suite/innodb_gis/r/rtree_temporary.result new file mode 100644 index 00000000000..5ce02c881cc --- /dev/null +++ b/mysql-test/suite/innodb_gis/r/rtree_temporary.result @@ -0,0 +1,14 @@ +# +# MDEV-27417 Spatial index tries to update +# change buffer bookkeeping page +# +CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB; +INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366; +DROP TABLE t1; +# +# MDEV-28478 Assertion mtr->get_log_mode() == MTR_LOG_NO_REDO +# +CREATE TEMPORARY TABLE t1 (c POINT NOT NULL,SPATIAL (c)) ENGINE=InnoDB; +INSERT INTO t1 SELECT POINT(0,0) FROM seq_1_to_366; +INSERT INTO t1 VALUES (POINT(1e-270,1e-130)); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_gis/t/rtree_split.test b/mysql-test/suite/innodb_gis/t/rtree_split.test index 8697141ddea..6f285187508 100644 --- a/mysql-test/suite/innodb_gis/t/rtree_split.test +++ b/mysql-test/suite/innodb_gis/t/rtree_split.test @@ -73,11 +73,3 @@ select count(*) from t1 where MBRWithin(t1.c2, @g1); # Clean up. drop table t1; - ---echo # ---echo # MDEV-27417 Spatial index tries to update ---echo # change buffer bookkeeping page ---echo # -CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB; -INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366; -DROP TABLE t1; diff --git a/mysql-test/suite/innodb_gis/t/rtree_temporary.test b/mysql-test/suite/innodb_gis/t/rtree_temporary.test new file mode 100644 index 00000000000..5c4df251970 --- /dev/null +++ b/mysql-test/suite/innodb_gis/t/rtree_temporary.test @@ -0,0 +1,18 @@ +--source include/have_innodb.inc +--source include/have_sequence.inc + +--echo # +--echo # MDEV-27417 Spatial index tries to update +--echo # change buffer bookkeeping page +--echo # +CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB; +INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366; +DROP TABLE t1; + +--echo # +--echo # MDEV-28478 Assertion mtr->get_log_mode() == MTR_LOG_NO_REDO +--echo # +CREATE TEMPORARY TABLE t1 (c POINT NOT NULL,SPATIAL (c)) ENGINE=InnoDB; +INSERT INTO t1 SELECT POINT(0,0) FROM seq_1_to_366; +INSERT INTO t1 VALUES (POINT(1e-270,1e-130)); +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.result b/mysql-test/suite/mariabackup/compression_providers_unloaded.result index 10c06971ab4..ccf3e0355a4 100644 --- a/mysql-test/suite/mariabackup/compression_providers_unloaded.result +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.result @@ -1,5 +1,6 @@ call mtr.add_suppression("Background Page read failed to read, uncompress, or decrypt"); call mtr.add_suppression("Table is compressed or encrypted but uncompress or decrypt failed"); +call mtr.add_suppression("Refusing to load corrupted table"); # # Testing mariabackup with bzip2 compression # diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.test b/mysql-test/suite/mariabackup/compression_providers_unloaded.test index 715ab4ae8c0..673c16d03cf 100644 --- a/mysql-test/suite/mariabackup/compression_providers_unloaded.test +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.test @@ -1,6 +1,7 @@ let $alg = $MTR_COMBINATIONS; call mtr.add_suppression("Background Page read failed to read, uncompress, or decrypt"); call mtr.add_suppression("Table is compressed or encrypted but uncompress or decrypt failed"); +call mtr.add_suppression("Refusing to load corrupted table"); if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'provider_$alg' and plugin_status='active'`) { diff --git a/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc new file mode 100644 index 00000000000..4a83c9c394e --- /dev/null +++ b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info.inc @@ -0,0 +1,14 @@ +--disable_query_log +--file_exists $targetdir/xtrabackup_slave_info +CREATE TEMPORARY TABLE tmp_slave_info(lineno SERIAL, line TEXT); +--replace_result $targetdir TARGETDIR +--eval LOAD DATA LOCAL INFILE '$targetdir/xtrabackup_slave_info' INTO TABLE tmp_slave_info (line); +SELECT + lineno, + regexp_replace( + regexp_replace(line, '(?<=MASTER_LOG_POS=)[0-9]+', '<NUM>'), + '[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>') + AS line +FROM tmp_slave_info ORDER BY lineno; +DROP TEMPORARY TABLE tmp_slave_info; +--enable_query_log diff --git a/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc new file mode 100644 index 00000000000..90b2d00b61d --- /dev/null +++ b/mysql-test/suite/mariabackup/include/show_xtrabackup_slave_info_out.inc @@ -0,0 +1,20 @@ +--disable_query_log +--file_exists $XTRABACKUP_OUT +CREATE TEMPORARY TABLE tmp_slave_info_out(lineno SERIAL, line TEXT); +--replace_result $targetdir TARGETDIR +--eval LOAD DATA LOCAL INFILE '$XTRABACKUP_OUT' INTO TABLE tmp_slave_info_out (line); +SELECT + replace( + regexp_replace( + regexp_replace(line, + '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]', + 'YYYY-MM-DD hh:mm:ss'), + '[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>'), + '\r','' /* Remove CR on Windows */) + AS line +FROM tmp_slave_info_out +WHERE line LIKE '%MySQL slave binlog position%' + OR line LIKE '%Failed to get master binlog coordinates%' +ORDER BY lineno; +DROP TEMPORARY TABLE tmp_slave_info_out; +--enable_query_log diff --git a/mysql-test/suite/mariabackup/incremental_backup.test b/mysql-test/suite/mariabackup/incremental_backup.test index 62cdf9e6cb3..ec38af4c27d 100644 --- a/mysql-test/suite/mariabackup/incremental_backup.test +++ b/mysql-test/suite/mariabackup/incremental_backup.test @@ -8,6 +8,7 @@ if (`select @@max_binlog_stmt_cache_size = 4294963200 and @@innodb_page_size = 6 call mtr.add_suppression("InnoDB: New log files created"); +let $test_comp=`select @@innodb_page_size < 32768`; let basedir=$MYSQLTEST_VARDIR/tmp/backup; let incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1; @@ -16,6 +17,14 @@ CREATE TABLE t(i INT PRIMARY KEY) ENGINE INNODB; # MDEV-515 takes X-lock on the table for the first insert. # So concurrent insert won't happen on the table INSERT INTO t VALUES(100); +if ($test_comp) { + # If MDEV-28474 is not fixed, backup preparing will crash with SIGSEGV. + --disable_query_log + --disable_result_log + CREATE TABLE t_comp(i INT PRIMARY KEY) ENGINE INNODB ROW_FORMAT=COMPRESSED; + --enable_query_log + --enable_result_log +} BEGIN; INSERT INTO t VALUES(2); connect (con1,localhost,root,,); @@ -99,6 +108,13 @@ let $targetdir=$basedir; SELECT * FROM t; DROP TABLE t; +if ($test_comp) { + --disable_query_log + --disable_result_log + DROP TABLE t_comp; + --enable_query_log + --enable_result_log +} DROP TABLE t_aria; # Cleanup diff --git a/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.result b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.result new file mode 100644 index 00000000000..e3f8bb245e7 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.result @@ -0,0 +1,18 @@ +call mtr.add_suppression("InnoDB: New log files created"); +CREATE TABLE t1 (i INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); +CREATE DATABASE test1; +CREATE TABLE test1.t1 (a INT) ENGINE=InnoDB; +INSERT INTO test1.t1 VALUES (1000); +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +i +0 +SELECT * FROM test1.t1; +a +1000 +DROP TABLE t1; +DROP DATABASE test1; diff --git a/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.test b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.test new file mode 100644 index 00000000000..a79d280b668 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_backup_newdb_before_inc.test @@ -0,0 +1,35 @@ +--source include/have_innodb.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 t1 (i INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES(0); + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=10 --target-dir=$basedir +--enable_result_log + +CREATE DATABASE test1; +CREATE TABLE test1.t1 (a INT) ENGINE=InnoDB; +INSERT INTO test1.t1 VALUES (1000); + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --parallel=2 --ftwrl-wait-timeout=5 --ftwrl-wait-threshold=300 --ftwrl-wait-query-type=all --target-dir=$incremental_dir --incremental-basedir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir +--exec $XTRABACKUP --prepare --target-dir=$basedir --incremental-dir=$incremental_dir +--enable_result_log + +--let $targetdir=$basedir +--source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t1; +SELECT * FROM test1.t1; + +DROP TABLE t1; +DROP DATABASE test1; +--rmdir $basedir +--rmdir $incremental_dir diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result new file mode 100644 index 00000000000..ac74893d2cf --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.result @@ -0,0 +1,24 @@ +call mtr.add_suppression("InnoDB: New log files created"); +# +# Start of 10.2 tests +# +# +# MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken +# +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; +# Prepare full backup, apply incremental one +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT COUNT(*) FROM test.t1; +COUNT(*) +0 +SELECT COUNT(*) FROM test1.t1; +COUNT(*) +10000 +DROP TABLE t1; +DROP DATABASE test1; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test new file mode 100644 index 00000000000..c4695edb845 --- /dev/null +++ b/mysql-test/suite/mariabackup/incremental_newdb_while_backup.test @@ -0,0 +1,47 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +call mtr.add_suppression("InnoDB: New log files created"); + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-28446 mariabackup prepare fails for incrementals if a new schema is created after full backup is taken +--echo # + +--let $basedir=$MYSQLTEST_VARDIR/tmp/backup +--let $incremental_dir=$MYSQLTEST_VARDIR/tmp/backup_inc1 + +CREATE TABLE t1(i INT PRIMARY KEY) ENGINE INNODB; + +--disable_result_log +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir +--enable_result_log + +--let after_load_tablespaces=BEGIN NOT ATOMIC CREATE DATABASE test1; CREATE TABLE test1.t1 ENGINE=INNODB SELECT UUID() from test.seq_1_to_10000; END + +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$incremental_dir --incremental-basedir=$basedir --dbug=+d,mariabackup_events,mariabackup_inject_code +--let after_load_tablespaces= +--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 +--enable_result_log + +--let $targetdir=$basedir +--source include/restart_and_restore.inc +--enable_result_log + +SELECT COUNT(*) FROM test.t1; +SELECT COUNT(*) FROM test1.t1; + +DROP TABLE t1; +DROP DATABASE test1; +--rmdir $basedir +--rmdir $incremental_dir + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/mariabackup/rpl_slave_info.result b/mysql-test/suite/mariabackup/rpl_slave_info.result index 13044fd6c39..ec27166ecfb 100644 --- a/mysql-test/suite/mariabackup/rpl_slave_info.result +++ b/mysql-test/suite/mariabackup/rpl_slave_info.result @@ -13,6 +13,9 @@ connection slave; "using_gtid: Slave_Pos" FOUND 1 /gtid_slave_pos/ in xtrabackup_slave_info NOT FOUND /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; ############### # If Using_Gtid != 'No' and !gtid_slave_pos, backup master position ######################## @@ -20,6 +23,8 @@ include/stop_slave.inc SET GLOBAL gtid_slave_pos=""; NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>; ############### # If Using_Gtid == 'No', backup Exec_Master_Log_Pos ######################## @@ -31,6 +36,8 @@ connection slave; "using_gtid: No" NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>; connection master; DROP TABLE t; connection slave; diff --git a/mysql-test/suite/mariabackup/rpl_slave_info.test b/mysql-test/suite/mariabackup/rpl_slave_info.test index ca7682d8af9..1c5dd89acc9 100644 --- a/mysql-test/suite/mariabackup/rpl_slave_info.test +++ b/mysql-test/suite/mariabackup/rpl_slave_info.test @@ -27,6 +27,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=MASTER_LOG_FILE --source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc rmdir $targetdir; @@ -35,7 +36,9 @@ rmdir $targetdir; --echo ######################## --source include/stop_slave.inc +--disable_warnings SET GLOBAL gtid_slave_pos=""; +--enable_warnings --let $targetdir=$MYSQLTEST_VARDIR/tmp/backup --disable_result_log @@ -47,6 +50,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=MASTER_LOG_FILE --source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc rmdir $targetdir; @@ -74,6 +78,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi --source include/search_pattern_in_file.inc --let SEARCH_PATTERN=MASTER_LOG_FILE --source include/search_pattern_in_file.inc +--source include/show_xtrabackup_slave_info.inc rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/slave_info_norpl.result b/mysql-test/suite/mariabackup/slave_info_norpl.result new file mode 100644 index 00000000000..9fcd67a8916 --- /dev/null +++ b/mysql-test/suite/mariabackup/slave_info_norpl.result @@ -0,0 +1,59 @@ +# +# Start of 10.2 tests +# +# +# MDEV-21037 mariabackup does not detect multi-source replication slave +# +SELECT @@global.gtid_slave_pos; +@@global.gtid_slave_pos + + +# Without any masters the file xtrabackup_slave_info is not created +line +[00] YYYY-MM-DD hh:mm:ss Failed to get master binlog coordinates from SHOW SLAVE STATUS.This means that the server is not a replication slave. Ignoring the --slave-info option + +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000; +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0' + +CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002; +lineno line +1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +2 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0'; master 'master2' filename '' position '0' + +SET GLOBAL gtid_slave_pos='1-1-1,2-2-2'; +CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos; +CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no; +CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos; +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; +2 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +3 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos; +5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' filename '' position '0'; master 'master2' filename '' position '0'; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos + +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos; +lineno line +1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; +2 CHANGE MASTER TO master_use_gtid = slave_pos; +3 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos; +5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>; +6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos; +line +[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' master_use_gtid = slave_pos; master 'master2' filename '' position '0'; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos +RESET SLAVE ALL; +RESET SLAVE 'master2' ALL; +RESET SLAVE 'master3' ALL; +RESET SLAVE 'master4' ALL; +RESET SLAVE 'master5' ALL; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/mariabackup/slave_info_norpl.test b/mysql-test/suite/mariabackup/slave_info_norpl.test new file mode 100644 index 00000000000..0d2d2ed4861 --- /dev/null +++ b/mysql-test/suite/mariabackup/slave_info_norpl.test @@ -0,0 +1,86 @@ +# +# "mariabackup --slave-info" tests that can be run without +# actually starting the replication. +# + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-21037 mariabackup does not detect multi-source replication slave +--echo # + +--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup +--let $XTRABACKUP_ARGS=--defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --databases=test --target-dir=$targetdir +--let $XTRABACKUP_OUT=$MYSQLTEST_VARDIR/tmp/xtrabackup_out + +# Should be empty by default +SELECT @@global.gtid_slave_pos; + +--echo +--echo # Without any masters the file xtrabackup_slave_info is not created + +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--error 1 +--file_exists $targetdir/xtrabackup_slave_info +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +SET GLOBAL gtid_slave_pos='1-1-1,2-2-2'; +CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos; +CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no; +CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos; + +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +--echo +CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos; +--disable_result_log +exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT; +--enable_result_log +--source include/show_xtrabackup_slave_info.inc +--source include/show_xtrabackup_slave_info_out.inc +--remove_file $XTRABACKUP_OUT +rmdir $targetdir; + +RESET SLAVE ALL; +RESET SLAVE 'master2' ALL; +RESET SLAVE 'master3' ALL; +RESET SLAVE 'master4' ALL; +RESET SLAVE 'master5' ALL; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/parts/inc/part_alter_values.inc b/mysql-test/suite/parts/inc/part_alter_values.inc index 2f16476c78b..ca18faa5758 100644 --- a/mysql-test/suite/parts/inc/part_alter_values.inc +++ b/mysql-test/suite/parts/inc/part_alter_values.inc @@ -1,3 +1,5 @@ +--source include/have_symlink.inc + --echo # --echo # MDEV-14641 Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine --echo # diff --git a/mysql-test/suite/parts/t/partition_alter_myisam.test b/mysql-test/suite/parts/t/partition_alter_myisam.test index 326cf52b018..d3abb8842e1 100644 --- a/mysql-test/suite/parts/t/partition_alter_myisam.test +++ b/mysql-test/suite/parts/t/partition_alter_myisam.test @@ -1,5 +1,4 @@ --source include/have_partition.inc ---source include/have_symlink.inc --let $engine=MyISAM --source inc/part_alter_values.inc diff --git a/mysql-test/suite/perfschema/include/socket_ipv6.inc b/mysql-test/suite/perfschema/include/socket_ipv6.inc index dd077a12c7a..0c9f47abe47 100644 --- a/mysql-test/suite/perfschema/include/socket_ipv6.inc +++ b/mysql-test/suite/perfschema/include/socket_ipv6.inc @@ -20,6 +20,7 @@ let $check_ipv6_just_check= 1; #============================================================================== --disable_query_log --disable_result_log +--disable_connect_log --disable_abort_on_error let $check_ipv6_supported= 1; @@ -44,6 +45,7 @@ if(!$mysql_errno) connection default; --enable_abort_on_error +--enable_connect_log --enable_result_log --enable_query_log @@ -62,6 +64,7 @@ let $check_ipv4_mapped_just_check= 1; #============================================================================== --disable_query_log --disable_result_log +--disable_connect_log --disable_abort_on_error let $check_ipv4_mapped_supported= 1; @@ -86,6 +89,7 @@ if(!$mysql_errno) connection default; --enable_abort_on_error +--enable_connect_log --enable_result_log --enable_query_log diff --git a/mysql-test/suite/perfschema/r/digest_view.result b/mysql-test/suite/perfschema/r/digest_view.result index b2c908109e6..a5996cc0083 100644 --- a/mysql-test/suite/perfschema/r/digest_view.result +++ b/mysql-test/suite/perfschema/r/digest_view.result @@ -191,17 +191,17 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR -test 325a5266eeb07f609043730630a54f62 EXPLAIN SELECT * FROM `test` . `v1` 1 -test e860d6b0816b2b4854badd34fbbd6207 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1 -test d162188aba15f30fbad441adcd8d96af EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1 -test b22e464e9cc580f0e67bfdd65f11402b EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1 -test ccb1e6631108bba01e42d1755e32399d EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1 -test ef05c6bd2efecfe1635b58ffc118cabd SELECT * FROM `test` . `v1` 1 -test 7755326c5700a225c95f470c1a909f21 SELECT * FROM `test` . `v1` WHERE `a` = ? 1 -test aa8bcfc412f56c41fbe6161b2a3a971c SELECT * FROM `test` . `v1` WHERE `b` > ? 1 -test 5ea7548b0f49730b2c419ff6a94a3f09 SELECT `a` , `b` FROM `test` . `v1` 1 -test 30756ef4e5a36c461ba9bdce676b9811 SELECT `b` , `a` FROM `test` . `v1` 1 -test 61e13f96828d862446f5e8ee1cade61d TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 +test 27a9ab161a63050c84a63c6f77ebeb33 EXPLAIN SELECT * FROM `test` . `v1` 1 +test ab0ab27c04f3a294feb86bede4331f86 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1 +test 2e722346a5c2ef820946bcd04ccac208 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1 +test 07baf2264db30b6b25302603436ebe82 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1 +test 3a7dbc963635ab0de6e160e0a4212bce EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1 +test 6b845c2e3a7421997e3b610d14b5c842 SELECT * FROM `test` . `v1` 1 +test cb2ee099edbf6e0e5ee6ae14f3b1498a SELECT * FROM `test` . `v1` WHERE `a` = ? 1 +test e2dc5a300d2ba54ebb987a2ca6b90d93 SELECT * FROM `test` . `v1` WHERE `b` > ? 1 +test c68e0f99323f7bb7732c7b5cf32c0ec2 SELECT `a` , `b` FROM `test` . `v1` 1 +test 43c5de955c9a72d2bb6f49db5c0ad3e7 SELECT `b` , `a` FROM `test` . `v1` 1 +test 1678258ba15f7ccc63fd7b833763914a TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 DROP TABLE test.v1; CREATE VIEW test.v1 AS SELECT * FROM test.t1; EXPLAIN SELECT * from test.v1; @@ -248,19 +248,19 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR -test 04aae3c6f9b3d3394fbea32dd201320a CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1 -test e551faf16ae3ffe7aeb6d923c8f97452 DROP TABLE `test` . `v1` 1 -test 325a5266eeb07f609043730630a54f62 EXPLAIN SELECT * FROM `test` . `v1` 2 -test e860d6b0816b2b4854badd34fbbd6207 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2 -test d162188aba15f30fbad441adcd8d96af EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2 -test b22e464e9cc580f0e67bfdd65f11402b EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2 -test ccb1e6631108bba01e42d1755e32399d EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2 -test ef05c6bd2efecfe1635b58ffc118cabd SELECT * FROM `test` . `v1` 2 -test 7755326c5700a225c95f470c1a909f21 SELECT * FROM `test` . `v1` WHERE `a` = ? 2 -test aa8bcfc412f56c41fbe6161b2a3a971c SELECT * FROM `test` . `v1` WHERE `b` > ? 2 -test 9b3c3d8a2f8b2d9775f9d87d0932e5b5 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1 -test 5ea7548b0f49730b2c419ff6a94a3f09 SELECT `a` , `b` FROM `test` . `v1` 2 -test 30756ef4e5a36c461ba9bdce676b9811 SELECT `b` , `a` FROM `test` . `v1` 2 -test 61e13f96828d862446f5e8ee1cade61d TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 +test 342cd5e41944d5f857f92b1e374857de CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1 +test 2653f30030efcb6125121daa8eadf418 DROP TABLE `test` . `v1` 1 +test 27a9ab161a63050c84a63c6f77ebeb33 EXPLAIN SELECT * FROM `test` . `v1` 2 +test ab0ab27c04f3a294feb86bede4331f86 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2 +test 2e722346a5c2ef820946bcd04ccac208 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2 +test 07baf2264db30b6b25302603436ebe82 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2 +test 3a7dbc963635ab0de6e160e0a4212bce EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2 +test 6b845c2e3a7421997e3b610d14b5c842 SELECT * FROM `test` . `v1` 2 +test cb2ee099edbf6e0e5ee6ae14f3b1498a SELECT * FROM `test` . `v1` WHERE `a` = ? 2 +test e2dc5a300d2ba54ebb987a2ca6b90d93 SELECT * FROM `test` . `v1` WHERE `b` > ? 2 +test a13cfeda6d474d29546719d76dcfa831 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1 +test c68e0f99323f7bb7732c7b5cf32c0ec2 SELECT `a` , `b` FROM `test` . `v1` 2 +test 43c5de955c9a72d2bb6f49db5c0ad3e7 SELECT `b` , `a` FROM `test` . `v1` 2 +test 1678258ba15f7ccc63fd7b833763914a TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 DROP VIEW test.v1; DROP TABLE test.t1; diff --git a/mysql-test/suite/perfschema/r/misc.result b/mysql-test/suite/perfschema/r/misc.result index 83ca6d5cf3f..b1fa4f6c765 100644 --- a/mysql-test/suite/perfschema/r/misc.result +++ b/mysql-test/suite/perfschema/r/misc.result @@ -174,3 +174,16 @@ select object_type, object_schema, object_name from performance_schema.objects_summary_global_by_type where object_schema="test"; object_type object_schema object_name +# +# MDEV-28344: sys.ps_setup_save and dependent procedures fail +# with ER_ILLEGAL_HA_CREATE_OPTION +# +CREATE TEMPORARY TABLE t1 (t int) ENGINE = PERFORMANCE_SCHEMA; +ERROR HY000: Table storage engine 'PERFORMANCE_SCHEMA' does not support the create option 'TEMPORARY' +CREATE TEMPORARY TABLE t1 LIKE performance_schema.setup_actors; +ERROR HY000: Table storage engine 'PERFORMANCE_SCHEMA' does not support the create option 'TEMPORARY' +SET @default_storage_engine_old = @@default_storage_engine; +SET default_storage_engine = performance_schema; +CREATE TEMPORARY TABLE t1 (t int); +ERROR HY000: Table storage engine 'PERFORMANCE_SCHEMA' does not support the create option 'TEMPORARY' +SET @@default_storage_engine = @default_storage_engine_old; diff --git a/mysql-test/suite/perfschema/r/socket_connect.result b/mysql-test/suite/perfschema/r/socket_connect.result index b33ee6f2951..5de362bf370 100644 --- a/mysql-test/suite/perfschema/r/socket_connect.result +++ b/mysql-test/suite/perfschema/r/socket_connect.result @@ -1,7 +1,6 @@ #============================================================================== # Establish the level of IPV6 support #============================================================================== -connection default; #============================================================================== # Get hostname, port number #============================================================================== diff --git a/mysql-test/suite/perfschema/r/socket_summary_by_event_name_func.result b/mysql-test/suite/perfschema/r/socket_summary_by_event_name_func.result index 01e374ed94f..611038f886e 100644 --- a/mysql-test/suite/perfschema/r/socket_summary_by_event_name_func.result +++ b/mysql-test/suite/perfschema/r/socket_summary_by_event_name_func.result @@ -1,7 +1,6 @@ #============================================================================== # Establish the level of IPV6 support #============================================================================== -connection default; #============================================================================== # Get hostname, port number #============================================================================== diff --git a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result index 864374be5af..13b51569b60 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result +++ b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result @@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 #################################### SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long; event_name digest digest_text sql_text -statement/sql/select ca9181d6d668396d467dd974f58a9402 SELECT ? + ? + SELECT ... -statement/sql/truncate 460cb5329baea0e4242059cfda01d1d7 TRUNCATE TABLE truncat... +statement/sql/select 1fd0cdb6b5aa22bd0809a39b2dc2ac70 SELECT ? + ? + SELECT ... +statement/sql/truncate 0a9c405cebde6df4be315dae86ff398a TRUNCATE TABLE truncat... diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test index 848be3beea1..79c23c65616 100644 --- a/mysql-test/suite/perfschema/t/misc.test +++ b/mysql-test/suite/perfschema/t/misc.test @@ -298,3 +298,23 @@ drop tables t1; select object_type, object_schema, object_name from performance_schema.objects_summary_global_by_type where object_schema="test"; + +--echo # +--echo # MDEV-28344: sys.ps_setup_save and dependent procedures fail +--echo # with ER_ILLEGAL_HA_CREATE_OPTION +--echo # + +# It is not allowed to create temporary tables with performance schema +--error ER_ILLEGAL_HA_CREATE_OPTION +CREATE TEMPORARY TABLE t1 (t int) ENGINE = PERFORMANCE_SCHEMA; + +--error ER_ILLEGAL_HA_CREATE_OPTION +CREATE TEMPORARY TABLE t1 LIKE performance_schema.setup_actors; + +SET @default_storage_engine_old = @@default_storage_engine; +SET default_storage_engine = performance_schema; + +--error ER_ILLEGAL_HA_CREATE_OPTION +CREATE TEMPORARY TABLE t1 (t int); + +SET @@default_storage_engine = @default_storage_engine_old;
\ No newline at end of file diff --git a/mysql-test/suite/plugins/r/multiauth,aix.rdiff b/mysql-test/suite/plugins/r/multiauth,aix.rdiff deleted file mode 100644 index 0a2570cbd89..00000000000 --- a/mysql-test/suite/plugins/r/multiauth,aix.rdiff +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/mysql-test/suite/plugins/r/multiauth.result b/mysql-test/suite/plugins/r/multiauth.result -index aed46ac8964..24bb0a24f03 100644 ---- a/mysql-test/suite/plugins/r/multiauth.result -+++ b/mysql-test/suite/plugins/r/multiauth.result -@@ -181,7 +181,8 @@ show create user mysqltest1; - CREATE USER for mysqltest1@% - CREATE USER `mysqltest1`@`%` IDENTIFIED VIA ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' - # no plugin = failure --mysqltest: Could not open connection 'default': 1045 Plugin client_ed25519 could not be loaded: <PLUGINDIR>/no/client_ed25519.so: cannot open shared object file: No such file or directory -+mysqltest: Could not open connection 'default': 1045 Plugin client_ed25519 could not be loaded: Could not load module <PLUGINDIR>/no/client_ed25519.so. -+System error: No such file or directory - alter user mysqltest1 identified via ed25519 as password("good") OR mysql_native_password as password("works"); - show create user mysqltest1; - CREATE USER for mysqltest1@% diff --git a/mysql-test/suite/plugins/r/multiauth.result b/mysql-test/suite/plugins/r/multiauth.result index 8ae45d1fb9f..73241619008 100644 --- a/mysql-test/suite/plugins/r/multiauth.result +++ b/mysql-test/suite/plugins/r/multiauth.result @@ -181,7 +181,7 @@ show create user mysqltest1; CREATE USER for mysqltest1@% CREATE USER `mysqltest1`@`%` IDENTIFIED VIA ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' # no plugin = failure -mysqltest: Could not open connection 'default': 1045 Plugin client_ed25519 could not be loaded: <PLUGINDIR>/no/client_ed25519.so: cannot open shared object file: No such file or directory +mysqltest: Could not open connection 'default': 1045 Plugin client_ed25519 could not be loaded: no such file alter user mysqltest1 identified via ed25519 as password("good") OR mysql_native_password as password("works"); show create user mysqltest1; CREATE USER for mysqltest1@% diff --git a/mysql-test/suite/plugins/t/multiauth.test b/mysql-test/suite/plugins/t/multiauth.test index f0eea21ee76..86c98a5d5c3 100644 --- a/mysql-test/suite/plugins/t/multiauth.test +++ b/mysql-test/suite/plugins/t/multiauth.test @@ -1,5 +1,4 @@ --source include/not_ubsan.inc ---source include/platform.inc let $REGEX_VERSION_ID=/$mysql_get_server_version/VERSION_ID/; let $REGEX_PASSWORD_LAST_CHANGED=/password_last_changed": [0-9]*/password_last_changed": #/; @@ -187,7 +186,8 @@ eval $dreplace, mysqltest1; create user mysqltest1 identified via ed25519 as password("good"); show create user mysqltest1; --echo # no plugin = failure ---replace_result $plugindir <PLUGINDIR> +# covers Linux (1st re), FreeBSD (2nd), AIX (3rd and 4th) +--replace_regex /loaded: .*client_ed25519.so: cannot open shared object file: No such file or directory/loaded: no such file/ /loaded: Cannot open.*client_ed25519.so./loaded: no such file/ /loaded: .*Could not load module.*client_ed25519.so.\n/loaded: no such file/ /System error: No such file or directory// --error 1 --exec $try_auth -u mysqltest1 -pgood --plugin-dir=$plugindir/no alter user mysqltest1 identified via ed25519 as password("good") OR mysql_native_password as password("works"); diff --git a/mysql-test/suite/roles/definer.result b/mysql-test/suite/roles/definer.result index 66c455625aa..a83a42a0c67 100644 --- a/mysql-test/suite/roles/definer.result +++ b/mysql-test/suite/roles/definer.result @@ -441,14 +441,14 @@ DELIMITER ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; DELIMITER ; /*!50106 SET TIME_ZONE= @save_time_zone */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`role1` FUNCTION `fn1`() RETURNS int(11) return (select sum(a+b) from t1) ;; @@ -457,14 +457,14 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`role2` FUNCTION `fn2`() RETURNS int(11) return (select sum(a+b) from t1) ;; @@ -473,14 +473,14 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`role3`@`%` FUNCTION `fn3`() RETURNS int(11) return (select sum(a+b) from t1) ;; @@ -489,14 +489,14 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`role1` PROCEDURE `pr1`() insert t1 values (111, 222, 333) ;; @@ -505,14 +505,14 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`role2`@`%` PROCEDURE `pr2`() insert t1 values (111, 222, 333) ;; @@ -521,14 +521,14 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = latin1 */ ; /*!50003 SET character_set_results = latin1 */ ; /*!50003 SET collation_connection = latin1_swedish_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`role3`@`%` PROCEDURE `pr3`() insert t1 values (111, 222, 333) ;; diff --git a/mysql-test/suite/rpl/include/rpl_parallel_deadlock_corrupt_binlog.inc b/mysql-test/suite/rpl/include/rpl_parallel_deadlock_corrupt_binlog.inc index 3a135ef5cc4..592ffd3b068 100644 --- a/mysql-test/suite/rpl/include/rpl_parallel_deadlock_corrupt_binlog.inc +++ b/mysql-test/suite/rpl/include/rpl_parallel_deadlock_corrupt_binlog.inc @@ -22,6 +22,7 @@ CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB; SET GLOBAL slave_parallel_threads=1; SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +CALL mtr.add_suppression("Unexpected break of being relay-logged GTID"); --connection server_1 INSERT INTO t2 VALUES (101); diff --git a/mysql-test/suite/rpl/include/rpl_ssl.inc b/mysql-test/suite/rpl/include/rpl_ssl.inc index aff5499c8e5..bd77f213ae1 100644 --- a/mysql-test/suite/rpl/include/rpl_ssl.inc +++ b/mysql-test/suite/rpl/include/rpl_ssl.inc @@ -37,7 +37,7 @@ select * from t1; # The slave is synced and waiting/reading from master # SHOW SLAVE STATUS will show "Waiting for master to send event" -let $status_items= Master_SSL_Allowed, Master_SSL_CA_Path, Master_SSL_CA_File, Master_SSL_Cert, Master_SSL_Key; +let $status_items= Master_SSL_Allowed, Master_SSL_CA_Path, Master_SSL_CA_File, Master_SSL_Crl, Master_SSL_Crlpath, Master_SSL_Cert, Master_SSL_Key; source include/show_slave_status.inc; source include/check_slave_is_running.inc; diff --git a/mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result b/mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result new file mode 100644 index 00000000000..f4d257c2668 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_glle_no_terminate.result @@ -0,0 +1,46 @@ +include/master-slave.inc +[connection master] +connection slave; +include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +# +# Initialize test data +connection master; +create table t1 (a int); +SET @@session.server_id= 3; +create table t2 (a int); +include/save_master_gtid.inc +# +# Have the replica "reconnect" and the primary will send Gtid, Glle, DDL +connection slave; +set global gtid_slave_pos="0-3-1"; +include/start_slave.inc +include/sync_with_master_gtid.inc +# +# Ensure that the replica did not error +connection slave; +include/sync_with_master_gtid.inc +Last_SQL_Error = +Last_SQL_Errno = 0 +# +# Ensure that the primary sent a Glle after a Gtid event +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +slave-relay-bin.000002 # Rotate # # master-bin.000001;pos=POS +slave-relay-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +slave-relay-bin.000002 # Gtid_list # # [] +slave-relay-bin.000002 # Binlog_checkpoint # # master-bin.000001 +slave-relay-bin.000002 # Gtid # # GTID #-#-# +slave-relay-bin.000002 # Gtid_list # # [#-#-#] +slave-relay-bin.000002 # Query # # use `test`; create table t2 (a int) +# +# Ensure the DDL was executed on the replica +# +# Cleanup +# t1 does not make it to the replica +connection master; +set sql_log_bin=0; +DROP TABLE t1; +set sql_log_bin=1; +DROP TABLE t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_gtid_grouping.result b/mysql-test/suite/rpl/r/rpl_gtid_grouping.result new file mode 100644 index 00000000000..ad7d6116c49 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_gtid_grouping.result @@ -0,0 +1,54 @@ +include/master-slave.inc +[connection master] +connection slave; +call mtr.add_suppression("Unexpected break of being relay-logged GTID 0-27697-1000"); +call mtr.add_suppression("Relay log write failure: could not queue event from master"); +call mtr.add_suppression("The current group of events starts with a non-GTID"); +include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +include/start_slave.inc +connection master; +CREATE TABLE t (a INT) ENGINE=innodb; +INSERT INTO t VALUES(1); +### A. Simulate an unnoticeable loss of Xid event +connection slave; +SET @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +connection master; +SET @@gtid_seq_no=1000; +set @@server_id=27697; +INSERT INTO t VALUES(1000); +set @@server_id=default; +INSERT INTO t VALUES(1001); +## Prove the error occurs. +connection slave; +include/wait_for_slave_io_error.inc [errno=1595] +## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +include/start_slave.inc +### B. Do the same to GTID event. +connection slave; +SET @@global.debug_dbug="+d,slave_discard_gtid_0_x_1002"; +connection master; +SET @@gtid_seq_no=1002; +set @@server_id=27697; +INSERT INTO t VALUES(1002); +set @@server_id=default; +INSERT INTO t VALUES(1003); +## Prove the error occurs. +connection slave; +include/wait_for_slave_io_error.inc [errno=1595] +## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +include/start_slave.inc +connection master; +connection slave; +include/diff_tables.inc [master:t,slave:t] +"===== Clean up =====" +connection slave; +include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=no; +include/start_slave.inc +connection master; +DROP TABLE t; +SET GLOBAL LOG_WARNINGS=default; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff b/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff new file mode 100644 index 00000000000..e31f1e5d991 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_iodku,stmt.rdiff @@ -0,0 +1,27 @@ +--- r/rpl_iodku.result 2022-05-04 18:51:24.956414404 +0300 ++++ r/rpl_iodku,stmt.reject 2022-05-04 18:51:49.520106231 +0300 +@@ -1,10 +1,15 @@ + include/master-slave.inc + [connection master] ++call mtr.add_suppression("Unsafe statement written to the binary log using statement"); + CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, a INT, b INT, c INT, + UNIQUE (a), UNIQUE (b)) ENGINE=innodb; + INSERT INTO t1 (`a`,`c`) VALUES (1,1), (2,1) ON DUPLICATE KEY UPDATE c = 1; ++Warnings: ++Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe + # UNSAFE + INSERT INTO t1 (`a`,`c`) VALUES (3, 1),(2,1), (1,1) ON DUPLICATE KEY UPDATE c = a * 10 + VALUES(c); ++Warnings: ++Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe + SELECT * from t1; + id a b c + 1 1 NULL 11 +@@ -17,6 +22,8 @@ + INSERT INTO t1 VALUES (1,10,1); + # eligable for the statement format run unsafe warning + INSERT INTO t1 VALUES (2,20,2) ON DUPLICATE KEY UPDATE c = 100; ++Warnings: ++Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe + # not eligable: no warning in the statement format run + INSERT INTO t1 (`a`,`c`) VALUES (3, 1) ON DUPLICATE KEY UPDATE c = 99; + SELECT * from t1; diff --git a/mysql-test/suite/rpl/r/rpl_iodku.result b/mysql-test/suite/rpl/r/rpl_iodku.result new file mode 100644 index 00000000000..55348da1439 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_iodku.result @@ -0,0 +1,32 @@ +include/master-slave.inc +[connection master] +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, a INT, b INT, c INT, +UNIQUE (a), UNIQUE (b)) ENGINE=innodb; +INSERT INTO t1 (`a`,`c`) VALUES (1,1), (2,1) ON DUPLICATE KEY UPDATE c = 1; +# UNSAFE +INSERT INTO t1 (`a`,`c`) VALUES (3, 1),(2,1), (1,1) ON DUPLICATE KEY UPDATE c = a * 10 + VALUES(c); +SELECT * from t1; +id a b c +1 1 NULL 11 +2 2 NULL 21 +3 3 NULL 1 +connection slave; +include/diff_tables.inc [master:t1,slave:t1] +connection master; +CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, UNIQUE (a), UNIQUE (b)) ENGINE=innodb; +INSERT INTO t1 VALUES (1,10,1); +# eligable for the statement format run unsafe warning +INSERT INTO t1 VALUES (2,20,2) ON DUPLICATE KEY UPDATE c = 100; +# not eligable: no warning in the statement format run +INSERT INTO t1 (`a`,`c`) VALUES (3, 1) ON DUPLICATE KEY UPDATE c = 99; +SELECT * from t1; +a b c +1 10 1 +2 20 2 +3 NULL 1 +connection slave; +include/diff_tables.inc [master:t1,slave:t1] +connection master; +DROP TABLE t1; +connection slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_mdev_17614.result b/mysql-test/suite/rpl/r/rpl_mdev_17614.result index 39057334926..ba077111522 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev_17614.result +++ b/mysql-test/suite/rpl/r/rpl_mdev_17614.result @@ -1,5 +1,6 @@ include/master-slave.inc [connection master] +# Case 1: UNSAFE call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY , b INT, UNIQUE(b), c int) engine=innodb; @@ -37,6 +38,7 @@ drop table t1; connection slave; start slave; include/wait_for_slave_to_start.inc +# Case 2: UNSAFE connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, UNIQUE(b), c int) engine=innodb; @@ -45,8 +47,12 @@ connection master; INSERT INTO t1 VALUES (default, 1, 1); BEGIN; INSERT INTO t1 VALUES (default, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe connection master1; INSERT INTO t1 VALUES(default, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe connection master; COMMIT; SELECT * FROM t1; @@ -62,6 +68,7 @@ a b c connection master; drop table t1; connection slave; +# Case 3A: UNSAFE connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, UNIQUE(b), c int, d int ) engine=innodb; @@ -93,6 +100,67 @@ a b c d connection master; drop table t1; connection slave; +# Case 3B: UNSAFE - all column specified. +connection master; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, +UNIQUE(b), c int, d int ) engine=innodb; +connection slave; +connection master; +INSERT INTO t1 VALUES (1, 1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, NULL, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe +connection master1; +INSERT INTO t1 VALUES(3, NULL, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe +connection master; +COMMIT; +SELECT * FROM t1; +a b c d +1 1 1 1 +2 NULL 2 2 +3 NULL 2 3 +connection slave; +#same data as master +SELECT * FROM t1; +a b c d +1 1 1 1 +2 NULL 2 2 +3 NULL 2 3 +connection master; +drop table t1; +connection slave; +# Case 3C: SAFE - only one unique key (PK) specified. +connection master; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, +UNIQUE(b), c int, d int ) engine=innodb; +connection slave; +connection master; +INSERT INTO t1 VALUES (1, 1, 1, 1); +BEGIN; +INSERT INTO t1 (`a`, `c`, `d`) VALUES (2, 2, 2) ON DUPLICATE KEY UPDATE c=99; +connection master1; +INSERT INTO t1 (`a`, `c`, `d`) VALUES(3, 2, 3) ON DUPLICATE KEY UPDATE c=100; +connection master; +COMMIT; +SELECT * FROM t1; +a b c d +1 1 1 1 +2 NULL 2 2 +3 NULL 2 3 +connection slave; +#same data as master +SELECT * FROM t1; +a b c d +1 1 1 1 +2 NULL 2 2 +3 NULL 2 3 +connection master; +drop table t1; +connection slave; +# Case 4: UNSAFE connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, UNIQUE(b), c int) engine=innodb; @@ -101,8 +169,12 @@ connection master; INSERT INTO t1 VALUES (1, 1, 1); BEGIN; INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe connection master1; INSERT INTO t1 VALUES(2, 2, 3) ON DUPLICATE KEY UPDATE b=VALUES(b), c=VALUES(c); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe connection master; COMMIT; SELECT * FROM t1; diff --git a/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result b/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result new file mode 100644 index 00000000000..1172d8e39a9 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_mysql_manager_race_condition.result @@ -0,0 +1,27 @@ +include/master-slave.inc +[connection master] +connection master; +# Create a GTID event so the binlog background thread will submit a +# mysql handler job the next time mysqld is restarted. +create table t1 (a int); +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +# Set a debug point that forces the main mysqld thread to sleep before +# anything is initialized for the mysql handle manager +# Restart the slave mysqld instance so it re-initializes with the +# binlog background thread submitting a mysql handler job and the +# mysql handler initialization suspending for a second. Without the fix +# associated with this test/patch, the following restart will error +# with a failed assertion. +include/rpl_restart_server.inc [server_number=2 parameters: --debug_dbug="+d,delay_start_handle_manager"] +include/start_slave.inc +# +# Cleanup +# +connection master; +drop table t1; +include/save_master_gtid.inc +connection slave; +include/sync_with_master_gtid.inc +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_parallel_deadlock_corrupt_binlog.result b/mysql-test/suite/rpl/r/rpl_parallel_deadlock_corrupt_binlog.result index 74d1d53b67c..f3203cfe8e6 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_deadlock_corrupt_binlog.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_deadlock_corrupt_binlog.result @@ -15,6 +15,7 @@ include/stop_slave.inc SET GLOBAL slave_parallel_threads=1; SET @old_dbug= @@GLOBAL.debug_dbug; SET GLOBAL debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; +CALL mtr.add_suppression("Unexpected break of being relay-logged GTID"); connection server_1; INSERT INTO t2 VALUES (101); INSERT INTO t2 VALUES (102); diff --git a/mysql-test/suite/rpl/r/rpl_parallel_temptable.result b/mysql-test/suite/rpl/r/rpl_parallel_temptable.result index 52efed22541..1a1c12f836d 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_temptable.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_temptable.result @@ -132,8 +132,13 @@ connection server_1; INSERT INTO t1 VALUES (0, 1); include/save_master_gtid.inc connection server_2; +set @@sql_log_bin=0; +call mtr.add_suppression("Unexpected break of being relay-logged GTID 1-1-32 event group by the current GTID event 0-1-4"); +set @@sql_log_bin=1; +set @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; include/start_slave.inc include/sync_with_master_gtid.inc +set @@global.debug_dbug=""; SELECT * FROM t1 ORDER BY a; a b 0 1 diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result b/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result new file mode 100644 index 00000000000..719b61b796b --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_shutdown_await_ack.result @@ -0,0 +1,517 @@ +############################# +# Common setup for all tests +############################# +# Note: Simulated slave delay is hardcoded to 800 milliseconds +# Note: Simulated master shutdown delay is hardcoded to 500 milliseconds +include/rpl_init.inc [topology=1->2, 1->3] +connection server_1; +# Slaves which simulate an error will produce a timeout on the primary +call mtr.add_suppression("Timeout waiting"); +call mtr.add_suppression("did not exit"); +# Suppress slave errors related to the simulated error +connection server_2; +call mtr.add_suppression("reply failed"); +call mtr.add_suppression("Replication event checksum verification"); +call mtr.add_suppression("Relay log write failure"); +call mtr.add_suppression("Failed to kill the active semi-sync connection"); +connection server_3; +call mtr.add_suppression("reply failed"); +call mtr.add_suppression("Replication event checksum verification"); +call mtr.add_suppression("Relay log write failure"); +call mtr.add_suppression("Failed to kill the active semi-sync connection"); +connection server_1; +CREATE TABLE t1 (a int); +connection server_2; +connection server_3; +connect server_1_con2, localhost, root,,; +############################# +# Test cases +############################# +# +# Test Case 1) If both replicas simulate a delay that is within the +# allowed timeout, the primary should delay killing the suspended thread +# until an ACK is received (Rpl_semi_sync_master_yes_tx should be 1). +# +connection server_1; +#-- +#-- Semi-sync Setup +connection server_1; +#-- Enable semi-sync on slaves +let slave_last= 3 +connection server_2; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +connection server_3; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +#-- Enable semi-sync on master +connection server_1; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +set @@global.rpl_semi_sync_master_timeout= 1600; +#-- Wait for master to recognize semi-sync slaves +connection server_1; +#-- Master should have semi-sync enabled with 2 connections +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status ON +show status like 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 2 +#-- Prepare servers to simulate delay or error +connection server_1; +SET @@GLOBAL.debug_dbug= ""; +connection server_2; +SET @@GLOBAL.debug_dbug= "+d,simulate_delay_semisync_slave_reply"; +connection server_3; +SET @@GLOBAL.debug_dbug= "+d,simulate_delay_semisync_slave_reply"; +#-- +#-- Test begins +connection server_1; +#-- Begin semi-sync transaction +INSERT INTO t1 VALUES (1); +connection server_1_con2; +#-- Wait until master recognizes a connection is awaiting semi-sync ACK +show status like 'Rpl_semi_sync_master_wait_sessions'; +Variable_name Value +Rpl_semi_sync_master_wait_sessions 1 +#-- Give enough time after timeout/ack received to query yes_tx/no_tx +SET @@GLOBAL.debug_dbug= "+d,delay_shutdown_phase_2_after_semisync_wait"; +#-- Begin master shutdown +SHUTDOWN WAIT FOR ALL SLAVES; +connection server_1; +#-- Ensure either ACK was received (yes_tx=1) or timeout (no_tx=1) +show status like 'Rpl_semi_sync_master_yes_tx'; +Variable_name Value +Rpl_semi_sync_master_yes_tx 1 +show status like 'Rpl_semi_sync_master_no_tx'; +Variable_name Value +Rpl_semi_sync_master_no_tx 0 +connection server_1_con2; +# Check logs to ensure shutdown was delayed +FOUND 1 /Delaying shutdown to await semi-sync ACK/ in mysqld.1.err +# Validate slave data is in correct state +connection server_2; +select count(*)=1 from t1; +count(*)=1 +1 +connection server_3; +select count(*)=1 from t1; +count(*)=1 +1 +# +#-- Re-synchronize slaves with master and disable semi-sync +#-- Stop slaves +connection server_2; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +connection server_3; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +#-- Bring the master back up +connection server_1_con2; +connection default; +connection server_1; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 0; +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status OFF +TRUNCATE TABLE t1; +#-- Bring slaves back up +connection server_2; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +connection server_3; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +# +# Test Case 2) If both replicas simulate an error before sending an ACK, +# the primary should delay killing the suspended thread until the +# timeout is reached (Rpl_semi_sync_master_no_tx should be 1). +# +connection server_1; +#-- +#-- Semi-sync Setup +connection server_1; +#-- Enable semi-sync on slaves +let slave_last= 3 +connection server_2; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +connection server_3; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +#-- Enable semi-sync on master +connection server_1; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +set @@global.rpl_semi_sync_master_timeout= 500; +#-- Wait for master to recognize semi-sync slaves +connection server_1; +#-- Master should have semi-sync enabled with 2 connections +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status ON +show status like 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 2 +#-- Prepare servers to simulate delay or error +connection server_1; +SET @@GLOBAL.debug_dbug= "+d,mysqld_delay_kill_threads_phase_1"; +connection server_2; +SET @@GLOBAL.debug_dbug= "+d,corrupt_queue_event"; +connection server_3; +SET @@GLOBAL.debug_dbug= "+d,corrupt_queue_event"; +#-- +#-- Test begins +connection server_1; +#-- Begin semi-sync transaction +INSERT INTO t1 VALUES (1); +connection server_1_con2; +#-- Wait until master recognizes a connection is awaiting semi-sync ACK +show status like 'Rpl_semi_sync_master_wait_sessions'; +Variable_name Value +Rpl_semi_sync_master_wait_sessions 1 +#-- Give enough time after timeout/ack received to query yes_tx/no_tx +SET @@GLOBAL.debug_dbug= "+d,delay_shutdown_phase_2_after_semisync_wait"; +#-- Begin master shutdown +SHUTDOWN WAIT FOR ALL SLAVES; +connection server_1; +#-- Ensure either ACK was received (yes_tx=1) or timeout (no_tx=1) +show status like 'Rpl_semi_sync_master_yes_tx'; +Variable_name Value +Rpl_semi_sync_master_yes_tx 0 +show status like 'Rpl_semi_sync_master_no_tx'; +Variable_name Value +Rpl_semi_sync_master_no_tx 1 +connection server_1_con2; +# Check logs to ensure shutdown was delayed +FOUND 2 /Delaying shutdown to await semi-sync ACK/ in mysqld.1.err +# Validate slave data is in correct state +connection server_2; +select count(*)=0 from t1; +count(*)=0 +1 +connection server_3; +select count(*)=0 from t1; +count(*)=0 +1 +# +#-- Re-synchronize slaves with master and disable semi-sync +#-- Stop slaves +connection server_2; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +connection server_3; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +#-- Bring the master back up +connection server_1_con2; +connection default; +connection server_1; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 0; +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status OFF +TRUNCATE TABLE t1; +#-- Bring slaves back up +connection server_2; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +connection server_3; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +# +# Test Case 3) If one replica simulates a delay within the allowed +# timeout and the other simulates an error before sending an ACK, the +# primary should delay killing the suspended thread until it receives an +# ACK from the delayed slave (Rpl_semi_sync_master_yes_tx should be 1). +# +connection server_1; +#-- +#-- Semi-sync Setup +connection server_1; +#-- Enable semi-sync on slaves +let slave_last= 3 +connection server_2; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +connection server_3; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +#-- Enable semi-sync on master +connection server_1; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +set @@global.rpl_semi_sync_master_timeout= 1600; +#-- Wait for master to recognize semi-sync slaves +connection server_1; +#-- Master should have semi-sync enabled with 2 connections +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status ON +show status like 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 2 +#-- Prepare servers to simulate delay or error +connection server_1; +SET @@GLOBAL.debug_dbug= "+d,mysqld_delay_kill_threads_phase_1"; +connection server_2; +SET @@GLOBAL.debug_dbug= "+d,corrupt_queue_event"; +connection server_3; +SET @@GLOBAL.debug_dbug= "+d,simulate_delay_semisync_slave_reply"; +#-- +#-- Test begins +connection server_1; +#-- Begin semi-sync transaction +INSERT INTO t1 VALUES (1); +connection server_1_con2; +#-- Wait until master recognizes a connection is awaiting semi-sync ACK +show status like 'Rpl_semi_sync_master_wait_sessions'; +Variable_name Value +Rpl_semi_sync_master_wait_sessions 1 +#-- Give enough time after timeout/ack received to query yes_tx/no_tx +SET @@GLOBAL.debug_dbug= "+d,delay_shutdown_phase_2_after_semisync_wait"; +#-- Begin master shutdown +SHUTDOWN WAIT FOR ALL SLAVES; +connection server_1; +#-- Ensure either ACK was received (yes_tx=1) or timeout (no_tx=1) +show status like 'Rpl_semi_sync_master_yes_tx'; +Variable_name Value +Rpl_semi_sync_master_yes_tx 1 +show status like 'Rpl_semi_sync_master_no_tx'; +Variable_name Value +Rpl_semi_sync_master_no_tx 0 +connection server_1_con2; +# Check logs to ensure shutdown was delayed +FOUND 3 /Delaying shutdown to await semi-sync ACK/ in mysqld.1.err +# Validate slave data is in correct state +connection server_2; +select count(*)=0 from t1; +count(*)=0 +1 +connection server_3; +select count(*)=1 from t1; +count(*)=1 +1 +# +#-- Re-synchronize slaves with master and disable semi-sync +#-- Stop slaves +connection server_2; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +connection server_3; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +#-- Bring the master back up +connection server_1_con2; +connection default; +connection server_1; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 0; +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status OFF +TRUNCATE TABLE t1; +#-- Bring slaves back up +connection server_2; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +connection server_3; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +# +# Test Case 4) If a replica errors before sending an ACK, it will cause +# the IO thread to stop and handle the error. During error handling, if +# semi-sync is active, the replica will form a new connection with the +# primary to kill the active connection. However, if the primary is +# shutting down, it may kill the new connection, thereby leaving the +# active semi-sync connection in-tact. The slave should notice this, and +# not issue a `QUIT` command to the primary, which would otherwise be +# sent to kill an active connection. This test case validates that the +# slave does not send a `QUIT` in this case (Rpl_semi_sync_master_yes_tx +# should be 1 because server_3 will send the ACK within a valid timeout). +# +connection server_1; +#-- +#-- Semi-sync Setup +connection server_1; +#-- Enable semi-sync on slaves +let slave_last= 3 +connection server_2; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +connection server_3; +set global rpl_semi_sync_slave_enabled = 1; +include/stop_slave.inc +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status ON +#-- Enable semi-sync on master +connection server_1; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +set @@global.rpl_semi_sync_master_timeout= 1600; +#-- Wait for master to recognize semi-sync slaves +connection server_1; +#-- Master should have semi-sync enabled with 2 connections +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status ON +show status like 'Rpl_semi_sync_master_clients'; +Variable_name Value +Rpl_semi_sync_master_clients 2 +#-- Prepare servers to simulate delay or error +connection server_1; +SET @@GLOBAL.debug_dbug= "+d,mysqld_delay_kill_threads_phase_1"; +connection server_2; +SET @@GLOBAL.debug_dbug= "+d,corrupt_queue_event,slave_delay_killing_semisync_connection"; +connection server_3; +SET @@GLOBAL.debug_dbug= "+d,simulate_delay_semisync_slave_reply"; +#-- +#-- Test begins +connection server_1; +#-- Begin semi-sync transaction +INSERT INTO t1 VALUES (1); +connection server_1_con2; +#-- Wait until master recognizes a connection is awaiting semi-sync ACK +show status like 'Rpl_semi_sync_master_wait_sessions'; +Variable_name Value +Rpl_semi_sync_master_wait_sessions 1 +#-- Give enough time after timeout/ack received to query yes_tx/no_tx +SET @@GLOBAL.debug_dbug= "+d,delay_shutdown_phase_2_after_semisync_wait"; +#-- Begin master shutdown +SHUTDOWN WAIT FOR ALL SLAVES; +connection server_1; +#-- Ensure either ACK was received (yes_tx=1) or timeout (no_tx=1) +show status like 'Rpl_semi_sync_master_yes_tx'; +Variable_name Value +Rpl_semi_sync_master_yes_tx 1 +show status like 'Rpl_semi_sync_master_no_tx'; +Variable_name Value +Rpl_semi_sync_master_no_tx 0 +connection server_1_con2; +# Check logs to ensure shutdown was delayed +FOUND 4 /Delaying shutdown to await semi-sync ACK/ in mysqld.1.err +# Validate slave data is in correct state +connection server_2; +select count(*)=0 from t1; +count(*)=0 +1 +connection server_3; +select count(*)=1 from t1; +count(*)=1 +1 +# +#-- Re-synchronize slaves with master and disable semi-sync +#-- Stop slaves +connection server_2; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +connection server_3; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0; +include/stop_slave.inc +#-- Bring the master back up +connection server_1_con2; +connection default; +connection server_1; +SET @@GLOBAL.debug_dbug= ""; +SET @@GLOBAL.rpl_semi_sync_master_enabled = 0; +show status like 'Rpl_semi_sync_master_status'; +Variable_name Value +Rpl_semi_sync_master_status OFF +TRUNCATE TABLE t1; +#-- Bring slaves back up +connection server_2; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +connection server_3; +include/start_slave.inc +show status like 'Rpl_semi_sync_slave_status'; +Variable_name Value +Rpl_semi_sync_slave_status OFF +SELECT COUNT(*)=0 from t1; +COUNT(*)=0 +1 +############################# +# Cleanup +############################# +connection server_2; +include/stop_slave.inc +include/start_slave.inc +connection server_3; +include/stop_slave.inc +include/start_slave.inc +connection server_1; +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_ssl.result b/mysql-test/suite/rpl/r/rpl_ssl.result index 0b3a6cd0eca..ce9e4d486cf 100644 --- a/mysql-test/suite/rpl/r/rpl_ssl.result +++ b/mysql-test/suite/rpl/r/rpl_ssl.result @@ -23,6 +23,8 @@ t Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc @@ -37,6 +39,8 @@ include/wait_for_slave_to_start.inc Master_SSL_Allowed = 'Yes' Master_SSL_CA_Path = '' Master_SSL_CA_File = 'MYSQL_TEST_DIR/std_data/cacert.pem' +Master_SSL_Crl = '' +Master_SSL_Crlpath = '' Master_SSL_Cert = 'MYSQL_TEST_DIR/std_data/client-cert.pem' Master_SSL_Key = 'MYSQL_TEST_DIR/std_data/client-key.pem' include/check_slave_is_running.inc diff --git a/mysql-test/suite/rpl/r/rpl_unsafe_statements.result b/mysql-test/suite/rpl/r/rpl_unsafe_statements.result index 27065fffaa6..941984bf329 100644 --- a/mysql-test/suite/rpl/r/rpl_unsafe_statements.result +++ b/mysql-test/suite/rpl/r/rpl_unsafe_statements.result @@ -1,6 +1,5 @@ include/master-slave.inc [connection master] -call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); CREATE TABLE t1(id INT AUTO_INCREMENT, i INT, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TABLE t2(id INT AUTO_INCREMENT, i INT, PRIMARY KEY (id)) ENGINE=INNODB; CREATE TRIGGER trig1 AFTER INSERT ON t1 @@ -50,13 +49,9 @@ connection master; DROP TABLE t1; CREATE TABLE t1(i INT, j INT, UNIQUE KEY(i), UNIQUE KEY(j)) ENGINE=INNODB; INSERT INTO t1 (i,j) VALUES (1,2) ON DUPLICATE KEY UPDATE j=j+1; -Warnings: -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe START TRANSACTION; LOCK TABLES t1 WRITE; INSERT INTO t1 (i,j) VALUES (1,2) ON DUPLICATE KEY UPDATE j=j+1; -Warnings: -Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe UNLOCK TABLES; COMMIT; connection slave; diff --git a/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test b/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test new file mode 100644 index 00000000000..f0f38a31da6 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_glle_no_terminate.test @@ -0,0 +1,72 @@ +# +# Purpose: +# If a fake Glle event follows a Gtid event, we need to ensure the rest of +# the group should not terminate at the Glle event. MDEV-28550 revealed that +# a Glle would terminate the event and upon reconnect, the DDL would be lost. +# +# Methodology: +# Force the primary to send a fake GLLE event after a GTID on a "reconnect" +# and ensure that both 1) the replica does not error, and 2) the original +# command within the GTID is executed. +# +# References: +# MDEV-28550: improper handling of replication event group that contains Gtid_log_list_event + +--source include/master-slave.inc + +# Independent of binlog format +--source include/have_binlog_format_statement.inc + +--connection slave +--source include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; + +--echo # +--echo # Initialize test data +--connection master +create table t1 (a int); +SET @@session.server_id= 3; +create table t2 (a int); +--source include/save_master_gtid.inc + +--echo # +--echo # Have the replica "reconnect" and the primary will send Gtid, Glle, DDL +--connection slave +eval set global gtid_slave_pos="0-3-1"; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc + +--echo # +--echo # Ensure that the replica did not error +connection slave; +--source include/sync_with_master_gtid.inc +let $error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1); +--echo Last_SQL_Error = $error +let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1); +--echo Last_SQL_Errno = $errno + +--echo # +--echo # Ensure that the primary sent a Glle after a Gtid event +let $binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1); +let $binlog_start= $relaylog_start; +let $binlog_limit=0,10; +--source include/show_relaylog_events.inc + +--echo # +--echo # Ensure the DDL was executed on the replica +if (!`SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'test' AND table_name = 't2'`) +{ + die "t2 should exist on slave"; +} + +--echo # +--echo # Cleanup + +--echo # t1 does not make it to the replica +--connection master +set sql_log_bin=0; +DROP TABLE t1; +set sql_log_bin=1; +DROP TABLE t2; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_grouping.test b/mysql-test/suite/rpl/t/rpl_gtid_grouping.test new file mode 100644 index 00000000000..66448c4f96c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_gtid_grouping.test @@ -0,0 +1,97 @@ +# ==== Purpose ==== +# +# Test verifies that replicated transaction boundaries are set properly +# at receiving from master time. +# +# ==== Implementation ==== +# +# A. Simulate an unnoticeable loss of Xid event to observe a slave error, +# then restart slave to recover from the failure. +# B. Do the same to GTID event. +# +# ==== References ==== +# +# MDEV-27697 slave must recognize incomplete replication event group +# +--source include/have_binlog_format_mixed.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/master-slave.inc + +--connection slave +call mtr.add_suppression("Unexpected break of being relay-logged GTID 0-27697-1000"); +call mtr.add_suppression("Relay log write failure: could not queue event from master"); +call mtr.add_suppression("The current group of events starts with a non-GTID"); + +--source include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=slave_pos; +--source include/start_slave.inc + +--connection master +CREATE TABLE t (a INT) ENGINE=innodb; +INSERT INTO t VALUES(1); +save_master_pos; + +--echo ### A. Simulate an unnoticeable loss of Xid event +--sync_slave_with_master +SET @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; + +--connection master +SET @@gtid_seq_no=1000; +set @@server_id=27697; +INSERT INTO t VALUES(1000); +set @@server_id=default; +INSERT INTO t VALUES(1001); + +--echo ## Prove the error occurs. +--connection slave +# ER_SLAVE_RELAY_LOG_WRITE_FAILURE +--let $slave_io_errno = 1595 +--source include/wait_for_slave_io_error.inc +## EOP + +--echo ## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +--source include/start_slave.inc + +--echo ### B. Do the same to GTID event. +--connection slave +SET @@global.debug_dbug="+d,slave_discard_gtid_0_x_1002"; + +--connection master +SET @@gtid_seq_no=1002; +set @@server_id=27697; +INSERT INTO t VALUES(1002); +set @@server_id=default; +INSERT INTO t VALUES(1003); + +--echo ## Prove the error occurs. +--connection slave +# ER_SLAVE_RELAY_LOG_WRITE_FAILURE +--let $slave_io_errno = 1595 +--source include/wait_for_slave_io_error.inc +## EOP + +--echo ## Prove the slave recovers after the simulation condtion is lifted. +SET @@global.debug_dbug=default; +--source include/start_slave.inc + +--connection master +save_master_pos; + +--sync_slave_with_master +## EOP + +--let $diff_tables=master:t,slave:t +--source include/diff_tables.inc + +--echo "===== Clean up =====" +--connection slave +--source include/stop_slave.inc +CHANGE MASTER TO MASTER_USE_GTID=no; +--source include/start_slave.inc + +--connection master +DROP TABLE t; +SET GLOBAL LOG_WARNINGS=default; +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_iodku.test b/mysql-test/suite/rpl/t/rpl_iodku.test new file mode 100644 index 00000000000..815b927c350 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_iodku.test @@ -0,0 +1,50 @@ +--source include/have_innodb.inc +--source include/master-slave.inc + +if (`select @@binlog_format = "statement"`) +{ + call mtr.add_suppression("Unsafe statement written to the binary log using statement"); +} + +## MDEV-28310 loss of binlog event for multi-record IODKU +# Check that the duplicate key error does not cause +# loss of replication event for IODKU that specifies values +# for at least two unique columns per record. +# "Implicit" NULL value of the auto-increment column also counts. + +CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, a INT, b INT, c INT, + UNIQUE (a), UNIQUE (b)) ENGINE=innodb; +INSERT INTO t1 (`a`,`c`) VALUES (1,1), (2,1) ON DUPLICATE KEY UPDATE c = 1; +--echo # UNSAFE +# because of two keys involved: a UK and PK even though implicitly via auto-inc +INSERT INTO t1 (`a`,`c`) VALUES (3, 1),(2,1), (1,1) ON DUPLICATE KEY UPDATE c = a * 10 + VALUES(c); +SELECT * from t1; + +--sync_slave_with_master +--let $diff_tables = master:t1,slave:t1 +--source include/diff_tables.inc + +## MDEV-21810 MBR: Unexpected "Unsafe statement" warning for unsafe IODKU +# Unnecessary unsafe statement warning is not error-logged anymore. + + +--connection master +CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, UNIQUE (a), UNIQUE (b)) ENGINE=innodb; +INSERT INTO t1 VALUES (1,10,1); +--echo # eligable for the statement format run unsafe warning +INSERT INTO t1 VALUES (2,20,2) ON DUPLICATE KEY UPDATE c = 100; +--echo # not eligable: no warning in the statement format run +INSERT INTO t1 (`a`,`c`) VALUES (3, 1) ON DUPLICATE KEY UPDATE c = 99; +SELECT * from t1; + +--sync_slave_with_master +--let $diff_tables = master:t1,slave:t1 +--source include/diff_tables.inc + +# Cleanup +--connection master +DROP TABLE t1; +--sync_slave_with_master + + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_mdev_17614.test b/mysql-test/suite/rpl/t/rpl_mdev_17614.test index 9b86c8c15b5..c11aad3305e 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev_17614.test +++ b/mysql-test/suite/rpl/t/rpl_mdev_17614.test @@ -2,15 +2,22 @@ source include/have_debug.inc; source include/have_innodb.inc; -- source include/have_binlog_format_statement.inc source include/master-slave.inc; -# MDEV-17614 -# INSERT on dup key update is replication unsafe -# There can be three case -# 1. 2 unique key, Replication is unsafe. -# 2. 2 unique key , with one auto increment key, Safe to replicate because Innodb will acquire gap lock -# 3. n no of unique keys (n>1) but insert is only in 1 unique key -# 4. 2 unique key , with one auto increment key(but user gives auto inc value), unsafe to replicate +# MDEV-17614 INSERT on dup key update is replication unsafe +# +# The following cases are tested below: +# 1. 2 unique key, replication is UNSAFE +# 2. 2 unique key, with one auto increment key and implicit value to it. +# It is UNSAFE because autoinc column values of being inserted records +# are revealed dynamically, so unknown at the binlog-format decision time +# and hence this pessimistic expectation +# 3. 2 unique keys +# A. insert is only in 1 unique key, still all colums are specified => UNSAFE +# B. both unique keys are specified => UNSAFE +# C. only one unique key is specified => SAFE (motivated by MDEV-28310) +# 4. 2 unique key, with one auto increment key(but user gives auto inc value) => +# UNSAFE to replicate -# Case 1 +--echo # Case 1: UNSAFE call mtr.add_suppression("Unsafe statement written to the binary log using statement format"); CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY , b INT, UNIQUE(b), c int) engine=innodb; @@ -42,7 +49,8 @@ drop table t1; connection slave; start slave; --source include/wait_for_slave_to_start.inc -# Case 2 + +--echo # Case 2: UNSAFE --connection master CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, UNIQUE(b), c int) engine=innodb; @@ -64,7 +72,7 @@ connection master; drop table t1; --sync_slave_with_master -# Case 3 +--echo # Case 3A: UNSAFE --connection master CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, UNIQUE(b), c int, d int ) engine=innodb; @@ -85,7 +93,50 @@ connection master; drop table t1; --sync_slave_with_master -# Case 4 +--echo # Case 3B: UNSAFE - all column specified. +--connection master +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, +UNIQUE(b), c int, d int ) engine=innodb; +sync_slave_with_master; +connection master; +INSERT INTO t1 VALUES (1, 1, 1, 1); +BEGIN; +INSERT INTO t1 VALUES (2, NULL, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); + --connection master1 + INSERT INTO t1 VALUES(3, NULL, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +--connection master +COMMIT; +SELECT * FROM t1; +--sync_slave_with_master +--echo #same data as master +SELECT * FROM t1; +connection master; +drop table t1; +--sync_slave_with_master + + +--echo # Case 3C: SAFE - only one unique key (PK) specified. +--connection master +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, +UNIQUE(b), c int, d int ) engine=innodb; +sync_slave_with_master; +connection master; +INSERT INTO t1 VALUES (1, 1, 1, 1); +BEGIN; +INSERT INTO t1 (`a`, `c`, `d`) VALUES (2, 2, 2) ON DUPLICATE KEY UPDATE c=99; + --connection master1 + INSERT INTO t1 (`a`, `c`, `d`) VALUES(3, 2, 3) ON DUPLICATE KEY UPDATE c=100; +--connection master +COMMIT; +SELECT * FROM t1; +--sync_slave_with_master +--echo #same data as master +SELECT * FROM t1; +connection master; +drop table t1; +--sync_slave_with_master + +--echo # Case 4: UNSAFE --connection master CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY auto_increment, b INT, UNIQUE(b), c int) engine=innodb; diff --git a/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition-slave.opt b/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition-slave.opt new file mode 100644 index 00000000000..d127ef62043 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition-slave.opt @@ -0,0 +1 @@ +--gtid-cleanup-batch-size=1 diff --git a/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test b/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test new file mode 100644 index 00000000000..751da3158b7 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_mysql_manager_race_condition.test @@ -0,0 +1,67 @@ +# +# Purpose: +# This test ensures that, during mysqld initialization, the mysql handle +# manager starts before the binlog background thread. This is because the +# binlog background thread uses the mysql handle manager, and if the background +# thread tries to submit a job to the handle manager before it is +# initialized/started, mysqld can crash (the actual behavior is undefined). +# This race condition lead to the problem described in MDEV-26473. +# +# Methodology: +# This test ensures that the binlog background thread cannot be started +# before the mysql manager is started. Specifically, it forces a path in +# the binlog background thread to call mysql_manager_submit() by reducing +# --gtid-cleanup-batch-size to be 1 (which submits a job to delete unused rows +# from the mysql.gtid_slave_pos* tables). With this path forced, the main +# mysqld thread is suspended just before its handle manager initialization to +# allow time for the binlog thread to call mysql_manager_submit. The fix +# associated with this test should enforce that the binlog background thread is +# not created before the handle manager is initialized. +# +# References: +# MDEV-26473 mysqld got exception 0xc0000005 (rpl_slave_state/rpl_load_gtid_slave_state) +# + +--source include/have_debug.inc +--source include/master-slave.inc + +# The race condition discovered from MDEV-26473 is binlog format independent. +# We use ROW format though because it was used by the reporter. +--source include/have_binlog_format_row.inc + +--connection master + +--echo # Create a GTID event so the binlog background thread will submit a +--echo # mysql handler job the next time mysqld is restarted. +create table t1 (a int); +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--echo # Set a debug point that forces the main mysqld thread to sleep before +--echo # anything is initialized for the mysql handle manager +--let $rpl_server_parameters=--debug_dbug="+d,delay_start_handle_manager" + + +--echo # Restart the slave mysqld instance so it re-initializes with the +--echo # binlog background thread submitting a mysql handler job and the +--echo # mysql handler initialization suspending for a second. Without the fix +--echo # associated with this test/patch, the following restart will error +--echo # with a failed assertion. +--source include/rpl_restart_server.inc +--source include/start_slave.inc + + +--echo # +--echo # Cleanup +--echo # + +--connection master +drop table t1; +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_parallel_temptable.test b/mysql-test/suite/rpl/t/rpl_parallel_temptable.test index 04165ee4752..edb854842e1 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_temptable.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_temptable.test @@ -201,9 +201,16 @@ INSERT INTO t1 VALUES (0, 1); # execution of format_description event will not wait infinitely # for a commit of the incomplete group that never happens. +# Apart from the suppression, MDEV-27697 refinement to the original test needs +# an allowance to one time accept malformed event group. +set @@sql_log_bin=0; +call mtr.add_suppression("Unexpected break of being relay-logged GTID 1-1-32 event group by the current GTID event 0-1-4"); +set @@sql_log_bin=1; +set @@global.debug_dbug="+d,slave_discard_xid_for_gtid_0_x_1000"; --source include/start_slave.inc #--sync_with_master --source include/sync_with_master_gtid.inc +set @@global.debug_dbug=""; SELECT * FROM t1 ORDER BY a; SHOW STATUS LIKE 'Slave_open_temp_tables'; diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.cnf b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.cnf new file mode 100644 index 00000000000..2cf1b1786bd --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.cnf @@ -0,0 +1,14 @@ +!include ../my.cnf + +[mysqld.1] +log_warnings=9 + +[mysqld.2] +log_warnings=9 + +[mysqld.3] +log_warnings=9 + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.inc b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.inc new file mode 100644 index 00000000000..a232f68540d --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.inc @@ -0,0 +1,163 @@ +# +# Helper file to ensure that a primary waits for all ACKS (or timeout) from its +# replicas before shutting down. +# +# Parameters: +# server_1_dbug (string) Debug setting for primary (server 1) +# server_2_dbug (string) Debug setting to simulate delay or error on +# the first replica (server 2) +# server_3_dbug (string) Debug setting to simulate delay or error on +# the second replica (server 3) +# semisync_timeout (int) Rpl_semi_sync_master_timeout to use +# server_2_expect_row_count (int) The number of rows expected on the first +# replica after the shutdown +# server_3_expect_row_count (int) The number of rows expected on the second +# replica after the shutdown +# + +--connection server_1 +let $log_error_file= `SELECT @@GLOBAL.log_error`; + +--echo #-- +--echo #-- Semi-sync Setup + +--connection server_1 +--save_master_pos + +echo #-- Enable semi-sync on slaves +let slave_last= 3; +--let i= 2 +while (`SELECT $i <= $slave_last`) +{ + --connection server_$i + --sync_with_master + + set global rpl_semi_sync_slave_enabled = 1; + source include/stop_slave.inc; + source include/start_slave.inc; + show status like 'Rpl_semi_sync_slave_status'; + + --inc $i +} + +--echo #-- Enable semi-sync on master +--connection server_1 +SET @@GLOBAL.rpl_semi_sync_master_enabled = 1; +--eval set @@global.rpl_semi_sync_master_timeout= $semisync_timeout + +--echo #-- Wait for master to recognize semi-sync slaves +--connection server_1 +let $status_var= Rpl_semi_sync_master_clients; +let $status_var_value= 2; +source include/wait_for_status_var.inc; + +--echo #-- Master should have semi-sync enabled with 2 connections +show status like 'Rpl_semi_sync_master_status'; +show status like 'Rpl_semi_sync_master_clients'; + +--echo #-- Prepare servers to simulate delay or error +--connection server_1 +--eval SET @@GLOBAL.debug_dbug= $server_1_dbug +--connection server_2 +--eval SET @@GLOBAL.debug_dbug= $server_2_dbug +--connection server_3 +--eval SET @@GLOBAL.debug_dbug= $server_3_dbug + +--echo #-- +--echo #-- Test begins + +--connection server_1 +--echo #-- Begin semi-sync transaction +--send INSERT INTO t1 VALUES (1) + +--connection server_1_con2 +--echo #-- Wait until master recognizes a connection is awaiting semi-sync ACK +let $status_var= Rpl_semi_sync_master_wait_sessions; +let $status_var_value= 1; +source include/wait_for_status_var.inc; +show status like 'Rpl_semi_sync_master_wait_sessions'; + +--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +wait +EOF + +--echo #-- Give enough time after timeout/ack received to query yes_tx/no_tx +SET @@GLOBAL.debug_dbug= "+d,delay_shutdown_phase_2_after_semisync_wait"; + +--echo #-- Begin master shutdown +--send SHUTDOWN WAIT FOR ALL SLAVES + +--connection server_1 +--reap +--echo #-- Ensure either ACK was received (yes_tx=1) or timeout (no_tx=1) +show status like 'Rpl_semi_sync_master_yes_tx'; +show status like 'Rpl_semi_sync_master_no_tx'; + +--connection server_1_con2 +--reap +--source include/wait_until_disconnected.inc + +--echo # Check logs to ensure shutdown was delayed +--let SEARCH_FILE=$log_error_file +--let SEARCH_PATTERN=Delaying shutdown to await semi-sync ACK +--source include/search_pattern_in_file.inc + +--echo # Validate slave data is in correct state +--connection server_2 +--eval select count(*)=$server_2_expect_row_count from t1 +--connection server_3 +--eval select count(*)=$server_3_expect_row_count from t1 + +--echo # +--echo #-- Re-synchronize slaves with master and disable semi-sync + +--echo #-- Stop slaves + +--connection server_2 +--eval SET @@GLOBAL.debug_dbug= "$sav_server_2_dbug" +--eval SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0 +source include/stop_slave.inc; + +--connection server_3 +--eval SET @@GLOBAL.debug_dbug= "$sav_server_3_dbug" +--eval SET @@GLOBAL.rpl_semi_sync_slave_enabled= 0 +source include/stop_slave.inc; + +--echo #-- Bring the master back up +--connection server_1_con2 +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +restart +EOF + +--enable_reconnect +--source include/wait_until_connected_again.inc + +--connection default +--enable_reconnect +--source include/wait_until_connected_again.inc + +--connection server_1 +--enable_reconnect +--source include/wait_until_connected_again.inc + +--eval SET @@GLOBAL.debug_dbug= "$sav_master_dbug" +let $status_var= Rpl_semi_sync_master_clients; +let $status_var_value= 0; +source include/wait_for_status_var.inc; +--eval SET @@GLOBAL.rpl_semi_sync_master_enabled = 0 +show status like 'Rpl_semi_sync_master_status'; + +TRUNCATE TABLE t1; +--save_master_pos + +--echo #-- Bring slaves back up +--let i= 2 +while (`SELECT $i <= $slave_last`) +{ + --connection server_$i + source include/start_slave.inc; + show status like 'Rpl_semi_sync_slave_status'; + --sync_with_master + SELECT COUNT(*)=0 from t1; + --inc $i +} diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test new file mode 100644 index 00000000000..5e9cda6466e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_shutdown_await_ack.test @@ -0,0 +1,214 @@ +# +# Purpose: +# This test validates that data is consistent between a primary and replica +# in semi-sync mode when the primary is issued `SHUTDOWN WAIT FOR SLAVES` +# during an active communication. More specifically, the primary should not +# kill the connection until it is sure a replica has received all binlog +# data, i.e. once the primary receives the ACK. If a primary is issued a +# shutdown before receiving an ACK, it should wait until either 1) the ACK is +# received, or 2) the configured timeout (rpl_semi_sync_master_timeout) is +# reached. +# +# Methodology: +# Using a topology consisting of one primary with two replicas, all in +# semi-sync mode, we use DEBUG_DBUG to simulate an error or delay on the +# replicas during an active communication while the primary is issued +# `SHUTDOWN WAIT FOR SLAVES`. We create four test cases to ensure the primary +# will correctly wait for the communication to finish, and use the semi-sync +# status variables Rpl_semi_sync_master_yes_tx and Rpl_semi_sync_master_no_tx +# to ensure the connection was not prematurely killed due to the shutdown. +# Test Case 1) If both replicas simulate a delay that is within the allowed +# timeout, the primary should delay killing the suspended thread +# until an ACK is received (Rpl_semi_sync_master_yes_tx should +# be 1). +# Test Case 2) If both replicas simulate an error before sending an ACK, the +# primary should delay killing the suspended thread until the +# the timeout is reached (Rpl_semi_sync_master_no_tx should be +# 1). +# Test Case 3) If one replica simulates a delay within the allowed timeout +# and the other simulates an error before sending an ACK, the +# primary should delay killing the suspended thread until it +# receives an ACK from the delayed slave +# (Rpl_semi_sync_master_yes_tx should be 1). +# Test Case 4) If a replica errors before sending an ACK, it will cause the +# IO thread to stop and handle the error. During error handling, +# if semi-sync is active, the replica will form a new connection +# with the primary to kill the active connection. However, if +# the primary is shutting down, it may kill the new connection, +# thereby leaving the active semi-sync connection in-tact. The +# slave should notice this, and not issue a `QUIT` command to +# the primary, which would otherwise be sent to kill an active +# connection. This test case validates that the slave does not +# send a `QUIT` in this case (Rpl_semi_sync_master_yes_tx should +# be 1 because server_3 will send the ACK within a valid +# timeout). +# +# References: +# MDEV-11853: semisync thread can be killed after sync binlog but before ACK +# in the sync state +# MDEV-28114: Semi-sync Master ACK Receiver Thread Can Error on COM_QUIT +# + +--echo ############################# +--echo # Common setup for all tests +--echo ############################# + +--echo # Note: Simulated slave delay is hardcoded to 800 milliseconds +--echo # Note: Simulated master shutdown delay is hardcoded to 500 milliseconds + +--source include/have_debug.inc +--let $rpl_topology=1->2, 1->3 +--source include/rpl_init.inc + +--connection server_1 + +--echo # Slaves which simulate an error will produce a timeout on the primary +call mtr.add_suppression("Timeout waiting"); +call mtr.add_suppression("did not exit"); + +--let $sav_master_timeout= `SELECT @@global.rpl_semi_sync_master_timeout` +--let $sav_enabled_master= `SELECT @@GLOBAL.rpl_semi_sync_master_enabled` +--let $sav_master_dbug= `SELECT @@GLOBAL.debug_dbug` + +--echo # Suppress slave errors related to the simulated error +--connection server_2 +call mtr.add_suppression("reply failed"); +call mtr.add_suppression("Replication event checksum verification"); +call mtr.add_suppression("Relay log write failure"); +call mtr.add_suppression("Failed to kill the active semi-sync connection"); +--let $sav_enabled_server_2=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled` +--let $sav_server_2_dbug= `SELECT @@GLOBAL.debug_dbug` + +--connection server_3 +call mtr.add_suppression("reply failed"); +call mtr.add_suppression("Replication event checksum verification"); +call mtr.add_suppression("Relay log write failure"); +call mtr.add_suppression("Failed to kill the active semi-sync connection"); +--let $sav_enabled_server_3=`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled` +--let $sav_server_3_dbug= `SELECT @@GLOBAL.debug_dbug` + +--connection server_1 +CREATE TABLE t1 (a int); +--save_master_pos + +--let i= 2 +--let slave_last= 3 +while (`SELECT $i <= $slave_last`) +{ + --connection server_$i + --sync_with_master + --inc $i +} + +# Set up the connection used to issue the shutdown +--connect(server_1_con2, localhost, root,,) + + +--echo ############################# +--echo # Test cases +--echo ############################# + +--echo # +--echo # Test Case 1) If both replicas simulate a delay that is within the +--echo # allowed timeout, the primary should delay killing the suspended thread +--echo # until an ACK is received (Rpl_semi_sync_master_yes_tx should be 1). +--echo # +--let server_1_dbug= "" +--let server_2_dbug= "+d,simulate_delay_semisync_slave_reply" +--let server_3_dbug= "+d,simulate_delay_semisync_slave_reply" +--let semisync_timeout= 1600 +--let server_2_expect_row_count= 1 +--let server_3_expect_row_count= 1 +--source rpl_semi_sync_shutdown_await_ack.inc + +--echo # +--echo # Test Case 2) If both replicas simulate an error before sending an ACK, +--echo # the primary should delay killing the suspended thread until the +--echo # timeout is reached (Rpl_semi_sync_master_no_tx should be 1). +--echo # +--let server_1_dbug= "+d,mysqld_delay_kill_threads_phase_1" +--let server_2_dbug= "+d,corrupt_queue_event" +--let server_3_dbug= "+d,corrupt_queue_event" +--let semisync_timeout= 500 +--let server_2_expect_row_count= 0 +--let server_3_expect_row_count= 0 +--source rpl_semi_sync_shutdown_await_ack.inc + +--echo # +--echo # Test Case 3) If one replica simulates a delay within the allowed +--echo # timeout and the other simulates an error before sending an ACK, the +--echo # primary should delay killing the suspended thread until it receives an +--echo # ACK from the delayed slave (Rpl_semi_sync_master_yes_tx should be 1). +--echo # +--let server_1_dbug= "+d,mysqld_delay_kill_threads_phase_1" +--let server_2_dbug= "+d,corrupt_queue_event" +--let server_3_dbug= "+d,simulate_delay_semisync_slave_reply" +--let semisync_timeout= 1600 +--let server_2_expect_row_count= 0 +--let server_3_expect_row_count= 1 +--source rpl_semi_sync_shutdown_await_ack.inc + +--echo # +--echo # Test Case 4) If a replica errors before sending an ACK, it will cause +--echo # the IO thread to stop and handle the error. During error handling, if +--echo # semi-sync is active, the replica will form a new connection with the +--echo # primary to kill the active connection. However, if the primary is +--echo # shutting down, it may kill the new connection, thereby leaving the +--echo # active semi-sync connection in-tact. The slave should notice this, and +--echo # not issue a `QUIT` command to the primary, which would otherwise be +--echo # sent to kill an active connection. This test case validates that the +--echo # slave does not send a `QUIT` in this case (Rpl_semi_sync_master_yes_tx +--echo # should be 1 because server_3 will send the ACK within a valid timeout). +--echo # + +# mysqld_delay_kill_threads_phase1 ensures that server_2 will have enough time +# to start a new connection that has the intent to kill the active semi-sync +# connection +--let server_1_dbug= "+d,mysqld_delay_kill_threads_phase_1" + +# slave_delay_killing_semisync_connection ensures that the primary has force +# killed its current connection before it is able to issue `KILL` +--let server_2_dbug= "+d,corrupt_queue_event,slave_delay_killing_semisync_connection" +--let server_3_dbug= "+d,simulate_delay_semisync_slave_reply" +--let semisync_timeout= 1600 +--let server_2_expect_row_count= 0 +--let server_3_expect_row_count= 1 +--source rpl_semi_sync_shutdown_await_ack.inc + +--echo ############################# +--echo # Cleanup +--echo ############################# + +--connection server_2 +source include/stop_slave.inc; +source include/start_slave.inc; + +--disable_query_log +--eval SET @@GLOBAL.rpl_semi_sync_slave_enabled = $sav_enabled_server_2 +--eval SET @@GLOBAL.debug_dbug= "$sav_server_2_dbug" +--enable_query_log + +--connection server_3 +source include/stop_slave.inc; +source include/start_slave.inc; + +--disable_query_log +--eval SET @@GLOBAL.rpl_semi_sync_slave_enabled = $sav_enabled_server_3 +--eval SET @@GLOBAL.debug_dbug= "$sav_server_3_dbug" +--enable_query_log + + +--connection server_1 +let $status_var= Rpl_semi_sync_master_clients; +let $status_var_value= 0; +source include/wait_for_status_var.inc; + +--disable_query_log +--eval SET @@GLOBAL.rpl_semi_sync_master_timeout= $sav_master_timeout +--eval SET @@GLOBAL.rpl_semi_sync_master_enabled= $sav_enabled_master +--eval SET @@GLOBAL.debug_dbug= "$sav_master_dbug" +--enable_query_log + +drop table t1; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_unsafe_statements.test b/mysql-test/suite/rpl/t/rpl_unsafe_statements.test index 9185e566b9c..40c9b9bb25f 100644 --- a/mysql-test/suite/rpl/t/rpl_unsafe_statements.test +++ b/mysql-test/suite/rpl/t/rpl_unsafe_statements.test @@ -25,7 +25,7 @@ --source include/have_innodb.inc --source include/have_binlog_format_mixed.inc --source include/master-slave.inc -call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + # Case-1: BINLOG_STMT_UNSAFE_AUTOINC_COLUMNS # Statement is unsafe because it invokes a trigger or a # stored function that inserts into an AUTO_INCREMENT column. diff --git a/mysql-test/suite/sys_vars/r/group_concat_max_len_func.result b/mysql-test/suite/sys_vars/r/group_concat_max_len_func.result index 30e2639af37..01f44ae51be 100644 --- a/mysql-test/suite/sys_vars/r/group_concat_max_len_func.result +++ b/mysql-test/suite/sys_vars/r/group_concat_max_len_func.result @@ -94,4 +94,58 @@ DROP TABLE t1; disconnect test_con2; disconnect test_con1; connection default; +CREATE TABLE t1(val VARCHAR(100) PRIMARY KEY) CHARACTER SET utf8mb4 COLLATE utf8mb4_danish_ci; +INSERT INTO t1 VALUES('bar'); +INSERT INTO t1 VALUES('foo'); +SET group_concat_max_len = 1073741823; +SHOW VARIABLES LIKE 'group_concat_max_len'; +Variable_name Value +group_concat_max_len 1073741823 +SELECT GROUP_CONCAT(val) AS simple FROM t1; +simple +bar,foo +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; +nested +bar,foo +SET group_concat_max_len = 1073741824; +SHOW VARIABLES LIKE 'group_concat_max_len'; +Variable_name Value +group_concat_max_len 1073741824 +SELECT GROUP_CONCAT(val) AS simple FROM t1; +simple +bar,foo +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; +nested +bar,foo +SET group_concat_max_len = 1073741825; +SHOW VARIABLES LIKE 'group_concat_max_len'; +Variable_name Value +group_concat_max_len 1073741825 +SELECT GROUP_CONCAT(val) AS simple FROM t1; +simple +bar,foo +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; +nested +bar,foo +SET group_concat_max_len = 1073741826; +SHOW VARIABLES LIKE 'group_concat_max_len'; +Variable_name Value +group_concat_max_len 1073741826 +SELECT GROUP_CONCAT(val) AS simple FROM t1; +simple +bar,foo +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; +nested +bar,foo +SET group_concat_max_len = 2147483649; +SHOW VARIABLES LIKE 'group_concat_max_len'; +Variable_name Value +group_concat_max_len 2147483649 +SELECT GROUP_CONCAT(val) AS simple FROM t1; +simple +bar,foo +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; +nested +bar,foo +DROP TABLE t1; SET @@global.group_concat_max_len = @save; diff --git a/mysql-test/suite/sys_vars/t/group_concat_max_len_func.test b/mysql-test/suite/sys_vars/t/group_concat_max_len_func.test index b053ee229d7..d90fc061289 100644 --- a/mysql-test/suite/sys_vars/t/group_concat_max_len_func.test +++ b/mysql-test/suite/sys_vars/t/group_concat_max_len_func.test @@ -132,4 +132,35 @@ disconnect test_con1; connection default; +CREATE TABLE t1(val VARCHAR(100) PRIMARY KEY) CHARACTER SET utf8mb4 COLLATE utf8mb4_danish_ci; +INSERT INTO t1 VALUES('bar'); +INSERT INTO t1 VALUES('foo'); + +SET group_concat_max_len = 1073741823; +SHOW VARIABLES LIKE 'group_concat_max_len'; +SELECT GROUP_CONCAT(val) AS simple FROM t1; +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; + +SET group_concat_max_len = 1073741824; +SHOW VARIABLES LIKE 'group_concat_max_len'; +SELECT GROUP_CONCAT(val) AS simple FROM t1; +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; + +SET group_concat_max_len = 1073741825; +SHOW VARIABLES LIKE 'group_concat_max_len'; +SELECT GROUP_CONCAT(val) AS simple FROM t1; +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; + +SET group_concat_max_len = 1073741826; +SHOW VARIABLES LIKE 'group_concat_max_len'; +SELECT GROUP_CONCAT(val) AS simple FROM t1; +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; + +SET group_concat_max_len = 2147483649; +SHOW VARIABLES LIKE 'group_concat_max_len'; +SELECT GROUP_CONCAT(val) AS simple FROM t1; +SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp; + +DROP TABLE t1; + SET @@global.group_concat_max_len = @save; diff --git a/mysql-test/suite/sysschema/r/pr_create_synonym_db.result b/mysql-test/suite/sysschema/r/pr_create_synonym_db.result index bd7e4edc6e6..8c0e8dfa957 100644 --- a/mysql-test/suite/sysschema/r/pr_create_synonym_db.result +++ b/mysql-test/suite/sysschema/r/pr_create_synonym_db.result @@ -50,3 +50,17 @@ DROP TABLE test.t1; DROP TABLE test.t2; DROP TABLE `is`; DROP TABLE `ab``c`; +# +# MDEV-28342: sys.create_synonym_db fails +# when a temporary table masks a base table +# +create database db; +use db; +create table a(a int); +create table t (b int); +create table b(a int); +create temporary table b (a int); +call sys.create_synonym_db('db','db_copy'); +ERROR HY000: Table`db`.`b`shadows base table. View cannot be created! Terminating! +drop database db; +drop database db_copy; diff --git a/mysql-test/suite/sysschema/r/pr_diagnostics.result b/mysql-test/suite/sysschema/r/pr_diagnostics.result index 90021f636d8..d07295bdbe9 100644 --- a/mysql-test/suite/sysschema/r/pr_diagnostics.result +++ b/mysql-test/suite/sysschema/r/pr_diagnostics.result @@ -6,6 +6,8 @@ SET @sys.debug = 'OFF', @sys.diagnostics.allow_i_s_tables = 'OFF', @sys.diagnostics.include_raw = 'OFF'; CALL sys.diagnostics(0, 0, 'full'); +summary +Disabled 1 thread ERROR 45000: in_max_runtime must be greater than 0 CALL sys.diagnostics(2, 0, 'full'); ERROR 45000: in_interval must be greater than 0 diff --git a/mysql-test/suite/sysschema/r/pr_table_exists.result b/mysql-test/suite/sysschema/r/pr_table_exists.result index 83db569eecf..76085bd72dd 100644 --- a/mysql-test/suite/sysschema/r/pr_table_exists.result +++ b/mysql-test/suite/sysschema/r/pr_table_exists.result @@ -42,3 +42,31 @@ ERROR 22001: Data too long for column 'in_db' at row 1 CALL sys.table_exists('test', @identifier, @exists); ERROR 22001: Data too long for column 'in_table' at row 0 SET @identifier := NULL; +# +# MDEV-28391: table_exists procedure fails with +# Incorrect table name with backtick identifiers +# +CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CALL sys.table_exists('test', 'ab`c', @tbl_type); +SELECT @tbl_type; +@tbl_type +BASE TABLE +DROP TABLE `ab``c`; +CREATE TEMPORARY TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CALL sys.table_exists('test', 'ab`c', @tbl_type); +SELECT @tbl_type; +@tbl_type +TEMPORARY +DROP TABLE `ab``c`; +CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CREATE TEMPORARY TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CALL sys.table_exists('test', 'ab`c', @tbl_type); +SELECT @tbl_type; +@tbl_type +TEMPORARY +# We cannot send quoted identifer to the procedure, no table will be found +CALL sys.table_exists('test', '`ab``c`', @tbl_type); +SELECT @tbl_type; +@tbl_type + +DROP TABLE `ab``c`; diff --git a/mysql-test/suite/sysschema/t/pr_create_synonym_db.test b/mysql-test/suite/sysschema/t/pr_create_synonym_db.test index 4fbe8759380..30c6f502e30 100644 --- a/mysql-test/suite/sysschema/t/pr_create_synonym_db.test +++ b/mysql-test/suite/sysschema/t/pr_create_synonym_db.test @@ -50,3 +50,20 @@ DROP TABLE test.t1; DROP TABLE test.t2; DROP TABLE `is`; DROP TABLE `ab``c`; + +--echo # +--echo # MDEV-28342: sys.create_synonym_db fails +--echo # when a temporary table masks a base table +--echo # + +create database db; +use db; +create table a(a int); +create table t (b int); +create table b(a int); +create temporary table b (a int); +--error ER_SIGNAL_EXCEPTION +call sys.create_synonym_db('db','db_copy'); + +drop database db; +drop database db_copy; diff --git a/mysql-test/suite/sysschema/t/pr_diagnostics.test b/mysql-test/suite/sysschema/t/pr_diagnostics.test index 01825a1274e..40ea90005a9 100644 --- a/mysql-test/suite/sysschema/t/pr_diagnostics.test +++ b/mysql-test/suite/sysschema/t/pr_diagnostics.test @@ -19,7 +19,6 @@ SET @sys.debug = 'ON', @sys.diagnostics.allow_i_s_tables = 'ON', @sys.diagnostics.include_raw = 'ON'; ---error ER_ILLEGAL_HA_CREATE_OPTION CALL sys.diagnostics(4, 2, 'full'); SET @sys.debug = 'OFF', diff --git a/mysql-test/suite/sysschema/t/pr_table_exists.test b/mysql-test/suite/sysschema/t/pr_table_exists.test index d0c538843b1..83e1dc0b9d9 100644 --- a/mysql-test/suite/sysschema/t/pr_table_exists.test +++ b/mysql-test/suite/sysschema/t/pr_table_exists.test @@ -46,3 +46,24 @@ CALL sys.table_exists(@identifier, 't1', @exists); CALL sys.table_exists('test', @identifier, @exists); SET @identifier := NULL; + +--echo # +--echo # MDEV-28391: table_exists procedure fails with +--echo # Incorrect table name with backtick identifiers +--echo # +CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CALL sys.table_exists('test', 'ab`c', @tbl_type); +SELECT @tbl_type; +DROP TABLE `ab``c`; +CREATE TEMPORARY TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CALL sys.table_exists('test', 'ab`c', @tbl_type); +SELECT @tbl_type; +DROP TABLE `ab``c`; +CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CREATE TEMPORARY TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); +CALL sys.table_exists('test', 'ab`c', @tbl_type); +SELECT @tbl_type; +--echo # We cannot send quoted identifer to the procedure, no table will be found +CALL sys.table_exists('test', '`ab``c`', @tbl_type); +SELECT @tbl_type; +DROP TABLE `ab``c`;
\ No newline at end of file diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index b7bd63f662e..4ec57413a15 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2; create table t1 (a int, b int, v int as (a+1), index idx(b)); insert into t1(a, b) values (4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10); @@ -247,7 +246,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `a` bigint(20) DEFAULT NULL, - `b` bigint(20) GENERATED ALWAYS AS (`a` > '2') VIRTUAL + `b` bigint(20) GENERATED ALWAYS AS (`a` > 2) VIRTUAL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 insert into t1 (a) values (1),(3); select * from t1; @@ -450,9 +449,6 @@ SET sql_mode=DEFAULT; # End of 10.1 tests # # -# Start of 10.2 tests -# -# # MDEV-16518 MYSQL57_GENERATED_FIELD: The code in TABLE_SHARE::init_from_binary_frm_image() is not safe # SHOW TABLES; @@ -531,5 +527,26 @@ a b DROP TABLE t1; SET sql_mode=DEFAULT; # +# CONTEXT_ANALYSIS_ONLY_VCOL_EXPR +# +call mtr.add_suppression("Charset id.*trying to replace"); +create table t1 (c1 char(1) character set ucs2 collate ucs2_test_ci, +v1 char(1) character set ucs2 collate ucs2_test_ci as (c1), +v2 int as (c1 = 'b'), +v3 int as (v1 = 'b')); +insert into t1 (c1) values ('a'); +select * from t1 where v1 = 'b'; +c1 v1 v2 v3 +a a 1 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` char(1) CHARACTER SET ucs2 COLLATE ucs2_test_ci DEFAULT NULL, + `v1` char(1) CHARACTER SET ucs2 GENERATED ALWAYS AS (`c1`) VIRTUAL, + `v2` int(11) GENERATED ALWAYS AS (`c1` = 'b') VIRTUAL, + `v3` int(11) GENERATED ALWAYS AS (`v1` = 'b') VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +# # End of 10.2 tests # diff --git a/mysql-test/suite/vcol/r/vcol_syntax.result b/mysql-test/suite/vcol/r/vcol_syntax.result index a799c13cd92..ffe5ec495c3 100644 --- a/mysql-test/suite/vcol/r/vcol_syntax.result +++ b/mysql-test/suite/vcol/r/vcol_syntax.result @@ -183,8 +183,17 @@ select a from t1 order by 'x' = b; a drop table t1; create table t1 (a int , b date as (1 in ('x' ,(database ()) ))) ; +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'test' select b from t1; b +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'test' select a from t1 order by 'x' = b; a +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'x' +Warning 1292 Truncated incorrect DOUBLE value: 'test' drop table t1; diff --git a/mysql-test/suite/vcol/r/wrong_arena.result b/mysql-test/suite/vcol/r/wrong_arena.result index cd36801f601..d5ba19b3db3 100644 --- a/mysql-test/suite/vcol/r/wrong_arena.result +++ b/mysql-test/suite/vcol/r/wrong_arena.result @@ -1,3 +1,6 @@ +# +# MDEV-9690 concurrent queries with virtual columns crash in temporal code +# create table t1 (a datetime, # get_datetime_value b int as (a > 1), # Arg_comparator @@ -59,6 +62,9 @@ a b Warnings: Warning 1292 Truncated incorrect datetime value: '1' drop table t1; +# +# MDEV-13435 Crash when selecting virtual columns generated using JSON functions +# create table t1 ( id int not null , js varchar(1000) not null, @@ -68,3 +74,16 @@ select * from t1; id js t 0 {"default" : {"start": "00:00:00", "end":"23:59:50"}} NULL drop table t1; +# +# MDEV-26281 ASAN use-after-poison when complex conversion is involved in blob +# +create table t1 (v2 blob as ('a' is null), a1 int, a char(1) as (cast(a1 in (0,current_user() is null) as char(16777216) ))); +insert ignore into t1 values ('x','x',v2) ; +Warnings: +Warning 1906 The value specified for generated column 'v2' in table 't1' has been ignored +Warning 1366 Incorrect integer value: 'x' for column `test`.`t1`.`a1` at row 1 +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/vcol/t/vcol_misc.opt b/mysql-test/suite/vcol/t/vcol_misc.opt new file mode 100644 index 00000000000..fd1faea4f8e --- /dev/null +++ b/mysql-test/suite/vcol/t/vcol_misc.opt @@ -0,0 +1 @@ +--character-sets-dir=$MYSQL_TEST_DIR/std_data/ldml/ diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test index 6f770190bb1..3062e5a685d 100644 --- a/mysql-test/suite/vcol/t/vcol_misc.test +++ b/mysql-test/suite/vcol/t/vcol_misc.test @@ -3,10 +3,6 @@ let $MYSQLD_DATADIR= `select @@datadir`; ---disable_warnings -drop table if exists t1,t2; ---enable_warnings - # # Bug#601164: DELETE/UPDATE with ORDER BY index and LIMIT # @@ -419,11 +415,6 @@ SET sql_mode=DEFAULT; --echo # End of 10.1 tests --echo # - ---echo # ---echo # Start of 10.2 tests ---echo # - --echo # --echo # MDEV-16518 MYSQL57_GENERATED_FIELD: The code in TABLE_SHARE::init_from_binary_frm_image() is not safe --echo # @@ -506,5 +497,20 @@ DROP TABLE t1; SET sql_mode=DEFAULT; --echo # +--echo # CONTEXT_ANALYSIS_ONLY_VCOL_EXPR +--echo # + +--source include/have_ucs2.inc +call mtr.add_suppression("Charset id.*trying to replace"); +create table t1 (c1 char(1) character set ucs2 collate ucs2_test_ci, + v1 char(1) character set ucs2 collate ucs2_test_ci as (c1), + v2 int as (c1 = 'b'), + v3 int as (v1 = 'b')); +insert into t1 (c1) values ('a'); +select * from t1 where v1 = 'b'; +show create table t1; +drop table t1; + +--echo # --echo # End of 10.2 tests --echo # diff --git a/mysql-test/suite/vcol/t/wrong_arena.test b/mysql-test/suite/vcol/t/wrong_arena.test index 8ac1af5c36b..296cb68f5c0 100644 --- a/mysql-test/suite/vcol/t/wrong_arena.test +++ b/mysql-test/suite/vcol/t/wrong_arena.test @@ -3,9 +3,9 @@ # not in the TABLE::expr_arena. # -# -# MDEV-9690 concurrent queries with virtual columns crash in temporal code -# +--echo # +--echo # MDEV-9690 concurrent queries with virtual columns crash in temporal code +--echo # create table t1 (a datetime, # get_datetime_value b int as (a > 1), # Arg_comparator @@ -40,9 +40,9 @@ connection default; select * from t1; drop table t1; -# -# MDEV-13435 Crash when selecting virtual columns generated using JSON functions -# +--echo # +--echo # MDEV-13435 Crash when selecting virtual columns generated using JSON functions +--echo # create table t1 ( id int not null , js varchar(1000) not null, @@ -50,3 +50,14 @@ create table t1 ( insert into t1(id,js) values (0, '{"default" : {"start": "00:00:00", "end":"23:59:50"}}'); select * from t1; drop table t1; + +--echo # +--echo # MDEV-26281 ASAN use-after-poison when complex conversion is involved in blob +--echo # +create table t1 (v2 blob as ('a' is null), a1 int, a char(1) as (cast(a1 in (0,current_user() is null) as char(16777216) ))); +insert ignore into t1 values ('x','x',v2) ; +drop table t1; + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/mysql-test/suite/versioning/r/delete_history.result b/mysql-test/suite/versioning/r/delete_history.result index 9e72826dac1..382b567a106 100644 --- a/mysql-test/suite/versioning/r/delete_history.result +++ b/mysql-test/suite/versioning/r/delete_history.result @@ -62,8 +62,10 @@ partition by system_time limit 1 partitions 3; insert into t values (1); update t set a= 2; update t set a= 3; +Warnings: +Warning 4114 Versioned table `test`.`t`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ delete history from t; -# The above warning is one command late (MDEV-20345) ^^^ select * from t for system_time all; a 3 diff --git a/mysql-test/suite/versioning/r/partition,heap.rdiff b/mysql-test/suite/versioning/r/partition,heap.rdiff index 779b715f813..0844017d1f4 100644 --- a/mysql-test/suite/versioning/r/partition,heap.rdiff +++ b/mysql-test/suite/versioning/r/partition,heap.rdiff @@ -1,6 +1,6 @@ --- partition.result +++ partition,heap.reject -@@ -1582,85 +1582,6 @@ +@@ -2120,85 +2120,6 @@ (PARTITION `p0` HISTORY ENGINE = X, PARTITION `pn` CURRENT ENGINE = X) drop tables t1, tp1; @@ -84,9 +84,9 @@ - PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X) -drop tables t1, tp1; # - # MDEV-17554 Auto-create new partition for system versioned tables with history partitioned by INTERVAL/LIMIT + # End of 10.7 tests # -@@ -2193,134 +2114,6 @@ +@@ -2753,134 +2674,6 @@ Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p0`) is out of INTERVAL, need more HISTORY partitions drop prepare s; affected rows: 0 diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index bb8fb980f45..dd8d217185d 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -1,5 +1,5 @@ -SET @save_persistent=@@GLOBAL.innodb_stats_persistent; -SET GLOBAL innodb_stats_persistent=0; +set @save_persistent=@@global.innodb_stats_persistent; +set global innodb_stats_persistent= 0; call mtr.add_suppression("need more HISTORY partitions"); set system_versioning_alter_history=keep; # Check conventional partitioning on temporal tables @@ -267,6 +267,9 @@ x 6 delete from t1 where x < 4; delete from t1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ select * from t1 partition (p0); x 1 @@ -282,6 +285,7 @@ insert into t1 values (7), (8); delete from t1; Warnings: Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ select * from t1 partition (p1) order by x; x 4 @@ -670,10 +674,13 @@ x 4 delete from t1 where x < 3; delete from t1; -### warn about full partition +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ delete from t1; Warnings: Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ (no matter if nothing was deleted) select * from t1 partition (p0sp0); x 1 @@ -849,7 +856,11 @@ partition p1 history, partition p2 history, partition pn current); delete from t1 where x = 1; +# You see warning above ^ delete from t1 where x = 2; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ # # MDEV-14923 Assertion upon INSERT into locked versioned partitioned table # @@ -972,9 +983,13 @@ create or replace table t1 (x int) with system versioning partition by system_ti lock tables t1 write; insert into t1 values (0), (1), (2), (3); delete from t1 where x < 3; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ delete from t1; Warnings: Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ unlock tables; # # MDEV-20336 Assertion bitmap_is_set(read_partitions) upon SELECT FOR UPDATE from versioned table @@ -1098,6 +1113,7 @@ 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'; +# You see warning above ^ 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 @@ -1107,6 +1123,8 @@ partition by system_time limit 1 insert into t1 values (null); update t1 set f= 'foo'; update t1 set f= 'bar'; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions 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 @@ -1235,8 +1253,335 @@ delete from t1; unlock tables; drop table t1; set timestamp= default; +# +# MDEV-25546 LIMIT partitioning does not respect ROLLBACK +# +create or replace table t1 (pk int primary key) +with system versioning engine innodb +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_1_to_90; +start transaction; +replace into t1 select seq from seq_1_to_80; +replace into t1 select seq from seq_1_to_70; +replace into t1 select seq from seq_1_to_60; +select partition_name, table_rows +from information_schema.partitions +where table_name = 't1'; +partition_name table_rows +p0 150 +p1 60 +pn 90 +rollback; +select partition_name, table_rows +from information_schema.partitions +where table_name = 't1'; +partition_name table_rows +p0 0 +p1 0 +pn 90 +replace into t1 select seq from seq_1_to_10; +select partition_name, table_rows +from information_schema.partitions +where table_name = 't1'; +partition_name table_rows +p0 10 +p1 0 +pn 90 +drop table t1; +# +# MDEV-28271 Assertion on TRUNCATE PARTITION for PARTITION BY SYSTEM_TIME +# +create table t1 (x int) with system versioning +partition by system_time limit 1 ( +partition p0 history, +partition p1 history, +partition p2 history, # p2 just disables warning about p1 partition full +partition pn current); +insert into t1 values (0); +update t1 set x= x + 1; +update t1 set x= x + 1; +select * from t1 partition (p0); +x +0 +select * from t1 partition (p1); +x +1 +select * from t1 partition (pn); +x +2 +delete from t1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions +delete history from t1; +select * from t1 partition (p0); +x +select * from t1 partition (p1); +x +select * from t1 partition (pn); +x +insert into t1 values (0); +update t1 set x= x + 1; +update t1 set x= x + 1; +# TRUNCATE PARTITION ALL does the same +alter table t1 truncate partition all; +select * from t1 partition (p0); +x +select * from t1 partition (p1); +x +select * from t1 partition (pn); +x +insert into t1 values (0); +update t1 set x= x + 1; +update t1 set x= x + 1; +# TRUNCATE PARTITION deletes data from HISTORY partition +alter table t1 truncate partition p1; +select * from t1 partition (p0); +x +0 +select * from t1 partition (p1); +x +select * from t1 partition (pn); +x +2 +# or from CURRENT partition +alter table t1 truncate partition pn; +select * from t1 partition (p0); +x +0 +select * from t1 partition (p1); +x +select * from t1 partition (pn); +x +drop table t1; +# +# MDEV-20077 Warning on full history partition is delayed until next DML statement +# +# DELETE +create table t1 (x int) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_200; +# p0 is filled with 100 records (no warnings): +delete from t1 where x <= 99; +# p1 is filled with 1 + 100 records (warning is printed): +delete from t1 where x <= 100; +delete from t1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +101 +drop table t1; +# DELETE under LOCK TABLES +create table t1 (x int) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_200; +lock tables t1 write; +# (LOCK TABLES) p0 is filled with 100 records (no warnings): +delete from t1 where x <= 99; +# (LOCK TABLES) p1 is filled with 1 + 100 records (warning is printed): +delete from t1 where x <= 100; +delete from t1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +unlock tables; +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +101 +drop table t1; +# DELETE multitable +create table t1 (x int) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +create table t2 (y int); +insert into t1 select seq from seq_0_to_200; +insert into t2 select seq from seq_0_to_3; +delete t1, t2 from t1 join t2 where x < 50 and y = 0; +delete t1, t2 from t1 join t2 where x < 100 and y = 1; +delete t1, t2 from t1 join t2 where x < 150 and y = 2; +delete t1, t2 from t1 join t2; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +101 +drop table t1; +# UDPATE +create table t1 (x int) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_49; +update t1 set x= x + 1; +update t1 set x= x + 1; +update t1 set x= x + 1; +update t1 set x= x + 1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +100 +drop tables t1, t2; +# UPDATE multitable +create table t1 (x int) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +create table t2 (y int); +insert into t1 select seq from seq_0_to_49; +insert into t2 values (5); +update t1, t2 set x= x + 1; +update t1, t2 set x= x + 1; +update t1, t2 set x= x + 1; +update t1, t2 set x= x + 1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +100 +drop tables t1, t2; +# INSERT .. ON DUPLICATE KEY UPDATE (ODKU) +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_100; +delete from t1 where x <= 99; +insert into t1 values (100) on duplicate key update x= 400; +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +1 +drop table t1; +# INSERT .. SELECT .. ON DUPLICATE KEY UPDATE (ODKU) +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +create table t2 (y int); +insert into t2 values (100); +insert into t1 select seq from seq_0_to_100; +delete from t1 where x <= 99; +insert into t1 select * from t2 on duplicate key update x= 500; +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +1 +drop tables t1, t2; +# REPLACE +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_100; +delete from t1 where x < 99; +replace t1 values (100); +replace t1 values (100); +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +1 +drop table t1; +# LOAD DATA .. REPLACE +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_49; +select x into outfile 'MDEV-20077.data' from t1; +load data infile 'MDEV-20077.data' replace into table t1 (x); +load data infile 'MDEV-20077.data' replace into table t1 (x); +load data infile 'MDEV-20077.data' replace into table t1 (x); +load data infile 'MDEV-20077.data' replace into table t1 (x); +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +100 +drop table t1; +# REPLACE .. SELECT +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( +partition p0 history, +partition p1 history, +partition pn current); +insert into t1 select seq from seq_0_to_49; +replace t1 select * from t1; +replace t1 select * from t1; +replace t1 select * from t1; +replace t1 select * from t1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p1`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ +select count(*) from t1 partition (p0); +count(*) +100 +select count(*) from t1 partition (p1); +count(*) +100 +drop table t1; +# +# MDEV-28552 Assertion `inited==RND' failed in handler::ha_rnd_end +# +create table tcount (c int unsigned); +insert into tcount values (0); +create table t (f int) with system versioning +partition by system_time limit 1000 +(partition p1 history, partition pn current); +insert into t values (1),(2); +create trigger tr before insert on t for each row update tcount set c = c + 1; +insert into t select * from t; +drop table tcount, t; +# # 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 @@ -1268,8 +1613,10 @@ select * from t1 where i > 0 or pk = 1000 limit 1; pk i c 1 1 a drop table t1; +# # End of 10.4 tests # +# # MDEV-22153 ALTER add default history partitions makes table inaccessible # create or replace table t1 (x int) with system versioning partition by system_time; @@ -1474,6 +1821,9 @@ t1 CREATE TABLE `t1` ( PARTITIONS 6 update t1 set x= x + 1; update t1 set x= x + 1; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p4`) is out of LIMIT, need more HISTORY partitions +# You see warning above ^ select * from t1 partition (p0); x 0 @@ -1638,6 +1988,8 @@ insert into t1 values (2), (12), (22); update t1 set x= x + 1 where x = 2; update t1 set x= x + 1 where x = 12; update t1 set x= x + 1 where x = 22; +Warnings: +Warning 4114 Versioned table `test`.`t1`: last HISTORY partition (`p2`) is out of LIMIT, need more HISTORY partitions select * from t1 partition (p1); x 12 @@ -1860,6 +2212,9 @@ t1 CREATE TABLE `t1` ( PARTITION `pn` VALUES LESS THAN MAXVALUE ENGINE = X) drop tables t1, tp1; # +# End of 10.7 tests +# +# # MDEV-17554 Auto-create new partition for system versioned tables # with history partitioned by INTERVAL/LIMIT # @@ -2105,10 +2460,10 @@ affected rows: 1 update t1 set x= x + 1; affected rows: 1 info: Rows matched: 1 Changed: 1 Inserted: 1 Warnings: 0 -update t1 set x= x + 1; +update t1 set x= x + 2; affected rows: 1 info: Rows matched: 1 Changed: 1 Inserted: 1 Warnings: 0 -update t1 set x= x + 1; +update t1 set x= x + 3; affected rows: 1 info: Rows matched: 1 Changed: 1 Inserted: 1 Warnings: 0 show create table t1; @@ -2902,4 +3257,4 @@ delete from t partition (px); ERROR HY000: Unknown partition 'px' in table 't' unlock tables; drop table t; -SET GLOBAL innodb_stats_persistent=@save_persistent; +set global innodb_stats_persistent= @save_persistent; diff --git a/mysql-test/suite/versioning/r/rpl_row.result b/mysql-test/suite/versioning/r/rpl_row.result index 124993423e7..ab96268f5a6 100644 --- a/mysql-test/suite/versioning/r/rpl_row.result +++ b/mysql-test/suite/versioning/r/rpl_row.result @@ -12,6 +12,44 @@ connection master; drop table t1; set binlog_row_image= @old_row_image; # +# MDEV-28254 Wrong position for row_start, row_end after adding column +# to implicit versioned table +# +set @@system_versioning_alter_history= keep; +set @@session.time_zone='+00:00'; +create table t1 (x int) with system versioning engine innodb; +alter table t1 add column y int, algorithm=inplace; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +connection slave; +drop table t1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) DEFAULT NULL, + `y` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING +connection master; +set timestamp= 12345; +insert t1 values (1, 1); +select *, unix_timestamp(row_start) as row_start, unix_timestamp(row_end) as row_end from t1; +x y row_start row_end +1 1 12345.000000 2147483647.999999 +set timestamp= default; +### INSERT INTO `test`.`t1` +### SET +### @1=1 +### @2=1 +### @3=12345.000000 +### @4=2147483647.999999 +connection slave; +select * from t1; +x y +1 1 +connection master; +drop table t1; +# # MDEV-25347 DML events for auto-partitioned tables are written into binary log twice # flush binary logs; diff --git a/mysql-test/suite/versioning/t/delete_history.test b/mysql-test/suite/versioning/t/delete_history.test index b9d957f461c..634eccee996 100644 --- a/mysql-test/suite/versioning/t/delete_history.test +++ b/mysql-test/suite/versioning/t/delete_history.test @@ -63,8 +63,8 @@ partition by system_time limit 1 partitions 3; insert into t values (1); update t set a= 2; update t set a= 3; +--echo # You see warning above ^ delete history from t; ---echo # The above warning is one command late (MDEV-20345) ^^^ select * from t for system_time all; --echo # VIEW diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index de7536f0e6c..23fd35650cb 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -1,9 +1,10 @@ -- source include/have_partition.inc -- source suite/versioning/common.inc -- source suite/versioning/engines.inc +-- source include/have_sequence.inc -SET @save_persistent=@@GLOBAL.innodb_stats_persistent; -SET GLOBAL innodb_stats_persistent=0; +set @save_persistent=@@global.innodb_stats_persistent; +set global innodb_stats_persistent= 0; call mtr.add_suppression("need more HISTORY partitions"); @@ -241,12 +242,14 @@ insert into t1 values (1), (2), (3), (4), (5), (6); select * from t1 partition (pn); delete from t1 where x < 4; delete from t1; +--echo # You see warning above ^ select * from t1 partition (p0); select * from t1 partition (p1); insert into t1 values (7), (8); --echo ### warn about full partition delete from t1; +--echo # You see warning above ^ select * from t1 partition (p1) order by x; --echo # @@ -509,8 +512,9 @@ select * from t1 partition (pnsp1); delete from t1 where x < 3; delete from t1; ---echo ### warn about full partition +--echo # You see warning above ^ delete from t1; +--echo # You see warning above ^ (no matter if nothing was deleted) select * from t1 partition (p0sp0); select * from t1 partition (p0sp1); select * from t1 partition (p1sp0); @@ -686,7 +690,9 @@ alter table t1 partition by system_time limit 1 ( partition p2 history, partition pn current); delete from t1 where x = 1; +--echo # You see warning above ^ delete from t1 where x = 2; +--echo # You see warning above ^ --echo # --echo # MDEV-14923 Assertion upon INSERT into locked versioned partitioned table @@ -814,7 +820,9 @@ create or replace table t1 (x int) with system versioning partition by system_ti lock tables t1 write; insert into t1 values (0), (1), (2), (3); delete from t1 where x < 3; +--echo # You see warning above ^ delete from t1; +--echo # You see warning above ^ unlock tables; --echo # @@ -929,6 +937,7 @@ 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'; +--echo # You see warning above ^ create or replace view v1 as select * from t1 for system_time all; --error ER_TABLE_NOT_LOCKED_FOR_WRITE @@ -1089,7 +1098,312 @@ delete from t1; unlock tables; drop table t1; set timestamp= default; + +--echo # +--echo # MDEV-25546 LIMIT partitioning does not respect ROLLBACK +--echo # +create or replace table t1 (pk int primary key) +with system versioning engine innodb +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); +insert into t1 select seq from seq_1_to_90; + +start transaction; +# Puts 80 rows into p0 +replace into t1 select seq from seq_1_to_80; +# Puts another 70 rows into p0 +replace into t1 select seq from seq_1_to_70; +# Puts 60 rows into p1 +replace into t1 select seq from seq_1_to_60; + +select partition_name, table_rows +from information_schema.partitions +where table_name = 't1'; +rollback; + +select partition_name, table_rows +from information_schema.partitions +where table_name = 't1'; + +# Should put 10 rows into the empty partition p0 +replace into t1 select seq from seq_1_to_10; +select partition_name, table_rows +from information_schema.partitions +where table_name = 't1'; + # Cleanup +drop table t1; + +--echo # +--echo # MDEV-28271 Assertion on TRUNCATE PARTITION for PARTITION BY SYSTEM_TIME +--echo # +create table t1 (x int) with system versioning +partition by system_time limit 1 ( + partition p0 history, + partition p1 history, + partition p2 history, # p2 just disables warning about p1 partition full + partition pn current); + +insert into t1 values (0); +update t1 set x= x + 1; +update t1 set x= x + 1; + +select * from t1 partition (p0); +select * from t1 partition (p1); +select * from t1 partition (pn); + +delete from t1; +delete history from t1; +select * from t1 partition (p0); +select * from t1 partition (p1); +select * from t1 partition (pn); + +insert into t1 values (0); +update t1 set x= x + 1; +update t1 set x= x + 1; + +--echo # TRUNCATE PARTITION ALL does the same +alter table t1 truncate partition all; +select * from t1 partition (p0); +select * from t1 partition (p1); +select * from t1 partition (pn); + +insert into t1 values (0); +update t1 set x= x + 1; +update t1 set x= x + 1; + +--echo # TRUNCATE PARTITION deletes data from HISTORY partition +alter table t1 truncate partition p1; +select * from t1 partition (p0); +select * from t1 partition (p1); +select * from t1 partition (pn); + +--echo # or from CURRENT partition +alter table t1 truncate partition pn; +select * from t1 partition (p0); +select * from t1 partition (p1); +select * from t1 partition (pn); + +drop table t1; + +--echo # +--echo # MDEV-20077 Warning on full history partition is delayed until next DML statement +--echo # +--echo # DELETE +create table t1 (x int) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_200; + +--echo # p0 is filled with 100 records (no warnings): +delete from t1 where x <= 99; +--echo # p1 is filled with 1 + 100 records (warning is printed): +delete from t1 where x <= 100; +delete from t1; +--echo # You see warning above ^ + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; + +--echo # DELETE under LOCK TABLES +create table t1 (x int) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_200; + +lock tables t1 write; +--echo # (LOCK TABLES) p0 is filled with 100 records (no warnings): +delete from t1 where x <= 99; +--echo # (LOCK TABLES) p1 is filled with 1 + 100 records (warning is printed): +delete from t1 where x <= 100; +delete from t1; +--echo # You see warning above ^ +unlock tables; + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; + +--echo # DELETE multitable +create table t1 (x int) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +create table t2 (y int); + +insert into t1 select seq from seq_0_to_200; +insert into t2 select seq from seq_0_to_3; +delete t1, t2 from t1 join t2 where x < 50 and y = 0; +delete t1, t2 from t1 join t2 where x < 100 and y = 1; +delete t1, t2 from t1 join t2 where x < 150 and y = 2; +delete t1, t2 from t1 join t2; +--echo # You see warning above ^ + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; + +--echo # UDPATE +create table t1 (x int) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_49; + +update t1 set x= x + 1; +update t1 set x= x + 1; +update t1 set x= x + 1; +update t1 set x= x + 1; +--echo # You see warning above ^ + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop tables t1, t2; + +--echo # UPDATE multitable +create table t1 (x int) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +create table t2 (y int); + +insert into t1 select seq from seq_0_to_49; +insert into t2 values (5); + +update t1, t2 set x= x + 1; +update t1, t2 set x= x + 1; +update t1, t2 set x= x + 1; +update t1, t2 set x= x + 1; +--echo # You see warning above ^ + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop tables t1, t2; + +--echo # INSERT .. ON DUPLICATE KEY UPDATE (ODKU) +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_100; + +delete from t1 where x <= 99; +insert into t1 values (100) on duplicate key update x= 400; + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; + +--echo # INSERT .. SELECT .. ON DUPLICATE KEY UPDATE (ODKU) +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +create table t2 (y int); +insert into t2 values (100); +insert into t1 select seq from seq_0_to_100; + +delete from t1 where x <= 99; +insert into t1 select * from t2 on duplicate key update x= 500; + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop tables t1, t2; + +--echo # REPLACE +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_100; + +delete from t1 where x < 99; +replace t1 values (100); +replace t1 values (100); + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; + +--echo # LOAD DATA .. REPLACE +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_49; +select x into outfile 'MDEV-20077.data' from t1; + +load data infile 'MDEV-20077.data' replace into table t1 (x); +load data infile 'MDEV-20077.data' replace into table t1 (x); +load data infile 'MDEV-20077.data' replace into table t1 (x); +load data infile 'MDEV-20077.data' replace into table t1 (x); +--echo # You see warning above ^ + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; +--remove_file $datadir/test/MDEV-20077.data + +--echo # REPLACE .. SELECT +create table t1 (x int primary key) with system versioning +partition by system_time limit 100 ( + partition p0 history, + partition p1 history, + partition pn current); + +insert into t1 select seq from seq_0_to_49; +replace t1 select * from t1; +replace t1 select * from t1; +replace t1 select * from t1; +replace t1 select * from t1; +--echo # You see warning above ^ + +select count(*) from t1 partition (p0); +select count(*) from t1 partition (p1); +drop table t1; + +--echo # +--echo # MDEV-28552 Assertion `inited==RND' failed in handler::ha_rnd_end +--echo # +create table tcount (c int unsigned); +insert into tcount values (0); + +create table t (f int) with system versioning +partition by system_time limit 1000 +(partition p1 history, partition pn current); +insert into t values (1),(2); +create trigger tr before insert on t for each row update tcount set c = c + 1; + +insert into t select * from t; + +# cleanup +drop table tcount, t; + +--echo # --echo # End of 10.3 tests +--echo # --echo # --echo # MDEV-22283 Server crashes in key_copy or unexpected error 156: The table already existed in the storage engine @@ -1121,7 +1435,9 @@ replace into t1 select * from t1; select * from t1 where i > 0 or pk = 1000 limit 1; drop table t1; +--echo # --echo # End of 10.4 tests +--echo # --echo # --echo # MDEV-22153 ALTER add default history partitions makes table inaccessible @@ -1232,6 +1548,7 @@ alter table t1 partition by system_time limit 1; show create table t1; update t1 set x= x + 1; update t1 set x= x + 1; +--echo # You see warning above ^ select * from t1 partition (p0); select * from t1 partition (p1); select * from t1 partition (p2); @@ -1443,6 +1760,10 @@ drop tables t1, tp1; } --echo # +--echo # End of 10.7 tests +--echo # + +--echo # --echo # MDEV-17554 Auto-create new partition for system versioned tables --echo # with history partitioned by INTERVAL/LIMIT --echo # @@ -1592,8 +1913,8 @@ partition by system_time limit 1 auto; lock tables t1 write; insert into t1 values (1); update t1 set x= x + 1; -update t1 set x= x + 1; -update t1 set x= x + 1; +update t1 set x= x + 2; +update t1 set x= x + 3; --replace_result $default_engine DEFAULT_ENGINE show create table t1; unlock tables; @@ -2177,5 +2498,6 @@ unlock tables; drop table t; --disable_prepare_warnings -SET GLOBAL innodb_stats_persistent=@save_persistent; +set global innodb_stats_persistent= @save_persistent; + --source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/rpl_row.test b/mysql-test/suite/versioning/t/rpl_row.test index a9b12e52a41..e36d77fc023 100644 --- a/mysql-test/suite/versioning/t/rpl_row.test +++ b/mysql-test/suite/versioning/t/rpl_row.test @@ -1,5 +1,6 @@ --source include/have_binlog_format_row.inc --source include/master-slave.inc +--source include/have_innodb.inc --echo # MDEV-16252: MINIMAL binlog_row_image does not work for versioned tables set @old_row_image= @@binlog_row_image; @@ -15,4 +16,44 @@ update t1 set i = 0; drop table t1; set binlog_row_image= @old_row_image; +--echo # +--echo # MDEV-28254 Wrong position for row_start, row_end after adding column +--echo # to implicit versioned table +--echo # +--let TMP= $MYSQLTEST_VARDIR/tmp +--let $MYSQLD_DATADIR= `select @@datadir` +set @@system_versioning_alter_history= keep; +set @@session.time_zone='+00:00'; + +create table t1 (x int) with system versioning engine innodb; +alter table t1 add column y int, algorithm=inplace; +check table t1; +--exec $MYSQL_DUMP --databases test > $TMP/dump.sql + +--sync_slave_with_master +drop table t1; +--exec $MYSQL_SLAVE test < $TMP/dump.sql +show create table t1; + +--connection master +set timestamp= 12345; +--let $start_pos= query_get_value("SHOW MASTER STATUS", Position, 1) +insert t1 values (1, 1); +select *, unix_timestamp(row_start) as row_start, unix_timestamp(row_end) as row_end from t1; +--let $stop_pos= query_get_value("SHOW MASTER STATUS", Position, 1) +set timestamp= default; + +# NOTE: pipe grep is not Windows-compatible +--let grep_file= $TMP/out.txt +--let grep_regex= ^### +--exec $MYSQL_BINLOG -v -j $start_pos --stop-position=$stop_pos -o 3 $MYSQLD_DATADIR/master-bin.000001 > $grep_file +--source include/grep.inc +--sync_slave_with_master +select * from t1; + +--connection master +drop table t1; +--remove_files_wildcard $TMP *.txt +--remove_files_wildcard $TMP *.sql + --source rpl_common.inc diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result deleted file mode 100644 index aaeabff9663..00000000000 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink.result +++ /dev/null @@ -1,174 +0,0 @@ -# -# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above -# -# Verbose run -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -START TRANSACTION; -ELSE -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -END IF| -\d ; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it. -Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. -UNLOCK TABLES; -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=Aria; -ALTER TABLE time_zone_name ENGINE=Aria; -ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; -END IF| -\d ; -# Silent run -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -START TRANSACTION; -ELSE -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -END IF| -\d ; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -UNLOCK TABLES; -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=Aria; -ALTER TABLE time_zone_name ENGINE=Aria; -ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; -END IF| -\d ; -# -# Testing with explicit timezonefile -# -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -SELECT 'skip truncate tables'; -START TRANSACTION; -ELSE -SELECT 'skip truncate tables'; -END IF| -\d ; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -UNLOCK TABLES; -COMMIT; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=Aria; -ALTER TABLE time_zone_name ENGINE=Aria; -ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; -END IF| -\d ; -# -# Testing --leap -# -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=InnoDB; -ALTER TABLE time_zone_name ENGINE=InnoDB; -ALTER TABLE time_zone_transition ENGINE=InnoDB; -ALTER TABLE time_zone_transition_type ENGINE=InnoDB; -SELECT 'skip truncate tables'; -START TRANSACTION; -ELSE -SELECT 'skip truncate tables'; -END IF| -\d ; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone_leap_second ENGINE=InnoDB; -END IF| -\d ; -TRUNCATE TABLE time_zone_leap_second; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone_leap_second ENGINE=Aria; -END IF| -\d ; -ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -UNLOCK TABLES; -COMMIT; -\d | -IF (select count(*) from information_schema.global_variables where -variable_name='wsrep_on' and variable_value='ON') = 1 THEN -ALTER TABLE time_zone ENGINE=Aria; -ALTER TABLE time_zone_name ENGINE=Aria; -ALTER TABLE time_zone_transition ENGINE=Aria, ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ENGINE=Aria, ORDER BY Time_zone_id, Transition_type_id; -END IF| -\d ; diff --git a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result b/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result deleted file mode 100644 index 1b1785347f3..00000000000 --- a/mysql-test/suite/wsrep/r/mysql_tzinfo_to_sql_symlink_skip.result +++ /dev/null @@ -1,104 +0,0 @@ -# -# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above -# -# Verbose run -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -LOCK TABLES time_zone WRITE, - time_zone_leap_second WRITE, - time_zone_name WRITE, - time_zone_transition WRITE, - time_zone_transition_type WRITE; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/ignored.tab' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/ignored.tab' as time zone. Skipping it. -Warning: Skipping directory 'MYSQLTEST_VARDIR/zoneinfo/posix/posix': to avoid infinite symlink recursion. -UNLOCK TABLES; -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -# Silent run -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -TRUNCATE TABLE time_zone; -TRUNCATE TABLE time_zone_name; -TRUNCATE TABLE time_zone_transition; -TRUNCATE TABLE time_zone_transition_type; -LOCK TABLES time_zone WRITE, - time_zone_leap_second WRITE, - time_zone_name WRITE, - time_zone_transition WRITE, - time_zone_transition_type WRITE; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/garbage' as time zone. Skipping it. -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('posix/GMT', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -Warning: Unable to load 'MYSQLTEST_VARDIR/zoneinfo/posix/garbage' as time zone. Skipping it. -UNLOCK TABLES; -COMMIT; -ALTER TABLE time_zone_transition ORDER BY Time_zone_id, Transition_time; -ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id; -# -# Testing with explicit timezonefile -# -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -SELECT 'skip truncate tables'; -LOCK TABLES time_zone WRITE, - time_zone_leap_second WRITE, - time_zone_name WRITE, - time_zone_transition WRITE, - time_zone_transition_type WRITE; -INSERT INTO time_zone (Use_leap_seconds) VALUES ('N'); -SET @time_zone_id= LAST_INSERT_ID(); -INSERT INTO time_zone_name (Name, Time_zone_id) VALUES ('XXX', @time_zone_id); -INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset`, Is_DST, Abbreviation) VALUES - (@time_zone_id, 0, 0, 0, 'GMT') -; -UNLOCK TABLES; -COMMIT; -# -# Testing --leap -# -set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?'); -prepare set_wsrep_write_binlog from @prep1; -set @toggle=0; execute set_wsrep_write_binlog using @toggle; -SELECT 'skip truncate tables'; -LOCK TABLES time_zone WRITE, - time_zone_leap_second WRITE, - time_zone_name WRITE, - time_zone_transition WRITE, - time_zone_transition_type WRITE; -TRUNCATE TABLE time_zone_leap_second; -ALTER TABLE time_zone_leap_second ORDER BY Transition_time; -UNLOCK TABLES; -COMMIT; diff --git a/plugin/auth_pam/auth_pam.c b/plugin/auth_pam/auth_pam.c index 12e958b706b..ffcfa019294 100644 --- a/plugin/auth_pam/auth_pam.c +++ b/plugin/auth_pam/auth_pam.c @@ -21,6 +21,7 @@ #include <string.h> #include <sys/types.h> #include <sys/wait.h> +#include <spawn.h> #include <mysql/plugin_auth.h> #include "auth_pam_tool.h" @@ -51,71 +52,57 @@ static int pam_auth(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) unsigned char field, *pkt; unsigned int n_sleep= 0; useconds_t sleep_time= 100; + posix_spawn_file_actions_t file_actions; + char toolpath[FN_REFLEN]; + size_t plugin_dir_len= strlen(opt_plugin_dir); + char *const argv[2]= {toolpath, 0}; + int res; PAM_DEBUG((stderr, "PAM: opening pipes.\n")); if (pipe(p_to_c) < 0 || pipe(c_to_p) < 0) { - /* Error creating pipes. */ + my_printf_error(ENOEXEC, "pam: cannot create pipes (errno: %M)", + ME_ERROR_LOG_ONLY, errno); return CR_ERROR; } - PAM_DEBUG((stderr, "PAM: forking.\n")); - if ((proc_id= fork()) < 0) + + if (plugin_dir_len + tool_name_len + 2 > sizeof(toolpath)) { - /* Error forking. */ - close(p_to_c[0]); - close(c_to_p[1]); - goto error_ret; + my_printf_error(ENOEXEC, "pam: too long path to <plugindir>/%s", + ME_ERROR_LOG_ONLY, tool_name); + return CR_ERROR; } - if (proc_id == 0) - { - /* The 'sandbox' process started. */ - char toolpath[FN_REFLEN]; - size_t plugin_dir_len= strlen(opt_plugin_dir); - - PAM_DEBUG((stderr, "PAM: Child process prepares pipes.\n")); - - if (close(p_to_c[1]) < 0 || - close(c_to_p[0]) < 0 || - dup2(p_to_c[0], 0) < 0 || /* Parent's pipe to STDIN. */ - dup2(c_to_p[1], 1) < 0) /* Sandbox's pipe to STDOUT. */ - { - exit(-1); - } + memcpy(toolpath, opt_plugin_dir, plugin_dir_len); + if (plugin_dir_len && toolpath[plugin_dir_len-1] != FN_LIBCHAR) + toolpath[plugin_dir_len++]= FN_LIBCHAR; + memcpy(toolpath+plugin_dir_len, tool_name, tool_name_len+1); - PAM_DEBUG((stderr, "PAM: check tool directory: %s, %s.\n", - opt_plugin_dir, tool_name)); - if (plugin_dir_len + tool_name_len + 2 > sizeof(toolpath)) - { - /* Tool path too long. */ - exit(-1); - } - - memcpy(toolpath, opt_plugin_dir, plugin_dir_len); - if (plugin_dir_len && toolpath[plugin_dir_len-1] != FN_LIBCHAR) - toolpath[plugin_dir_len++]= FN_LIBCHAR; - memcpy(toolpath+plugin_dir_len, tool_name, tool_name_len+1); - - PAM_DEBUG((stderr, "PAM: execute pam sandbox [%s].\n", toolpath)); - (void) execl(toolpath, toolpath, NULL); - PAM_DEBUG((stderr, "PAM: exec() failed.\n")); - my_printf_error(1, "PAM: Cannot execute %s (errno: %M)", ME_ERROR_LOG_ONLY, - toolpath, errno); - exit(-1); - } + PAM_DEBUG((stderr, "PAM: forking %s\n", toolpath)); + res= posix_spawn_file_actions_init(&file_actions) || + posix_spawn_file_actions_addclose(&file_actions, p_to_c[1]) || + posix_spawn_file_actions_addclose(&file_actions, c_to_p[0]) || + posix_spawn_file_actions_adddup2(&file_actions, p_to_c[0], 0) || + posix_spawn_file_actions_adddup2(&file_actions, c_to_p[1], 1) || + posix_spawn(&proc_id, toolpath, &file_actions, NULL, argv, NULL); /* Parent process continues. */ + posix_spawn_file_actions_destroy(&file_actions); + close(p_to_c[0]); + close(c_to_p[1]); - PAM_DEBUG((stderr, "PAM: parent continues.\n")); - if (close(p_to_c[0]) < 0 || - close(c_to_p[1]) < 0) + if (res) + { + my_printf_error(ENOEXEC, "pam: cannot exec %s (errno: %M)", + ME_ERROR_LOG_ONLY, toolpath, errno); goto error_ret; + } /* no user name yet ? read the client handshake packet with the user name */ if (info->user_name == 0) { if ((pkt_len= vio->read_packet(vio, &pkt)) < 0) - return CR_ERROR; + goto error_ret; } else pkt= NULL; diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index e8eacc2bd5d..3c94df243d0 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -16,7 +16,7 @@ #define PLUGIN_VERSION 0x104 -#define PLUGIN_STR_VERSION "1.4.13" +#define PLUGIN_STR_VERSION "1.4.14" #define _my_thread_var loc_thread_var @@ -954,7 +954,19 @@ static unsigned long long query_counter= 1; static struct connection_info *get_loc_info(MYSQL_THD thd) { + /* + This is the original code and supposed to be returned + bach to this as the MENT-1438 is finally understood/resolved. return (struct connection_info *) THDVAR(thd, loc_info); + */ + struct connection_info *ci= (struct connection_info *) THDVAR(thd, loc_info); + if ((size_t) ci->user_length > sizeof(ci->user)) + { + ci->user_length= 0; + ci->host_length= 0; + ci->ip_length= 0; + } + return ci; } @@ -1390,6 +1402,16 @@ static size_t log_header(char *message, size_t message_len, host= userip; } + /* + That was added to find the possible cause of the MENT-1438. + Supposed to be removed after that. + */ + if (username_len > 1024) + { + username= "unknown_user"; + username_len= (unsigned int) strlen(username); + } + if (output_type == OUTPUT_SYSLOG) return my_snprintf(message, message_len, "%.*s,%.*s,%.*s,%d,%lld,%s", diff --git a/scripts/galera_new_cluster.sh b/scripts/galera_new_cluster.sh index e0763ed516a..ac9dcf42102 100755 --- a/scripts/galera_new_cluster.sh +++ b/scripts/galera_new_cluster.sh @@ -22,7 +22,7 @@ EOF fi systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' && \ - systemctl start ${1:-mariadb} + systemctl restart ${1:-mariadb} extcode=$? diff --git a/scripts/sys_schema/CMakeLists.txt b/scripts/sys_schema/CMakeLists.txt index f2f206a1a93..ccb268cc4fd 100644 --- a/scripts/sys_schema/CMakeLists.txt +++ b/scripts/sys_schema/CMakeLists.txt @@ -167,6 +167,7 @@ SET(files ${CMAKE_CURRENT_SOURCE_DIR}/after_setup.sql) ENDIF() +SET_PROPERTY(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${files}) SET(CMAKE_CONFIGURABLE_FILE_CONTENT) FOREACH(f ${files}) diff --git a/scripts/sys_schema/procedures/create_synonym_db.sql b/scripts/sys_schema/procedures/create_synonym_db.sql index 703ec9bff3b..e373a9b4ee6 100644 --- a/scripts/sys_schema/procedures/create_synonym_db.sql +++ b/scripts/sys_schema/procedures/create_synonym_db.sql @@ -97,9 +97,8 @@ BEGIN DECLARE v_db_err_msg TEXT; DECLARE v_table VARCHAR(64); DECLARE v_views_created INT DEFAULT 0; - - DECLARE db_doesnt_exist CONDITION FOR SQLSTATE '42000'; - DECLARE db_name_exists CONDITION FOR SQLSTATE 'HY000'; + DECLARE v_table_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY') DEFAULT ''; + DECLARE v_temp_table TEXT; DECLARE c_table_names CURSOR FOR SELECT TABLE_NAME @@ -144,6 +143,21 @@ BEGIN LEAVE c_table_names; END IF; + -- Check does temporary table shadows the base table. If it is so, terminate. + CALL sys.table_exists(in_db_name, v_table, v_table_exists); + IF (v_table_exists = 'TEMPORARY') THEN + SET v_temp_table = + CONCAT( + 'Table', + sys.quote_identifier(in_db_name), + '.', + sys.quote_identifier(v_table), + 'shadows base table. View cannot be created! Terminating!'); + SIGNAL SQLSTATE 'HY000' + SET MESSAGE_TEXT = v_temp_table; + LEAVE c_table_names; + END IF; + SET @create_view_stmt = CONCAT( 'CREATE SQL SECURITY INVOKER VIEW ', sys.quote_identifier(in_synonym), diff --git a/scripts/sys_schema/procedures/ps_setup_save.sql b/scripts/sys_schema/procedures/ps_setup_save.sql index a5a2197e935..b7843ecd1f2 100644 --- a/scripts/sys_schema/procedures/ps_setup_save.sql +++ b/scripts/sys_schema/procedures/ps_setup_save.sql @@ -80,14 +80,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp_setup_instruments; DROP TEMPORARY TABLE IF EXISTS tmp_threads; - CREATE TEMPORARY TABLE tmp_setup_actors LIKE performance_schema.setup_actors; - CREATE TEMPORARY TABLE tmp_setup_consumers LIKE performance_schema.setup_consumers; - CREATE TEMPORARY TABLE tmp_setup_instruments LIKE performance_schema.setup_instruments; + CREATE TEMPORARY TABLE tmp_setup_actors AS SELECT * FROM performance_schema.setup_actors; + CREATE TEMPORARY TABLE tmp_setup_consumers AS SELECT * FROM performance_schema.setup_consumers; + CREATE TEMPORARY TABLE tmp_setup_instruments AS SELECT * FROM performance_schema.setup_instruments; CREATE TEMPORARY TABLE tmp_threads (THREAD_ID bigint unsigned NOT NULL PRIMARY KEY, INSTRUMENTED enum('YES','NO') NOT NULL); - INSERT INTO tmp_setup_actors SELECT * FROM performance_schema.setup_actors; - INSERT INTO tmp_setup_consumers SELECT * FROM performance_schema.setup_consumers; - INSERT INTO tmp_setup_instruments SELECT * FROM performance_schema.setup_instruments; INSERT INTO tmp_threads SELECT THREAD_ID, INSTRUMENTED FROM performance_schema.threads; ELSE SIGNAL SQLSTATE VALUE '90000' diff --git a/scripts/sys_schema/procedures/table_exists.sql b/scripts/sys_schema/procedures/table_exists.sql index 8a17e0e19f4..0f7640329e7 100644 --- a/scripts/sys_schema/procedures/table_exists.sql +++ b/scripts/sys_schema/procedures/table_exists.sql @@ -133,6 +133,8 @@ CREATE DEFINER='mariadb.sys'@'localhost' PROCEDURE table_exists ( CONTAINS SQL BEGIN DECLARE v_error BOOLEAN DEFAULT FALSE; + DECLARE db_quoted VARCHAR(64); + DECLARE table_quoted VARCHAR(64); DECLARE v_table_type VARCHAR(16) DEFAULT ''; DECLARE v_system_db BOOLEAN DEFAULT LOWER(in_db) IN ('information_schema', 'performance_schema'); @@ -140,19 +142,28 @@ BEGIN DECLARE CONTINUE HANDLER FOR 1146 SET v_error = TRUE; SET out_exists = ''; + SET db_quoted = sys.quote_identifier(in_db); + SET table_quoted = sys.quote_identifier(in_table); -- Verify whether the table name exists as a normal table IF (EXISTS(SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table)) THEN -- Unfortunately the only way to determine whether there is also a temporary table is to try to create -- a temporary table with the same name. If it succeeds the table didn't exist as a temporary table. IF v_system_db = FALSE THEN - SET @sys.tmp.table_exists.SQL = CONCAT('CREATE TEMPORARY TABLE `', in_db, '`.`', in_table, '` (id INT PRIMARY KEY)'); + SET @sys.tmp.table_exists.SQL = CONCAT('CREATE TEMPORARY TABLE ', + db_quoted, + '.', + table_quoted, + '(id INT PRIMARY KEY)'); PREPARE stmt_create_table FROM @sys.tmp.table_exists.SQL; EXECUTE stmt_create_table; DEALLOCATE PREPARE stmt_create_table; -- The temporary table was created, i.e. it didn't exist. Remove it again so we don't leave garbage around. - SET @sys.tmp.table_exists.SQL = CONCAT('DROP TEMPORARY TABLE `', in_db, '`.`', in_table, '`'); + SET @sys.tmp.table_exists.SQL = CONCAT('DROP TEMPORARY TABLE ', + db_quoted, + '.', + table_quoted); PREPARE stmt_drop_table FROM @sys.tmp.table_exists.SQL; EXECUTE stmt_drop_table; DEALLOCATE PREPARE stmt_drop_table; @@ -174,7 +185,10 @@ BEGIN -- If it does it's possible to SELECT from the table without causing an error. -- If it does not exist even a PREPARE using the table will fail. IF v_system_db = FALSE THEN - SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM `', in_db, '`.`', in_table, '`'); + SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM ', + db_quoted, + '.', + table_quoted); PREPARE stmt_select FROM @sys.tmp.table_exists.SQL; IF (NOT v_error) THEN DEALLOCATE PREPARE stmt_select; diff --git a/scripts/wsrep_sst_backup.sh b/scripts/wsrep_sst_backup.sh index 55e11ddffc0..301739905b6 100644 --- a/scripts/wsrep_sst_backup.sh +++ b/scripts/wsrep_sst_backup.sh @@ -64,7 +64,7 @@ then [ -f "$FLUSHED" ] && rm -f "$FLUSHED" [ -f "$ERROR" ] && rm -f "$ERROR" - echo "flush tables" + echo "flush tables" # Wait for : # (a) Tables to be flushed, AND @@ -72,7 +72,7 @@ then # (c) ERROR file, in case flush tables operation failed. while [ ! -r "$FLUSHED" ] && \ - ! grep -q -F ':' '--' "$FLUSHED" >/dev/null 2>&1 + ! grep -q -F ':' -- "$FLUSHED" >/dev/null 2>&1 do # Check whether ERROR file exists. if [ -f "$ERROR" ]; then @@ -98,15 +98,11 @@ then echo "done $STATE" -elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ] -then - wsrep_log_error "Unrecognized role: '$WSREP_SST_OPT_ROLE'" - exit 22 # EINVAL - +else # joiner -else - wsrep_log_error "Unrecognized role: '$WSREP_SST_OPT_ROLE'" + wsrep_log_error "Unsupported role: '$WSREP_SST_OPT_ROLE'" exit 22 # EINVAL + fi exit 0 diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index cc5db9e9e01..9d69ddf63a1 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -17,7 +17,8 @@ # This is a common command line parser to be sourced by other SST scripts -set -ue +trap 'exit 32' HUP PIPE +trap 'exit 3' INT QUIT TERM # Setting the path for some utilities on CentOS export PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin" @@ -184,7 +185,7 @@ case "$1" in shift ;; '--bypass') - WSREP_SST_OPT_BYPASS=1 + readonly WSREP_SST_OPT_BYPASS=1 ;; '--datadir') # Let's remove the trailing slash: @@ -511,7 +512,24 @@ case "$1" in esac shift done -readonly WSREP_SST_OPT_BYPASS + +WSREP_TRANSFER_TYPE='SST' +[ $WSREP_SST_OPT_BYPASS -ne 0 ] && readonly WSREP_TRANSFER_TYPE='IST' +# Let's take the name of the current script as a base, +# removing the directory, extension and "wsrep_sst_" prefix: +WSREP_METHOD="${0##*/}" +WSREP_METHOD="${WSREP_METHOD%.*}" +readonly WSREP_METHOD="${WSREP_METHOD#wsrep_sst_}" +if [ -n "${WSREP_SST_OPT_ROLE+x}" ]; then + if [ "$WSREP_SST_OPT_ROLE" != 'donor' -a \ + "$WSREP_SST_OPT_ROLE" != 'joiner' ] + then + wsrep_log_error "Unrecognized role: '$WSREP_SST_OPT_ROLE'" + exit 22 # EINVAL + fi +else + readonly WSREP_SST_OPT_ROLE='donor' +fi # The same argument can be present on the command line several # times, in this case we must take its last value: @@ -719,7 +737,7 @@ wsrep_log() { # echo everything to stderr so that it gets into common error log # deliberately made to look different from the rest of the log - local readonly tst="$(date +%Y%m%d\ %H:%M:%S.%N | cut -b -21)" + local readonly tst=$(date "+%Y%m%d %H:%M:%S.%N" | cut -b -21) echo "WSREP_SST: $* ($tst)" >&2 } @@ -1050,7 +1068,7 @@ is_local_ip() [ "$1" = '127.0.0.1' -o \ "$1" = '127.0.0.2' -o \ "$1" = 'localhost' -o \ - "$1" = '[::1]' ] && return 0 + "$1" = '::1' ] && return 0 # If the address starts with "127." this is probably a local # address, but we need to clarify what follows this prefix: if [ "${1#127.}" != "$1" ]; then @@ -1067,21 +1085,25 @@ is_local_ip() "$1" = "$(hostname -f)" -o \ "$1" = "$(hostname -d)" ] && return 0 fi + # If the address contains anything other than digits + # and separators, it is not a local address: + [ "${1#*[!0-9.]}" != "$1" ] && \ + [ "${1#*[!0-9A-Fa-f:\[\]]}" != "$1" ] && return 1 # Now let's check if the given address is assigned to # one of the network cards: local ip_util=$(commandex 'ip') if [ -n "$ip_util" ]; then # ip address show ouput format is " inet[6] <address>/<mask>": "$ip_util" address show \ - | grep -E '^[[:space:]]*inet.? [^[:space:]]+/' -o \ - | grep -F " $1/" >/dev/null && return 0 + | grep -o -E '^[[:space:]]*inet.?[[:space:]]+[^[:space:]]+/' \ + | grep -qw -F -- "$1/" && return 0 else local ifconfig_util=$(commandex 'ifconfig') if [ -n "$ifconfig_util" ]; then # ifconfig output format is " inet[6] <address> ...": "$ifconfig_util" \ - | grep -E '^[[:space:]]*inet.? [^[:space:]]+ ' -o \ - | grep -F " $1 " >/dev/null && return 0 + | grep -o -E '^[[:space:]]*inet.?[[:space:]]+[^[:space:]]+' \ + | grep -qw -F -- "$1" && return 0 fi fi return 1 @@ -1403,7 +1425,7 @@ get_proc() if [ -z "$nproc" ]; then set +e if [ "$OS" = 'Linux' ]; then - nproc=$(grep -c processor /proc/cpuinfo 2>/dev/null) + nproc=$(grep -cw -E '^processor' /proc/cpuinfo 2>/dev/null) elif [ "$OS" = 'Darwin' -o "$OS" = 'FreeBSD' ]; then nproc=$(sysctl -n hw.ncpu) fi @@ -1452,3 +1474,19 @@ check_server_ssl_config() fi fi } + +simple_cleanup() +{ + # Since this is invoked just after exit NNN + local estatus=$? + if [ $estatus -ne 0 ]; then + wsrep_log_error "Cleanup after exit with status: $estatus" + fi + if [ -n "${SST_PID:-}" ]; then + [ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD" + [ -f "$SST_PID" ] && rm -f "$SST_PID" || : + fi + exit $estatus +} + +wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE started on $WSREP_SST_OPT_ROLE" diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index c8426a1d533..d622fc3b1d9 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -87,7 +87,7 @@ encrypt_chunk="" readonly SECRET_TAG='secret' readonly TOTAL_TAG='total' -readonly COMPLETE_TAG='complete' +readonly TOTAL_TAG_SST="$SECRET_TAG /$TOTAL_TAG" # Required for backup locks # For backup locks it is 1 sent by joiner @@ -164,12 +164,10 @@ get_keys() exit 3 fi - if [ -z "$ekey" ]; then - if [ ! -r "$ekeyfile" ]; then - wsrep_log_error "FATAL: Either key must be specified" \ - "or keyfile must be readable" - exit 3 - fi + if [ -z "$ekey" -a ! -r "$ekeyfile" ]; then + wsrep_log_error "FATAL: Either key must be specified" \ + "or keyfile must be readable" + exit 3 fi if [ "$eformat" = 'openssl' ]; then @@ -216,9 +214,7 @@ get_keys() exit 2 fi - if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then - ecmd="$ecmd -d" - fi + [ "$WSREP_SST_OPT_ROLE" = 'joiner' ] && ecmd="$ecmd -d" stagemsg="$stagemsg-XB-Encrypted" } @@ -323,7 +319,8 @@ get_transfer() if [ -z "$ssl_dhparams" ]; then # Determine the socat version SOCAT_VERSION=$(socat -V 2>&1 | \ - grep -m1 -owE '[0-9]+(\.[0-9]+)+' | head -n1) + grep -m1 -owE '[0-9]+(\.[0-9]+)+' | \ + head -n1 || :) if [ -z "$SOCAT_VERSION" ]; then wsrep_log_error "******** FATAL ERROR ******************" wsrep_log_error "* Cannot determine the socat version. *" @@ -639,18 +636,6 @@ get_stream() wsrep_log_info "Streaming with $sfmt" } -sig_joiner_cleanup() -{ - local estatus=$? - if [ $estatus -ne 0 ]; then - wsrep_log_error "Cleanup after exit with status: $estatus" - fi - wsrep_log_error "Removing $MAGIC_FILE file due to signal" - [ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD" - [ -f "$MAGIC_FILE" ] && rm -f "$MAGIC_FILE" - exit $estatus -} - cleanup_at_exit() { # Since this is invoked just after exit NNN @@ -661,6 +646,11 @@ cleanup_at_exit() [ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD" + if [ $estatus -ne 0 ]; then + wsrep_log_error "Removing $MAGIC_FILE file due to signal" + [ -f "$MAGIC_FILE" ] && rm -f "$MAGIC_FILE" || : + fi + if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then wsrep_log_info "Removing the sst_in_progress file" wsrep_cleanup_progress_file @@ -690,7 +680,7 @@ cleanup_at_exit() fi # Final cleanup - pgid=$(ps -o pgid= $$ 2>/dev/null | grep -o -E '[0-9]*' || :) + pgid=$(ps -o pgid= $$ 2>/dev/null | grep -o -E '[0-9]+' || :) # This means no setsid done in mysqld. # We don't want to kill mysqld here otherwise. @@ -786,17 +776,15 @@ recv_joiner() fi fi - pushd "$dir" 1>/dev/null - set +e - if [ $wait -ne 0 ]; then wait_for_listen & fi + cd "$dir" + set +e timeit "$msg" "$ltcmd | $strmcmd; RC=( "\${PIPESTATUS[@]}" )" - set -e - popd 1>/dev/null + cd "$OLD_PWD" if [ ${RC[0]} -eq 124 ]; then wsrep_log_error "Possible timeout in receiving first data from" \ @@ -814,17 +802,21 @@ recv_joiner() if [ $checkf -eq 1 ]; then if [ ! -r "$MAGIC_FILE" ]; then - # this message should cause joiner to abort + # this message should cause joiner to abort: wsrep_log_error "receiving process ended without creating" \ - "'$MAGIC_FILE'" - wsrep_log_info "Contents of datadir" + "magic file ($MAGIC_FILE)" + wsrep_log_info "Contents of datadir:" wsrep_log_info $(ls -l "$dir/"*) exit 32 fi - - # check donor supplied secret - SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \ - cut -d ' ' -f2) + # Select the "secret" tag whose value does not start + # with a slash symbol. All new tags must to start with + # the space and the slash symbol after the word "secret" - + # to be removed by older versions of the SST scripts: + SECRET=$(grep -m1 -E "^$SECRET_TAG[[:space:]]+[^/]" \ + -- "$MAGIC_FILE" || :) + # Check donor supplied secret: + SECRET=$(trim_string "${SECRET#$SECRET_TAG}") if [ "$SECRET" != "$MY_SECRET" ]; then wsrep_log_error "Donor does not know my secret!" wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'" @@ -832,16 +824,12 @@ recv_joiner() fi # check total SST footprint - total=$(grep -F -- "$TOTAL_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) + total=$(grep -F -- "$TOTAL_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 3) if [ $total -ge 0 ]; then # report to parent echo "$TOTAL_TAG $total" fi - # remove secret and total from the magic file - grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" | \ - grep -v -F -- "$TOTAL_TAG " > "$MAGIC_FILE.new" - mv "$MAGIC_FILE.new" "$MAGIC_FILE" fi } @@ -850,11 +838,11 @@ send_donor() local dir="$1" local msg="$2" - pushd "$dir" 1>/dev/null + cd "$dir" set +e timeit "$msg" "$strmcmd | $tcmd; RC=( "\${PIPESTATUS[@]}" )" set -e - popd 1>/dev/null + cd "$OLD_PWD" for ecode in "${RC[@]}"; do if [ $ecode -ne 0 ]; then @@ -869,7 +857,7 @@ monitor_process() { local sst_stream_pid=$1 - while true ; do + while :; do if ! ps -p "$WSREP_SST_OPT_PARENT" >/dev/null 2>&1; then wsrep_log_error \ "Parent mysqld process (PID: $WSREP_SST_OPT_PARENT)" \ @@ -886,13 +874,6 @@ monitor_process() [ -f "$MAGIC_FILE" ] && rm -f "$MAGIC_FILE" -if [ "$WSREP_SST_OPT_ROLE" != 'joiner' -a \ - "$WSREP_SST_OPT_ROLE" != 'donor' ] -then - wsrep_log_error "Invalid role '$WSREP_SST_OPT_ROLE'" - exit 22 -fi - read_cnf setup_ports @@ -1009,8 +990,8 @@ setup_commands() get_stream get_transfer -if [ "$WSREP_SST_OPT_ROLE" = 'donor' ] -then +if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then + trap cleanup_at_exit EXIT if [ $WSREP_SST_OPT_BYPASS -eq 0 ] @@ -1062,7 +1043,7 @@ then echo "$WSREP_SST_OPT_GTID $WSREP_SST_OPT_GTID_DOMAIN_ID" > "$MAGIC_FILE" # Tell joiner what to expect: - echo "$TOTAL_TAG $payload" >> "$MAGIC_FILE" + echo "$TOTAL_TAG_SST $payload" >> "$MAGIC_FILE" if [ -n "$WSREP_SST_OPT_REMOTE_PSWD" ]; then # Let joiner know that we know its secret @@ -1140,6 +1121,7 @@ then fi setup_commands + set +e timeit "$stagemsg-SST" "$INNOBACKUP | $tcmd; RC=( "\${PIPESTATUS[@]}" )" set -e @@ -1183,10 +1165,9 @@ then echo "done $WSREP_SST_OPT_GTID" wsrep_log_info "Total time on donor: $totime seconds" - wsrep_log_info "mariabackup SST/IST completed on donor" -elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ] -then +else # joiner + [ -e "$SST_PROGRESS_FILE" ] && \ wsrep_log_info "Stale sst_in_progress file: $SST_PROGRESS_FILE" [ -n "$SST_PROGRESS_FILE" ] && touch "$SST_PROGRESS_FILE" @@ -1257,6 +1238,7 @@ then sleep 1 done + trap simple_cleanup EXIT echo $$ > "$SST_PID" stagemsg='Joiner-Recv' @@ -1266,7 +1248,7 @@ then [ -f "$DATA/$IST_FILE" ] && rm -f "$DATA/$IST_FILE" # May need xtrabackup_checkpoints later on - [ -f "$DATA/xtrabackup_binary" ] && rm -f "$DATA/xtrabackup_binary" + [ -f "$DATA/xtrabackup_binary" ] && rm -f "$DATA/xtrabackup_binary" [ -f "$DATA/xtrabackup_galera_info" ] && rm -f "$DATA/xtrabackup_galera_info" ADDR="$WSREP_SST_OPT_HOST" @@ -1293,7 +1275,6 @@ then MY_SECRET="" # for check down in recv_joiner() fi - trap sig_joiner_cleanup HUP PIPE INT TERM trap cleanup_at_exit EXIT get_keys @@ -1323,8 +1304,7 @@ then recv_joiner "$STATDIR" "$stagemsg-gtid" $stimeout 1 1 - if ! ps -p "$WSREP_SST_OPT_PARENT" >/dev/null 2>&1 - then + if ! ps -p "$WSREP_SST_OPT_PARENT" >/dev/null 2>&1; then wsrep_log_error "Parent mysqld process (PID: $WSREP_SST_OPT_PARENT)" \ "terminated unexpectedly." exit 32 @@ -1352,13 +1332,13 @@ then cd "$DATA" wsrep_log_info "Cleaning the old binary logs" # If there is a file with binlogs state, delete it: - [ -f "$binlog_base.state" ] && rm -fv "$binlog_base.state" 1>&2 + [ -f "$binlog_base.state" ] && rm -f "$binlog_base.state" >&2 # Clean up the old binlog files and index: if [ -f "$binlog_index" ]; then while read bin_file || [ -n "$bin_file" ]; do - rm -fv "$bin_file" 1>&2 || : + rm -f "$bin_file" >&2 || : done < "$binlog_index" - rm -fv "$binlog_index" 1>&2 + rm -f "$binlog_index" >&2 fi if [ -n "$binlog_dir" -a "$binlog_dir" != '.' -a \ -d "$binlog_dir" ] @@ -1369,7 +1349,7 @@ then "Cleaning the binlog directory '$binlog_dir' as well" fi fi - rm -fv "$binlog_base".[0-9]* 1>&2 || : + rm -f "$binlog_base".[0-9]* >&2 || : cd "$OLD_PWD" fi @@ -1380,13 +1360,13 @@ then ${ib_undo_dir:+"$ib_undo_dir"} \ ${ib_log_dir:+"$ib_log_dir"} \ "$DATA" -mindepth 1 -prune -regex "$cpat" \ - -o -exec rm -rfv {} 1>&2 \+ + -o -exec rm -rf {} >&2 \+ else find ${ib_home_dir:+"$ib_home_dir"} \ ${ib_undo_dir:+"$ib_undo_dir"} \ ${ib_log_dir:+"$ib_log_dir"} \ "$DATA" -mindepth 1 -prune -regex "$cpat" \ - -o -exec rm -rfv {} 1>&2 \+ + -o -exec rm -rf {} >&2 \+ fi TDATA="$DATA" @@ -1458,7 +1438,6 @@ then wsrep_log_info "Preparing the backup at $DATA" setup_commands timeit 'mariabackup prepare stage' "$INNOAPPLY" - if [ $? -ne 0 ]; then wsrep_log_error "mariabackup apply finished with errors." \ "Check syslog or '$INNOAPPLYLOG' for details." @@ -1515,6 +1494,10 @@ then else wsrep_log_info "'$IST_FILE' received from donor: Running IST" + if [ $WSREP_SST_OPT_BYPASS -eq 0 ]; then + readonly WSREP_SST_OPT_BYPASS=1 + readonly WSREP_TRANSFER_TYPE='IST' + fi fi @@ -1523,12 +1506,13 @@ then exit 2 fi - coords=$(cat "$MAGIC_FILE") + # Remove special tags from the magic file, and from the output: + coords=$(grep -v -E "^$SECRET_TAG[[:space:]]" -- "$MAGIC_FILE") wsrep_log_info "Galera co-ords from recovery: $coords" - cat "$MAGIC_FILE" # Output : UUID:seqno wsrep_gtid_domain_id + echo "$coords" # Output : UUID:seqno wsrep_gtid_domain_id wsrep_log_info "Total time on joiner: $totime seconds" - wsrep_log_info "mariabackup SST/IST completed on joiner" fi +wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE completed on $WSREP_SST_OPT_ROLE" exit 0 diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index 3c92f489cb5..e1efcbf11ad 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -163,10 +163,11 @@ then echo "$STOP_WSREP" && $MYSQLDUMP && echo "$CSV_TABLES_FIX" && \ echo "$RESTORE_GENERAL_LOG" && echo "$RESTORE_SLOW_QUERY_LOG" && \ echo "$SET_START_POSITION" && echo "$SET_WSREP_GTID_DOMAIN_ID" \ - || echo "SST failed to complete;") | $MYSQL + || echo "SST failed to complete;") | $MYSQL || exit $? else wsrep_log_info "Bypassing state dump." - echo "$SET_START_POSITION" | $MYSQL + echo "$SET_START_POSITION" | $MYSQL || exit $? fi -# +wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE completed on $WSREP_SST_OPT_ROLE" +exit 0 diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index adc78f1c70d..acae6fd754c 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -34,6 +34,12 @@ wsrep_check_programs rsync cleanup_joiner() { + # Since this is invoked just after exit NNN + local estatus=$? + if [ $estatus -ne 0 ]; then + wsrep_log_error "Cleanup after exit with status: $estatus" + fi + local failure=0 [ "$(pwd)" != "$OLD_PWD" ] && cd "$OLD_PWD" @@ -72,7 +78,9 @@ cleanup_joiner() wsrep_cleanup_progress_file fi - [ -f "$SST_PID" ] && rm -f "$SST_PID" + [ -f "$SST_PID" ] && rm -f "$SST_PID" || : + + exit $estatus } check_pid_and_port() @@ -310,6 +318,7 @@ if [ -n "$SSLMODE" -a "$SSLMODE" != 'DISABLED' ]; then fi readonly SECRET_TAG='secret' +readonly BYPASS_TAG='secret /bypass' SST_PID="$WSREP_SST_OPT_DATA/wsrep_sst.pid" @@ -325,6 +334,7 @@ while check_pid "$SST_PID" 0; do sleep 1 done +trap simple_cleanup EXIT echo $$ > "$SST_PID" # give some time for stunnel from the previous SST to complete: @@ -358,7 +368,7 @@ while check_pid "$RSYNC_PID" 1 "$RSYNC_CONF"; do sleep 1 done -[ -f "$MAGIC_FILE" ] && rm -f "$MAGIC_FILE" +[ -f "$MAGIC_FILE" ] && rm -f "$MAGIC_FILE" [ -f "$BINLOG_TAR_FILE" ] && rm -f "$BINLOG_TAR_FILE" if [ "$WSREP_SST_OPT_ROLE" = 'donor' ]; then @@ -390,7 +400,7 @@ EOF ERROR="$WSREP_SST_OPT_DATA/sst_error" [ -f "$FLUSHED" ] && rm -f "$FLUSHED" - [ -f "$ERROR" ] && rm -f "$ERROR" + [ -f "$ERROR" ] && rm -f "$ERROR" echo 'flush tables' @@ -400,7 +410,7 @@ EOF # (c) ERROR file, in case flush tables operation failed. while [ ! -r "$FLUSHED" ] && \ - ! grep -q -F ':' '--' "$FLUSHED" >/dev/null 2>&1 + ! grep -q -F ':' -- "$FLUSHED" 2>/dev/null do # Check whether ERROR file exists. if [ -f "$ERROR" ]; then @@ -440,10 +450,10 @@ EOF tar_type=0 if tar --help | grep -qw -F -- '--transform'; then tar_type=1 - elif tar --version | grep -q -E '^bsdtar\>'; then + elif tar --version | grep -qw -E '^bsdtar'; then tar_type=2 fi - if [ $tar_type -ne 2 ]; then + if [ $tar_type -eq 2 ]; then if [ -n "$BASH_VERSION" ]; then printf '%s' "$binlog_files" >&2 else @@ -508,9 +518,8 @@ EOF fi # Use deltaxfer only for WAN: - inv=$(basename "$0") WHOLE_FILE_OPT="" - if [ "${inv%wsrep_sst_rsync_wan*}" = "$inv" ]; then + if [ "${WSREP_METHOD%_wan}" = "$WSREP_METHOD" ]; then WHOLE_FILE_OPT='--whole-file' fi @@ -620,7 +629,6 @@ FILTER="-f '- /lost+found' wsrep_log_info "Transfer of data done" - else # BYPASS wsrep_log_info "Bypassing state dump." @@ -641,6 +649,10 @@ FILTER="-f '- /lost+found' echo "$SECRET_TAG $WSREP_SST_OPT_REMOTE_PSWD" >> "$MAGIC_FILE" fi + if [ $WSREP_SST_OPT_BYPASS -ne 0 ]; then + echo "$BYPASS_TAG" >> "$MAGIC_FILE" + fi + rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --archive --quiet --checksum "$MAGIC_FILE" \ "rsync://$WSREP_SST_OPT_ADDR" >&2 || RC=$? @@ -654,15 +666,11 @@ FILTER="-f '- /lost+found' if [ -n "$STUNNEL" ]; then [ -f "$STUNNEL_CONF" ] && rm -f "$STUNNEL_CONF" - [ -f "$STUNNEL_PID" ] && rm -f "$STUNNEL_PID" + [ -f "$STUNNEL_PID" ] && rm -f "$STUNNEL_PID" fi - [ -f "$SST_PID" ] && rm -f "$SST_PID" +else # joiner - wsrep_log_info "rsync SST/IST completed on donor" - -elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ] -then check_sockets_utils ADDR="$WSREP_SST_OPT_HOST" @@ -670,8 +678,6 @@ then RSYNC_ADDR="$WSREP_SST_OPT_HOST" RSYNC_ADDR_UNESCAPED="$WSREP_SST_OPT_HOST_UNESCAPED" - trap 'exit 32' HUP PIPE - trap 'exit 3' INT TERM ABRT trap cleanup_joiner EXIT touch "$SST_PROGRESS_FILE" @@ -804,8 +810,7 @@ EOF sleep 1 done - if ! ps -p $MYSQLD_PID >/dev/null 2>&1 - then + if ! ps -p $MYSQLD_PID >/dev/null 2>&1; then wsrep_log_error \ "Parent mysqld process (PID: $MYSQLD_PID) terminated unexpectedly." kill -- -$MYSQLD_PID @@ -813,52 +818,68 @@ EOF exit 32 fi - if [ -r "$MAGIC_FILE" ]; then - if [ -n "$MY_SECRET" ]; then - # Check donor supplied secret: - SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | \ - cut -d ' ' -f2) - if [ "$SECRET" != "$MY_SECRET" ]; then - wsrep_log_error "Donor does not know my secret!" - wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'" - exit 32 - fi - fi - else + if [ ! -r "$MAGIC_FILE" ]; then # This message should cause joiner to abort: - wsrep_log_info "rsync process ended without creating magic file" - echo "rsync process ended without creating '$MAGIC_FILE'" + wsrep_log_info "rsync process ended without creating" \ + "magic file ($MAGIC_FILE)" exit 32 fi - if [ -n "$WSREP_SST_OPT_BINLOG" ]; then - binlog_tar_present=0 - [ -f "$BINLOG_TAR_FILE" ] && binlog_tar_present=1 + if [ -n "$MY_SECRET" ]; then + # Select the "secret" tag whose value does not start + # with a slash symbol. All new tags must to start with + # the space and the slash symbol after the word "secret" - + # to be removed by older versions of the SST scripts: + SECRET=$(grep -m1 -E "^$SECRET_TAG[[:space:]]+[^/]" \ + -- "$MAGIC_FILE" || :) + # Check donor supplied secret: + SECRET=$(trim_string "${SECRET#$SECRET_TAG}") + if [ "$SECRET" != "$MY_SECRET" ]; then + wsrep_log_error "Donor does not know my secret!" + wsrep_log_info "Donor: '$SECRET', my: '$MY_SECRET'" + exit 32 + fi + fi + + if [ $WSREP_SST_OPT_BYPASS -eq 0 ]; then + if grep -m1 -qE "^$BYPASS_TAG([[space]]+.*)?\$" -- "$MAGIC_FILE"; then + readonly WSREP_SST_OPT_BYPASS=1 + readonly WSREP_TRANSFER_TYPE='IST' + fi + fi + + binlog_tar_present=0 + if [ -f "$BINLOG_TAR_FILE" ]; then + if [ $WSREP_SST_OPT_BYPASS -ne 0 ]; then + wsrep_log_warning "tar with binlogs transferred in the IST mode" + fi + binlog_tar_present=1 + fi + + if [ $WSREP_SST_OPT_BYPASS -eq 0 -a -n "$WSREP_SST_OPT_BINLOG" ]; then # If it is SST (not an IST) or tar with binlogs is present # among the transferred files, then we need to remove the # old binlogs: - if [ $WSREP_SST_OPT_BYPASS -eq 0 -o $binlog_tar_present -ne 0 ]; then - cd "$DATA" - # Clean up the old binlog files and index: - binlog_index="$WSREP_SST_OPT_BINLOG_INDEX" - if [ -f "$binlog_index" ]; then - while read bin_file || [ -n "$bin_file" ]; do - rm -f "$bin_file" || : - done < "$binlog_index" - rm -f "$binlog_index" - fi - binlog_cd=0 - # Change the directory to binlog base (if possible): - if [ -n "$binlog_dir" -a "$binlog_dir" != '.' -a \ - -d "$binlog_dir" ] - then - binlog_cd=1 - cd "$binlog_dir" - fi - # Clean up unindexed binlog files: - rm -f "$binlog_base".[0-9]* || : - [ $binlog_cd -ne 0 ] && cd "$DATA_DIR" + cd "$DATA" + # Clean up the old binlog files and index: + binlog_index="$WSREP_SST_OPT_BINLOG_INDEX" + if [ -f "$binlog_index" ]; then + while read bin_file || [ -n "$bin_file" ]; do + rm -f "$bin_file" || : + done < "$binlog_index" + rm -f "$binlog_index" + fi + binlog_cd=0 + # Change the directory to binlog base (if possible): + if [ -n "$binlog_dir" -a "$binlog_dir" != '.' -a \ + -d "$binlog_dir" ] + then + binlog_cd=1 + cd "$binlog_dir" fi + # Clean up unindexed binlog files: + rm -f "$binlog_base".[0-9]* || : + [ $binlog_cd -ne 0 ] && cd "$DATA_DIR" if [ $binlog_tar_present -ne 0 ]; then # Create a temporary file: tmpdir=$(parse_cnf '--mysqld|sst' 'tmpdir') @@ -882,7 +903,7 @@ EOF # Extracting binlog files: wsrep_log_info "Extracting binlog files:" RC=0 - if tar --version | grep -q -E '^bsdtar\>'; then + if tar --version | grep -qw -E '^bsdtar'; then tar -tf "$BINLOG_TAR_FILE" > "$tmpfile" && \ tar -xvf "$BINLOG_TAR_FILE" > /dev/null || RC=$? else @@ -890,8 +911,8 @@ EOF cat "$tmpfile" >&2 || RC=$? fi if [ $RC -ne 0 ]; then - rm -f "$tmpfile" wsrep_log_error "Error unpacking tar file with binlog files" + rm -f "$tmpfile" exit 32 fi # Rebuild binlog index: @@ -904,24 +925,13 @@ EOF fi fi - if [ -n "$MY_SECRET" ]; then - # remove secret from the magic file, and output - # the UUID:seqno & wsrep_gtid_domain_id: - grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" - else - # Output the UUID:seqno and wsrep_gtid_domain_id: - cat "$MAGIC_FILE" - fi - - wsrep_log_info "rsync SST/IST completed on joiner" - -# wsrep_cleanup_progress_file -# cleanup_joiner -else - wsrep_log_error "Unrecognized role: '$WSREP_SST_OPT_ROLE'" - exit 22 # EINVAL + # Remove special tags from the magic file, and from the output: + coords=$(grep -v -E "^$SECRET_TAG[[:space:]]" -- "$MAGIC_FILE") + wsrep_log_info "Galera co-ords from recovery: $coords" + echo "$coords" # Output : UUID:seqno wsrep_gtid_domain_id fi [ -f "$BINLOG_TAR_FILE" ] && rm -f "$BINLOG_TAR_FILE" +wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE completed on $WSREP_SST_OPT_ROLE" exit 0 diff --git a/sql-common/client.c b/sql-common/client.c index 3bb000db937..d2c6778e167 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2497,6 +2497,8 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, mpvio.db= db; mpvio.plugin= auth_plugin; + DBUG_EXECUTE_IF("client_delay_run_plugin_auth", my_sleep(400000);); + res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql); DBUG_PRINT ("info", ("authenticate_user returned %s", res == CR_OK ? "CR_OK" : diff --git a/sql/field.cc b/sql/field.cc index 2fe66a96b15..4435e8c7f38 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3345,11 +3345,12 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg, decimal_digits_t dec_arg,bool zero_arg, bool unsigned_arg) :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, dec_arg, zero_arg, unsigned_arg) + unireg_check_arg, field_name_arg, + MY_MIN(dec_arg, DECIMAL_MAX_SCALE), zero_arg, unsigned_arg) { precision= get_decimal_precision(len_arg, dec_arg, unsigned_arg); - DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION) && - (dec <= DECIMAL_MAX_SCALE)); + DBUG_ASSERT(precision <= DECIMAL_MAX_PRECISION); + DBUG_ASSERT(dec <= DECIMAL_MAX_SCALE); bin_size= my_decimal_get_binary_size(precision, dec); } diff --git a/sql/field.h b/sql/field.h index 7b279ffb41e..cb78bdccd4b 100644 --- a/sql/field.h +++ b/sql/field.h @@ -5501,22 +5501,22 @@ public: bool check_vcol_for_key(THD *thd) const; - void set_lex_charset_collation(const Lex_charset_collation_st &lc) + void set_charset_collation_attrs(const + Lex_column_charset_collation_attrs_st &lc) { - charset= lc.charset_collation(); + charset= lc.charset_info(); if (lc.is_contextually_typed_collation()) flags|= CONTEXT_COLLATION_FLAG; else flags&= ~CONTEXT_COLLATION_FLAG; } - Lex_charset_collation lex_charset_collation() const + Lex_column_charset_collation_attrs charset_collation_attrs() const { - return Lex_charset_collation( - charset, - !charset ? Lex_charset_collation_st::TYPE_EMPTY : - flags & CONTEXT_COLLATION_FLAG ? - Lex_charset_collation_st::TYPE_COLLATE_CONTEXTUALLY_TYPED : - Lex_charset_collation_st::TYPE_CHARACTER_SET); + if (!charset) + return Lex_column_charset_collation_attrs(); + if (flags & CONTEXT_COLLATION_FLAG) + return Lex_column_charset_collation_attrs(Lex_context_collation(charset)); + return Lex_column_charset_collation_attrs(Lex_exact_collation(charset)); } }; diff --git a/sql/gcalc_tools.cc b/sql/gcalc_tools.cc index 307f063fb43..25c80a7a796 100644 --- a/sql/gcalc_tools.cc +++ b/sql/gcalc_tools.cc @@ -132,7 +132,7 @@ int Gcalc_function::count_internal(const char *cur_func, uint set_type, int mask= (c_op & op_not) ? 1:0; uint n_ops= c_op & ~(op_any | op_not | v_mask); uint n_shape= c_op & ~(op_any | op_not | v_mask); /* same as n_ops */ - value v_state= (value) (c_op & v_mask); + op_type v_state= (op_type) (c_op & v_mask); int result= 0; const char *sav_cur_func= cur_func; diff --git a/sql/gcalc_tools.h b/sql/gcalc_tools.h index e625b355d95..bb1f473e180 100644 --- a/sql/gcalc_tools.h +++ b/sql/gcalc_tools.h @@ -52,17 +52,15 @@ private: int count_internal(const char *cur_func, uint set_type, const char **end); public: - enum value - { - v_empty= 0x0000000, - v_find_t= 0x1000000, - v_find_f= 0x2000000, - v_t_found= 0x3000000, - v_f_found= 0x4000000, - v_mask= 0x7000000 - }; enum op_type { + v_empty= 0x00000000, + v_find_t= 0x01000000, + v_find_f= 0x02000000, + v_t_found= 0x03000000, + v_f_found= 0x04000000, + v_mask= 0x07000000, + op_not= 0x80000000, op_shape= 0x00000000, op_union= 0x10000000, diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 34c65f2e45d..e85ce02b7e6 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2021, MariaDB + Copyright (c) 2009, 2022, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4177,6 +4177,8 @@ int ha_partition::external_lock(THD *thd, int lock_type) if (lock_type == F_UNLCK) { bitmap_clear_all(used_partitions); + if (m_lock_type == F_WRLCK && m_part_info->vers_require_hist_part(thd)) + m_part_info->vers_check_limit(thd); } else { @@ -10576,7 +10578,16 @@ bool ha_partition::commit_inplace_alter_table(TABLE *altered_table, Loop over all other partitions as to follow the protocol! */ uint i; - DBUG_ASSERT(0); + /* + InnoDB does not set ha_alter_info->group_commit_ctx to NULL in the + case if autoincrement attribute is necessary to reset for all + partitions for INNOBASE_INPLACE_IGNORE handler flags. It does not + affect durability, because it is solely about updating the InnoDB data + dictionary caches (one InnoDB dict_table_t per partition or + sub-partition). + */ + DBUG_ASSERT(table->found_next_number_field + && !altered_table->found_next_number_field); for (i= 1; i < m_tot_parts; i++) { ha_alter_info->handler_ctx= part_inplace_ctx->handler_ctx_array[i]; diff --git a/sql/ha_partition.h b/sql/ha_partition.h index fbf34efe39f..9cbb6c928ee 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1608,9 +1608,6 @@ public: /** Get the number of records in part_elem and its subpartitions, if any. - Also sets read_partitions bit for each partition id it uses (that is needed - for vers_set_hist_part() because it is called before read_partitions bitmap - is initialized). */ ha_rows part_records(partition_element *part_elem) { @@ -1623,7 +1620,6 @@ public: for (; part_id < part_id_end; ++part_id) { handler *file= m_file[part_id]; - bitmap_set_bit(&(m_part_info->read_partitions), part_id); file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_OPEN); part_recs+= file->stats.records; } diff --git a/sql/handler.cc b/sql/handler.cc index fb1f9ba8a76..2f2c7064e6a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4365,6 +4365,7 @@ void handler::print_error(int error, myf errflag) if ((int) key_nr >= 0 && key_nr < table->s->keys) { print_keydup_error(table, &table->key_info[key_nr], errflag); + table->file->lookup_errkey= -1; DBUG_VOID_RETURN; } } @@ -5810,6 +5811,9 @@ int handler::calculate_checksum() for (uint i= 0; i < table->s->fields; i++ ) { Field *f= table->field[i]; + if (!f->stored_in_db()) + continue; + if (! (thd->variables.old_behavior & OLD_MODE_COMPAT_5_1_CHECKSUM) && f->is_real_null(0)) @@ -7917,24 +7921,6 @@ int ha_abort_transaction(THD *bf_thd, THD *victim_thd, my_bool signal) #endif /* WITH_WSREP */ -bool HA_CREATE_INFO::check_conflicting_charset_declarations(CHARSET_INFO *cs) -{ - if ((used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && - /* DEFAULT vs explicit, or explicit vs DEFAULT */ - (((default_table_charset == NULL) != (cs == NULL)) || - /* Two different explicit character sets */ - (default_table_charset && cs && - !my_charset_same(default_table_charset, cs)))) - { - my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), - "CHARACTER SET ", default_table_charset ? - default_table_charset->cs_name.str : "DEFAULT", - "CHARACTER SET ", cs ? cs->cs_name.str : "DEFAULT"); - return true; - } - return false; -} - /* Remove all indexes for a given table from global index statistics */ static diff --git a/sql/handler.h b/sql/handler.h index cdab18cecbc..60c6195e68e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -967,6 +967,7 @@ typedef struct xid_t XID; */ typedef uint Binlog_file_id; const Binlog_file_id MAX_binlog_id= UINT_MAX; +const my_off_t MAX_off_t = (~(my_off_t) 0); /* Compound binlog-id and byte offset of transaction's first event in a sequence (e.g the recovery sequence) of binlog files. @@ -981,14 +982,22 @@ struct xid_recovery_member my_xid xid; uint in_engine_prepare; // number of engines that have xid prepared bool decided_to_commit; - Binlog_offset binlog_coord; // semisync recovery binlog offset + /* + Semisync recovery binlog offset. It's initialized with the maximum + unreachable offset. The max value will remain for any transaction + not found in binlog to yield its rollback decision as it's guaranteed + to be within a truncated tail part of the binlog. + */ + Binlog_offset binlog_coord; XID *full_xid; // needed by wsrep or past it recovery decltype(::server_id) server_id; // server id of orginal server xid_recovery_member(my_xid xid_arg, uint prepare_arg, bool decided_arg, XID *full_xid_arg, decltype(::server_id) server_id_arg) : xid(xid_arg), in_engine_prepare(prepare_arg), - decided_to_commit(decided_arg), full_xid(full_xid_arg) , server_id(server_id_arg) {}; + decided_to_commit(decided_arg), + binlog_coord(Binlog_offset(MAX_binlog_id, MAX_off_t)), + full_xid(full_xid_arg), server_id(server_id_arg) {}; }; /* for recover() handlerton call */ @@ -2280,33 +2289,6 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, Schema_specification_st::init(); alter_info= NULL; } - bool check_conflicting_charset_declarations(CHARSET_INFO *cs); - bool add_table_option_default_charset(CHARSET_INFO *cs) - { - // cs can be NULL, e.g.: CREATE TABLE t1 (..) CHARACTER SET DEFAULT; - if (check_conflicting_charset_declarations(cs)) - return true; - default_table_charset= cs; - used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; - return false; - } - bool add_alter_list_item_convert_to_charset(CHARSET_INFO *cs) - { - /* - cs cannot be NULL, as sql_yacc.yy translates - CONVERT TO CHARACTER SET DEFAULT - to - CONVERT TO CHARACTER SET <character-set-of-the-current-database> - TODO: Shouldn't we postpone resolution of DEFAULT until the - character set of the table owner database is loaded from its db.opt? - */ - DBUG_ASSERT(cs); - if (check_conflicting_charset_declarations(cs)) - return true; - alter_table_convert_to_charset= default_table_charset= cs; - used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); - return false; - } ulong table_options_with_row_type() { if (row_type == ROW_TYPE_DYNAMIC || row_type == ROW_TYPE_PAGE) @@ -2314,6 +2296,10 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, else return table_options; } + bool resolve_to_charset_collation_context(THD *thd, + const Lex_table_charset_collation_attrs_st &default_cscl, + const Lex_table_charset_collation_attrs_st &convert_cscl, + const Charset_collation_context &ctx); }; @@ -2324,16 +2310,23 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, struct Table_specification_st: public HA_CREATE_INFO, public DDL_options_st { + Lex_table_charset_collation_attrs_st default_charset_collation; + Lex_table_charset_collation_attrs_st convert_charset_collation; + // Deep initialization void init() { HA_CREATE_INFO::init(); DDL_options_st::init(); + default_charset_collation.init(); + convert_charset_collation.init(); } void init(DDL_options_st::Options options_arg) { HA_CREATE_INFO::init(); DDL_options_st::init(options_arg); + default_charset_collation.init(); + convert_charset_collation.init(); } /* Quick initialization, for parser. @@ -2345,6 +2338,46 @@ struct Table_specification_st: public HA_CREATE_INFO, { HA_CREATE_INFO::options= 0; DDL_options_st::init(); + default_charset_collation.init(); + convert_charset_collation.init(); + } + + bool add_table_option_convert_charset(CHARSET_INFO *cs) + { + // cs can be NULL, e.g.: ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT; + used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); + return cs ? + convert_charset_collation.merge_exact_charset(Lex_exact_charset(cs)) : + convert_charset_collation.merge_charset_default(); + } + bool add_table_option_convert_collation(const Lex_extended_collation_st &cl) + { + used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); + return convert_charset_collation.merge_collation(cl); + } + + bool add_table_option_default_charset(CHARSET_INFO *cs) + { + // cs can be NULL, e.g.: CREATE TABLE t1 (..) CHARACTER SET DEFAULT; + used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + return cs ? + default_charset_collation.merge_exact_charset(Lex_exact_charset(cs)) : + default_charset_collation.merge_charset_default(); + } + bool add_table_option_default_collation(const Lex_extended_collation_st &cl) + { + used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + return default_charset_collation.merge_collation(cl); + } + + bool resolve_to_charset_collation_context(THD *thd, + const Charset_collation_context &ctx) + { + return HA_CREATE_INFO:: + resolve_to_charset_collation_context(thd, + default_charset_collation, + convert_charset_collation, + ctx); } }; diff --git a/sql/item.cc b/sql/item.cc index 3b8345f4416..6c5a892fc96 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -959,8 +959,7 @@ bool Item_field::check_field_expression_processor(void *arg) (!field->vcol_info && !org_field->vcol_info)) && field->field_index >= org_field->field_index)) { - my_error(ER_EXPRESSION_REFERS_TO_UNINIT_FIELD, - MYF(0), + my_error(ER_EXPRESSION_REFERS_TO_UNINIT_FIELD, MYF(0), org_field->field_name.str, field->field_name.str); return 1; } @@ -7998,8 +7997,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) else if (!ref || ref == not_found_item) { DBUG_ASSERT(reference_trough_name != 0); - if (!(ref= resolve_ref_in_select_and_group(thd, this, - context->select_lex))) + if (!(ref= resolve_ref_in_select_and_group(thd, this, context->select_lex))) goto error; /* Some error occurred (e.g. ambiguous names). */ if (ref == not_found_item) /* This reference was not resolved. */ @@ -8012,8 +8010,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) if (unlikely(!outer_context)) { /* The current reference cannot be resolved in this query. */ - my_error(ER_BAD_FIELD_ERROR,MYF(0), - this->full_name(), thd->where); + my_error(ER_BAD_FIELD_ERROR,MYF(0), full_name(), thd->where); goto error; } @@ -9505,6 +9502,12 @@ bool Item_default_value::eq(const Item *item, bool binary_cmp) const } +bool Item_default_value::check_field_expression_processor(void *) +{ + field->default_value= ((Item_field *)(arg->real_item()))->field->default_value; + return 0; +} + bool Item_default_value::fix_fields(THD *thd, Item **items) { Item *real_arg; @@ -9546,7 +9549,6 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) } if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of()))) goto error; - cached_field= def_field; memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of()); def_field->reset_fields(); @@ -9575,8 +9577,7 @@ error: void Item_default_value::cleanup() { - delete cached_field; // Free cached blob data - cached_field= 0; + delete field; // Free cached blob data Item_field::cleanup(); } @@ -9651,6 +9652,12 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) return Item_field::save_in_field(field_arg, no_conversions); } +void Item_default_value::save_in_result_field(bool no_conversions) +{ + calculate(); + Item_field::save_in_result_field(no_conversions); +} + double Item_default_value::val_result() { calculate(); @@ -9710,6 +9717,23 @@ table_map Item_default_value::used_tables() const return field->default_value->expr->used_tables(); } +bool Item_default_value::register_field_in_read_map(void *arg) +{ + TABLE *table= (TABLE *) arg; + int res= 0; + if (!table || (table && table == field->table)) + { + if (field->default_value && field->default_value->expr) + res= field->default_value->expr->walk(&Item::register_field_in_read_map,1,arg); + } + else if (result_field && table == result_field->table) + { + bitmap_set_bit(table->read_set, result_field->field_index); + } + + return res; +} + /** This method like the walk method traverses the item tree, but at the same time it can replace some nodes in the tree. diff --git a/sql/item.h b/sql/item.h index 4ef0e1b93b2..d1d19157b83 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2177,6 +2177,12 @@ public: return 0; } + virtual bool set_extraction_flag_processor(void *arg) + { + set_extraction_flag(*(int16*)arg); + return 0; + } + /** Check db/table_name if they defined in item and match arg values @@ -6613,7 +6619,6 @@ class Item_default_value : public Item_field void calculate(); public: Item *arg= nullptr; - Field *cached_field= nullptr; Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a, bool vcol_assignment_arg) : Item_field(thd, context_arg), @@ -6630,6 +6635,10 @@ public: bool get_date(THD *thd, MYSQL_TIME *ltime,date_mode_t fuzzydate) override; bool val_native(THD *thd, Native *to) override; bool val_native_result(THD *thd, Native *to) override; + longlong val_datetime_packed(THD *thd) override + { return Item::val_datetime_packed(thd); } + longlong val_time_packed(THD *thd) override + { return Item::val_time_packed(thd); } /* Result variants */ double val_result() override; @@ -6643,6 +6652,7 @@ public: bool send(Protocol *protocol, st_value *buffer) override; int save_in_field(Field *field_arg, bool no_conversions) override; + void save_in_result_field(bool no_conversions) override; bool save_in_param(THD *, Item_param *param) override { // It should not be possible to have "EXECUTE .. USING DEFAULT(a)" @@ -6658,11 +6668,12 @@ public: } bool vcol_assignment_allowed_value() const override { return vcol_assignment_ok; } - Field *get_tmp_table_field() override { return nullptr; } Item *get_tmp_table_item(THD *) override { return this; } Item_field *field_for_view_update() override { return nullptr; } bool update_vcol_processor(void *) override { return false; } + bool check_field_expression_processor(void *arg) override; bool check_func_default_processor(void *) override { return true; } + bool register_field_in_read_map(void *arg) override; bool walk(Item_processor processor, bool walk_subquery, void *args) override { return (arg && arg->walk(processor, walk_subquery, args)) || @@ -6941,7 +6952,7 @@ public: for any value. */ -class Item_cache: public Item, +class Item_cache: public Item_fixed_hybrid, public Type_handler_hybrid_field_type { protected: @@ -6972,7 +6983,7 @@ public: bool null_value_inside; Item_cache(THD *thd): - Item(thd), + Item_fixed_hybrid(thd), Type_handler_hybrid_field_type(&type_handler_string), example(0), cached_field(0), value_cached(0), @@ -6981,10 +6992,11 @@ public: set_maybe_null(); null_value= 1; null_value_inside= true; + quick_fix_field(); } protected: Item_cache(THD *thd, const Type_handler *handler): - Item(thd), + Item_fixed_hybrid(thd), Type_handler_hybrid_field_type(handler), example(0), cached_field(0), value_cached(0), @@ -6993,6 +7005,7 @@ protected: set_maybe_null(); null_value= 1; null_value_inside= true; + quick_fix_field(); } public: @@ -7045,10 +7058,17 @@ public: } return mark_unsupported_function("cache", arg, VCOL_IMPOSSIBLE); } + bool fix_fields(THD *thd, Item **ref) override + { + quick_fix_field(); + if (example && !example->fixed()) + return example->fix_fields(thd, ref); + return 0; + } void cleanup() override { clear(); - Item::cleanup(); + Item_fixed_hybrid::cleanup(); } /** Check if saved item has a non-NULL value. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index dbfbc07a600..a53bb2e53b6 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -7663,7 +7663,17 @@ bool Item_equal::create_pushable_equalities(THD *thd, if (!eq || equalities->push_back(eq, thd->mem_root)) return true; if (!clone_const) - right_item->set_extraction_flag(MARKER_IMMUTABLE); + { + /* + Also set IMMUTABLE_FL for any sub-items of the right_item. + This is needed to prevent Item::cleanup_excluding_immutables_processor + from peforming cleanup of the sub-items and so creating an item tree + where a fixed item has non-fixed items inside it. + */ + int16 new_flag= MARKER_IMMUTABLE; + right_item->walk(&Item::set_extraction_flag_processor, false, + (void*)&new_flag); + } } while ((item=it++)) diff --git a/sql/item_func.cc b/sql/item_func.cc index f25dffdfd02..e53b89a9291 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2501,7 +2501,7 @@ void Item_func_round::fix_arg_decimal() set_handler(&type_handler_newdecimal); unsigned_flag= args[0]->unsigned_flag; decimals= args[0]->decimals; - max_length= float_length(args[0]->decimals) + 1; + max_length= args[0]->max_length; } } diff --git a/sql/item_func.h b/sql/item_func.h index 185242b7901..a4122f78e87 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -3773,7 +3773,7 @@ public: } bool set(const Type_handler *handler, const Lex_length_and_dec_st & length_and_dec, - const Lex_charset_collation_st &cscl, + const Lex_column_charset_collation_attrs_st &cscl, CHARSET_INFO *defcs) { CHARSET_INFO *tmp= cscl.resolved_to_character_set(defcs); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index de31c82abf4..2169ac874e5 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -826,6 +826,7 @@ bool Item_subselect::exec() DBUG_ENTER("Item_subselect::exec"); DBUG_ASSERT(fixed()); DBUG_ASSERT(thd); + DBUG_ASSERT(!eliminated); DBUG_EXECUTE_IF("Item_subselect", Item::Print print(this, @@ -1361,11 +1362,18 @@ bool Item_singlerow_subselect::fix_length_and_dec() } unsigned_flag= value->unsigned_flag; /* - If there are not tables in subquery then ability to have NULL value - depends on SELECT list (if single row subquery have tables then it - always can be NULL if there are not records fetched). + If the subquery has no tables (1) and is not a UNION (2), like: + + (SELECT subq_value) + + then its NULLability is the same as subq_value's NULLability. + + (1): A subquery that uses a table will return NULL when the table is empty. + (2): A UNION subquery will return NULL if it produces a "Subquery returns + more than one row" error. */ - if (engine->no_tables()) + if (engine->no_tables() && + engine->engine_type() != subselect_engine::UNION_ENGINE) set_maybe_null(engine->may_be_null()); else { @@ -1401,6 +1409,16 @@ Item* Item_singlerow_subselect::expr_cache_insert_transformer(THD *tmp_thd, DBUG_ASSERT(thd == tmp_thd); + /* + Do not create subquery cache if the subquery was eliminated. + The optimizer may eliminate subquery items (see + eliminate_subselect_processor). However it does not update + all query's data structures, so the eliminated item may be + still reachable. + */ + if (eliminated) + DBUG_RETURN(this); + if (expr_cache) DBUG_RETURN(expr_cache); diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 109a0f883e8..4f79c8f647d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1559,6 +1559,8 @@ void Item_sum_sum::fix_length_and_dec_decimal() decimals= args[0]->decimals; /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */ int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS; + decimals= MY_MIN(decimals, DECIMAL_MAX_SCALE); + precision= MY_MIN(precision, DECIMAL_MAX_PRECISION); max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, unsigned_flag); @@ -1970,12 +1972,12 @@ void Item_sum_avg::fix_length_and_dec_decimal() { Item_sum_sum::fix_length_and_dec_decimal(); int precision= args[0]->decimal_precision() + prec_increment; - decimals= MY_MIN(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); + decimals= MY_MIN(args[0]->decimal_scale() + prec_increment, DECIMAL_MAX_SCALE); max_length= my_decimal_precision_to_length_no_truncation(precision, decimals, unsigned_flag); f_precision= MY_MIN(precision+DECIMAL_LONGLONG_DIGITS, DECIMAL_MAX_PRECISION); - f_scale= args[0]->decimals; + f_scale= args[0]->decimal_scale(); dec_bin_size= my_decimal_get_binary_size(f_precision, f_scale); } @@ -4261,9 +4263,9 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref) result.set_charset(collation.collation); result_field= 0; null_value= 1; - max_length= (uint32)MY_MIN(thd->variables.group_concat_max_len - / collation.collation->mbminlen - * collation.collation->mbmaxlen, UINT_MAX32); + max_length= (uint32) MY_MIN((ulonglong) thd->variables.group_concat_max_len + / collation.collation->mbminlen + * collation.collation->mbmaxlen, UINT_MAX32); uint32 offset; if (separator->needs_conversion(separator->length(), separator->charset(), diff --git a/sql/json_table.cc b/sql/json_table.cc index e2f90aa2a9a..a9e882291b6 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -874,7 +874,7 @@ int Json_table_column::set(THD *thd, enum_type ctype, const LEX_CSTRING &path, int Json_table_column::set(THD *thd, enum_type ctype, const LEX_CSTRING &path, - const Lex_charset_collation_st &cl) + const Lex_column_charset_collation_attrs_st &cl) { if (cl.is_empty() || cl.is_contextually_typed_collate_default()) return set(thd, ctype, path, nullptr); diff --git a/sql/json_table.h b/sql/json_table.h index 2cadb07961e..6398b061889 100644 --- a/sql/json_table.h +++ b/sql/json_table.h @@ -161,7 +161,7 @@ public: } int set(THD *thd, enum_type ctype, const LEX_CSTRING &path, CHARSET_INFO *cs); int set(THD *thd, enum_type ctype, const LEX_CSTRING &path, - const Lex_charset_collation_st &cl); + const Lex_column_charset_collation_attrs_st &cl); Json_table_column(Create_field *f, Json_table_nested_path *nest) : m_field(f), m_nest(nest), m_explicit_cs(NULL) { diff --git a/sql/lex_charset.cc b/sql/lex_charset.cc index 7570abbdfb9..c36e01498c5 100644 --- a/sql/lex_charset.cc +++ b/sql/lex_charset.cc @@ -21,47 +21,333 @@ #include "mysqld_error.h" +static void +raise_ER_CONFLICTING_DECLARATIONS(const char *clause1, + const char *name1, + const char *clause2, + const char *name2, + bool reverse_order) +{ + if (!reverse_order) + my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), + clause1, name1, clause2, name2); + else + my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), + clause2, name2, clause1, name1); +} + + +static void +raise_ER_CONFLICTING_DECLARATIONS(const char *clause1, + const char *name1, + const char *name1_part2, + const char *clause2, + const char *name2, + bool reverse_order) +{ + char def[MY_CS_NAME_SIZE * 2]; + my_snprintf(def, sizeof(def), "%s (%s)", name1, name1_part2); + raise_ER_CONFLICTING_DECLARATIONS(clause1, def, + clause2, name2, + reverse_order); +} + + +bool Lex_exact_charset::raise_if_not_equal(const Lex_exact_charset &rhs) const +{ + if (m_ci == rhs.m_ci) + return false; + my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), + "CHARACTER SET ", m_ci->cs_name.str, + "CHARACTER SET ", rhs.m_ci->cs_name.str); + return true; +} + + +bool Lex_exact_charset:: + raise_if_not_applicable(const Lex_exact_collation &cl) const +{ + return Lex_exact_charset_opt_extended_collate(m_ci, false). + raise_if_not_applicable(cl); +} + + +bool Lex_exact_charset_opt_extended_collate:: + raise_if_not_applicable(const Lex_exact_collation &cl) const +{ + if (!my_charset_same(m_ci, cl.charset_info())) + { + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + cl.charset_info()->coll_name.str, m_ci->cs_name.str); + return true; + } + return false; +} + + +bool +Lex_exact_collation::raise_if_not_equal(const Lex_exact_collation &cl) const +{ + if (m_ci != cl.m_ci) + { + my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), + "COLLATE ", m_ci->coll_name.str, + "COLLATE ", cl.m_ci->coll_name.str); + return true; + } + return false; +} + + +/* + Merge an exact collation and a contexual collation. + @param cl - The contextual collation to merge to "this". + @param reverse_order - If the contextual collation is on the left side + + Use reverse_order as follows: + false: COLLATE latin1_swedish_ci COLLATE DEFAULT + true: COLLATE DEFAULT COLLATE latin1_swedish_ci +*/ +bool +Lex_exact_collation:: + raise_if_conflicts_with_context_collation(const Lex_context_collation &cl, + bool reverse_order) const +{ + if (cl.is_contextually_typed_collate_default() && + !(m_ci->state & MY_CS_PRIMARY)) + { + raise_ER_CONFLICTING_DECLARATIONS("COLLATE ", m_ci->coll_name.str, + "COLLATE ", "DEFAULT", reverse_order); + return true; + } + + if (cl.is_contextually_typed_binary_style() && + !(m_ci->state & MY_CS_BINSORT)) + { + raise_ER_CONFLICTING_DECLARATIONS("COLLATE ", m_ci->coll_name.str, + "", "BINARY", reverse_order); + return true; + } + return false; +} + + +bool +Lex_context_collation::raise_if_not_equal(const Lex_context_collation &cl) const +{ + /* + Only equal context collations are possible here so far: + - Column grammar only supports BINARY, but does not support COLLATE DEFAULT + - DB/Table grammar only support COLLATE DEFAULT + But we'll have different collations here - uca140 is coming soon. + */ + DBUG_ASSERT(m_ci == cl.m_ci); + return false; +} + + +/* + Resolve a context collation to the character set (when the former gets known): + CREATE TABLE t1 (a CHAR(10) BINARY) CHARACTER SET latin1; + CREATE DATABASE db1 COLLATE DEFAULT CHARACTER SET latin1; +*/ +bool Lex_exact_charset_opt_extended_collate:: + merge_context_collation_override(const Lex_context_collation &cl) +{ + DBUG_ASSERT(m_ci); + + // CHAR(10) BINARY + if (cl.is_contextually_typed_binary_style()) + { + CHARSET_INFO *ci= find_bin_collation(); + if (!ci) + return true; + m_ci= ci; + m_with_collate= true; + return false; + } + + // COLLATE DEFAULT + if (cl.is_contextually_typed_collate_default()) + { + CHARSET_INFO *ci= find_default_collation(); + DBUG_ASSERT(ci); + if (!ci) + return true; + m_ci= ci; + m_with_collate= true; + return false; + } + + /* + A non-binary and non-default contextually typed collation. + We don't have such yet - the parser cannot produce this. + But we have "uca1400_as_ci" coming soon. + */ + DBUG_ASSERT(0); + return false; +} + + +bool Lex_extended_collation_st::merge_exact_charset(const Lex_exact_charset &cs) +{ + switch (m_type) { + case TYPE_EXACT: + { + // COLLATE latin1_swedish_ci .. CHARACTER SET latin1 + return cs.raise_if_not_applicable(Lex_exact_collation(m_ci)); + } + case TYPE_CONTEXTUALLY_TYPED: + { + // COLLATE DEFAULT .. CHARACTER SET latin1 + Lex_exact_charset_opt_extended_collate tmp(cs); + if (tmp.merge_context_collation(Lex_context_collation(m_ci))) + return true; + *this= Lex_extended_collation(tmp.collation()); + return false; + } + } + DBUG_ASSERT(0); + return false; +} + + +bool Lex_extended_collation_st:: + merge_exact_collation(const Lex_exact_collation &rhs) +{ + switch (m_type) { + + case TYPE_EXACT: + /* + EXACT + EXACT + COLLATE latin1_bin .. COLLATE latin1_bin + */ + return Lex_exact_collation(m_ci).raise_if_not_equal(rhs); + + case TYPE_CONTEXTUALLY_TYPED: + { + /* + CONTEXT + EXACT + CHAR(10) COLLATE DEFAULT .. COLLATE latin1_swedish_ci + CHAR(10) BINARY .. COLLATE latin1_bin + CHAR(10) COLLATE uca1400_as_ci .. COLLATE latin1_bin - coming soon + */ + if (rhs.raise_if_conflicts_with_context_collation( + Lex_context_collation(m_ci), true)) + return true; + *this= Lex_extended_collation(rhs); + return false; + } + } + DBUG_ASSERT(0); + return false; +} + + +bool Lex_extended_collation_st:: + raise_if_conflicts_with_context_collation(const Lex_context_collation &rhs) + const +{ + switch (m_type) { + + case TYPE_EXACT: + /* + EXACT + CONTEXT + COLLATE latin1_swedish_ci .. COLLATE DEFAULT + */ + return Lex_exact_collation(m_ci). + raise_if_conflicts_with_context_collation(rhs, false); + + case TYPE_CONTEXTUALLY_TYPED: + { + /* + CONTEXT + CONTEXT: + CHAR(10) BINARY .. COLLATE DEFAULT - not supported by the parser + CREATE DATABASE db1 COLLATE DEFAULT COLLATE DEFAULT; + */ + return Lex_context_collation(m_ci).raise_if_not_equal(rhs); + } + } + DBUG_ASSERT(0); + return false; +} + + +/* + Merge two non-empty COLLATE clauses. +*/ +bool Lex_extended_collation_st::merge(const Lex_extended_collation_st &rhs) +{ + switch (rhs.type()) { + case TYPE_EXACT: + /* + EXACT + EXACT + COLLATE latin1_swedish_ci .. COLLATE latin1_swedish_ci + + CONTEXT + EXACT + COLLATE DEFAULT .. COLLATE latin1_swedish_ci + CHAR(10) BINARY .. COLLATE latin1_bin + */ + return merge_exact_collation(Lex_exact_collation(rhs.m_ci)); + case TYPE_CONTEXTUALLY_TYPED: + /* + EXACT + CONTEXT + COLLATE latin1_swedish_ci .. COLLATE DEFAULT + + CONTEXT + CONTEXT + COLLATE DEFAULT .. COLLATE DEFAULT + CHAR(10) BINARY .. COLLATE DEFAULT + */ + return raise_if_conflicts_with_context_collation( + Lex_context_collation(rhs.m_ci)); + } + DBUG_ASSERT(0); + return false; +} + + /** find a collation with binary comparison rules */ -CHARSET_INFO *Lex_charset_collation_st::find_bin_collation(CHARSET_INFO *cs) +CHARSET_INFO *Lex_exact_charset_opt_extended_collate::find_bin_collation() const { /* We don't need to handle old_mode=UTF8_IS_UTF8MB3 here, - because "cs" points to a real character set name. + because "m_ci" points to a real character set name. It can be either "utf8mb3" or "utf8mb4". It cannot be "utf8". No thd->get_utf8_flag() flag passed to get_charset_by_csname(). */ - DBUG_ASSERT(cs->cs_name.length !=4 || memcmp(cs->cs_name.str, "utf8", 4)); + DBUG_ASSERT(m_ci->cs_name.length !=4 || memcmp(m_ci->cs_name.str, "utf8", 4)); /* CREATE TABLE t1 (a CHAR(10) BINARY) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; Nothing to do, we have the binary collation already. */ - if (cs->state & MY_CS_BINSORT) - return cs; + if (m_ci->state & MY_CS_BINSORT) + return m_ci; // CREATE TABLE t1 (a CHAR(10) BINARY) CHARACTER SET utf8mb4; - const LEX_CSTRING &cs_name= cs->cs_name; - if (!(cs= get_charset_by_csname(cs->cs_name.str, MY_CS_BINSORT, MYF(0)))) + CHARSET_INFO *cs; + if (!(cs= get_charset_by_csname(m_ci->cs_name.str, MY_CS_BINSORT, MYF(0)))) { char tmp[65]; - strxnmov(tmp, sizeof(tmp)-1, cs_name.str, "_bin", NULL); + strxnmov(tmp, sizeof(tmp)-1, m_ci->cs_name.str, "_bin", NULL); my_error(ER_UNKNOWN_COLLATION, MYF(0), tmp); } return cs; } -CHARSET_INFO *Lex_charset_collation_st::find_default_collation(CHARSET_INFO *cs) +CHARSET_INFO * +Lex_exact_charset_opt_extended_collate::find_default_collation() const { // See comments in find_bin_collation() - DBUG_ASSERT(cs->cs_name.length !=4 || memcmp(cs->cs_name.str, "utf8", 4)); + DBUG_ASSERT(m_ci->cs_name.length !=4 || memcmp(m_ci->cs_name.str, "utf8", 4)); /* CREATE TABLE t1 (a CHAR(10) COLLATE DEFAULT) CHARACTER SET utf8mb4; Nothing to do, we have the default collation already. */ - if (cs->state & MY_CS_PRIMARY) - return cs; + if (m_ci->state & MY_CS_PRIMARY) + return m_ci; /* CREATE TABLE t1 (a CHAR(10) COLLATE DEFAULT) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; @@ -69,7 +355,8 @@ CHARSET_INFO *Lex_charset_collation_st::find_default_collation(CHARSET_INFO *cs) Don't need to handle old_mode=UTF8_IS_UTF8MB3 here. See comments in find_bin_collation. */ - cs= get_charset_by_csname(cs->cs_name.str, MY_CS_PRIMARY, MYF(MY_WME)); + CHARSET_INFO *cs= get_charset_by_csname(m_ci->cs_name.str, + MY_CS_PRIMARY, MYF(MY_WME)); /* The above should never fail, as we have default collations for all character sets. @@ -79,21 +366,6 @@ CHARSET_INFO *Lex_charset_collation_st::find_default_collation(CHARSET_INFO *cs) } -bool Lex_charset_collation_st::set_charset_collate_exact(CHARSET_INFO *cs, - CHARSET_INFO *cl) -{ - DBUG_ASSERT(cs != nullptr && cl != nullptr); - if (!my_charset_same(cl, cs)) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - cl->coll_name.str, cs->cs_name.str); - return true; - } - set_collate_exact(cl); - return false; -} - - /* Resolve an empty or a contextually typed collation according to the upper level default character set (and optionally a collation), e.g.: @@ -105,8 +377,8 @@ bool Lex_charset_collation_st::set_charset_collate_exact(CHARSET_INFO *cs, "this" is the COLLATE clause (e.g. of a column) "def" is the upper level CHARACTER SET clause (e.g. of a table) */ -CHARSET_INFO * -Lex_charset_collation_st::resolved_to_character_set(CHARSET_INFO *def) const +CHARSET_INFO *Lex_exact_charset_extended_collation_attrs_st:: + resolved_to_character_set(CHARSET_INFO *def) const { DBUG_ASSERT(def); @@ -120,103 +392,84 @@ Lex_charset_collation_st::resolved_to_character_set(CHARSET_INFO *def) const DBUG_ASSERT(m_ci); return m_ci; case TYPE_COLLATE_CONTEXTUALLY_TYPED: - break; + { + Lex_exact_charset_opt_extended_collate tmp(def, true); + if (tmp.merge_context_collation_override(Lex_context_collation(m_ci))) + return NULL; + return tmp.collation().charset_info(); + } } - - // Contextually typed - DBUG_ASSERT(m_ci); - - if (is_contextually_typed_binary_style()) // CHAR(10) BINARY - return find_bin_collation(def); - - if (is_contextually_typed_collate_default()) // CHAR(10) COLLATE DEFAULT - return find_default_collation(def); - - /* - Non-binary and non-default contextually typed collation. - We don't have such yet - the parser cannot produce this. - But will have soon, e.g. "uca1400_as_ci". - */ DBUG_ASSERT(0); return NULL; } -/* - Merge the CHARACTER SET clause to: - - an empty COLLATE clause - - an explicitly typed collation name - - a contextually typed collation - - "this" corresponds to `CHARACTER SET xxx [BINARY]` - "cl" corresponds to the COLLATE clause -*/ -bool -Lex_charset_collation_st:: - merge_charset_clause_and_collate_clause(const Lex_charset_collation_st &cl) +bool Lex_exact_charset_extended_collation_attrs_st:: + merge_exact_collation(const Lex_exact_collation &cl) { - if (cl.is_empty()) // No COLLATE clause - return false; - switch (m_type) { case TYPE_EMPTY: /* No CHARACTER SET clause CHAR(10) NOT NULL COLLATE latin1_bin - CHAR(10) NOT NULL COLLATE DEFAULT */ - *this= cl; + *this= Lex_exact_charset_extended_collation_attrs(cl); return false; case TYPE_CHARACTER_SET: - case TYPE_COLLATE_EXACT: { - Lex_explicit_charset_opt_collate ecs(m_ci, m_type == TYPE_COLLATE_EXACT); - if (ecs.merge_collate_or_error(cl)) + // CHARACTER SET latin1 .. COLLATE latin1_swedish_ci + if (Lex_exact_charset(m_ci).raise_if_not_applicable(cl)) return true; - set_collate_exact(ecs.charset_and_collation()); + *this= Lex_exact_charset_extended_collation_attrs(cl); return false; } + case TYPE_COLLATE_EXACT: + { + // [CHARACTER SET latin1] COLLATE latin1_bin .. COLLATE latin1_bin + return Lex_exact_collation(m_ci).raise_if_not_equal(cl); + } case TYPE_COLLATE_CONTEXTUALLY_TYPED: - break; - } - - if (is_contextually_typed_collation()) - { - if (cl.is_contextually_typed_collation()) { - /* - CONTEXT + CONTEXT: - CHAR(10) BINARY .. COLLATE DEFAULT - not supported by the parser - CHAR(10) BINARY .. COLLATE uca1400_as_ci - not supported yet - */ - DBUG_ASSERT(0); // Not possible yet + // COLLATE DEFAULT .. COLLATE latin1_swedish_ci + if (cl.raise_if_conflicts_with_context_collation( + Lex_context_collation(m_ci), true)) + return true; + *this= Lex_exact_charset_extended_collation_attrs(cl); return false; } + } + DBUG_ASSERT(0); + return false; +} + +bool Lex_exact_charset_extended_collation_attrs_st:: + merge_context_collation(const Lex_context_collation &cl) +{ + switch (m_type) { + case TYPE_EMPTY: /* - CONTEXT + EXPLICIT - CHAR(10) COLLATE DEFAULT .. COLLATE latin1_swedish_ci - CHAR(10) BINARY .. COLLATE latin1_bin - CHAR(10) COLLATE uca1400_as_ci .. COLLATE latin1_bin + No CHARACTER SET clause + CHAR(10) NOT NULL .. COLLATE DEFAULT */ - if (is_contextually_typed_collate_default() && - !(cl.charset_collation()->state & MY_CS_PRIMARY)) - { - my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), - "COLLATE ", "DEFAULT", "COLLATE ", - cl.charset_collation()->coll_name.str); - return true; - } - - if (is_contextually_typed_binary_style() && - !(cl.charset_collation()->state & MY_CS_BINSORT)) + *this= Lex_exact_charset_extended_collation_attrs(cl); + return false; + case TYPE_CHARACTER_SET: { - my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), - "", "BINARY", "COLLATE ", cl.charset_collation()->coll_name.str); - return true; + // CHARACTER SET latin1 .. COLLATE DEFAULT + Lex_exact_charset_opt_extended_collate tmp(m_ci, false); + if (tmp.merge_context_collation(cl)) + return true; + *this= Lex_exact_charset_extended_collation_attrs(tmp.collation()); + return false; } - *this= cl; - return false; + case TYPE_COLLATE_EXACT: + // [CHARACTER SET latin1] COLLATE latin1_swedish_ci .. COLLATE DEFAULT + return Lex_exact_collation(m_ci). + raise_if_conflicts_with_context_collation(cl, false); + case TYPE_COLLATE_CONTEXTUALLY_TYPED: + // COLLATE DEFAULT .. COLLATE DEFAULT + return Lex_context_collation(m_ci).raise_if_not_equal(cl); } DBUG_ASSERT(0); @@ -224,69 +477,38 @@ Lex_charset_collation_st:: } -bool -Lex_explicit_charset_opt_collate:: - merge_collate_or_error(const Lex_charset_collation_st &cl) +bool Lex_exact_charset_opt_extended_collate:: + merge_exact_collation(const Lex_exact_collation &cl) { - DBUG_ASSERT(cl.type() != Lex_charset_collation_st::TYPE_CHARACTER_SET); + // CHARACTER SET latin1 [COLLATE latin1_bin] .. COLLATE latin1_bin + if (m_with_collate) + return Lex_exact_collation(m_ci).raise_if_not_equal(cl); + if (raise_if_not_applicable(cl)) + return true; + *this= Lex_exact_charset_opt_extended_collate(cl); + return false; +} - switch (cl.type()) { - case Lex_charset_collation_st::TYPE_EMPTY: - return false; - case Lex_charset_collation_st::TYPE_CHARACTER_SET: - DBUG_ASSERT(0); - return false; - case Lex_charset_collation_st::TYPE_COLLATE_EXACT: - /* - EXPLICIT + EXPLICIT - CHAR(10) CHARACTER SET latin1 .. COLLATE latin1_bin - CHAR(10) CHARACTER SET latin1 COLLATE latin1_bin .. COLLATE latin1_bin - CHAR(10) COLLATE latin1_bin .. COLLATE latin1_bin - CHAR(10) COLLATE latin1_bin .. COLLATE latin1_bin - CHAR(10) CHARACTER SET latin1 BINARY .. COLLATE latin1_bin - */ - if (m_with_collate && m_ci != cl.charset_collation()) - { - my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), - "COLLATE ", m_ci->coll_name.str, - "COLLATE ", cl.charset_collation()->coll_name.str); - return true; - } - if (!my_charset_same(m_ci, cl.charset_collation())) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - cl.charset_collation()->coll_name.str, m_ci->cs_name.str); - return true; - } - m_ci= cl.charset_collation(); - m_with_collate= true; - return false; - case Lex_charset_collation_st::TYPE_COLLATE_CONTEXTUALLY_TYPED: - if (cl.is_contextually_typed_collate_default()) - { - /* - SET NAMES latin1 COLLATE DEFAULT; - ALTER TABLE t1 CONVERT TO CHARACTER SET latin1 COLLATE DEFAULT; - */ - CHARSET_INFO *tmp= Lex_charset_collation_st::find_default_collation(m_ci); - if (!tmp) - return true; - m_ci= tmp; - m_with_collate= true; - return false; - } - else - { - /* - EXPLICIT + CONTEXT - CHAR(10) COLLATE latin1_bin .. COLLATE DEFAULT not possible yet - CHAR(10) COLLATE latin1_bin .. COLLATE uca1400_as_ci - */ +bool Lex_exact_charset_opt_extended_collate:: + merge_context_collation(const Lex_context_collation &cl) +{ + // CHARACTER SET latin1 [COLLATE latin1_bin] .. COLLATE DEFAULT + if (m_with_collate) + return Lex_exact_collation(m_ci). + raise_if_conflicts_with_context_collation(cl, false); + return merge_context_collation_override(cl); +} - DBUG_ASSERT(0); // Not possible yet - return false; - } + +bool Lex_exact_charset_extended_collation_attrs_st:: + merge_collation(const Lex_extended_collation_st &cl) +{ + switch (cl.type()) { + case Lex_extended_collation_st::TYPE_EXACT: + return merge_exact_collation(Lex_exact_collation(cl.charset_info())); + case Lex_extended_collation_st::TYPE_CONTEXTUALLY_TYPED: + return merge_context_collation(Lex_context_collation(cl.charset_info())); } DBUG_ASSERT(0); return false; @@ -294,47 +516,161 @@ Lex_explicit_charset_opt_collate:: /* - This method is used in the "attribute_list" rule to merge two independent - COLLATE clauses (not belonging to a CHARACTER SET clause). + Mix an unordered combination of CHARACTER SET and COLLATE clauses + (i.e. COLLATE can come before CHARACTER SET). + Merge a CHARACTER SET clause. + @param cs - The "CHARACTER SET exact_charset_name". */ -bool -Lex_charset_collation_st:: - merge_collate_clause_and_collate_clause(const Lex_charset_collation_st &cl) +bool Lex_exact_charset_extended_collation_attrs_st:: + merge_exact_charset(const Lex_exact_charset &cs) { - /* - "BINARY" and "COLLATE DEFAULT" are not possible - in an independent COLLATE clause in a column attribute. - */ - DBUG_ASSERT(!is_contextually_typed_collation()); - DBUG_ASSERT(!cl.is_contextually_typed_collation()); - - if (cl.is_empty()) - return false; + DBUG_ASSERT(cs.charset_info()); switch (m_type) { case TYPE_EMPTY: - *this= cl; + // CHARACTER SET cs + *this= Lex_exact_charset_extended_collation_attrs(cs); return false; + case TYPE_CHARACTER_SET: - DBUG_ASSERT(0); - return false; + // CHARACTER SET cs1 .. CHARACTER SET cs2 + return Lex_exact_charset(m_ci).raise_if_not_equal(cs); + case TYPE_COLLATE_EXACT: + // COLLATE latin1_bin .. CHARACTER SET cs + return cs.raise_if_not_applicable(Lex_exact_collation(m_ci)); + case TYPE_COLLATE_CONTEXTUALLY_TYPED: - break; + // COLLATE DEFAULT .. CHARACTER SET cs + { + Lex_exact_charset_opt_extended_collate tmp(cs); + if (tmp.merge_context_collation(Lex_context_collation(m_ci))) + return true; + *this= Lex_exact_charset_extended_collation_attrs(tmp.collation()); + return false; + } } + DBUG_ASSERT(0); + return false; +} - /* - Two independent explicit collations: - CHAR(10) NOT NULL COLLATE latin1_bin DEFAULT 'a' COLLATE latin1_bin - Note, we should perhaps eventually disallow double COLLATE clauses. - But for now let's just disallow only conflicting ones. - */ - if (charset_collation() != cl.charset_collation()) + +bool Lex_extended_charset_extended_collation_attrs_st::merge_charset_default() +{ + if (m_charset_order == CHARSET_TYPE_EMPTY) + m_charset_order= CHARSET_TYPE_CONTEXT; + Lex_opt_context_charset_st::merge_charset_default(); + return false; +} + + +bool Lex_extended_charset_extended_collation_attrs_st:: + merge_exact_charset(const Lex_exact_charset &cs) +{ + m_had_charset_exact= true; + if (m_charset_order == CHARSET_TYPE_EMPTY) + m_charset_order= CHARSET_TYPE_EXACT; + return Lex_exact_charset_extended_collation_attrs_st::merge_exact_charset(cs); +} + + +bool Lex_extended_charset_extended_collation_attrs_st:: + raise_if_charset_conflicts_with_default( + const Lex_exact_charset_opt_extended_collate &def) const +{ + DBUG_ASSERT(m_charset_order != CHARSET_TYPE_EMPTY || is_empty()); + if (!my_charset_same(def.collation().charset_info(), m_ci)) { - my_error(ER_CONFLICTING_DECLARATIONS, MYF(0), - "COLLATE ", charset_collation()->coll_name.str, - "COLLATE ", cl.charset_collation()->coll_name.str); + raise_ER_CONFLICTING_DECLARATIONS("CHARACTER SET ", "DEFAULT", + def.collation().charset_info()->cs_name.str, + "CHARACTER SET ", m_ci->cs_name.str, + m_charset_order == CHARSET_TYPE_EXACT); return true; } return false; } + + +CHARSET_INFO * +Lex_extended_charset_extended_collation_attrs_st:: + resolved_to_context(const Charset_collation_context &ctx) const +{ + if (Lex_opt_context_charset_st::is_empty()) + { + // Without CHARACTER SET DEFAULT + return Lex_exact_charset_extended_collation_attrs_st:: + resolved_to_character_set(ctx.collate_default().charset_info()); + } + + // With CHARACTER SET DEFAULT + switch (type()) { + case TYPE_EMPTY: + // CHARACTER SET DEFAULT; + return ctx.charset_default().charset().charset_info(); + + case TYPE_CHARACTER_SET: + // CHARACTER SET DEFAULT CHARACTER SET cs_exact + if (raise_if_charset_conflicts_with_default(ctx.charset_default())) + { + /* + A possible scenario: + SET character_set_server=utf8mb4; + CREATE DATABASE db1 CHARACTER SET latin1 CHARACTER SET DEFAULT; + */ + return NULL; + } + return m_ci; + + case TYPE_COLLATE_EXACT: + { + /* + CREATE DATABASE db1 + COLLATE cl_exact + [ CHARACTER SET cs_exact ] + CHARACTER SET DEFAULT; + */ + if (m_had_charset_exact && + raise_if_charset_conflicts_with_default(ctx.charset_default())) + { + /* + A possible scenario: + SET character_set_server=utf8mb4; + CREATE DATABASE db1 + COLLATE latin1_bin + CHARACTER SET latin1 + CHARACTER SET DEFAULT; + */ + return NULL; + } + /* + Now check that "COLLATE cl_exact" does not conflict with + CHARACTER SET DEFAULT. + */ + if (ctx.charset_default(). + raise_if_not_applicable(Lex_exact_collation(m_ci))) + { + /* + A possible scenario: + SET character_set_server=utf8mb4; + CREATE DATABASE db1 + COLLATE latin1_bin + CHARACTER SET DEFAULT; + */ + return NULL; + } + return m_ci; + } + + case TYPE_COLLATE_CONTEXTUALLY_TYPED: + /* + Both CHARACTER SET and COLLATE are contextual: + ALTER DATABASE db1 CHARACTER SET DEFAULT COLLATE DEFAULT; + ALTER DATABASE db1 COLLATE DEFAULT CHARACTER SET DEFAULT; + */ + return Lex_exact_charset_extended_collation_attrs_st:: + resolved_to_character_set(ctx.charset_default(). + collation().charset_info()); + } + DBUG_ASSERT(0); + return NULL; +} diff --git a/sql/lex_charset.h b/sql/lex_charset.h index abbe761df36..d195b405569 100644 --- a/sql/lex_charset.h +++ b/sql/lex_charset.h @@ -16,8 +16,237 @@ #ifndef LEX_CHARSET_INCLUDED #define LEX_CHARSET_INCLUDED + +/* + An exact character set, e.g: + CHARACTER SET latin1 +*/ +class Lex_exact_charset +{ + CHARSET_INFO *m_ci; +public: + explicit Lex_exact_charset(CHARSET_INFO *ci) + :m_ci(ci) + { + DBUG_ASSERT(m_ci); + DBUG_ASSERT(m_ci->state & MY_CS_PRIMARY); + } + CHARSET_INFO *charset_info() const { return m_ci; } + bool raise_if_not_equal(const Lex_exact_charset &rhs) const; + bool raise_if_not_applicable(const class Lex_exact_collation &cl) const; +}; + + +/* + An optional contextually typed character set: + [ CHARACTER SET DEFAULT ] +*/ +class Lex_opt_context_charset_st +{ + /* + Currently we support only DEFAULT as a possible value. + So "bool" is enough. + */ + bool m_had_charset_default; +public: + void init() + { + m_had_charset_default= false; + } + void merge_charset_default() + { + /* + Ok to specify CHARACTER SET DEFAULT multiple times. + No error raised here. + */ + m_had_charset_default= true; + } + bool is_empty() const + { + return !m_had_charset_default; + } + bool is_contextually_typed_charset_default() const + { + return m_had_charset_default; + } +}; + + +/* + A contextually typed collation, e.g.: + COLLATE DEFAULT + CHAR(10) BINARY +*/ +class Lex_context_collation +{ + CHARSET_INFO *m_ci; +public: + explicit Lex_context_collation(CHARSET_INFO *ci) + :m_ci(ci) + { + DBUG_ASSERT(ci); + } + CHARSET_INFO *charset_info() const { return m_ci; } + bool is_contextually_typed_collate_default() const + { + return m_ci == &my_collation_contextually_typed_default; + } + bool is_contextually_typed_binary_style() const + { + return m_ci == &my_collation_contextually_typed_binary; + } + bool raise_if_not_equal(const Lex_context_collation &cl) const; +}; + + +/* + An exact collation, e.g. + COLLATE latin1_swedish_ci +*/ +class Lex_exact_collation +{ + CHARSET_INFO *m_ci; +public: + explicit Lex_exact_collation(CHARSET_INFO *ci) + :m_ci(ci) + { + DBUG_ASSERT(ci); + } + CHARSET_INFO *charset_info() const { return m_ci; } + // EXACT + EXACT + bool raise_if_not_equal(const Lex_exact_collation &cl) const; + // EXACT + CONTEXT + // CONTEXT + EXACT + bool raise_if_conflicts_with_context_collation(const Lex_context_collation &, + bool reverse_order) const; +}; + + +/* + Parse time COLLATE clause: + COLLATE colation_name + The collation can be either exact or contextual: + COLLATE latin1_bin + COLLATE DEFAULT +*/ +class Lex_extended_collation_st +{ +public: + enum Type + { + TYPE_EXACT, + TYPE_CONTEXTUALLY_TYPED + }; +protected: + CHARSET_INFO *m_ci; + Type m_type; +public: + void init(CHARSET_INFO *ci, Type type) + { + m_ci= ci; + m_type= type; + } + CHARSET_INFO *charset_info() const { return m_ci; } + Type type() const { return m_type; } + void set_collate_default() + { + m_ci= &my_collation_contextually_typed_default; + m_type= TYPE_CONTEXTUALLY_TYPED; + } + bool raise_if_conflicts_with_context_collation(const Lex_context_collation &) + const; + bool merge_exact_charset(const Lex_exact_charset &rhs); + bool merge_exact_collation(const Lex_exact_collation &rhs); + bool merge(const Lex_extended_collation_st &rhs); +}; + + +class Lex_extended_collation: public Lex_extended_collation_st +{ +public: + Lex_extended_collation(CHARSET_INFO *ci, Type type) + { + init(ci, type); + } + Lex_extended_collation(const Lex_exact_collation &rhs) + { + init(rhs.charset_info(), TYPE_EXACT); + } +}; + + +/* + CHARACTER SET cs_exact [COLLATE cl_exact_or_context] +*/ +class Lex_exact_charset_opt_extended_collate +{ + CHARSET_INFO *m_ci; + bool m_with_collate; +public: + Lex_exact_charset_opt_extended_collate(CHARSET_INFO *ci, bool with_collate) + :m_ci(ci), m_with_collate(with_collate) + { + DBUG_ASSERT(m_ci); + DBUG_ASSERT((m_ci->state & MY_CS_PRIMARY) || m_with_collate); + } + Lex_exact_charset_opt_extended_collate(const Lex_exact_charset &cs) + :m_ci(cs.charset_info()), m_with_collate(false) + { + DBUG_ASSERT(m_ci); + DBUG_ASSERT(m_ci->state & MY_CS_PRIMARY); + } + Lex_exact_charset_opt_extended_collate(const Lex_exact_collation &cl) + :m_ci(cl.charset_info()), m_with_collate(true) + { + DBUG_ASSERT(m_ci); + } + bool with_collate() const { return m_with_collate; } + CHARSET_INFO *find_bin_collation() const; + CHARSET_INFO *find_default_collation() const; + bool raise_if_not_applicable(const Lex_exact_collation &cl) const; + /* + Add another COLLATE clause (exact or context). + So the full syntax looks like: + CHARACTER SET cs [COLLATE cl] ... COLLATE cl2 + */ + bool merge_collation(const Lex_extended_collation_st &cl) + { + switch (cl.type()) { + case Lex_extended_collation_st::TYPE_EXACT: + return merge_exact_collation(Lex_exact_collation(cl.charset_info())); + case Lex_extended_collation_st::TYPE_CONTEXTUALLY_TYPED: + return merge_context_collation(Lex_context_collation(cl.charset_info())); + } + DBUG_ASSERT(0); + return false; + } + /* + Add a context collation: + CHARACTER SET cs [COLLATE cl] ... COLLATE DEFAULT + */ + bool merge_context_collation(const Lex_context_collation &cl); + bool merge_context_collation_override(const Lex_context_collation &cl); + /* + Add an exact collation: + CHARACTER SET cs [COLLATE cl] ... COLLATE latin1_bin + */ + bool merge_exact_collation(const Lex_exact_collation &cl); + Lex_exact_collation collation() const + { + return Lex_exact_collation(m_ci); + } + Lex_exact_charset charset() const + { + if ((m_ci->state & MY_CS_PRIMARY)) + return Lex_exact_charset(m_ci); + return Lex_exact_charset(find_default_collation()); + } +}; + + /* - Parse time character set and collation. + Parse time character set and collation for: + [CHARACTER SET cs_exact] [COLLATE cl_exact_or_context] Can be: @@ -44,7 +273,7 @@ Resolution happens in Type_handler::Column_definition_prepare_stage1(). */ -struct Lex_charset_collation_st +struct Lex_exact_charset_extended_collation_attrs_st { public: enum Type @@ -60,20 +289,50 @@ public: #define LEX_CHARSET_COLLATION_TYPE_BITS 2 static_assert(((1<<LEX_CHARSET_COLLATION_TYPE_BITS)-1) >= TYPE_COLLATE_CONTEXTUALLY_TYPED, - "Lex_charset_collation_st::Type bits check"); + "Lex_exact_charset_extended_collation_attrs_st::Type bits"); protected: CHARSET_INFO *m_ci; Type m_type; -public: - static CHARSET_INFO *find_bin_collation(CHARSET_INFO *cs); - static CHARSET_INFO *find_default_collation(CHARSET_INFO *cs); +protected: + static Type type_from_lex_collation_type(Lex_extended_collation_st::Type type) + { + switch (type) { + case Lex_extended_collation_st::TYPE_EXACT: + return TYPE_COLLATE_EXACT; + case Lex_extended_collation_st::TYPE_CONTEXTUALLY_TYPED: + return TYPE_COLLATE_CONTEXTUALLY_TYPED; + } + DBUG_ASSERT(0); + return TYPE_COLLATE_EXACT; + } public: void init() { m_ci= NULL; m_type= TYPE_EMPTY; } + void init(CHARSET_INFO *cs, Type type) + { + DBUG_ASSERT(cs || type == TYPE_EMPTY); + m_ci= cs; + m_type= type; + } + void init(const Lex_exact_charset &cs) + { + m_ci= cs.charset_info(); + m_type= TYPE_CHARACTER_SET; + } + void init(const Lex_exact_collation &cs) + { + m_ci= cs.charset_info(); + m_type= TYPE_COLLATE_EXACT; + } + void init(const Lex_exact_charset_opt_extended_collate &cscl) + { + cscl.with_collate() ? init(cscl.collation()) : + init(cscl.charset()); + } bool is_empty() const { return m_type == TYPE_EMPTY; @@ -84,23 +343,26 @@ public: m_ci= cs; m_type= TYPE_CHARACTER_SET; } - void set_charset_collate_default(CHARSET_INFO *cs) + bool set_charset_collate_default(CHARSET_INFO *cs) { DBUG_ASSERT(cs); + if (!(cs= Lex_exact_charset_opt_extended_collate(cs, true). + find_default_collation())) + return true; m_ci= cs; m_type= TYPE_COLLATE_EXACT; + return false; } bool set_charset_collate_binary(CHARSET_INFO *cs) { DBUG_ASSERT(cs); - if (!(cs= find_bin_collation(cs))) + if (!(cs= Lex_exact_charset_opt_extended_collate(cs, true). + find_bin_collation())) return true; m_ci= cs; m_type= TYPE_COLLATE_EXACT; return false; } - bool set_charset_collate_exact(CHARSET_INFO *cs, - CHARSET_INFO *cl); void set_collate_default() { m_ci= &my_collation_contextually_typed_default; @@ -113,19 +375,9 @@ public: } bool is_contextually_typed_collate_default() const { - return m_ci == &my_collation_contextually_typed_default; + return Lex_context_collation(m_ci).is_contextually_typed_collate_default(); } - bool is_contextually_typed_binary_style() const - { - return m_ci == &my_collation_contextually_typed_binary; - } - void set_collate_exact(CHARSET_INFO *cl) - { - DBUG_ASSERT(cl); - m_ci= cl; - m_type= TYPE_COLLATE_EXACT; - } - CHARSET_INFO *charset_collation() const + CHARSET_INFO *charset_info() const { return m_ci; } @@ -138,62 +390,262 @@ public: return m_type == TYPE_COLLATE_CONTEXTUALLY_TYPED; } CHARSET_INFO *resolved_to_character_set(CHARSET_INFO *cs) const; - bool merge_charset_clause_and_collate_clause(const Lex_charset_collation_st &cl); - bool merge_collate_clause_and_collate_clause(const Lex_charset_collation_st &cl); + /* + Merge the column CHARACTER SET clause to: + - an exact collation name + - a contextually typed collation + "this" corresponds to `CHARACTER SET xxx [BINARY]` + "cl" corresponds to the COLLATE clause + */ + bool merge_column_charset_clause_and_collate_clause( + const Lex_exact_charset_extended_collation_attrs_st &cl) + { + switch (cl.type()) { + case TYPE_EMPTY: + return false; + case TYPE_COLLATE_EXACT: + return merge_exact_collation(Lex_exact_collation(cl.charset_info())); + case TYPE_COLLATE_CONTEXTUALLY_TYPED: + case TYPE_CHARACTER_SET: + break; + } + DBUG_ASSERT(0); + return false; + } + /* + This method is used in the "attribute_list" rule to merge two independent + COLLATE clauses (not belonging to a CHARACTER SET clause). + "BINARY" and "COLLATE DEFAULT" are not possible + in an independent COLLATE clause in a column attribute. + */ + bool merge_column_collate_clause_and_collate_clause( + const Lex_exact_charset_extended_collation_attrs_st &cl) + { + DBUG_ASSERT(m_type != TYPE_COLLATE_CONTEXTUALLY_TYPED); + DBUG_ASSERT(m_type != TYPE_CHARACTER_SET); + switch (cl.type()) { + case TYPE_EMPTY: + return false; + case TYPE_COLLATE_EXACT: + return merge_exact_collation(Lex_exact_collation(cl.charset_info())); + case TYPE_COLLATE_CONTEXTUALLY_TYPED: + case TYPE_CHARACTER_SET: + break; + } + DBUG_ASSERT(0); + return false; + } + bool merge_exact_charset(const Lex_exact_charset &cs); + bool merge_exact_collation(const Lex_exact_collation &cl); + bool merge_context_collation(const Lex_context_collation &cl); + bool merge_collation(const Lex_extended_collation_st &cl); }; -/* - CHARACTER SET cs [COLLATE cl] -*/ -class Lex_explicit_charset_opt_collate +class Charset_collation_context { - CHARSET_INFO *m_ci; - bool m_with_collate; + /* + Although the goal of m_charset_default is to store the meaning + of CHARACTER SET DEFAULT, it does not necessarily point to a + default collation of CHARACTER SET DEFAULT. It can point to its any + arbitrary collation. + For performance purposes we don't need to find the default + collation at the instantiation time of "this", because: + - m_charset_default may not be even needed during the resolution + - when it's needed, in many cases it's passed to my_charset_same(), + which does not need the default collation again. + + Note, m_charset_default and m_collate_default are not necessarily equal. + + - The default value for CHARACTER SET is taken from the upper level: + CREATE DATABASE db1 CHARACTER SET DEFAULT; <-- @@character_set_server + ALTER DATABASE db1 CHARACTER SET DEFAULT; <-- @@character_set_server + + - The default value for COLLATE is taken from the upper level for CREATE: + CREATE DATABASE db1 COLLATE DEFAULT; <-- @@collation_server + CREATE TABLE db1.t1 COLLATE DEFAULT; <-- character set of "db1" + + - The default value for COLLATE is taken from the same level for ALTER: + ALTER DATABASE db1 COLLATE DEFAULT; <-- the default collation of the + current db1 character set + ALTER TABLE db1.t1 COLLATE DEFAULT; <-- the default collation of the + current db1.t1 character set + */ + + // comes from the upper level + Lex_exact_charset_opt_extended_collate m_charset_default; + + // comes from the upper or the current level + Lex_exact_collation m_collate_default; public: - Lex_explicit_charset_opt_collate(CHARSET_INFO *ci, bool with_collate) - :m_ci(ci), m_with_collate(with_collate) + Charset_collation_context(CHARSET_INFO *charset_default, + CHARSET_INFO *collate_default) + :m_charset_default(charset_default, + !(charset_default->state & MY_CS_PRIMARY)), + m_collate_default(collate_default) + { } + const Lex_exact_charset_opt_extended_collate charset_default() const { - DBUG_ASSERT(m_ci); - // Item_func_set_collation uses non-default collations in "ci" - //DBUG_ASSERT(m_ci->default_flag() || m_with_collate); + return m_charset_default; + } + const Lex_exact_collation collate_default() const + { + return m_collate_default; } +}; + + +/* + A universal container. It can store at the same time: + - CHARACTER SET DEFAULT + - CHARACTER SET cs_exact + - COLLATE {cl_exact|cl_context} + All three parts can co-exist. + All three parts are optional. + Parts can come in any arbitrary order, e.g: + + CHARACTER SET DEFAULT [CHARACTER SET latin1] COLLATE latin1_bin + CHARACTER SET latin1 CHARACTER SET DEFAULT COLLATE latin1_bin + COLLATE latin1_bin [CHARACTER SET latin1] CHARACTER SET DEFAULT + COLLATE latin1_bin CHARACTER SET DEFAULT [CHARACTER SET latin1] +*/ +class Lex_extended_charset_extended_collation_attrs_st: + public Lex_opt_context_charset_st, + public Lex_exact_charset_extended_collation_attrs_st +{ + enum charset_type_t + { + CHARSET_TYPE_EMPTY, + CHARSET_TYPE_CONTEXT, + CHARSET_TYPE_EXACT + }; /* - Merge to another COLLATE clause. So the full syntax looks like: - CHARACTER SET cs [COLLATE cl] ... COLLATE cl2 + Which part came first: + - CHARACTER SET DEFAULT or + - CHARACTER SET cs_exact + e.g. to produce error messages preserving the user typed + order of CHARACTER SET clauses in case of conflicts. */ - bool merge_collate_or_error(const Lex_charset_collation_st &cl); - bool merge_opt_collate_or_error(const Lex_charset_collation_st &cl) + charset_type_t m_charset_order; + /* + The parent class Lex_exact_charset_extended_collation_attrs_st + does not let know if a "COLLATE cl_exact" was used in combination with + "CHARACTER SET cs_exact" or just alone. + Here we need to distinguish: + - CHARACTER SET cs_exact COLLATE cl_exact, or + - COLLATE cl_exact CHARACTER SET cs_exact + versus just: + - COLLATE cl_exact + to produce better error messages in case of conflicts. + So let's add a flag member: + */ + bool m_had_charset_exact; +public: + void init() { - if (cl.is_empty()) - return false; - return merge_collate_or_error(cl); + Lex_opt_context_charset_st::init(); + Lex_exact_charset_extended_collation_attrs_st::init(); + m_charset_order= CHARSET_TYPE_EMPTY; + m_had_charset_exact= false; } - CHARSET_INFO *charset_and_collation() const { return m_ci; } - bool with_collate() const { return m_with_collate; } + void init(const Lex_exact_charset_opt_extended_collate &c) + { + Lex_opt_context_charset_st::init(); + Lex_exact_charset_extended_collation_attrs_st::init(c); + m_charset_order= CHARSET_TYPE_EXACT; + m_had_charset_exact= true; + } + bool is_empty() const + { + return Lex_opt_context_charset_st::is_empty() && + Lex_exact_charset_extended_collation_attrs_st::is_empty(); + } + bool raise_if_charset_conflicts_with_default( + const Lex_exact_charset_opt_extended_collate &def) const; + CHARSET_INFO *resolved_to_context(const Charset_collation_context &ctx) const; + bool merge_charset_default(); + bool merge_exact_charset(const Lex_exact_charset &cs); }; -class Lex_charset_collation: public Lex_charset_collation_st +class Lex_exact_charset_extended_collation_attrs: + public Lex_exact_charset_extended_collation_attrs_st { public: - Lex_charset_collation() + Lex_exact_charset_extended_collation_attrs() { init(); } - Lex_charset_collation(CHARSET_INFO *collation, Type type) + Lex_exact_charset_extended_collation_attrs(CHARSET_INFO *collation, Type type) { - DBUG_ASSERT(collation || type == TYPE_EMPTY); - m_ci= collation; - m_type= type; + init(collation, type); + } + explicit + Lex_exact_charset_extended_collation_attrs(const Lex_exact_charset &cs) + { + init(cs.charset_info(), TYPE_CHARACTER_SET); + } + explicit + Lex_exact_charset_extended_collation_attrs(const Lex_exact_collation &cl) + { + init(cl.charset_info(), TYPE_COLLATE_EXACT); + } + explicit + Lex_exact_charset_extended_collation_attrs(const Lex_context_collation &cl) + { + init(cl.charset_info(), TYPE_COLLATE_CONTEXTUALLY_TYPED); } - static Lex_charset_collation national(bool bin_mod) + explicit + Lex_exact_charset_extended_collation_attrs( + const Lex_exact_charset_opt_extended_collate &cscl) + { + init(cscl); + } + explicit + Lex_exact_charset_extended_collation_attrs(const Lex_extended_collation_st &cl) + { + init(cl.charset_info(), type_from_lex_collation_type(cl.type())); + } + static Lex_exact_charset_extended_collation_attrs national(bool bin_mod) { return bin_mod ? - Lex_charset_collation(&my_charset_utf8mb3_bin, TYPE_COLLATE_EXACT) : - Lex_charset_collation(&my_charset_utf8mb3_general_ci, TYPE_CHARACTER_SET); + Lex_exact_charset_extended_collation_attrs(&my_charset_utf8mb3_bin, + TYPE_COLLATE_EXACT) : + Lex_exact_charset_extended_collation_attrs(&my_charset_utf8mb3_general_ci, + TYPE_CHARACTER_SET); + } +}; + + +class Lex_extended_charset_extended_collation_attrs: + public Lex_extended_charset_extended_collation_attrs_st +{ +public: + Lex_extended_charset_extended_collation_attrs() + { + init(); + } + explicit Lex_extended_charset_extended_collation_attrs( + const Lex_exact_charset_opt_extended_collate &c) + { + init(c); } }; + +using Lex_column_charset_collation_attrs_st = + Lex_exact_charset_extended_collation_attrs_st; + +using Lex_column_charset_collation_attrs = + Lex_exact_charset_extended_collation_attrs; + + +using Lex_table_charset_collation_attrs_st = + Lex_extended_charset_extended_collation_attrs_st; + +using Lex_table_charset_collation_attrs = + Lex_extended_charset_extended_collation_attrs; + + #endif // LEX_CHARSET_INCLUDED diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 710f05784d1..934226685a9 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -335,7 +335,7 @@ static char *init_bootstrap_command_line(char *cmdline, size_t size) " %s" " --bootstrap" " --datadir=." - " --loose-innodb-buffer-pool-size=10M" + " --loose-innodb-buffer-pool-size=20M" "\"" , mysqld_path, opt_verbose_bootstrap ? "--console" : ""); return cmdline; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 00a7b23b085..9a64fbf2c52 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1559,11 +1559,15 @@ static void kill_thread(THD *thd) /** First shutdown everything but slave threads and binlog dump connections */ -static my_bool kill_thread_phase_1(THD *thd, void *) +static my_bool kill_thread_phase_1(THD *thd, int *n_threads_awaiting_ack) { DBUG_PRINT("quit", ("Informing thread %ld that it's time to die", (ulong) thd->thread_id)); - if (thd->slave_thread || thd->is_binlog_dump_thread()) + + if (thd->slave_thread || thd->is_binlog_dump_thread() || + (shutdown_wait_for_slaves && + repl_semisync_master.is_thd_awaiting_semisync_ack(thd) && + ++(*n_threads_awaiting_ack))) return 0; if (DBUG_IF("only_kill_system_threads") ? !thd->system_thread : 0) @@ -1578,7 +1582,7 @@ static my_bool kill_thread_phase_1(THD *thd, void *) */ static my_bool kill_thread_phase_2(THD *thd, void *) { - if (shutdown_wait_for_slaves) + if (shutdown_wait_for_slaves && thd->is_binlog_dump_thread()) { thd->set_killed(KILL_SERVER); } @@ -1751,7 +1755,29 @@ static void close_connections(void) This will give the threads some time to gracefully abort their statements and inform their clients that the server is about to die. */ - server_threads.iterate(kill_thread_phase_1); + DBUG_EXECUTE_IF("mysqld_delay_kill_threads_phase_1", my_sleep(200000);); + int n_threads_awaiting_ack= 0; + server_threads.iterate(kill_thread_phase_1, &n_threads_awaiting_ack); + + /* + If we are waiting on any ACKs, delay killing the thread until either an ACK + is received or the timeout is hit. + + Allow at max the number of sessions to await a timeout; however, if all + ACKs have been received in less iterations, then quit early + */ + if (shutdown_wait_for_slaves && repl_semisync_master.get_master_enabled()) + { + int waiting_threads= repl_semisync_master.sync_get_master_wait_sessions(); + if (waiting_threads) + sql_print_information("Delaying shutdown to await semi-sync ACK"); + + while (waiting_threads-- > 0) + repl_semisync_master.await_slave_reply(); + } + + DBUG_EXECUTE_IF("delay_shutdown_phase_2_after_semisync_wait", + my_sleep(500000);); Events::deinit(); slave_prepare_for_shutdown(); @@ -1774,7 +1800,8 @@ static void close_connections(void) */ DBUG_PRINT("info", ("THD_count: %u", THD_count::value())); - for (int i= 0; (THD_count::connection_thd_count()) && i < 1000; i++) + for (int i= 0; THD_count::connection_thd_count() - n_threads_awaiting_ack + && i < 1000; i++) my_sleep(20000); if (global_system_variables.log_warnings) @@ -1788,9 +1815,10 @@ static void close_connections(void) wsrep_sst_auth_free(); #endif /* All threads has now been aborted */ - DBUG_PRINT("quit", ("Waiting for threads to die (count=%u)", THD_count::value())); + DBUG_PRINT("quit", ("Waiting for threads to die (count=%u)", + THD_count::connection_thd_count() - n_threads_awaiting_ack)); - while (THD_count::connection_thd_count()) + while (THD_count::connection_thd_count() - n_threads_awaiting_ack) my_sleep(1000); /* Kill phase 2 */ @@ -5353,6 +5381,9 @@ static int init_server_components() if (ha_recover(0)) unireg_abort(1); +#ifndef EMBEDDED_LIBRARY + start_handle_manager(); +#endif if (opt_bin_log) { int error; @@ -5810,8 +5841,6 @@ int mysqld_main(int argc, char **argv) } } - start_handle_manager(); - /* Copy default global rpl_filter to global_rpl_filter */ copy_filter_setting(global_rpl_filter, get_or_create_rpl_filter("", 0)); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 5c2237fb3d2..19f077136cb 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -829,12 +829,10 @@ bool partition_info::vers_set_hist_part(THD *thd, uint *create_count) { DBUG_ASSERT(!vers_info->interval.is_set()); ha_partition *hp= (ha_partition*)(table->file); - partition_element *next= NULL; + partition_element *next; List_iterator<partition_element> it(partitions); - while (next != vers_info->hist_part) - next= it++; - DBUG_ASSERT(bitmap_is_set(&read_partitions, next->id)); - ha_rows records= hp->part_records(next); + ha_rows records= 0; + vers_info->hist_part= partitions.head(); while ((next= it++) != vers_info->now_part) { DBUG_ASSERT(bitmap_is_set(&read_partitions, next->id)); @@ -850,14 +848,11 @@ bool partition_info::vers_set_hist_part(THD *thd, uint *create_count) { if (auto_hist) *create_count= 1; - else - my_error(WARN_VERS_PART_FULL, MYF(ME_WARNING|ME_ERROR_LOG), - table->s->db.str, table->s->table_name.str, - vers_info->hist_part->partition_name, "LIMIT"); } else vers_info->hist_part= next; } + return 0; } else if (vers_info->interval.is_set() && vers_info->hist_part->range_value <= thd->query_start()) @@ -927,7 +922,7 @@ bool partition_info::vers_set_hist_part(THD *thd, uint *create_count) bool vers_create_partitions(THD *thd, TABLE_LIST* tl, uint num_parts) { bool result= true; - HA_CREATE_INFO create_info; + Table_specification_st create_info; Alter_info alter_info; partition_info *save_part_info= thd->work_part_info; Query_tables_list save_query_tables; @@ -1039,6 +1034,43 @@ exit: } +/** + Warn at the end of DML command if the last history partition is out of LIMIT. +*/ +void partition_info::vers_check_limit(THD *thd) +{ + if (vers_info->auto_hist || !vers_info->limit || + vers_info->hist_part->id + 1 < vers_info->now_part->id) + return; + + /* + NOTE: at this point read_partitions bitmap is already pruned by DML code, + we have to set read bits for working history partition. We could use + bitmap_set_all(), but this is not optimal since there can be quite a number + of partitions. + */ + const uint32 sub_factor= num_subparts ? num_subparts : 1; + uint32 part_id= vers_info->hist_part->id * sub_factor; + const uint32 part_id_end= part_id + sub_factor; + DBUG_ASSERT(part_id_end <= num_parts * sub_factor); + + ha_partition *hp= (ha_partition*)(table->file); + ha_rows hist_rows= hp->part_records(vers_info->hist_part); + if (hist_rows >= vers_info->limit) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + WARN_VERS_PART_FULL, + ER_THD(thd, WARN_VERS_PART_FULL), + table->s->db.str, table->s->table_name.str, + vers_info->hist_part->partition_name, "LIMIT"); + + sql_print_warning(ER_THD(thd, WARN_VERS_PART_FULL), + table->s->db.str, table->s->table_name.str, + vers_info->hist_part->partition_name, "LIMIT"); + } +} + + /* Check that the partition/subpartition is setup to use the correct storage engine diff --git a/sql/partition_info.h b/sql/partition_info.h index a3e36a64ffa..93247b939e4 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -407,6 +407,12 @@ public: bool auto_part, const char *table_name); bool vers_set_limit(ulonglong limit, bool auto_part, const char *table_name); bool vers_set_hist_part(THD* thd, uint *create_count); + bool vers_require_hist_part(THD *thd) const + { + return part_type == VERSIONING_PARTITION && + thd->lex->vers_history_generating(); + } + void vers_check_limit(THD *thd); bool vers_fix_field_list(THD *thd); void vers_update_el_ids(); partition_element *get_partition(uint part_id) diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index eb9c0758d02..516c9da31d9 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -3677,9 +3677,9 @@ int Id_delegating_gtid_event_filter<T>::set_id_restrictions( { DBUG_ASSERT(map_element->filter->get_filter_type() == (mode == - Gtid_event_filter::id_restriction_mode::WHITELIST_MODE) - ? Gtid_event_filter::ACCEPT_ALL_GTID_FILTER_TYPE - : Gtid_event_filter::REJECT_ALL_GTID_FILTER_TYPE); + Gtid_event_filter::id_restriction_mode::WHITELIST_MODE + ? Gtid_event_filter::ACCEPT_ALL_GTID_FILTER_TYPE + : Gtid_event_filter::REJECT_ALL_GTID_FILTER_TYPE)); } } diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index 8bbb87c0e81..925e271e68a 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -26,6 +26,7 @@ extern const LEX_CSTRING rpl_gtid_slave_state_table_name; class String; +#define PARAM_GTID(G) G.domain_id, G.server_id, G.seq_no #define GTID_MAX_STR_LENGTH (10+1+10+1+20) #define PARAM_GTID(G) G.domain_id, G.server_id, G.seq_no diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index cfe29824328..0e72ff441c4 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -463,6 +463,37 @@ void Repl_semi_sync_master::cleanup() delete m_active_tranxs; } +int Repl_semi_sync_master::sync_get_master_wait_sessions() +{ + int wait_sessions; + lock(); + wait_sessions= rpl_semi_sync_master_wait_sessions; + unlock(); + return wait_sessions; +} + +void Repl_semi_sync_master::create_timeout(struct timespec *out, + struct timespec *start_arg) +{ + struct timespec *start_ts; + struct timespec now_ts; + if (!start_arg) + { + set_timespec(now_ts, 0); + start_ts= &now_ts; + } + else + { + start_ts= start_arg; + } + + long diff_secs= (long) (m_wait_timeout / TIME_THOUSAND); + long diff_nsecs= (long) ((m_wait_timeout % TIME_THOUSAND) * TIME_MILLION); + long nsecs= start_ts->tv_nsec + diff_nsecs; + out->tv_sec= start_ts->tv_sec + diff_secs + nsecs / TIME_BILLION; + out->tv_nsec= nsecs % TIME_BILLION; +} + void Repl_semi_sync_master::lock() { mysql_mutex_lock(&LOCK_binlog); @@ -862,13 +893,6 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, m_wait_file_name, (ulong)m_wait_file_pos)); } - /* Calcuate the waiting period. */ - long diff_secs = (long) (m_wait_timeout / TIME_THOUSAND); - long diff_nsecs = (long) ((m_wait_timeout % TIME_THOUSAND) * TIME_MILLION); - long nsecs = start_ts.tv_nsec + diff_nsecs; - abstime.tv_sec = start_ts.tv_sec + diff_secs + nsecs/TIME_BILLION; - abstime.tv_nsec = nsecs % TIME_BILLION; - /* In semi-synchronous replication, we wait until the binlog-dump * thread has received the reply on the relevant binlog segment from the * replication slave. @@ -879,12 +903,20 @@ int Repl_semi_sync_master::commit_trx(const char* trx_wait_binlog_name, */ rpl_semi_sync_master_wait_sessions++; + /* We keep track of when this thread is awaiting an ack to ensure it is + * not killed while awaiting an ACK if a shutdown is issued. + */ + set_thd_awaiting_semisync_ack(thd, TRUE); + DBUG_PRINT("semisync", ("%s: wait %lu ms for binlog sent (%s, %lu)", "Repl_semi_sync_master::commit_trx", m_wait_timeout, m_wait_file_name, (ulong)m_wait_file_pos)); + create_timeout(&abstime, &start_ts); wait_result = cond_timewait(&abstime); + + set_thd_awaiting_semisync_ack(thd, FALSE); rpl_semi_sync_master_wait_sessions--; if (wait_result != 0) @@ -1320,6 +1352,25 @@ void Repl_semi_sync_master::set_export_stats() unlock(); } +void Repl_semi_sync_master::await_slave_reply() +{ + struct timespec abstime; + + DBUG_ENTER("Repl_semi_sync_master::::await_slave_reply"); + lock(); + + /* Just return if there is nothing to wait for */ + if (!rpl_semi_sync_master_wait_sessions) + goto end; + + create_timeout(&abstime, NULL); + cond_timewait(&abstime); + +end: + unlock(); + DBUG_VOID_RETURN; +} + /* Get the waiting time given the wait's staring time. * * Return: diff --git a/sql/semisync_master.h b/sql/semisync_master.h index 9f0acf57a60..04fc0e5ce50 100644 --- a/sql/semisync_master.h +++ b/sql/semisync_master.h @@ -472,6 +472,21 @@ class Repl_semi_sync_master m_wait_timeout = wait_timeout; } + int sync_get_master_wait_sessions(); + + /* + Calculates a timeout that is m_wait_timeout after start_arg and saves it + in out. If start_arg is NULL, the timeout is m_wait_timeout after the + current system time. + */ + void create_timeout(struct timespec *out, struct timespec *start_arg); + + /* + Blocks the calling thread until the ack_receiver either receives an ACK + or times out (from rpl_semi_sync_master_timeout) + */ + void await_slave_reply(); + /*set the ACK point, after binlog sync or after transaction commit*/ void set_wait_point(unsigned long ack_point) { @@ -620,6 +635,30 @@ class Repl_semi_sync_master void check_and_switch(); + /* + Determines if the given thread is currently awaiting a semisync_ack. Note + that the thread's value is protected by this class's LOCK_binlog, so this + function (indirectly) provides safe access. + */ + my_bool is_thd_awaiting_semisync_ack(THD *thd) + { + lock(); + my_bool ret= thd->is_awaiting_semisync_ack; + unlock(); + return ret; + } + + /* + Update the thread's value for is_awaiting_semisync_ack. LOCK_binlog (from + this class) should be acquired before calling this function. + */ + void set_thd_awaiting_semisync_ack(THD *thd, + my_bool _is_awaiting_semisync_ack) + { + mysql_mutex_assert_owner(&LOCK_binlog); + thd->is_awaiting_semisync_ack= _is_awaiting_semisync_ack; + } + mysql_mutex_t LOCK_rpl_semi_sync_master_enabled; }; diff --git a/sql/semisync_slave.cc b/sql/semisync_slave.cc index 684199031ee..788aab78911 100644 --- a/sql/semisync_slave.cc +++ b/sql/semisync_slave.cc @@ -114,10 +114,12 @@ int Repl_semi_sync_slave::slave_start(Master_info *mi) int Repl_semi_sync_slave::slave_stop(Master_info *mi) { - if (rpl_semi_sync_slave_status) - rpl_semi_sync_slave_status= 0; if (get_slave_enabled()) kill_connection(mi->mysql); + + if (rpl_semi_sync_slave_status) + rpl_semi_sync_slave_status= 0; + return 0; } @@ -133,6 +135,8 @@ void Repl_semi_sync_slave::kill_connection(MYSQL *mysql) char kill_buffer[30]; MYSQL *kill_mysql = NULL; + size_t kill_buffer_length; + kill_mysql = mysql_init(kill_mysql); mysql_options(kill_mysql, MYSQL_OPT_CONNECT_TIMEOUT, &m_kill_conn_timeout); mysql_options(kill_mysql, MYSQL_OPT_READ_TIMEOUT, &m_kill_conn_timeout); @@ -144,13 +148,35 @@ void Repl_semi_sync_slave::kill_connection(MYSQL *mysql) { sql_print_information("cannot connect to master to kill slave io_thread's " "connection"); - mysql_close(kill_mysql); - return; + goto failed_graceful_kill; } - size_t kill_buffer_length = my_snprintf(kill_buffer, 30, "KILL %lu", - mysql->thread_id); - mysql_real_query(kill_mysql, kill_buffer, (ulong)kill_buffer_length); + + DBUG_EXECUTE_IF("slave_delay_killing_semisync_connection", my_sleep(400000);); + + kill_buffer_length= my_snprintf(kill_buffer, 30, "KILL %lu", + mysql->thread_id); + if (mysql_real_query(kill_mysql, kill_buffer, (ulong)kill_buffer_length)) + { + sql_print_information( + "Failed to gracefully kill our active semi-sync connection with " + "primary. Silently closing the connection."); + goto failed_graceful_kill; + } + +end: mysql_close(kill_mysql); + return; + +failed_graceful_kill: + /* + If we fail to issue `KILL` on the primary to kill the active semi-sync + connection; we need to locally clean up our side of the connection. This + is because mysql_close will send COM_QUIT on the active semi-sync + connection, causing the primary to error. + */ + net_clear(&(mysql->net), 0); + end_server(mysql); + goto end; } int Repl_semi_sync_slave::request_transmit(Master_info *mi) diff --git a/sql/semisync_slave.h b/sql/semisync_slave.h index e7ccd952130..f0b8eceeebf 100644 --- a/sql/semisync_slave.h +++ b/sql/semisync_slave.h @@ -23,6 +23,7 @@ #include "sql_priv.h" #include "rpl_mi.h" #include "mysql.h" +#include <sql_common.h> class Master_info; diff --git a/sql/share/CMakeLists.txt b/sql/share/CMakeLists.txt index 55f39e5e22b..ddb813057ab 100644 --- a/sql/share/CMakeLists.txt +++ b/sql/share/CMakeLists.txt @@ -15,30 +15,32 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA SET (dirs +bulgarian +chinese +czech danish -german -slovak dutch -greek -norwegian -spanish english +estonian +french +german +greek +hindi hungarian -norwegian-ny -swedish italian -polish -ukrainian japanese +korean +norwegian-ny +norwegian +polish portuguese romanian -estonian -korean russian -czech -french serbian -hindi +slovak +spanish +swedish +ukrainian ) SET(files diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 388a3aa74c1..e2cacdae420 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -1,4 +1,4 @@ -languages chinese=chi gbk, czech=cze latin2, danish=dan latin1, dutch=nla latin1, english=eng latin1, estonian=est latin7, french=fre latin1, german=ger latin1, greek=greek greek, hungarian=hun latin2, italian=ita latin1, japanese=jpn ujis, korean=kor euckr, norwegian-ny=norwegian-ny latin1, norwegian=nor latin1, polish=pol latin2, portuguese=por latin1, romanian=rum latin2, russian=rus koi8r, serbian=serbian cp1250, slovak=slo latin2, spanish=spa latin1, swedish=swe latin1, ukrainian=ukr koi8u, bulgarian=bgn cp1251, hindi=hindi utf8mb3; +languages bulgarian=bgn cp1251, chinese=chi gbk, czech=cze latin2, danish=dan latin1, dutch=nla latin1, english=eng latin1, estonian=est latin7, french=fre latin1, german=ger latin1, greek=greek greek, hindi=hindi utf8mb3, hungarian=hun latin2, italian=ita latin1, japanese=jpn ujis, korean=kor euckr, norwegian-ny=norwegian-ny latin1, norwegian=nor latin1, polish=pol latin2, portuguese=por latin1, romanian=rum latin2, russian=rus koi8r, serbian=serbian cp1250, slovak=slo latin2, spanish=spa latin1, swedish=swe latin1, ukrainian=ukr koi8u; default-language eng @@ -6450,10 +6450,21 @@ ER_AMBIGUOUS_FIELD_TERM ger "Das erste Zeichen der Zeichenkette FIELDS TERMINATED ist mehrdeutig; bitte benutzen Sie nicht optionale und nicht leere FIELDS ENCLOSED BY" spa "El primer carácter de la cadena de los FIELDS TERMINATED es ambiguo; por favor, use FIELDS ENCLOSED BY no opcionales y no vacÃos" ER_FOREIGN_SERVER_EXISTS - chi "您æ£åœ¨å°è¯•åˆ›å»ºçš„外æ¥æœåŠ¡å™¨%så·²å˜åœ¨" - eng "The foreign server, %s, you are trying to create already exists" - ger "Der entfernte Server %s, den Sie versuchen zu erzeugen, existiert schon" - spa "El servidor foráneo %s que intenta crear ya existe" + chi "æ— æ³•åˆ›å»ºå¤–éƒ¨æœåŠ¡å™¨'%s'ï¼Œå› ä¸ºå®ƒå·²ç»å˜åœ¨" + eng "Cannot create foreign server '%s' as it already exists" + fin "Vieraata palvelinta '%s' ei voida luoda, koska se on jo olemassa" + fre "Impossible de créer le serveur étranger '%s' car il existe déjà " + ger "Der auswärtige Server '%s' kann nicht erstellt werden, da er bereits vorhanden ist" + greek "Δεν είναι δυνατή η δημιουÏγία ξÎνου διακομιστή '%s' επειδή υπάÏχει ήδη" + ita "Impossibile creare il server esterno '%s' poiché esiste già " + jpn "外部サーãƒãƒ¼ '%s'ã¯æ—¢ã«å˜åœ¨ã™ã‚‹ãŸã‚ã€ä½œæˆã§ãã¾ã›ã‚“" + nla "Kan geen externe server '%s' maken omdat deze al bestaat" + nor "Kan ikke opprette utenlandsk server '%s' fordi den allerede eksisterer" + pol "Nie można utworzyć obcego serwera '%s', ponieważ już istnieje" + por "Não foi possÃvel criar o servidor externo '%s' porque ele já existe" + rus "Ðевозможно Ñоздать Ñторонний Ñервер '%s', так как он уже ÑущеÑтвует" + spa "No se puede crear el servidor externo '%s' porque ya existe" + swe "Det gick inte att skapa främmande server '%s' eftersom den redan finns" ER_FOREIGN_SERVER_DOESNT_EXIST chi "您å°è¯•å¼•ç”¨çš„外部æœåŠ¡å™¨å称ä¸å˜åœ¨ã€‚æ•°æ®æºé”™è¯¯ï¼š%-.64s" eng "The foreign server name you are trying to reference does not exist. Data source error: %-.64s" @@ -8200,12 +8211,12 @@ ER_TABLE_IN_SYSTEM_TABLESPACE spa "Tabla %-.192s en espacio de tablas del sitema" ER_IO_READ_ERROR - chi "IO读å–错误:(%lu,%s)%s" + chi "IO读å–错误:(%lu,%s)%s" eng "IO Read error: (%lu, %s) %s" spa "Error de Lectura de E/S: (%lu, %s) %s" ER_IO_WRITE_ERROR - chi "IO写错错误:(%lu,%s)%s" + chi "IO写错错误:(%lu,%s)%s" eng "IO Write error: (%lu, %s) %s" spa "Error de Escritura de E/S: (%lu, %s) %s" @@ -9300,7 +9311,7 @@ ER_REF_TO_RECURSIVE_WITH_TABLE_IN_DERIVED eng "Reference to recursive WITH table '%s' in materialized derived" spa "Referencia recursiva con WITH tabla '%s' en derivada materializada" ER_NOT_STANDARD_COMPLIANT_RECURSIVE - chi "表'%s'è¿å了递归定义的é™åˆ¶" + chi "表'%s'R_WRONG_WINDOW_SPEC_NAMEè¿å了递归定义的é™åˆ¶" eng "Restrictions imposed on recursive definitions are violated for table '%s'" ER_WRONG_WINDOW_SPEC_NAME chi "没有定义å称'%s'的窗å£è§„范" diff --git a/sql/slave.cc b/sql/slave.cc index f6f243d7f03..19037525422 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3307,9 +3307,9 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full, protocol->store((uint32) mi->master_id); // SQL_Delay // Master_Ssl_Crl - protocol->store_string_or_null(mi->ssl_ca, &my_charset_bin); + protocol->store_string_or_null(mi->ssl_crl, &my_charset_bin); // Master_Ssl_Crlpath - protocol->store_string_or_null(mi->ssl_capath, &my_charset_bin); + protocol->store_string_or_null(mi->ssl_crlpath, &my_charset_bin); // Using_Gtid protocol->store_string_or_null(mi->using_gtid_astext(mi->using_gtid), &my_charset_bin); @@ -3402,7 +3402,7 @@ bool show_all_master_info(THD* thd) String gtid_pos; Master_info **tmp; List<Item> field_list; - DBUG_ENTER("show_master_info"); + DBUG_ENTER("show_all_master_info"); mysql_mutex_assert_owner(&LOCK_active_mi); gtid_pos.length(0); @@ -4991,6 +4991,7 @@ Stopping slave I/O thread due to out-of-memory error from master"); not cause the slave IO thread to stop, and the error messages are already reported. */ + DBUG_EXECUTE_IF("simulate_delay_semisync_slave_reply", my_sleep(800000);); (void)repl_semisync_slave.slave_reply(mi); } @@ -6777,17 +6778,75 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) mi->gtid_event_seen= true; /* - We have successfully queued to relay log everything before this GTID, so + Unless the previous group is malformed, + we have successfully queued to relay log everything before this GTID, so in case of reconnect we can start from after any previous GTID. - (Normally we would have updated gtid_current_pos earlier at the end of - the previous event group, but better leave an extra check here for - safety). + (We must have updated gtid_current_pos earlier at the end of + the previous event group. Unless ...) */ - if (mi->events_queued_since_last_gtid) + if (unlikely(mi->events_queued_since_last_gtid > 0)) { - mi->gtid_current_pos.update(&mi->last_queued_gtid); - mi->events_queued_since_last_gtid= 0; + /* + ...unless the last group has not been completed. An assert below + can be satisfied only with the strict mode that ensures + against "genuine" gtid duplicates. + */ + rpl_gtid *gtid_in_slave_state= + mi->gtid_current_pos.find(mi->last_queued_gtid.domain_id); + + // Slave gtid state must not have updated yet to the last received gtid. + DBUG_ASSERT((mi->using_gtid == Master_info::USE_GTID_NO || + !opt_gtid_strict_mode) || + (!gtid_in_slave_state || + !(*gtid_in_slave_state == mi->last_queued_gtid))); + + DBUG_EXECUTE_IF("slave_discard_xid_for_gtid_0_x_1000", + { + /* Inject an event group that is missing its XID commit event. */ + if ((mi->last_queued_gtid.domain_id == 0 && + mi->last_queued_gtid.seq_no == 1000) || + (mi->last_queued_gtid.domain_id == 1 && + mi->last_queued_gtid.seq_no == 32)) + { + sql_print_warning( + "Unexpected break of being relay-logged GTID %u-%u-%llu " + "event group by the current GTID event %u-%u-%llu", + PARAM_GTID(mi->last_queued_gtid),PARAM_GTID(event_gtid)); + DBUG_SET("-d,slave_discard_xid_for_gtid_0_x_1000"); + goto dbug_gtid_accept; + } + }); + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + sql_print_error("Unexpected break of being relay-logged GTID %u-%u-%llu " + "event group by the current GTID event %u-%u-%llu", + PARAM_GTID(mi->last_queued_gtid),PARAM_GTID(event_gtid)); + goto err; } + else if (unlikely(mi->gtid_reconnect_event_skip_count > 0)) + { + if (mi->gtid_reconnect_event_skip_count == + mi->events_queued_since_last_gtid) + { + DBUG_ASSERT(event_gtid == mi->last_queued_gtid); + + goto default_action; + } + + DBUG_ASSERT(0); + } + // else_likely{... +#ifndef DBUG_OFF +dbug_gtid_accept: + DBUG_EXECUTE_IF("slave_discard_gtid_0_x_1002", + { + if (mi->last_queued_gtid.server_id == 27697 && + mi->last_queued_gtid.seq_no == 1002) + { + DBUG_SET("-d,slave_discard_gtid_0_x_1002"); + goto skip_relay_logging; + } + }); +#endif mi->last_queued_gtid= event_gtid; mi->last_queued_gtid_standalone= (gtid_flag & Gtid_log_event::FL_STANDALONE) != 0; @@ -6797,7 +6856,7 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) ++mi->events_queued_since_last_gtid; inc_pos= event_len; - + // ...} eof else_likely } break; /* @@ -6877,6 +6936,12 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) case XID_EVENT: DBUG_EXECUTE_IF("slave_discard_xid_for_gtid_0_x_1000", { + if (mi->last_queued_gtid.server_id == 27697 && + mi->last_queued_gtid.seq_no == 1000) + { + DBUG_SET("-d,slave_discard_xid_for_gtid_0_x_1000"); + goto skip_relay_logging; + } /* Inject an event group that is missing its XID commit event. */ if (mi->last_queued_gtid.domain_id == 0 && mi->last_queued_gtid.seq_no == 1000) @@ -6923,15 +6988,48 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) } };); - if (mi->using_gtid != Master_info::USE_GTID_NO && mi->gtid_event_seen) + if (mi->using_gtid != Master_info::USE_GTID_NO) { - if (unlikely(mi->gtid_reconnect_event_skip_count)) + if (likely(mi->gtid_event_seen)) { - --mi->gtid_reconnect_event_skip_count; - gtid_skip_enqueue= true; + if (unlikely(mi->gtid_reconnect_event_skip_count)) + { + if (!got_gtid_event && + mi->gtid_reconnect_event_skip_count == + mi->events_queued_since_last_gtid) + goto gtid_not_start; // the 1st re-sent must be gtid + + --mi->gtid_reconnect_event_skip_count; + gtid_skip_enqueue= true; + } + else if (likely(mi->events_queued_since_last_gtid)) + { + DBUG_ASSERT(!got_gtid_event); + + ++mi->events_queued_since_last_gtid; + } + else if (Log_event::is_group_event((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET])) + { + goto gtid_not_start; // no first gtid event in this group + } + } + else if (Log_event::is_group_event((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET])) + { + gtid_not_start: + + DBUG_ASSERT(!got_gtid_event); + + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + sql_print_error("The current group of events starts with " + "a non-GTID %s event; " + "the last seen GTID is %u-%u-%llu", + Log_event::get_type_str((Log_event_type) (uchar) + buf[EVENT_TYPE_OFFSET]), + mi->last_queued_gtid); + goto err; } - else if (mi->events_queued_since_last_gtid) - ++mi->events_queued_since_last_gtid; } if (!is_compress_event) @@ -7129,8 +7227,9 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) mi->using_gtid != Master_info::USE_GTID_NO && mi->events_queued_since_last_gtid > 0 && ( (mi->last_queued_gtid_standalone && - !Log_event::is_part_of_group((Log_event_type)(uchar) - buf[EVENT_TYPE_OFFSET])) || + (LOG_EVENT_IS_QUERY((Log_event_type)(uchar) + buf[EVENT_TYPE_OFFSET]) || + (uchar)buf[EVENT_TYPE_OFFSET] == INCIDENT_EVENT)) || (!mi->last_queued_gtid_standalone && ((uchar)buf[EVENT_TYPE_OFFSET] == XID_EVENT || (uchar)buf[EVENT_TYPE_OFFSET] == XA_PREPARE_LOG_EVENT || @@ -7142,11 +7241,13 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) The whole of the current event group is queued. So in case of reconnect we can start from after the current GTID. */ - if (mi->gtid_reconnect_event_skip_count) + if (gtid_skip_enqueue) { bool first= true; StringBuffer<1024> gtid_text; + DBUG_ASSERT(mi->events_queued_since_last_gtid > 1); + rpl_slave_state_tostring_helper(>id_text, &mi->last_queued_gtid, &first); sql_print_error("Slave IO thread received a terminal event from " @@ -7156,6 +7257,8 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) gtid_text.ptr(), mi->gtid_reconnect_event_skip_count, mi->events_queued_since_last_gtid); + error= ER_SLAVE_RELAY_LOG_WRITE_FAILURE; + goto err; } mi->gtid_current_pos.update(&mi->last_queued_gtid); mi->events_queued_since_last_gtid= 0; diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index b3949a94751..36ad37104bd 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -312,3 +312,12 @@ sp_cache::cleanup() { my_hash_free(&m_hashtable); } + + +void Sp_caches::sp_caches_clear() +{ + sp_cache_clear(&sp_proc_cache); + sp_cache_clear(&sp_func_cache); + sp_cache_clear(&sp_package_spec_cache); + sp_cache_clear(&sp_package_body_cache); +} diff --git a/sql/sp_head.cc b/sql/sp_head.cc index fab72fd0c6f..bdd94fd6d0e 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -830,7 +830,7 @@ void sp_head::set_stmt_end(THD *thd) { Lex_input_stream *lip= & thd->m_parser_state->m_lip; /* shortcut */ - const char *end_ptr= lip->get_cpp_ptr(); /* shortcut */ + const char *end_ptr= lip->get_cpp_tok_start(); /* shortcut */ /* Make the string of parameters. */ diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 86c6e9a27f8..1d5875733ac 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -411,7 +411,7 @@ bool Sql_cmd_alter_table::execute(THD *thd) referenced from this structure will be modified. @todo move these into constructor... */ - HA_CREATE_INFO create_info(lex->create_info); + Table_specification_st create_info(lex->create_info); Alter_info alter_info(lex->alter_info, thd->mem_root); create_info.alter_info= &alter_info; privilege_t priv(NO_ACL); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 50371b3e722..18ffdc9e174 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -819,7 +819,14 @@ int close_thread_tables(THD *thd) table->s->table_name.str, (ulong) table->query_id)); if (thd->locked_tables_mode) + { +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (table->part_info && table->part_info->vers_require_hist_part(thd) && + !thd->stmt_arena->is_stmt_prepare()) + table->part_info->vers_check_limit(thd); +#endif table->vcol_cleanup_expr(thd); + } /* Detach MERGE children after every statement. Even under LOCK TABLES. */ if (thd->locked_tables_mode <= LTM_LOCK_TABLES || @@ -8664,9 +8671,11 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, thd->lex->which_check_option_applicable(); bool save_is_item_list_lookup= select_lex->is_item_list_lookup; TABLE_LIST *derived= select_lex->master_unit()->derived; + bool save_resolve_in_select_list= select_lex->context.resolve_in_select_list; DBUG_ENTER("setup_conds"); select_lex->is_item_list_lookup= 0; + select_lex->context.resolve_in_select_list= false; thd->column_usage= MARK_COLUMNS_READ; DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage)); @@ -8719,7 +8728,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, List<TABLE_LIST> &leaves, select_lex->where= *conds; } thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; - DBUG_RETURN(MY_TEST(thd->is_error())); + select_lex->context.resolve_in_select_list= save_resolve_in_select_list; + DBUG_RETURN(thd->is_error()); err_no_arena: select_lex->is_item_list_lookup= save_is_item_list_lookup; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f902f12481e..a0ba1d7e5a3 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2021, MariaDB Corporation. + Copyright (c) 2008, 2022, 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 @@ -56,6 +56,7 @@ #include "sp_rcontext.h" #include "sp_cache.h" #include "sql_show.h" // append_identifier +#include "sql_db.h" // get_default_db_collation #include "transaction.h" #include "sql_select.h" /* declares create_tmp_table() */ #include "debug_sync.h" @@ -679,7 +680,8 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) #ifdef HAVE_REPLICATION , current_linfo(0), - slave_info(0) + slave_info(0), + is_awaiting_semisync_ack(0) #endif #ifdef WITH_WSREP , @@ -861,11 +863,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) get_sequence_last_key, (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC); - sp_proc_cache= NULL; - sp_func_cache= NULL; - sp_package_spec_cache= NULL; - sp_package_body_cache= NULL; - /* For user vars replication*/ if (opt_bin_log) my_init_dynamic_array(key_memory_user_var_entry, &user_var_events, @@ -1439,10 +1436,7 @@ void THD::change_user(void) SEQUENCES_HASH_SIZE, 0, 0, (my_hash_get_key) get_sequence_last_key, (my_hash_free_key) free_sequence_last, HASH_THREAD_SPECIFIC); - sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); - sp_cache_clear(&sp_package_spec_cache); - sp_cache_clear(&sp_package_body_cache); + sp_caches_clear(); opt_trace.delete_traces(); } @@ -1569,10 +1563,7 @@ void THD::cleanup(void) my_hash_free(&user_vars); my_hash_free(&sequences); - sp_cache_clear(&sp_proc_cache); - sp_cache_clear(&sp_func_cache); - sp_cache_clear(&sp_package_spec_cache); - sp_cache_clear(&sp_package_body_cache); + sp_caches_clear(); auto_inc_intervals_forced.empty(); auto_inc_intervals_in_cur_stmt_for_binlog.empty(); @@ -6741,49 +6732,86 @@ int THD::decide_logging_format(TABLE_LIST *tables) DBUG_RETURN(0); } -int THD::decide_logging_format_low(TABLE *table) + +/* + Reconsider logging format in case of INSERT...ON DUPLICATE KEY UPDATE + for tables with more than one unique keys in case of MIXED binlog format. + + Unsafe means that a master could execute the statement differently than + the slave. + This could can happen in the following cases: + - The unique check are done in different order on master or slave + (different engine or different key order). + - There is a conflict on another key than the first and before the + statement is committed, another connection commits a row that conflicts + on an earlier unique key. Example follows: + + Below a and b are unique keys, the table has a row (1,1,0) + connection 1: + INSERT INTO t1 set a=2,b=1,c=0 ON DUPLICATE KEY UPDATE c=1; + connection 2: + INSERT INTO t1 set a=2,b=2,c=0; + + If 2 commits after 1 has been executed but before 1 has committed + (and are thus put before the other in the binary log), one will + get different data on the slave: + (1,1,1),(2,2,1) instead of (1,1,1),(2,2,0) +*/ + +void THD::reconsider_logging_format_for_iodup(TABLE *table) { - DBUG_ENTER("decide_logging_format_low"); - /* - INSERT...ON DUPLICATE KEY UPDATE on a table with more than one unique keys - can be unsafe. - */ - if (wsrep_binlog_format() <= BINLOG_FORMAT_STMT && - !is_current_stmt_binlog_format_row() && - !lex->is_stmt_unsafe() && - lex->duplicates == DUP_UPDATE) + DBUG_ENTER("reconsider_logging_format_for_iodup"); + enum_binlog_format bf= (enum_binlog_format) wsrep_binlog_format(); + + DBUG_ASSERT(lex->duplicates == DUP_UPDATE); + + if (bf <= BINLOG_FORMAT_STMT && + !is_current_stmt_binlog_format_row()) { + KEY *end= table->s->key_info + table->s->keys; uint unique_keys= 0; - uint keys= table->s->keys, i= 0; - Field *field; - for (KEY* keyinfo= table->s->key_info; - i < keys && unique_keys <= 1; i++, keyinfo++) - if (keyinfo->flags & HA_NOSAME && - !(keyinfo->key_part->field->flags & AUTO_INCREMENT_FLAG && - //User given auto inc can be unsafe - !keyinfo->key_part->field->val_int())) + + for (KEY *keyinfo= table->s->key_info; keyinfo < end ; keyinfo++) + { + if (keyinfo->flags & HA_NOSAME) { + /* + We assume that the following cases will guarantee that the + key is unique if a key part is not set: + - The key part is an autoincrement (autogenerated) + - The key part has a default value that is null and it not + a virtual field that will be calculated later. + */ for (uint j= 0; j < keyinfo->user_defined_key_parts; j++) { - field= keyinfo->key_part[j].field; - if(!bitmap_is_set(table->write_set,field->field_index)) - goto exit; + Field *field= keyinfo->key_part[j].field; + if (!bitmap_is_set(table->write_set, field->field_index)) + { + /* Check auto_increment */ + if (field == table->next_number_field) + goto exit; + if (field->is_real_null() && !field->default_value) + goto exit; + } } - unique_keys++; + if (unique_keys++) + break; exit:; } - + } if (unique_keys > 1) { - lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS); - binlog_unsafe_warning_flags|= lex->get_stmt_unsafe_flags(); + if (bf == BINLOG_FORMAT_STMT && !lex->is_stmt_unsafe()) + { + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS); + binlog_unsafe_warning_flags|= lex->get_stmt_unsafe_flags(); + } set_current_stmt_binlog_format_row_if_mixed(); if (is_current_stmt_binlog_format_row()) binlog_prepare_for_row_logging(); - DBUG_RETURN(1); } } - DBUG_RETURN(0); + DBUG_VOID_RETURN; } #ifndef MYSQL_CLIENT @@ -8269,3 +8297,27 @@ THD_list_iterator *THD_list_iterator::iterator() { return &server_threads; } + + +Charset_collation_context +THD::charset_collation_context_alter_db(const char *db) +{ + return Charset_collation_context(variables.collation_server, + get_default_db_collation(this, db)); +} + + +Charset_collation_context +THD::charset_collation_context_create_table_in_db(const char *db) +{ + CHARSET_INFO *cs= get_default_db_collation(this, db); + return Charset_collation_context(cs, cs); +} + + +Charset_collation_context +THD::charset_collation_context_alter_table(const TABLE_SHARE *s) +{ + return Charset_collation_context(get_default_db_collation(this, s->db.str), + s->table_charset); +} diff --git a/sql/sql_class.h b/sql/sql_class.h index 47d4f9fee6a..806f77c1ba2 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, 2021, MariaDB Corporation. + Copyright (c) 2009, 2022, 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 @@ -1185,7 +1185,7 @@ public: /* We build without RTTI, so dynamic_cast can't be used. */ enum Type { - STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE, TABLE_ARENA + STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE }; Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg) : @@ -2367,6 +2367,39 @@ struct wait_for_commit void reinit(); }; + +class Sp_caches +{ +public: + sp_cache *sp_proc_cache; + sp_cache *sp_func_cache; + sp_cache *sp_package_spec_cache; + sp_cache *sp_package_body_cache; + Sp_caches() + :sp_proc_cache(NULL), + sp_func_cache(NULL), + sp_package_spec_cache(NULL), + sp_package_body_cache(NULL) + { } + ~Sp_caches() + { + // All caches must be freed by the caller explicitly + DBUG_ASSERT(sp_proc_cache == NULL); + DBUG_ASSERT(sp_func_cache == NULL); + DBUG_ASSERT(sp_package_spec_cache == NULL); + DBUG_ASSERT(sp_package_body_cache == NULL); + } + void sp_caches_swap(Sp_caches &rhs) + { + swap_variables(sp_cache*, sp_proc_cache, rhs.sp_proc_cache); + swap_variables(sp_cache*, sp_func_cache, rhs.sp_func_cache); + swap_variables(sp_cache*, sp_package_spec_cache, rhs.sp_package_spec_cache); + swap_variables(sp_cache*, sp_package_body_cache, rhs.sp_package_body_cache); + } + void sp_caches_clear(); +}; + + extern "C" void my_message_sql(uint error, const char *str, myf MyFlags); @@ -2562,7 +2595,8 @@ class THD: public THD_count, /* this must be first */ */ public Item_change_list, public MDL_context_owner, - public Open_tables_state + public Open_tables_state, + public Sp_caches { private: inline bool is_stmt_prepare() const @@ -3606,10 +3640,6 @@ public: enum_sql_command last_sql_command; // Last sql_command exceuted in mysql_execute_command() sp_rcontext *spcont; // SP runtime context - sp_cache *sp_proc_cache; - sp_cache *sp_func_cache; - sp_cache *sp_package_spec_cache; - sp_cache *sp_package_body_cache; /** number of name_const() substitutions, see sp_head.cc:subst_spvars() */ uint query_name_consts; @@ -4407,8 +4437,7 @@ public: bool is_item_tree_change_register_required() { - return !stmt_arena->is_conventional() - || stmt_arena->type() == Query_arena::TABLE_ARENA; + return !stmt_arena->is_conventional(); } void change_item_tree(Item **place, Item *new_value) @@ -4998,18 +5027,18 @@ public: mdl_context.release_transactional_locks(this); } int decide_logging_format(TABLE_LIST *tables); + /* - In Some cases when decide_logging_format is called it does not have all - information to decide the logging format. So that cases we call decide_logging_format_2 - at later stages in execution. - One example would be binlog format for IODKU but column with unique key is not inserted. - We don't have inserted columns info when we call decide_logging_format so on later stage we call - decide_logging_format_low + In Some cases when decide_logging_format is called it does not have + all information to decide the logging format. So that cases we call + decide_logging_format_2 at later stages in execution. - @returns 0 if no format is changed - 1 if there is change in binlog format + One example would be binlog format for insert on duplicate key + (IODKU) but column with unique key is not inserted. We do not have + inserted columns info when we call decide_logging_format so on + later stage we call reconsider_logging_format_for_iodup() */ - int decide_logging_format_low(TABLE *table); + void reconsider_logging_format_for_iodup(TABLE *table); enum need_invoker { INVOKER_NONE=0, INVOKER_USER, INVOKER_ROLE}; void binlog_invoker(bool role) { m_binlog_invoker= role ? INVOKER_ROLE : INVOKER_USER; } @@ -5259,6 +5288,14 @@ public: bool is_binlog_dump_thread(); #endif + /* + Indicates if this thread is suspended due to awaiting an ACK from a + replica. True if suspended, false otherwise. + + Note that this variable is protected by Repl_semi_sync_master::LOCK_binlog + */ + bool is_awaiting_semisync_ack; + inline ulong wsrep_binlog_format() const { return WSREP_BINLOG_FORMAT(variables.binlog_format); @@ -5484,6 +5521,19 @@ public: MY_UTF8_IS_UTF8MB3 : 0); } + Charset_collation_context + charset_collation_context_create_db() const + { + return Charset_collation_context(variables.collation_server, + variables.collation_server); + } + Charset_collation_context + charset_collation_context_alter_db(const char *db); + Charset_collation_context + charset_collation_context_create_table_in_db(const char *db); + Charset_collation_context + charset_collation_context_alter_table(const TABLE_SHARE *s); + /** Save current lex to the output parameter and reset it to point to main_lex. This method is called from mysql_client_binlog_statement() @@ -5581,8 +5631,8 @@ my_eof(THD *thd) inline date_conv_mode_t sql_mode_for_dates(THD *thd) { - static_assert((date_conv_mode_t::KNOWN_MODES & - time_round_mode_t::KNOWN_MODES) == 0, + static_assert((ulonglong(date_conv_mode_t::KNOWN_MODES) & + ulonglong(time_round_mode_t::KNOWN_MODES)) == 0, "date_conv_mode_t and time_round_mode_t must use different " "bit values"); static_assert(MODE_NO_ZERO_DATE == date_mode_t::NO_ZERO_DATE && @@ -6103,6 +6153,7 @@ public: m_plock(NULL), exit_done(0), saved_tmp_table_share(0) { + DBUG_ASSERT(create_info->default_table_charset); bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); bzero(&ddl_log_state_rm, sizeof(ddl_log_state_rm)); } diff --git a/sql/sql_db.cc b/sql/sql_db.cc index c5defc1959c..9da1ac5ca77 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -943,6 +943,7 @@ exit: int mysql_create_db(THD *thd, const LEX_CSTRING *db, DDL_options_st options, const Schema_specification_st *create_info) { + DBUG_ASSERT(create_info->default_table_charset); /* As mysql_create_db_internal() may modify Db_create_info structure passed to it, we need to use a copy to make execution prepared statement- safe. @@ -958,6 +959,7 @@ int mysql_create_db(THD *thd, const LEX_CSTRING *db, DDL_options_st options, bool mysql_alter_db(THD *thd, const LEX_CSTRING *db, const Schema_specification_st *create_info) { + DBUG_ASSERT(create_info->default_table_charset); /* As mysql_alter_db_internal() may modify Db_create_info structure passed to it, we need to use a copy to make execution prepared statement- safe. diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 833492d3d9f..7235dc6472d 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -712,8 +712,10 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler, if (!in_prepare) { MY_BITMAP *old_map= dbug_tmp_use_all_columns(table, &table->write_set); - (void) item->save_in_field(key_part->field, 1); + int res= item->save_in_field(key_part->field, 1); dbug_tmp_restore_column_map(&table->write_set, old_map); + if (res) + return 1; } key_len+= key_part->store_length; keypart_map= (keypart_map << 1) | 1; diff --git a/sql/sql_i_s.h b/sql/sql_i_s.h index bed2e886718..a3614d889c9 100644 --- a/sql/sql_i_s.h +++ b/sql/sql_i_s.h @@ -158,10 +158,10 @@ public: }; -class Yesno: public Varchar +class Yes_or_empty: public Varchar { public: - Yesno(): Varchar(3) { } + Yes_or_empty(): Varchar(3) { } }; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e498daca83c..d9d22dbe514 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2022, 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 @@ -995,7 +995,12 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, goto values_loop_end; THD_STAGE_INFO(thd, stage_update); - thd->decide_logging_format_low(table); + + if (duplic == DUP_UPDATE) + { + restore_record(table,s->default_values); // Get empty record + thd->reconsider_logging_format_for_iodup(table); + } fix_rownum_pointers(thd, thd->lex->current_select, &info.accepted_rows); if (returning) fix_rownum_pointers(thd, thd->lex->returning(), &info.accepted_rows); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 18d54bf0d69..5f2f072b348 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -719,7 +719,6 @@ init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex) return TRUE; context->resolve_in_table_list_only(table_list); lex->use_only_table_context= TRUE; - lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VCOL_EXPR; select_lex->cur_pos_in_select_list= UNDEF_POS; table->map= 1; //To ensure correct calculation of const item table_list->table= table; @@ -1212,6 +1211,7 @@ void LEX::start(THD *thd_arg) context_stack.empty(); //empty select_stack select_stack_top= 0; + select_stack_outer_barrier= 0; unit.init_query(); current_select_number= 0; curr_with_clause= 0; @@ -5296,17 +5296,21 @@ void SELECT_LEX::update_used_tables() while ((tl= ti++)) { TABLE_LIST *embedding= tl; - do + if (!is_eliminated_table(join->eliminated_tables, tl)) { - bool maybe_null; - if ((maybe_null= MY_TEST(embedding->outer_join))) + do { - tl->table->maybe_null= maybe_null; - break; + bool maybe_null; + if ((maybe_null= MY_TEST(embedding->outer_join))) + { + tl->table->maybe_null= maybe_null; + break; + } } + while ((embedding= embedding->embedding)); } - while ((embedding= embedding->embedding)); - if (tl->on_expr) + + if (tl->on_expr && !is_eliminated_table(join->eliminated_tables, tl)) { tl->on_expr->update_used_tables(); tl->on_expr->walk(&Item::eval_not_null_tables, 0, NULL); @@ -5333,8 +5337,11 @@ void SELECT_LEX::update_used_tables() if (embedding->on_expr && embedding->nested_join->join_list.head() == tl) { - embedding->on_expr->update_used_tables(); - embedding->on_expr->walk(&Item::eval_not_null_tables, 0, NULL); + if (!is_eliminated_table(join->eliminated_tables, embedding)) + { + embedding->on_expr->update_used_tables(); + embedding->on_expr->walk(&Item::eval_not_null_tables, 0, NULL); + } } tl= embedding; embedding= tl->embedding; @@ -7800,7 +7807,7 @@ bool LEX::maybe_start_compound_statement(THD *thd) if (!make_sp_head(thd, NULL, &sp_handler_procedure, DEFAULT_AGGREGATE)) return true; sphead->set_suid(SP_IS_NOT_SUID); - sphead->set_body_start(thd, thd->m_parser_state->m_lip.get_cpp_ptr()); + sphead->set_body_start(thd, thd->m_parser_state->m_lip.get_cpp_tok_start()); } return false; } @@ -11867,6 +11874,21 @@ bool LEX::sp_create_set_password_instr(THD *thd, } +bool LEX::set_names(const char *pos, + const Lex_exact_charset_opt_extended_collate &cscl, + bool no_lookahead) +{ + if (sp_create_assignment_lex(thd, pos)) + return true; + CHARSET_INFO *ci= cscl.collation().charset_info(); + set_var_collation_client *var; + var= new (thd->mem_root) set_var_collation_client(ci, ci, ci); + return unlikely(var == NULL) || + unlikely(thd->lex->var_list.push_back(var, thd->mem_root)) || + unlikely(sp_create_assignment_instr(thd, no_lookahead)); +} + + bool LEX::map_data_type(const Lex_ident_sys_st &schema_name, Lex_field_type_st *type) const { diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a6e7546d38c..4f2e775a7fc 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -2047,8 +2047,7 @@ public: @retval nonzero if the statement is a row injection */ inline bool is_stmt_row_injection() const { - return binlog_stmt_flags & - (1U << (BINLOG_STMT_UNSAFE_COUNT + BINLOG_STMT_TYPE_ROW_INJECTION)); + return binlog_stmt_flags & (1U << BINLOG_STMT_TYPE_ROW_INJECTION); } /** @@ -2058,8 +2057,7 @@ public: */ inline void set_stmt_row_injection() { DBUG_ENTER("set_stmt_row_injection"); - binlog_stmt_flags|= - (1U << (BINLOG_STMT_UNSAFE_COUNT + BINLOG_STMT_TYPE_ROW_INJECTION)); + binlog_stmt_flags|= (1U << BINLOG_STMT_TYPE_ROW_INJECTION); DBUG_VOID_RETURN; } @@ -2335,7 +2333,7 @@ private: The statement is a row injection (i.e., either a BINLOG statement or a row event executed by the slave SQL thread). */ - BINLOG_STMT_TYPE_ROW_INJECTION = 0, + BINLOG_STMT_TYPE_ROW_INJECTION = BINLOG_STMT_UNSAFE_COUNT, /** The last element of this enumeration type. */ BINLOG_STMT_TYPE_COUNT @@ -2349,8 +2347,8 @@ private: - The low BINLOG_STMT_UNSAFE_COUNT bits indicate the types of unsafeness that the current statement has. - - The next BINLOG_STMT_TYPE_COUNT bits indicate if the statement - is of some special type. + - The next BINLOG_STMT_TYPE_COUNT-BINLOG_STMT_TYPE_COUNT bits indicate if + the statement is of some special type. This must be a member of LEX, not of THD: each stored procedure needs to remember its unsafeness state between calls and each @@ -3309,6 +3307,12 @@ public: List<Name_resolution_context> context_stack; SELECT_LEX *select_stack[MAX_SELECT_NESTING + 1]; uint select_stack_top; + /* + Usually this is set to 0, but for INSERT/REPLACE SELECT it is set to 1. + When parsing such statements the pointer to the most outer select is placed + into the second element of select_stack rather than into the first. + */ + uint select_stack_outer_barrier; SQL_I_List<ORDER> proc_list; SQL_I_List<TABLE_LIST> auxiliary_table_list, save_list; @@ -3752,6 +3756,17 @@ public: bool copy_db_to(LEX_CSTRING *to); + void inc_select_stack_outer_barrier() + { + select_stack_outer_barrier++; + } + + SELECT_LEX *parser_current_outer_select() + { + return select_stack_top - 1 == select_stack_outer_barrier ? + 0 : select_stack[select_stack_top - 2]; + } + Name_resolution_context *current_context() { return context_stack.head(); @@ -3818,6 +3833,9 @@ public: int case_stmt_action_then(); bool setup_select_in_parentheses(); + bool set_names(const char *pos, + const Lex_exact_charset_opt_extended_collate &cs, + bool no_lookahead); bool set_trigger_new_row(const LEX_CSTRING *name, Item *val); bool set_trigger_field(const LEX_CSTRING *name1, const LEX_CSTRING *name2, Item *val); @@ -4390,6 +4408,23 @@ public: bool add_alter_list(LEX_CSTRING par_name, Virtual_column_info *expr, bool par_exists); bool add_alter_list(LEX_CSTRING name, LEX_CSTRING new_name, bool exists); + bool add_alter_list_item_convert_to_charset(CHARSET_INFO *cs) + { + if (create_info.add_table_option_convert_charset(cs)) + return true; + alter_info.flags|= ALTER_CONVERT_TO; + return false; + } + bool + add_alter_list_item_convert_to_charset(CHARSET_INFO *cs, + const Lex_extended_collation_st &cl) + { + if (create_info.add_table_option_convert_charset(cs) || + create_info.add_table_option_convert_collation(cl)) + return true; + alter_info.flags|= ALTER_CONVERT_TO; + return false; + } void set_command(enum_sql_command command, DDL_options_st options) { @@ -4529,6 +4564,29 @@ public: return create_info.vers_info; } + /* The list of history-generating DML commands */ + bool vers_history_generating() const + { + switch (sql_command) + { + case SQLCOM_DELETE: + return !vers_conditions.delete_history; + case SQLCOM_UPDATE: + case SQLCOM_UPDATE_MULTI: + case SQLCOM_DELETE_MULTI: + case SQLCOM_REPLACE: + case SQLCOM_REPLACE_SELECT: + return true; + case SQLCOM_INSERT: + case SQLCOM_INSERT_SELECT: + return duplicates == DUP_UPDATE; + case SQLCOM_LOAD: + return duplicates == DUP_REPLACE; + default: + return false; + } + } + int add_period(Lex_ident name, Lex_ident_sys_st start, Lex_ident_sys_st end) { if (lex_string_cmp(system_charset_info, &start, &end) == 0) diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index df6847f2ba1..3d3728b9e00 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -134,6 +134,7 @@ void start_handle_manager() { pthread_t hThread; int err; + DBUG_EXECUTE_IF("delay_start_handle_manager", my_sleep(1000);); manager_thread_in_use = 1; mysql_cond_init(key_COND_manager, &COND_manager,NULL); mysql_mutex_init(key_LOCK_manager, &LOCK_manager, NULL); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0ac082b1812..0597b086b7b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -43,9 +43,7 @@ // mysql_alter_db, // check_db_dir_existence, // my_dbopt_cleanup -#include "sql_table.h" // mysql_create_like_table, - // mysql_create_table, - // mysql_alter_table, +#include "sql_table.h" // mysql_alter_table, // mysql_backup_table, // mysql_restore_table #include "sql_reload.h" // reload_acl_and_cache @@ -1507,22 +1505,6 @@ static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables) } #ifdef WITH_WSREP -static my_bool wsrep_read_only_option(THD *thd, TABLE_LIST *all_tables) -{ - int opt_readonly_saved = opt_readonly; - privilege_t flag_saved= thd->security_ctx->master_access & PRIV_IGNORE_READ_ONLY; - - opt_readonly = 0; - thd->security_ctx->master_access &= ~PRIV_IGNORE_READ_ONLY; - - my_bool ret = !deny_updates_if_read_only_option(thd, all_tables); - - opt_readonly = opt_readonly_saved; - thd->security_ctx->master_access |= flag_saved; - - return ret; -} - static void wsrep_copy_query(THD *thd) { thd->wsrep_retry_command = thd->get_command(); @@ -4206,7 +4188,7 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) */ { /* Prepare stack copies to be re-execution safe */ - HA_CREATE_INFO create_info; + Table_specification_st create_info; Alter_info alter_info(lex->alter_info, thd->mem_root); if (unlikely(thd->is_fatal_error)) /* out of memory creating alter_info */ @@ -4216,10 +4198,9 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) if (check_one_table_access(thd, INDEX_ACL, all_tables)) goto error; /* purecov: inspected */ - bzero((char*) &create_info, sizeof(create_info)); + create_info.init(); create_info.db_type= 0; create_info.row_type= ROW_TYPE_NOT_USED; - create_info.default_table_charset= thd->variables.collation_database; create_info.alter_info= &alter_info; WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL); @@ -5178,6 +5159,10 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) &lex->name)) break; + if ((res= lex->create_info.resolve_to_charset_collation_context(thd, + thd->charset_collation_context_create_db()))) + break; + WSREP_TO_ISOLATION_BEGIN(lex->name.str, NULL, NULL); res= mysql_create_db(thd, &lex->name, @@ -5239,6 +5224,10 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) if (prepare_db_action(thd, ALTER_ACL, db)) break; + if ((res= lex->create_info.resolve_to_charset_collation_context(thd, + thd->charset_collation_context_alter_db(lex->name.str)))) + break; + WSREP_TO_ISOLATION_BEGIN(db->str, NULL, NULL); res= mysql_alter_db(thd, db, &lex->create_info); @@ -7852,7 +7841,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, { bool is_autocommit= !thd->in_multi_stmt_transaction_mode() && - wsrep_read_only_option(thd, thd->lex->query_tables); + !thd->wsrep_applier; bool retry_autocommit; do { @@ -8890,6 +8879,7 @@ bool st_select_lex::add_window_def(THD *thd, fields_in_window_functions+= win_part_list_ptr->elements + win_order_list_ptr->elements; } + win_def->win_spec_number= window_specs.elements; return (win_def == NULL || window_specs.push_back(win_def)); } @@ -8917,6 +8907,7 @@ bool st_select_lex::add_window_spec(THD *thd, win_order_list_ptr->elements; } thd->lex->win_spec= win_spec; + win_spec->win_spec_number= window_specs.elements; return (win_spec == NULL || window_specs.push_back(win_spec)); } @@ -9060,9 +9051,7 @@ push_new_name_resolution_context(THD *thd, right_op->last_leaf_for_name_resolution(); LEX *lex= thd->lex; on_context->select_lex = lex->current_select; - st_select_lex *curr_select= lex->pop_select(); - st_select_lex *outer_sel= lex->select_stack_head(); - lex->push_select(curr_select); + st_select_lex *outer_sel= lex->parser_current_outer_select(); on_context->outer_context = outer_sel ? &outer_sel->context : 0; return lex->push_context(on_context); } @@ -10488,40 +10477,6 @@ bool parse_sql(THD *thd, Parser_state *parser_state, */ - -/** - Check and merge "CHARACTER SET cs [ COLLATE cl ]" clause - - @param cs character set pointer. - @param cl collation pointer. - - Check if collation "cl" is applicable to character set "cs". - - If "cl" is NULL (e.g. when COLLATE clause is not specified), - then simply "cs" is returned. - - @return Error status. - @retval NULL, if "cl" is not applicable to "cs". - @retval pointer to merged CHARSET_INFO on success. -*/ - - -CHARSET_INFO* -merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl) -{ - if (cl) - { - if (!my_charset_same(cs, cl)) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), cl->coll_name.str, - cs->cs_name.str); - return NULL; - } - return cl; - } - return cs; -} - void LEX::mark_first_table_as_inserting() { TABLE_LIST *t= first_select_lex()->table_list.first; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 9e1ec6fabbc..d3cf83b6e08 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -78,7 +78,6 @@ bool check_string_char_length(const LEX_CSTRING *str, uint err_msg, size_t max_char_length, CHARSET_INFO *cs, bool no_error); bool check_ident_length(const LEX_CSTRING *ident); -CHARSET_INFO* merge_charset_and_collation(CHARSET_INFO *cs, CHARSET_INFO *cl); bool check_host_name(LEX_CSTRING *str); bool check_identifier_name(LEX_CSTRING *str, uint max_char_length, uint err_code, const char *param_for_err_msg); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index d2cdbdaf122..f42b9955b90 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5984,11 +5984,12 @@ the generated partition syntax in a correct manner. tab_part_info != part_info && part_info->part_type == VERSIONING_PARTITION && part_info->num_parts == 0) { - if (part_info->vers_info->interval.is_set() && + if (part_info->vers_info->interval.is_set() && ( + !tab_part_info->vers_info->interval.is_set() || /* TODO: equivalent intervals like 1 hour and 60 mins should be considered equal */ memcmp(&part_info->vers_info->interval, &tab_part_info->vers_info->interval, - sizeof(Vers_part_info::interval))) + sizeof(Vers_part_info::interval)))) { /* If interval is changed we can not do fast alter */ tab_part_info= tab_part_info->get_clone(thd); diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index fb1ae0d5fc7..4edd6e7f9a0 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -195,7 +195,8 @@ static bool check_exchange_partition(TABLE *table, TABLE *part_table) bool compare_table_with_partition(THD *thd, TABLE *table, TABLE *part_table, partition_element *part_elem, uint part_id) { - HA_CREATE_INFO table_create_info, part_create_info; + HA_CREATE_INFO table_create_info; + Table_specification_st part_create_info; Alter_info part_alter_info; Alter_table_ctx part_alter_ctx; // Not used DBUG_ENTER("compare_table_with_partition"); @@ -258,8 +259,13 @@ bool compare_table_with_partition(THD *thd, TABLE *table, TABLE *part_table, my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0)); DBUG_RETURN(TRUE); } - DBUG_ASSERT(table->s->db_create_options == - part_table->s->db_create_options); + + if (table->s->db_create_options != part_table->s->db_create_options) + { + my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0)); + DBUG_RETURN(TRUE); + } + DBUG_ASSERT(table->s->db_options_in_use == part_table->s->db_options_in_use); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2e647712e64..66781caac3e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -374,7 +374,8 @@ bool check_valid_path(const char *path, size_t len) static void fix_dl_name(MEM_ROOT *root, LEX_CSTRING *dl) { const size_t so_ext_len= sizeof(SO_EXT) - 1; - if (my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len, + if (dl->length < so_ext_len || + my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len, SO_EXT)) { char *s= (char*)alloc_root(root, dl->length + so_ext_len + 1); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 766cb28dfd1..019adceacc5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -111,12 +111,19 @@ static void optimize_straight_join(JOIN *join, table_map join_tables); static bool greedy_search(JOIN *join, table_map remaining_tables, uint depth, uint prune_level, uint use_cond_selectivity); -static bool best_extension_by_limited_search(JOIN *join, - table_map remaining_tables, - uint idx, double record_count, - double read_time, uint depth, - uint prune_level, - uint use_cond_selectivity); +enum enum_best_search { + SEARCH_ABORT= -2, + SEARCH_ERROR= -1, + SEARCH_OK= 0, + SEARCH_FOUND_EDGE=1 +}; +static enum_best_search +best_extension_by_limited_search(JOIN *join, + table_map remaining_tables, + uint idx, double record_count, + double read_time, uint depth, + uint prune_level, + uint use_cond_selectivity); static uint determine_search_depth(JOIN* join); C_MODE_START static int join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2); @@ -409,6 +416,7 @@ POSITION::POSITION() range_rowid_filter_info= 0; ref_depend_map= dups_producing_tables= 0; inner_tables_handled_with_other_sjs= 0; + type= JT_UNKNOWN; dups_weedout_picker.set_empty(); firstmatch_picker.set_empty(); loosescan_picker.set_empty(); @@ -8468,6 +8476,7 @@ best_access_path(JOIN *join, pos->records_read= records; pos->read_time= best; pos->key= best_key; + pos->type= best_type; pos->table= s; pos->ref_depend_map= best_ref_depends_map; pos->loosescan_picker.loosescan_key= MAX_KEY; @@ -9123,9 +9132,12 @@ greedy_search(JOIN *join, do { /* Find the extension of the current QEP with the lowest cost */ join->best_read= DBL_MAX; - if (best_extension_by_limited_search(join, remaining_tables, idx, record_count, - read_time, search_depth, prune_level, - use_cond_selectivity)) + if ((int) best_extension_by_limited_search(join, remaining_tables, idx, + record_count, + read_time, search_depth, + prune_level, + use_cond_selectivity) < + (int) SEARCH_OK) DBUG_RETURN(TRUE); /* 'best_read < DBL_MAX' means that optimizer managed to find @@ -9761,6 +9773,28 @@ exit: } +/* + Check if the table is an EQ_REF or similar table and there is no cost + to gain by moveing it to a later stage. + We call such a table a edge table (or hanging leaf) as it will read at + most one row and will not add to the number of row combinations in the join. +*/ + +static inline enum_best_search +check_if_edge_table(POSITION *pos, + double pushdown_cond_selectivity) +{ + + if ((pos->type == JT_EQ_REF || + (pos->type == JT_REF && + pos->records_read == 1 && + !pos->range_rowid_filter_info)) && + pushdown_cond_selectivity >= 0.999) + return SEARCH_FOUND_EDGE; + return SEARCH_OK; +} + + /** Find a good, possibly optimal, query execution plan (QEP) by a possibly exhaustive search. @@ -9875,12 +9909,17 @@ exit: pushed to a table should be taken into account @retval - FALSE ok + enum_best_search::SEARCH_OK All fine @retval - TRUE Fatal error + enum_best_search::SEARCH_FOUND_EDGE All remaning tables are edge tables + @retval + enum_best_search::SEARCH_ABORT Killed by user + @retval + enum_best_search::SEARCH_ERROR Fatal error */ -static bool + +static enum_best_search best_extension_by_limited_search(JOIN *join, table_map remaining_tables, uint idx, @@ -9890,9 +9929,17 @@ best_extension_by_limited_search(JOIN *join, uint prune_level, uint use_cond_selectivity) { - DBUG_ENTER("best_extension_by_limited_search"); - THD *thd= join->thd; + /* + 'join' is a partial plan with lower cost than the best plan so far, + so continue expanding it further with the tables in 'remaining_tables'. + */ + JOIN_TAB *s; + double best_record_count= DBL_MAX; + double best_read_time= DBL_MAX; + bool disable_jbuf= join->thd->variables.join_cache_level == 0; + enum_best_search best_res; + DBUG_ENTER("best_extension_by_limited_search"); DBUG_EXECUTE_IF("show_explain_probe_best_ext_lim_search", if (dbug_user_var_equals_int(thd, @@ -9902,19 +9949,7 @@ best_extension_by_limited_search(JOIN *join, ); if (unlikely(thd->check_killed())) // Abort - DBUG_RETURN(TRUE); - - DBUG_EXECUTE("opt", print_plan(join, idx, read_time, record_count, idx, - "SOFAR:");); - - /* - 'join' is a partial plan with lower cost than the best plan so far, - so continue expanding it further with the tables in 'remaining_tables'. - */ - JOIN_TAB *s; - double best_record_count= DBL_MAX; - double best_read_time= DBL_MAX; - bool disable_jbuf= join->thd->variables.join_cache_level == 0; + DBUG_RETURN(SEARCH_ABORT); DBUG_EXECUTE("opt", print_plan(join, idx, record_count, read_time, read_time, "part_plan");); @@ -9930,15 +9965,18 @@ best_extension_by_limited_search(JOIN *join, for (JOIN_TAB **pos= join->best_ref + idx ; (s= *pos) ; pos++) { table_map real_table_bit= s->table->map; - if ((remaining_tables & real_table_bit) && - (allowed_tables & real_table_bit) && + DBUG_ASSERT(remaining_tables & real_table_bit); + + if ((allowed_tables & real_table_bit) && !(remaining_tables & s->dependent) && - (!idx || !check_interleaving_with_nj(s))) + !check_interleaving_with_nj(s)) { double current_record_count, current_read_time; + double partial_join_cardinality; POSITION *position= join->positions + idx; - + POSITION loose_scan_pos; Json_writer_object trace_one_table(thd); + if (unlikely(thd->trace_started())) { trace_plan_prefix(join, idx, remaining_tables); @@ -9946,7 +9984,6 @@ best_extension_by_limited_search(JOIN *join, } /* Find the best access method from 's' to the current partial plan */ - POSITION loose_scan_pos; best_access_path(join, s, remaining_tables, join->positions, idx, disable_jbuf, record_count, position, &loose_scan_pos); @@ -10021,32 +10058,51 @@ best_extension_by_limited_search(JOIN *join, double pushdown_cond_selectivity= 1.0; if (use_cond_selectivity > 1) pushdown_cond_selectivity= table_cond_selectivity(join, idx, s, - remaining_tables & + remaining_tables & ~real_table_bit); join->positions[idx].cond_selectivity= pushdown_cond_selectivity; - if (unlikely(thd->trace_started()) && pushdown_cond_selectivity < 1.0) - trace_one_table.add("selectivity", pushdown_cond_selectivity); + partial_join_cardinality= (current_record_count * + pushdown_cond_selectivity); - double partial_join_cardinality= current_record_count * - pushdown_cond_selectivity; - if ( (search_depth > 1) && (remaining_tables & ~real_table_bit) & allowed_tables ) - { /* Recursively expand the current partial plan */ + if (unlikely(thd->trace_started())) + { + if (pushdown_cond_selectivity < 1.0) + { + trace_one_table.add("selectivity", pushdown_cond_selectivity); + trace_one_table.add("estimated_join_cardinality", + partial_join_cardinality); + } + } + + if ((search_depth > 1) && (remaining_tables & ~real_table_bit) & + allowed_tables) + { + /* Recursively expand the current partial plan */ swap_variables(JOIN_TAB*, join->best_ref[idx], *pos); Json_writer_array trace_rest(thd, "rest_of_plan"); - if (best_extension_by_limited_search(join, - remaining_tables & ~real_table_bit, - idx + 1, - partial_join_cardinality, - current_read_time, - search_depth - 1, - prune_level, - use_cond_selectivity)) - DBUG_RETURN(TRUE); + best_res= + best_extension_by_limited_search(join, + remaining_tables & + ~real_table_bit, + idx + 1, + partial_join_cardinality, + current_read_time, + search_depth - 1, + prune_level, + use_cond_selectivity); + if ((int) best_res < (int) SEARCH_OK) + DBUG_RETURN(best_res); // Abort swap_variables(JOIN_TAB*, join->best_ref[idx], *pos); + if (best_res == SEARCH_FOUND_EDGE && + check_if_edge_table(join->positions+ idx, + pushdown_cond_selectivity) != + SEARCH_FOUND_EDGE) + best_res= SEARCH_OK; } else - { /* + { + /* 'join' is either the best partial QEP with 'search_depth' relations, or the best complete QEP so far, whichever is smaller. */ @@ -10055,15 +10111,13 @@ best_extension_by_limited_search(JOIN *join, join->positions[join->const_tables].table->table) { /* - We may have to make a temp table, note that this is only a - heuristic since we cannot know for sure at this point. - Hence it may be wrong. + We may have to make a temp table, note that this is only a + heuristic since we cannot know for sure at this point. + Hence it may be wrong. */ trace_one_table.add("cost_for_sorting", current_record_count); current_read_time= COST_ADD(current_read_time, current_record_count); } - trace_one_table.add("estimated_join_cardinality", - partial_join_cardinality); if (current_read_time < join->best_read) { memcpy((uchar*) join->best_positions, (uchar*) join->positions, @@ -10076,12 +10130,19 @@ best_extension_by_limited_search(JOIN *join, read_time, current_read_time, "full_plan");); + best_res= check_if_edge_table(join->positions + idx, + pushdown_cond_selectivity); } restore_prev_nj_state(s); restore_prev_sj_state(remaining_tables, s, idx); + if (best_res == SEARCH_FOUND_EDGE) + { + trace_one_table.add("pruned_by_hanging_leaf", true); + DBUG_RETURN(best_res); + } } } - DBUG_RETURN(FALSE); + DBUG_RETURN(SEARCH_OK); } @@ -17233,7 +17294,6 @@ static uint reset_nj_counters(JOIN *join, List<TABLE_LIST> *join_list) static bool check_interleaving_with_nj(JOIN_TAB *next_tab) { - TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding; JOIN *join= next_tab->join; if (join->cur_embedding_map & ~next_tab->embedding_map) @@ -17245,6 +17305,7 @@ static bool check_interleaving_with_nj(JOIN_TAB *next_tab) return TRUE; } + TABLE_LIST *next_emb= next_tab->table->pos_in_table_list->embedding; /* Do update counters for "pairs of brackets" that we've left (marked as X,Y,Z in the above picture) @@ -18430,14 +18491,17 @@ Field *Item_default_value::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { - if (field->default_value && (field->flags & BLOB_FLAG)) + if (field->default_value || (field->flags & BLOB_FLAG)) { /* We have to use a copy function when using a blob with default value as the we have to calculate the default value before we can use it. */ get_tmp_field_src(src, param); - return tmp_table_field_from_field_type(root, table); + Field *result= tmp_table_field_from_field_type(root, table); + if (result && param->modify_item()) + result_field= result; + return result; } /* Same code as in Item_field::create_tmp_field_ex, except no default field @@ -18874,6 +18938,7 @@ TABLE *Create_tmp_table::start(THD *thd, table->copy_blobs= 1; table->in_use= thd; table->no_rows_with_nulls= param->force_not_null_cols; + table->expr_arena= thd; table->s= share; init_tmp_table_share(thd, share, "", 0, "(temporary)", tmpname); @@ -25087,8 +25152,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, if (find_order_in_list(thd, ref_pointer_array, tables, order, fields, all_fields, false, true, from_window_spec)) return 1; - if ((*order->item)->with_window_func() && - context_analysis_place != IN_ORDER_BY) + Item * const item= *order->item; + if (item->with_window_func() && context_analysis_place != IN_ORDER_BY) { my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; @@ -25099,20 +25164,18 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, an ORDER BY clause */ - if (for_union && - ((*order->item)->with_sum_func() || - (*order->item)->with_window_func())) + if (for_union && (item->with_sum_func() || item->with_window_func())) { my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number); return 1; } - if (!(*order->item)->with_sum_func()) - continue; - - if (from_window_spec && (*order->item)->type() != Item::SUM_FUNC_ITEM) - (*order->item)->split_sum_func(thd, ref_pointer_array, - all_fields, SPLIT_SUM_SELECT); + if ((from_window_spec && item->with_sum_func() && + item->type() != Item::SUM_FUNC_ITEM) || item->with_window_func()) + { + item->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); + } } return 0; } @@ -26062,15 +26125,17 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, for (uint i= 0; (item= it++); i++) { Field *field; - if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) || - item->with_window_func()) + enum Item::Type item_type= item->type(); + if ((item->with_sum_func() && item_type != Item::SUM_FUNC_ITEM) || + item->with_window_func()) item_field= item; - else if (item->type() == Item::FIELD_ITEM) + else if (item_type == Item::FIELD_ITEM || + item_type == Item::DEFAULT_VALUE_ITEM) { if (!(item_field= item->get_tmp_table_item(thd))) DBUG_RETURN(true); } - else if (item->type() == Item::FUNC_ITEM && + else if (item_type == Item::FUNC_ITEM && ((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC) { field= item->get_tmp_table_field(); @@ -27929,7 +27994,7 @@ static void print_table_array(THD *thd, too) */ -static bool is_eliminated_table(table_map eliminated_tables, TABLE_LIST *tbl) +bool is_eliminated_table(table_map eliminated_tables, TABLE_LIST *tbl) { return eliminated_tables && ((tbl->table && (tbl->table->map & eliminated_tables)) || diff --git a/sql/sql_select.h b/sql/sql_select.h index e6f63b465f6..34d689cf698 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2,7 +2,7 @@ #define SQL_SELECT_INCLUDED /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2020, MariaDB Corporation. + Copyright (c) 2008, 2022, 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 @@ -989,6 +989,8 @@ public: */ enum sj_strategy_enum sj_strategy; + /* Type of join (EQ_REF, REF etc) */ + enum join_type type; /* Valid only after fix_semijoin_strategies_for_picked_join_order() call: if sj_strategy!=SJ_OPT_NONE, this is the number of subsequent tables that @@ -2469,6 +2471,8 @@ int create_sort_index(THD *thd, JOIN *join, JOIN_TAB *tab, Filesort *fsort); JOIN_TAB *first_explain_order_tab(JOIN* join); JOIN_TAB *next_explain_order_tab(JOIN* join, JOIN_TAB* tab); +bool is_eliminated_table(table_map eliminated_tables, TABLE_LIST *tbl); + bool check_simple_equality(THD *thd, const Item::Context &ctx, Item *left_item, Item *right_item, COND_EQUAL *cond_equal); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2134bb04f6e..04bec87ca13 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5193,6 +5193,7 @@ public: int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) { + DBUG_ENTER("get_all_tables"); LEX *lex= thd->lex; TABLE *table= tables->table; TABLE_LIST table_acl_check; @@ -5210,7 +5211,29 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) uint table_open_method= tables->table_open_method; bool can_deadlock; MEM_ROOT tmp_mem_root; - DBUG_ENTER("get_all_tables"); + /* + We're going to open FRM files for tables. + In case of VIEWs that contain stored function calls, + these stored functions will be parsed and put to the SP cache. + + Suppose we have a view containing a stored function call: + CREATE VIEW v1 AS SELECT f1() AS c1; + and now we're running: + SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=f1(); + If a parallel thread invalidates the cache, + e.g. by creating or dropping some stored routine, + the SELECT query will re-parse f1() when processing "v1" + and replace the outdated cached version of f1() to a new one. + But the old version of f1() is referenced from the m_sp member + of the Item_func_sp instances used in the WHERE condition. + We cannot destroy it. To avoid such clashes, let's remember + all old routines into a temporary SP cache collection + and process tables with a new empty temporary SP cache collection. + Then restore to the old SP cache collection at the end. + */ + Sp_caches old_sp_caches; + + old_sp_caches.sp_caches_swap(*thd); bzero(&tmp_mem_root, sizeof(tmp_mem_root)); @@ -5386,6 +5409,13 @@ err: thd->restore_backup_open_tables_state(&open_tables_state_backup); free_root(&tmp_mem_root, 0); + /* + Now restore to the saved SP cache collection + and clear the temporary SP cache collection. + */ + old_sp_caches.sp_caches_swap(*thd); + old_sp_caches.sp_caches_clear(); + DBUG_RETURN(error); } @@ -9093,7 +9123,7 @@ ST_FIELD_INFO columns_fields_info[]= Column("ORDINAL_POSITION", ULonglong(), NOT_NULL, OPEN_FRM_ONLY), Column("COLUMN_DEFAULT", Longtext(MAX_FIELD_VARCHARLENGTH), NULLABLE, "Default",OPEN_FRM_ONLY), - Column("IS_NULLABLE", Yesno(), NOT_NULL, "Null", OPEN_FRM_ONLY), + Column("IS_NULLABLE", Yes_or_empty(), NOT_NULL, "Null", OPEN_FRM_ONLY), Column("DATA_TYPE", Name(), NOT_NULL, OPEN_FRM_ONLY), Column("CHARACTER_MAXIMUM_LENGTH",ULonglong(), NULLABLE, OPEN_FRM_ONLY), Column("CHARACTER_OCTET_LENGTH", ULonglong(), NULLABLE, OPEN_FRM_ONLY), @@ -9130,8 +9160,8 @@ ST_FIELD_INFO collation_fields_info[]= Column("COLLATION_NAME", CSName(), NOT_NULL, "Collation"), Column("CHARACTER_SET_NAME", CSName(), NOT_NULL, "Charset"), Column("ID", SLonglong(MY_INT32_NUM_DECIMAL_DIGITS), NOT_NULL, "Id"), - Column("IS_DEFAULT", Yesno(), NOT_NULL, "Default"), - Column("IS_COMPILED", Yesno(), NOT_NULL, "Compiled"), + Column("IS_DEFAULT", Yes_or_empty(), NOT_NULL, "Default"), + Column("IS_COMPILED", Yes_or_empty(), NOT_NULL, "Compiled"), Column("SORTLEN", SLonglong(3), NOT_NULL, "Sortlen"), CEnd() }; @@ -9139,10 +9169,10 @@ ST_FIELD_INFO collation_fields_info[]= ST_FIELD_INFO applicable_roles_fields_info[]= { - Column("GRANTEE", Userhost(), NOT_NULL), + Column("GRANTEE", Userhost(), NOT_NULL), Column("ROLE_NAME", Varchar(USERNAME_CHAR_LENGTH), NOT_NULL), - Column("IS_GRANTABLE", Yesno(), NOT_NULL), - Column("IS_DEFAULT", Yesno(), NULLABLE), + Column("IS_GRANTABLE", Yes_or_empty(), NOT_NULL), + Column("IS_DEFAULT", Yes_or_empty(), NULLABLE), CEnd() }; @@ -9286,7 +9316,7 @@ ST_FIELD_INFO view_fields_info[]= Column("TABLE_NAME", Name(), NOT_NULL, OPEN_FRM_ONLY), Column("VIEW_DEFINITION", Longtext(65535), NOT_NULL, OPEN_FRM_ONLY), Column("CHECK_OPTION", Varchar(8), NOT_NULL, OPEN_FRM_ONLY), - Column("IS_UPDATABLE", Yesno(), NOT_NULL, OPEN_FULL_TABLE), + Column("IS_UPDATABLE", Yes_or_empty(), NOT_NULL, OPEN_FULL_TABLE), Column("DEFINER", Definer(), NOT_NULL, OPEN_FRM_ONLY), Column("SECURITY_TYPE", Varchar(7), NOT_NULL, OPEN_FRM_ONLY), Column("CHARACTER_SET_CLIENT", CSName(), NOT_NULL, OPEN_FRM_ONLY), @@ -9298,46 +9328,46 @@ ST_FIELD_INFO view_fields_info[]= ST_FIELD_INFO user_privileges_fields_info[]= { - Column("GRANTEE", Userhost(), NOT_NULL), - Column("TABLE_CATALOG", Catalog(), NOT_NULL), - Column("PRIVILEGE_TYPE", Name(), NOT_NULL), - Column("IS_GRANTABLE", Yesno(), NOT_NULL), + Column("GRANTEE", Userhost(), NOT_NULL), + Column("TABLE_CATALOG", Catalog(), NOT_NULL), + Column("PRIVILEGE_TYPE", Name(), NOT_NULL), + Column("IS_GRANTABLE", Yes_or_empty(), NOT_NULL), CEnd() }; ST_FIELD_INFO schema_privileges_fields_info[]= { - Column("GRANTEE", Userhost(), NOT_NULL), - Column("TABLE_CATALOG", Catalog(), NOT_NULL), - Column("TABLE_SCHEMA", Name(), NOT_NULL), - Column("PRIVILEGE_TYPE", Name(), NOT_NULL), - Column("IS_GRANTABLE", Yesno(), NOT_NULL), + Column("GRANTEE", Userhost(), NOT_NULL), + Column("TABLE_CATALOG", Catalog(), NOT_NULL), + Column("TABLE_SCHEMA", Name(), NOT_NULL), + Column("PRIVILEGE_TYPE", Name(), NOT_NULL), + Column("IS_GRANTABLE", Yes_or_empty(), NOT_NULL), CEnd() }; ST_FIELD_INFO table_privileges_fields_info[]= { - Column("GRANTEE", Userhost(), NOT_NULL), - Column("TABLE_CATALOG", Catalog(), NOT_NULL), - Column("TABLE_SCHEMA", Name(), NOT_NULL), - Column("TABLE_NAME", Name(), NOT_NULL), - Column("PRIVILEGE_TYPE", Name(), NOT_NULL), - Column("IS_GRANTABLE", Yesno(), NOT_NULL), + Column("GRANTEE", Userhost(), NOT_NULL), + Column("TABLE_CATALOG", Catalog(), NOT_NULL), + Column("TABLE_SCHEMA", Name(), NOT_NULL), + Column("TABLE_NAME", Name(), NOT_NULL), + Column("PRIVILEGE_TYPE", Name(), NOT_NULL), + Column("IS_GRANTABLE", Yes_or_empty(), NOT_NULL), CEnd() }; ST_FIELD_INFO column_privileges_fields_info[]= { - Column("GRANTEE", Userhost(), NOT_NULL), - Column("TABLE_CATALOG", Catalog(), NOT_NULL), - Column("TABLE_SCHEMA", Name(), NOT_NULL), - Column("TABLE_NAME", Name(), NOT_NULL), - Column("COLUMN_NAME", Name(), NOT_NULL), - Column("PRIVILEGE_TYPE", Name(), NOT_NULL), - Column("IS_GRANTABLE", Yesno(), NOT_NULL), + Column("GRANTEE", Userhost(), NOT_NULL), + Column("TABLE_CATALOG", Catalog(), NOT_NULL), + Column("TABLE_SCHEMA", Name(), NOT_NULL), + Column("TABLE_NAME", Name(), NOT_NULL), + Column("COLUMN_NAME", Name(), NOT_NULL), + Column("PRIVILEGE_TYPE", Name(), NOT_NULL), + Column("IS_GRANTABLE", Yes_or_empty(), NOT_NULL), CEnd() }; @@ -9478,7 +9508,7 @@ ST_FIELD_INFO sysvars_fields_info[]= Column("NUMERIC_MAX_VALUE", Varchar(MY_INT64_NUM_DECIMAL_DIGITS), NULLABLE), Column("NUMERIC_BLOCK_SIZE", Varchar(MY_INT64_NUM_DECIMAL_DIGITS), NULLABLE), Column("ENUM_VALUE_LIST", Longtext(65535), NULLABLE), - Column("READ_ONLY", Yesno(), NOT_NULL), + Column("READ_ONLY", Yes_or_empty(), NOT_NULL), Column("COMMAND_LINE_ARGUMENT",Name(), NULLABLE), Column("GLOBAL_VALUE_PATH", Varchar(2048), NULLABLE), CEnd() diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 43fa10fab3c..449478a7fa4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2202,7 +2202,7 @@ bool check_duplicates_in_interval(const char *set_or_name, bool Column_definition:: prepare_charset_for_string(const Column_derived_attributes *dattr) { - CHARSET_INFO *tmp= lex_charset_collation(). + CHARSET_INFO *tmp= charset_collation_attrs(). resolved_to_character_set(dattr->charset()); if (!tmp) return true; @@ -3875,38 +3875,6 @@ bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len, /* - Set table default charset, if not set - - SYNOPSIS - set_table_default_charset() - create_info Table create information - - DESCRIPTION - If the table character set was not given explicitly, - let's fetch the database default character set and - apply it to the table. -*/ - -static void set_table_default_charset(THD *thd, HA_CREATE_INFO *create_info, - const LEX_CSTRING &db) -{ - /* - If the table character set was not given explicitly, - let's fetch the database default character set and - apply it to the table. - */ - if (!create_info->default_table_charset) - { - Schema_specification_st db_info; - - load_db_opt_by_name(thd, db.str, &db_info); - - create_info->default_table_charset= db_info.default_table_charset; - } -} - - -/* Extend long VARCHAR fields to blob & prepare field if it's a blob SYNOPSIS @@ -4064,14 +4032,14 @@ handler *mysql_create_frm_image(THD *thd, const LEX_CSTRING &db, handler *file; DBUG_ENTER("mysql_create_frm_image"); + DBUG_ASSERT(create_info->default_table_charset); + if (!alter_info->create_list.elements) { my_error(ER_TABLE_MUST_HAVE_COLUMNS, MYF(0)); DBUG_RETURN(NULL); } - set_table_default_charset(thd, create_info, db); - db_options= create_info->table_options_with_row_type(); if (unlikely(!(file= get_new_handler((TABLE_SHARE*) 0, thd->mem_root, @@ -4345,6 +4313,7 @@ err: @retval -1 table existed but IF NOT EXISTS was used */ +static int create_table_impl(THD *thd, DDL_LOG_STATE *ddl_log_state_create, DDL_LOG_STATE *ddl_log_state_rm, @@ -4365,6 +4334,8 @@ int create_table_impl(THD *thd, DBUG_PRINT("enter", ("db: '%s' table: '%s' tmp: %d path: %s", db.str, table_name.str, internal_tmp_table, path.str)); + DBUG_ASSERT(create_info->default_table_charset); + /* Easy check for ddl logging if we are creating a temporary table */ if (create_info->tmp_table()) { @@ -4703,6 +4674,8 @@ int mysql_create_table_no_lock(THD *thd, LEX_CSTRING cpath; LEX_CUSTRING frm= {0,0}; + DBUG_ASSERT(create_info->default_table_charset); + if (create_info->tmp_table()) path_length= build_tmptable_filename(thd, path, sizeof(path)); else @@ -4771,6 +4744,8 @@ int mysql_create_table_no_lock(THD *thd, close of thread tables. */ + +static bool mysql_create_table(THD *thd, TABLE_LIST *create_table, Table_specification_st *create_info, Alter_info *alter_info) @@ -4784,6 +4759,8 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, bool result; DBUG_ENTER("mysql_create_table"); + DBUG_ASSERT(create_info->default_table_charset); + DBUG_ASSERT(create_table == thd->lex->query_tables); bzero(&ddl_log_state_create, sizeof(ddl_log_state_create)); @@ -5222,6 +5199,7 @@ mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, TRUE error */ +static bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, Table_specification_st *create_info) @@ -5296,6 +5274,14 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, local_create_info.db_type= src_table->table->s->db_type(); local_create_info.row_type= src_table->table->s->row_type; local_create_info.alter_info= &local_alter_info; + /* + This statement: + CREATE TABLE t1 LIKE t2 + does not support table charset/collation clauses. + No needs to copy. Assert they are empty. + */ + DBUG_ASSERT(create_info->default_charset_collation.is_empty()); + DBUG_ASSERT(create_info->convert_charset_collation.is_empty()); if (mysql_prepare_alter_table(thd, src_table->table, &local_create_info, &local_alter_info, &local_alter_ctx)) goto err; @@ -7949,12 +7935,14 @@ void append_drop_column(THD *thd, String *str, Field *field) bool mysql_prepare_alter_table(THD *thd, TABLE *table, - HA_CREATE_INFO *create_info, + Table_specification_st *create_info, Alter_info *alter_info, Alter_table_ctx *alter_ctx) { /* New column definitions are added here */ List<Create_field> new_create_list; + /* System-invisible fields must be added last */ + List<Create_field> new_create_tail; /* New key definitions are added here */ List<Key> new_key_list; List<Alter_rename_key> rename_key_list(alter_info->alter_rename_key_list); @@ -8013,8 +8001,11 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, create_info->max_rows= table->s->max_rows; if (!(used_fields & HA_CREATE_USED_AVG_ROW_LENGTH)) create_info->avg_row_length= table->s->avg_row_length; - if (!(used_fields & HA_CREATE_USED_DEFAULT_CHARSET)) - create_info->default_table_charset= table->s->table_charset; + + if (create_info->resolve_to_charset_collation_context(thd, + thd->charset_collation_context_alter_table(table->s))) + DBUG_RETURN(true); + if (!(used_fields & HA_CREATE_USED_AUTO) && table->found_next_number_field) { /* Table has an autoincrement, copy value to new table */ @@ -8181,7 +8172,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, dropped_sys_vers_fields|= field->flags; drop_it.remove(); } - else + else if (field->invisible < INVISIBLE_SYSTEM) { /* This field was not dropped and not changed, add it to the list @@ -8232,6 +8223,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, alter_it.remove(); } } + else + { + DBUG_ASSERT(field->invisible == INVISIBLE_SYSTEM); + def= new (thd->mem_root) Create_field(thd, field, field); + new_create_tail.push_back(def, thd->mem_root); + } } /* @@ -8394,6 +8391,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, alter_it.remove(); } } + + new_create_list.append(&new_create_tail); + if (unlikely(alter_info->alter_list.elements)) { my_error(ER_BAD_FIELD_ERROR, MYF(0), @@ -9763,7 +9763,7 @@ static uint64 get_start_alter_id(THD *thd) bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, - HA_CREATE_INFO *create_info, + Table_specification_st *create_info, TABLE_LIST *table_list, Alter_info *alter_info, uint order_num, ORDER *order, bool ignore, @@ -10356,7 +10356,7 @@ do_continue:; DBUG_RETURN(true); } - set_table_default_charset(thd, create_info, alter_ctx.db); + DBUG_ASSERT(create_info->default_table_charset); if (create_info->check_fields(thd, alter_info, table_list->table_name, table_list->db) || @@ -11776,7 +11776,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) { - HA_CREATE_INFO create_info; + Table_specification_st create_info; Alter_info alter_info; TABLE_LIST *next_table= table_list->next_global; DBUG_ENTER("mysql_recreate_table"); @@ -11788,9 +11788,8 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) /* hide following tables from open_tables() */ table_list->next_global= NULL; - bzero((char*) &create_info, sizeof(create_info)); + create_info.init(); create_info.row_type=ROW_TYPE_NOT_USED; - create_info.default_table_charset=default_charset_info; create_info.alter_info= &alter_info; /* Force alter table to recreate table */ alter_info.flags= (ALTER_CHANGE_COLUMN | ALTER_RECREATE); @@ -12047,6 +12046,11 @@ bool Sql_cmd_create_table_like::execute(THD *thd) const bool used_engine= lex->create_info.used_fields & HA_CREATE_USED_ENGINE; DBUG_ASSERT((m_storage_engine_name.str != NULL) == used_engine); + + if (lex->create_info.resolve_to_charset_collation_context(thd, + thd->charset_collation_context_create_table_in_db(first_table->db.str))) + DBUG_RETURN(true); + if (used_engine) { if (resolve_storage_engine_with_error(thd, &lex->create_info.db_type, @@ -12119,19 +12123,9 @@ bool Sql_cmd_create_table_like::execute(THD *thd) */ if (!(create_info.used_fields & HA_CREATE_USED_ENGINE)) create_info.use_default_db_type(thd); - /* - If we are using SET CHARSET without DEFAULT, add an implicit - DEFAULT to not confuse old users. (This may change). - */ - if ((create_info.used_fields & - (HA_CREATE_USED_DEFAULT_CHARSET | HA_CREATE_USED_CHARSET)) == - HA_CREATE_USED_CHARSET) - { - create_info.used_fields&= ~HA_CREATE_USED_CHARSET; - create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; - create_info.default_table_charset= create_info.alter_table_convert_to_charset; - create_info.alter_table_convert_to_charset= 0; - } + + DBUG_ASSERT(!(create_info.used_fields & HA_CREATE_USED_CHARSET)); + DBUG_ASSERT(create_info.convert_charset_collation.is_empty()); /* If we are a slave, we should add OR REPLACE if we don't have @@ -12357,3 +12351,46 @@ bool Sql_cmd_create_table_like::execute(THD *thd) end_with_restore_list: DBUG_RETURN(res); } + + +bool HA_CREATE_INFO:: + resolve_to_charset_collation_context(THD *thd, + const Lex_table_charset_collation_attrs_st &default_cscl_arg, + const Lex_table_charset_collation_attrs_st &convert_cscl, + const Charset_collation_context &ctx) +{ + /* + If CONVERT TO clauses are specified only (without table default clauses), + then we copy CONVERT TO clauses to default clauses, so e.g: + CONVERT TO CHARACTER SET utf8mb4 + means + CONVERT TO CHARACTER SET utf8mb4, DEFAULT CHARACTER SET utf8mb4 + */ + Lex_table_charset_collation_attrs_st default_cscl= + !convert_cscl.is_empty() && default_cscl_arg.is_empty() ? + convert_cscl : default_cscl_arg; + + if (default_cscl.is_empty()) + default_table_charset= ctx.collate_default().charset_info(); + else + { + // Make sure we don't do double resolution in direct SQL execution + DBUG_ASSERT(!default_table_charset || thd->stmt_arena->is_stmt_execute()); + if (!(default_table_charset= + default_cscl.resolved_to_context(ctx))) + return true; + } + + if (convert_cscl.is_empty()) + alter_table_convert_to_charset= NULL; + else + { + // Make sure we don't do double resolution in direct SQL execution + DBUG_ASSERT(!alter_table_convert_to_charset || + thd->stmt_arena->is_stmt_execute()); + if (!(alter_table_convert_to_charset= + convert_cscl.resolved_to_context(ctx))) + return true; + } + return false; +} diff --git a/sql/sql_table.h b/sql/sql_table.h index e3cfec9ca93..c9e4d969482 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -19,6 +19,7 @@ #include <my_sys.h> // pthread_mutex_t #include "m_string.h" // LEX_CUSTRING +#include "lex_charset.h" #define ERROR_INJECT(code) \ ((DBUG_IF("crash_" code) && (DBUG_SUICIDE(), 0)) || \ @@ -90,9 +91,6 @@ void build_lower_case_table_filename(char *buff, size_t bufflen, const LEX_CSTRING *table, uint flags); uint build_tmptable_filename(THD* thd, char *buff, size_t bufflen); -bool mysql_create_table(THD *thd, TABLE_LIST *create_table, - Table_specification_st *create_info, - Alter_info *alter_info); bool add_keyword_to_query(THD *thd, String *result, const LEX_CSTRING *keyword, const LEX_CSTRING *add); @@ -156,14 +154,14 @@ int mysql_discard_or_import_tablespace(THD *thd, bool discard); bool mysql_prepare_alter_table(THD *thd, TABLE *table, - HA_CREATE_INFO *create_info, + Table_specification_st *create_info, Alter_info *alter_info, Alter_table_ctx *alter_ctx); bool mysql_trans_prepare_alter_copy_data(THD *thd); bool mysql_trans_commit_alter_copy_data(THD *thd); bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, - HA_CREATE_INFO *create_info, + Table_specification_st *create_info, TABLE_LIST *table_list, Alter_info *alter_info, uint order_num, ORDER *order, bool ignore, @@ -173,9 +171,6 @@ bool mysql_compare_tables(TABLE *table, HA_CREATE_INFO *create_info, bool *metadata_equal); bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy); -bool mysql_create_like_table(THD *thd, TABLE_LIST *table, - TABLE_LIST *src_table, - Table_specification_st *create_info); bool mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, const LEX_CSTRING *old_name, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, LEX_CUSTRING *id, diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index be6e120716d..d80342a8395 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -1209,4 +1209,3 @@ bool JOIN::transform_in_predicates_into_in_subq(THD *thd) thd->lex->current_select= save_current_select; DBUG_RETURN(false); } - diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 69ca474eee1..0ede2b3fee2 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -2295,7 +2295,6 @@ Type_handler_decimal_result::make_num_distinct_aggregator_field( const Item *item) const { - DBUG_ASSERT(item->decimals <= DECIMAL_MAX_SCALE); return new (mem_root) Field_new_decimal(NULL, item->max_length, (uchar *) (item->maybe_null() ? "" : 0), @@ -2716,7 +2715,7 @@ Type_handler::Column_definition_set_attributes(THD *thd, column_definition_type_t type) const { - def->set_lex_charset_collation(attr.lex_charset_collation()); + def->set_charset_collation_attrs(attr.charset_collation_attrs()); def->set_length_and_dec(attr); return false; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 82ef47608b9..74ed078e936 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -2130,10 +2130,9 @@ int multi_update::prepare(List<Item> ¬_used_values, if (!tl) DBUG_RETURN(1); update.link_in_list(tl, &tl->next_local); - tl->shared= table_count++; + table_ref->shared= tl->shared= table_count++; table->no_keyread=1; table->covering_keys.clear_all(); - table->pos_in_table_list= tl; table->prepare_triggers_for_update_stmt_or_event(); table->reset_default_fields(); } diff --git a/sql/sql_window.cc b/sql/sql_window.cc index e50a17333e8..c0acecd138f 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2016, 2017 MariaDB + Copyright (c) 2016, 2022 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -424,16 +424,49 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd) #define CMP_GT 2 // Greater then static -int compare_order_elements(ORDER *ord1, ORDER *ord2) +int compare_order_elements(ORDER *ord1, int weight1, + ORDER *ord2, int weight2) { if (*ord1->item == *ord2->item && ord1->direction == ord2->direction) return CMP_EQ; Item *item1= (*ord1->item)->real_item(); Item *item2= (*ord2->item)->real_item(); - DBUG_ASSERT(item1->type() == Item::FIELD_ITEM && - item2->type() == Item::FIELD_ITEM); - int cmp= ((Item_field *) item1)->field->field_index - - ((Item_field *) item2)->field->field_index; + + bool item1_field= (item1->type() == Item::FIELD_ITEM); + bool item2_field= (item2->type() == Item::FIELD_ITEM); + + ptrdiff_t cmp; + if (item1_field && item2_field) + { + DBUG_ASSERT(((Item_field *) item1)->field->table == + ((Item_field *) item2)->field->table); + cmp= ((Item_field *) item1)->field->field_index - + ((Item_field *) item2)->field->field_index; + } + else if (item1_field && !item2_field) + return CMP_LT; + else if (!item1_field && item2_field) + return CMP_LT; + else + { + /* + Ok, item1_field==NULL and item2_field==NULL. + We're not able to compare Item expressions. Order them according to + their passed "weight" (which comes from Window_spec::win_spec_number): + */ + if (weight1 != weight2) + cmp= weight1 - weight2; + else + { + /* + The weight is the same. That is, the elements come from the same + window specification... This shouldn't happen. + */ + DBUG_ASSERT(0); + cmp= item1 - item2; + } + } + if (cmp == 0) { if (ord1->direction == ord2->direction) @@ -446,7 +479,9 @@ int compare_order_elements(ORDER *ord1, ORDER *ord2) static int compare_order_lists(SQL_I_List<ORDER> *part_list1, - SQL_I_List<ORDER> *part_list2) + int spec_number1, + SQL_I_List<ORDER> *part_list2, + int spec_number2) { if (part_list1 == part_list2) return CMP_EQ; @@ -471,7 +506,8 @@ int compare_order_lists(SQL_I_List<ORDER> *part_list1, if (!elem1 || !elem2) break; - if ((cmp= compare_order_elements(elem1, elem2))) + if ((cmp= compare_order_elements(elem1, spec_number1, + elem2, spec_number2))) return cmp; } if (elem1) @@ -566,7 +602,9 @@ int compare_window_spec_joined_lists(Window_spec *win_spec1, win_spec1->join_partition_and_order_lists(); win_spec2->join_partition_and_order_lists(); int cmp= compare_order_lists(win_spec1->partition_list, - win_spec2->partition_list); + win_spec1->win_spec_number, + win_spec2->partition_list, + win_spec2->win_spec_number); win_spec1->disjoin_partition_and_order_lists(); win_spec2->disjoin_partition_and_order_lists(); return cmp; @@ -584,7 +622,9 @@ int compare_window_funcs_by_window_specs(Item_window_func *win_func1, if (win_spec1 == win_spec2) return CMP_EQ; cmp= compare_order_lists(win_spec1->partition_list, - win_spec2->partition_list); + win_spec1->win_spec_number, + win_spec2->partition_list, + win_spec2->win_spec_number); if (cmp == CMP_EQ) { /* @@ -603,7 +643,9 @@ int compare_window_funcs_by_window_specs(Item_window_func *win_func1, } cmp= compare_order_lists(win_spec1->order_list, - win_spec2->order_list); + win_spec1->win_spec_number, + win_spec2->order_list, + win_spec2->win_spec_number); if (cmp != CMP_EQ) return cmp; @@ -696,7 +738,9 @@ void order_window_funcs_by_window_specs(List<Item_window_func> *win_func_list) int cmp; if (win_spec_prev->partition_list == win_spec_curr->partition_list) cmp= compare_order_lists(win_spec_prev->order_list, - win_spec_curr->order_list); + win_spec_prev->win_spec_number, + win_spec_curr->order_list, + win_spec_curr->win_spec_number); else cmp= compare_window_spec_joined_lists(win_spec_prev, win_spec_curr); if (!(CMP_LT_C <= cmp && cmp <= CMP_GT_C)) diff --git a/sql/sql_window.h b/sql/sql_window.h index 5e76a33dcd0..66ea8c7dd4d 100644 --- a/sql/sql_window.h +++ b/sql/sql_window.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2016, 2017 MariaDB + Copyright (c) 2016, 2022 MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -120,10 +120,15 @@ class Window_spec : public Sql_alloc Window_spec *referenced_win_spec; - Window_spec(LEX_CSTRING *win_ref, - SQL_I_List<ORDER> *part_list, - SQL_I_List<ORDER> *ord_list, - Window_frame *win_frame) + /* + Window_spec objects are numbered by the number of their appearance in the + query. This is used by compare_order_elements() to provide a predictable + ordering of PARTITION/ORDER BY clauses. + */ + int win_spec_number; + + Window_spec(LEX_CSTRING *win_ref, SQL_I_List<ORDER> *part_list, + SQL_I_List<ORDER> *ord_list, Window_frame *win_frame) : window_names_are_checked(false), window_ref(win_ref), partition_list(part_list), save_partition_list(NULL), order_list(ord_list), save_order_list(NULL), diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 826c470511f..80d6c12e4e5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -213,7 +213,9 @@ void _CONCAT_UNDERSCORED(turn_parser_debug_on,yyparse)() Lex_length_and_dec_st Lex_length_and_dec; Lex_cast_type_st Lex_cast_type; Lex_field_type_st Lex_field_type; - Lex_charset_collation_st Lex_charset_collation; + Lex_exact_charset_extended_collation_attrs_st + Lex_exact_charset_extended_collation_attrs; + Lex_extended_collation_st Lex_extended_collation; Lex_dyncol_type_st Lex_dyncol_type; Lex_for_loop_st for_loop; Lex_for_loop_bounds_st for_loop_bounds; @@ -343,12 +345,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); */ %ifdef MARIADB -%expect 67 +%expect 71 %else -%expect 69 +%expect 72 %endif - /* Comments for TOKENS. For each token, please include in the same line a comment that contains @@ -376,6 +377,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); */ %token <NONE> ABORT_SYM /* INTERNAL (used in lex) */ %token <NONE> IMPOSSIBLE_ACTION /* To avoid warning for yyerrlab1 */ +%token <NONE> FORCE_LOOKAHEAD /* INTERNAL never returned by the lexer */ %token <NONE> END_OF_INPUT /* INTERNAL */ %token <kwd> COLON_ORACLE_SYM /* INTERNAL */ %token <kwd> PARAM_MARKER /* INTERNAL */ @@ -389,7 +391,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token <NONE> WITH_ROLLUP_SYM /* INTERNAL */ %token <NONE> WITH_SYSTEM_SYM /* INTERNAL */ - /* Identifiers */ @@ -1379,7 +1380,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); field_type_misc json_table_field_type -%type <Lex_charset_collation> +%type <Lex_exact_charset_extended_collation_attrs> binary opt_binary opt_binary_and_compression @@ -1387,6 +1388,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); attribute_list field_def +%type <Lex_extended_collation> + collation_name + collation_name_or_default + %type <Lex_dyncol_type> opt_dyncol_type dyncol_type numeric_dyncol_type temporal_dyncol_type string_dyncol_type @@ -1579,14 +1584,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); text_or_password %type <charset> - opt_collate_or_default charset_name charset_or_alias charset_name_or_default old_or_new_charset_name old_or_new_charset_name_or_default - collation_name - collation_name_or_default opt_load_data_charset UNDERSCORE_CHARSET @@ -2367,9 +2369,9 @@ create: If the table exists, we should either not create it or replace it */ lex->query_tables->open_strategy= TABLE_LIST::OPEN_STUB; - lex->create_info.default_table_charset= NULL; lex->name= null_clex_str; lex->create_last_non_select_table= lex->last_table(); + lex->inc_select_stack_outer_barrier(); } create_body { @@ -2509,9 +2511,7 @@ create: } | create_or_replace DATABASE opt_if_not_exists ident { - Lex->create_info.default_table_charset= NULL; - Lex->create_info.schema_comment= NULL; - Lex->create_info.used_fields= 0; + Lex->create_info.init(); } opt_create_database_options { @@ -2709,6 +2709,9 @@ sequence_def: } ; +/* this rule is used to force look-ahead in the parser */ +force_lookahead: {} | FORCE_LOOKAHEAD {} ; + server_def: SERVER_SYM opt_if_not_exists ident_or_text { @@ -2910,7 +2913,7 @@ ev_sql_stmt: lex->sphead->set_body_start(thd, lip->get_cpp_ptr()); } - sp_proc_stmt + sp_proc_stmt force_lookahead { /* return back to the original memory root ASAP */ if (Lex->sp_body_finalize_event(thd)) @@ -5527,15 +5530,9 @@ default_charset: default_collation: opt_default COLLATE_SYM opt_equal collation_name_or_default { - HA_CREATE_INFO *cinfo= &Lex->create_info; - if (unlikely((cinfo->used_fields & HA_CREATE_USED_DEFAULT_CHARSET) && - cinfo->default_table_charset && $4 && - !($4= merge_charset_and_collation(cinfo->default_table_charset, - $4)))) + Table_specification_st *cinfo= &Lex->create_info; + if (unlikely(cinfo->add_table_option_default_collation($4))) MYSQL_YYABORT; - - Lex->create_info.default_table_charset= $4; - Lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; } ; @@ -5786,10 +5783,10 @@ field_type_or_serial: } field_def { - Lex_charset_collation tmp= $1.lex_charset_collation(); - if (tmp.merge_charset_clause_and_collate_clause($3)) + auto tmp= $1.charset_collation_attrs(); + if (tmp.merge_column_charset_clause_and_collate_clause($3)) MYSQL_YYABORT; - Lex->last_field->set_lex_charset_collation(tmp); + Lex->last_field->set_charset_collation_attrs(tmp); } | SERIAL_SYM { @@ -5827,7 +5824,7 @@ field_def: | attribute_list compressed_deprecated_column_attribute { $$= $1; } | attribute_list compressed_deprecated_column_attribute attribute_list { - if (($$= $1).merge_collate_clause_and_collate_clause($3)) + if (($$= $1).merge_column_collate_clause_and_collate_clause($3)) MYSQL_YYABORT; } | opt_generated_always AS virtual_column_func @@ -6076,7 +6073,7 @@ field_type_string: | nchar opt_field_length opt_bin_mod { $$.set(&type_handler_string, $2, - Lex_charset_collation::national($3)); + Lex_exact_charset_extended_collation_attrs::national($3)); } | BINARY opt_field_length { @@ -6093,7 +6090,7 @@ field_type_string: | nvarchar opt_field_length opt_compressed opt_bin_mod { $$.set(&type_handler_varchar, $2, - Lex_charset_collation::national($4)); + Lex_exact_charset_extended_collation_attrs::national($4)); } | VARBINARY opt_field_length opt_compressed { @@ -6308,7 +6305,7 @@ opt_precision: attribute_list: attribute_list attribute { - if (($$= $1).merge_collate_clause_and_collate_clause($2)) + if (($$= $1).merge_column_collate_clause_and_collate_clause($2)) MYSQL_YYABORT; } | attribute @@ -6335,7 +6332,7 @@ attribute: } | COLLATE_SYM collation_name { - $$.set_collate_exact($2); + $$= Lex_exact_charset_extended_collation_attrs($2); } | serial_attribute { $$.init(); } ; @@ -6475,20 +6472,17 @@ old_or_new_charset_name_or_default: collation_name: ident_or_text { - if (unlikely(!($$= mysqld_collation_get_by_name($1.str, + CHARSET_INFO *cs; + if (unlikely(!(cs= mysqld_collation_get_by_name($1.str, thd->get_utf8_flag())))) MYSQL_YYABORT; + $$= Lex_extended_collation(Lex_exact_collation(cs)); } ; -opt_collate_or_default: - /* empty */ { $$=NULL; } - | COLLATE_SYM collation_name_or_default { $$=$2; } - ; - collation_name_or_default: collation_name { $$=$1; } - | DEFAULT { $$=NULL; } + | DEFAULT { $$.set_collate_default(); } ; opt_default: @@ -6531,11 +6525,18 @@ binary: } | charset_or_alias COLLATE_SYM collation_name { - if ($$.set_charset_collate_exact($1, $3)) + if ($3.merge_exact_charset(Lex_exact_charset($1))) MYSQL_YYABORT; + $$= Lex_exact_charset_extended_collation_attrs($3); + } + | COLLATE_SYM collation_name + { + $$= Lex_exact_charset_extended_collation_attrs($2); + } + | COLLATE_SYM DEFAULT + { + $$.set_collate_default(); } - | COLLATE_SYM collation_name { $$.set_collate_exact($2); } - | COLLATE_SYM DEFAULT { $$.set_collate_default(); } ; opt_bin_mod: @@ -6943,9 +6944,7 @@ alter: } | ALTER DATABASE ident_or_empty { - Lex->create_info.default_table_charset= NULL; - Lex->create_info.schema_comment= NULL; - Lex->create_info.used_fields= 0; + Lex->create_info.init(); if (Lex->main_select_push(true)) MYSQL_YYABORT; } @@ -6961,8 +6960,7 @@ alter: } | ALTER DATABASE COMMENT_SYM opt_equal TEXT_STRING_sys { - Lex->create_info.default_table_charset= NULL; - Lex->create_info.used_fields= 0; + Lex->create_info.init(); Lex->create_info.schema_comment= thd->make_clex_string($5); Lex->create_info.used_fields|= HA_CREATE_USED_COMMENT; } @@ -7606,19 +7604,15 @@ alter_list_item: lex->alter_info.flags|= ALTER_RENAME_INDEX; } | CONVERT_SYM TO_SYM charset charset_name_or_default - opt_collate_or_default { - if (!$4) - { - $4= thd->variables.collation_database; - } - $5= $5 ? $5 : $4; - if (unlikely(!my_charset_same($4,$5))) - my_yyabort_error((ER_COLLATION_CHARSET_MISMATCH, MYF(0), - $5->coll_name.str, $4->cs_name.str)); - if (unlikely(Lex->create_info.add_alter_list_item_convert_to_charset($5))) + if (Lex->add_alter_list_item_convert_to_charset($4)) + MYSQL_YYABORT; + } + | CONVERT_SYM TO_SYM charset charset_name_or_default + COLLATE_SYM collation_name_or_default + { + if (Lex->add_alter_list_item_convert_to_charset($4, $6)) MYSQL_YYABORT; - Lex->alter_info.flags|= ALTER_CONVERT_TO; } | create_table_options_space_separated { @@ -9735,7 +9729,9 @@ string_factor_expr: primary_expr | string_factor_expr COLLATE_SYM collation_name { - if (unlikely(!($$= new (thd->mem_root) Item_func_set_collation(thd, $1, $3)))) + if (unlikely(!($$= new (thd->mem_root) + Item_func_set_collation(thd, $1, + $3.charset_info())))) MYSQL_YYABORT; } ; @@ -11355,7 +11351,7 @@ json_table_column_type: COLUMN_DEFINITION_TABLE_FIELD); if (Lex->json_table->m_cur_json_table_column-> set(thd, Json_table_column::PATH, $3, - $1.lex_charset_collation())) + $1.charset_collation_attrs())) { MYSQL_YYABORT; } @@ -11366,7 +11362,7 @@ json_table_column_type: COLUMN_DEFINITION_TABLE_FIELD); if (Lex->json_table->m_cur_json_table_column-> set(thd, Json_table_column::EXISTS_PATH, $4, - $1.lex_charset_collation())) + $1.charset_collation_attrs())) MYSQL_YYABORT; } ; @@ -12946,6 +12942,7 @@ insert_start: { if (Lex->main_select_push()) MYSQL_YYABORT; mysql_init_select(Lex); + Lex->inc_select_stack_outer_barrier(); Lex->current_select->parsing_place= BEFORE_OPT_LIST; } ; @@ -16576,26 +16573,20 @@ option_value_no_option_type: thd->parse_error(); MYSQL_YYABORT; } - | NAMES_SYM charset_name_or_default opt_collate_or_default + | NAMES_SYM charset_name_or_default { - if (sp_create_assignment_lex(thd, $1.pos())) + CHARSET_INFO *def= global_system_variables.character_set_client; + Lex_exact_charset_opt_extended_collate tmp($2 ? $2 : def, false); + if (Lex->set_names($1.pos(), tmp, yychar == YYEMPTY)) MYSQL_YYABORT; - LEX *lex= Lex; - CHARSET_INFO *cs2; - CHARSET_INFO *cs3; - cs2= $2 ? $2 : global_system_variables.character_set_client; - cs3= $3 ? $3 : cs2; - if (unlikely(!my_charset_same(cs2, cs3))) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - cs3->coll_name.str, cs2->cs_name.str); - MYSQL_YYABORT; - } - set_var_collation_client *var; - var= new (thd->mem_root) set_var_collation_client(cs3, cs3, cs3); - if (unlikely(var == NULL) || - unlikely(lex->var_list.push_back(var, thd->mem_root)) || - unlikely(sp_create_assignment_instr(thd, yychar == YYEMPTY))) + } + | NAMES_SYM charset_name_or_default + COLLATE_SYM collation_name_or_default + { + CHARSET_INFO *def= global_system_variables.character_set_client; + Lex_exact_charset_opt_extended_collate tmp($2 ? $2 : def, false); + if (tmp.merge_collation($4) || + Lex->set_names($1.pos(), tmp, yychar == YYEMPTY)) MYSQL_YYABORT; } | DEFAULT ROLE_SYM grant_role @@ -17776,8 +17767,8 @@ trigger_tail: lex->sphead->set_body_start(thd, lip->get_cpp_tok_start()); } - sp_proc_stmt /* $19 */ - { /* $20 */ + sp_proc_stmt /* $19 */ force_lookahead /* $20 */ + { /* $21 */ LEX *lex= Lex; lex->sql_command= SQLCOM_CREATE_TRIGGER; @@ -17817,7 +17808,6 @@ sf_return_type: } ; - /*************************************************************************/ xa: @@ -18155,7 +18145,7 @@ sf_c_chistics_and_body_standalone: lex->sphead->set_c_chistics(lex->sp_chistics); lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); } - sp_proc_stmt_in_returns_clause + sp_proc_stmt_in_returns_clause force_lookahead { if (unlikely(Lex->sp_body_finalize_function(thd))) MYSQL_YYABORT; @@ -18176,7 +18166,7 @@ sp_tail_standalone: Lex->sphead->set_c_chistics(Lex->sp_chistics); Lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); } - sp_proc_stmt + sp_proc_stmt force_lookahead { if (unlikely(Lex->sp_body_finalize_procedure(thd))) MYSQL_YYABORT; @@ -19027,8 +19017,7 @@ sf_c_chistics_and_body_standalone: lex->sphead->set_c_chistics(lex->sp_chistics); lex->sphead->set_body_start(thd, YYLIP->get_cpp_tok_start()); } - sp_tail_is - sp_body + sp_tail_is sp_body force_lookahead { if (unlikely(Lex->sp_body_finalize_function(thd))) MYSQL_YYABORT; diff --git a/sql/structs.h b/sql/structs.h index eab15c4d92b..52e47d5d7ee 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -699,17 +699,18 @@ public: } void set(const Type_handler *handler, const Lex_length_and_dec_st &length_and_dec, - const Lex_charset_collation_st &coll) + const Lex_column_charset_collation_attrs_st &coll) { m_handler= handler; - m_ci= coll.charset_collation(); + m_ci= coll.charset_info(); Lex_length_and_dec_st::operator=(length_and_dec); m_collation_type= ((uint8) coll.type()) & 0x3; } - void set(const Type_handler *handler, const Lex_charset_collation_st &coll) + void set(const Type_handler *handler, + const Lex_column_charset_collation_attrs_st &coll) { m_handler= handler; - m_ci= coll.charset_collation(); + m_ci= coll.charset_info(); Lex_length_and_dec_st::reset(); m_collation_type= ((uint8) coll.type()) & 0x3; } @@ -734,10 +735,10 @@ public: } const Type_handler *type_handler() const { return m_handler; } CHARSET_INFO *charset_collation() const { return m_ci; } - Lex_charset_collation lex_charset_collation() const + Lex_column_charset_collation_attrs charset_collation_attrs() const { - return Lex_charset_collation(m_ci, - (Lex_charset_collation_st::Type) + return Lex_column_charset_collation_attrs(m_ci, + (Lex_column_charset_collation_attrs_st::Type) m_collation_type); } }; @@ -768,7 +769,7 @@ public: m_ci= cs; Lex_length_and_dec_st::reset(); } - bool set(int type, const Lex_charset_collation_st &collation, + bool set(int type, const Lex_column_charset_collation_attrs_st &collation, CHARSET_INFO *charset) { CHARSET_INFO *tmp= collation.resolved_to_character_set(charset); diff --git a/sql/table.cc b/sql/table.cc index efa7ae3a5b6..f0d51495953 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -45,30 +45,20 @@ #include "ha_sequence.h" #include "sql_show.h" #include "opt_trace.h" +#include "sql_db.h" // get_default_db_collation /* For MySQL 5.7 virtual fields */ #define MYSQL57_GENERATED_FIELD 128 #define MYSQL57_GCOL_HEADER_SIZE 4 -class Table_arena: public Query_arena -{ -public: - Table_arena(MEM_ROOT *mem_root, enum enum_state state_arg) : - Query_arena(mem_root, state_arg){} - virtual Type type() const - { - return TABLE_ARENA; - } -}; - bool TABLE::init_expr_arena(MEM_ROOT *mem_root) { /* We need to use CONVENTIONAL_EXECUTION here to ensure that any new items created by fix_fields() are not reverted. */ - expr_arena= new (alloc_root(mem_root, sizeof(Table_arena))) - Table_arena(mem_root, Query_arena::STMT_CONVENTIONAL_EXECUTION); + expr_arena= new (alloc_root(mem_root, sizeof(Query_arena))) + Query_arena(mem_root, Query_arena::STMT_CONVENTIONAL_EXECUTION); return expr_arena == NULL; } @@ -3514,6 +3504,19 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, else thd->set_n_backup_active_arena(arena, &backup); + /* + THD::reset_db() does not set THD::db_charset, + so it keeps pointing to the character set and collation + of the current database, rather than the database of the + new initialized table. After reset_db() the result of + get_default_db_collation() can be wrong. The latter is + used inside charset_collation_context_create_table_in_db(). + Let's initialize ctx before calling reset_db(). + This makes sure the db.opt file to be loaded properly when needed. + */ + Charset_collation_context + ctx(thd->charset_collation_context_create_table_in_db(db.str)); + thd->reset_db(&db); lex_start(thd); @@ -3521,6 +3524,9 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, sql_unusable_for_discovery(thd, hton, sql_copy)))) goto ret; + if (thd->lex->create_info.resolve_to_charset_collation_context(thd, ctx)) + DBUG_RETURN(true); + thd->lex->create_info.db_type= hton; #ifdef WITH_PARTITION_STORAGE_ENGINE thd->work_part_info= 0; // For partitioning @@ -3659,8 +3665,7 @@ class Vcol_expr_context bool inited; THD *thd; TABLE *table; - LEX *old_lex; - LEX lex; + Query_arena backup_arena; table_map old_map; Security_context *save_security_ctx; sql_mode_t save_sql_mode; @@ -3670,7 +3675,6 @@ public: inited(false), thd(_thd), table(_table), - old_lex(thd->lex), old_map(table->map), save_security_ctx(thd->security_ctx), save_sql_mode(thd->variables.sql_mode) {} @@ -3682,18 +3686,6 @@ public: bool Vcol_expr_context::init() { - /* - As this is vcol expression we must narrow down name resolution to - single table. - */ - if (init_lex_with_single_table(thd, table, &lex)) - { - my_error(ER_OUT_OF_RESOURCES, MYF(0)); - table->map= old_map; - return true; - } - - lex.sql_command= old_lex->sql_command; thd->variables.sql_mode= 0; TABLE_LIST const *tl= table->pos_in_table_list; @@ -3702,6 +3694,8 @@ bool Vcol_expr_context::init() if (table->pos_in_table_list->security_ctx) thd->security_ctx= tl->security_ctx; + thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); + inited= true; return false; } @@ -3710,9 +3704,9 @@ Vcol_expr_context::~Vcol_expr_context() { if (!inited) return; - end_lex_with_single_table(thd, table, old_lex); table->map= old_map; thd->security_ctx= save_security_ctx; + thd->restore_active_arena(table->expr_arena, &backup_arena); thd->variables.sql_mode= save_sql_mode; } @@ -4111,6 +4105,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, outparam->s= share; outparam->db_stat= db_stat; outparam->write_row_record= NULL; + outparam->status= STATUS_NO_RECORD; if (share->incompatible_version && !(ha_open_flags & (HA_OPEN_FOR_ALTER | HA_OPEN_FOR_REPAIR | @@ -6960,7 +6955,7 @@ Item *Field_iterator_view::create_item(THD *thd) Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, LEX_CSTRING *name) { - bool save_wrapper= thd->lex->first_select_lex()->no_wrap_view_item; + bool save_wrapper= thd->lex->current_select->no_wrap_view_item; Item *field= *field_ref; DBUG_ENTER("create_view_field"); diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h index 70759e381a5..f99d33094df 100644 --- a/sql/wsrep_trans_observer.h +++ b/sql/wsrep_trans_observer.h @@ -232,6 +232,10 @@ static inline int wsrep_before_prepare(THD* thd, bool all) WSREP_DEBUG("wsrep_before_prepare: %d", wsrep_is_real(thd, all)); int ret= 0; DBUG_ASSERT(wsrep_run_commit_hook(thd, all)); + if ((ret= thd->wsrep_parallel_slave_wait_for_prior_commit())) + { + DBUG_RETURN(ret); + } if ((ret= thd->wsrep_cs().before_prepare()) == 0) { DBUG_ASSERT(!thd->wsrep_trx().ws_meta().gtid().is_undefined()); diff --git a/storage/columnstore/columnstore b/storage/columnstore/columnstore -Subproject a0877d66ed97840658831a53c253a485e9ca5b7 +Subproject 1929e73ecb65b57533669f3e70d7555715c6505 diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index d1975dae32d..c0c32533302 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -113,7 +113,11 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename) } // endif f - pID = vfork(); +#ifdef HAVE_VFORK + pID = vfork(); +#else + pID = fork(); +#endif sprintf(fn, "-o%s", filename); if (pID == 0) { diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index e4e79e612a0..9ee8e466632 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -44,8 +44,6 @@ Created 6/2/1994 Heikki Tuuri #include "dict0boot.h" #include "row0sel.h" /* row_search_max_autoinc() */ -Atomic_counter<uint32_t> btr_validate_index_running; - /**************************************************************//** Checks if the page in the cursor can be merged with given page. If necessary, re-organize the merge_page. @@ -2598,8 +2596,8 @@ btr_insert_into_right_sibling( max_size = page_get_max_insert_size_after_reorganize(next_page, 1); /* Extends gap lock for the next page */ - if (cursor->index->has_locking()) { - lock_update_split_left(next_block, block); + if (is_leaf && cursor->index->has_locking()) { + lock_update_node_pointer(block, next_block); } rec = page_cur_tuple_insert( @@ -3534,17 +3532,9 @@ retry: } if (mbr_changed) { -#ifdef UNIV_DEBUG - bool success = rtr_update_mbr_field( - &cursor2, offsets2, &father_cursor, - merge_page, &new_mbr, NULL, mtr); - - ut_ad(success); -#else rtr_update_mbr_field( &cursor2, offsets2, &father_cursor, merge_page, &new_mbr, NULL, mtr); -#endif } else { rtr_node_ptr_delete(&father_cursor, mtr); } @@ -5036,7 +5026,6 @@ btr_validate_index( ulint n = btr_page_get_level(root); - btr_validate_index_running++; for (ulint i = 0; i <= n; ++i) { if (!btr_validate_level(index, trx, n - i, lockout)) { @@ -5045,15 +5034,6 @@ btr_validate_index( } mtr_commit(&mtr); - /* In theory we need release barrier here, so that - btr_validate_index_running decrement is guaranteed to - happen after latches are released. - - Original code issued SEQ_CST on update and non-atomic - access on load. Which means it had broken synchronisation - as well. */ - btr_validate_index_running--; - return(err); } diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index e5bb8a9651e..d42dcc3d464 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -5808,7 +5808,6 @@ discard_page: rec_t* father_rec; btr_cur_t father_cursor; rec_offs* offsets; - bool upd_ret; ulint len; rtr_page_get_father_block(NULL, heap, index, @@ -5822,17 +5821,8 @@ discard_page: rtr_read_mbr(rec_get_nth_field( father_rec, offsets, 0, &len), &father_mbr); - upd_ret = rtr_update_mbr_field(&father_cursor, offsets, - NULL, page, &father_mbr, - next_rec, mtr); - - if (!upd_ret) { - *err = DB_ERROR; - - mem_heap_free(heap); - return(FALSE); - } - + rtr_update_mbr_field(&father_cursor, offsets, NULL, + page, &father_mbr, next_rec, mtr); ut_d(parent_latched = true); } else { /* Otherwise, if we delete the leftmost node pointer diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 35ac226f848..b986b5c2325 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1106,15 +1106,19 @@ bool buf_pool_t::create() ut_ad(srv_buf_pool_size > 0); ut_ad(!resizing); ut_ad(!chunks_old); - ut_ad(!field_ref_zero); + /* mariabackup loads tablespaces, and it requires field_ref_zero to be + allocated before innodb initialization */ + ut_ad(srv_operation >= SRV_OPERATION_RESTORE || !field_ref_zero); NUMA_MEMPOLICY_INTERLEAVE_IN_SCOPE; - if (auto b= aligned_malloc(UNIV_PAGE_SIZE_MAX, 4096)) - field_ref_zero= static_cast<const byte*> - (memset_aligned<4096>(b, 0, UNIV_PAGE_SIZE_MAX)); - else - return true; + if (!field_ref_zero) { + if (auto b= aligned_malloc(UNIV_PAGE_SIZE_MAX, 4096)) + field_ref_zero= static_cast<const byte*> + (memset_aligned<4096>(b, 0, UNIV_PAGE_SIZE_MAX)); + else + return true; + } chunk_t::map_reg= UT_NEW_NOKEY(chunk_t::map()); diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index c309858004d..6d8ec745d0a 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -1313,7 +1313,7 @@ dict_load_columns( ut_ad(dict_sys.locked()); - mtr_start(&mtr); + mtr.start(); dict_index_t* sys_index = dict_sys.sys_columns->indexes.start; ut_ad(!dict_sys.sys_columns->not_redundant()); @@ -1402,8 +1402,7 @@ next_rec: btr_pcur_move_to_next_user_rec(&pcur, &mtr); } - btr_pcur_close(&pcur); - mtr_commit(&mtr); + mtr.commit(); } /** Loads SYS_VIRTUAL info for one virtual column @@ -1435,7 +1434,7 @@ dict_load_virtual_one_col( return; } - mtr_start(&mtr); + mtr.start(); sys_virtual_index = dict_sys.sys_virtual->indexes.start; ut_ad(!dict_sys.sys_virtual->not_redundant()); @@ -1493,8 +1492,7 @@ dict_load_virtual_one_col( btr_pcur_move_to_next_user_rec(&pcur, &mtr); } - btr_pcur_close(&pcur); - mtr_commit(&mtr); + mtr.commit(); } /** Loads info from SYS_VIRTUAL for virtual columns. @@ -1684,7 +1682,7 @@ dict_load_fields( ut_ad(dict_sys.locked()); - mtr_start(&mtr); + mtr.start(); dict_index_t* sys_index = dict_sys.sys_fields->indexes.start; ut_ad(!dict_sys.sys_fields->not_redundant()); @@ -1732,9 +1730,8 @@ dict_load_fields( error = DB_SUCCESS; func_exit: - btr_pcur_close(&pcur); - mtr_commit(&mtr); - return(error); + mtr.commit(); + return error; } /** Error message for a delete-marked record in dict_load_index_low() */ @@ -1938,7 +1935,7 @@ dict_load_indexes( ut_ad(dict_sys.locked()); - mtr_start(&mtr); + mtr.start(); sys_index = dict_sys.sys_indexes->indexes.start; ut_ad(!dict_sys.sys_indexes->not_redundant()); @@ -2142,10 +2139,8 @@ next_rec: } func_exit: - btr_pcur_close(&pcur); - mtr_commit(&mtr); - - return(error); + mtr.commit(); + return error; } /** Load a table definition from a SYS_TABLES record to dict_table_t. @@ -2318,7 +2313,7 @@ static dict_table_t *dict_load_table_one(const span<const char> &name, heap = mem_heap_create(32000); - mtr_start(&mtr); + mtr.start(); dict_index_t *sys_index = dict_sys.sys_tables->indexes.start; ut_ad(!dict_sys.sys_tables->not_redundant()); @@ -2346,8 +2341,7 @@ static dict_table_t *dict_load_table_one(const span<const char> &name, if (!btr_pcur_is_on_user_rec(&pcur)) { /* Not found */ err_exit: - btr_pcur_close(&pcur); - mtr_commit(&mtr); + mtr.commit(); mem_heap_free(heap); DBUG_RETURN(NULL); @@ -2370,8 +2364,7 @@ err_exit: goto err_exit; } - btr_pcur_close(&pcur); - mtr_commit(&mtr); + mtr.commit(); dict_load_tablespace(table, ignore_err); @@ -2616,10 +2609,8 @@ check_rec: } } - btr_pcur_close(&pcur); mtr.commit(); - - return(table); + return table; } /********************************************************************//** @@ -2676,7 +2667,7 @@ static void dict_load_foreign_cols(dict_foreign_t *foreign, trx_id_t trx_id) mem_heap_alloc(foreign->heap, foreign->n_fields * sizeof(void*))); - mtr_start(&mtr); + mtr.start(); dict_index_t* sys_index = dict_sys.sys_foreign_cols->indexes.start; ut_ad(!dict_sys.sys_foreign_cols->not_redundant()); @@ -2787,7 +2778,6 @@ next: btr_pcur_move_to_next_user_rec(&pcur, &mtr); } - btr_pcur_close(&pcur); mtr.commit(); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -2860,7 +2850,6 @@ dict_load_foreign( if (!btr_pcur_is_on_user_rec(&pcur)) { not_found: - btr_pcur_close(&pcur); mtr.commit(); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -2948,7 +2937,6 @@ dict_load_foreign( foreign->heap, (const char*) field, len); dict_mem_referenced_table_name_lookup_set(foreign, TRUE); - btr_pcur_close(&pcur); mtr.commit(); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -3107,7 +3095,7 @@ loop: rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__ID, &len); /* Copy the string because the page may be modified or evicted - after mtr_commit() below. */ + after mtr.commit() below. */ char fk_id[MAX_TABLE_NAME_LEN + 1]; ut_a(len <= MAX_TABLE_NAME_LEN); @@ -3134,7 +3122,7 @@ loop: "SYS_FOREIGN", int(len), fk_id); /* fall through */ default: - btr_pcur_close(&pcur); + ut_free(pcur.old_rec_buf); DBUG_RETURN(err); } @@ -3146,8 +3134,8 @@ next_rec: goto loop; load_next_index: - btr_pcur_close(&pcur); - mtr_commit(&mtr); + mtr.commit(); + ut_free(pcur.old_rec_buf); sec_index = dict_table_get_next_index(sec_index); diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index a081e8e5538..35f42637f8f 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1884,11 +1884,8 @@ dict_stats_analyze_index_level( } #endif /* UNIV_STATS_DEBUG */ - /* Release the latch on the last page, because that is not done by - btr_pcur_close(). This function works also for non-leaf pages. */ btr_leaf_page_release(btr_pcur_get_block(&pcur), BTR_SEARCH_LEAF, mtr); - btr_pcur_close(&pcur); ut_free(prev_rec_buf); mem_heap_free(heap); } @@ -2394,8 +2391,6 @@ dict_stats_analyze_index_for_n_prefix( n_diff_data->n_external_pages_sum += n_external_pages; } - - btr_pcur_close(&pcur); } /** statistics for an index */ diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 85490372180..663fc60aef8 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1974,7 +1974,7 @@ fil_crypt_flush_space( if (buf_block_t* block = buf_page_get_gen( page_id_t(space->id, 0), space->zip_size(), RW_X_LATCH, NULL, BUF_GET_POSSIBLY_FREED, &mtr)) { - if (block->page.is_freed()) { + if (!block->page.is_freed()) { mtr.set_named_space(space); crypt_data->write_page0(block, &mtr); } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 5358df2271a..aff880489eb 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -3494,13 +3494,13 @@ fts_add_doc_by_id( } if (!is_id_cluster) { - btr_pcur_close(doc_pcur); + ut_free(doc_pcur->old_rec_buf); } } func_exit: mtr_commit(&mtr); - btr_pcur_close(&pcur); + ut_free(pcur.old_rec_buf); mem_heap_free(heap); return(TRUE); @@ -3581,7 +3581,6 @@ fts_get_max_doc_id( } func_exit: - btr_pcur_close(&pcur); mtr_commit(&mtr); return(doc_id); } diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index f389851a4ea..f17c532414b 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2021, MariaDB Corporation. +Copyright (c) 2019, 2022, 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 @@ -185,9 +185,8 @@ rtr_index_build_node_ptr( } /**************************************************************//** -Update the mbr field of a spatial index row. -@return true if update is successful */ -bool +Update the mbr field of a spatial index row. */ +void rtr_update_mbr_field( /*=================*/ btr_cur_t* cursor, /*!< in/out: cursor pointed to rec.*/ @@ -535,8 +534,6 @@ update_mbr: page_is_comp(page)))); mem_heap_free(heap); - - return(true); } /**************************************************************//** @@ -1262,12 +1259,8 @@ rtr_ins_enlarge_mbr( page = buf_block_get_frame(block); /* Update the mbr field of the rec. */ - if (!rtr_update_mbr_field(&cursor, offsets, NULL, page, - &new_mbr, NULL, mtr)) { - err = DB_ERROR; - break; - } - + rtr_update_mbr_field(&cursor, offsets, NULL, page, + &new_mbr, NULL, mtr); page_cursor = btr_cur_get_page_cur(&cursor); block = page_cur_get_block(page_cursor); } @@ -1577,7 +1570,7 @@ rtr_merge_mbr_changed( /****************************************************************//** Merge 2 mbrs and update the the mbr that cursor is on. */ -dberr_t +void rtr_merge_and_update_mbr( /*=====================*/ btr_cur_t* cursor, /*!< in/out: cursor */ @@ -1587,27 +1580,15 @@ rtr_merge_and_update_mbr( page_t* child_page, /*!< in: the page. */ mtr_t* mtr) /*!< in: mtr */ { - dberr_t err = DB_SUCCESS; rtr_mbr_t new_mbr; - bool changed = false; - - ut_ad(dict_index_is_spatial(cursor->index)); - changed = rtr_merge_mbr_changed(cursor, cursor2, offsets, offsets2, - &new_mbr); - - /* Update the mbr field of the rec. And will delete the record - pointed by cursor2 */ - if (changed) { - if (!rtr_update_mbr_field(cursor, offsets, cursor2, child_page, - &new_mbr, NULL, mtr)) { - err = DB_ERROR; - } + if (rtr_merge_mbr_changed(cursor, cursor2, offsets, offsets2, + &new_mbr)) { + rtr_update_mbr_field(cursor, offsets, cursor2, child_page, + &new_mbr, NULL, mtr); } else { rtr_node_ptr_delete(cursor2, mtr); } - - return(err); } /*************************************************************//** diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 074249efc72..b19d3adefac 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1027,10 +1027,6 @@ static SHOW_VAR innodb_status_variables[]= { /* Status variables for page compression */ {"page_compression_saved", &export_vars.innodb_page_compression_saved, SHOW_LONGLONG}, - {"num_index_pages_written", - &export_vars.innodb_index_pages_written, SHOW_LONGLONG}, - {"num_non_index_pages_written", - &export_vars.innodb_non_index_pages_written, SHOW_LONGLONG}, {"num_pages_page_compressed", &export_vars.innodb_pages_page_compressed, SHOW_LONGLONG}, {"num_page_compressed_trim_op", @@ -1085,8 +1081,6 @@ static SHOW_VAR innodb_status_variables[]= { &export_vars.innodb_encryption_rotation_pages_flushed, SHOW_SIZE_T}, {"encryption_rotation_estimated_iops", &export_vars.innodb_encryption_rotation_estimated_iops, SHOW_SIZE_T}, - {"encryption_key_rotation_list_length", - &export_vars.innodb_key_rotation_list_length, SHOW_LONGLONG}, {"encryption_n_merge_blocks_encrypted", &export_vars.innodb_n_merge_blocks_encrypted, SHOW_LONGLONG}, {"encryption_n_merge_blocks_decrypted", @@ -2110,9 +2104,9 @@ fail: pcur.restore_position(BTR_SEARCH_LEAF, &mtr); } - btr_pcur_close(&pcur); mtr.commit(); trx->free(); + ut_free(pcur.old_rec_buf); ut_d(purge_sys.resume_FTS()); } @@ -13551,7 +13545,28 @@ int ha_innobase::delete_table(const char *name) } if (err == DB_SUCCESS) + { + if (!table->space) + { + const char *data_dir_path= DICT_TF_HAS_DATA_DIR(table->flags) + ? table->data_dir_path : nullptr; + char *path= fil_make_filepath(data_dir_path, table->name, CFG, + data_dir_path != nullptr); + os_file_delete_if_exists(innodb_data_file_key, path, nullptr); + ut_free(path); + path= fil_make_filepath(data_dir_path, table->name, IBD, + data_dir_path != nullptr); + os_file_delete_if_exists(innodb_data_file_key, path, nullptr); + ut_free(path); + if (data_dir_path) + { + path= fil_make_filepath(nullptr, table->name, ISL, false); + os_file_delete_if_exists(innodb_data_file_key, path, nullptr); + ut_free(path); + } + } err= lock_sys_tables(trx); + } dict_sys.lock(SRW_LOCK_CALL); @@ -16620,8 +16635,8 @@ ha_innobase::get_auto_increment( (3) It is restricted only for insert operations. */ - if (increment > 1 && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE - && autoinc < col_max_value) { + if (increment > 1 && increment <= ~autoinc && autoinc < col_max_value + && thd_sql_command(m_user_thd) != SQLCOM_ALTER_TABLE) { ulonglong prev_auto_inc = autoinc; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 35126431c73..05a69648720 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -5998,7 +5998,7 @@ add_all_virtual: if (offsets_heap) { mem_heap_free(offsets_heap); } - btr_pcur_close(&pcur); + ut_free(pcur.old_rec_buf); goto func_exit; } else if (is_root && page_rec_is_supremum(rec) && !index->table->instant) { @@ -8899,6 +8899,7 @@ free_and_exit: } } + DBUG_ASSERT(!prebuilt->table->indexes.start->online_log); DBUG_ASSERT(prebuilt->table->indexes.start->online_status == ONLINE_INDEX_COMPLETE); @@ -10687,6 +10688,10 @@ commit_cache_norebuild( : NULL; DBUG_ASSERT((ctx->new_table->fts == NULL) == (ctx->new_table->fts_doc_id_index == NULL)); + if (table->found_next_number_field + && !altered_table->found_next_number_field) { + ctx->prebuilt->table->persistent_autoinc = 0; + } DBUG_RETURN(found); } @@ -10868,7 +10873,15 @@ ha_innobase::commit_inplace_alter_table( if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)) { DBUG_ASSERT(!ctx0); MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); - ha_alter_info->group_commit_ctx = NULL; + if (table->found_next_number_field + && !altered_table->found_next_number_field) { + m_prebuilt->table->persistent_autoinc = 0; + /* Don't reset ha_alter_info->group_commit_ctx to make + partitions engine to call this function for all + partitions. */ + } + else + ha_alter_info->group_commit_ctx = NULL; DBUG_RETURN(false); } @@ -10957,6 +10970,12 @@ ha_innobase::commit_inplace_alter_table( LOCK_X); } + DBUG_EXECUTE_IF("deadlock_table_fail", + { + error= DB_DEADLOCK; + trx_rollback_for_mysql(trx); + }); + if (error != DB_SUCCESS) { lock_fail: my_error_innodb( @@ -10964,6 +10983,16 @@ lock_fail: if (fts_exist) { purge_sys.resume_FTS(); } + + /* Deadlock encountered and rollbacked the + transaction. So restart the transaction + to remove the newly created table or + index from data dictionary and table cache + in rollback_inplace_alter_table() */ + if (trx->state == TRX_STATE_NOT_STARTED) { + trx_start_for_ddl(trx); + } + DBUG_RETURN(true); } else if ((ctx->new_table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) @@ -11052,10 +11081,14 @@ err_index: DBUG_RETURN(true); } + index->lock.x_unlock(); + error = row_log_apply( m_prebuilt->trx, index, altered_table, ctx->m_stage); + index->lock.x_lock(SRW_LOCK_CALL); + if (error != DB_SUCCESS) { goto err_index; } @@ -11350,6 +11383,8 @@ foreign_fail: purge_sys.resume_FTS(); } MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); + /* There is no need to reset dict_table_t::persistent_autoinc + as the table is reloaded */ DBUG_RETURN(false); } diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index b035d73774d..6b006625bcc 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2333,13 +2333,11 @@ loop: if (btr_pcur_is_after_last_on_page(&pcur)) { ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); goto loop; } } done: ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); mem_heap_empty(heap); #endif } @@ -2391,7 +2389,6 @@ ibuf_merge_pages( == page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO)); ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); return(0); } @@ -2401,7 +2398,6 @@ ibuf_merge_pages( space_ids, page_nos, n_pages); ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); ibuf_read_merge_pages(space_ids, page_nos, *n_pages); @@ -2459,8 +2455,6 @@ ibuf_merge_space( ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); - if (n_pages > 0) { ut_ad(n_pages <= UT_ARR_SIZE(pages)); @@ -3300,9 +3294,15 @@ fail_exit: commit_exit: ibuf_mtr_commit(&bitmap_mtr); goto fail_exit; + } else if (!lock_sys.rd_lock_try()) { + goto commit_exit; } else { - LockGuard g{lock_sys.rec_hash, page_id}; - if (lock_sys_t::get_first(g.cell(), page_id)) { + hash_cell_t* cell = lock_sys.rec_hash.cell_get(page_id.fold()); + lock_sys.rec_hash.latch(cell)->acquire(); + const lock_t* lock = lock_sys_t::get_first(*cell, page_id); + lock_sys.rec_hash.latch(cell)->release(); + lock_sys.rd_unlock(); + if (lock) { goto commit_exit; } } @@ -3426,8 +3426,7 @@ commit_exit: func_exit: ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); - + ut_free(pcur.old_rec_buf); mem_heap_free(heap); if (err == DB_SUCCESS @@ -3805,7 +3804,6 @@ dump: /* Delete the different-length record, and insert the buffered one. */ - lock_rec_store_on_page_infimum(block, rec); page_cur_delete_rec(&page_cur, index, offsets, mtr); page_cur_move_to_prev(&page_cur); rec = ibuf_insert_to_index_page_low(entry, block, index, @@ -3813,8 +3811,6 @@ dump: &page_cur); ut_ad(!cmp_dtuple_rec(entry, rec, index, offsets)); - lock_rec_restore_from_page_infimum(*block, rec, - block->page.id()); } else { offsets = NULL; ibuf_insert_to_index_page_low(entry, block, index, @@ -3947,8 +3943,6 @@ ibuf_delete( return; } - lock_update_delete(block, rec); - if (!page_zip) { max_ins_size = page_get_max_insert_size_after_reorganize( @@ -4423,8 +4417,7 @@ loop: goto loop; } else if (btr_pcur_is_after_last_on_page(&pcur)) { ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); - + ut_free(pcur.old_rec_buf); goto loop; } } @@ -4435,12 +4428,12 @@ reset_bit: } ibuf_mtr_commit(&mtr); + ut_free(pcur.old_rec_buf); if (space) { space->release(); } - btr_pcur_close(&pcur); mem_heap_free(heap); ibuf.n_merges++; @@ -4506,20 +4499,20 @@ loop: we start from the beginning again */ ut_ad(mtr.has_committed()); +clear: + ut_free(pcur.old_rec_buf); goto loop; } if (btr_pcur_is_after_last_on_page(&pcur)) { ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); - - goto loop; + goto clear; } } leave_loop: ibuf_mtr_commit(&mtr); - btr_pcur_close(&pcur); + ut_free(pcur.old_rec_buf); ibuf_add_ops(ibuf.n_discarded_ops, dops); diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 8644acb0831..c6e90c8cbef 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -2,7 +2,7 @@ Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2014, 2021, MariaDB Corporation. +Copyright (c) 2014, 2022, 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 @@ -25,8 +25,7 @@ The B-tree Created 6/2/1994 Heikki Tuuri *******************************************************/ -#ifndef btr0btr_h -#define btr0btr_h +#pragma once #include "dict0dict.h" #include "data0data.h" @@ -681,6 +680,3 @@ btr_lift_page_up( /**************************************************************** Global variable controlling if scrubbing should be performed */ extern my_bool srv_immediate_scrub_data_uncompressed; -extern Atomic_counter<uint32_t> btr_validate_index_running; - -#endif diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index f6636816e72..57ee40e9ee6 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2021, MariaDB Corporation. +Copyright (c) 2017, 2022, 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 @@ -92,8 +92,7 @@ btr_pcur_free( btr_pcur_t* pcur); /**************************************************************//** -Initializes and opens a persistent cursor to an index tree. It should be -closed with btr_pcur_close. */ +Initializes and opens a persistent cursor to an index tree. */ UNIV_INLINE dberr_t btr_pcur_open_low( @@ -218,9 +217,7 @@ cursor is currently positioned. The latch is acquired by the are not allowed, you must take care (if using the cursor in S-mode) to manually release the latch by either calling btr_leaf_page_release(btr_pcur_get_block(&pcur), pcur.latch_mode, mtr) -or by committing the mini-transaction right after btr_pcur_close(). -A subsequent attempt to crawl the same page in the same mtr would cause -an assertion failure. */ +or by mtr_t::commit(). */ UNIV_INLINE void btr_pcur_close( diff --git a/storage/innobase/include/btr0pcur.inl b/storage/innobase/include/btr0pcur.inl index f5e59c7268e..4bd15fd7287 100644 --- a/storage/innobase/include/btr0pcur.inl +++ b/storage/innobase/include/btr0pcur.inl @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2021, MariaDB Corporation. +Copyright (c) 2015, 2022, 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 @@ -329,8 +329,7 @@ btr_pcur_free( } /**************************************************************//** -Initializes and opens a persistent cursor to an index tree. It should be -closed with btr_pcur_close. */ +Initializes and opens a persistent cursor to an index tree. */ UNIV_INLINE dberr_t btr_pcur_open_low( @@ -518,9 +517,7 @@ cursor is currently positioned. The latch is acquired by the are not allowed, you must take care (if using the cursor in S-mode) to manually release the latch by either calling btr_leaf_page_release(btr_pcur_get_block(&pcur), pcur.latch_mode, mtr) -or by committing the mini-transaction right after btr_pcur_close(). -A subsequent attempt to crawl the same page in the same mtr would cause -an assertion failure. */ +or by mtr_t::commit(). */ UNIV_INLINE void btr_pcur_close( diff --git a/storage/innobase/include/buf0types.h b/storage/innobase/include/buf0types.h index 38df7cbe462..bad3fd79571 100644 --- a/storage/innobase/include/buf0types.h +++ b/storage/innobase/include/buf0types.h @@ -89,20 +89,25 @@ this must be equal to srv_page_size */ class page_id_t { public: - /** Constructor from (space, page_no). @param space tablespace id @param page_no page number */ - page_id_t(uint32_t space, uint32_t page_no) : + constexpr page_id_t(uint32_t space, uint32_t page_no) : m_id(uint64_t{space} << 32 | page_no) {} - page_id_t(uint64_t id) : m_id(id) {} - bool operator==(const page_id_t& rhs) const { return m_id == rhs.m_id; } - bool operator!=(const page_id_t& rhs) const { return m_id != rhs.m_id; } - bool operator<(const page_id_t& rhs) const { return m_id < rhs.m_id; } - bool operator>(const page_id_t& rhs) const { return m_id > rhs.m_id; } - bool operator<=(const page_id_t& rhs) const { return m_id <= rhs.m_id; } - bool operator>=(const page_id_t& rhs) const { return m_id >= rhs.m_id; } + constexpr page_id_t(uint64_t id) : m_id(id) {} + constexpr bool operator==(const page_id_t& rhs) const + { return m_id == rhs.m_id; } + constexpr bool operator!=(const page_id_t& rhs) const + { return m_id != rhs.m_id; } + constexpr bool operator<(const page_id_t& rhs) const + { return m_id < rhs.m_id; } + constexpr bool operator>(const page_id_t& rhs) const + { return m_id > rhs.m_id; } + constexpr bool operator<=(const page_id_t& rhs) const + { return m_id <= rhs.m_id; } + constexpr bool operator>=(const page_id_t& rhs) const + { return m_id >= rhs.m_id; } page_id_t &operator--() { ut_ad(page_no()); m_id--; return *this; } page_id_t &operator++() { @@ -123,15 +128,16 @@ public: /** Retrieve the tablespace id. @return tablespace id */ - uint32_t space() const { return static_cast<uint32_t>(m_id >> 32); } + constexpr uint32_t space() const { return static_cast<uint32_t>(m_id >> 32); } /** Retrieve the page number. @return page number */ - uint32_t page_no() const { return static_cast<uint32_t>(m_id); } + constexpr uint32_t page_no() const { return static_cast<uint32_t>(m_id); } /** Retrieve the fold value. @return fold value */ - ulint fold() const { return (ulint{space()} << 20) + space() + page_no(); } + constexpr ulint fold() const + { return (ulint{space()} << 20) + space() + page_no(); } /** Reset the page number only. @param[in] page_no page number */ @@ -140,7 +146,7 @@ public: m_id= (m_id & ~uint64_t{0} << 32) | page_no; } - ulonglong raw() { return m_id; } + constexpr ulonglong raw() const { return m_id; } private: /** The page identifier */ diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index 104e99fc0cd..271e4e1fb76 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2021, MariaDB Corporation. +Copyright (c) 2013, 2022, 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 @@ -72,7 +72,7 @@ enum dict_err_ignore_t { DICT_ERR_IGNORE_FK_NOKEY = 1, /*!< ignore error if any foreign key is missing */ DICT_ERR_IGNORE_INDEX = 2, /*!< ignore corrupted indexes */ - DICT_ERR_IGNORE_RECOVER_LOCK = 4, + DICT_ERR_IGNORE_RECOVER_LOCK = 4 | DICT_ERR_IGNORE_FK_NOKEY, /*!< Used when recovering table locks for resurrected transactions. Silently load a missing diff --git a/storage/innobase/include/gis0rtree.h b/storage/innobase/include/gis0rtree.h index de5a9075059..024df3e4094 100644 --- a/storage/innobase/include/gis0rtree.h +++ b/storage/innobase/include/gis0rtree.h @@ -372,7 +372,7 @@ rtr_page_copy_rec_list_start_no_locks( /****************************************************************//** Merge 2 mbrs and update the the mbr that cursor is on. */ -dberr_t +void rtr_merge_and_update_mbr( /*=====================*/ btr_cur_t* cursor, /*!< in/out: cursor */ @@ -404,9 +404,8 @@ rtr_merge_mbr_changed( /**************************************************************//** -Update the mbr field of a spatial index row. -@return true if successful */ -bool +Update the mbr field of a spatial index row. */ +void rtr_update_mbr_field( /*=================*/ btr_cur_t* cursor, /*!< in: cursor pointed to rec.*/ diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index a11bc60e7a0..b67a1011f6b 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2022, Oracle and/or its affiliates. Copyright (c) 2017, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -136,6 +136,41 @@ void lock_update_root_raise(const buf_block_t &block, const page_id_t root); @param new_block the target page @param old old page (not index root page) */ void lock_update_copy_and_discard(const buf_block_t &new_block, page_id_t old); + +/** Update gap locks between the last record of the left_block and the +first record of the right_block when a record is about to be inserted +at the start of the right_block, even though it should "naturally" be +inserted as the last record of the left_block according to the +current node pointer in the parent page. + +That is, we assume that the lowest common ancestor of the left_block +and right_block routes the key of the new record to the left_block, +but a heuristic which tries to avoid overflowing left_block has chosen +to insert the record into right_block instead. Said ancestor performs +this routing by comparing the key of the record to a "split point" - +all records greater or equal to than the split point (node pointer) +are in right_block, and smaller ones in left_block. +The split point may be smaller than the smallest key in right_block. + +The gap between the last record on the left_block and the first record +on the right_block is represented as a gap lock attached to the supremum +pseudo-record of left_block, and a gap lock attached to the new first +record of right_block. + +Thus, inserting the new record, and subsequently adjusting the node +pointers in parent pages to values smaller or equal to the new +records' key, will mean that gap will be sliced at a different place +("moved to the left"): fragment of the 1st gap will now become treated +as 2nd. Therefore, we must copy any GRANTED locks from 1st gap to the +2nd gap. Any WAITING locks must be of INSERT_INTENTION type (as no +other GAP locks ever wait for anything) and can stay at 1st gap, as +their only purpose is to notify the requester they can retry +insertion, and there's no correctness requirement to avoid waking them +up too soon. +@param left_block left page +@param right_block right page */ +void lock_update_node_pointer(const buf_block_t *left_block, + const buf_block_t *right_block); /*************************************************************//** Updates the lock table when a page is split to the left. */ void diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h index c955500ff7a..d205783cb95 100644 --- a/storage/innobase/include/mtr0log.h +++ b/storage/innobase/include/mtr0log.h @@ -24,6 +24,9 @@ Mini-transaction log record encoding and decoding #pragma once #include "mtr0mtr.h" +/** The smallest invalid page identifier for persistent tablespaces */ +constexpr page_id_t end_page_id{SRV_SPACE_ID_UPPER_BOUND, 0}; + /** The minimum 2-byte integer (0b10xxxxxx xxxxxxxx) */ constexpr uint32_t MIN_2BYTE= 1 << 7; /** The minimum 3-byte integer (0b110xxxxx xxxxxxxx xxxxxxxx) */ @@ -389,6 +392,7 @@ inline byte *mtr_t::log_write(const page_id_t id, const buf_page_t *bpage, type <= FILE_CHECKPOINT, "invalid type"); ut_ad(type >= FILE_CREATE || is_named_space(id.space())); ut_ad(!bpage || bpage->id() == id); + ut_ad(id < end_page_id); constexpr bool have_len= type != INIT_PAGE && type != FREE_PAGE; constexpr bool have_offset= type == WRITE || type == MEMSET || type == MEMMOVE; diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 3fc9c743cc6..1ca2d7a429f 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -174,8 +174,6 @@ enum monitor_id_t { MONITOR_OVLD_BUF_POOL_PAGES_FREE, MONITOR_OVLD_PAGE_CREATED, MONITOR_OVLD_PAGES_WRITTEN, - MONITOR_OVLD_INDEX_PAGES_WRITTEN, - MONITOR_OVLD_NON_INDEX_PAGES_WRITTEN, MONITOR_OVLD_PAGES_READ, MONITOR_OVLD_INDEX_SEC_REC_CLUSTER_READS, MONITOR_OVLD_INDEX_SEC_REC_CLUSTER_READS_AVOIDED, diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index ffcbd15ace2..41f61567b53 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -92,10 +92,6 @@ struct srv_stats_t /** Number of bytes saved by page compression */ ulint_ctr_n_t page_compression_saved; - /* Number of index pages written */ - ulint_ctr_n_t index_pages_written; - /* Number of non index pages written */ - ulint_ctr_n_t non_index_pages_written; /* Number of pages compressed with page compression */ ulint_ctr_n_t pages_page_compressed; /* Number of TRIM operations induced by page compression */ @@ -153,9 +149,6 @@ struct srv_stats_t /** Number of encryption_get_latest_key_version calls */ ulint_ctr_n_t n_key_requests; - /** Number of spaces in keyrotation list */ - ulint_ctr_n_t key_rotation_list_length; - /** Number of temporary tablespace blocks encrypted */ ulint_ctr_n_t n_temp_blocks_encrypted; @@ -739,10 +732,6 @@ struct export_var_t{ int64_t innodb_page_compression_saved;/*!< Number of bytes saved by page compression */ - int64_t innodb_index_pages_written; /*!< Number of index pages - written */ - int64_t innodb_non_index_pages_written; /*!< Number of non index pages - written */ int64_t innodb_pages_page_compressed;/*!< Number of pages compressed by page compression */ int64_t innodb_page_compressed_trim_op;/*!< Number of TRIM operations @@ -781,7 +770,6 @@ struct export_var_t{ ulint innodb_encryption_rotation_pages_flushed; ulint innodb_encryption_rotation_estimated_iops; int64_t innodb_encryption_key_requests; - int64_t innodb_key_rotation_list_length; }; extern tpool::thread_pool *srv_thread_pool; diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h index a56752fc91d..8abf187f968 100644 --- a/storage/innobase/include/trx0rec.h +++ b/storage/innobase/include/trx0rec.h @@ -232,8 +232,6 @@ must hold a latch on the index page of the clustered index record. @param v_status status determine if it is going into this function by purge thread or not. And if we read "after image" of undo log -@param undo_block undo log block which was cached during - online dml apply or nullptr @retval true if previous version was built, or if it was an insert or the table has been rebuilt @retval false if the previous version is earlier than purge_view, @@ -249,8 +247,7 @@ trx_undo_prev_version_build( rec_t **old_vers, mem_heap_t *v_heap, dtuple_t **vrow, - ulint v_status, - const buf_block_t *undo_block= nullptr); + ulint v_status); /** Read from an undo log record a non-virtual column value. @param[in,out] ptr pointer to remaining part of the undo record diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index 1f33a9db091..0392f71a9bd 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -925,20 +925,16 @@ public: /** - Returns the minimum trx id in rw trx list. + Determine if the specified transaction or any older one might be active. - This is the smallest id for which the trx can possibly be active. (But, you - must look at the trx->state to find out if the minimum trx id transaction - itself is active, or already committed.) - - @return the minimum trx id, or m_max_trx_id if the trx list is empty + @param caller_trx used to get/set pins + @param id transaction identifier + @return whether any transaction not newer than id might be active */ - trx_id_t get_min_trx_id() + bool find_same_or_older(trx_t *caller_trx, trx_id_t id) { - trx_id_t id= get_max_trx_id(); - rw_trx_hash.iterate(get_min_trx_id_callback, &id); - return id; + return rw_trx_hash.iterate(caller_trx, find_same_or_older_callback, &id); } @@ -1173,18 +1169,10 @@ public: } private: - static my_bool get_min_trx_id_callback(rw_trx_hash_element_t *element, - trx_id_t *id) + static my_bool find_same_or_older_callback(rw_trx_hash_element_t *element, + trx_id_t *id) { - if (element->id < *id) - { - element->mutex.wr_lock(); - /* We don't care about read-only transactions here. */ - if (element->trx && element->trx->rsegs.m_redo.rseg) - *id= element->id; - element->mutex.wr_unlock(); - } - return 0; + return element->id <= *id; } diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index 111369e6a0f..cf2b99c6113 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -332,14 +332,14 @@ parse the undo log record and store the record type, update vector and compiler information */ class UndorecApplier { - /** undo log block which was latched */ - const buf_block_t *block; + /** Undo log block page id */ + page_id_t page_id; /** Undo log record pointer */ trx_undo_rec_t *undo_rec; /** Offset of the undo log record within the block */ - ulint offset; + uint16_t offset; /** Transaction id of the undo log */ - trx_id_t trx_id; + const trx_id_t trx_id; /** Undo log record type */ ulint type; /** compiler information */ @@ -353,21 +353,23 @@ class UndorecApplier mtr_t mtr; public: - UndorecApplier(const buf_block_t *block, trx_id_t trx_id) - : block(block), trx_id(trx_id) + UndorecApplier(page_id_t page_id, trx_id_t trx_id) : + page_id(page_id), trx_id(trx_id), heap(mem_heap_create(100)) { - ut_ad(block->page.lock.have_any()); - heap= mem_heap_create(100); } - /** Assign the undo log block */ - void assign_block(const buf_block_t *undo_block) + /** Assign the next page id */ + void assign_next(const page_id_t next_page_id) { - block= undo_block; + page_id= next_page_id; } /** Assign the undo log record and offset */ - void assign_rec(trx_undo_rec_t *rec); + inline void assign_rec(const buf_block_t &block, uint16_t offset); + + uint16_t get_offset() const { return offset; } + + page_id_t get_page_id() const { return page_id; } /** Handle the DML undo log and apply it on online indexes */ void apply_undo_rec(); @@ -396,7 +398,7 @@ private: { uint16_t offset= static_cast<uint16_t>(roll_ptr); uint32_t page_no= static_cast<uint32_t>(roll_ptr >> 16); - return page_no == block->page.id().page_no() && offset == this->offset; + return page_no == page_id.page_no() && offset == this->offset; } /** Clear the undo log record information */ @@ -406,7 +408,6 @@ private: cmpl_info= 0; type= 0; update= nullptr; - offset= 0; mem_heap_empty(heap); } diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 2d27a674275..4d8d3345c47 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2022, Oracle and/or its affiliates. Copyright (c) 2014, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -1045,39 +1045,22 @@ lock_sec_rec_some_has_impl( dict_index_t* index, /*!< in: secondary index */ const rec_offs* offsets)/*!< in: rec_get_offsets(rec, index) */ { - trx_t* trx; - trx_id_t max_trx_id; - const page_t* page = page_align(rec); - - lock_sys.assert_unlocked(); - ut_ad(!dict_index_is_clust(index)); - ut_ad(page_rec_is_user_rec(rec)); - ut_ad(rec_offs_validate(rec, index, offsets)); - ut_ad(!rec_is_metadata(rec, *index)); - - max_trx_id = page_get_max_trx_id(page); - - /* Some transaction may have an implicit x-lock on the record only - if the max trx id for the page >= min trx id for the trx list, or - database recovery is running. */ - - if (max_trx_id < trx_sys.get_min_trx_id()) { - - trx = 0; - - } else if (!lock_check_trx_id_sanity(max_trx_id, rec, index, offsets)) { - - /* The page is corrupt: try to avoid a crash by returning 0 */ - trx = 0; + lock_sys.assert_unlocked(); + ut_ad(!dict_index_is_clust(index)); + ut_ad(page_rec_is_user_rec(rec)); + ut_ad(rec_offs_validate(rec, index, offsets)); + ut_ad(!rec_is_metadata(rec, *index)); - /* In this case it is possible that some transaction has an implicit - x-lock. We have to look in the clustered index. */ + const trx_id_t max_trx_id= page_get_max_trx_id(page_align(rec)); - } else { - trx = row_vers_impl_x_locked(caller_trx, rec, index, offsets); - } + if ((caller_trx->id > max_trx_id && + !trx_sys.find_same_or_older(caller_trx, max_trx_id)) || + !lock_check_trx_id_sanity(max_trx_id, rec, index, offsets)) + return nullptr; - return(trx); + /* In this case it is possible that some transaction has an implicit + x-lock. We have to look in the clustered index. */ + return row_vers_impl_x_locked(caller_trx, rec, index, offsets); } /*********************************************************************//** @@ -2769,6 +2752,18 @@ lock_update_split_right( PAGE_HEAP_NO_SUPREMUM, h); } +void lock_update_node_pointer(const buf_block_t *left_block, + const buf_block_t *right_block) +{ + const ulint h= lock_get_min_heap_no(right_block); + const page_id_t l{left_block->page.id()}; + const page_id_t r{right_block->page.id()}; + LockMultiGuard g{lock_sys.rec_hash, l, r}; + + lock_rec_inherit_to_gap(g.cell2(), r, g.cell1(), l, right_block->page.frame, + h, PAGE_HEAP_NO_SUPREMUM); +} + #ifdef UNIV_DEBUG static void lock_assert_no_spatial(const page_id_t id) { @@ -4776,25 +4771,25 @@ loop: holding a tablespace latch. */ if (!latched) for (i = nth_bit; i < lock_rec_get_n_bits(lock); i++) { - - if (i == PAGE_HEAP_NO_SUPREMUM - || lock_rec_get_nth_bit(lock, i)) { + bool locked = lock_rec_get_nth_bit(lock, i); + if (locked || i == PAGE_HEAP_NO_SUPREMUM) { rec = page_find_rec_with_heap_no(block->page.frame, i); ut_a(rec); - ut_ad(!lock_rec_get_nth_bit(lock, i) - || page_rec_is_leaf(rec)); - offsets = rec_get_offsets(rec, lock->index, offsets, - lock->index->n_core_fields, - ULINT_UNDEFINED, &heap); + ut_ad(!locked || page_rec_is_leaf(rec)); /* If this thread is holding the file space latch (fil_space_t::latch), the following check WILL break the latching order and may cause a deadlock of threads. */ - lock_rec_queue_validate( - true, id, rec, lock->index, offsets); + if (locked) { + offsets = rec_get_offsets(rec, lock->index, + offsets, lock->index->n_core_fields, + ULINT_UNDEFINED, &heap); + lock_rec_queue_validate(true, id, rec, + lock->index, offsets); + } nth_bit = i + 1; @@ -4876,12 +4871,6 @@ static void lock_rec_block_validate(const page_id_t page_id) BUF_GET_POSSIBLY_FREED, &mtr, &err); - if (err != DB_SUCCESS) { - ib::error() << "Lock rec block validate failed for tablespace " - << space->chain.start->name - << page_id << " err " << err; - } - ut_ad(!block || block->page.is_freed() || lock_rec_validate_page(block, space->is_latched())); @@ -5413,7 +5402,6 @@ lock_sec_rec_read_check_and_lock( que_thr_t* thr) /*!< in: query thread */ { dberr_t err; - ulint heap_no; ut_ad(!dict_index_is_clust(index)); ut_ad(!dict_index_is_online_ddl(index)); @@ -5433,17 +5421,10 @@ lock_sec_rec_read_check_and_lock( const page_id_t id{block->page.id()}; ut_ad(!rec_is_metadata(rec, *index)); - heap_no = page_rec_get_heap_no(rec); - - /* Some transaction may have an implicit x-lock on the record only - if the max trx id for the page >= min trx id for the trx list or a - database recovery is running. */ trx_t *trx = thr_get_trx(thr); - if (!lock_table_has(trx, index->table, LOCK_X) - && !page_rec_is_supremum(rec) - && page_get_max_trx_id(block->page.frame) - >= trx_sys.get_min_trx_id() + if (!page_rec_is_supremum(rec) + && !lock_table_has(trx, index->table, LOCK_X) && lock_rec_convert_impl_to_expl(thr_get_trx(thr), id, rec, index, offsets) && gap_mode == LOCK_REC_NOT_GAP) { @@ -5464,7 +5445,7 @@ lock_sec_rec_read_check_and_lock( #endif /* WITH_WSREP */ err = lock_rec_lock(false, gap_mode | mode, - block, heap_no, index, thr); + block, page_rec_get_heap_no(rec), index, thr); #ifdef WITH_WSREP if (trx->wsrep == 3) trx->wsrep = 1; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 5eedb6a0ea7..e3ffdcc749e 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -2361,7 +2361,6 @@ row_import_set_sys_max_row_id( row_id = mach_read_from_6(rec); } - btr_pcur_close(&pcur); mtr_commit(&mtr); if (row_id) { diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 69798c33276..08f28bbad18 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1800,9 +1800,8 @@ row_ins_check_foreign_constraint( } end_scan: - btr_pcur_close(&pcur); - mtr_commit(&mtr); + ut_free(pcur.old_rec_buf); /* Restore old value */ dtuple_set_n_fields_cmp(entry, n_fields_cmp); @@ -2474,8 +2473,7 @@ row_ins_index_entry_big_rec( mtr.commit(); - btr_pcur_close(&pcur); - + ut_free(pcur.old_rec_buf); return(error); } @@ -2803,8 +2801,7 @@ func_exit: mem_heap_free(offsets_heap); } - btr_pcur_close(&pcur); - + ut_free(pcur.old_rec_buf); DBUG_RETURN(err); } @@ -2904,8 +2901,12 @@ row_ins_sec_index_entry_low( rtr_init_rtr_info(&rtr_info, false, &cursor, index, false); rtr_info_update_btr(&cursor, &rtr_info); - mtr_start(&mtr); - index->set_modified(mtr); + mtr.start(); + if (index->table->is_temporary()) { + mtr.set_log_mode(MTR_LOG_NO_REDO); + } else { + index->set_modified(mtr); + } search_mode &= ulint(~BTR_MODIFY_LEAF); search_mode |= BTR_MODIFY_TREE; err = btr_cur_search_to_nth_level( @@ -3141,9 +3142,6 @@ row_ins_clust_index_entry( #endif /* WITH_WSREP */ const ulint orig_n_fields = entry->n_fields; - /* Try first optimistic descent to the B-tree */ - log_free_check(); - /* For intermediate table during copy alter table, skip the undo log and record lock checking for insertion operation. diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index a0805b27adf..f45d4253d73 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -3829,7 +3829,7 @@ UndorecApplier::get_old_rec(const dtuple_t &tuple, dict_index_t *index, return version; trx_undo_prev_version_build(*clust_rec, &mtr, version, index, *offsets, heap, &prev_version, nullptr, - nullptr, 0, block); + nullptr, 0); version= prev_version; } while (version); @@ -3983,7 +3983,7 @@ void UndorecApplier::log_update(const dtuple_t &tuple, heap, rec_offs_size(offsets)), match_rec, offsets); trx_undo_prev_version_build(rec, &mtr, match_rec, clust_index, offsets, heap, &prev_version, nullptr, - nullptr, 0, block); + nullptr, 0); prev_offsets= rec_get_offsets(prev_version, clust_index, prev_offsets, clust_index->n_core_fields, diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 8a36b03f4a5..da8d2cd66ff 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2987,8 +2987,7 @@ wait_again: row_fts_free_pll_merge_buf(psort_info); ut_free(merge_buf); - - btr_pcur_close(&pcur); + ut_free(pcur.old_rec_buf); if (sp_tuples != NULL) { for (ulint i = 0; i < num_spatial; i++) { diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index f77856f8406..5aa42392213 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -504,10 +504,7 @@ row_purge_remove_sec_if_poss_leaf( btr_cur_get_rec(btr_cur), index); ut_ad(0); - - btr_pcur_close(&pcur); - - goto func_exit_no_pcur; + goto func_exit; } if (index->is_spatial()) { @@ -532,10 +529,7 @@ row_purge_remove_sec_if_poss_leaf( "skip purging last" " record on page " << block->page.id()); - - btr_pcur_close(&pcur); - mtr.commit(); - return(success); + goto func_exit; } } @@ -555,9 +549,9 @@ row_purge_remove_sec_if_poss_leaf( /* The deletion was buffered. */ case ROW_NOT_FOUND: /* The index entry does not exist, nothing to do. */ - btr_pcur_close(&pcur); // FIXME: do we need these? when is btr_cur->rtr_info set? -func_exit_no_pcur: +func_exit: mtr.commit(); + btr_pcur_close(&pcur); // FIXME: do we need these? when is btr_cur->rtr_info set? return(success); } diff --git a/storage/innobase/row/row0row.cc b/storage/innobase/row/row0row.cc index 4cd1c3a4d26..b83b0ab1fef 100644 --- a/storage/innobase/row/row0row.cc +++ b/storage/innobase/row/row0row.cc @@ -1260,8 +1260,6 @@ row_get_clust_rec( dtuple_t* ref; dict_table_t* table; btr_pcur_t pcur; - ibool found; - rec_t* clust_rec; ut_ad(!dict_index_is_clust(index)); @@ -1271,17 +1269,12 @@ row_get_clust_rec( ref = row_build_row_ref(ROW_COPY_POINTERS, index, rec, heap); - found = row_search_on_row_ref(&pcur, mode, table, ref, mtr); - - clust_rec = found ? btr_pcur_get_rec(&pcur) : NULL; + auto found = row_search_on_row_ref(&pcur, mode, table, ref, mtr); mem_heap_free(heap); - btr_pcur_close(&pcur); - *clust_index = dict_table_get_first_index(table); - - return(clust_rec); + return found ? btr_pcur_get_rec(&pcur) : nullptr; } /***************************************************************//** diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 5e6c4e17f3b..48647fcb622 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -6132,8 +6132,6 @@ row_search_get_max_rec( rec = nullptr; found: - btr_pcur_close(&pcur); - ut_ad(!rec || !(rec_get_info_bits(rec, dict_table_is_comp(index->table)) & (REC_INFO_MIN_REC_FLAG | REC_INFO_DELETED_FLAG))); diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index cd576e86da9..b2069b11f0f 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -272,18 +272,6 @@ static monitor_info_t innodb_counter_info[] = MONITOR_EXISTING | MONITOR_DEFAULT_ON), MONITOR_DEFAULT_START, MONITOR_OVLD_PAGES_WRITTEN}, - {"buffer_index_pages_written", "buffer", - "Number of index pages written (innodb_index_pages_written)", - static_cast<monitor_type_t>( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_INDEX_PAGES_WRITTEN}, - - {"buffer_non_index_pages_written", "buffer", - "Number of non index pages written (innodb_non_index_pages_written)", - static_cast<monitor_type_t>( - MONITOR_EXISTING | MONITOR_DEFAULT_ON), - MONITOR_DEFAULT_START, MONITOR_OVLD_NON_INDEX_PAGES_WRITTEN}, - {"buffer_pages_read", "buffer", "Number of pages read (innodb_pages_read)", static_cast<monitor_type_t>( @@ -1468,16 +1456,6 @@ srv_mon_process_existing_counter( value = buf_pool.stat.n_pages_written; break; - /* innodb_index_pages_written, the number of index pages written */ - case MONITOR_OVLD_INDEX_PAGES_WRITTEN: - value = srv_stats.index_pages_written; - break; - - /* innodb_non_index_pages_written, the number of non index pages written */ - case MONITOR_OVLD_NON_INDEX_PAGES_WRITTEN: - value = srv_stats.non_index_pages_written; - break; - case MONITOR_LRU_BATCH_FLUSH_TOTAL_PAGE: value = buf_lru_flush_page_count; break; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index ac3e101b515..b36cdef9433 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1109,8 +1109,6 @@ srv_export_innodb_status(void) srv_truncated_status_writes; export_vars.innodb_page_compression_saved = srv_stats.page_compression_saved; - export_vars.innodb_index_pages_written = srv_stats.index_pages_written; - export_vars.innodb_non_index_pages_written = srv_stats.non_index_pages_written; export_vars.innodb_pages_page_compressed = srv_stats.pages_page_compressed; export_vars.innodb_page_compressed_trim_op = srv_stats.page_compressed_trim_op; export_vars.innodb_pages_page_decompressed = srv_stats.pages_page_decompressed; @@ -1155,8 +1153,6 @@ srv_export_innodb_status(void) crypt_stat.estimated_iops; export_vars.innodb_encryption_key_requests = srv_stats.n_key_requests; - export_vars.innodb_key_rotation_list_length = - srv_stats.key_rotation_list_length; } mysql_mutex_unlock(&srv_innodb_monitor_mutex); diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 2d289245ca3..35ba37c6629 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -2237,15 +2237,12 @@ err_exit: /** Copy an undo record to heap. @param[in] roll_ptr roll pointer to a record that exists -@param[in,out] heap memory heap where copied -@param[in] undo_block undo log block which was cached during - DML online log apply */ +@param[in,out] heap memory heap where copied */ static trx_undo_rec_t* trx_undo_get_undo_rec_low( roll_ptr_t roll_ptr, - mem_heap_t* heap, - const buf_block_t* undo_block= nullptr) + mem_heap_t* heap) { trx_undo_rec_t* undo_rec; ulint rseg_id; @@ -2261,21 +2258,15 @@ trx_undo_get_undo_rec_low( trx_rseg_t* rseg = &trx_sys.rseg_array[rseg_id]; ut_ad(rseg->is_persistent()); - if (undo_block - && undo_block->page.id().page_no() == page_no) { - undo_rec = trx_undo_rec_copy( - undo_block->page.frame + offset, heap); - } else { - mtr.start(); + mtr.start(); - buf_block_t *undo_page = trx_undo_page_get_s_latched( - page_id_t(rseg->space->id, page_no), &mtr); + buf_block_t *undo_page = trx_undo_page_get_s_latched( + page_id_t(rseg->space->id, page_no), &mtr); - undo_rec = trx_undo_rec_copy( - undo_page->page.frame + offset, heap); + undo_rec = trx_undo_rec_copy( + undo_page->page.frame + offset, heap); - mtr.commit(); - } + mtr.commit(); return(undo_rec); } @@ -2288,8 +2279,6 @@ trx_undo_get_undo_rec_low( undo log of this transaction @param[in] name table name @param[out] undo_rec own: copy of the record -@param[in] undo_block undo log block which was cached during - DML online log apply @retval true if the undo log has been truncated and we cannot fetch the old version @retval false if the undo log record is available @@ -2301,15 +2290,13 @@ trx_undo_get_undo_rec( mem_heap_t* heap, trx_id_t trx_id, const table_name_t& name, - trx_undo_rec_t** undo_rec, - const buf_block_t* undo_block) + trx_undo_rec_t** undo_rec) { purge_sys.latch.rd_lock(SRW_LOCK_CALL); bool missing_history = purge_sys.changes_visible(trx_id, name); if (!missing_history) { - *undo_rec = trx_undo_get_undo_rec_low( - roll_ptr, heap, undo_block); + *undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap); } purge_sys.latch.rd_unlock(); @@ -2363,8 +2350,7 @@ trx_undo_prev_version_build( rec_t **old_vers, mem_heap_t *v_heap, dtuple_t **vrow, - ulint v_status, - const buf_block_t*undo_block) + ulint v_status) { trx_undo_rec_t* undo_rec = NULL; dtuple_t* entry; @@ -2403,7 +2389,7 @@ trx_undo_prev_version_build( if (trx_undo_get_undo_rec( roll_ptr, heap, rec_trx_id, index->table->name, - &undo_rec, undo_block)) { + &undo_rec)) { if (v_status & TRX_UNDO_PREV_IN_PURGE) { /* We are fetching the record being purged */ undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap); diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 13f5f3b09a2..a0b14635f8c 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -290,10 +290,12 @@ trx_undo_get_first_rec(const fil_space_t &space, uint32_t page_no, mtr); } -void UndorecApplier::assign_rec(trx_undo_rec_t *rec) +inline void UndorecApplier::assign_rec(const buf_block_t &block, + uint16_t offset) { - this->undo_rec= rec; - this->offset= page_offset(rec); + ut_ad(block.page.lock.have_s()); + this->offset= offset; + this->undo_rec= trx_undo_rec_copy(block.page.frame + offset, heap); } void UndorecApplier::apply_undo_rec() @@ -355,12 +357,11 @@ ATTRIBUTE_COLD void trx_t::apply_log() page_id_t page_id{rsegs.m_redo.rseg->space->id, undo->hdr_page_no}; page_id_t next_page_id(page_id); mtr_t mtr; - mem_heap_t *heap= mem_heap_create(100); mtr.start(); buf_block_t *block= buf_page_get(page_id, 0, RW_S_LATCH, &mtr); ut_ad(block); - UndorecApplier log_applier(block, id); + UndorecApplier log_applier(page_id, id); for (;;) { @@ -368,9 +369,12 @@ ATTRIBUTE_COLD void trx_t::apply_log() undo->hdr_offset); while (rec) { - log_applier.assign_rec(rec); + log_applier.assign_rec(*block, page_offset(rec)); + mtr.commit(); log_applier.apply_undo_rec(); - rec= trx_undo_page_get_next_rec(block, page_offset(rec), + mtr.start(); + block= buf_page_get(log_applier.get_page_id(), 0, RW_S_LATCH, &mtr); + rec= trx_undo_page_get_next_rec(block, log_applier.get_offset(), page_id.page_no(), undo->hdr_offset); } @@ -382,12 +386,11 @@ ATTRIBUTE_COLD void trx_t::apply_log() next_page_id.set_page_no(next); mtr.commit(); mtr.start(); - block= buf_page_get(next_page_id, 0, RW_S_LATCH, &mtr); - log_applier.assign_block(block); + block= buf_page_get_gen(next_page_id, 0, RW_S_LATCH, block, BUF_GET, &mtr); + log_applier.assign_next(next_page_id); ut_ad(block); } mtr.commit(); - mem_heap_free(heap); apply_online_log= false; } diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc index 6b9c6a7e066..71a058273f7 100644 --- a/storage/perfschema/pfs_engine_table.cc +++ b/storage/perfschema/pfs_engine_table.cc @@ -731,7 +731,8 @@ static bool allow_drop_table_privilege() { assert(thd->lex != NULL); if ((thd->lex->sql_command != SQLCOM_TRUNCATE) && - (thd->lex->sql_command != SQLCOM_GRANT)) { + (thd->lex->sql_command != SQLCOM_GRANT) && + (thd->lex->sql_command != SQLCOM_REVOKE)) { return false; } diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result index e12f9344ce9..45c87cc7313 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result @@ -51,8 +51,6 @@ buffer_pool_bytes_dirty buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL buffer_pool_pages_free buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Buffer pages currently free (innodb_buffer_pool_pages_free) buffer_pages_created buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages created (innodb_pages_created) buffer_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages written (innodb_pages_written) -buffer_index_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of index pages written (innodb_index_pages_written) -buffer_non_index_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of non index pages written (innodb_non_index_pages_written) buffer_pages_read buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of pages read (innodb_pages_read) buffer_index_sec_rec_cluster_reads buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of secondary record reads triggered cluster read buffer_index_sec_rec_cluster_reads_avoided buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of secondary record reads avoided triggering cluster read diff --git a/storage/spider/mysql-test/spider/r/variable_deprecation.result b/storage/spider/mysql-test/spider/r/variable_deprecation.result index 39b7f9d320a..316f0a4883e 100644 --- a/storage/spider/mysql-test/spider/r/variable_deprecation.result +++ b/storage/spider/mysql-test/spider/r/variable_deprecation.result @@ -150,6 +150,21 @@ Warnings: Warning 1287 The table parameter 'crd_weight' is deprecated and will be removed in a future release DROP TABLE tbl_a; DROP TABLE tbl_b; +# MDEV-28560 Deprecate spider_buffer_size +SET spider_buffer_size = 1; +Warnings: +Warning 1287 '@@spider_buffer_size' is deprecated and will be removed in a future release +SHOW VARIABLES LIKE "spider_buffer_size"; +Variable_name Value +spider_buffer_size 1 +CREATE TABLE tbl_a (a INT) ENGINE=Spider COMMENT='bfz "1"'; +Warnings: +Warning 1287 The table parameter 'bfz' is deprecated and will be removed in a future release +CREATE TABLE tbl_b (a INT) ENGINE=Spider COMMENT='buffer_size "1"'; +Warnings: +Warning 1287 The table parameter 'buffer_size' is deprecated and will be removed in a future release +DROP TABLE tbl_a; +DROP TABLE tbl_b; DROP DATABASE auto_test_local; for master_1 for child2 diff --git a/storage/spider/mysql-test/spider/t/variable_deprecation.test b/storage/spider/mysql-test/spider/t/variable_deprecation.test index c115e8fbec3..f4fccdb841b 100644 --- a/storage/spider/mysql-test/spider/t/variable_deprecation.test +++ b/storage/spider/mysql-test/spider/t/variable_deprecation.test @@ -92,6 +92,15 @@ eval CREATE TABLE tbl_b (a INT) $MASTER_1_ENGINE COMMENT='crd_weight "1"'; DROP TABLE tbl_a; DROP TABLE tbl_b; +--echo # MDEV-28560 Deprecate spider_buffer_size +SET spider_buffer_size = 1; +SHOW VARIABLES LIKE "spider_buffer_size"; +eval CREATE TABLE tbl_a (a INT) $MASTER_1_ENGINE COMMENT='bfz "1"'; +eval CREATE TABLE tbl_b (a INT) $MASTER_1_ENGINE COMMENT='buffer_size "1"'; + +DROP TABLE tbl_a; +DROP TABLE tbl_b; + DROP DATABASE auto_test_local; --disable_query_log diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index efa524cfd46..fcfb7239b8c 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -3719,27 +3719,15 @@ int spider_db_mbase::append_lock_tables( conn_link_idx = tmp_spider->conn_link_idx[tmp_link_idx]; spider_mbase_share *db_share = (spider_mbase_share *) tmp_spider->share->dbton_share[conn->dbton_id]; - if (&db_share->db_names_str[conn_link_idx]) - { - db_name = db_share->db_names_str[conn_link_idx].ptr(); - db_name_length = db_share->db_names_str[conn_link_idx].length(); - db_name_charset = tmp_spider->share->access_charset; - } else { - db_name = tmp_spider->share->tgt_dbs[conn_link_idx]; - db_name_length = tmp_spider->share->tgt_dbs_lengths[conn_link_idx]; - db_name_charset = system_charset_info; - } - if (&db_share->table_names_str[conn_link_idx]) - { - table_name = db_share->table_names_str[conn_link_idx].ptr(); - table_name_length = db_share->table_names_str[conn_link_idx].length(); - table_name_charset = tmp_spider->share->access_charset; - } else { - table_name = tmp_spider->share->tgt_table_names[conn_link_idx]; - table_name_length = - tmp_spider->share->tgt_table_names_lengths[conn_link_idx]; - table_name_charset = system_charset_info; - } + + db_name = db_share->db_names_str[conn_link_idx].ptr(); + db_name_length = db_share->db_names_str[conn_link_idx].length(); + db_name_charset = tmp_spider->share->access_charset; + + table_name = db_share->table_names_str[conn_link_idx].ptr(); + table_name_length = db_share->table_names_str[conn_link_idx].length(); + table_name_charset = tmp_spider->share->access_charset; + if ((error_num = spider_db_mbase_utility-> append_lock_table_body( str, diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index d129006ced8..1147840ba78 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -1000,7 +1000,7 @@ int spider_param_bulk_update_size( */ static MYSQL_THDVAR_INT( buffer_size, /* name */ - PLUGIN_VAR_RQCMDARG, /* opt */ + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_DEPRECATED, /* opt */ "Buffer size", /* comment */ NULL, /* check */ spider_use_table_value_deprecated, /* update */ diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index d3ba8356b40..9768963dd3a 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -2218,6 +2218,7 @@ int spider_parse_connect_info( 2147483647); SPIDER_PARAM_INT_WITH_MAX("aim", auto_increment_mode, 0, 3); SPIDER_PARAM_INT("alc", active_link_count, 1); + SPIDER_PARAM_DEPRECATED_WARNING("bfz"); SPIDER_PARAM_INT("bfz", buffer_size, 0); SPIDER_PARAM_LONGLONG("bfr", bgs_first_read, 0); SPIDER_PARAM_INT("bmd", bgs_mode, 0); @@ -2416,6 +2417,7 @@ int spider_parse_connect_info( SPIDER_PARAM_DEPRECATED_WARNING("use_handler"); SPIDER_PARAM_LONG_LIST_WITH_MAX("use_handler", use_handlers, 0, 3); SPIDER_PARAM_INT_WITH_MAX("casual_read", casual_read, 0, 63); + SPIDER_PARAM_DEPRECATED_WARNING("buffer_size"); SPIDER_PARAM_INT("buffer_size", buffer_size, 0); error_num = connect_string_parse.print_param_error(); goto error; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 73efe74367d..094c02618d0 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -33849,7 +33849,7 @@ static void my_uca_handler_map(struct charset_info_st *cs, #define MY_UCA_ASCII_OPTIMIZE 0 #define MY_UCA_COMPILE_CONTRACTIONS 1 #define MY_UCA_COLL_INIT my_coll_init_uca -#include "ctype-uca.ic" +#include "ctype-uca.inl" /* @@ -33954,7 +33954,7 @@ ex: #define MY_UCA_ASCII_OPTIMIZE 0 #define MY_UCA_COMPILE_CONTRACTIONS 1 #define MY_UCA_COLL_INIT my_coll_init_uca -#include "ctype-uca.ic" +#include "ctype-uca.inl" #define MY_CS_UCS2_UCA_FLAGS (MY_CS_COMMON_UCA_FLAGS|MY_CS_NONASCII) #define MY_CS_UCS2_UCA_NOPAD_FLAGS (MY_CS_UCS2_UCA_FLAGS|MY_CS_NOPAD) @@ -34916,7 +34916,7 @@ my_uca_coll_init_utf8mb3(struct charset_info_st *cs, MY_CHARSET_LOADER *loader); #define MY_UCA_ASCII_OPTIMIZE 1 #define MY_UCA_COMPILE_CONTRACTIONS 1 #define MY_UCA_COLL_INIT my_uca_coll_init_utf8mb3 -#include "ctype-uca.ic" +#include "ctype-uca.inl" #define MY_FUNCTION_NAME(x) my_uca_ ## x ## _no_contractions_utf8mb3 #define MY_MB_WC(scanner, wc, beg, end) (my_mb_wc_utf8mb3_quick(wc, beg, end)) @@ -34924,7 +34924,7 @@ my_uca_coll_init_utf8mb3(struct charset_info_st *cs, MY_CHARSET_LOADER *loader); #define MY_UCA_ASCII_OPTIMIZE 1 #define MY_UCA_COMPILE_CONTRACTIONS 0 #define MY_UCA_COLL_INIT my_uca_coll_init_utf8mb3 -#include "ctype-uca.ic" +#include "ctype-uca.inl" static my_bool @@ -35921,7 +35921,7 @@ my_uca_coll_init_utf8mb4(struct charset_info_st *cs, MY_CHARSET_LOADER *loader); #define MY_UCA_ASCII_OPTIMIZE 1 #define MY_UCA_COMPILE_CONTRACTIONS 1 #define MY_UCA_COLL_INIT my_uca_coll_init_utf8mb4 -#include "ctype-uca.ic" +#include "ctype-uca.inl" #define MY_FUNCTION_NAME(x) my_uca_ ## x ## _no_contractions_utf8mb4 #define MY_MB_WC(scanner, wc, beg, end) (my_mb_wc_utf8mb4_quick(wc, beg, end)) @@ -35929,7 +35929,7 @@ my_uca_coll_init_utf8mb4(struct charset_info_st *cs, MY_CHARSET_LOADER *loader); #define MY_UCA_ASCII_OPTIMIZE 1 #define MY_UCA_COMPILE_CONTRACTIONS 0 #define MY_UCA_COLL_INIT my_uca_coll_init_utf8mb4 -#include "ctype-uca.ic" +#include "ctype-uca.inl" static my_bool @@ -36897,7 +36897,7 @@ struct charset_info_st my_charset_utf8mb4_unicode_520_nopad_ci= #define MY_UCA_ASCII_OPTIMIZE 0 #define MY_UCA_COMPILE_CONTRACTIONS 1 #define MY_UCA_COLL_INIT my_coll_init_uca -#include "ctype-uca.ic" +#include "ctype-uca.inl" extern MY_CHARSET_HANDLER my_charset_utf32_handler; @@ -37854,7 +37854,7 @@ struct charset_info_st my_charset_utf32_unicode_520_nopad_ci= #define MY_UCA_ASCII_OPTIMIZE 0 #define MY_UCA_COMPILE_CONTRACTIONS 1 #define MY_UCA_COLL_INIT my_coll_init_uca -#include "ctype-uca.ic" +#include "ctype-uca.inl" extern MY_CHARSET_HANDLER my_charset_utf16_handler; diff --git a/strings/ctype-uca.ic b/strings/ctype-uca.inl index 6cf31ace11a..6cf31ace11a 100644 --- a/strings/ctype-uca.ic +++ b/strings/ctype-uca.inl diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index d66ab814f4d..bfa7f296300 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -100,6 +100,7 @@ DBUG_PRINT("test", ("name: %s", str)); \ fprintf(stdout, "%u of (%u/%u): %s", test_count++, iter_count, \ opt_count, str); \ fprintf(stdout, " \n#####################################\n"); \ + fflush(stdout); \ } #define myheader_r(str) \ @@ -109,6 +110,7 @@ DBUG_PRINT("test", ("name: %s", str)); \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%s", str); \ fprintf(stdout, " \n#####################################\n"); \ + fflush(stdout); \ } static void print_error(const char *msg); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index c67583958ea..0f32477bcf8 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -20244,6 +20244,7 @@ static void test_proxy_header_tcp(const char *ipaddr, int port) // normalize IPv4-mapped IPv6 addresses, e.g ::ffff:127.0.0.2 to 127.0.0.2 const char *normalized_addr= strncmp(ipaddr, "::ffff:", 7)?ipaddr : ipaddr + 7; + myheader("test_proxy_header_tcp"); memset(&v2_header, 0, sizeof(v2_header)); sprintf(text_header,"PROXY %s %s %s %d 3306\r\n",family == AF_INET?"TCP4":"TCP6", ipaddr, ipaddr, port); @@ -20322,6 +20323,7 @@ static void test_proxy_header_localhost() MYSQL_RES *result; MYSQL_ROW row; int rc; + myheader("test_proxy_header_localhost"); memset(&v2_header, 0, sizeof(v2_header)); memcpy(v2_header.sig, "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A", 12); @@ -20354,6 +20356,7 @@ static void test_proxy_header_ignore() int rc; MYSQL *m = mysql_client_init(NULL); v2_proxy_header v2_header; + myheader("test_ps_params_in_ctes"); DIE_UNLESS(m != NULL); mysql_optionsv(m, MARIADB_OPT_PROXY_HEADER, "PROXY UNKNOWN\r\n",15); DIE_UNLESS(mysql_real_connect(m, opt_host, "root", "", NULL, opt_port, opt_unix_socket, 0) == m); @@ -20384,6 +20387,7 @@ static void test_proxy_header_ignore() static void test_proxy_header() { + myheader("test_proxy_header"); test_proxy_header_tcp("192.0.2.1",3333); test_proxy_header_tcp("2001:db8:85a3::8a2e:370:7334",2222); test_proxy_header_tcp("::ffff:192.0.2.1",2222); @@ -20403,6 +20407,7 @@ static void test_bulk_autoinc() int i, id[]= {2, 3, 777}, count= sizeof(id)/sizeof(id[0]); MYSQL_RES *result; + myheader("test_bulk_autoinc"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS ai_field_value"); myquery(rc); rc= mysql_query(mysql, "CREATE TABLE ai_field_value (id int not null primary key auto_increment)"); @@ -20456,6 +20461,7 @@ static void test_bulk_delete() int i, id[]= {1, 2, 4}, count= sizeof(id)/sizeof(id[0]); MYSQL_RES *result; + myheader("test_bulk_delete"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (id int not null primary key)"); @@ -20518,6 +20524,7 @@ static void test_bulk_replace() count= sizeof(id)/sizeof(id[0]); MYSQL_RES *result; + myheader("test_bulk_replace"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (id int not null primary key, active int)"); @@ -20748,6 +20755,7 @@ static void test_ps_params_in_ctes() int int_data[1]; MYSQL_STMT *stmt; + myheader("test_ps_params_in_ctes"); rc= mysql_query(mysql, "create table t1(a int, b int, key(a))"); myquery(rc); diff --git a/tpool/aio_liburing.cc b/tpool/aio_liburing.cc index 8192a5b7fed..a4a899d08d4 100644 --- a/tpool/aio_liburing.cc +++ b/tpool/aio_liburing.cc @@ -52,7 +52,8 @@ public: case ENOSYS: my_printf_error(ER_UNKNOWN_ERROR, "io_uring_queue_init() failed with ENOSYS:" - " try uprading the kernel", + " check seccomp filters, and the kernel version " + "(newer than 5.1 required)", ME_ERROR_LOG | ME_WARNING); break; default: diff --git a/win/packaging/ca/CustomAction.cpp b/win/packaging/ca/CustomAction.cpp index 328e73accb8..dbd0b36745f 100644 --- a/win/packaging/ca/CustomAction.cpp +++ b/win/packaging/ca/CustomAction.cpp @@ -664,6 +664,12 @@ unsigned long long GetMaxBufferSize(unsigned long long totalPhys) /* + Magic undocumented number for bufferpool minimum, + allows innodb to start also for all page sizes. +*/ +static constexpr unsigned long long minBufferpoolMB= 20; + +/* Checks SERVICENAME, PORT and BUFFERSIZE parameters */ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) @@ -791,34 +797,37 @@ extern "C" UINT __stdcall CheckDatabaseProperties (MSIHANDLE hInstall) unsigned long long availableMemory= GetMaxBufferSize(memstatus.ullTotalPhys)/ONE_MB; swprintf_s(invalidValueMsg, - L"Invalid buffer pool size. Please use a number between 1 and %llu", - availableMemory); - if(BufferPoolSizeLen == 0 || BufferPoolSizeLen > 15) + L"Invalid buffer pool size. Please use a number between %llu and %llu", + minBufferpoolMB, availableMemory); + if (BufferPoolSizeLen == 0 || BufferPoolSizeLen > 15 || !BufferPoolSize[0]) { ErrorMsg= invalidValueMsg; goto LExit; } - for (DWORD i=0; i < BufferPoolSizeLen && BufferPoolSize[BufferPoolSizeLen]; - i++) - { - if(BufferPoolSize[i]< '0' || BufferPoolSize[i] > '9') - { - ErrorMsg= invalidValueMsg; - goto LExit; - } - } + BufferPoolSize[BufferPoolSizeLen]=0; MsiSetPropertyW(hInstall, L"BUFFERPOOLSIZE", BufferPoolSize); - long long sz = _wtoi64(BufferPoolSize); - if(sz <= 0 || sz > (long long)availableMemory) + wchar_t *end; + unsigned long long sz = wcstoull(BufferPoolSize, &end, 10); + if (sz > availableMemory || sz < minBufferpoolMB || *end) { - if(sz > 0) + if (*end == 0) { - swprintf_s(invalidValueMsg, - L"Value for buffer pool size is too large." - L"Only approximately %llu MB is available for allocation." - L"Please use a number between 1 and %llu.", - availableMemory, availableMemory); + if(sz > availableMemory) + { + swprintf_s(invalidValueMsg, + L"Value for buffer pool size is too large." + L"Only approximately %llu MB is available for allocation." + L"Please use a number between %llu and %llu.", + availableMemory, minBufferpoolMB, availableMemory); + } + else if(sz < minBufferpoolMB) + { + swprintf_s(invalidValueMsg, + L"Value for buffer pool size is too small." + L"Please use a number between %llu and %llu.", + minBufferpoolMB, availableMemory); + } } ErrorMsg= invalidValueMsg; goto LExit; diff --git a/wsrep-lib b/wsrep-lib -Subproject edd141127c11d78ef073f9f3ca61708821f20b3 +Subproject 8bfce04189671eb1f06e0fa83dff8c880f31088 |