1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge branch '10.7' into 10.8

This commit is contained in:
Oleksandr Byelkin
2022-02-04 14:50:25 +01:00
907 changed files with 20182 additions and 6211 deletions

2
.gitattributes vendored
View File

@ -30,7 +30,7 @@ pcre/testdata/greppatN4 -text
*.c diff=cpp
*.h diff=cpp
*.cc diff=cpp
*.ic diff=cpp
*.inl diff=cpp
*.cpp diff=cpp
*.java diff=cpp

View File

@ -419,6 +419,10 @@ IF(WITH_UNIT_TESTS)
ENDIF()
ENDIF()
INCLUDE(cpack_tgz)
INCLUDE(cpack_rpm)
INCLUDE(cpack_deb)
UNSET (MYSQLD_STATIC_PLUGIN_LIBS CACHE)
INCLUDE(mariadb_connector_c) # this does ADD_SUBDIRECTORY(libmariadb)

View File

@ -1,15 +1,5 @@
init:
# Install bison
- choco feature disable --name showDownloadProgress
- choco install -y winflexbison
- C:\ProgramData\chocolatey\lib\winflexbison\tools\win_bison.exe --version
version: build-{build}~branch-{branch}
cache:
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml
clone_depth: 1
build_script:
@ -26,8 +16,8 @@ build_script:
- cd _build
- set BUILD_TYPE=MinSizeRel
- set GENERATOR=-GNinja
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
- cmake -E time cmake %GENERATOR% .. -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DMYSQL_MAINTAINER_MODE=ERR -DFAST_BUILD=1 -DBISON_EXECUTABLE=C:\ProgramData\chocolatey\lib\winflexbison\tools\win_bison.exe -DPLUGIN_PERFSCHEMA=NO -DPLUGIN_FEEDBACK=NO
- call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
- cmake -E time cmake %GENERATOR% .. -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DMYSQL_MAINTAINER_MODE=ERR -DFAST_BUILD=1 -DBISON_EXECUTABLE=C:\cygwin64\bin\bison.exe -DPLUGIN_PERFSCHEMA=NO -DPLUGIN_FEEDBACK=NO
- set /A jobs=2*%NUMBER_OF_PROCESSORS%
- cmake -E time cmake --build . -j %jobs% --config %BUILD_TYPE% --target minbuild
@ -37,4 +27,4 @@ test_script:
- set /A parallel=4*%NUMBER_OF_PROCESSORS%
- perl mysql-test-run.pl --force --max-test-fail=10 --retry=2 -parallel=%parallel% --testcase-timeout=4 --suite=main --skip-test-list=%APPVEYOR_BUILD_FOLDER%\win\appveyor_skip_tests.txt --mysqld=--loose-innodb-flush-log-at-trx-commit=2
image: Visual Studio 2019
image: Visual Studio 2022

View File

@ -101,6 +101,7 @@ enum options_client
OPT_SSL_CRL, OPT_SSL_CRLPATH,
OPT_IGNORE_DATA,
OPT_PRINT_ROW_COUNT, OPT_PRINT_ROW_EVENT_POSITIONS,
OPT_CHECK_IF_UPGRADE_NEEDED,
OPT_SHUTDOWN_WAIT_FOR_SLAVES,
OPT_COPY_S3_TABLES,
OPT_PRINT_TABLE_METADATA,

View File

@ -22,7 +22,7 @@
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
#define VER "1.4"
#define VER "2.0"
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
@ -37,13 +37,15 @@
#endif
static int phase = 0;
static int info_file= -1;
static const int phases_total = 7;
static char mysql_path[FN_REFLEN];
static char mysqlcheck_path[FN_REFLEN];
static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag,
static my_bool debug_info_flag, debug_check_flag,
opt_systables_only, opt_version_check;
static my_bool opt_not_used, opt_silent;
static my_bool opt_not_used, opt_silent, opt_check_upgrade;
static uint opt_force, opt_verbose;
static uint my_end_arg= 0;
static char *opt_user= (char*)"root";
@ -96,8 +98,8 @@ static struct my_option my_long_options[]=
{"debug", '#', "This is a non-debug version. Catch this and exit.",
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else
{"debug", '#', "Output debug log.", &default_dbug_option,
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
&debug_check_flag, &debug_check_flag,
@ -111,9 +113,13 @@ static struct my_option my_long_options[]=
"Default authentication client-side plugin to use.",
&opt_default_auth, &opt_default_auth, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"check-if-upgrade-is-needed", OPT_CHECK_IF_UPGRADE_NEEDED,
"Exits with status 0 if an upgrades is required, 1 otherwise.",
&opt_check_upgrade, &opt_check_upgrade,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
"has already been executed for the current version of MariaDB.",
&opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
&opt_not_used, &opt_not_used, 0 , GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#define PASSWORD_OPT 12
@ -191,6 +197,12 @@ static void free_used_memory(void)
dynstr_free(&ds_plugin_data_types);
if (cnf_file_path)
my_delete(cnf_file_path, MYF(MY_WME));
if (info_file >= 0)
{
(void) my_lock(info_file, F_UNLCK, 0, 1, MYF(0));
my_close(info_file, MYF(MY_WME));
info_file= -1;
}
}
@ -236,6 +248,13 @@ static void verbose(const char *fmt, ...)
}
static void print_error(const char *error_msg, DYNAMIC_STRING *output)
{
fprintf(stderr, "%s\n", error_msg);
fprintf(stderr, "%s", output->str);
}
/*
Add one option - passed to mysql_upgrade on command line
or by defaults file(my.cnf) - to a dynamic string, in
@ -269,6 +288,7 @@ static void add_one_option_cnf_file(DYNAMIC_STRING *ds,
dynstr_append(ds, "\n");
}
static my_bool
get_one_option(const struct my_option *opt, const char *argument,
const char *filename __attribute__((unused)))
@ -344,11 +364,17 @@ get_one_option(const struct my_option *opt, const char *argument,
my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
die(0);
break;
case 'f': /* --force */
opt_force++;
if (argument == disabled_my_option)
opt_force= 0;
add_option= 0;
break;
case OPT_SILENT:
opt_verbose= 0;
add_option= 0;
break;
case 'f': /* --force */
case OPT_CHECK_IF_UPGRADE_NEEDED: /* --check-if-upgrade-needed */
case 's': /* --upgrade-system-tables */
case OPT_WRITE_BINLOG: /* --write-binlog */
add_option= FALSE;
@ -378,6 +404,18 @@ get_one_option(const struct my_option *opt, const char *argument,
}
/* Convert the specified version string into the numeric format. */
static ulong STDCALL calc_server_version(char *some_version)
{
uint major, minor, version;
char *point= some_version, *end_point;
major= (uint) strtoul(point, &end_point, 10); point=end_point+1;
minor= (uint) strtoul(point, &end_point, 10); point=end_point+1;
version= (uint) strtoul(point, &end_point, 10);
return (ulong) major * 10000L + (ulong)(minor * 100 + version);
}
/**
Run a command using the shell, storing its output in the supplied dynamic
string.
@ -584,7 +622,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
if (my_write(fd, sql_log_bin, sizeof(sql_log_bin)-1,
MYF(MY_FNABP | MY_WME)))
{
my_close(fd, MYF(0));
my_close(fd, MYF(MY_WME));
my_delete(query_file_path, MYF(0));
die("Failed to write to '%s'", query_file_path);
}
@ -593,7 +631,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
if (my_write(fd, (uchar*) query, strlen(query),
MYF(MY_FNABP | MY_WME)))
{
my_close(fd, MYF(0));
my_close(fd, MYF(MY_WME));
my_delete(query_file_path, MYF(0));
die("Failed to write to '%s'", query_file_path);
}
@ -610,7 +648,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
"2>&1",
NULL);
my_close(fd, MYF(0));
my_close(fd, MYF(MY_WME));
my_delete(query_file_path, MYF(0));
DBUG_RETURN(ret);
@ -657,6 +695,9 @@ static int get_upgrade_info_file_name(char* name)
&ds_datadir, FALSE) ||
extract_variable_from_show(&ds_datadir, name))
{
print_error("Reading datadir from the MariaDB server failed. Got the "
"following error when executing the 'mysql' command line client",
&ds_datadir);
dynstr_free(&ds_datadir);
DBUG_RETURN(1); /* Query failed */
}
@ -668,6 +709,83 @@ static int get_upgrade_info_file_name(char* name)
DBUG_RETURN(0);
}
static char upgrade_info_file[FN_REFLEN]= {0};
/*
Open or create mysql_upgrade_info file in servers data dir.
Take a lock to ensure there cannot be any other mysql_upgrades
runninc concurrently
*/
const char *create_error_message=
"%sCould not open or create the upgrade info file '%s' in "
"the MariaDB Servers data directory, errno: %d (%s)\n";
static void open_mysql_upgrade_file()
{
char errbuff[80];
if (get_upgrade_info_file_name(upgrade_info_file))
{
die("Upgrade failed");
}
if ((info_file= my_create(upgrade_info_file, 0,
O_RDWR | O_NOFOLLOW,
MYF(0))) < 0)
{
if (opt_force >= 2)
{
fprintf(stdout, create_error_message,
"", upgrade_info_file, errno,
my_strerror(errbuff, sizeof(errbuff)-1, errno));
fprintf(stdout,
"--force --force used, continuing without using the %s file.\n"
"Note that this means that there is no protection against "
"concurrent mysql_upgrade executions and next mysql_upgrade run "
"will do a full upgrade again!\n",
upgrade_info_file);
return;
}
fprintf(stdout, create_error_message,
"FATAL ERROR: ",
upgrade_info_file, errno,
my_strerror(errbuff, sizeof(errbuff)-1, errno));
if (errno == EACCES)
{
fprintf(stderr,
"Note that mysql_upgrade should be run as the same user as the "
"MariaDB server binary, normally 'mysql' or 'root'.\n"
"Alternatively you can use mysql_upgrade --force --force. "
"Please check the documentation if you decide to use the force "
"option!\n");
}
fflush(stderr);
die(0);
}
if (my_lock(info_file, F_WRLCK, 0, 1, MYF(0)))
{
die("Could not exclusively lock on file '%s'. Error %d: %s\n",
upgrade_info_file, my_errno,
my_strerror(errbuff, sizeof(errbuff)-1, my_errno));
}
}
/**
Place holder for versions that require a major upgrade
@return 0 upgrade has alredy been run on this version
@return 1 upgrade has to be run
*/
static int faulty_server_versions(const char *version)
{
return 0;
}
/*
Read the content of mysql_upgrade_info file and
@ -677,86 +795,111 @@ static int get_upgrade_info_file_name(char* name)
NOTE
This is an optimization to avoid running mysql_upgrade
when it's already been performed for the particular
version of MySQL.
version of MariaDB.
In case the MySQL server can't return the upgrade info
In case the MariaDBL server can't return the upgrade info
file it's always better to report that the upgrade hasn't
been performed.
@return 0 Upgrade has alredy been run on this version
@return > 0 Upgrade has to be run
*/
static int upgrade_already_done(myf flags)
static int upgrade_already_done(int silent)
{
FILE *in;
char upgrade_info_file[FN_REFLEN]= {0};
const char *version = MYSQL_SERVER_VERSION;
const char *s;
char *pos;
my_off_t length;
if (get_upgrade_info_file_name(upgrade_info_file))
return 0; /* Could not get filename => not sure */
if (!(in= my_fopen(upgrade_info_file, O_RDONLY, flags)))
return 0; /* Could not open file => not sure */
if (info_file < 0)
{
DBUG_ASSERT(opt_force > 1);
return 1; /* No info file and --force */
}
bzero(upgrade_from_version, sizeof(upgrade_from_version));
if (!fgets(upgrade_from_version, sizeof(upgrade_from_version), in))
(void) my_seek(info_file, 0, SEEK_SET, MYF(0));
/* We have -3 here to make calc_server_version() safe */
length= my_read(info_file, (uchar*) upgrade_from_version,
sizeof(upgrade_from_version)-3,
MYF(MY_WME));
if (!length)
{
/* Preserve errno for caller */
int save_errno= errno;
(void) my_fclose(in, flags);
errno= save_errno;
if (opt_verbose)
verbose("Empty or non existent %s. Assuming mysql_upgrade has to be run!",
upgrade_info_file);
return 1;
}
/* Remove possible \ŋ that may end in output */
if ((pos= strchr(upgrade_from_version, '\n')))
*pos= 0;
if (faulty_server_versions(upgrade_from_version))
{
if (opt_verbose)
verbose("Upgrading from version %s requires mysql_upgrade to be run!",
upgrade_from_version);
return 2;
}
s= strchr(version, '.');
s= strchr(s + 1, '.');
if (strncmp(upgrade_from_version, version,
(size_t)(s - version + 1)))
{
if (calc_server_version(upgrade_from_version) <= MYSQL_VERSION_ID)
{
verbose("Major version upgrade detected from %s to %s. Check required!",
upgrade_from_version, version);
return 3;
}
die("Version mismatch (%s -> %s): Trying to downgrade from a higher to "
"lower version is not supported!",
upgrade_from_version, version);
}
if (!silent)
{
verbose("This installation of MariaDB is already upgraded to %s.\n"
"There is no need to run mysql_upgrade again for %s.",
upgrade_from_version, version);
if (!opt_check_upgrade)
verbose("You can use --force if you still want to run mysql_upgrade",
upgrade_from_version, version);
}
return 0;
}
if (my_fclose(in, flags))
return 0;
errno= 0;
return (strncmp(upgrade_from_version, MYSQL_SERVER_VERSION,
sizeof(MYSQL_SERVER_VERSION)-1)==0);
}
/*
Write mysql_upgrade_info file in servers data dir indicating that
upgrade has been done for this version
NOTE
This might very well fail but since it's just an optimization
to run mysql_upgrade only when necessary the error can be
ignored.
*/
static void create_mysql_upgrade_info_file(void)
static void finish_mysql_upgrade_info_file(void)
{
FILE *out;
char upgrade_info_file[FN_REFLEN]= {0};
if (get_upgrade_info_file_name(upgrade_info_file))
return; /* Could not get filename => skip */
if (!(out= my_fopen(upgrade_info_file, O_TRUNC | O_WRONLY, MYF(0))))
{
fprintf(stderr,
"Could not create the upgrade info file '%s' in "
"the MariaDB Servers datadir, errno: %d\n",
upgrade_info_file, errno);
if (info_file < 0)
return;
}
/* Write new version to file */
my_fwrite(out, (uchar*) MYSQL_SERVER_VERSION,
sizeof(MYSQL_SERVER_VERSION), MY_WME);
my_fclose(out, MYF(MY_WME));
(void) my_seek(info_file, 0, SEEK_CUR, MYF(0));
(void) my_chsize(info_file, 0, 0, MYF(0));
(void) my_seek(info_file, 0, 0, MYF(0));
(void) my_write(info_file, (uchar*) MYSQL_SERVER_VERSION,
sizeof(MYSQL_SERVER_VERSION)-1, MYF(MY_WME));
(void) my_write(info_file, (uchar*) "\n", 1, MYF(MY_WME));
(void) my_lock(info_file, F_UNLCK, 0, 1, MYF(0));
/*
Check if the upgrad_info_file was properly created/updated
Check if the upgrade_info_file was properly created/updated
It's not a fatal error -> just print a message if it fails
*/
if (!upgrade_already_done(MY_WME))
if (upgrade_already_done(1))
fprintf(stderr,
"Upgrade file '%s' was not properly created. "
"Got error errno while checking file content: %d\n",
"Could not write to the upgrade info file '%s' in "
"the MariaDB Servers datadir, errno: %d\n",
upgrade_info_file, errno);
my_close(info_file, MYF(MY_WME));
info_file= -1;
return;
}
@ -1151,7 +1294,7 @@ static int check_slave_repositories(void)
}
/*
Update all system tables in MySQL Server to current
Update all system tables in MariaDB Server to current
version using "mysql" to execute all the SQL commands
compiled into the mysql_fix_privilege_tables array
*/
@ -1220,24 +1363,6 @@ static int run_sql_fix_privilege_tables(void)
}
static void print_error(const char *error_msg, DYNAMIC_STRING *output)
{
fprintf(stderr, "%s\n", error_msg);
fprintf(stderr, "%s", output->str);
}
/* Convert the specified version string into the numeric format. */
static ulong STDCALL calc_server_version(char *some_version)
{
uint major, minor, version;
char *point= some_version, *end_point;
major= (uint) strtoul(point, &end_point, 10); point=end_point+1;
minor= (uint) strtoul(point, &end_point, 10); point=end_point+1;
version= (uint) strtoul(point, &end_point, 10);
return (ulong) major * 10000L + (ulong)(minor * 100 + version);
}
/**
Check if the server version matches with the server version mysql_upgrade
was compiled with.
@ -1273,7 +1398,6 @@ static int check_version_match(void)
"check.\n", version_str, MYSQL_SERVER_VERSION);
return 1;
}
else
return 0;
}
@ -1283,6 +1407,8 @@ int main(int argc, char **argv)
char self_name[FN_REFLEN + 1];
MY_INIT(argv[0]);
DBUG_PROCESS(argv[0]);
load_defaults_or_exit("my", load_default_groups, &argc, &argv);
defaults_argv= argv; /* Must be freed by 'free_defaults' */
@ -1324,12 +1450,17 @@ int main(int argc, char **argv)
die(NULL);
my_write(fd, USTRING_WITH_LEN( "[client]\n"), MYF(MY_FAE));
my_write(fd, (uchar*)ds_args.str, ds_args.length, MYF(MY_FAE));
my_close(fd, MYF(0));
my_close(fd, MYF(MY_WME));
}
/* Find mysql */
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
open_mysql_upgrade_file();
if (opt_check_upgrade)
exit(upgrade_already_done(0) == 0);
/* Find mysqlcheck */
find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
@ -1338,15 +1469,10 @@ int main(int argc, char **argv)
/*
Read the mysql_upgrade_info file to check if mysql_upgrade
already has been run for this installation of MySQL
already has been run for this installation of MariaDB
*/
if (!opt_force && upgrade_already_done(0))
{
printf("This installation of MariaDB is already upgraded to %s, "
"use --force if you still need to run mysql_upgrade\n",
MYSQL_SERVER_VERSION);
goto end;
}
if (!opt_force && !upgrade_already_done(0))
goto end; /* Upgrade already done */
if (opt_version_check && check_version_match())
die("Upgrade failed");
@ -1373,8 +1499,8 @@ int main(int argc, char **argv)
verbose("OK");
/* Create a file indicating upgrade has been performed */
create_mysql_upgrade_info_file();
/* Finish writing indicating upgrade has been performed */
finish_mysql_upgrade_info_file();
DBUG_ASSERT(phase == phases_total);

View File

@ -197,6 +197,8 @@ SETA(CPACK_RPM_devel_PACKAGE_OBSOLETES
"MySQL-devel")
SETA(CPACK_RPM_devel_PACKAGE_PROVIDES
"MySQL-devel")
SETA(CPACK_RPM_devel_PACKAGE_REQUIRES
"MariaDB-shared >= 10.2.42")
SETA(CPACK_RPM_server_PACKAGE_OBSOLETES
"MariaDB"
@ -358,9 +360,11 @@ MACRO(ADDIF var)
ENDIF()
ENDMACRO()
ADDIF(MYSQL_MAINTAINER_MODE)
ADDIF(CMAKE_BUILD_TYPE)
ADDIF(BUILD_CONFIG)
ADDIF(WITH_SSL)
ADDIF(WITH_JEMALLOC)
ENDIF()
ENDIF(RPM)

10
cmake/cpack_tgz.cmake Normal file
View File

@ -0,0 +1,10 @@
IF(NOT RPM AND NOT DEB)
#
# use -DEXTRA_FILES='/path/to/file=where/to/install;/bin/dd=bin;...'
#
FOREACH(f ${EXTRA_FILES})
STRING(REGEX REPLACE "=.*$" "" from ${f})
STRING(REGEX REPLACE "^.*=" "" to ${f})
INSTALL(PROGRAMS ${from} DESTINATION ${to})
ENDFOREACH()
ENDIF()

View File

@ -19,12 +19,21 @@ MACRO(BUNDLE_PCRE2)
SET(intdir)
ENDIF()
SET(file ${dir}/src/pcre2-build/${intdir}${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
# PCRE names static libraries differently depending on platform.
# On Windows, but not elsewhere, it adds "-static" to the library name,
# or "-staticd".
IF(WIN32)
SET(PCRE_STATIC "-static")
ELSE()
SET(PCRE_STATIC "")
ENDIF()
SET(file ${dir}/src/pcre2-build/${intdir}${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${PCRE_STATIC}${CMAKE_STATIC_LIBRARY_SUFFIX})
IF(WIN32)
# Debug libary name.
# Same condition as in pcre2 CMakeLists.txt that adds "d"
SET(file_d ${dir}/src/pcre2-build/${intdir}${CMAKE_STATIC_LIBRARY_PREFIX}${lib}d${CMAKE_STATIC_LIBRARY_SUFFIX})
SET(file_d ${dir}/src/pcre2-build/${intdir}${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${PCRE_STATIC}d${CMAKE_STATIC_LIBRARY_SUFFIX})
SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION_DEBUG ${file_d})
ELSE()
SET(file_d)
@ -44,8 +53,8 @@ MACRO(BUNDLE_PCRE2)
ExternalProject_Add(
pcre2
PREFIX "${dir}"
URL "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.37/pcre2-10.37.zip"
URL_MD5 8c1699a725d4b28410adf4b964ebbcb7
URL "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.zip"
URL_MD5 e101c0ca9edb4b0af103bebe78ba52b0
INSTALL_COMMAND ""
CMAKE_ARGS
"-DCMAKE_WARN_DEPRECATED=FALSE"

View File

@ -119,7 +119,7 @@ MACRO (MYSQL_CHECK_SSL)
ENDIF()
FIND_PACKAGE(OpenSSL)
SET_PACKAGE_PROPERTIES(OpenSSL PROPERTIES TYPE RECOMMENDED)
IF(OPENSSL_FOUND)
IF(OPENSSL_FOUND AND OPENSSL_VERSION AND OPENSSL_VERSION VERSION_LESS "3.0.0")
SET(OPENSSL_LIBRARY ${OPENSSL_SSL_LIBRARY})
INCLUDE(CheckSymbolExists)
SET(SSL_SOURCES "")

View File

@ -17,7 +17,7 @@ MACRO(CHECK_SYSTEMD)
IF(UNIX)
INCLUDE(FindPkgConfig)
# http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html
SET(WITH_SYSTEMD "auto" CACHE STRING "Enable systemd scripts and notification support")
SET(WITH_SYSTEMD "auto" CACHE STRING "Enable systemd scripts and notification support. Allowed values yes/no/auto.")
IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto")
IF(PKG_CONFIG_FOUND)
IF (NOT DEFINED LIBSYSTEMD_FOUND)
@ -54,6 +54,13 @@ MACRO(CHECK_SYSTEMD)
SET(SYSTEMD_LIMIT "# For liburing and io_uring_setup()
LimitMEMLOCK=524288")
ENDIF()
IF(NOT DEB AND NOT RPM)
SET(SYSTEMD_READWRITEPATH "# Database dir: '${MYSQL_DATADIR}' should be writable even
# ProtectSystem=full prevents it
ReadWritePaths=-${MYSQL_DATADIR}\n")
ENDIF()
MESSAGE_ONCE(systemd "Systemd features enabled")
ELSE()
UNSET(LIBSYSTEMD)

View File

@ -863,9 +863,16 @@ MARK_AS_ADVANCED(NO_ALARM)
CHECK_CXX_SOURCE_COMPILES("
int main()
{
long long int var= 1;
long long int *ptr= &var;
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
char x=1;
short y=1;
int z=1;
long w = 1;
long long s = 1;
x = __atomic_add_fetch(&x, 1, __ATOMIC_SEQ_CST);
y = __atomic_add_fetch(&y, 1, __ATOMIC_SEQ_CST);
z = __atomic_add_fetch(&z, 1, __ATOMIC_SEQ_CST);
w = __atomic_add_fetch(&w, 1, __ATOMIC_SEQ_CST);
return (int)__atomic_load_n(&s, __ATOMIC_SEQ_CST);
}"
HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
IF (HAVE_GCC_C11_ATOMICS_WITHOUT_LIBATOMIC)
@ -876,9 +883,16 @@ ELSE()
CHECK_CXX_SOURCE_COMPILES("
int main()
{
long long int var= 1;
long long int *ptr= &var;
return (int)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
char x=1;
short y=1;
int z=1;
long w = 1;
long long s = 1;
x = __atomic_add_fetch(&x, 1, __ATOMIC_SEQ_CST);
y = __atomic_add_fetch(&y, 1, __ATOMIC_SEQ_CST);
z = __atomic_add_fetch(&z, 1, __ATOMIC_SEQ_CST);
w = __atomic_add_fetch(&w, 1, __ATOMIC_SEQ_CST);
return (int)__atomic_load_n(&s, __ATOMIC_SEQ_CST);
}"
HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)
IF(HAVE_GCC_C11_ATOMICS_WITH_LIBATOMIC)

View File

@ -34,7 +34,7 @@ then
# Take the files and part of control from MCS directory
cp -v storage/columnstore/columnstore/debian/mariadb-plugin-columnstore.* debian/
echo >> debian/control
sed "s/10.7/${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}/" <storage/columnstore/columnstore/debian/control >> debian/control
sed "s/10.6/${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}/" <storage/columnstore/columnstore/debian/control >> debian/control
fi
# Don't build or try to put files in a package for selected plugins and components on Travis-CI

View File

@ -52,6 +52,12 @@ The parts not included are excluded by #ifndef UNIV_INNOCHECKSUM. */
#include <string.h>
#ifdef UNIV_NONINL
# include "fsp0fsp.inl"
# include "mach0data.inl"
# include "ut0rnd.inl"
#endif
#ifndef PRIuMAX
#define PRIuMAX "llu"
#endif

View File

@ -345,6 +345,9 @@ char orig_argv1[FN_REFLEN];
pthread_cond_t scanned_lsn_cond;
/** Store the deferred tablespace name during --backup */
static std::set<std::string> defer_space_names;
typedef std::map<space_id_t,std::string> space_id_to_name_t;
struct ddl_tracker_t {
@ -354,10 +357,54 @@ struct ddl_tracker_t {
std::set<space_id_t> drops;
/* For DDL operation found in redo log, */
space_id_to_name_t id_to_name;
/** Deferred tablespaces with their ID and name which was
found in redo log of DDL operations */
space_id_to_name_t deferred_tables;
/** Insert the deferred tablespace id with the name */
void insert_defer_id(space_id_t space_id, std::string name)
{
auto it= defer_space_names.find(name);
if (it != defer_space_names.end())
{
deferred_tables[space_id]= name;
defer_space_names.erase(it);
}
}
/** Rename the deferred tablespace with new name */
void rename_defer(space_id_t space_id, std::string old_name,
std::string new_name)
{
if (deferred_tables.find(space_id) != deferred_tables.end())
deferred_tables[space_id] = new_name;
auto defer_end= defer_space_names.end();
auto defer= defer_space_names.find(old_name);
if (defer == defer_end)
defer= defer_space_names.find(new_name);
if (defer != defer_end)
{
deferred_tables[space_id]= new_name;
defer_space_names.erase(defer);
}
}
/** Delete the deferred tablespace */
void delete_defer(space_id_t space_id, std::string name)
{
deferred_tables.erase(space_id);
defer_space_names.erase(name);
}
};
static ddl_tracker_t ddl_tracker;
/** Stores the space ids of page0 INIT_PAGE redo records. It is
used to indicate whether the given deferred tablespace can
be reconstructed. */
static std::set<space_id_t> first_page_init_ids;
// Convert non-null terminated filename to space name
static std::string filename_to_spacename(const void *filename, size_t len);
@ -765,33 +812,57 @@ static std::string filename_to_spacename(const void *filename, size_t len)
/** Report an operation to create, delete, or rename a file during backup.
@param[in] space_id tablespace identifier
@param[in] create whether the file is being created
@param[in] type redo log file operation type
@param[in] name file name (not NUL-terminated)
@param[in] len length of name, in bytes
@param[in] new_name new file name (NULL if not rename)
@param[in] new_len length of new_name, in bytes (0 if NULL) */
static void backup_file_op(uint32_t space_id, bool create,
static void backup_file_op(uint32_t space_id, int type,
const byte* name, ulint len,
const byte* new_name, ulint new_len)
{
ut_ad(!create || !new_name);
ut_ad(name);
ut_ad(len);
ut_ad(!new_name == !new_len);
mysql_mutex_assert_owner(&recv_sys.mutex);
if (create) {
ddl_tracker.id_to_name[space_id] = filename_to_spacename(name, len);
switch(type) {
case FILE_CREATE:
{
std::string space_name = filename_to_spacename(name, len);
ddl_tracker.id_to_name[space_id] = space_name;
ddl_tracker.delete_defer(space_id, space_name);
msg("DDL tracking : create %u \"%.*s\"", space_id, int(len), name);
}
else if (new_name) {
ddl_tracker.id_to_name[space_id] = filename_to_spacename(new_name, new_len);
break;
case FILE_MODIFY:
ddl_tracker.insert_defer_id(
space_id, filename_to_spacename(name, len));
msg("DDL tracking : modify %u \"%.*s\"", space_id, int(len), name);
break;
case FILE_RENAME:
{
std::string new_space_name = filename_to_spacename(
new_name, new_len);
std::string old_space_name = filename_to_spacename(
name, len);
ddl_tracker.id_to_name[space_id] = new_space_name;
ddl_tracker.rename_defer(space_id, old_space_name,
new_space_name);
msg("DDL tracking : rename %u \"%.*s\",\"%.*s\"",
space_id, int(len), name, int(new_len), new_name);
} else {
}
break;
case FILE_DELETE:
ddl_tracker.drops.insert(space_id);
ddl_tracker.delete_defer(
space_id, filename_to_spacename(name, len));
msg("DDL tracking : delete %u \"%.*s\"", space_id, int(len), name);
break;
default:
ut_ad(0);
break;
}
}
@ -805,29 +876,38 @@ static void backup_file_op(uint32_t space_id, bool create,
We will abort backup in this case.
*/
static void backup_file_op_fail(uint32_t space_id, bool create,
static void backup_file_op_fail(uint32_t space_id, int type,
const byte* name, ulint len,
const byte* new_name, ulint new_len)
{
bool fail;
if (create) {
msg("DDL tracking : create %u \"%.*s\"",
space_id, int(len), name);
std::string spacename = filename_to_spacename(name, len);
fail = !check_if_skip_table(spacename.c_str());
}
else if (new_name) {
bool fail = false;
switch(type) {
case FILE_CREATE:
msg("DDL tracking : create %u \"%.*s\"", space_id, int(len), name);
fail = !check_if_skip_table(
filename_to_spacename(name, len).c_str());
break;
case FILE_MODIFY:
msg("DDL tracking : modify %u \"%.*s\"", space_id, int(len), name);
break;
case FILE_RENAME:
msg("DDL tracking : rename %u \"%.*s\",\"%.*s\"",
space_id, int(len), name, int(new_len), new_name);
std::string spacename = filename_to_spacename(name, len);
std::string new_spacename = filename_to_spacename(new_name, new_len);
fail = !check_if_skip_table(spacename.c_str()) || !check_if_skip_table(new_spacename.c_str());
}
else {
std::string spacename = filename_to_spacename(name, len);
fail = !check_if_skip_table(spacename.c_str());
fail = !check_if_skip_table(
filename_to_spacename(name, len).c_str())
|| !check_if_skip_table(
filename_to_spacename(new_name, new_len).c_str());
break;
case FILE_DELETE:
fail = !check_if_skip_table(
filename_to_spacename(name, len).c_str());
msg("DDL tracking : delete %u \"%.*s\"", space_id, int(len), name);
break;
default:
ut_ad(0);
break;
}
if (fail) {
ut_a(opt_no_lock);
die("DDL operation detected in the late phase of backup."
@ -835,6 +915,12 @@ static void backup_file_op_fail(uint32_t space_id, bool create,
}
}
/* Function to store the space id of page0 INIT_PAGE
@param space_id space id which has page0 init page */
static void backup_first_page_op(space_id_t space_id)
{
first_page_init_ids.insert(space_id);
}
/*
Retrieve default data directory, to be used with --copy-back.
@ -3359,7 +3445,8 @@ static void xb_load_single_table_tablespace(const char *dirname,
{
ut_ad(srv_operation == SRV_OPERATION_BACKUP
|| srv_operation == SRV_OPERATION_RESTORE_DELTA
|| srv_operation == SRV_OPERATION_RESTORE);
|| srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_BACKUP_NO_DEFER);
/* Ignore .isl files on XtraBackup recovery. All tablespaces must be
local. */
if (is_remote && srv_operation == SRV_OPERATION_RESTORE_DELTA) {
@ -3427,6 +3514,10 @@ static void xb_load_single_table_tablespace(const char *dirname,
}
if (!defer && file->m_defer) {
const char *file_path = file->filepath();
defer_space_names.insert(
filename_to_spacename(
file_path, strlen(file_path)));
delete file;
ut_free(name);
return;
@ -4534,6 +4625,7 @@ static bool xtrabackup_backup_func()
srv_operation = SRV_OPERATION_BACKUP;
log_file_op = backup_file_op;
first_page_init = backup_first_page_op;
metadata_to_lsn = 0;
/* initialize components */
@ -4548,6 +4640,7 @@ fail:
}
log_file_op = NULL;
first_page_init = NULL;
if (dst_log_file) {
ds_close(dst_log_file);
dst_log_file = NULL;
@ -4793,6 +4886,7 @@ free_and_fail:
innodb_shutdown();
log_file_op = NULL;
first_page_init = NULL;
pthread_cond_destroy(&scanned_lsn_cond);
if (!corrupted_pages.empty()) {
ut_ad(opt_log_innodb_page_corruption);
@ -4873,7 +4967,9 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
continue;
}
if (ddl_tracker.drops.find(id) == ddl_tracker.drops.end()) {
if (ddl_tracker.drops.find(id) == ddl_tracker.drops.end()
&& ddl_tracker.deferred_tables.find(id)
== ddl_tracker.deferred_tables.end()) {
dropped_tables.erase(name);
new_tables[id] = name;
if (opt_log_innodb_page_corruption)
@ -4918,6 +5014,41 @@ void backup_fix_ddl(CorruptedPages &corrupted_pages)
DBUG_EXECUTE_IF("check_mdl_lock_works", DBUG_ASSERT(new_tables.size() == 0););
srv_operation = SRV_OPERATION_BACKUP_NO_DEFER;
/* Mariabackup detected the FILE_MODIFY or FILE_RENAME
for the deferred tablespace. So it needs to read the
tablespace again if innodb doesn't have page0 initialization
redo log for it */
for (space_id_to_name_t::iterator iter =
ddl_tracker.deferred_tables.begin();
iter != ddl_tracker.deferred_tables.end();
iter++) {
if (check_if_skip_table(iter->second.c_str())) {
continue;
}
if (first_page_init_ids.find(iter->first)
!= first_page_init_ids.end()) {
new_tables[iter->first] = iter->second.c_str();
continue;
}
xb_load_single_table_tablespace(iter->second, false);
}
/* Mariabackup doesn't detect any FILE_OP for the deferred
tablespace. There is a possiblity that page0 could've
been corrupted persistently in the disk */
for (auto space_name: defer_space_names) {
if (!check_if_skip_table(space_name.c_str())) {
xb_load_single_table_tablespace(
space_name, false);
}
}
srv_operation = SRV_OPERATION_BACKUP;
for (const auto &t : new_tables) {
if (!check_if_skip_table(t.second.c_str())) {
xb_load_single_table_tablespace(t.second, false,

View File

@ -104,6 +104,7 @@ ${WOLFCRYPT_SRCDIR}/wc_port.c
${WOLFCRYPT_SRCDIR}/wc_encrypt.c
${WOLFCRYPT_SRCDIR}/hash.c
${WOLFCRYPT_SRCDIR}/wolfmath.c
${WOLFCRYPT_SRCDIR}/kdf.c
)
# Use fastmath large number math library.

View File

@ -2,6 +2,7 @@
#define WOLFSSL_USER_SETTINGS_H
#define HAVE_CRL
#define WOLFSSL_HAVE_ERROR_QUEUE
#define WOLFSSL_MYSQL_COMPATIBLE
#define HAVE_ECC
#define ECC_TIMING_RESISTANT

View File

@ -36,8 +36,9 @@ extern const char *client_errors[]; /* Error messages */
#define CR_MIN_ERROR 2000 /* For easier client code */
#define CR_MAX_ERROR 2999
#if !defined(ER)
#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST)? \
client_errors[(X)-CR_ERROR_FIRST]: client_errors[CR_UNKNOWN_ERROR])
#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST) \
? client_errors[(X)-CR_ERROR_FIRST] \
: client_errors[CR_UNKNOWN_ERROR-CR_ERROR_FIRST])
#endif
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */

View File

@ -224,6 +224,7 @@ typedef struct st_json_engine_t
int stack[JSON_DEPTH_LIMIT]; /* Keeps the stack of nested JSON structures. */
int stack_p; /* The 'stack' pointer. */
volatile uchar *killed_ptr;
} json_engine_t;

View File

@ -351,6 +351,60 @@ struct my_collation_handler_st
const uchar *, size_t, const uchar *, size_t, my_bool);
int (*strnncollsp)(CHARSET_INFO *,
const uchar *, size_t, const uchar *, size_t);
/*
strnncollsp_nchars() - similar to strnncollsp() but assumes that both
strings were originally CHAR(N) values with the
same N, then were optionally space-padded,
or optionally space-trimmed.
In other words, this function compares in the way
if we insert both values into a CHAR(N) column
and then compare the two column values.
It compares the same amount of characters from the two strings.
This is especially important for NOPAD collations.
If CHAR_LENGTH of the two strings are different,
the shorter string is virtually padded with trailing spaces
up to CHAR_LENGTH of the longer string, to guarantee that the
same amount of characters are compared.
This is important if the two CHAR(N) strings are space-trimmed
(e.g. like in InnoDB compact format for CHAR).
The function compares not more than "nchars" characters only.
This can be useful to compare CHAR(N) space-padded strings
(when the exact N is known) without having to truncate them before
the comparison.
For example, Field_string stores a "CHAR(3) CHARACTER SET utf8mb4" value
of "aaa" as 12 bytes in a record buffer:
- 3 bytes of the actual data, followed by
- 9 bytes of spaces (just fillers, not real data)
The caller can pass nchars=3 to compare CHAR(3) record values.
In such case, the comparator won't go inside the 9 bytes of the fillers.
If N is not known, the caller can pass max(len1,len2) as the "nchars" value
(i.e. the maximum of the OCTET_LENGTH of the two strings).
Notes on complex collations.
This function counts contraction parts as individual characters.
For example, the Czech letter 'ch' (in Czech collations)
is ordinarily counted by the "nchars" limit as TWO characters
(although it is only one letter).
This corresponds to what CHAR(N) does in INSERT.
If the "nchars" limit tears apart a contraction, only the part fitting
into "nchars" characters is used. For example, in case of a Czech collation,
the string "ach" with nchars=2 is compared as 'ac': the contraction
'ch' is torn apart and the letter 'c' acts as an individual character.
This emulates the same comparison result with the scenario when we insert
'ach' into a CHAR(2) column and then compare it.
*/
int (*strnncollsp_nchars)(CHARSET_INFO *,
const uchar *str1, size_t len1,
const uchar *str2, size_t len2,
size_t nchars);
size_t (*strnxfrm)(CHARSET_INFO *,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags);

View File

@ -528,7 +528,8 @@ enum ha_base_keytype {
#define HA_ERR_SEQUENCE_INVALID_DATA 195
#define HA_ERR_SEQUENCE_RUN_OUT 196
#define HA_ERR_COMMIT_ERROR 197
#define HA_ERR_LAST 197 /* Copy of last error nr * */
#define HA_ERR_PARTITION_LIST 198
#define HA_ERR_LAST 198 /* Copy of last error nr * */
/* Number of different errors */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)

View File

@ -108,7 +108,8 @@ static const char *handler_error_messages[]=
"Tablespace is missing for a table",
"Sequence has been run out",
"Sequence values are conflicting",
"Error during commit"
"Error during commit",
"Cannot select partitions"
};
#endif /* MYSYS_MY_HANDLER_ERRORS_INCLUDED */

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2021, MariaDB Corporation.
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
@ -277,7 +277,7 @@ extern int my_umask_dir,
extern SECURITY_ATTRIBUTES my_dir_security_attributes;
LPSECURITY_ATTRIBUTES my_win_file_secattr();
#endif
extern my_bool my_use_symdir;
extern MYSQL_PLUGIN_IMPORT my_bool my_use_symdir;
extern ulong my_default_record_cache_size;
extern MYSQL_PLUGIN_IMPORT my_bool my_disable_locking;

View File

@ -147,7 +147,8 @@ struct st_mysql_auth
@return 0 for ok, 1 for error
Can be NULL.
Can be NULL, in this case one will not be able to use SET PASSWORD or
PASSWORD('...') in GRANT, CREATE USER, ALTER USER.
*/
int (*hash_password)(const char *password, size_t password_length,
char *hash, size_t *hash_length);

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@ -216,7 +216,7 @@
With the instrumentation, mysql_fclose(NULL, ...) will safely return 0,
which is an extension compared to my_fclose and is therefore compliant.
mysql_fclose is on purpose *not* implementing
@code DBUG_ASSERT(file != NULL) @endcode,
@code assert(file != NULL) @endcode,
since doing so could introduce regressions.
*/
#ifdef HAVE_PSI_FILE_INTERFACE

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2011, 2021, Oracle and/or its affiliates
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2012, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2012, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2014, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2013, Oracle and/or its affiliates.
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
Copyright (c) 2020, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2011, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2008, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2013, 2021, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2016, 2021, MariaDB Corporation.
Copyright (c) 2016, 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
@ -73,7 +73,10 @@
#define EVP_MD_CTX_SIZE sizeof(EVP_MD_CTX)
#endif
#ifndef DH_set0_pqg
#define DH_set0_pqg(D,P,Q,G) ((D)->p= (P), (D)->g= (G))
#endif
#define EVP_CIPHER_CTX_encrypting(ctx) ((ctx)->encrypt)
#define EVP_CIPHER_CTX_SIZE sizeof(EVP_CIPHER_CTX)

View File

@ -19,8 +19,8 @@
C_MODE_START
void lib_connection_phase(NET *net, int phase);
void init_embedded_mysql(MYSQL *mysql, int client_flag);
void *create_embedded_thd(int client_flag);
void init_embedded_mysql(MYSQL *mysql, ulong client_flag);
void *create_embedded_thd(ulong client_flag);
int check_embedded_connection(MYSQL *mysql, const char *db);
void free_old_query(MYSQL *mysql);
extern MYSQL_METHODS embedded_methods;

View File

@ -674,7 +674,7 @@ void end_embedded_server()
}
void init_embedded_mysql(MYSQL *mysql, int client_flag)
void init_embedded_mysql(MYSQL *mysql, ulong client_flag)
{
THD *thd = (THD *)mysql->thd;
thd->mysql= mysql;
@ -694,7 +694,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag)
create_new_thread(), and prepare_new_connection_state(). This should
be refactored to avoid code duplication.
*/
void *create_embedded_thd(int client_flag)
void *create_embedded_thd(ulong client_flag)
{
THD * thd= new THD(next_thread_id());
@ -710,7 +710,7 @@ void *create_embedded_thd(int client_flag)
thd->set_command(COM_SLEEP);
thd->set_time();
thd->init_for_queries();
thd->client_capabilities= client_flag;
thd->client_capabilities= client_flag | MARIADB_CLIENT_EXTENDED_METADATA;
thd->real_id= pthread_self();
thd->db= null_clex_str;
@ -841,7 +841,7 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
/* acl_authenticate() takes the data from thd->net->read_pos */
thd->net.read_pos= (uchar*)buf;
if (acl_authenticate(thd, 0, end - buf))
if (acl_authenticate(thd, (uint) (end - buf)))
{
my_free(thd->security_ctx->user);
goto err;

View File

@ -239,6 +239,21 @@ Old option accepted for backward compatibility but ignored\&.
.sp -1
.IP \(bu 2.3
.\}
.\" mysql_upgrade: check-if-upgrade-is-needed option
.\" check-if-upgrade-is-needed option: mysql_upgrade
\fB\-\-check\-if\-upgrade\-is\-needed\fR
.sp
Exit with a status code indicating if an upgrade is needed\&. Returns 0 if upgrade needed or current version couldn't be determined, 1 when no action required\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysql_upgrade: datadir option
.\" datadir option: mysql_upgrade
\fB\-\-datadir=\fR\fB\fIpath\fR\fR

View File

@ -1,4 +1,5 @@
perl mysql-test-run.pl --verbose-restart --force --suite-timeout=120 --max-test-fail=10 --retry=3 --parallel=4 --suite=^
if "%MTR_PARALLEL%"=="" set MTR_PARALLEL=%NUMBER_OF_PROCESSORS%
perl mysql-test-run.pl --verbose-restart --force --suite-timeout=120 --max-test-fail=10 --retry=3 --suite=^
vcol,gcol,perfschema,^
main,^
innodb,^

View File

@ -0,0 +1,3 @@
binlog.binlog_truncate_active_log : MDEV-26919 - undefined value
main.json_normalize : MDEV-27415 - out of bounds
main.json_equals : MDEV-27415 - out of bounds

View File

@ -153,7 +153,12 @@ explain select * from t0 where
(((key3 <7 and key7 < 6) or key5 < 2) and (key5 < 5 or key6 < 6));
explain select * from t0 where
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
((key3 < 4 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
((key3 < 4 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
@ -162,6 +167,11 @@ explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
((key3 < 10 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
# 8. Verify that "order by" after index merge uses filesort
select * from t0 where key1 < 5 or key8 < 4 order by key1;

View File

@ -1,5 +1,7 @@
#
# Check if the current used server is an embedded server#
#
if (`SELECT VERSION() NOT LIKE '%embedded%'`)
{
--skip Test requires: embedded server
}

View File

@ -0,0 +1,16 @@
#
# Test that we do not have an embedded server compiled with privileges.
# This is not a regular setup, but we are running this in buildbot for
# testing of embedded + privileges.
# Some funcs_1 test cannot handle this combination, which is why we have this
# file to disable them
#
--source include/is_embedded.inc
let priv=`SELECT privileges FROM information_schema.columns limit 1`;
if (`SELECT "$priv" <> ""`)
{
--skip Embedded server is compiled with privileges; Test disabled.
}

View File

@ -1,10 +1,8 @@
let $is_win = `select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows")`;
let $is_embedded = `select version() like '%embedded%'`;
#echo is_win: $is_win;
#echo is_embedded: $is_embedded;
if ($is_win)
{
if ($is_embedded)
if(!$MYSQL_EMBEDDED)
{
skip Not supported with embedded on windows;
}

View File

@ -142,11 +142,11 @@ sub diff {
sub is_subset {
my ($set, $subset)= @_;
my %cache = map { _split_option($_) } @$set;
my %cache = map { join('=', _split_option($_)), 1 } @$set;
for (@$subset){
my ($name, $value)= _split_option($_);
return 0 unless exists $cache{$name} and $cache{$name} eq $value;
return 0 unless $cache{"$name=$value"};
}
return 1;

View File

@ -112,4 +112,14 @@ select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N N N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 10 20 30 40 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
drop user foo;
#
# Bug #29882299: ALTER USER ... IDENTIFIED WITH ... BY ... SHOULD BE A PRIVILEGED OPERATION
#
create user foo@localhost;
connect x,localhost,foo;
alter user current_user identified with 'something';
ERROR 42000: Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
connection default;
disconnect x;
drop user foo@localhost;
update mysql.global_priv set priv=@root_priv where user='root' and host='localhost';

View File

@ -106,4 +106,15 @@ alter user foo with MAX_QUERIES_PER_HOUR 10
select * from mysql.user where user = 'foo';
drop user foo;
--echo #
--echo # Bug #29882299: ALTER USER ... IDENTIFIED WITH ... BY ... SHOULD BE A PRIVILEGED OPERATION
--echo #
create user foo@localhost;
--connect x,localhost,foo
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
alter user current_user identified with 'something';
--connection default
--disconnect x
drop user foo@localhost;
update mysql.global_priv set priv=@root_priv where user='root' and host='localhost';

View File

@ -1071,58 +1071,58 @@ create table t1 like information_schema.processlist;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ID` bigint(4) NOT NULL DEFAULT 0,
`USER` varchar(128) NOT NULL DEFAULT '',
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
`TIME` int(7) NOT NULL DEFAULT 0,
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext DEFAULT NULL,
`TIME_MS` decimal(22,3) NOT NULL DEFAULT 0.000,
`STAGE` tinyint(2) NOT NULL DEFAULT 0,
`MAX_STAGE` tinyint(2) NOT NULL DEFAULT 0,
`PROGRESS` decimal(7,3) NOT NULL DEFAULT 0.000,
`MEMORY_USED` bigint(7) NOT NULL DEFAULT 0,
`MAX_MEMORY_USED` bigint(7) NOT NULL DEFAULT 0,
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT 0,
`QUERY_ID` bigint(4) NOT NULL DEFAULT 0,
`INFO_BINARY` blob DEFAULT NULL,
`TID` bigint(4) NOT NULL DEFAULT 0
`ID` bigint(4) NOT NULL,
`USER` varchar(128) NOT NULL,
`HOST` varchar(64) NOT NULL,
`DB` varchar(64),
`COMMAND` varchar(16) NOT NULL,
`TIME` int(7) NOT NULL,
`STATE` varchar(64),
`INFO` longtext,
`TIME_MS` decimal(22,3) NOT NULL,
`STAGE` tinyint(2) NOT NULL,
`MAX_STAGE` tinyint(2) NOT NULL,
`PROGRESS` decimal(7,3) NOT NULL,
`MEMORY_USED` bigint(7) NOT NULL,
`MAX_MEMORY_USED` bigint(7) NOT NULL,
`EXAMINED_ROWS` int(7) NOT NULL,
`QUERY_ID` bigint(4) NOT NULL,
`INFO_BINARY` blob,
`TID` bigint(4) NOT NULL
) DEFAULT CHARSET=utf8mb3
drop table t1;
create temporary table t1 like information_schema.processlist;
show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`ID` bigint(4) NOT NULL DEFAULT 0,
`USER` varchar(128) NOT NULL DEFAULT '',
`HOST` varchar(64) NOT NULL DEFAULT '',
`DB` varchar(64) DEFAULT NULL,
`COMMAND` varchar(16) NOT NULL DEFAULT '',
`TIME` int(7) NOT NULL DEFAULT 0,
`STATE` varchar(64) DEFAULT NULL,
`INFO` longtext DEFAULT NULL,
`TIME_MS` decimal(22,3) NOT NULL DEFAULT 0.000,
`STAGE` tinyint(2) NOT NULL DEFAULT 0,
`MAX_STAGE` tinyint(2) NOT NULL DEFAULT 0,
`PROGRESS` decimal(7,3) NOT NULL DEFAULT 0.000,
`MEMORY_USED` bigint(7) NOT NULL DEFAULT 0,
`MAX_MEMORY_USED` bigint(7) NOT NULL DEFAULT 0,
`EXAMINED_ROWS` int(7) NOT NULL DEFAULT 0,
`QUERY_ID` bigint(4) NOT NULL DEFAULT 0,
`INFO_BINARY` blob DEFAULT NULL,
`TID` bigint(4) NOT NULL DEFAULT 0
`ID` bigint(4) NOT NULL,
`USER` varchar(128) NOT NULL,
`HOST` varchar(64) NOT NULL,
`DB` varchar(64),
`COMMAND` varchar(16) NOT NULL,
`TIME` int(7) NOT NULL,
`STATE` varchar(64),
`INFO` longtext,
`TIME_MS` decimal(22,3) NOT NULL,
`STAGE` tinyint(2) NOT NULL,
`MAX_STAGE` tinyint(2) NOT NULL,
`PROGRESS` decimal(7,3) NOT NULL,
`MEMORY_USED` bigint(7) NOT NULL,
`MAX_MEMORY_USED` bigint(7) NOT NULL,
`EXAMINED_ROWS` int(7) NOT NULL,
`QUERY_ID` bigint(4) NOT NULL,
`INFO_BINARY` blob,
`TID` bigint(4) NOT NULL
) DEFAULT CHARSET=utf8mb3
drop table t1;
create table t1 like information_schema.character_sets;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
`DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
`MAXLEN` bigint(3) NOT NULL DEFAULT 0
`CHARACTER_SET_NAME` varchar(32) NOT NULL,
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL,
`DESCRIPTION` varchar(60) NOT NULL,
`MAXLEN` bigint(3) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
drop table t1;

View File

@ -19567,6 +19567,22 @@ SET DEFAULT_STORAGE_ENGINE=Default;
# End of 10.2 tests
#
#
# Start of 10.4 tests
#
#
# MDEV-26953 Assertion `!str || str != Ptr || !is_alloced()' failed in String::copy upon SELECT with sjis
#
SET NAMES sjis;
CREATE TABLE t (a VARCHAR(3));
INSERT INTO t VALUES (''),('');
SELECT GROUP_CONCAT(PASSWORD(a)) AS f FROM t;
f
,
DROP TABLE t;
#
# End of 10.4 tests
#
#
# Start of 10.5 tests
#
#
@ -19586,12 +19602,6 @@ EXECUTE IMMEDIATE _cp1257 0xD182;
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 '<27>_0143<34>_201A' at line 1
SET NAMES sjis;
#
# End of 10.5 tests
#
#
# Start of 10.5 tests
#
#
# MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds)
#
SET NAMES sjis;

View File

@ -263,6 +263,24 @@ let $coll_pad='sjis_bin';
--echo # End of 10.2 tests
--echo #
--echo #
--echo # Start of 10.4 tests
--echo #
--echo #
--echo # MDEV-26953 Assertion `!str || str != Ptr || !is_alloced()' failed in String::copy upon SELECT with sjis
--echo #
SET NAMES sjis;
CREATE TABLE t (a VARCHAR(3));
INSERT INTO t VALUES (''),('');
SELECT GROUP_CONCAT(PASSWORD(a)) AS f FROM t;
DROP TABLE t;
--echo #
--echo # End of 10.4 tests
--echo #
--echo #
--echo # Start of 10.5 tests
--echo #
@ -288,16 +306,6 @@ EXECUTE IMMEDIATE _cp1257 0xD182;
SET NAMES sjis;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-22625 SIGSEGV in intern_find_sys_var (optimized builds)
--echo #

View File

@ -1207,6 +1207,59 @@ REPLACE INTO v2 ( SELECT * FROM v4 ) UNION ( SELECT f FROM v2 );
drop view v1,v2,v3,v4;
drop table t1,t2,t3;
#
# MDEV-20325: Assertion `outer_context || !*from_field || *from_field == not_found_field' failed in Item_field::fix_outer_field | `!derived->is_excluded()' failed in TABLE_LIST::set_check_materialized | SIGEGV in st_select_lex::mark_as_dependent (optimized builds)
#
CREATE TABLE t1 (a INT);
# Check that re-execution of a stored routine containing
# a query with subquery in the FROM clause doesn't result in
# assert failure in case the 'derived_merge' optimizer option
# has been turned on/off
CREATE PROCEDURE sp() SELECT * FROM (SELECT a FROM t1) tb;
CALL sp();
a
SET optimizer_switch='derived_merge=off';
# Without the patch the following statement would result in assert
# failure
CALL sp();
a
# Check the same test case for Prepared Statement
SET optimizer_switch='derived_merge=on';
PREPARE stmt FROM "SELECT * FROM (SELECT a FROM t1) tb";
EXECUTE stmt;
a
SET optimizer_switch='derived_merge=off';
# Without the patch the following statement would result in assert
# failure
EXECUTE stmt;
a
DEALLOCATE PREPARE stmt;
# Here check the reverse test case - first turn off the 'derived_merge'
# optimizer option, run the stored routine containing a query with
# subquery in the FROM clause, then turn on the 'derived_merge'
# optimizer option and re-execute the same stored routine to check that
# the routine is finished successfully.
CREATE PROCEDURE sp1() SELECT * FROM (SELECT a FROM t1) tb;
SET optimizer_switch='derived_merge=off';
CALL sp1();
a
SET optimizer_switch='derived_merge=on';
CALL sp1();
a
# Check the same test case for Prepared Statement
SET optimizer_switch='derived_merge=off';
PREPARE stmt FROM "SELECT * FROM (SELECT a FROM t1) tb";
EXECUTE stmt;
a
SET optimizer_switch='derived_merge=on';
# Without the patch the following statement would result in assert
# failure
EXECUTE stmt;
a
DEALLOCATE PREPARE stmt;
DROP PROCEDURE sp;
DROP PROCEDURE sp1;
DROP TABLE t1;
#
# End of 10.2 tests
#
#

View File

@ -1042,6 +1042,57 @@ REPLACE INTO v2 ( SELECT * FROM v4 ) UNION ( SELECT f FROM v2 );
drop view v1,v2,v3,v4;
drop table t1,t2,t3;
--echo #
--echo # MDEV-20325: Assertion `outer_context || !*from_field || *from_field == not_found_field' failed in Item_field::fix_outer_field | `!derived->is_excluded()' failed in TABLE_LIST::set_check_materialized | SIGEGV in st_select_lex::mark_as_dependent (optimized builds)
--echo #
CREATE TABLE t1 (a INT);
--echo # Check that re-execution of a stored routine containing
--echo # a query with subquery in the FROM clause doesn't result in
--echo # assert failure in case the 'derived_merge' optimizer option
--echo # has been turned on/off
CREATE PROCEDURE sp() SELECT * FROM (SELECT a FROM t1) tb;
CALL sp();
SET optimizer_switch='derived_merge=off';
--echo # Without the patch the following statement would result in assert
--echo # failure
CALL sp();
--echo # Check the same test case for Prepared Statement
SET optimizer_switch='derived_merge=on';
PREPARE stmt FROM "SELECT * FROM (SELECT a FROM t1) tb";
EXECUTE stmt;
SET optimizer_switch='derived_merge=off';
--echo # Without the patch the following statement would result in assert
--echo # failure
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
--echo # Here check the reverse test case - first turn off the 'derived_merge'
--echo # optimizer option, run the stored routine containing a query with
--echo # subquery in the FROM clause, then turn on the 'derived_merge'
--echo # optimizer option and re-execute the same stored routine to check that
--echo # the routine is finished successfully.
CREATE PROCEDURE sp1() SELECT * FROM (SELECT a FROM t1) tb;
SET optimizer_switch='derived_merge=off';
CALL sp1();
SET optimizer_switch='derived_merge=on';
CALL sp1();
--echo # Check the same test case for Prepared Statement
SET optimizer_switch='derived_merge=off';
PREPARE stmt FROM "SELECT * FROM (SELECT a FROM t1) tb";
EXECUTE stmt;
SET optimizer_switch='derived_merge=on';
--echo # Without the patch the following statement would result in assert
--echo # failure
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP PROCEDURE sp;
DROP PROCEDURE sp1;
DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
--echo #

View File

@ -19859,7 +19859,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1
1 PRIMARY <derived2> ref key0 key0 5 test.t3.id 2
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
2 LATERAL DERIVED cp2 ref a a 5 test.t1.a 1 Using index
2 LATERAL DERIVED cp2 ref a a 5 test.t1.a 1 Using where; Using index
explain format=json select * from t1, (select a from t1 cp2 group by a) dt, t3
where dt.a = t1.a and t1.a = t3.id and t1.a in (select a from t2);
EXPLAIN
@ -19946,6 +19946,7 @@ EXPLAIN
"ref": ["test.t1.a"],
"rows": 1,
"filtered": 100,
"attached_condition": "cp2.a = t3.`id`",
"using_index": true
}
}
@ -19969,6 +19970,652 @@ id a a id
21 2 2 2
deallocate prepare stmt;
drop table t1,t2,t3;
#
# MDEV-MDEV-27132: Splittable derived with equality in WHERE
#
CREATE TABLE t1 (
id int PRIMARY KEY
) ENGINE=MyISAM;
INSERT INTO t1 VALUES
(-1),(2070),(4826),(4827),(4828),(4829),(4830),(4831),(4832),(4833),(4834),
(4835),(4836),(4837),(4838),(4839),(4840),(4841),(4842),(4843),(4844),
(4845),(4846),(4847),(4848),(4849),(4850),(4851),(4852),(4853),(4854),
(4855),(4856),(4857),(4858),(4859),(4860),(4861),(4862),(4863),(4864),
(4865),(4866),(4867),(4868),(4869),(4870),(4871),(4872),(4873),(4874),
(4875),(4876);
CREATE TABLE t2 (
id int PRIMARY KEY AUTO_INCREMENT,
deleted int(1),
t1_id int,
email varchar(255),
reporting_person int(1),
KEY t1_id (t1_id)
) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(1,0,2064,'1test@test.ee',1),(2,1626095588,2066,'2test@test.ee',1),
(3,0,2066,'3test@test.ee',1),(4,0,2068,'4test@test.ee',1),
(5,0,2068,'5test@test.ee',1),(6,0,2069,'6test@test.ee',1),(7,0,2070,'',0),
(8,0,2070,'',0),(9,0,2071,'',0),(10,0,2071,'',0),(11,0,2072,'',0),
(12,0,2072,'',0),(13,0,2072,'13test@test.ee',1),(14,0,2073,'14test@test.ee',1),
(15,0,2074,'15test@test.ee',1),(16,0,2075,'16test@test.ee',1),(17,0,2075,'',0),
(18,0,2075,'',0),(19,0,2076,'19test@test.ee',1),(20,0,2077,'',0),
(21,0,2078,'21test@test.ee',1),(22,0,2078,'22test@test.ee',1);
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+10000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+20000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+40000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+80000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+160000, email, reporting_person FROM t2;
CREATE TABLE t3 (
id int PRIMARY KEY,
deleted int,
t1_id int,
YEAR int(4),
quarter int(1),
KEY t1_id (t1_id,year,quarter)
) ENGINE=MyISAM;
INSERT INTO t3 VALUES
(1,0,3885,2020,1),(2,0,2064,2020,1),(3,1611670734,2225,2020,1),
(4,0,2070,2020,1),(5,1611055981,2095,2020,1),(6,1610970096,2102,2020,1),
(7,0,3974,2020,1),(153,1609851928,3892,2020,2),(154,0,3885,2020,2),
(155,0,2064,2020,2),(156,1611670717,2225,2020,2),(157,0,2070,2020,2),
(317,0,2257,2020,2),(318,0,3885,2020,3),(319,0,2064,2020,3),
(320,1611670709,2225,2020,3),(321,0,2070,2020,3),(322,0,2095,2020,3),
(323,0,2102,2020,3),(324,0,3974,2020,3),(325,0,3886,2020,3),
(326,1609939963,2104,2020,3),(327,0,3887,2020,3),(328,0,3888,2020,3),
(329,0,2148,2020,3),(330,0,3889,2020,3),(331,0,3890,2020,3),
(332,0,2179,2020,3),(333,0,2115,2020,3),(334,0,2193,2020,3),
(335,0,2213,2020,3),(336,0,3891,2020,3),(337,1609851955,3892,2020,3),
(338,1610447706,2232,2020,3),(339,0,2235,2020,3),(340,0,2237,2020,3),
(341,0,3972,2020,3),(342,1610449357,2242,2020,3),(343,0,3893,2020,3),
(344,0,2257,2020,3),(345,0,3951,2020,3),(346,0,3894,2020,3),
(347,0,3912,2020,3),(348,0,3895,2020,3),(349,0,2301,2020,3),
(350,0,2304,2020,3),(351,0,3896,2020,3);
ANALYZE TABLE t1,t2,t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
set optimizer_switch='split_materialized=on';
SELECT t1.id
FROM t1
JOIN t3
ON t3.t1_id = t1.id
JOIN (SELECT t1_id FROM t2 WHERE reporting_person = 1 GROUP BY t1_id) tx
ON tx.t1_id = t1.id
WHERE t1.id BETWEEN 200 AND 100000;
id
EXPLAIN SELECT t1.id
FROM t1
JOIN t3
ON t3.t1_id = t1.id
JOIN (SELECT t1_id FROM t2 WHERE reporting_person = 1 GROUP BY t1_id) tx
ON tx.t1_id = t1.id
WHERE t1.id BETWEEN 200 AND 100000;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 range t1_id t1_id 5 NULL 47 Using where; Using index
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.t1_id 1 Using index
1 PRIMARY <derived2> ref key0 key0 5 test.t3.t1_id 2
2 LATERAL DERIVED t2 ref t1_id t1_id 5 test.t1.id 3 Using index condition; Using where
EXPLAIN FORMAT=JSON SELECT t1.id
FROM t1
JOIN t3
ON t3.t1_id = t1.id
JOIN (SELECT t1_id FROM t2 WHERE reporting_person = 1 GROUP BY t1_id) tx
ON tx.t1_id = t1.id
WHERE t1.id BETWEEN 200 AND 100000;
EXPLAIN
{
"query_block": {
"select_id": 1,
"nested_loop": [
{
"table": {
"table_name": "t3",
"access_type": "range",
"possible_keys": ["t1_id"],
"key": "t1_id",
"key_length": "5",
"used_key_parts": ["t1_id"],
"rows": 47,
"filtered": 100,
"attached_condition": "t3.t1_id between 200 and 100000 and t3.t1_id is not null",
"using_index": true
}
},
{
"table": {
"table_name": "t1",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "4",
"used_key_parts": ["id"],
"ref": ["test.t3.t1_id"],
"rows": 1,
"filtered": 100,
"using_index": true
}
},
{
"table": {
"table_name": "<derived2>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "5",
"used_key_parts": ["t1_id"],
"ref": ["test.t3.t1_id"],
"rows": 2,
"filtered": 100,
"materialized": {
"lateral": 1,
"query_block": {
"select_id": 2,
"nested_loop": [
{
"table": {
"table_name": "t2",
"access_type": "ref",
"possible_keys": ["t1_id"],
"key": "t1_id",
"key_length": "5",
"used_key_parts": ["t1_id"],
"ref": ["test.t1.id"],
"rows": 3,
"filtered": 59.09090805,
"index_condition": "t2.t1_id between 200 and 100000 and t2.t1_id = t3.t1_id",
"attached_condition": "t2.reporting_person = 1"
}
}
]
}
}
}
}
]
}
}
set optimizer_switch='split_materialized=off';
SELECT t1.id
FROM t1
JOIN t3
ON t3.t1_id = t1.id
JOIN (SELECT t1_id FROM t2 WHERE reporting_person = 1 GROUP BY t1_id) tx
ON tx.t1_id = t1.id
WHERE t1.id BETWEEN 200 AND 100000;
id
set optimizer_switch='split_materialized=default';
DROP TABLE t1,t2,t3;
#
# MDEV-27510: Splittable derived with grouping over two tables
#
CREATE TABLE ledgers (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(32)
) ENGINE=MyISAM;
CREATE TABLE charges (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
from_ledger_id BIGINT UNSIGNED NOT NULL,
to_ledger_id BIGINT UNSIGNED NOT NULL,
amount INT NOT NULL,
KEY fk_charge_from_ledger (from_ledger_id),
KEY fk_charge_to_ledger (to_ledger_id)
) ENGINE=MyISAM;
CREATE TABLE transactions (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
ledger_id BIGINT UNSIGNED NOT NULL,
KEY fk_transactions_ledger (ledger_id)
) ENGINE=MyISAM;
CREATE TABLE transaction_items (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
transaction_id BIGINT UNSIGNED NOT NULL,
charge_id BIGINT UNSIGNED,
amount INT NOT NULL,
KEY fk_items_transaction (transaction_id),
KEY fk_items_charge (charge_id)
) ENGINE=MyISAM;
INSERT INTO ledgers (id, name) VALUES
(1, 'Anna'), (2, 'John'), (3, 'Fred');
INSERT INTO charges (id, from_ledger_id, to_ledger_id, amount) VALUES
(1, 2, 1, 200), (2, 1, 2, 330), (3, 1, 2, 640), (4, 3, 1, 640), (5, 3, 2, 1000),
(6, 3, 1, 660), (7, 2, 3, 650), (8, 3, 2, 160), (9, 2, 1, 740), (10, 3, 2, 310),
(11, 2, 1, 640), (12, 3, 2, 240), (13, 3, 2, 340), (14, 2, 1, 720),
(15, 2, 3, 100),
(16, 2, 3, 980), (17, 2, 1, 80), (18, 1, 2, 760), (19, 2, 3, 740),
(20, 2, 1, 990);
INSERT INTO transactions (id, ledger_id) VALUES
(2, 1), (3, 1), (5, 1), (8, 1), (12, 1), (18, 1), (22, 1), (28, 1),
(34, 1), (35, 1),
(40, 1), (1, 2), (4, 2), (6, 2), (10, 2), (13, 2), (16, 2), (17, 2),
(20, 2), (21, 2),
(24, 2), (26, 2), (27, 2), (29, 2), (31, 2), (33, 2), (36, 2), (37, 2),
(39, 2), (7, 3),
(9, 3), (11, 3), (14, 3), (15, 3), (19, 3), (23, 3), (25, 3), (30, 3),
(32, 3), (38, 3);
INSERT INTO transaction_items (id, transaction_id, charge_id, amount) VALUES
(1, 1, 1, -200), (2, 2, 1, 200), (3, 3, 2, -330), (4, 4, 2, 330),
(5, 5, 3, -640),
(6, 6, 3, 640), (7, 7, 4, -640), (8, 8, 4, 640), (9, 9, 5, -1000),
(10, 10, 5, 1000),
(11, 11, 6, -660), (12, 12, 6, 660), (13, 13, 7, -650), (14, 14, 7, 650),
(15, 15, 8, -160),
(16, 16, 8, 160), (17, 17, 9, -740), (18, 18, 9, 740), (19, 19, 10, -310),
(20, 20, 10, 310),
(21, 21, 11, -640), (22, 22, 11, 640), (23, 23, 12, -240), (24, 24, 12, 240),
(25, 25, 13, -340),
(26, 26, 13, 340), (27, 27, 14, -720), (28, 28, 14, 720), (29, 29, 15, -100),
(30, 30, 15, 100),
(31, 31, 16, -980), (32, 32, 16, 980), (33, 33, 17, -80), (34, 34, 17, 80),
(35, 35, 18, -760),
(36, 36, 18, 760), (37, 37, 19, -740), (38, 38, 19, 740), (39, 39, 20, -990),
(40, 40, 20, 990);
ANALYZE TABLE ledgers, charges, transactions, transaction_items;
Table Op Msg_type Msg_text
test.ledgers analyze status Engine-independent statistics collected
test.ledgers analyze status OK
test.charges analyze status Engine-independent statistics collected
test.charges analyze status OK
test.transactions analyze status Engine-independent statistics collected
test.transactions analyze status OK
test.transaction_items analyze status Engine-independent statistics collected
test.transaction_items analyze status OK
set optimizer_switch='split_materialized=on';
SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
INNER JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id from_ledger_id to_ledger_id from_num_rows
2 1 2 1
3 1 2 1
5 3 2 1
8 3 2 1
10 3 2 1
12 3 2 1
13 3 2 1
18 1 2 1
EXPLAIN SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
INNER JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY charges ALL PRIMARY,fk_charge_from_ledger,fk_charge_to_ledger NULL NULL NULL 20 Using where
1 PRIMARY <derived2> ref key0 key0 17 test.charges.from_ledger_id,test.charges.id 2
2 LATERAL DERIVED transaction_items ref fk_items_transaction,fk_items_charge fk_items_charge 9 test.charges.id 2
2 LATERAL DERIVED transactions eq_ref PRIMARY,fk_transactions_ledger PRIMARY 8 test.transaction_items.transaction_id 1 Using where
EXPLAIN FORMAT=JSON SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
INNER JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
EXPLAIN
{
"query_block": {
"select_id": 1,
"nested_loop": [
{
"table": {
"table_name": "charges",
"access_type": "ALL",
"possible_keys": [
"PRIMARY",
"fk_charge_from_ledger",
"fk_charge_to_ledger"
],
"rows": 20,
"filtered": 40,
"attached_condition": "charges.to_ledger_id = 2"
}
},
{
"table": {
"table_name": "<derived2>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "17",
"used_key_parts": ["ledger_id", "charge_id"],
"ref": ["test.charges.from_ledger_id", "test.charges.id"],
"rows": 2,
"filtered": 100,
"materialized": {
"lateral": 1,
"query_block": {
"select_id": 2,
"nested_loop": [
{
"table": {
"table_name": "transaction_items",
"access_type": "ref",
"possible_keys": ["fk_items_transaction", "fk_items_charge"],
"key": "fk_items_charge",
"key_length": "9",
"used_key_parts": ["charge_id"],
"ref": ["test.charges.id"],
"rows": 2,
"filtered": 100
}
},
{
"table": {
"table_name": "transactions",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY", "fk_transactions_ledger"],
"key": "PRIMARY",
"key_length": "8",
"used_key_parts": ["id"],
"ref": ["test.transaction_items.transaction_id"],
"rows": 1,
"filtered": 100,
"attached_condition": "transactions.ledger_id = charges.from_ledger_id"
}
}
]
}
}
}
}
]
}
}
set optimizer_switch='split_materialized=off';
SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
INNER JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id from_ledger_id to_ledger_id from_num_rows
2 1 2 1
3 1 2 1
5 3 2 1
8 3 2 1
10 3 2 1
12 3 2 1
13 3 2 1
18 1 2 1
EXPLAIN SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
INNER JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY charges ALL PRIMARY,fk_charge_from_ledger,fk_charge_to_ledger NULL NULL NULL 20 Using where
1 PRIMARY <derived2> ref key0 key0 17 test.charges.from_ledger_id,test.charges.id 4
2 DERIVED transaction_items ALL fk_items_transaction NULL NULL NULL 40 Using temporary; Using filesort
2 DERIVED transactions eq_ref PRIMARY PRIMARY 8 test.transaction_items.transaction_id 1
INSERT INTO charges (id, from_ledger_id, to_ledger_id, amount) VALUES
(101, 4, 2, 100), (102, 7, 2, 200);
set optimizer_switch='split_materialized=on';
SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
LEFT JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id from_ledger_id to_ledger_id from_num_rows
2 1 2 1
3 1 2 1
5 3 2 1
8 3 2 1
10 3 2 1
12 3 2 1
13 3 2 1
18 1 2 1
101 4 2 NULL
102 7 2 NULL
EXPLAIN SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
LEFT JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY charges ALL fk_charge_to_ledger NULL NULL NULL 20 Using where
1 PRIMARY <derived2> ref key0 key0 18 test.charges.from_ledger_id,test.charges.id 2
2 LATERAL DERIVED transaction_items ref fk_items_transaction,fk_items_charge fk_items_charge 9 test.charges.id 2
2 LATERAL DERIVED transactions eq_ref PRIMARY,fk_transactions_ledger PRIMARY 8 test.transaction_items.transaction_id 1 Using where
EXPLAIN FORMAT=JSON SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
LEFT JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
EXPLAIN
{
"query_block": {
"select_id": 1,
"nested_loop": [
{
"table": {
"table_name": "charges",
"access_type": "ALL",
"possible_keys": ["fk_charge_to_ledger"],
"rows": 20,
"filtered": 50,
"attached_condition": "charges.to_ledger_id = 2"
}
},
{
"table": {
"table_name": "<derived2>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "18",
"used_key_parts": ["ledger_id", "charge_id"],
"ref": ["test.charges.from_ledger_id", "test.charges.id"],
"rows": 2,
"filtered": 100,
"materialized": {
"lateral": 1,
"query_block": {
"select_id": 2,
"nested_loop": [
{
"table": {
"table_name": "transaction_items",
"access_type": "ref",
"possible_keys": ["fk_items_transaction", "fk_items_charge"],
"key": "fk_items_charge",
"key_length": "9",
"used_key_parts": ["charge_id"],
"ref": ["test.charges.id"],
"rows": 2,
"filtered": 100
}
},
{
"table": {
"table_name": "transactions",
"access_type": "eq_ref",
"possible_keys": ["PRIMARY", "fk_transactions_ledger"],
"key": "PRIMARY",
"key_length": "8",
"used_key_parts": ["id"],
"ref": ["test.transaction_items.transaction_id"],
"rows": 1,
"filtered": 100,
"attached_condition": "transactions.ledger_id = charges.from_ledger_id"
}
}
]
}
}
}
}
]
}
}
set optimizer_switch='split_materialized=off';
SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
LEFT JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id from_ledger_id to_ledger_id from_num_rows
2 1 2 1
3 1 2 1
5 3 2 1
8 3 2 1
10 3 2 1
12 3 2 1
13 3 2 1
18 1 2 1
101 4 2 NULL
102 7 2 NULL
EXPLAIN SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
LEFT JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY charges ALL fk_charge_to_ledger NULL NULL NULL 20 Using where
1 PRIMARY <derived2> ref key0 key0 18 test.charges.from_ledger_id,test.charges.id 4
2 DERIVED transaction_items ALL fk_items_transaction NULL NULL NULL 40 Using temporary; Using filesort
2 DERIVED transactions eq_ref PRIMARY PRIMARY 8 test.transaction_items.transaction_id 1
set optimizer_switch='split_materialized=default';
DROP TABLE transaction_items;
DROP TABLE transactions;
DROP TABLE charges;
DROP TABLE ledgers;
# End of 10.3 tests
#
# MDEV-18679: materialized view with SELECT S containing materialized

View File

@ -3629,6 +3629,248 @@ deallocate prepare stmt;
drop table t1,t2,t3;
--echo #
--echo # MDEV-MDEV-27132: Splittable derived with equality in WHERE
--echo #
CREATE TABLE t1 (
id int PRIMARY KEY
) ENGINE=MyISAM;
INSERT INTO t1 VALUES
(-1),(2070),(4826),(4827),(4828),(4829),(4830),(4831),(4832),(4833),(4834),
(4835),(4836),(4837),(4838),(4839),(4840),(4841),(4842),(4843),(4844),
(4845),(4846),(4847),(4848),(4849),(4850),(4851),(4852),(4853),(4854),
(4855),(4856),(4857),(4858),(4859),(4860),(4861),(4862),(4863),(4864),
(4865),(4866),(4867),(4868),(4869),(4870),(4871),(4872),(4873),(4874),
(4875),(4876);
CREATE TABLE t2 (
id int PRIMARY KEY AUTO_INCREMENT,
deleted int(1),
t1_id int,
email varchar(255),
reporting_person int(1),
KEY t1_id (t1_id)
) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(1,0,2064,'1test@test.ee',1),(2,1626095588,2066,'2test@test.ee',1),
(3,0,2066,'3test@test.ee',1),(4,0,2068,'4test@test.ee',1),
(5,0,2068,'5test@test.ee',1),(6,0,2069,'6test@test.ee',1),(7,0,2070,'',0),
(8,0,2070,'',0),(9,0,2071,'',0),(10,0,2071,'',0),(11,0,2072,'',0),
(12,0,2072,'',0),(13,0,2072,'13test@test.ee',1),(14,0,2073,'14test@test.ee',1),
(15,0,2074,'15test@test.ee',1),(16,0,2075,'16test@test.ee',1),(17,0,2075,'',0),
(18,0,2075,'',0),(19,0,2076,'19test@test.ee',1),(20,0,2077,'',0),
(21,0,2078,'21test@test.ee',1),(22,0,2078,'22test@test.ee',1);
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+10000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+20000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+40000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+80000, email, reporting_person FROM t2;
INSERT INTO t2(deleted, t1_id, email, reporting_person)
SELECT deleted, t1_id+160000, email, reporting_person FROM t2;
CREATE TABLE t3 (
id int PRIMARY KEY,
deleted int,
t1_id int,
YEAR int(4),
quarter int(1),
KEY t1_id (t1_id,year,quarter)
) ENGINE=MyISAM;
INSERT INTO t3 VALUES
(1,0,3885,2020,1),(2,0,2064,2020,1),(3,1611670734,2225,2020,1),
(4,0,2070,2020,1),(5,1611055981,2095,2020,1),(6,1610970096,2102,2020,1),
(7,0,3974,2020,1),(153,1609851928,3892,2020,2),(154,0,3885,2020,2),
(155,0,2064,2020,2),(156,1611670717,2225,2020,2),(157,0,2070,2020,2),
(317,0,2257,2020,2),(318,0,3885,2020,3),(319,0,2064,2020,3),
(320,1611670709,2225,2020,3),(321,0,2070,2020,3),(322,0,2095,2020,3),
(323,0,2102,2020,3),(324,0,3974,2020,3),(325,0,3886,2020,3),
(326,1609939963,2104,2020,3),(327,0,3887,2020,3),(328,0,3888,2020,3),
(329,0,2148,2020,3),(330,0,3889,2020,3),(331,0,3890,2020,3),
(332,0,2179,2020,3),(333,0,2115,2020,3),(334,0,2193,2020,3),
(335,0,2213,2020,3),(336,0,3891,2020,3),(337,1609851955,3892,2020,3),
(338,1610447706,2232,2020,3),(339,0,2235,2020,3),(340,0,2237,2020,3),
(341,0,3972,2020,3),(342,1610449357,2242,2020,3),(343,0,3893,2020,3),
(344,0,2257,2020,3),(345,0,3951,2020,3),(346,0,3894,2020,3),
(347,0,3912,2020,3),(348,0,3895,2020,3),(349,0,2301,2020,3),
(350,0,2304,2020,3),(351,0,3896,2020,3);
ANALYZE TABLE t1,t2,t3;
let $q=
SELECT t1.id
FROM t1
JOIN t3
ON t3.t1_id = t1.id
JOIN (SELECT t1_id FROM t2 WHERE reporting_person = 1 GROUP BY t1_id) tx
ON tx.t1_id = t1.id
WHERE t1.id BETWEEN 200 AND 100000;
set optimizer_switch='split_materialized=on';
eval $q;
eval EXPLAIN $q;
eval EXPLAIN FORMAT=JSON $q;
set optimizer_switch='split_materialized=off';
eval $q;
set optimizer_switch='split_materialized=default';
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-27510: Splittable derived with grouping over two tables
--echo #
CREATE TABLE ledgers (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(32)
) ENGINE=MyISAM;
CREATE TABLE charges (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
from_ledger_id BIGINT UNSIGNED NOT NULL,
to_ledger_id BIGINT UNSIGNED NOT NULL,
amount INT NOT NULL,
KEY fk_charge_from_ledger (from_ledger_id),
KEY fk_charge_to_ledger (to_ledger_id)
) ENGINE=MyISAM;
CREATE TABLE transactions (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
ledger_id BIGINT UNSIGNED NOT NULL,
KEY fk_transactions_ledger (ledger_id)
) ENGINE=MyISAM;
CREATE TABLE transaction_items (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
transaction_id BIGINT UNSIGNED NOT NULL,
charge_id BIGINT UNSIGNED,
amount INT NOT NULL,
KEY fk_items_transaction (transaction_id),
KEY fk_items_charge (charge_id)
) ENGINE=MyISAM;
INSERT INTO ledgers (id, name) VALUES
(1, 'Anna'), (2, 'John'), (3, 'Fred');
INSERT INTO charges (id, from_ledger_id, to_ledger_id, amount) VALUES
(1, 2, 1, 200), (2, 1, 2, 330), (3, 1, 2, 640), (4, 3, 1, 640), (5, 3, 2, 1000),
(6, 3, 1, 660), (7, 2, 3, 650), (8, 3, 2, 160), (9, 2, 1, 740), (10, 3, 2, 310),
(11, 2, 1, 640), (12, 3, 2, 240), (13, 3, 2, 340), (14, 2, 1, 720),
(15, 2, 3, 100),
(16, 2, 3, 980), (17, 2, 1, 80), (18, 1, 2, 760), (19, 2, 3, 740),
(20, 2, 1, 990);
INSERT INTO transactions (id, ledger_id) VALUES
(2, 1), (3, 1), (5, 1), (8, 1), (12, 1), (18, 1), (22, 1), (28, 1),
(34, 1), (35, 1),
(40, 1), (1, 2), (4, 2), (6, 2), (10, 2), (13, 2), (16, 2), (17, 2),
(20, 2), (21, 2),
(24, 2), (26, 2), (27, 2), (29, 2), (31, 2), (33, 2), (36, 2), (37, 2),
(39, 2), (7, 3),
(9, 3), (11, 3), (14, 3), (15, 3), (19, 3), (23, 3), (25, 3), (30, 3),
(32, 3), (38, 3);
INSERT INTO transaction_items (id, transaction_id, charge_id, amount) VALUES
(1, 1, 1, -200), (2, 2, 1, 200), (3, 3, 2, -330), (4, 4, 2, 330),
(5, 5, 3, -640),
(6, 6, 3, 640), (7, 7, 4, -640), (8, 8, 4, 640), (9, 9, 5, -1000),
(10, 10, 5, 1000),
(11, 11, 6, -660), (12, 12, 6, 660), (13, 13, 7, -650), (14, 14, 7, 650),
(15, 15, 8, -160),
(16, 16, 8, 160), (17, 17, 9, -740), (18, 18, 9, 740), (19, 19, 10, -310),
(20, 20, 10, 310),
(21, 21, 11, -640), (22, 22, 11, 640), (23, 23, 12, -240), (24, 24, 12, 240),
(25, 25, 13, -340),
(26, 26, 13, 340), (27, 27, 14, -720), (28, 28, 14, 720), (29, 29, 15, -100),
(30, 30, 15, 100),
(31, 31, 16, -980), (32, 32, 16, 980), (33, 33, 17, -80), (34, 34, 17, 80),
(35, 35, 18, -760),
(36, 36, 18, 760), (37, 37, 19, -740), (38, 38, 19, 740), (39, 39, 20, -990),
(40, 40, 20, 990);
ANALYZE TABLE ledgers, charges, transactions, transaction_items;
let $q=
SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
INNER JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
set optimizer_switch='split_materialized=on';
eval $q;
eval EXPLAIN $q;
eval EXPLAIN FORMAT=JSON $q;
set optimizer_switch='split_materialized=off';
eval $q;
eval EXPLAIN $q;
INSERT INTO charges (id, from_ledger_id, to_ledger_id, amount) VALUES
(101, 4, 2, 100), (102, 7, 2, 200);
let $q1=
SELECT
charges.id,
charges.from_ledger_id,
charges.to_ledger_id,
from_agg_items.num_rows AS from_num_rows
FROM charges
LEFT JOIN (
SELECT
transactions.ledger_id,
transaction_items.charge_id,
count(*) as num_rows
FROM transaction_items
INNER JOIN transactions ON transaction_items.transaction_id = transactions.id
GROUP BY transactions.ledger_id, transaction_items.charge_id
) AS from_agg_items
ON from_agg_items.charge_id = charges.id AND
from_agg_items.ledger_id = charges.from_ledger_id
WHERE charges.to_ledger_id = 2;
set optimizer_switch='split_materialized=on';
eval $q1;
eval EXPLAIN $q1;
eval EXPLAIN FORMAT=JSON $q1;
set optimizer_switch='split_materialized=off';
eval $q1;
eval EXPLAIN $q1;
set optimizer_switch='split_materialized=default';
DROP TABLE transaction_items;
DROP TABLE transactions;
DROP TABLE charges;
DROP TABLE ledgers;
--echo # End of 10.3 tests
--echo #

View File

@ -242,5 +242,49 @@ drop table t1,t2,t3;
set optimizer_switch='split_materialized=default';
set use_stat_tables=default;
set optimizer_use_condition_selectivity=default;
#
# MDEV-26337: subquery with groupby and ROLLUP returns incorrect results
# (The testcase is taken from testcase for MDEV-13389 due to it being
# much smaller)
#
create table t3 (a int, b int, c char(127), index idx_b(b)) engine=myisam;
insert into t3 values
(8,11,'aa'), (5,15,'cc'), (1,14,'bb'), (2,12,'aa'), (7,17,'cc'),
(7,18,'aa'), (2,11,'aa'), (7,10,'bb'), (3,11,'dd'), (4,12,'ee'),
(5,14,'dd'), (9,12,'ee');
create table t4 (a int, b int, c char(127), index idx(a,c)) engine=myisam;
insert into t4 values
(7,10,'cc'), (1,20,'aa'), (2,23,'bb'), (7,18,'cc'), (1,30,'bb'),
(4,71,'xx'), (3,15,'aa'), (7,82,'aa'), (8,12,'dd'), (4,15,'aa'),
(11,33,'yy'), (10,42,'zz'), (4,53,'xx'), (10,17,'yy'), (7,12,'cc'),
(8,20,'dd'), (7,32,'bb'), (1,50,'aa'), (3,40,'bb'), (3,77,'aa');
insert into t4 select a+10, b+10, concat(c,'f') from t4;
analyze table t3,t4;
Table Op Msg_type Msg_text
test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
test.t4 analyze status Engine-independent statistics collected
test.t4 analyze status OK
# This should use a plan with LATERAL DERIVED:
explain select t3.a,t3.c,t.max,t.min
from t3 join
(select a, c, max(b) max, min(b) min from t4 group by a,c) t
on t3.a=t.a and t3.c=t.c
where t3.b > 15;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 range idx_b idx_b 5 NULL 2 Using index condition; Using where
1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 2
2 LATERAL DERIVED t4 ref idx idx 133 test.t3.a,test.t3.c 1
# ... and if one adds WITH ROLLUP, then LATERAL DERIVED is no longer used:
explain select t3.a,t3.c,t.max,t.min
from t3 join
(select a, c, max(b) max, min(b) min from t4 group by a,c with rollup) t
on t3.a=t.a and t3.c=t.c
where t3.b > 15;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 range idx_b idx_b 5 NULL 2 Using index condition; Using where
1 PRIMARY <derived2> ref key0 key0 133 test.t3.a,test.t3.c 4
2 DERIVED t4 ALL NULL NULL NULL NULL 40 Using filesort
drop table t3, t4;
# End of 10.3 tests
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;

View File

@ -195,6 +195,42 @@ set optimizer_switch='split_materialized=default';
set use_stat_tables=default;
set optimizer_use_condition_selectivity=default;
--echo #
--echo # MDEV-26337: subquery with groupby and ROLLUP returns incorrect results
--echo # (The testcase is taken from testcase for MDEV-13389 due to it being
--echo # much smaller)
--echo #
create table t3 (a int, b int, c char(127), index idx_b(b)) engine=myisam;
insert into t3 values
(8,11,'aa'), (5,15,'cc'), (1,14,'bb'), (2,12,'aa'), (7,17,'cc'),
(7,18,'aa'), (2,11,'aa'), (7,10,'bb'), (3,11,'dd'), (4,12,'ee'),
(5,14,'dd'), (9,12,'ee');
create table t4 (a int, b int, c char(127), index idx(a,c)) engine=myisam;
insert into t4 values
(7,10,'cc'), (1,20,'aa'), (2,23,'bb'), (7,18,'cc'), (1,30,'bb'),
(4,71,'xx'), (3,15,'aa'), (7,82,'aa'), (8,12,'dd'), (4,15,'aa'),
(11,33,'yy'), (10,42,'zz'), (4,53,'xx'), (10,17,'yy'), (7,12,'cc'),
(8,20,'dd'), (7,32,'bb'), (1,50,'aa'), (3,40,'bb'), (3,77,'aa');
insert into t4 select a+10, b+10, concat(c,'f') from t4;
analyze table t3,t4;
--echo # This should use a plan with LATERAL DERIVED:
explain select t3.a,t3.c,t.max,t.min
from t3 join
(select a, c, max(b) max, min(b) min from t4 group by a,c) t
on t3.a=t.a and t3.c=t.c
where t3.b > 15;
--echo # ... and if one adds WITH ROLLUP, then LATERAL DERIVED is no longer used:
explain select t3.a,t3.c,t.max,t.min
from t3 join
(select a, c, max(b) max, min(b) min from t4 group by a,c with rollup) t
on t3.a=t.a and t3.c=t.c
where t3.b > 15;
drop table t3, t4;
--echo # End of 10.3 tests
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;

View File

@ -2459,8 +2459,6 @@ SELECT * FROM t1;
a
1
1
1
1
drop table t1,t2;
set optimizer_switch=@save968720_optimizer_switch;
#
@ -3576,4 +3574,134 @@ a
7
drop view v1;
drop table t1;
#
# MDEV-24454 Second execution of SELECT containing set function
# MDEV-25086: whose only argument is an outer reference to a column
# of mergeable view/derived/table/CTE
#
create table t1 (a int);
create table t2 (b int);
insert into t1 values (3), (1), (3);
insert into t2 values (70), (30), (70);
create view v1 as select * from t2;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r from v1;
";
execute stmt;
r
170
execute stmt;
r
170
deallocate prepare stmt;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r from (select * from t2) dt;
";
execute stmt;
r
170
execute stmt;
r
170
deallocate prepare stmt;
prepare stmt from "
with cte as (select * from t2)
select (select sum(b) from t1 where a=1) as r from cte;
";
execute stmt;
r
170
execute stmt;
r
170
deallocate prepare stmt;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r
from (select * from v1 where b > 50) dt;
";
execute stmt;
r
140
execute stmt;
r
140
deallocate prepare stmt;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r
from (select * from (select * from t2) dt1 where b > 50) dt;
";
execute stmt;
r
140
execute stmt;
r
140
deallocate prepare stmt;
prepare stmt from "
with cte as (select * from (select * from t2) dt1 where b > 50)
select (select sum(b) from t1 where a=1) as r from cte;
";
execute stmt;
r
140
execute stmt;
r
140
deallocate prepare stmt;
create procedure sp1()
begin
select (select sum(b) from t1 where a=1) as r from v1;
end |
call sp1();
r
170
call sp1();
r
170
drop procedure sp1;
create procedure sp1()
begin
select (select sum(b) from t1 where a=1) as r from (select * from t2) dt;
end |
call sp1();
r
170
call sp1();
r
170
drop procedure sp1;
create procedure sp1()
begin
with cte as (select * from t2)
select (select sum(b) from t1 where a=1) as r from cte;
end |
call sp1();
r
170
call sp1();
r
170
drop procedure sp1;
drop view v1;
drop table t1,t2;
CREATE TABLE t1(f0 INT);
INSERT INTO t1 VALUES (3);
CREATE VIEW v1 AS SELECT f0 AS f1 FROM t1;
CREATE VIEW v2 AS
SELECT
(SELECT GROUP_CONCAT(v1.f1 SEPARATOR ', ') FROM v1 n) AS f2,
GROUP_CONCAT('aa' SEPARATOR ', ') AS f3
FROM v1;
CREATE VIEW v3 AS SELECT * FROM v2;
CREATE PROCEDURE p1()
SELECT * FROM v3;
CALL p1();
f2 f3
3 aa
CALL p1();
f2 f3
3 aa
DROP PROCEDURE p1;
DROP VIEW v1,v2,v3;
DROP TABLE t1;
# End of 10.2 tests

View File

@ -2289,4 +2289,115 @@ select * from ((select a from t1 limit 2) order by a desc) dt;
drop view v1;
drop table t1;
--echo #
--echo # MDEV-24454 Second execution of SELECT containing set function
--echo # MDEV-25086: whose only argument is an outer reference to a column
--echo # of mergeable view/derived/table/CTE
--echo #
create table t1 (a int);
create table t2 (b int);
insert into t1 values (3), (1), (3);
insert into t2 values (70), (30), (70);
create view v1 as select * from t2;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r from v1;
";
execute stmt;
execute stmt;
deallocate prepare stmt;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r from (select * from t2) dt;
";
execute stmt;
execute stmt;
deallocate prepare stmt;
prepare stmt from "
with cte as (select * from t2)
select (select sum(b) from t1 where a=1) as r from cte;
";
execute stmt;
execute stmt;
deallocate prepare stmt;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r
from (select * from v1 where b > 50) dt;
";
execute stmt;
execute stmt;
deallocate prepare stmt;
prepare stmt from "
select (select sum(b) from t1 where a=1) as r
from (select * from (select * from t2) dt1 where b > 50) dt;
";
execute stmt;
execute stmt;
deallocate prepare stmt;
prepare stmt from "
with cte as (select * from (select * from t2) dt1 where b > 50)
select (select sum(b) from t1 where a=1) as r from cte;
";
execute stmt;
execute stmt;
deallocate prepare stmt;
--delimiter |
create procedure sp1()
begin
select (select sum(b) from t1 where a=1) as r from v1;
end |
--delimiter ;
call sp1();
call sp1();
drop procedure sp1;
--delimiter |
create procedure sp1()
begin
select (select sum(b) from t1 where a=1) as r from (select * from t2) dt;
end |
--delimiter ;
call sp1();
call sp1();
drop procedure sp1;
--delimiter |
create procedure sp1()
begin
with cte as (select * from t2)
select (select sum(b) from t1 where a=1) as r from cte;
end |
--delimiter ;
call sp1();
call sp1();
drop procedure sp1;
drop view v1;
drop table t1,t2;
CREATE TABLE t1(f0 INT);
INSERT INTO t1 VALUES (3);
CREATE VIEW v1 AS SELECT f0 AS f1 FROM t1;
CREATE VIEW v2 AS
SELECT
(SELECT GROUP_CONCAT(v1.f1 SEPARATOR ', ') FROM v1 n) AS f2,
GROUP_CONCAT('aa' SEPARATOR ', ') AS f3
FROM v1;
CREATE VIEW v3 AS SELECT * FROM v2;
CREATE PROCEDURE p1()
SELECT * FROM v3;
CALL p1();
CALL p1();
DROP PROCEDURE p1;
DROP VIEW v1,v2,v3;
DROP TABLE t1;
--echo # End of 10.2 tests

View File

@ -20,3 +20,4 @@ partition_open_files_limit : open_files_limit check broken by MDEV-18360
partition_innodb : Waiting for fix MDEV-20169
type_enum : Waiting for fix MDEV-6978
type_set : Waiting for fix MDEV-6978
mysqldump-system : FIXME nondeterministic

View File

@ -2,4 +2,3 @@
--error 1193
set global event_scheduler=ON;

View File

@ -0,0 +1,20 @@
#
# MDEV-26249: Crash in in Explain_node::print_explain_for_children while writing to the slow query log
#
set @sql_tmp=@@slow_query_log;
SET GLOBAL slow_query_log = 1;
SET long_query_time = 0.000000;
SET log_slow_verbosity = 'explain';
CREATE TABLE t1 ( id varchar(50), KEY (id)) engine=innodb;
SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;
id
select 1;
1
1
explain
SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 DERIVED t1 range NULL id 53 NULL 2 Using index for group-by
SET GLOBAL slow_query_log = @sql_tmp;
drop table t1;

View File

@ -0,0 +1,20 @@
--echo #
--echo # MDEV-26249: Crash in in Explain_node::print_explain_for_children while writing to the slow query log
--echo #
--source include/have_innodb.inc
set @sql_tmp=@@slow_query_log;
SET GLOBAL slow_query_log = 1;
SET long_query_time = 0.000000;
SET log_slow_verbosity = 'explain';
CREATE TABLE t1 ( id varchar(50), KEY (id)) engine=innodb;
SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;
select 1;
explain
SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;
SET GLOBAL slow_query_log = @sql_tmp;
drop table t1;

View File

@ -29,6 +29,9 @@ INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
ERROR HY000: Field 'mi' doesn't have a default value
DROP TABLE t1;
#
# Start of 10.2 tests
#
set timestamp=unix_timestamp('2001-01-01 10:20:30.123456');
create table t1 (a int default 1, b int default (a+1),
c varchar(100) default 'foo', d text default 'bar',
@ -40,3 +43,121 @@ default(a) default(b) default(c) default(d) default(e) default(f)
1 2 foo bar 2001-01-01 10:20:30 2001-01-01 10:20:30.120000
1 11 foo bar 2001-01-01 10:20:30 2001-01-01 10:20:30.120000
drop table t1;
#
# MDEV-21639 DEFAULT(col) evaluates to a bad value in WHERE clause
#
CREATE TABLE t1 (a BIGINT NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = 10 AS ce
FROM t1;
a DEFAULT(a) c ce
10000 10 10 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END=10;
a
10000
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = 10 AS ce
FROM t1;
a DEFAULT(a) c ce
10000 10 10 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END=10;
a
10000
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL(10,0) NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = 10 AS ce
FROM t1;
a DEFAULT(a) c ce
10000 10 10 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END=10;
a
10000
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(32) NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '10' AS ce
FROM t1;
a DEFAULT(a) c ce
10000 10 10 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='10';
a
10000
DROP TABLE t1;
CREATE TABLE t1 (a DATE NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP()%10,DATE'2001-01-01')));
INSERT INTO t1 VALUES ('2000-01-01');
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '2001-01-01' AS ce
FROM t1;
a DEFAULT(a) c ce
2000-01-01 2001-01-01 2001-01-01 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='2001-01-01';
a
2000-01-01
DROP TABLE t1;
CREATE TABLE t1 (a TIME NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP()%10,TIME'10:20:30')));
INSERT INTO t1 VALUES ('10:00:00');
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '10:20:30' AS ce
FROM t1;
a DEFAULT(a) c ce
10:00:00 10:20:30 10:20:30 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='10:20:30';
a
10:00:00
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),TIMESTAMP'2001-01-01 10:20:30')));
INSERT INTO t1 VALUES ('2000-01-01 10:00:00');
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '2001-01-01 10:20:30' AS ce
FROM t1;
a DEFAULT(a) c ce
2000-01-01 10:00:00 2001-01-01 10:20:30 2001-01-01 10:20:30 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='2001-01-01 10:20:30';
a
2000-01-01 10:00:00
DROP TABLE t1;
CREATE TABLE t1 (a INT NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),FALSE)));
INSERT INTO t1 VALUES (10);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END IS FALSE AS ce
FROM t1;
a DEFAULT(a) c ce
10 0 0 1
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END IS FALSE;
a
10
DROP TABLE t1;
#
# End of 10.2 tests
#

View File

@ -34,9 +34,9 @@ INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
DROP TABLE t1;
#
# 10.2 tests
#
--echo #
--echo # Start of 10.2 tests
--echo #
set timestamp=unix_timestamp('2001-01-01 10:20:30.123456');
create table t1 (a int default 1, b int default (a+1),
@ -46,3 +46,99 @@ insert t1 () values ();
insert t1 (a) values (10);
select default(a),default(b),default(c),default(d),default(e),default(f) from t1;
drop table t1;
--echo #
--echo # MDEV-21639 DEFAULT(col) evaluates to a bad value in WHERE clause
--echo #
CREATE TABLE t1 (a BIGINT NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = 10 AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END=10;
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = 10 AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END=10;
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL(10,0) NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = 10 AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END=10;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(32) NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),10)));
INSERT INTO t1 VALUES (10000);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '10' AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='10';
DROP TABLE t1;
CREATE TABLE t1 (a DATE NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP()%10,DATE'2001-01-01')));
INSERT INTO t1 VALUES ('2000-01-01');
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '2001-01-01' AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='2001-01-01';
DROP TABLE t1;
CREATE TABLE t1 (a TIME NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP()%10,TIME'10:20:30')));
INSERT INTO t1 VALUES ('10:00:00');
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '10:20:30' AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='10:20:30';
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),TIMESTAMP'2001-01-01 10:20:30')));
INSERT INTO t1 VALUES ('2000-01-01 10:00:00');
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END = '2001-01-01 10:20:30' AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END='2001-01-01 10:20:30';
DROP TABLE t1;
CREATE TABLE t1 (a INT NOT NULL DEFAULT (IF(false,UNIX_TIMESTAMP(),FALSE)));
INSERT INTO t1 VALUES (10);
SELECT
a,
DEFAULT(a),
CASE WHEN a THEN DEFAULT(a) END AS c,
CASE WHEN a THEN DEFAULT(a) END IS FALSE AS ce
FROM t1;
SELECT a FROM t1 WHERE CASE WHEN a THEN DEFAULT(a) END IS FALSE;
DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
--echo #

View File

@ -604,7 +604,7 @@ AME AME
explain
select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 0 NULL 15 Using where; Using index
1 SIMPLE t1 index PRIMARY PRIMARY 3 NULL 15 Using where; Using index
explain
select min(a1) from t1 where (a1 < 'KKK' or a1 > 'KKK');
id select_type table type possible_keys key key_len ref rows Extra

View File

@ -940,6 +940,24 @@ SELECT JSON_REPLACE( JSON_DETAILED('["x"]'), '$.a', 'xx' );
JSON_REPLACE( JSON_DETAILED('["x"]'), '$.a', 'xx' )
["x"]
#
# MDEV-18284 JSON casting using JSON_COMPACT doesn't always work
# with values from subqueries
#
CREATE TABLE json_test(a JSON, b JSON);
INSERT INTO json_test VALUES ("[1,2,3]", '{"a":"foo"}');
SELECT * FROM json_test;
a b
[1,2,3] {"a":"foo"}
SELECT json_object("a", json_compact(a), "b", b)
FROM (SELECT * FROM json_test) AS json_test_values;
json_object("a", json_compact(a), "b", b)
{"a": [1,2,3], "b": {"a":"foo"}}
SELECT json_object("a", json_compact(a), "b", json_compact(b))
FROM (SELECT * FROM json_test) AS json_test_values;
json_object("a", json_compact(a), "b", json_compact(b))
{"a": [1,2,3], "b": {"a":"foo"}}
DROP TABLE json_test;
#
# End of 10.2 tests
#
#
@ -1388,6 +1406,15 @@ id materials
DROP TABLE t1;
DROP TABLE t2;
#
# MDEV-27018 IF and COALESCE lose "json" property
#
SELECT json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f')));
json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f')))
{"a": {"b": "c"}}
SELECT json_object('a', coalesce(json_object('b', 'c')));
json_object('a', coalesce(json_object('b', 'c')))
{"a": {"b": "c"}}
#
# MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field
#
CREATE TABLE t (a VARCHAR(8));

View File

@ -557,6 +557,21 @@ SELECT
SELECT JSON_REPLACE( JSON_DETAILED('["x"]'), '$.a', 'xx' );
--echo #
--echo # MDEV-18284 JSON casting using JSON_COMPACT doesn't always work
--echo # with values from subqueries
--echo #
CREATE TABLE json_test(a JSON, b JSON);
INSERT INTO json_test VALUES ("[1,2,3]", '{"a":"foo"}');
SELECT * FROM json_test;
SELECT json_object("a", json_compact(a), "b", b)
FROM (SELECT * FROM json_test) AS json_test_values;
SELECT json_object("a", json_compact(a), "b", json_compact(b))
FROM (SELECT * FROM json_test) AS json_test_values;
DROP TABLE json_test;
--echo #
--echo # End of 10.2 tests
--echo #
@ -879,6 +894,14 @@ SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials
DROP TABLE t1;
DROP TABLE t2;
--echo #
--echo # MDEV-27018 IF and COALESCE lose "json" property
--echo #
SELECT json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f')));
SELECT json_object('a', coalesce(json_object('b', 'c')));
--echo #
--echo # MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field
--echo #

View File

@ -0,0 +1,42 @@
set global max_allowed_packet=1073741824;
connect u,localhost,root;
#
# MDEV-24909 JSON functions don't respect KILL QUERY / max_statement_time limit
#
set group_concat_max_len= 4294967295;
set @obj=concat_ws('','{', repeat('"a":"b",', 125000000/2), '"c":"d"}');
set @arr=concat_ws('','[', repeat('1234567,', 125000000/2), '2345678]');
select length(@obj), length(@arr);
length(@obj) length(@arr)
500000009 500000009
set max_statement_time=0.0001;
select json_array_append(@arr, '$[0]', 1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_array_insert(@arr, '$[0]', 1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_insert(@obj, '$.meta', 1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_compact(@arr);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_detailed(@arr);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_loose(@arr);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_merge(@obj, @arr);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_merge_patch(@obj, @obj);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_merge_preserve(@obj, @arr);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_remove(@obj,'$.foo');
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_replace(@obj,'$.foo',1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_set(@arr,'$[1000]',1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
disconnect u;
connection default;
set global max_allowed_packet=default;
#
# End of 10.6 tests
#

View File

@ -0,0 +1,37 @@
source include/have_profiling.inc;
source include/not_embedded.inc;
set global max_allowed_packet=1073741824;
connect u,localhost,root;
--echo #
--echo # MDEV-24909 JSON functions don't respect KILL QUERY / max_statement_time limit
--echo #
set group_concat_max_len= 4294967295;
set @obj=concat_ws('','{', repeat('"a":"b",', 125000000/2), '"c":"d"}');
set @arr=concat_ws('','[', repeat('1234567,', 125000000/2), '2345678]');
select length(@obj), length(@arr);
set max_statement_time=0.0001;
disable_abort_on_error;
select json_array_append(@arr, '$[0]', 1);
select json_array_insert(@arr, '$[0]', 1);
select json_insert(@obj, '$.meta', 1);
select json_compact(@arr);
select json_detailed(@arr);
select json_loose(@arr);
select json_merge(@obj, @arr);
select json_merge_patch(@obj, @obj);
select json_merge_preserve(@obj, @arr);
select json_remove(@obj,'$.foo');
select json_replace(@obj,'$.foo',1);
select json_set(@arr,'$[1000]',1);
enable_abort_on_error;
disconnect u;
connection default;
set global max_allowed_packet=default;
--echo #
--echo # End of 10.6 tests
--echo #

View File

@ -5028,6 +5028,59 @@ SELECT NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux');
NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux')
NULL
#
# Bug#31374305 - FORMAT() NOT DISPLAYING WHOLE NUMBER SIDE CORRECTLY
# FOR ES_MX AND ES_ES LOCALES
#
CREATE PROCEDURE load_locale_format_table()
BEGIN
DECLARE locale_list VARCHAR(1000) DEFAULT '
es_AR,es_BO,es_CL,es_CO,es_CR,es_DO,es_EC,es_ES,es_GT,es_HN,
es_MX,es_NI,es_PA,es_PE,es_PR,es_PY,es_SV,es_US,es_UY,es_VE';
SET @fmt_stmt = 'INSERT INTO locale_format VALUES
(?, FORMAT(12131254123412541,2,?));';
PREPARE stmt FROM @fmt_stmt;
WHILE locale_list != '' DO
/* get the first locale from the list */
SET @locale =
TRIM(REPLACE((SUBSTRING_INDEX(locale_list, ',', 1)), '\n',''));
EXECUTE stmt USING @locale, @locale;
/* remove the first locale from the list */
IF LOCATE(',', locale_list) > 0 THEN
SET locale_list =
SUBSTRING(locale_list, LOCATE(',', locale_list) + 1);
ELSE
SET locale_list = '';
END IF;
END WHILE;
DEALLOCATE PREPARE stmt;
END|
CREATE TABLE locale_format(locale VARCHAR(10), formatted_string VARCHAR(100));
CALL load_locale_format_table();
SELECT * FROM locale_format;
locale formatted_string
es_AR 12.131.254.123.412.541,00
es_BO 12.131.254.123.412.541,00
es_CL 12.131.254.123.412.541,00
es_CO 12.131.254.123.412.541,00
es_CR 12 131 254 123 412 541,00
es_DO 12,131,254,123,412,541.00
es_EC 12.131.254.123.412.541,00
es_ES 12.131.254.123.412.541,00
es_GT 12,131,254,123,412,541.00
es_HN 12,131,254,123,412,541.00
es_MX 12,131,254,123,412,541.00
es_NI 12,131,254,123,412,541.00
es_PA 12,131,254,123,412,541.00
es_PE 12,131,254,123,412,541.00
es_PR 12,131,254,123,412,541.00
es_PY 12.131.254.123.412.541,00
es_SV 12,131,254,123,412,541.00
es_US 12,131,254,123,412,541.00
es_UY 12.131.254.123.412.541,00
es_VE 12.131.254.123.412.541,00
DROP PROCEDURE load_locale_format_table;
DROP TABLE locale_format;
#
# End of 10.2 tests
#
#

View File

@ -2000,6 +2000,42 @@ DROP TABLE t1;
SELECT NULL IN (RIGHT(AES_ENCRYPT('foo','bar'), LAST_INSERT_ID()), 'qux');
--echo #
--echo # Bug#31374305 - FORMAT() NOT DISPLAYING WHOLE NUMBER SIDE CORRECTLY
--echo # FOR ES_MX AND ES_ES LOCALES
--echo #
DELIMITER |;
CREATE PROCEDURE load_locale_format_table()
BEGIN
DECLARE locale_list VARCHAR(1000) DEFAULT '
es_AR,es_BO,es_CL,es_CO,es_CR,es_DO,es_EC,es_ES,es_GT,es_HN,
es_MX,es_NI,es_PA,es_PE,es_PR,es_PY,es_SV,es_US,es_UY,es_VE';
SET @fmt_stmt = 'INSERT INTO locale_format VALUES
(?, FORMAT(12131254123412541,2,?));';
PREPARE stmt FROM @fmt_stmt;
WHILE locale_list != '' DO
/* get the first locale from the list */
SET @locale =
TRIM(REPLACE((SUBSTRING_INDEX(locale_list, ',', 1)), '\n',''));
EXECUTE stmt USING @locale, @locale;
/* remove the first locale from the list */
IF LOCATE(',', locale_list) > 0 THEN
SET locale_list =
SUBSTRING(locale_list, LOCATE(',', locale_list) + 1);
ELSE
SET locale_list = '';
END IF;
END WHILE;
DEALLOCATE PREPARE stmt;
END|
DELIMITER ;|
CREATE TABLE locale_format(locale VARCHAR(10), formatted_string VARCHAR(100));
CALL load_locale_format_table();
SELECT * FROM locale_format;
DROP PROCEDURE load_locale_format_table;
DROP TABLE locale_format;
--echo #
--echo # End of 10.2 tests

View File

@ -46,7 +46,7 @@ create table t1 (version char(60)) select database(), user(), version() as 'vers
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`database()` varchar(34) CHARACTER SET utf8mb3 DEFAULT NULL,
`database()` varchar(64) CHARACTER SET utf8mb3 DEFAULT NULL,
`user()` varchar(384) CHARACTER SET utf8mb3 DEFAULT NULL,
`version` char(60) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
@ -95,3 +95,21 @@ select left(concat(a,version()),1) from t1;
left(concat(a,version()),1)
a
drop table t1;
#
# Start of 10.2 tests
#
MDEV-27544 database() function under UNION ALL truncates results to 34 characters
SET NAMES utf8;
create database betäubungsmittelverschreibungsverordnung;
use betäubungsmittelverschreibungsverordnung;
select database() as "database" union all select database();
database
betäubungsmittelverschreibungsverordnung
betäubungsmittelverschreibungsverordnung
drop database betäubungsmittelverschreibungsverordnung;
#
# End of 10.2 tests
#

View File

@ -55,3 +55,23 @@ select left(concat(a,version()),1) from t1;
drop table t1;
# End of 4.1 tests
--echo #
--echo # Start of 10.2 tests
--echo #
--echo
--echo MDEV-27544 database() function under UNION ALL truncates results to 34 characters
--echo
--echo
SET NAMES utf8;
create database betäubungsmittelverschreibungsverordnung;
use betäubungsmittelverschreibungsverordnung;
select database() as "database" union all select database();
drop database betäubungsmittelverschreibungsverordnung;
--echo #
--echo # End of 10.2 tests
--echo #

View File

@ -1746,27 +1746,27 @@ drop table t1;
SHOW CREATE TABLE information_schema.geometry_columns;
Table Create Table
GEOMETRY_COLUMNS CREATE TEMPORARY TABLE `GEOMETRY_COLUMNS` (
`F_TABLE_CATALOG` varchar(512) NOT NULL DEFAULT '',
`F_TABLE_SCHEMA` varchar(64) NOT NULL DEFAULT '',
`F_TABLE_NAME` varchar(64) NOT NULL DEFAULT '',
`F_GEOMETRY_COLUMN` varchar(64) NOT NULL DEFAULT '',
`G_TABLE_CATALOG` varchar(512) NOT NULL DEFAULT '',
`G_TABLE_SCHEMA` varchar(64) NOT NULL DEFAULT '',
`G_TABLE_NAME` varchar(64) NOT NULL DEFAULT '',
`G_GEOMETRY_COLUMN` varchar(64) NOT NULL DEFAULT '',
`STORAGE_TYPE` tinyint(2) NOT NULL DEFAULT 0,
`GEOMETRY_TYPE` int(7) NOT NULL DEFAULT 0,
`COORD_DIMENSION` tinyint(2) NOT NULL DEFAULT 0,
`MAX_PPR` tinyint(2) NOT NULL DEFAULT 0,
`SRID` smallint(5) NOT NULL DEFAULT 0
`F_TABLE_CATALOG` varchar(512) NOT NULL,
`F_TABLE_SCHEMA` varchar(64) NOT NULL,
`F_TABLE_NAME` varchar(64) NOT NULL,
`F_GEOMETRY_COLUMN` varchar(64) NOT NULL,
`G_TABLE_CATALOG` varchar(512) NOT NULL,
`G_TABLE_SCHEMA` varchar(64) NOT NULL,
`G_TABLE_NAME` varchar(64) NOT NULL,
`G_GEOMETRY_COLUMN` varchar(64) NOT NULL,
`STORAGE_TYPE` tinyint(2) NOT NULL,
`GEOMETRY_TYPE` int(7) NOT NULL,
`COORD_DIMENSION` tinyint(2) NOT NULL,
`MAX_PPR` tinyint(2) NOT NULL,
`SRID` smallint(5) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
SHOW CREATE TABLE information_schema.spatial_ref_sys;
Table Create Table
SPATIAL_REF_SYS CREATE TEMPORARY TABLE `SPATIAL_REF_SYS` (
`SRID` smallint(5) NOT NULL DEFAULT 0,
`AUTH_NAME` varchar(512) NOT NULL DEFAULT '',
`AUTH_SRID` int(5) NOT NULL DEFAULT 0,
`SRTEXT` varchar(2048) NOT NULL DEFAULT ''
`SRID` smallint(5) NOT NULL,
`AUTH_NAME` varchar(512) NOT NULL,
`AUTH_SRID` int(5) NOT NULL,
`SRTEXT` varchar(2048) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
create table t1(g GEOMETRY, pt POINT);
create table t2(g LINESTRING, pl POLYGON);

View File

@ -2080,19 +2080,19 @@ id select_type table type possible_keys key key_len ref rows Extra
explain extended select a1,a2,min(b),max(b) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 98.44 Using where; Using index
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 96.30 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,min(`test`.`t1`.`b`) AS `min(b)`,max(`test`.`t1`.`b`) AS `max(b)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`
explain extended select a1,a2,b,min(c),max(c) from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.95 Using where; Using temporary; Using filesort
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.37 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,min(`test`.`t1`.`c`) AS `min(c)`,max(`test`.`t1`.`c`) AS `max(c)` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain extended select a1,a2,b,c from t1
where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (d > 'xy2') group by a1,a2,b,c;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.95 Using where; Using temporary; Using filesort
1 SIMPLE t1 ALL idx_t1_0,idx_t1_1,idx_t1_2 NULL NULL NULL 512 26.37 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`d` > 'xy2' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`,`test`.`t1`.`c`
explain select a1,a2,b,max(c),min(c) from t2 where (a2 = 'a') and (b = 'b') or (b < 'b') group by a1;
@ -2100,7 +2100,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL idx_t2_1 163 NULL 548 Using where; Using index
explain extended select a1,a2,b from t1 where (a1 = 'b' or a1 = 'd' or a1 = 'a' or a1 = 'c') and (a2 > 'a') and (c > 'a111') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 98.44 Using where; Using index
1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 130 NULL 276 96.30 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`a1` = 'b' or `test`.`t1`.`a1` = 'd' or `test`.`t1`.`a1` = 'a' or `test`.`t1`.`a1` = 'c') and `test`.`t1`.`a2` > 'a' and `test`.`t1`.`c` > 'a111' group by `test`.`t1`.`a1`,`test`.`t1`.`a2`,`test`.`t1`.`b`
explain select a1,a2,min(b),c from t2 where (a2 = 'a') and (c = 'a111') group by a1;

View File

@ -180,17 +180,29 @@ or
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6,i7 i3,i5 4,4 NULL 9 Using sort_union(i3,i5); Using where
explain select * from t0 where
((key3 < 4 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL i1,i2,i3,i5,i6 NULL NULL NULL 1024 Using where
explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
((key3 < 4 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 4,4 NULL 1024 Using sort_union(i3,i5); Using where
explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
((key3 < 5 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 ALL i1,i2,i3,i5,i6 NULL NULL NULL 1024 Using where
explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
((key3 < 10 or key5 < 4) and (key1 < 4 or key2 < 4))
or
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t0 index_merge i1,i2,i3,i5,i6 i3,i5 0,4 NULL 1024 Using sort_union(i3,i5); Using where
1 SIMPLE t0 ALL i1,i2,i3,i5,i6 NULL NULL NULL 1024 Using where
select * from t0 where key1 < 5 or key8 < 4 order by key1;
key1 key2 key3 key4 key5 key6 key7 key8
1 1 1 1 1 1 1 1023
@ -1690,7 +1702,7 @@ SELECT * FROM t1 FORCE KEY (PRIMARY , i , c1 , c2)
WHERE pk = 255 OR i = 22 OR (pk IN (1 , 136) AND c2 IN ('c' , 'w') AND (c1
NOT BETWEEN 'e' AND 'i' OR c2 > 'g')) OR (pk is not null and (pk <1 or pk>1)) ;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge PRIMARY,c1,i,c2 PRIMARY,i 0,5 NULL 69 Using sort_union(PRIMARY,i); Using where
1 SIMPLE t1 ALL PRIMARY,c1,i,c2 NULL NULL NULL 69 Using where
DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
#

View File

@ -230,7 +230,7 @@ Field Type Collation Null Key Default Extra Privileges Comment
Insert_priv enum('N','Y') utf8mb3_general_ci NO N select,insert,update,references
show full columns from v1;
Field Type Collation Null Key Default Extra Privileges Comment
c varchar(64) utf8mb3_general_ci NO select,insert,update,references
c varchar(64) utf8mb3_general_ci NO NULL select,insert,update,references
select * from information_schema.COLUMNS where table_name="t1"
and column_name= "a";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT IS_GENERATED GENERATION_EXPRESSION
@ -609,19 +609,19 @@ drop table t1;
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
`CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
`DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
`MAXLEN` bigint(3) NOT NULL DEFAULT 0
`CHARACTER_SET_NAME` varchar(32) NOT NULL,
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL,
`DESCRIPTION` varchar(60) NOT NULL,
`MAXLEN` bigint(3) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
set names latin2;
SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets;
Table Create Table
CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` (
`CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
`DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
`MAXLEN` bigint(3) NOT NULL DEFAULT 0
`CHARACTER_SET_NAME` varchar(32) NOT NULL,
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL,
`DESCRIPTION` varchar(60) NOT NULL,
`MAXLEN` bigint(3) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3
set names latin1;
create table t1 select * from information_schema.CHARACTER_SETS
@ -633,10 +633,10 @@ alter table t1 default character set utf8;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CHARACTER_SET_NAME` varchar(32) NOT NULL DEFAULT '',
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL DEFAULT '',
`DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
`MAXLEN` bigint(3) NOT NULL DEFAULT 0
`CHARACTER_SET_NAME` varchar(32) NOT NULL,
`DEFAULT_COLLATE_NAME` varchar(32) NOT NULL,
`DESCRIPTION` varchar(60) NOT NULL,
`MAXLEN` bigint(3) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3
drop table t1;
create view v1 as select * from information_schema.TABLES;
@ -2499,5 +2499,30 @@ select * from t1 where (name, len) in (select name, len from information_schema
name len
drop table t1;
#
# MDEV-20254 Problems with EMPTY_STRING_IS_NULL and I_S tables
#
SET SQL_MODE= 'EMPTY_STRING_IS_NULL';
CREATE OR REPLACE TABLE t1 AS SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE 1 = 0;
SHOW returned: CREATE TABLE `t1` (
`TABLE_NAME` varchar(64) CHARACTER SET utf8mb3 NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE `t1` (
`TABLE_NAME` varchar(64) CHARACTER SET utf8mb3 NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`TABLE_NAME` varchar(64) CHARACTER SET utf8mb3 NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
SET SQL_MODE= 'EMPTY_STRING_IS_NULL';
CREATE OR REPLACE TABLE t1 AS SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 1 = 0;
DROP TABLE t1;
# Executing the statement returned from SHOW CREATE TABLE
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
#
# End of 10.3 tests
#

View File

@ -2072,6 +2072,39 @@ create table t1 ( name varchar(64) character set utf8, len int);
select * from t1 where (name, len) in (select name, len from information_schema.innodb_sys_columns having len = 8);
drop table t1;
--echo #
--echo # MDEV-20254 Problems with EMPTY_STRING_IS_NULL and I_S tables
--echo #
# Test one column with detailed output
SET SQL_MODE= 'EMPTY_STRING_IS_NULL';
CREATE OR REPLACE TABLE t1 AS SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE 1 = 0;
--let $myvar= query_get_value(SHOW CREATE TABLE test.t1, Create Table, 1)
--echo SHOW returned: $myvar
DROP TABLE t1;
--eval $myvar
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
# Test all columns without detailed output.
# Just make sure the SHOW CREATE TABLE result
# can be passed back to the server without errors.
SET SQL_MODE= 'EMPTY_STRING_IS_NULL';
CREATE OR REPLACE TABLE t1 AS SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 1 = 0;
--let $myvar= query_get_value(SHOW CREATE TABLE test.t1, Create Table, 1)
DROP TABLE t1;
--disable_query_log
--echo # Executing the statement returned from SHOW CREATE TABLE
--eval $myvar
--enable_query_log
DROP TABLE t1;
SET SQL_MODE=DEFAULT;
--echo #
--echo # End of 10.3 tests
--echo #

View File

@ -1,4 +1,3 @@
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id),
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,

View File

@ -1,8 +1,6 @@
-- source include/testdb_only.inc
-- source include/have_innodb.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
--enable_warnings
-- source include/have_symlink.inc
#
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables

View File

@ -3,22 +3,22 @@ USE INFORMATION_SCHEMA;
SHOW CREATE TABLE INFORMATION_SCHEMA.PARAMETERS;
Table Create Table
PARAMETERS CREATE TEMPORARY TABLE `PARAMETERS` (
`SPECIFIC_CATALOG` varchar(512) NOT NULL DEFAULT '',
`SPECIFIC_SCHEMA` varchar(64) NOT NULL DEFAULT '',
`SPECIFIC_NAME` varchar(64) NOT NULL DEFAULT '',
`ORDINAL_POSITION` int(21) NOT NULL DEFAULT 0,
`PARAMETER_MODE` varchar(5) DEFAULT NULL,
`PARAMETER_NAME` varchar(64) DEFAULT NULL,
`DATA_TYPE` varchar(64) NOT NULL DEFAULT '',
`CHARACTER_MAXIMUM_LENGTH` int(21) DEFAULT NULL,
`CHARACTER_OCTET_LENGTH` int(21) DEFAULT NULL,
`NUMERIC_PRECISION` int(21) DEFAULT NULL,
`NUMERIC_SCALE` int(21) DEFAULT NULL,
`DATETIME_PRECISION` bigint(21) unsigned DEFAULT NULL,
`CHARACTER_SET_NAME` varchar(64) DEFAULT NULL,
`COLLATION_NAME` varchar(64) DEFAULT NULL,
`DTD_IDENTIFIER` longtext NOT NULL DEFAULT '',
`ROUTINE_TYPE` varchar(9) NOT NULL DEFAULT ''
`SPECIFIC_CATALOG` varchar(512) NOT NULL,
`SPECIFIC_SCHEMA` varchar(64) NOT NULL,
`SPECIFIC_NAME` varchar(64) NOT NULL,
`ORDINAL_POSITION` int(21) NOT NULL,
`PARAMETER_MODE` varchar(5),
`PARAMETER_NAME` varchar(64),
`DATA_TYPE` varchar(64) NOT NULL,
`CHARACTER_MAXIMUM_LENGTH` int(21),
`CHARACTER_OCTET_LENGTH` int(21),
`NUMERIC_PRECISION` int(21),
`NUMERIC_SCALE` int(21),
`DATETIME_PRECISION` bigint(21) unsigned,
`CHARACTER_SET_NAME` varchar(64),
`COLLATION_NAME` varchar(64),
`DTD_IDENTIFIER` longtext NOT NULL,
`ROUTINE_TYPE` varchar(9) NOT NULL
) DEFAULT CHARSET=utf8mb3
SELECT * FROM information_schema.columns
WHERE table_schema = 'information_schema'
@ -29,7 +29,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME SPECIFIC_CATALOG
ORDINAL_POSITION 1
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 512
@ -51,7 +51,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME SPECIFIC_SCHEMA
ORDINAL_POSITION 2
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -73,7 +73,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME SPECIFIC_NAME
ORDINAL_POSITION 3
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -95,7 +95,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME ORDINAL_POSITION
ORDINAL_POSITION 4
COLUMN_DEFAULT 0
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE int
CHARACTER_MAXIMUM_LENGTH NULL
@ -161,7 +161,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME DATA_TYPE
ORDINAL_POSITION 7
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -337,7 +337,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME DTD_IDENTIFIER
ORDINAL_POSITION 15
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE longtext
CHARACTER_MAXIMUM_LENGTH 4294967295
@ -359,7 +359,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
COLUMN_NAME ROUTINE_TYPE
ORDINAL_POSITION 16
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 9
@ -378,13 +378,13 @@ IS_GENERATED NEVER
GENERATION_EXPRESSION NULL
DESCRIBE INFORMATION_SCHEMA.PARAMETERS;
Field Type Null Key Default Extra
SPECIFIC_CATALOG varchar(512) NO
SPECIFIC_SCHEMA varchar(64) NO
SPECIFIC_NAME varchar(64) NO
ORDINAL_POSITION int(21) NO 0
SPECIFIC_CATALOG varchar(512) NO NULL
SPECIFIC_SCHEMA varchar(64) NO NULL
SPECIFIC_NAME varchar(64) NO NULL
ORDINAL_POSITION int(21) NO NULL
PARAMETER_MODE varchar(5) YES NULL
PARAMETER_NAME varchar(64) YES NULL
DATA_TYPE varchar(64) NO
DATA_TYPE varchar(64) NO NULL
CHARACTER_MAXIMUM_LENGTH int(21) YES NULL
CHARACTER_OCTET_LENGTH int(21) YES NULL
NUMERIC_PRECISION int(21) YES NULL
@ -392,8 +392,8 @@ NUMERIC_SCALE int(21) YES NULL
DATETIME_PRECISION bigint(21) unsigned YES NULL
CHARACTER_SET_NAME varchar(64) YES NULL
COLLATION_NAME varchar(64) YES NULL
DTD_IDENTIFIER longtext NO
ROUTINE_TYPE varchar(9) NO
DTD_IDENTIFIER longtext NO NULL
ROUTINE_TYPE varchar(9) NO NULL
# ========== parameters.2 ==========
DROP DATABASE IF EXISTS i_s_parameters_test;
CREATE DATABASE i_s_parameters_test;

View File

@ -5,37 +5,37 @@ USE INFORMATION_SCHEMA;
SHOW CREATE TABLE INFORMATION_SCHEMA.ROUTINES;
Table Create Table
ROUTINES CREATE TEMPORARY TABLE `ROUTINES` (
`SPECIFIC_NAME` varchar(64) NOT NULL DEFAULT '',
`ROUTINE_CATALOG` varchar(512) NOT NULL DEFAULT '',
`ROUTINE_SCHEMA` varchar(64) NOT NULL DEFAULT '',
`ROUTINE_NAME` varchar(64) NOT NULL DEFAULT '',
`ROUTINE_TYPE` varchar(13) NOT NULL DEFAULT '',
`DATA_TYPE` varchar(64) NOT NULL DEFAULT '',
`CHARACTER_MAXIMUM_LENGTH` int(21) DEFAULT NULL,
`CHARACTER_OCTET_LENGTH` int(21) DEFAULT NULL,
`NUMERIC_PRECISION` int(21) DEFAULT NULL,
`NUMERIC_SCALE` int(21) DEFAULT NULL,
`DATETIME_PRECISION` bigint(21) unsigned DEFAULT NULL,
`CHARACTER_SET_NAME` varchar(64) DEFAULT NULL,
`COLLATION_NAME` varchar(64) DEFAULT NULL,
`DTD_IDENTIFIER` longtext DEFAULT NULL,
`ROUTINE_BODY` varchar(8) NOT NULL DEFAULT '',
`ROUTINE_DEFINITION` longtext DEFAULT NULL,
`EXTERNAL_NAME` varchar(64) DEFAULT NULL,
`EXTERNAL_LANGUAGE` varchar(64) DEFAULT NULL,
`PARAMETER_STYLE` varchar(8) NOT NULL DEFAULT '',
`IS_DETERMINISTIC` varchar(3) NOT NULL DEFAULT '',
`SQL_DATA_ACCESS` varchar(64) NOT NULL DEFAULT '',
`SQL_PATH` varchar(64) DEFAULT NULL,
`SECURITY_TYPE` varchar(7) NOT NULL DEFAULT '',
`CREATED` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`LAST_ALTERED` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`SQL_MODE` varchar(8192) NOT NULL DEFAULT '',
`ROUTINE_COMMENT` longtext NOT NULL DEFAULT '',
`DEFINER` varchar(384) NOT NULL DEFAULT '',
`CHARACTER_SET_CLIENT` varchar(32) NOT NULL DEFAULT '',
`COLLATION_CONNECTION` varchar(32) NOT NULL DEFAULT '',
`DATABASE_COLLATION` varchar(32) NOT NULL DEFAULT ''
`SPECIFIC_NAME` varchar(64) NOT NULL,
`ROUTINE_CATALOG` varchar(512) NOT NULL,
`ROUTINE_SCHEMA` varchar(64) NOT NULL,
`ROUTINE_NAME` varchar(64) NOT NULL,
`ROUTINE_TYPE` varchar(13) NOT NULL,
`DATA_TYPE` varchar(64) NOT NULL,
`CHARACTER_MAXIMUM_LENGTH` int(21),
`CHARACTER_OCTET_LENGTH` int(21),
`NUMERIC_PRECISION` int(21),
`NUMERIC_SCALE` int(21),
`DATETIME_PRECISION` bigint(21) unsigned,
`CHARACTER_SET_NAME` varchar(64),
`COLLATION_NAME` varchar(64),
`DTD_IDENTIFIER` longtext,
`ROUTINE_BODY` varchar(8) NOT NULL,
`ROUTINE_DEFINITION` longtext,
`EXTERNAL_NAME` varchar(64),
`EXTERNAL_LANGUAGE` varchar(64),
`PARAMETER_STYLE` varchar(8) NOT NULL,
`IS_DETERMINISTIC` varchar(3) NOT NULL,
`SQL_DATA_ACCESS` varchar(64) NOT NULL,
`SQL_PATH` varchar(64),
`SECURITY_TYPE` varchar(7) NOT NULL,
`CREATED` datetime NOT NULL,
`LAST_ALTERED` datetime NOT NULL,
`SQL_MODE` varchar(8192) NOT NULL,
`ROUTINE_COMMENT` longtext NOT NULL,
`DEFINER` varchar(384) NOT NULL,
`CHARACTER_SET_CLIENT` varchar(32) NOT NULL,
`COLLATION_CONNECTION` varchar(32) NOT NULL,
`DATABASE_COLLATION` varchar(32) NOT NULL
) DEFAULT CHARSET=utf8mb3
SELECT * FROM information_schema.columns
WHERE table_schema = 'information_schema'
@ -46,7 +46,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME SPECIFIC_NAME
ORDINAL_POSITION 1
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -68,7 +68,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME ROUTINE_CATALOG
ORDINAL_POSITION 2
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 512
@ -90,7 +90,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME ROUTINE_SCHEMA
ORDINAL_POSITION 3
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -112,7 +112,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME ROUTINE_NAME
ORDINAL_POSITION 4
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -134,7 +134,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME ROUTINE_TYPE
ORDINAL_POSITION 5
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 13
@ -156,7 +156,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME DATA_TYPE
ORDINAL_POSITION 6
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -354,7 +354,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME ROUTINE_BODY
ORDINAL_POSITION 15
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 8
@ -442,7 +442,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME PARAMETER_STYLE
ORDINAL_POSITION 19
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 8
@ -464,7 +464,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME IS_DETERMINISTIC
ORDINAL_POSITION 20
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 3
@ -486,7 +486,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME SQL_DATA_ACCESS
ORDINAL_POSITION 21
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 64
@ -530,7 +530,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME SECURITY_TYPE
ORDINAL_POSITION 23
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 7
@ -552,7 +552,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME CREATED
ORDINAL_POSITION 24
COLUMN_DEFAULT '0000-00-00 00:00:00'
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE datetime
CHARACTER_MAXIMUM_LENGTH NULL
@ -574,7 +574,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME LAST_ALTERED
ORDINAL_POSITION 25
COLUMN_DEFAULT '0000-00-00 00:00:00'
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE datetime
CHARACTER_MAXIMUM_LENGTH NULL
@ -596,7 +596,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME SQL_MODE
ORDINAL_POSITION 26
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 8192
@ -618,7 +618,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME ROUTINE_COMMENT
ORDINAL_POSITION 27
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE longtext
CHARACTER_MAXIMUM_LENGTH 4294967295
@ -640,7 +640,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME DEFINER
ORDINAL_POSITION 28
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 384
@ -662,7 +662,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME CHARACTER_SET_CLIENT
ORDINAL_POSITION 29
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 32
@ -684,7 +684,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME COLLATION_CONNECTION
ORDINAL_POSITION 30
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 32
@ -706,7 +706,7 @@ TABLE_SCHEMA information_schema
TABLE_NAME ROUTINES
COLUMN_NAME DATABASE_COLLATION
ORDINAL_POSITION 31
COLUMN_DEFAULT ''
COLUMN_DEFAULT NULL
IS_NULLABLE NO
DATA_TYPE varchar
CHARACTER_MAXIMUM_LENGTH 32
@ -725,12 +725,12 @@ IS_GENERATED NEVER
GENERATION_EXPRESSION NULL
DESCRIBE INFORMATION_SCHEMA.ROUTINES;
Field Type Null Key Default Extra
SPECIFIC_NAME varchar(64) NO
ROUTINE_CATALOG varchar(512) NO
ROUTINE_SCHEMA varchar(64) NO
ROUTINE_NAME varchar(64) NO
ROUTINE_TYPE varchar(13) NO
DATA_TYPE varchar(64) NO
SPECIFIC_NAME varchar(64) NO NULL
ROUTINE_CATALOG varchar(512) NO NULL
ROUTINE_SCHEMA varchar(64) NO NULL
ROUTINE_NAME varchar(64) NO NULL
ROUTINE_TYPE varchar(13) NO NULL
DATA_TYPE varchar(64) NO NULL
CHARACTER_MAXIMUM_LENGTH int(21) YES NULL
CHARACTER_OCTET_LENGTH int(21) YES NULL
NUMERIC_PRECISION int(21) YES NULL
@ -739,23 +739,23 @@ DATETIME_PRECISION bigint(21) unsigned YES NULL
CHARACTER_SET_NAME varchar(64) YES NULL
COLLATION_NAME varchar(64) YES NULL
DTD_IDENTIFIER longtext YES NULL
ROUTINE_BODY varchar(8) NO
ROUTINE_BODY varchar(8) NO NULL
ROUTINE_DEFINITION longtext YES NULL
EXTERNAL_NAME varchar(64) YES NULL
EXTERNAL_LANGUAGE varchar(64) YES NULL
PARAMETER_STYLE varchar(8) NO
IS_DETERMINISTIC varchar(3) NO
SQL_DATA_ACCESS varchar(64) NO
PARAMETER_STYLE varchar(8) NO NULL
IS_DETERMINISTIC varchar(3) NO NULL
SQL_DATA_ACCESS varchar(64) NO NULL
SQL_PATH varchar(64) YES NULL
SECURITY_TYPE varchar(7) NO
CREATED datetime NO 0000-00-00 00:00:00
LAST_ALTERED datetime NO 0000-00-00 00:00:00
SQL_MODE varchar(8192) NO
ROUTINE_COMMENT longtext NO
DEFINER varchar(384) NO
CHARACTER_SET_CLIENT varchar(32) NO
COLLATION_CONNECTION varchar(32) NO
DATABASE_COLLATION varchar(32) NO
SECURITY_TYPE varchar(7) NO NULL
CREATED datetime NO NULL
LAST_ALTERED datetime NO NULL
SQL_MODE varchar(8192) NO NULL
ROUTINE_COMMENT longtext NO NULL
DEFINER varchar(384) NO NULL
CHARACTER_SET_CLIENT varchar(32) NO NULL
COLLATION_CONNECTION varchar(32) NO NULL
DATABASE_COLLATION varchar(32) NO NULL
# ========== routines.2 ==========
DROP DATABASE IF EXISTS i_s_routines_test;
CREATE DATABASE i_s_routines_test;

View File

@ -865,3 +865,22 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2;
End of 5.5 tests
#
# Beginning of 10.2 test
#
# MDEV-26698: Incorrect row number upon INSERT .. SELECT from the same
# table: rows are counted twice
#
CREATE TABLE t1(a TINYINT);
INSERT INTO t1 VALUES (1), (100);
INSERT INTO t1 SELECT a*2 FROM t1;
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
TRUNCATE TABLE t1;
# using ORDER BY
INSERT INTO t1 VALUES(1), (2), (100), (3);
INSERT INTO t1 SELECT a*2 FROM t1 ORDER BY a;
Warnings:
Warning 1264 Out of range value for column 'a' at row 4
DROP TABLE t1;
# End of 10.2 test

View File

@ -435,3 +435,28 @@ show create table t2;
drop table t1, t2;
--echo End of 5.5 tests
--echo #
--echo # Beginning of 10.2 test
--echo #
--echo # MDEV-26698: Incorrect row number upon INSERT .. SELECT from the same
--echo # table: rows are counted twice
--echo #
CREATE TABLE t1(a TINYINT);
INSERT INTO t1 VALUES (1), (100);
INSERT INTO t1 SELECT a*2 FROM t1;
TRUNCATE TABLE t1;
--echo # using ORDER BY
INSERT INTO t1 VALUES(1), (2), (100), (3);
INSERT INTO t1 SELECT a*2 FROM t1 ORDER BY a;
DROP TABLE t1;
--echo # End of 10.2 test

View File

@ -0,0 +1,56 @@
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
set @innodb_stats_persistent_sample_pages_save=
@@innodb_stats_persistent_sample_pages;
set global innodb_stats_persistent= 1;
set global innodb_stats_persistent_sample_pages=100;
set optimizer_use_condition_selectivity=1;
analyze SELECT sysapproval_approver0.`sys_id`
FROM ((sysapproval_approver sysapproval_approver0
INNER JOIN task task1
ON sysapproval_approver0.`sysapproval` = task1.`sys_id`
AND (( task1.`sys_domain_path` = '/'
OR task1.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task1.`sys_domain_path` LIKE '!!!/!!!/%' )))
INNER JOIN task task2
ON task1.`parent` = task2.`sys_id`
AND (( task2.`sys_domain_path` = '/'
OR task2.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task2.`sys_domain_path` LIKE '!!!/!!!/%' )))
WHERE task2.`sys_id` LIKE '8e7792a7dbfffb00fff8a345ca961934%'
AND ( sysapproval_approver0.`sys_domain_path` = '/'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!!/%' )
ORDER BY sysapproval_approver0.`order`
LIMIT 0, 50 ;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE task2 range PRIMARY,sys_class_name_2,sys_domain_path PRIMARY 96 NULL 1 0.00 100.00 100.00 Using where; Using temporary; Using filesort
1 SIMPLE task1 ref PRIMARY,task_parent,sys_class_name_2,sys_domain_path task_parent 99 test.task2.sys_id 1 NULL 100.00 NULL Using index condition; Using where
1 SIMPLE sysapproval_approver0 ref sysapproval_approver_ref5,sys_domain_path,sysapproval_approver_CHG1975376 sysapproval_approver_ref5 99 test.task1.sys_id 1 NULL 100.00 NULL Using index condition; Using where
set optimizer_use_condition_selectivity=4;
analyze SELECT sysapproval_approver0.`sys_id`
FROM ((sysapproval_approver sysapproval_approver0
INNER JOIN task task1
ON sysapproval_approver0.`sysapproval` = task1.`sys_id`
AND (( task1.`sys_domain_path` = '/'
OR task1.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task1.`sys_domain_path` LIKE '!!!/!!!/%' )))
INNER JOIN task task2
ON task1.`parent` = task2.`sys_id`
AND (( task2.`sys_domain_path` = '/'
OR task2.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task2.`sys_domain_path` LIKE '!!!/!!!/%' )))
WHERE task2.`sys_id` LIKE '8e7792a7dbfffb00fff8a345ca961934%'
AND ( sysapproval_approver0.`sys_domain_path` = '/'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!!/%' )
ORDER BY sysapproval_approver0.`order`
LIMIT 0, 50 ;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE task2 range PRIMARY,sys_class_name_2,sys_domain_path PRIMARY 96 NULL 1 0.00 98.00 100.00 Using where; Using temporary; Using filesort
1 SIMPLE task1 ref PRIMARY,task_parent,sys_class_name_2,sys_domain_path task_parent 99 test.task2.sys_id 1 NULL 100.00 NULL Using index condition; Using where
1 SIMPLE sysapproval_approver0 ref sysapproval_approver_ref5,sys_domain_path,sysapproval_approver_CHG1975376 sysapproval_approver_ref5 99 test.task1.sys_id 1 NULL 100.00 NULL Using index condition; Using where
drop table sysapproval_approver,task;
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;

View File

@ -0,0 +1,104 @@
#
# MDEV-25830: optimizer_use_condition_selectivity=4 sometimes produces worse plan than optimizer_use_condition_selectivity=1
# https://jira.mariadb.org/browse/MDEV-25830
#
--source include/innodb_prefix_index_cluster_optimization.inc
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
set @innodb_stats_persistent_sample_pages_save=
@@innodb_stats_persistent_sample_pages;
set global innodb_stats_persistent= 1;
set global innodb_stats_persistent_sample_pages=100;
--disable_query_log
--disable_result_log
--disable_warnings
DROP TABLE IF EXISTS `sysapproval_approver`;
CREATE TABLE `sysapproval_approver` (
`order` int(11) DEFAULT NULL,
`sysapproval` varchar(32) DEFAULT NULL,
`sys_id` char(32) NOT NULL DEFAULT '',
`sys_domain_path` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sys_id`),
KEY `sysapproval_approver_ref5` (`sysapproval`),
KEY `sys_domain_path` (`sys_domain_path`),
KEY `sysapproval_approver_CHG1975376` (`sys_domain_path`,`sysapproval`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `sysapproval_approver` VALUES (NULL,'c00004d787a8a5003fff83bdff434dea','000004d787a8a5003fff83bdff434dee','!!!/!!#/!!$/'),(NULL,NULL,'00000741db8bfb480be6a345ca96198e','!!!/!!#/!!$/'),(NULL,NULL,'00001605dbce48d0f7fca851ca961967','!!!/!!#/!!$/'),(NULL,'23b53105db2f324c5a4af85e0f96194e','000016c1db6ffa445d2f7aa31f9619a0','!!!/!!#/!!$/'),(NULL,NULL,'00001730dbe24890f7fca851ca9619aa','!!!/!!#/!!$/'),(NULL,NULL,'000017a01b127b00ada243f6fe4bcb8c','!!!/!!#/!!$/'),(NULL,'7f660139db6088185ed4a851ca961986','00001ab1dbecc8185ed4a851ca961970','!!!/!!#/!!$/'),(NULL,'6226cd801b19dc10a59033f2cd4bcb22','00001d84db9918505ed4a851ca96193f','!!!/!!!/(8]/'),(NULL,NULL,'00002246db83874002f17c541f961999','!!!/!!#/!!$/'),(NULL,NULL,'000026e01b9eb700ada243f6fe4bcbc5','!!!/!!#/!!$/'),(NULL,NULL,'000028e16f064e807b658e4c2c3ee4ae','!!!/!!#/!!$/'),(NULL,NULL,'00002914dba8670c54250b55ca961928','!!!/!!#/!!$/'),(NULL,NULL,'00002914dba8670c54250b55ca961931','!!!/!!#/!!$/'),(NULL,NULL,'00002914dba8670c54250b55ca96193a','!!!/!!#/!!$/'),(NULL,NULL,'00002914dba8670c54250b55ca961943','!!!/!!#/!!$/'),(NULL,NULL,'000030a4dbb90b40002af47e0f9619b1','!!!/!!#/!!$/'),(NULL,NULL,'000033fedb41fb041cd8a345ca9619fa','!!!/!!#/!!$/'),(NULL,NULL,'0000341ddb4ce3804ac3a851ca961916','!!!/!!#/!!$/'),(NULL,NULL,'0000393ddb709b002b6dfb651f961908','!!!/!!#/!!$/'),(NULL,'a81ca740db5cdc9416d2a345ca9619b3','00003b00dbdcdc9416d2a345ca961907','!!!/!!#/!!$/'),(NULL,'04003c88db5e3304d6a102d5ca961913','00003c88db5e3304d6a102d5ca96192a','!!!/!!#/!!$/'),(NULL,'4affb00cdbbf0f800e3dfb651f9619a0','0000450cdbbf0f800e3dfb651f961973','!!!/!!#/!!$/'),(NULL,NULL,'00005634dbd11fc4e9737a9e0f961988','!!!/!!#/!!$/'),(NULL,NULL,'00005634dbd11fc4e9737a9e0f9619ce','!!!/!!#/!!$/'),(NULL,NULL,'00005634dbd11fc4e9737a9e0f9619d7','!!!/!!#/!!$/'),(NULL,NULL,'00005784dbc49b00852c7a9e0f96198a','!!!/!!#/!!$/'),(NULL,NULL,'00005bc1dbcdd7042d1efb651f961978','!!!/!!#/!!$/'),(NULL,NULL,'0000637b6f37c24013568e4c2c3ee4d6','!!!/!!#/!!$/'),(NULL,'080069db0f858240a2c9982be1050eae','000069db0f858240a2c9982be1050eb2','!!!/!!#/!!$/'),(NULL,'f98e3bb21b155c10a59033f2cd4bcbef','00006c47db5d9010d82ffb24399619d8','!!!/!!!/#YZ/'),(NULL,NULL,'00006c50db6a0450d58ea345ca961972','!!!/!!#/!!$/'),(NULL,NULL,'00006e38dbc19304032a7a9e0f9619e4','!!!/!!#/!!$/'),(NULL,NULL,'00006edddbec8c5813b5fb24399619b9','!!!/!!#/!!$/'),(NULL,NULL,'000073fedb41fb041cd8a345ca961934','!!!/!!#/!!$/'),(NULL,NULL,'000073fedb41fb041cd8a345ca96195c','!!!/!!#/!!$/'),(NULL,'d03c6ee61b774410a59033f2cd4bcbf5','000076bfdbb74c981cd8a345ca9619ee','!!!/!!!/!;B/'),(NULL,NULL,'000076ecdbde48502be0a851ca9619dd','!!!/!!#/!!$/'),(NULL,NULL,'000076ecdbde48502be0a851ca9619fe','!!!/!!#/!!$/'),(NULL,NULL,'0000778d6fd01a4000270bae9f3ee4ff','!!!/!!#/!!$/'),(NULL,NULL,'000077c21b3fbb0cada243f6fe4bcba7','!!!/!!#/!!$/'),(NULL,NULL,'000077c21b3fbb0cada243f6fe4bcbcb','!!!/!!#/!!$/'),(NULL,'f6c5f2110f75de401c7e938172050e1b','000077e10f7d5e00e59b982be1050e62','!!!/!!#/!!$/'),(NULL,NULL,'00007fa76ff70a0000270bae9f3ee4b1','!!!/!!#/!!$/'),(NULL,'73ff6fe76f4761007ceff7307f3ee478','00007fe76f4761007ceff7307f3ee47c','!!!/!!#/!!$/'),(NULL,'a4d63f4bdb8fbf00414ed0c5ca96191d','0000881b1b8f7f00fff162c4bd4bcbe7','!!!/!!!/$)(/'),(NULL,'a4d63f4bdb8fbf00414ed0c5ca96191d','0000881b1b8f7f00fff162c4bd4bcbec','!!!/!!!/$)(/'),(NULL,NULL,'000094eb6f781a0099c5409e9f3ee48e','!!!/!!#/!!$/'),(NULL,NULL,'000094eb6f781a0099c5409e9f3ee493','!!!/!!#/!!$/'),(NULL,'401fb78cdb18d8dc1cd8a345ca9619c8','00009c10dbdc98dcfeb1a851ca96192f','!!!/!!!/$$8/'),(NULL,'9dd30a24db5c1cdc23f4a345ca96192b','00009e2cdb1c589c4819fb243996195c','!!!/!!#/!!$/');
DROP TABLE IF EXISTS `task`;
CREATE TABLE `task` (
`parent` varchar(32) DEFAULT NULL,
`sys_id` char(32) NOT NULL DEFAULT '',
`sys_domain_path` varchar(255) DEFAULT NULL,
PRIMARY KEY (`sys_id`),
KEY `task_parent` (`parent`),
KEY `sys_class_name_2` (`sys_domain_path`),
KEY `sys_domain_path` (`sys_domain_path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `task` VALUES (NULL,'-1','!!!/!!#/!!$/'),(NULL,'00000195dbe7f30413b5fb2439961936','!!!/!!#/!!$/'),(NULL,'0000032edb160f04d7e37aa31f961964','!!!/!!#/!!$/'),('a6fe0637dbddfb8c1cd8a345ca96196f','000003dcdb31f3c0a39a0b55ca961916','!!!/!!#/!!$/'),('2f1df65d6fca3100e7f68e4c2c3ee4e6','000004466f127d40e7f68e4c2c3ee4ce','!!!/!!#/!!$/'),('50dfb42edbbdd3403eb27a9e0f96199e','0000056edbbdd3403eb27a9e0f961995','!!!/!!!/+0{/'),('5f5af922dbb804d03bf6a851ca961999','000006eedb7c04d03bf6a851ca96190c','!!!/!!!/$9;/'),(NULL,'00000904db1dd45014d6fb24399619b7','!!!/!!#/!!$/'),('33c6e522db2c10104ac3a851ca9619f3','00000a06dbf0181416d2a345ca96197b','!!!/!!#/!!$/'),(NULL,'00000ccd6f9196041501f7307f3ee406','!!!/!!#/!!$/'),(NULL,'00000ee2dbb9bf4014d6fb24399619a7','!!!/!!#/!!$/'),(NULL,'00000f065bba40000a4de1945e425441','!!!/!!#/!!$/'),(NULL,'000013dedbc0bf00bbc40b55ca961959','!!!/!!!/,*7/'),(NULL,'000016bcdb29009cf7fca851ca961927','!!!/!!#/!!$/'),(NULL,'0000171bdbdb770066e0a345ca96195a','!!!/!!!/+N?/'),('8eb9317f1b895450d01143f6fe4bcb26','00001c80db5d509022e0fb24399619ed','!!!/!!!/0RG/'),(NULL,'00001d84dbf6f2405a4af85e0f9619f9','!!!/!!#/!!$/'),(NULL,'00001e31db25d4105ed4a851ca96195c','!!!/!!#/!!$/'),(NULL,'00001ea3db73c89823f4a345ca9619b5','!!!/!!#/!!$/'),('c3baf3fadb234c54d82ffb24399619e0','00001f4fdbab4c542be0a851ca96190c','!!!/!!#/!!$/'),(NULL,'0000221bdbb4b3c466e0a345ca9619f0','!!!/!!!/$^{/'),(NULL,'000022bcdb9c04d022e0fb24399619e1','!!!/!!#/!!$/'),('9b7152434f995a80f347524e0210c7e0','0000234b6f59de00fbd4409e9f3ee446','/'),('c64ed870145461009a1c80cd6740d192','00002434145461009a1c80cd6740d1e5','!!!/!!#/!!$/'),(NULL,'0000247edb84d7040e3dfb651f9619b2','!!!/!!#/!!$/'),(NULL,'000025f8dbb6ba007fc27c541f96195b','!!!/!!#/!!$/'),('9b691033485d95c0c5abf6bd15eef576','0000287348dd95c0c5abf6bd15eef572','!!!/!!#/!!$/'),('3c4f591edb7ce2406015f47e0f96191b','00002952dbbce2406015f47e0f961999','!!!/!!!/#MU/'),(NULL,'000029b0db6d5c104819fb24399619a8','!!!/!!#/!!$/'),(NULL,'00002a3d1b5f0010a59033f2cd4bcb90','!!!/!!!/&<#/'),(NULL,'00002a9fdb5787840e3dfb651f9619a6','!!!/!!#/!!$/'),(NULL,'00002c5adb5a0fc0d7e37aa31f9619ba','!!!/!!#/!!$/'),('fa753886dbd8181014d6fb2439961989','00002d5edbdc949466e0a345ca9619e4','!!!/!!!/$44/'),('56ff56bfdb469c503fa35583ca961987','00002e73db0a9c50364a5583ca961922','!!!/!!#/!!$/'),(NULL,'000031f6dba76b40c9c302d5ca9619c4','!!!/!!#/!!$/'),(NULL,'000036fadb1a0344d7e37aa31f96196d','!!!/!!#/!!$/'),(NULL,'000036ffdb046744d58ea345ca961937','!!!/!!#/!!$/'),(NULL,'000037c2dbaae700fb115583ca961926','!!!/!!#/!!$/'),(NULL,'000038eedbe32380b1b102d5ca9619c9','!!!/!!!/#2J/'),(NULL,'00003925dbb1c300225d7aa31f961993','!!!/!!#/!!$/'),('58c865acdb2944184ac3a851ca961901','0000392cdbe944184ac3a851ca9619ea','!!!/!!!/(*S/'),(NULL,'00003966db307a800e58fb651f9619a7','!!!/!!!/&C[/'),('bdeae17bdbfed3045ed4a851ca961933','0000397bdbb217045ed4a851ca96192e','!!!/!!#/!!$/'),('1b951202dbbe7b8014d6fb2439961926','00003a02db767f80fec4fb243996198f','!!!/!!!/#*L/'),(NULL,'00003e5bdbe33b8416d2a345ca961919','!!!/!!#/!!$/'),(NULL,'00003eef1b0a4410fff162c4bd4bcb0e','!!!/!!#/!!$/'),(NULL,'000040b6dbcfcb000e58fb651f9619d2','!!!/!!#/!!$/'),(NULL,'000040e5db0a185011762183ca9619c5','!!!/!!#/!!$/'),('101abff70ff99200a2c9982be1050ee7','000044c86f4a120000270bae9f3ee475','/'),('15d6f3c8dbb3ab0023f4a345ca9619ee','000045f2db5f2700f2eb02d5ca9619c6','!!!/!!!/#*./');
ANALYZE TABLE sysapproval_approver PERSISTENT FOR COLUMNS() INDEXES();
ANALYZE TABLE task PERSISTENT FOR COLUMNS() INDEXES();
--enable_warnings
--enable_result_log
--enable_query_log
# The following explain is left here from the original bug report.
# Can be useful if one gets this issue again in a future MariaDB version
#explain format= json SELECT sysapproval_approver0.`sys_id` FROM ((sysapproval_approver sysapproval_approver0 INNER JOIN task task1 ON sysapproval_approver0.`sysapproval` = task1.`sys_id` AND ((task1.`sys_domain_path` = '/' OR task1.`sys_domain_path` LIKE '!!!/!!#/!!$/%' OR task1.`sys_domain_path` LIKE '!!!/!!!/%'))) INNER JOIN task task2 ON task1.`parent` = task2.`sys_id` AND ((task2.`sys_domain_path` = '/' OR task2.`sys_domain_path` LIKE '!!!/!!#/!!$/%' OR task2.`sys_domain_path` LIKE '!!!/!!!/%'))) WHERE task2.`sys_id` LIKE '8e7792a7dbfffb00fff8a345ca961934%' AND (sysapproval_approver0.`sys_domain_path` = '/' OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!#/!!$/%' OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!!/%') ORDER BY sysapproval_approver0.`order` LIMIT 0, 50;
set optimizer_use_condition_selectivity=1;
analyze SELECT sysapproval_approver0.`sys_id`
FROM ((sysapproval_approver sysapproval_approver0
INNER JOIN task task1
ON sysapproval_approver0.`sysapproval` = task1.`sys_id`
AND (( task1.`sys_domain_path` = '/'
OR task1.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task1.`sys_domain_path` LIKE '!!!/!!!/%' )))
INNER JOIN task task2
ON task1.`parent` = task2.`sys_id`
AND (( task2.`sys_domain_path` = '/'
OR task2.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task2.`sys_domain_path` LIKE '!!!/!!!/%' )))
WHERE task2.`sys_id` LIKE '8e7792a7dbfffb00fff8a345ca961934%'
AND ( sysapproval_approver0.`sys_domain_path` = '/'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!!/%' )
ORDER BY sysapproval_approver0.`order`
LIMIT 0, 50 ;
set optimizer_use_condition_selectivity=4;
analyze SELECT sysapproval_approver0.`sys_id`
FROM ((sysapproval_approver sysapproval_approver0
INNER JOIN task task1
ON sysapproval_approver0.`sysapproval` = task1.`sys_id`
AND (( task1.`sys_domain_path` = '/'
OR task1.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task1.`sys_domain_path` LIKE '!!!/!!!/%' )))
INNER JOIN task task2
ON task1.`parent` = task2.`sys_id`
AND (( task2.`sys_domain_path` = '/'
OR task2.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR task2.`sys_domain_path` LIKE '!!!/!!!/%' )))
WHERE task2.`sys_id` LIKE '8e7792a7dbfffb00fff8a345ca961934%'
AND ( sysapproval_approver0.`sys_domain_path` = '/'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!#/!!$/%'
OR sysapproval_approver0.`sys_domain_path` LIKE '!!!/!!!/%' )
ORDER BY sysapproval_approver0.`order`
LIMIT 0, 50 ;
drop table sysapproval_approver,task;
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;

View File

@ -3,3 +3,4 @@
--log-output=FILE,TABLE
--max-allowed-packet=32000000
--proxy-protocol-networks=*
--sequence=on

View File

@ -1,3 +1,4 @@
--loose-enable-performance-schema
--max-allowed-packet=32000000
--proxy-protocol-networks=::1/32,127.0.0.0/8,localhost
--sequence=on

View File

@ -1,3 +1,4 @@
--general-log --general-log-file=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE,TABLE
--max-allowed-packet=32000000
--proxy-protocol-networks=::1,::ffff:127.0.0.1/97,localhost
--sequence=on

View File

@ -1,3 +1,14 @@
use mysql;
RENAME TABLE time_zone TO time_zone_orig,
time_zone_name TO time_zone_name_orig,
time_zone_transition TO time_zone_transition_orig,
time_zone_transition_type TO time_zone_transition_type_orig,
time_zone_leap_second TO time_zone_leap_second_orig;
CREATE TABLE time_zone LIKE time_zone_orig;
CREATE TABLE time_zone_name LIKE time_zone_name_orig;
CREATE TABLE time_zone_transition LIKE time_zone_transition_orig;
CREATE TABLE time_zone_transition_type LIKE time_zone_transition_type_orig;
CREATE TABLE time_zone_leap_second LIKE time_zone_leap_second_orig;
#
# MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
#
@ -9,13 +20,18 @@ ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
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);
@ -33,6 +49,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset
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;
@ -41,11 +58,26 @@ 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;
ALTER TABLE time_zone_transition_type 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
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
\d |
IF (select count(*) from information_schema.global_variables where
variable_name='wsrep_on' and variable_value='ON') = 1 THEN
@ -53,13 +85,18 @@ ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
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);
@ -74,6 +111,7 @@ INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, `Offset
(@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;
@ -82,10 +120,78 @@ 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;
ALTER TABLE time_zone_transition_type 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 ;
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
#
# Run on zoneinfo directory --skip-write-binlog
#
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;
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;
#
# Testing with explicit timezonefile
#
@ -96,6 +202,10 @@ 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');
@ -104,15 +214,79 @@ 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;
ALTER TABLE time_zone_transition_type 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 ;
skip truncate tables
skip truncate tables
SELECT COUNT(*) FROM time_zone;
COUNT(*)
1
SELECT COUNT(*) FROM time_zone_name;
COUNT(*)
1
SELECT COUNT(*) FROM time_zone_transition;
COUNT(*)
0
SELECT COUNT(*) FROM time_zone_transition_type;
COUNT(*)
1
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;
#
# Testing with explicit timezonefile --skip-write-binlog
#
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;
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
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;
#
# Testing --leap
#
@ -123,6 +297,10 @@ 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 |
@ -139,15 +317,72 @@ 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;
ALTER TABLE time_zone_transition_type 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 ;
skip truncate tables
skip truncate tables
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
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;
#
# Testing --skip-write-binlog --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;
skip truncate tables
skip truncate tables
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
#
# MDEV-6236 - [PATCH] mysql_tzinfo_to_sql may produce invalid SQL
#
@ -158,13 +393,19 @@ ALTER TABLE time_zone ENGINE=InnoDB;
ALTER TABLE time_zone_name ENGINE=InnoDB;
ALTER TABLE time_zone_transition ENGINE=InnoDB;
ALTER TABLE time_zone_transition_type ENGINE=InnoDB;
END IF|
\d ;
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
TRUNCATE TABLE time_zone_transition_type;
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 ;
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;
@ -173,7 +414,17 @@ 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;
ALTER TABLE time_zone_transition_type 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 ;
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;
RENAME TABLE time_zone_orig TO time_zone,
time_zone_name_orig TO time_zone_name,
time_zone_transition_orig TO time_zone_transition,
time_zone_transition_type_orig TO time_zone_transition_type,
time_zone_leap_second_orig TO time_zone_leap_second;

View File

@ -1,5 +1,18 @@
--source include/have_symlink.inc
--source include/not_windows.inc
--source include/not_embedded.inc
use mysql;
RENAME TABLE time_zone TO time_zone_orig,
time_zone_name TO time_zone_name_orig,
time_zone_transition TO time_zone_transition_orig,
time_zone_transition_type TO time_zone_transition_type_orig,
time_zone_leap_second TO time_zone_leap_second_orig;
CREATE TABLE time_zone LIKE time_zone_orig;
CREATE TABLE time_zone_name LIKE time_zone_name_orig;
CREATE TABLE time_zone_transition LIKE time_zone_transition_orig;
CREATE TABLE time_zone_transition_type LIKE time_zone_transition_type_orig;
CREATE TABLE time_zone_leap_second LIKE time_zone_leap_second_orig;
--echo #
--echo # MDEV-5226 mysql_tzinfo_to_sql errors with tzdata 2013f and above
@ -14,10 +27,41 @@
--echo # Verbose run
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL --verbose $MYSQLTEST_VARDIR/zoneinfo 2>&1
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 # Silent run
--echo # Run on zoneinfo directory
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
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 --skip-write-binlog
--echo #
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>&1
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
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;
# Below tests don't include TRUNCATE TABLE so clear them.
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 # Testing with explicit timezonefile
@ -25,13 +69,68 @@
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
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 # Testing with explicit timezonefile --skip-write-binlog
--echo #
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT XXX 2>&1
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
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 # Testing --leap
--echo #
--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
--exec $MYSQL_TZINFO_TO_SQL --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
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 # Testing --skip-write-binlog --leap
--echo #
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>&1
--exec $MYSQL_TZINFO_TO_SQL --skip-write-binlog --leap $MYSQLTEST_VARDIR/zoneinfo/GMT 2>/dev/null | $MYSQL -S $MASTER_MYSOCK -u root mysql
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
#
@ -48,3 +147,13 @@
--exec $MYSQL_TZINFO_TO_SQL $MYSQLTEST_VARDIR/zoneinfo 2>&1
--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;
RENAME TABLE time_zone_orig TO time_zone,
time_zone_name_orig TO time_zone_name,
time_zone_transition_orig TO time_zone_transition,
time_zone_transition_type_orig TO time_zone_transition_type,
time_zone_leap_second_orig TO time_zone_leap_second;

View File

@ -14,6 +14,7 @@
update mysql.global_priv set priv=json_set(priv, '$.plugin', 'mysql_native_password', '$.authentication_string', password('foo')) where user='root';
--replace_regex /[^ ]*mysql_upgrade_info/...mysql_upgrade_info/
--exec $MYSQL_UPGRADE
connect(con1,localhost,root,foo,,,);
@ -22,3 +23,6 @@ update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin', '$.
flush privileges;
# Load event table
set global event_scheduler=OFF;
let MYSQLD_DATADIR= `select @@datadir`;
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info

Some files were not shown because too many files have changed in this diff Show More