Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext

This commit is contained in:
Alexander Barkov 2017-01-17 18:25:18 +04:00
commit 095ea087b4
319 changed files with 6416 additions and 10130 deletions

4
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.reject
*.spec
*.bak
*.dgcov
*.rpm
.*.swp
*.ninja
@ -80,6 +81,9 @@ mysql-test/lib/My/SafeProcess/my_safe_process
mysql-test/mtr
mysql-test/mysql-test-run
mysql-test/var
mysql-test-gcov.err
mysql-test-gcov.msg
mysys/test_hash
mysys/thr_lock
mysys/thr_timer
packaging/rpm-oel/mysql.spec

View file

@ -32,9 +32,9 @@ then
configure="$configure --verbose"
fi
# git clean -fdX removes all ignored (build) files
commands="\
/bin/rm -rf configure;
/bin/rm -rf CMakeCache.txt CMakeFiles/
git clean -fdX
path=`dirname $0`
. \"$path/autorun.sh\""

View file

@ -42,7 +42,7 @@ Usage: $0 [-h|-n] [configure-options]
Influences the debug flags. Old is default.
--prefix=path Build with prefix 'path'.
Note: this script is intended for internal use by MySQL developers.
Note: this script is intended for internal use by MariaDB developers.
EOF
}
@ -120,10 +120,9 @@ path=`dirname $0`
get_make_parallel_flag
# SSL library to use.--with-ssl will select our bundled yaSSL
# implementation of SSL. To use OpenSSL you will need to specify
# the location of OpenSSL headers and libs on your system.
# Ex --with-ssl=/usr
SSL_LIBRARY=--with-ssl
# implementation of SSL. --with-ssl=yes will first try system library
# then the boundled one --with-ssl=system will use the system library.
SSL_LIBRARY=--with-ssl=system
if [ "x$warning_mode" = "xpedantic" ]; then
warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
@ -293,7 +292,7 @@ gcov_compile_flags="$gcov_compile_flags -DMYSQL_SERVER_SUFFIX=-gcov -DHAVE_gcov"
# GCC4 needs -fprofile-arcs -ftest-coverage on the linker command line (as well
# as on the compiler command line), and this requires setting LDFLAGS for BDB.
gcov_link_flags="-fprofile-arcs -ftest-coverage"
gcov_link_flags="-fprofile-arcs -ftest-coverage -lgcov"
gcov_configs="--with-gcov"

View file

@ -28,6 +28,6 @@ export LDFLAGS="$gcov_link_flags"
extra_flags="$pentium64_cflags $max_cflags $gcov_compile_flags"
c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs --with-zlib-dir=bundled"
extra_configs="$pentium_configs $debug_configs $gcov_configs $max_configs"
. "$path/FINISH.sh"

View file

@ -274,7 +274,7 @@ ENDIF()
# Set commonly used variables
IF(WIN32)
SET(DEFAULT_MYSQL_HOME "C:/MariaDB${MYSQL_BASE_VERSION}")
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MariaDB ${MYSQL_BASE_VERSION}")
SET(SHAREDIR share)
ELSE()
SET(DEFAULT_MYSQL_HOME ${CMAKE_INSTALL_PREFIX})

View file

@ -5156,6 +5156,7 @@ uint get_errcode_from_name(const char *error_name, const char *error_end)
handler_error_names)))
return tmp;
die("Unknown SQL error name '%s'", error_name);
return 0; // Keep compiler happy
}
const char *unknown_error= "<Unknown>";
@ -5786,6 +5787,7 @@ void do_connect(struct st_command *command)
my_bool con_shm __attribute__ ((unused))= 0;
int read_timeout= 0;
int write_timeout= 0;
int connect_timeout= 0;
struct st_connection* con_slot;
static DYNAMIC_STRING ds_connection_name;
@ -5892,6 +5894,11 @@ void do_connect(struct st_command *command)
{
write_timeout= atoi(con_options + sizeof("write_timeout=")-1);
}
else if (strncasecmp(con_options, "connect_timeout=",
sizeof("connect_timeout=")-1) == 0)
{
connect_timeout= atoi(con_options + sizeof("connect_timeout=")-1);
}
else
die("Illegal option to connect: %.*s",
(int) (end - con_options), con_options);
@ -5976,6 +5983,12 @@ void do_connect(struct st_command *command)
(char*)&write_timeout);
}
if (connect_timeout)
{
mysql_options(con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
(char*)&connect_timeout);
}
#ifdef HAVE_SMEM
if (con_shm)
{

View file

@ -165,21 +165,26 @@ foreach my $option (@ARGV)
$cmakeargs = $cmakeargs." -DWITH_LIBEVENT=bundled";
next;
}
if($option =~ /with-ssl=/)
if($option =~ /with-ssl=yes/)
{
$cmakeargs = $cmakeargs." -DWITH_SSL=yes";
next;
}
if($option =~ /with-ssl=system/)
{
$cmakeargs = $cmakeargs." -DWITH_SSL=system";
next;
}
if($option =~ /with-ssl$/)
{
$cmakeargs = $cmakeargs." -DWITH_SSL=bundled";
next;
}
if($option =~ /with-debug/)
{
$cmakeargs = $cmakeargs." -DCMAKE_BUILD_TYPE=Debug -DSECURITY_HARDENED=OFF";
next;
}
if($option =~ /with-ssl/)
{
$cmakeargs = $cmakeargs." -DWITH_SSL=bundled";
next;
}
if($option =~ /prefix=/)
{
$cmake_install_prefix= substr($option, 7);

View file

@ -1213,7 +1213,7 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_)
*
* SYNOPSIS
*
* VOID _db_pargs_(_line_, keyword)
* int _db_pargs_(_line_, keyword)
* int _line_;
* char *keyword;
*
@ -1226,12 +1226,14 @@ void _db_return_(struct _db_stack_frame_ *_stack_frame_)
*
*/
void _db_pargs_(uint _line_, const char *keyword)
int _db_pargs_(uint _line_, const char *keyword)
{
CODE_STATE *cs;
get_code_state_or_return;
get_code_state_or_return 0;
cs->u_line= _line_;
cs->u_keyword= keyword;
return DEBUGGING && _db_keyword_(cs, cs->u_keyword, 0);
}
@ -1265,27 +1267,24 @@ void _db_doprnt_(const char *format,...)
{
va_list args;
CODE_STATE *cs;
int save_errno;
get_code_state_or_return;
va_start(args,format);
if (!cs->locked)
pthread_mutex_lock(&THR_LOCK_dbug);
if (_db_keyword_(cs, cs->u_keyword, 0))
{
int save_errno=errno;
DoPrefix(cs, cs->u_line);
if (TRACING)
Indent(cs, cs->level + 1);
else
(void) fprintf(cs->stack->out_file->file, "%s: ", cs->func);
(void) fprintf(cs->stack->out_file->file, "%s: ", cs->u_keyword);
DbugVfprintf(cs->stack->out_file->file, format, args);
DbugFlush(cs);
errno=save_errno;
}
else if (!cs->locked)
pthread_mutex_unlock(&THR_LOCK_dbug);
save_errno=errno;
DoPrefix(cs, cs->u_line);
if (TRACING)
Indent(cs, cs->level + 1);
else
(void) fprintf(cs->stack->out_file->file, "%s: ", cs->func);
(void) fprintf(cs->stack->out_file->file, "%s: ", cs->u_keyword);
DbugVfprintf(cs->stack->out_file->file, format, args);
DbugFlush(cs);
errno=save_errno;
va_end(args);
}

View file

@ -17,7 +17,7 @@ usr/lib/mysql/plugin/qa_auth_client.so
usr/lib/mysql/plugin/qa_auth_interface.so
usr/lib/mysql/plugin/qa_auth_server.so
usr/share/mysql/mysql-test/README
usr/share/mysql/mysql-test/README.gcov
usr/share/mysql/mysql-test/README-gcov
usr/share/mysql/mysql-test/README.stress
usr/share/mysql/mysql-test/disabled.def
usr/share/mysql/mysql-test/lib

View file

@ -80,6 +80,7 @@ IF(WITH_INNOBASE_STORAGE_ENGINE OR WITH_XTRADB_STORAGE_ENGINE)
../storage/innobase/buf/buf0buf.cc
../storage/innobase/page/page0zip.cc
../storage/innobase/os/os0file.cc
../storage/innobase/fil/fil0crypt.cc
)

View file

@ -1,6 +1,6 @@
/*
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2016, MariaDB Corporation.
Copyright (c) 2014, 2017, 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
@ -70,6 +70,24 @@ The parts not included are excluded by #ifndef UNIV_INNOCHECKSUM. */
#define PRIuMAX "llu"
#endif
/*********************************************************************
Verify checksum for a page (iff it's encrypted)
NOTE: currently this function can only be run in single threaded mode
as it modifies srv_checksum_algorithm (temporarily)
@param[in] src_fame page to verify
@param[in] page_size page_size
@param[in] page_no page number of given read_buf
@param[in] strict_check true if strict-check option is enabled
@return true if page is encrypted AND OK, false otherwise */
UNIV_INTERN
bool
fil_space_verify_crypt_checksum(
/*============================*/
const byte* src_frame, /*!< in: page the verify */
const page_size_t& page_size /*!< in: page size */
,uintmax_t page_no,
bool strict_check);
/* Global variables */
static bool verbose;
static bool just_count;
@ -564,9 +582,25 @@ is_page_corrupted(
}
}
is_corrupted = buf_page_is_corrupted(
true, buf, page_size, false, cur_page_num, strict_verify,
is_log_enabled, log_file);
/* If page is encrypted, use different checksum calculation
as innochecksum can't decrypt pages. Note that some old InnoDB
versions did not initialize FIL_PAGE_FILE_FLUSH_LSN field
so if crypt checksum does not match we verify checksum using
normal method.
*/
if (mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) != 0) {
is_corrupted = fil_space_verify_crypt_checksum(buf, page_size,
cur_page_num, strict_verify);
} else {
is_corrupted = true;
}
if (is_corrupted) {
is_corrupted = buf_page_is_corrupted(
true, buf, page_size, false,
cur_page_num, strict_verify,
is_log_enabled, log_file);
}
return(is_corrupted);
}

View file

@ -42,7 +42,7 @@ extern "C" {
#define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */
#define HASH_THREAD_SPECIFIC 2 /* Mark allocated memory THREAD_SPECIFIC */
typedef uint my_hash_value_type;
typedef uint32 my_hash_value_type;
typedef uchar *(*my_hash_get_key)(const uchar *,size_t*,my_bool);
typedef my_hash_value_type (*my_hash_function)(CHARSET_INFO *,
const uchar *, size_t);

View file

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
Copyright (C) 2000-2011 Monty Program Ab
Copyright (C) 2000, 2017, MariaDB Corporation Ab
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
@ -50,7 +50,7 @@ extern void _db_set_init_(const char *control);
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
struct _db_stack_frame_ *_stack_frame_);
extern void _db_return_(struct _db_stack_frame_ *_stack_frame_);
extern void _db_pargs_(uint _line_,const char *keyword);
extern int _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_(const char *format,...)
ATTRIBUTE_FORMAT(printf, 1, 2);
extern void _db_dump_(uint _line_,const char *keyword,
@ -91,7 +91,7 @@ extern const char* _db_get_func_(void);
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
do {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;} while(0)
do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
#define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (a1)
@ -193,8 +193,18 @@ void debug_sync_point(const char* lock_name, uint lock_timeout);
#define DBUG_SYNC_POINT(lock_name,lock_timeout)
#endif /* EXTRA_DEBUG */
#ifdef __cplusplus
#ifdef __cplusplus
}
# ifdef DBUG_OFF
# define DBUG_LOG(keyword, v) do {} while (0)
# else
# include <sstream>
# define DBUG_LOG(keyword, v) do { \
if (_db_pargs_(__LINE__, keyword)) { \
std::ostringstream _db_s; _db_s << v; \
_db_doprnt_("%s", _db_s.str().c_str()); \
}} while (0)
# endif
#endif
#endif /* _my_dbug_h */

View file

@ -192,6 +192,14 @@ extern void my_large_free(uchar *ptr);
#define my_large_free(A) my_free_lock((A))
#endif /* HAVE_LARGE_PAGES */
void my_init_atomic_write(void);
#ifdef __linux__
my_bool my_test_if_atomic_write(File handle, int pagesize);
#else
#define my_test_if_atomic_write(A, B) 0
#endif /* __linux__ */
extern my_bool my_may_have_atomic_write;
#if defined(HAVE_ALLOCA) && !defined(HAVE_valgrind)
#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43)
#pragma alloca

View file

@ -76,3 +76,9 @@ then put your .test file and .result file(s) into a tar.gz archive,
add a README that explains the problem, ftp the archive to
ftp://ftp.askmonty.org/private and submit a report to
http://mariadb.org/jira about it.
The latest information about mysql-test-run can be found at:
https://mariadb.com/kb/en/mariadb/mysqltest/
If you want to create .rdiff files, check
https://mariadb.com/kb/en/mariadb/mysql-test-auxiliary-files/

View file

@ -2,12 +2,14 @@ To be able to see the level of coverage with the current test suite,
do the following:
- Make sure gcov is installed
- Compile the MySQL distribution with BUILD/compile-pentium-gcov (if your
- Compile the MySQL distribution with BUILD/compile-pentium64-gcov (if your
machine does not have a pentium CPU, hack this script, or just live with
the pentium-specific stuff)
- In the mysql-test directory, run this command: ./mysql-test-run -gcov
- To see the level of coverage for a given source file:
grep source_file_name /tmp/gcov.out
grep -1 source_file_name ../mysql-test-gcov.msg
- To see which lines are not yet covered, look at source_file_name.gcov in
the source tree. Then think hard about a test case that will cover those
lines, and write one!
the source tree. You can find this by doing something like:
find source-directory -name "mysqld.cc.gcov"
Then think hard about a test case that will cover those lines, and write
one!

198
mysql-test/dgcov.pl Executable file
View file

@ -0,0 +1,198 @@
#! /usr/bin/perl
# Copyright (C) 2003,2008 MySQL AB
# Copyright (C) 2010,2017 Sergei Golubchik and MariaDB Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Run gcov and report test coverage on only those code lines touched by
# a given list of commits.
use strict;
use warnings;
use Getopt::Long;
use File::Find;
use Cwd qw/realpath/;
my $opt_verbose=0;
my $opt_generate;
my $opt_help;
my $opt_purge;
my $opt_only_gcov;
my $opt_skip_gcov;
my %cov;
my $file_no=0;
GetOptions
("v|verbose+" => \$opt_verbose,
"h|help" => \$opt_help,
"p|purge" => \$opt_purge,
"g|generate" => \$opt_generate,
"o|only-gcov" => \$opt_only_gcov,
"s|skip-gcov" => \$opt_skip_gcov,
) or usage();
usage() if $opt_help;
sub logv(@) { print STDERR @_,"\n" if $opt_verbose; }
sub gcov_prefix($) { defined($_[0]) ? $_[0] || '#####' : '-' }
my $root= `git rev-parse --show-toplevel`;
chomp $root;
die "Failed to find tree root" unless $root;
$root=realpath($root).'/';
logv "Chdir $root";
chdir $root or die "chdir($root): $!";
my $res;
my $cmd;
if ($opt_purge)
{
$cmd= "find . -name '*.da' -o -name '*.gcda' -o -name '*.gcov' -o ".
"-name '*.dgcov' | grep -v 'README\.gcov' | xargs rm -f ''";
logv "Running: $cmd";
system($cmd)==0 or die "system($cmd): $? $!";
exit 0;
}
find(\&gcov_one_file, $root);
find(\&write_coverage, $root) if $opt_generate;
exit 0 if $opt_only_gcov;
if (@ARGV) {
print_gcov_for_diff(@ARGV);
} else {
print_gcov_for_diff('HEAD') or print_gcov_for_diff('HEAD^');
}
exit 0;
sub print_gcov_for_diff {
$cmd="git diff --no-prefix --ignore-space-change @_";
logv "Running: $cmd";
open PIPE, '-|', $cmd or die "Failed to popen '$cmd': $!: $?";
my ($lnum, $cnt, $fcov, $acc, $printme, $fname);
while (<PIPE>) {
if (/^diff --git (.*) \1\n/) {
print $acc if $printme;
$fname=$1;
$acc="dgcov $fname";
$acc=('*' x length($acc)) . "\n$acc\n" . ('*' x length($acc));
$lnum=undef;
$fcov=$cov{realpath($fname)};
$printme=0;
logv "File: $fname";
next;
}
if (/^@@ -\d+,\d+ \+(\d+),(\d+) @@/ and $fcov) {
$lnum=$1;
$cnt=$2;
$acc.="\n@@ +$lnum,$cnt @\@$'";
logv " lines: $lnum,",$lnum+$cnt;
next;
}
next unless $lnum and $cnt;
$acc.=sprintf '%9s:%5s:%s', '', $lnum, $' if /^ /;
++$printme, $acc.=sprintf '%9s:%5s:%s', gcov_prefix($fcov->{$lnum}), $lnum, $' if /^\+/;
die "$_^^^ dying", unless /^[- +]/;
++$lnum;
--$cnt;
}
print $acc if $printme;
close PIPE or die "command '$cmd' failed: $!: $?";
return defined($fname);
}
sub usage {
print <<END;
Usage: $0 --help
$0 [options] [git diff arguments]
The dgcov program runs gcov for code coverage analysis, and reports missing
coverage only for those lines that are changed by the specified commit(s).
Commits are specified in the format of git diff arguments. For example:
* All unpushed commits: $0 \@{u} HEAD
* All uncommitted changes: $0 HEAD
* Specific commit: $0 <commit>^ <commit>
If no arguments are specified, it prints the coverage for all uncommitted
changes, if any, otherwise for the last commit.
Options:
-h --help This help.
-v --verbose Show commands run.
-p --purge Delete all test coverage information, to prepare for a
new coverage test.
-o --only-gcov Stop after running gcov, don't run git
-s --skip-gcov Do not run gcov, assume .gcov files are already in place
-g --generate Create .dgcov files for all source files
Prior to running this tool, MariaDB should be built with
cmake -DENABLE_GCOV=ON
and the testsuite should be run. dgcov will report the coverage
for all lines modified in the specified commits.
END
exit 1;
}
sub gcov_one_file {
return unless /\.gcda$/;
unless ($opt_skip_gcov) {
$cmd= "gcov -i '$_' 2>/dev/null >/dev/null";
print STDERR ++$file_no,"\r" if not $opt_verbose and -t STDERR;
logv "Running: $cmd";
system($cmd)==0 or die "system($cmd): $? $!";
}
# now, read the generated file
open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!";
my $fname;
while (<FH>) {
chomp;
if (/^function:/) {
next;
}
if (/^file:/) {
$fname=realpath($');
next;
}
next if /^lcount:\d+,-\d+/; # whatever that means
unless (/^lcount:(\d+),(\d+)/ and $fname) {
warn "unknown line '$_' after running '$cmd'";
next;
}
$cov{$fname}->{$1}+=$2;
}
close(FH);
}
sub write_coverage {
my $fn=$File::Find::name;
my $h=$cov{$fn};
return unless $h and $root eq substr $fn, 0, length($root);
open I, '<', $fn or die "open(<$fn): $!";
open O, '>', "$fn.dgcov" or die "open(>$fn.dgcov): $!";
logv "Annotating: ", substr $fn, length($root);
while (<I>) {
printf O '%9s:%5s:%s', gcov_prefix($h->{$.}), $., $_;
}
close I;
close O;
}

View file

@ -47,8 +47,8 @@ if ($rpl_debug)
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect
# Send shutdown to the connected server and give
# it 10 seconds to die before zapping it
shutdown_server 10;
# it 60 seconds to die before zapping it
shutdown_server 60;
--source include/wait_until_disconnected.inc

View file

@ -82,8 +82,14 @@ perl;
}
$ENV{'SEARCH_FILE'} =~ s{^.*?([^/\\]+)$}{$1};
if ($content =~ m{$search_pattern}) {
die "FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
if $ENV{SEARCH_ABORT} eq 'FOUND';
print "FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
unless defined $ENV{SEARCH_ABORT};
} else {
die "NOT FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
if $ENV{SEARCH_ABORT} eq 'NOT FOUND';
print "NOT FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
unless defined $ENV{SEARCH_ABORT};
}
EOF

View file

@ -1,7 +1,14 @@
# Include this script only after using shutdown_mysqld.inc
# where $_expect_file_name was initialized.
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $_expect_file_name
if ($restart_parameters)
{
--exec echo "restart: $restart_parameters" > $_expect_file_name
}
if (!$restart_parameters)
{
--exec echo "restart" > $_expect_file_name
}
# Turn on reconnect
--enable_reconnect

View file

@ -1,71 +0,0 @@
# -*- cperl -*-
# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This is a library file used by the Perl version of mysql-test-run,
# and is part of the translation of the Bourne shell script with the
# same name.
use strict;
our $basedir;
sub gcov_prepare ($) {
my ($dir)= @_;
print "Purging gcov information from '$dir'...\n";
system("find $dir -name \*.gcov -o -name \*.da"
. " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm");
}
#
# Collect gcov statistics.
# Arguments:
# $dir basedir, normally build directory
# $gcov gcov utility program [path] name
# $gcov_msg message file name
# $gcov_err error file name
#
sub gcov_collect ($$$) {
my ($dir, $gcov, $gcov_msg, $gcov_err)= @_;
# Get current directory to return to later.
my $start_dir= cwd();
print "Collecting source coverage info using '$gcov'...$basedir\n";
-f "$dir/$gcov_msg" and unlink("$dir/$gcov_msg");
-f "$dir/$gcov_err" and unlink("$dir/$gcov_err");
my @dirs= `find "$dir" -type d -print | sort`;
#print "List of directories:\n@dirs\n";
foreach my $d ( @dirs ) {
chomp($d);
chdir($d) or next;
my @flist= glob("*.*.gcno");
print ("Collecting in '$d'...\n") if @flist;
foreach my $f (@flist) {
system("$gcov $f 2>>$dir/$gcov_err >>$dir/$gcov_msg");
system("perl", "$basedir/mysql-test/lib/process-purecov-annotations.pl", "$f.gcov");
}
chdir($start_dir);
}
print "gcov info in $dir/$gcov_msg, errors in $dir/$gcov_err\n";
}
1;

View file

@ -104,7 +104,6 @@ use IO::Select;
require "mtr_process.pl";
require "mtr_io.pl";
require "mtr_gcov.pl";
require "mtr_gprof.pl";
require "mtr_misc.pl";
@ -248,11 +247,6 @@ our $opt_mem= $ENV{'MTR_MEM'};
our $opt_clean_vardir= $ENV{'MTR_CLEAN_VARDIR'};
our $opt_gcov;
our $opt_gcov_src_dir;
our $opt_gcov_exe= "gcov";
our $opt_gcov_err= "mysql-test-gcov.err";
our $opt_gcov_msg= "mysql-test-gcov.msg";
our $opt_gprof;
our %gprof_dirs;
@ -383,11 +377,6 @@ sub main {
# --help will not reach here, so now it's safe to assume we have binaries
My::SafeProcess::find_bin();
if ( $opt_gcov ) {
gcov_prepare($basedir . "/" . $opt_gcov_src_dir);
}
print "vardir: $opt_vardir\n";
initialize_servers();
init_timers();
@ -431,6 +420,10 @@ sub main {
exit 0;
}
if ($opt_gcov) {
system './dgcov.pl --purge';
}
#######################################################################
my $num_tests= @$tests;
if ( $opt_parallel eq "auto" ) {
@ -555,15 +548,15 @@ sub main {
mtr_print_line();
if ( $opt_gcov ) {
gcov_collect($basedir . "/" . $opt_gcov_src_dir, $opt_gcov_exe,
$opt_gcov_msg, $opt_gcov_err);
}
print_total_times($opt_parallel) if $opt_report_times;
mtr_report_stats($prefix, $fail, $completed, $extra_warnings);
if ($opt_gcov) {
mtr_report("Running dgcov");
system "./dgcov.pl --generate > $opt_vardir/last_changes.dgcov";
}
if ( @$completed != $num_tests)
{
mtr_error("Not all tests completed (only ". scalar(@$completed) .
@ -1148,7 +1141,6 @@ sub command_line_setup {
# Coverage, profiling etc
'gcov' => \$opt_gcov,
'gcov-src-dir=s' => \$opt_gcov_src_dir,
'gprof' => \$opt_gprof,
'valgrind|valgrind-all' => \$opt_valgrind,
'valgrind-mysqltest' => \$opt_valgrind_mysqltest,
@ -6180,9 +6172,6 @@ Misc options
actions. Disable facility with NUM=0.
gcov Collect coverage information after the test.
The result is a gcov file per source and header file.
gcov-src-dir=subdir Collect coverage only within the given subdirectory.
For example, if you're only developing the SQL layer,
it makes sense to use --gcov-src-dir=sql
gprof Collect profiling information using gprof.
experimental=<file> Refer to list of tests considered experimental;
failures will be marked exp-fail instead of fail.

View file

@ -2089,6 +2089,21 @@ tab1 CREATE TABLE `tab1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE `tab1`;
#
# MDEV-11548 Reproducible server crash after the 2nd ALTER TABLE ADD FOREIGN KEY IF NOT EXISTS
#
CREATE TABLE t1 (id INT UNSIGNED NOT NULL PRIMARY KEY);
CREATE TABLE t2 (id1 INT UNSIGNED NOT NULL);
ALTER TABLE t2
ADD FOREIGN KEY IF NOT EXISTS (id1)
REFERENCES t1 (id);
ALTER TABLE t2
ADD FOREIGN KEY IF NOT EXISTS (id1)
REFERENCES t1 (id);
Warnings:
Note 1061 Duplicate key name 'id1'
DROP TABLE t2;
DROP TABLE t1;
#
# Start of 10.1 tests
#
#

View file

@ -2327,3 +2327,19 @@ a b dist
7 6 3
DROP VIEW edges2;
DROP TABLE edges;
#
# MDEV-11674: recursive CTE table that cannot be stored
# in a heap table
#
create table t1 (id int, test_data varchar(36));
insert into t1(id, test_data)
select id, test_data
from (
with recursive data_generator(id, test_data) as (
select 1 as id, uuid() as test_data
union all
select id + 1, uuid() from data_generator where id < 150000
)
select * from data_generator
) as a;
drop table t1;

View file

@ -480,6 +480,10 @@ a b
2 2
3 4
drop table t1;
CREATE OR REPLACE TABLE t1 (a INT DEFAULT @v);
drop table t1;
CREATE TABLE t1 (a INT DEFAULT @v:=1);
drop table t1;
#
# Error handling
#
@ -516,10 +520,6 @@ CREATE TABLE t1 (a INT DEFAULT(?));
Got one of the listed errors
CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a));
ERROR 01000: Expression for field `a` is refering to uninitialized field `b`
CREATE TABLE t1 (a INT DEFAULT @v);
ERROR HY000: Function or expression '@v' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT @v:=1);
ERROR HY000: Function or expression '@v' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy'));
ERROR HY000: Function or expression 'name_const()' cannot be used in the DEFAULT clause of `a`
CREATE TABLE t1 (a INT DEFAULT COUNT(*));

View file

@ -2158,35 +2158,31 @@ Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
SET optimizer_switch=@save_optimizer_switch;
connection default;
SELECT sleep(5.5);
SELECT sleep(50);
connect con2,localhost,root,,;
connection con2;
SELECT sleep(5);
SELECT sleep(50);
# -- Success: more than --thread_pool_max_threads normal connections not possible
connection default;
sleep(5.5)
0
connection con2;
sleep(5)
0
connection default;
SELECT sleep(5);
connection con2;
SELECT sleep(5);
connect extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
connection extracon;
SELECT 'Connection on extra port ok';
Connection on extra port ok
Connection on extra port ok
SELECT sleep(5.5);
connect extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
connection extracon2;
SELECT 'Connection on extra port 2 ok';
Connection on extra port 2 ok
Connection on extra port 2 ok
# -- Success: more than --extra-max-connections + 1 normal connections not possible
connection extracon2;
KILL QUERY <default_connection_ID>;
KILL QUERY <con2_connection_ID>;
connection default;
sleep(5)
0
sleep(50)
1
connection con2;
sleep(5)
sleep(50)
1
connection extracon;
sleep(5.5)
0

View file

@ -340,3 +340,26 @@ f1()
DROP FUNCTION f1;
DROP VIEW v1;
DROP TABLE t1,t2;
#
# Bug #16672723 "CAN'T FIND TEMPORARY TABLE".
#
CREATE FUNCTION f1() RETURNS INT RETURN 1;
CREATE TEMPORARY TABLE tmp1(a INT);
PREPARE stmt1 FROM "CREATE TEMPORARY TABLE tmp2 AS SELECT b FROM (SELECT f1() AS b FROM tmp1) AS t";
# The below statement failed before the fix.
EXECUTE stmt1;
DROP TEMPORARY TABLES tmp1, tmp2;
DEALLOCATE PREPARE stmt1;
DROP FUNCTION f1;
create procedure sp1()
begin
drop table if exists t1, t2;
create temporary table t1 select 1 v;
create table t2 (col varchar(45)) select distinct col from (select sf1() as col from t1) t;
end$$
create function sf1() returns text return 'blah';
call test.sp1();
call test.sp1();
drop procedure sp1;
drop function sf1;
drop table t2;

View file

@ -5848,6 +5848,31 @@ f1 f2
drop table t1, t2;
SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1;
ERROR 42S22: Unknown column 'SOME_GARBAGE.b.a' in 'field list'
#
# MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1
# FOR UPDATE
#
CREATE TABLE t1 (a INT);
insert into t1 values (1),(2);
CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` for update latin1 latin1_swedish_ci
select * from v1;
a
1
2
DROP VIEW v1;
CREATE VIEW v1 AS SELECT * FROM t1 LOCK IN SHARE MODE;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` lock in share mode latin1 latin1_swedish_ci
select * from v1;
a
1
2
DROP VIEW v1;
DROP TABLE t1;
# -----------------------------------------------------------------
# -- End of 10.0 tests.
# -----------------------------------------------------------------

View file

@ -139,3 +139,10 @@ flush tables;
create table t1 (a int) engine=archive;
ERROR 42S01: Table 't1' already exists
drop table t1;
CREATE OR REPLACE TABLE t1 ( pk INT AUTO_INCREMENT PRIMARY KEY ) ENGINE = ARCHIVE;
CREATE OR REPLACE TABLE t1 ( pk INT AUTO_INCREMENT PRIMARY KEY ) ENGINE = ARCHIVE;
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 ( pk INT AUTO_INCREMENT PRIMARY KEY ) ENGINE = ARCHIVE;
SELECT * FROM t1;
pk
DROP TABLE t1;

View file

@ -132,3 +132,13 @@ flush tables;
create table t1 (a int) engine=archive;
drop table t1;
#
# MDEV-11317: Error in deleting non existing .frm for tables with disocvery
#
CREATE OR REPLACE TABLE t1 ( pk INT AUTO_INCREMENT PRIMARY KEY ) ENGINE = ARCHIVE;
CREATE OR REPLACE TABLE t1 ( pk INT AUTO_INCREMENT PRIMARY KEY ) ENGINE = ARCHIVE;
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 ( pk INT AUTO_INCREMENT PRIMARY KEY ) ENGINE = ARCHIVE;
SELECT * FROM t1;
DROP TABLE t1;

View file

@ -10,7 +10,5 @@
#
##############################################################################
innodb_scrub : MDEV-8139
innodb_scrub_compressed : MDEV-8139
innodb_scrub_background : MDEV-8139
innochecksum: see buf_page_is_corrupted()
innodb_scrub_background : MDEV-8139 background scrubbing does not work reliably
innodb_scrub : MDEV-8139 occasional corruption of delete_3.ibd page 2

View file

@ -1,7 +1,3 @@
SET GLOBAL innodb_file_format = `Barracuda`;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
SET GLOBAL innodb_file_per_table = ON;
create table t1(c1 bigint not null, b char(200), c varchar(200)) engine=innodb encrypted=yes encryption_key_id=1;
show warnings;
Level Code Message
@ -15,14 +11,14 @@ set current_num = current_num + 1;
end while;
end//
commit;
set autocommit=0;
begin;
call innodb_insert_proc(2000);
commit;
set autocommit=1;
update t1 set c1 = c1 +1;
select count(*) from t1;
count(*)
2000
# Kill the server
# ibdata1 yes on expecting NOT FOUND
NOT FOUND /privatejanprivate/ in ibdata1
# t1 yes on expecting NOT FOUND
@ -55,5 +51,3 @@ FOUND /publicmessage/ in ib_logfile0
NOT FOUND /publicmessage/ in ib_logfile1
drop procedure innodb_insert_proc;
drop table t1;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html

View file

@ -0,0 +1,3 @@
create table t1(a int not null primary key auto_increment,
b varchar(200), c char(100), d varchar(150)) engine=innodb;
DROP TABLE t1;

View file

@ -1,5 +1,4 @@
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
SET GLOBAL innodb_fast_shutdown=0;
SHOW VARIABLES LIKE 'innodb_encrypt%';
Variable_name Value
innodb_encrypt_log OFF
@ -87,47 +86,47 @@ Innodb_pages0_read 3
# Restart Success!
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
use test;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
use innodb_encrypted_1;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
use innodb_encrypted_2;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
use innodb_encrypted_3;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
use innodb_encrypted_1;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 3
Innodb_pages0_read 1
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 103
Innodb_pages0_read 101
use innodb_encrypted_2;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 103
Innodb_pages0_read 101
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 203
Innodb_pages0_read 201
use innodb_encrypted_3;
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 203
Innodb_pages0_read 201
show status like 'innodb_pages0_read%';
Variable_name Value
Innodb_pages0_read 303
Innodb_pages0_read 301
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
COUNT(*)
100

View file

@ -1,207 +1,121 @@
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
#
# Test delete of records
#
create table t1 (
where variable_name like 'innodb_scrub_background%';
# MDEV-8139 Fix scrubbing tests
# FIXME: Add index(b) to each table; ensure that undo logs are scrubbed.
create table delete_3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
delete from delete_3;
create table delete_rollback_delete_3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
begin;
delete from delete_rollback_delete_3;
rollback;
delete from delete_rollback_delete_3;
create table insert_rollback_3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
begin;
rollback;
create table delete_2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compact;
# Populate table with rows
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# compact: delete from: grep -c bicycle t1.ibd
0
# compact: delete from: grep -c bicycle ibdata1
0
# compact: delete from: grep -c repairman t1.ibd
0
# compact: delete from: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete+rollback+delete
#
create table t1 (
delete from delete_2;
create table delete_rollback_delete_2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compact;
# Populate table with rows
begin;
delete from t1;
delete from delete_rollback_delete_2;
rollback;
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# compact: delete rollback: grep -c bicycle t1.ibd
0
# compact: delete rollback: grep -c bicycle ibdata1
0
# compact: delete rollback: grep -c repairman t1.ibd
0
# compact: delete rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test insert+rollback
#
create table t1 (
delete from delete_rollback_delete_2;
create table insert_rollback_2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compact;
# Populate table with rows
begin;
rollback;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# compact: insert rollback: grep -c bicycle t1.ibd
0
# compact: insert rollback: grep -c bicycle ibdata1
0
# compact: insert rollback: grep -c repairman t1.ibd
0
# compact: insert rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete of records
#
create table t1 (
create table delete_1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=redundant;
# Populate table with rows
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# redundant: delete from: grep -c bicycle t1.ibd
0
# redundant: delete from: grep -c bicycle ibdata1
0
# redundant: delete from: grep -c repairman t1.ibd
0
# redundant: delete from: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete+rollback+delete
#
create table t1 (
delete from delete_1;
create table delete_rollback_delete_1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=redundant;
# Populate table with rows
begin;
delete from t1;
delete from delete_rollback_delete_1;
rollback;
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# redundant: delete rollback: grep -c bicycle t1.ibd
0
# redundant: delete rollback: grep -c bicycle ibdata1
0
# redundant: delete rollback: grep -c repairman t1.ibd
0
# redundant: delete rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test insert+rollback
#
create table t1 (
delete from delete_rollback_delete_1;
create table insert_rollback_1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=redundant;
# Populate table with rows
begin;
rollback;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# redundant: insert rollback: grep -c bicycle t1.ibd
0
# redundant: insert rollback: grep -c bicycle ibdata1
0
# redundant: insert rollback: grep -c repairman t1.ibd
0
# redundant: insert rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete of records
#
create table t1 (
create table delete_0 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=dynamic;
# Populate table with rows
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: delete from: grep -c bicycle t1.ibd
0
# dynamic: delete from: grep -c bicycle ibdata1
0
# dynamic: delete from: grep -c repairman t1.ibd
0
# dynamic: delete from: grep -c repairman ibdata1
0
drop table t1;
#
# Test delete+rollback+delete
#
create table t1 (
delete from delete_0;
create table delete_rollback_delete_0 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
delete from t1;
delete from delete_rollback_delete_0;
rollback;
delete from t1;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: delete rollback: grep -c bicycle t1.ibd
0
# dynamic: delete rollback: grep -c bicycle ibdata1
0
# dynamic: delete rollback: grep -c repairman t1.ibd
0
# dynamic: delete rollback: grep -c repairman ibdata1
0
drop table t1;
#
# Test insert+rollback
#
create table t1 (
delete from delete_rollback_delete_0;
create table insert_rollback_0 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
rollback;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: insert rollback: grep -c bicycle t1.ibd
0
# dynamic: insert rollback: grep -c bicycle ibdata1
0
# dynamic: insert rollback: grep -c repairman t1.ibd
0
# dynamic: insert rollback: grep -c repairman ibdata1
0
drop table t1;
SET GLOBAL innodb_fast_shutdown=0;
# delete_3.ibd
# delete_rollback_delete_3.ibd
# insert_rollback_3.ibd
# delete_2.ibd
# delete_rollback_delete_2.ibd
# insert_rollback_2.ibd
# delete_1.ibd
# delete_rollback_delete_1.ibd
# insert_rollback_1.ibd
# delete_0.ibd
# delete_rollback_delete_0.ibd
# insert_rollback_0.ibd
check table delete_3, delete_rollback_delete_3, insert_rollback_3;
Table Op Msg_type Msg_text
test.delete_3 check status OK
test.delete_rollback_delete_3 check status OK
test.insert_rollback_3 check status OK
drop table delete_3, delete_rollback_delete_3, insert_rollback_3;
check table delete_2, delete_rollback_delete_2, insert_rollback_2;
Table Op Msg_type Msg_text
test.delete_2 check status OK
test.delete_rollback_delete_2 check status OK
test.insert_rollback_2 check status OK
drop table delete_2, delete_rollback_delete_2, insert_rollback_2;
check table delete_1, delete_rollback_delete_1, insert_rollback_1;
Table Op Msg_type Msg_text
test.delete_1 check status OK
test.delete_rollback_delete_1 check status OK
test.insert_rollback_1 check status OK
drop table delete_1, delete_rollback_delete_1, insert_rollback_1;
check table delete_0, delete_rollback_delete_0, insert_rollback_0;
Table Op Msg_type Msg_text
test.delete_0 check status OK
test.delete_rollback_delete_0 check status OK
test.insert_rollback_0 check status OK
drop table delete_0, delete_rollback_delete_0, insert_rollback_0;
show variables like 'innodb_%scrub_data%';
Variable_name Value
innodb_background_scrub_data_check_interval 3600

View file

@ -11,66 +11,146 @@ innodb_background_scrub_data_uncompressed ON
innodb_immediate_scrub_data_uncompressed OFF
# make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
truncate table snapshot_status;
insert into snapshot_status
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
#
# Test delete of records
#
create table t1 (
create table delete_3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=dynamic;
c text,
index(b)) engine = innodb row_format=compressed;
# Populate table with rows
delete from t1;
#
# Test delete+rollback+delete
#
create table t2 (
delete from delete_3;
create table delete_rollback_delete_3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=dynamic;
c text,
index(b)) engine = innodb row_format=compressed;
# Populate table with rows
begin;
delete from t2;
delete from delete_rollback_delete_3;
rollback;
delete from t2;
#
# Test insert+rollback
#
create table t3 (
delete from delete_rollback_delete_3;
create table insert_rollback_3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=dynamic;
c text,
index(b)) engine = innodb row_format=compressed;
# Populate table with rows
begin;
rollback;
create table delete_2 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compact;
# Populate table with rows
delete from delete_2;
create table delete_rollback_delete_2 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compact;
# Populate table with rows
begin;
delete from delete_rollback_delete_2;
rollback;
delete from delete_rollback_delete_2;
create table insert_rollback_2 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=compact;
# Populate table with rows
begin;
rollback;
create table delete_1 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=redundant;
# Populate table with rows
delete from delete_1;
create table delete_rollback_delete_1 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=redundant;
# Populate table with rows
begin;
delete from delete_rollback_delete_1;
rollback;
delete from delete_rollback_delete_1;
create table insert_rollback_1 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=redundant;
# Populate table with rows
begin;
rollback;
create table delete_0 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=dynamic;
# Populate table with rows
delete from delete_0;
create table delete_rollback_delete_0 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
delete from delete_rollback_delete_0;
rollback;
delete from delete_rollback_delete_0;
create table insert_rollback_0 (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format=dynamic;
# Populate table with rows
begin;
rollback;
# start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
# Wait max 10 min for scrubbing
# Success!
# stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
# restart mysqld so that all pages are flushed
# read all rows from table
select * from t1;
# dynamic: delete: grep -c bicycle t1.ibd
0
# dynamic: delete: grep -c repairman t1.ibd
0
# dynamic: delete rollback: grep -c bicycle t2.ibd
0
# dynamic: delete rollback: grep -c repairman t2.ibd
0
# dynamic: insert rollback: grep -c bicycle t3.ibd
0
# dynamic: insert rollback: grep -c repairman t3.ibd
0
drop table t1, t2, t3;
SET GLOBAL innodb_fast_shutdown=0;
# delete_3.ibd
# delete_rollback_delete_3.ibd
# insert_rollback_3.ibd
# delete_2.ibd
# delete_rollback_delete_2.ibd
# insert_rollback_2.ibd
# delete_1.ibd
# delete_rollback_delete_1.ibd
# insert_rollback_1.ibd
# delete_0.ibd
# delete_rollback_delete_0.ibd
# insert_rollback_0.ibd
check table delete_3, delete_rollback_delete_3, insert_rollback_3;
Table Op Msg_type Msg_text
test.delete_3 check status OK
test.delete_rollback_delete_3 check status OK
test.insert_rollback_3 check status OK
drop table delete_3, delete_rollback_delete_3, insert_rollback_3;
check table delete_2, delete_rollback_delete_2, insert_rollback_2;
Table Op Msg_type Msg_text
test.delete_2 check status OK
test.delete_rollback_delete_2 check status OK
test.insert_rollback_2 check status OK
drop table delete_2, delete_rollback_delete_2, insert_rollback_2;
check table delete_1, delete_rollback_delete_1, insert_rollback_1;
Table Op Msg_type Msg_text
test.delete_1 check status OK
test.delete_rollback_delete_1 check status OK
test.insert_rollback_1 check status OK
drop table delete_1, delete_rollback_delete_1, insert_rollback_1;
check table delete_0, delete_rollback_delete_0, insert_rollback_0;
Table Op Msg_type Msg_text
test.delete_0 check status OK
test.delete_rollback_delete_0 check status OK
test.insert_rollback_0 check status OK
drop table delete_0, delete_rollback_delete_0, insert_rollback_0;
show variables like 'innodb_%scrub_data%';
Variable_name Value
innodb_background_scrub_data_check_interval 3600
@ -78,4 +158,3 @@ innodb_background_scrub_data_compressed ON
innodb_background_scrub_data_interval 604800
innodb_background_scrub_data_uncompressed ON
innodb_immediate_scrub_data_uncompressed OFF
drop table snapshot_status;

View file

@ -1,71 +0,0 @@
# make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
#
# Test delete of records
#
create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
# Populate table with rows
delete from t1;
#
# Test delete+rollback+delete
#
create table t2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
# Populate table with rows
begin;
delete from t2;
rollback;
delete from t2;
#
# Test insert+rollback
#
create table t3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
# Populate table with rows
begin;
rollback;
# start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
# Wait max 10 min for scrubbing of this table
# Success!
# stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
# Now there should be background scrubs
# restart mysqld so that all pages are flushed (encryption off)
# so that grep will find stuff
# read all rows from table
select * from t1;
select * from t2;
select * from t3;
# grep -c bicycle t1.ibd
0
# grep -c bicycle ibdata1
0
# grep -c repairman t1.ibd
0
# grep -c repairman ibdata1
0
# grep -c boondoggle t2.ibd
0
# grep -c boondoggle ibdata1
0
# grep -c waste t2.ibd
0
# grep -c waste ibdata1
0
# grep -c keso t3.ibd
0
# grep -c keso ibdata1
0
# grep -c kent t3.ibd
0
# grep -c kent ibdata1
0
drop table t1, t2, t3;

View file

@ -6,19 +6,6 @@
# MDEV-9011: Redo log encryption does not work
#
--disable_query_log
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
--enable_query_log
--disable_query_log
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
--enable_query_log
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
create table t1(c1 bigint not null, b char(200), c varchar(200)) engine=innodb encrypted=yes encryption_key_id=1;
show warnings;
@ -35,16 +22,13 @@ end//
delimiter ;//
commit;
set autocommit=0;
begin;
call innodb_insert_proc(2000);
commit;
set autocommit=1;
update t1 set c1 = c1 +1;
select count(*) from t1;
-- source include/restart_mysqld.inc
--let $MYSQLD_DATADIR=`select @@datadir`
--let ib1_IBD = $MYSQLD_DATADIR/ibdata1
--let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd
@ -53,6 +37,8 @@ select count(*) from t1;
--let SEARCH_RANGE = 10000000
--let SEARCH_PATTERN=privatejanprivate
-- source include/kill_mysqld.inc
--echo # ibdata1 yes on expecting NOT FOUND
-- let SEARCH_FILE=$ib1_IBD
-- source include/search_pattern_in_file.inc
@ -68,7 +54,7 @@ select count(*) from t1;
--echo # Restart mysqld --innodb_encrypt_log=0
-- let $restart_parameters=--innodb_encrypt_log=0
-- source include/restart_mysqld.inc
-- source include/start_mysqld.inc
insert into t1 values(5000, substring(MD5(RAND()), -64), REPEAT('publicmessage',10));
insert into t1 values(5001, substring(MD5(RAND()), -64), REPEAT('publicmessage',10));
@ -106,9 +92,3 @@ insert into t1 values(5004, substring(MD5(RAND()), -64), REPEAT('publicmessage',
drop procedure innodb_insert_proc;
drop table t1;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
--enable_query_log

View file

@ -0,0 +1 @@
--loose-innodb-scrub-log=on

View file

@ -0,0 +1,13 @@
--source include/have_innodb.inc
#
# MDEV-11705: InnoDB: Failing assertion: (&log_sys->mutex)->is_owned() if server started with innodb-scrub-log
#
create table t1(a int not null primary key auto_increment,
b varchar(200), c char(100), d varchar(150)) engine=innodb;
let $wait_condition= SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'innodb_scrub_log';
--source include/wait_condition.inc
DROP TABLE t1;

View file

@ -6,13 +6,12 @@
-- source include/not_embedded.inc
--disable_query_log
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
let $innodb_encryption_threads_orig = `SELECT @@global.innodb_encryption_threads`;
--enable_query_log
SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;
# empty the change buffer and the undo logs to avoid extra reads
SET GLOBAL innodb_fast_shutdown=0;
--source include/restart_mysqld.inc
SHOW VARIABLES LIKE 'innodb_encrypt%';
@ -29,7 +28,8 @@ let $tables = 100;
--disable_query_log
while ($tables)
{
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb;
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb
stats_persistent=0;
commit;
let $rows = 100;
while($rows)
@ -64,7 +64,8 @@ set autocommit=0;
let $tables = 100;
while ($tables)
{
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb encrypted=yes;
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb
stats_persistent=0 encrypted=yes;
commit;
let $rows = 100;
while($rows)
@ -100,7 +101,8 @@ set autocommit=0;
let $tables = 100;
while ($tables)
{
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb encrypted=no;
eval create table t_$tables (a int not null primary key, b varchar(200)) engine=innodb
stats_persistent=0 encrypted=no;
commit;
let $rows = 100;
while($rows)
@ -268,7 +270,5 @@ drop database innodb_encrypted_2;
drop database innodb_encrypted_3;
--disable_query_log
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
EVAL SET GLOBAL innodb_encryption_threads = $innodb_encryption_threads_orig;
--enable_query_log

View file

@ -1,147 +1,138 @@
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/not_windows.inc
let $MYSQLD_DATADIR=`select @@datadir`;
let ib1_IBD = $MYSQLD_DATADIR/ibdata1;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
let INNODB_PAGE_SIZE= `select @@innodb_page_size`;
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
where variable_name like 'innodb_scrub_background%';
let $rowcount=500;
let $formatno = 3;
let $maxformatno= 4;
let $formatno= $maxformatno;
--echo # MDEV-8139 Fix scrubbing tests
--echo # FIXME: Add index(b) to each table; ensure that undo logs are scrubbed.
let $tableformat= (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format;
while ($formatno)
{
dec $formatno;
let $format = `select case $formatno
when 1 then 'dynamic'
when 2 then 'redundant'
when 3 then 'compact'
when 0 then 'dynamic'
when 1 then 'redundant'
when 2 then 'compact'
when 3 then 'compressed'
end`;
let $t= delete_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
eval insert into $t(b,c) values ('repairman', repeat('unicycle', 1000));
}
commit;
--enable_query_log
eval delete from $t;
let $t= delete_rollback_delete_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
eval insert into $t(b,c) values ('breakhuman', repeat('bicycle', 1000));
}
commit;
--enable_query_log
begin;
eval delete from $t;
rollback;
eval delete from $t;
let $t= insert_rollback_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
begin;
--disable_query_log
while ($numinserts)
{
dec $numinserts;
eval insert into $t(b,c) values ('wonderwoman', repeat('tricycle', 1000));
}
--enable_query_log
rollback;
}
SET GLOBAL innodb_fast_shutdown=0;
-- source include/shutdown_mysqld.inc
let SEARCH_ABORT= FOUND;
let SEARCH_PATTERN= (un|b|tr)icycle|(repair|breakhu|wonderwo)man;
let SEARCH_RANGE= 12582912;
let SEARCH_FILE= $MYSQLD_DATADIR/ibdata1;
# We may randomly find copies of unscrubbed pages in the doublewrite buffer.
# Let us scrub the doublewrite buffer ourselves.
perl;
use Fcntl 'SEEK_SET';
my $page_size = $ENV{INNODB_PAGE_SIZE};
open(FILE, "+<", "$ENV{SEARCH_FILE}") or die "cannot open: $!\n";
seek(FILE, $page_size * 64, SEEK_SET) or die "cannot seek: $!\n";
print(FILE chr(0) x ($page_size * 128)) or die "cannot write: $!\n";
close FILE or die "cannot close: $!\n";;
EOF
-- source include/search_pattern_in_file.inc
let $formatno= $maxformatno;
while ($formatno)
{
dec $formatno;
-- echo #
-- echo # Test delete of records
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
let $t= delete_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
let $t= delete_rollback_delete_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
let $t= insert_rollback_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
}
--enable_query_log
delete from t1;
-- source include/start_mysqld.inc
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: delete from: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: delete from: grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # $format: delete from: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: delete from: grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
drop table t1;
-- echo #
-- echo # Test delete+rollback+delete
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
while ($numinserts)
let $formatno= $maxformatno;
while ($formatno)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
}
--enable_query_log
dec $formatno;
begin;
delete from t1;
rollback;
delete from t1;
let $t= delete_$formatno, delete_rollback_delete_$formatno, insert_rollback_$formatno;
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: delete rollback: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: delete rollback: grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # $format: delete rollback: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: delete rollback: grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
drop table t1;
-- echo #
-- echo # Test insert+rollback
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
begin;
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
}
--enable_query_log
rollback;
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
-- echo # $format: insert rollback: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: insert rollback: grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # $format: insert rollback: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # $format: insert rollback: grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
drop table t1;
eval check table $t;
eval drop table $t;
}
show variables like 'innodb_%scrub_data%';

View file

@ -1,13 +1,9 @@
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/not_windows.inc
let $MYSQLD_DATADIR=`select @@datadir`;
let ib1_IBD = $MYSQLD_DATADIR/ibdata1;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd;
let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd;
let INNODB_PAGE_SIZE= `select @@innodb_page_size`;
--echo #
--echo # immediate scrubbing is off
@ -18,80 +14,67 @@ show variables like 'innodb_%scrub_data%';
-- echo # make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
create table snapshot_status engine = myisam
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
let $rowcount=500;
let $formatno = 1;
let $maxformatno= 4;
let $formatno= $maxformatno;
let $tableformat= (
a int auto_increment primary key,
b varchar(256),
c text,
index(b)) engine = innodb row_format;
while ($formatno)
{
let $format = `select case $formatno
when 1 then 'dynamic'
when 2 then 'redundant'
when 3 then 'compact'
when 4 then 'compressed'
end`;
dec $formatno;
let $format = `select case $formatno
when 0 then 'dynamic'
when 1 then 'redundant'
when 2 then 'compact'
when 3 then 'compressed'
end`;
truncate table snapshot_status;
insert into snapshot_status
select * from information_schema.global_status
where variable_name like 'innodb_scrub%';
-- echo #
-- echo # Test delete of records
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=$format;
let $t= delete_$formatno;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('unicycle', repeat('wonderwoman', 1000));
}
commit;
--enable_query_log
delete from t1;
eval delete from $t;
-- echo #
-- echo # Test delete+rollback+delete
-- echo #
let $t= delete_rollback_delete_$formatno;
eval create table t2 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=$format;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
begin;
while ($numinserts)
{
dec $numinserts;
insert into t2(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('bicycle', repeat('repairman', 1000));
}
commit;
--enable_query_log
begin;
delete from t2;
eval delete from $t;
rollback;
delete from t2;
eval delete from $t;
-- echo #
-- echo # Test insert+rollback
-- echo #
let $t= insert_rollback_$formatno;
eval create table t3 (
a int auto_increment primary key,
b varchar(256),
c text, index(b)) engine = innodb row_format=$format;
eval create table $t $tableformat=$format;
let $numinserts = $rowcount;
-- echo # Populate table with rows
@ -100,11 +83,12 @@ begin;
while ($numinserts)
{
dec $numinserts;
insert into t3(b,c) values ('bicycle', repeat('repairman', 1000));
eval insert into $t(b,c) values ('tricycle', repeat('superhuman', 1000));
}
--enable_query_log
rollback;
}
-- echo # start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
@ -130,35 +114,57 @@ if (!$success)
-- die Timeout waiting for background threads
}
-- echo # Success!
-- echo # stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
SET GLOBAL innodb_fast_shutdown=0;
-- source include/shutdown_mysqld.inc
-- echo # restart mysqld so that all pages are flushed
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
-- enable_result_log
let SEARCH_ABORT= FOUND;
let SEARCH_PATTERN= (un|b|tr)icycle|(repair|breakhu|wonderwo)man;
let SEARCH_RANGE= 12582912;
let SEARCH_FILE= $MYSQLD_DATADIR/ibdata1;
-- echo # $format: delete: grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # $format: delete: grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
# We may randomly find copies of unscrubbed pages in the doublewrite buffer.
# Let us scrub the doublewrite buffer ourselves.
perl;
use Fcntl 'SEEK_SET';
my $page_size = $ENV{INNODB_PAGE_SIZE};
open(FILE, "+<", "$ENV{SEARCH_FILE}") or die "cannot open: $!\n";
seek(FILE, $page_size * 64, SEEK_SET) or die "cannot seek: $!\n";
print(FILE chr(0) x ($page_size * 128)) or die "cannot write: $!\n";
close FILE or die "cannot close: $!\n";;
EOF
-- echo # $format: delete rollback: grep -c bicycle t2.ibd
-- exec grep -c bicycle $t2_IBD || true
-- echo # $format: delete rollback: grep -c repairman t2.ibd
-- exec grep -c repairman $t2_IBD || true
-- source include/search_pattern_in_file.inc
-- echo # $format: insert rollback: grep -c bicycle t3.ibd
-- exec grep -c bicycle $t3_IBD || true
-- echo # $format: insert rollback: grep -c repairman t3.ibd
-- exec grep -c repairman $t3_IBD || true
let $formatno= $maxformatno;
while ($formatno)
{
dec $formatno;
drop table t1, t2, t3;
let $t= delete_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
let $t= delete_rollback_delete_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
let $t= insert_rollback_$formatno.ibd;
let SEARCH_FILE= $MYSQLD_DATADIR/test/$t;
-- echo # $t
-- source include/search_pattern_in_file.inc
}
-- source include/start_mysqld.inc
let $formatno= $maxformatno;
while ($formatno)
{
dec $formatno;
let $t= delete_$formatno, delete_rollback_delete_$formatno, insert_rollback_$formatno;
eval check table $t;
eval drop table $t;
}
show variables like 'innodb_%scrub_data%';
drop table snapshot_status;

View file

@ -1,9 +0,0 @@
--innodb-file-per-table=1
--innodb-file-format=Barracuda
--innodb-immediate-scrub-data-uncompressed=ON
--innodb-background-scrub-data-uncompressed=ON
--innodb-background-scrub-data-compressed=ON
--loose-innodb-debug-force-scrubbing=ON
--innodb-encrypt-tables=OFF
--innodb-encrypt-log=OFF
--innodb-tablespaces-scrubbing

View file

@ -1,161 +0,0 @@
-- source include/have_innodb.inc
-- source include/not_embedded.inc
-- source include/have_example_key_management_plugin.inc
-- source include/not_windows.inc
let $MYSQLD_DATADIR=`select @@datadir`;
let ib1_IBD = $MYSQLD_DATADIR/ibdata1;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;
let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd;
let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd;
let $rowcount=500;
-- echo # make sure spaces are checked quickly
SET GLOBAL innodb_background_scrub_data_check_interval=1;
-- echo #
-- echo # Test delete of records
-- echo #
eval create table t1 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t1(b,c) values ('bicycle', repeat('repairman', 1000));
}
--enable_query_log
delete from t1;
-- echo #
-- echo # Test delete+rollback+delete
-- echo #
eval create table t2 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
let $numinserts = $rowcount;
-- echo # Populate table with rows
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t2(b,c) values ('boondoggle', repeat('waste of time', 1000));
}
--enable_query_log
begin;
delete from t2;
rollback;
delete from t2;
-- echo #
-- echo # Test insert+rollback
-- echo #
eval create table t3 (
a int auto_increment primary key,
b varchar(256),
c text) engine = innodb row_format=compressed;
let $numinserts = $rowcount;
-- echo # Populate table with rows
begin;
--disable_query_log
while ($numinserts)
{
dec $numinserts;
insert into t3(b,c) values ('keso', repeat('kent', 1000));
}
--enable_query_log
rollback;
-- echo # start scrubbing threads
SET GLOBAL innodb_encryption_threads=5;
-- echo # Wait max 10 min for scrubbing of this table
let $cnt=600;
while ($cnt)
{
let $success=`SELECT COUNT(*) = 0
FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING
WHERE LAST_SCRUB_COMPLETED IS NULL AND ( NAME like 'test/%' OR SPACE = 0 )`;
if ($success)
{
let $cnt=0;
}
if (!$success)
{
real_sleep 1;
dec $cnt;
}
}
if (!$success)
{
SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING;
SHOW STATUS LIKE 'innodb_%scrub%';
-- die Timeout waiting for background threads
}
-- echo # Success!
-- echo # stop scrubbing threads
SET GLOBAL innodb_encryption_threads=0;
--echo # Now there should be background scrubs
let $success=`select sum(variable_value) > 0
from information_schema.global_status
where variable_name in ('innodb_scrub_background_page_reorganizations',
'innodb_scrub_background_page_splits')`;
if (!$success) {
show status like 'innodb_scrub%';
}
-- echo # restart mysqld so that all pages are flushed (encryption off)
-- echo # so that grep will find stuff
-- source include/restart_mysqld.inc
-- echo # read all rows from table
-- disable_result_log
select * from t1;
select * from t2;
select * from t3;
-- enable_result_log
-- echo # grep -c bicycle t1.ibd
-- exec grep -c bicycle $t1_IBD || true
-- echo # grep -c bicycle ibdata1
-- exec grep -c bicycle $ib1_IBD || true
-- echo # grep -c repairman t1.ibd
-- exec grep -c repairman $t1_IBD || true
-- echo # grep -c repairman ibdata1
-- exec grep -c repairman $ib1_IBD || true
-- echo # grep -c boondoggle t2.ibd
-- exec grep -c boondoggle $t2_IBD || true
-- echo # grep -c boondoggle ibdata1
-- exec grep -c boondoggle $ib1_IBD || true
-- echo # grep -c waste t2.ibd
-- exec grep -c waste $t2_IBD || true
-- echo # grep -c waste ibdata1
-- exec grep -c waste $ib1_IBD || true
-- echo # grep -c keso t3.ibd
-- exec grep -c keso $t3_IBD || true
-- echo # grep -c keso ibdata1
-- exec grep -c keso $ib1_IBD || true
-- echo # grep -c kent t3.ibd
-- exec grep -c kent $t3_IBD || true
-- echo # grep -c kent ibdata1
-- exec grep -c kent $ib1_IBD || true
drop table t1, t2, t3;

View file

@ -4,6 +4,7 @@ CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
SET GLOBAL wsrep_provider_options='gmcast.isolate=1';
SET SESSION wsrep_on = OFF;
SET SESSION wsrep_on = ON;
SET global wsrep_sync_wait=0;
connection node_3;
START SLAVE;
include/wait_for_slave_param.inc [Slave_IO_Running]
@ -16,6 +17,7 @@ INSERT INTO t1 VALUES (1);
connection node_3;
connection node_1;
DROP TABLE t1;
SET global wsrep_sync_wait=7;
connection node_3;
STOP SLAVE;
RESET SLAVE ALL;

View file

@ -21,6 +21,15 @@ Variable_name Value
wsrep_cluster_status non-Primary
SELECT * FROM t1;
ERROR 08S01: WSREP has not yet prepared node for application use
SELECT @@wsrep_dirty_reads;
@@wsrep_dirty_reads
0
SELECT 2;
2
2
SELECT 2+2 FROM DUAL;
2+2
4
SET @@session.wsrep_dirty_reads=ON;
SELECT * FROM t1;
i

View file

@ -11,12 +11,16 @@
--enable_query_log
--connection node_1
--let $wsrep_sync_wait_state= `SELECT @@global.wsrep_sync_wait;`
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
SET GLOBAL wsrep_provider_options='gmcast.isolate=1';
SET SESSION wsrep_on = OFF;
--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'
--source include/wait_condition.inc
SET SESSION wsrep_on = ON;
#wsrep_sync_wait is set to zero because when slave tries to connect it it ask for queries like SELECT UNIX_TIMESTAMP() on node 1 which will fail, causing
#a warning in slave error log.
SET global wsrep_sync_wait=0;
--connection node_3
START SLAVE;
@ -47,6 +51,7 @@ INSERT INTO t1 VALUES (1);
--connection node_1
DROP TABLE t1;
--eval SET global wsrep_sync_wait=$wsrep_sync_wait_state
--connection node_3
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'
--source include/wait_condition.inc

View file

@ -37,6 +37,11 @@ SHOW STATUS LIKE 'wsrep_cluster_status';
--error ER_UNKNOWN_COM_ERROR
SELECT * FROM t1;
#Select query which does not access table should be allowed MDEV-11016
SELECT @@wsrep_dirty_reads;
SELECT 2;
SELECT 2+2 FROM DUAL;
SET @@session.wsrep_dirty_reads=ON;
SELECT * FROM t1;

View file

@ -30,15 +30,14 @@ x
x
x
connect con1,localhost,root,,;
connection con1;
BEGIN;
DELETE FROM t1 WHERE a=1;
INSERT INTO t1 VALUES(1,'X',1);
SET DEBUG='+d,crash_after_log_ibuf_upd_inplace';
Warnings:
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
SET DEBUG_DBUG='+d,crash_after_log_ibuf_upd_inplace';
SELECT b FROM t1 LIMIT 3;
ERROR HY000: Lost connection to MySQL server during query
disconnect con1;
connection default;
FOUND /Wrote log record for ibuf update in place operation/ in my_restart.err
CHECK TABLE t1;
Table Op Msg_type Msg_text

View file

@ -0,0 +1,8 @@
SET GLOBAL innodb_file_per_table=0;
CREATE TABLE t(a INT)ENGINE=InnoDB;
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE ibd4(a INT UNIQUE)ENGINE=InnoDB;
CREATE TABLE ibd4f(a INT UNIQUE)ENGINE=InnoDB;
CREATE TABLE ibd5(a INT UNIQUE, b INT UNIQUE)ENGINE=InnoDB;
# Kill the server
DROP TABLE t,ibd4,ibd4f,ibd5;

View file

@ -17,6 +17,9 @@ CREATE TABLE t1(
INDEX(b))
ENGINE=InnoDB STATS_PERSISTENT=0;
--let $_server_id= `SELECT @@server_id`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
# The flag innodb_change_buffering_debug is only available in debug builds.
# It instructs InnoDB to try to evict pages from the buffer pool when
# change buffering is possible, so that the change buffer will be used
@ -46,27 +49,22 @@ BEGIN;
SELECT b FROM t1 LIMIT 3;
connect (con1,localhost,root,,);
connection con1;
BEGIN;
DELETE FROM t1 WHERE a=1;
# This should be buffered, if innodb_change_buffering_debug = 1 is in effect.
INSERT INTO t1 VALUES(1,'X',1);
SET DEBUG='+d,crash_after_log_ibuf_upd_inplace';
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET DEBUG_DBUG='+d,crash_after_log_ibuf_upd_inplace';
--exec echo "wait" > $_expect_file_name
--error 2013
# This should force a change buffer merge
SELECT b FROM t1 LIMIT 3;
disconnect con1;
connection default;
let SEARCH_PATTERN=Wrote log record for ibuf update in place operation;
--source include/search_pattern_in_file.inc
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/start_mysqld.inc
CHECK TABLE t1;
# Cleanup
DROP TABLE t1;

View file

@ -0,0 +1,2 @@
--loose-innodb-sys-indexes
--innodb-data-file-path=ibdata1:1M:autoextend

View file

@ -0,0 +1,62 @@
--source include/have_innodb.inc
--source include/not_embedded.inc
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let MYSQLD_DATADIR=`select @@datadir`;
let MYSQLD_IS_DEBUG=`select version() like '%debug%'`;
--source include/no_checkpoint_start.inc
SET GLOBAL innodb_file_per_table=0;
CREATE TABLE t(a INT)ENGINE=InnoDB;
let INNODB_ROOT_PAGE= `SELECT page_no FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE name='GEN_CLUST_INDEX'`;
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE ibd4(a INT UNIQUE)ENGINE=InnoDB;
CREATE TABLE ibd4f(a INT UNIQUE)ENGINE=InnoDB;
CREATE TABLE ibd5(a INT UNIQUE, b INT UNIQUE)ENGINE=InnoDB;
let $drop_tables= DROP TABLE t,ibd4,ibd4f,ibd5;
--let CLEANUP_IF_CHECKPOINT= $drop_tables;
--source ../include/no_checkpoint_end.inc
perl;
use Fcntl 'SEEK_CUR', 'SEEK_END';
my $page_size = $ENV{'INNODB_PAGE_SIZE'};
my $restart;
if ($ENV{'MYSQLD_IS_DEBUG'})
{
# It is impractical to ensure that CREATE TABLE t will extend ibdata1.
# We rely on innodb_system_tablespace_extend_debug=1
# to recover from this fault injection if no size change was redo-logged.
my $root = $ENV{'INNODB_ROOT_PAGE'};
open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}ibdata1") or die;
my $size = sysseek(FILE, 0, SEEK_END) / $page_size;
seek(FILE, $page_size * ($root + 1), SEEK_SET) or die;
my $empty_tail= 1;
while(<FILE>) { unless (/\0*/gso) { $empty_tail= 0; last } }
if ($empty_tail)
{
$restart = "--innodb-data-file-size-debug=$size";
truncate(FILE, $page_size * $root);
}
close FILE;
}
open(FILE, ">$ENV{MYSQLTEST_VARDIR}/log/start_mysqld.txt") || die;
print FILE "--let \$restart_parameters=$restart\n" if $restart;
print FILE "--source include/start_mysqld.inc\n";
close FILE;
open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd4.ibd") or die;
truncate(FILE, $page_size * 4);
close FILE;
open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd4f.ibd") or die;
truncate(FILE, $page_size * 4 + 1234);
close FILE;
open(FILE, "+<", "$ENV{'MYSQLD_DATADIR'}test/ibd5.ibd") or die;
truncate(FILE, $page_size * 5);
close FILE;
EOF
--source $MYSQLTEST_VARDIR/log/start_mysqld.txt
--remove_file $MYSQLTEST_VARDIR/log/start_mysqld.txt
eval $drop_tables;

View file

@ -163,9 +163,9 @@ foreach (glob("$ENV{MYSQLD_DATADIR}/*/*.ibd")) {
}
EOF
let $restart_parameters = restart: --innodb_checksum_algorithm=strict_none --default_storage_engine=InnoDB;
--let $restart_parameters = --innodb_checksum_algorithm=strict_none --default_storage_engine=InnoDB
--source include/start_mysqld.inc
--let $restart_parameters=
# check the table status is GOOD with DML
INSERT INTO tab1 (pk, linestring_key, linestring_nokey)
VALUES (4, ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '), ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '));

View file

@ -15,6 +15,7 @@ optimize table mysql.proxies_priv;
optimize table mysql.tables_priv;
optimize table mysql.procs_priv;
optimize table mysql.servers;
optimize table mysql.roles_mapping;
update performance_schema.setup_consumers set enabled='YES';
update performance_schema.setup_objects set enabled='YES'
where object_type='TABLE' and object_schema= 'mysql';

View file

@ -24,6 +24,7 @@ optimize table mysql.proxies_priv;
optimize table mysql.tables_priv;
optimize table mysql.procs_priv;
optimize table mysql.servers;
optimize table mysql.roles_mapping;
--enable_result_log
# Start recording events

View file

@ -0,0 +1,203 @@
include/master-slave.inc
[connection master]
connection master;
create table t1(a int primary key);
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
connection slave;
select * from t1 order by a;
a
1
2
3
4
alter table t1 add column z1 int as(a+1) virtual, add column z2 int as (a+2) persistent;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
connection master;
insert into t1 values(5);
insert into t1 values(6);
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
#UPDATE query
connection master;
update t1 set a = a+10;
select * from t1 order by a;
a
11
12
13
14
15
16
connection slave;
select * from t1 order by a;
a z1 z2
11 12 13
12 13 14
13 14 15
14 15 16
15 16 17
16 17 18
connection master;
update t1 set a = a-10;
select * from t1 order by a;
a
1
2
3
4
5
6
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
#DELETE quert
connection master;
delete from t1 where a > 2 and a < 4;
select * from t1 order by a;
a
1
2
4
5
6
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
4 5 6
5 6 7
6 7 8
#REPLACE query
connection master;
replace into t1 values(1);
replace into t1 values(3);
replace into t1 values(1);
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
#SELECT query
connection master;
select * from t1 where a > 2 and a < 4;
a
3
connection slave;
select * from t1 where a > 2 and a < 4;
a z1 z2
3 4 5
#UPDATE with SELECT query
connection master;
update t1 set a = a + 10 where a > 2 and a < 4;
select * from t1 order by a;
a
1
2
4
5
6
13
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
4 5 6
5 6 7
6 7 8
13 14 15
connection master;
update t1 set a = a - 10 where a = 13;
select * from t1 order by a;
a
1
2
3
4
5
6
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
#Break Unique Constraint
alter table t1 add column z4 int as (a % 6) persistent unique;
connection master;
#entering duplicate value for slave persistent column
insert into t1 values(7);
select * from t1 order by a;
a
1
2
3
4
5
6
7
connection slave;
include/wait_for_slave_sql_error.inc [errno=1062]
select * from t1 order by a;
a z1 z2 z4
1 2 3 1
2 3 4 2
3 4 5 3
4 5 6 4
5 6 7 5
6 7 8 0
alter table t1 drop column z4;
start slave;
include/wait_for_slave_sql_to_start.inc
connection master;
connection slave;
select * from t1 order by a;
a z1 z2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
connection master;
select * from t1 order by a;
a
1
2
3
4
5
6
7
drop table t1;
include/rpl_end.inc

View file

@ -8,6 +8,7 @@ include/stop_slave.inc
Master_Log_File = 'master-bin.000001'
Using_Gtid = 'No'
CHANGE MASTER TO master_use_gtid=current_pos;
FLUSH LOGS;
connection server_1;
FLUSH LOGS;
include/wait_for_purge.inc "master-bin.000002"
@ -55,6 +56,7 @@ INSERT INTO t1 VALUES(5);
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -87,6 +89,7 @@ a
connection server_1;
INSERT INTO t1 VALUES (7);
connection server_2;
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -116,6 +119,7 @@ include/start_slave.inc
connection server_1;
INSERT INTO t1 VALUES (8);
connection server_2;
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -142,6 +146,7 @@ Error 1286 Unknown storage engine 'InnoDB'
connection server_1;
INSERT INTO t1 VALUES (9);
connection server_2;
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -171,6 +176,7 @@ domain_id COUNT(*)
connection server_1;
INSERT INTO t1 VALUES (11);
connection server_2;
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;
domain_id COUNT(*)
0 2
@ -180,6 +186,7 @@ connection server_1;
INSERT INTO t1 VALUES (12);
INSERT INTO t1 VALUES (13);
connection server_2;
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;
domain_id COUNT(*)
0 2

View file

@ -14,6 +14,7 @@ connection slave;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
include/start_slave.inc
include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1;
a
1
@ -27,6 +28,7 @@ connection slave;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
include/start_slave.inc
include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -41,6 +43,7 @@ connection slave;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
include/start_slave.inc
include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -56,6 +59,7 @@ connection slave;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
include/start_slave.inc
include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1
@ -72,6 +76,7 @@ connection slave;
CHANGE MASTER TO master_host='127.0.0.1', master_port=SERVER_MYPORT_1;
include/start_slave.inc
include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
a
1

View file

@ -2,9 +2,12 @@ include/master-slave.inc
[connection master]
call mtr.add_suppression("Unsafe statement written to the binary log");
CREATE TABLE t1 (a int);
connection slave;
connection master;
INSERT INTO t1 VALUES(SLEEP(2));
connection slave;
Seconds_Behind_Master: 1
Seconds_Behind_Master_is_less_than_100
1
connection master;
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave

View file

@ -0,0 +1,106 @@
--source include/master-slave.inc
--source include/have_binlog_format_row.inc
--enable_connect_log
--connection master
create table t1(a int primary key);
insert into t1 values(1);
insert into t1 values(2);
insert into t1 values(3);
insert into t1 values(4);
--sync_slave_with_master
select * from t1 order by a;
alter table t1 add column z1 int as(a+1) virtual, add column z2 int as (a+2) persistent;
select * from t1 order by a;
--connection master
insert into t1 values(5);
insert into t1 values(6);
--sync_slave_with_master
select * from t1 order by a;
--echo #UPDATE query
--connection master
update t1 set a = a+10;
select * from t1 order by a;
--sync_slave_with_master
select * from t1 order by a;
--connection master
update t1 set a = a-10;
select * from t1 order by a;
--sync_slave_with_master
select * from t1 order by a;
--echo #DELETE quert
--connection master
delete from t1 where a > 2 and a < 4;
select * from t1 order by a;
--sync_slave_with_master
select * from t1 order by a;
--echo #REPLACE query
--connection master
replace into t1 values(1);
replace into t1 values(3);
replace into t1 values(1);
--sync_slave_with_master
select * from t1 order by a;
--echo #SELECT query
--connection master
select * from t1 where a > 2 and a < 4;
--connection slave
select * from t1 where a > 2 and a < 4;
--echo #UPDATE with SELECT query
--connection master
update t1 set a = a + 10 where a > 2 and a < 4;
select * from t1 order by a;
--sync_slave_with_master
select * from t1 order by a;
--connection master
update t1 set a = a - 10 where a = 13;
select * from t1 order by a;
--sync_slave_with_master
select * from t1 order by a;
--echo #Break Unique Constraint
alter table t1 add column z4 int as (a % 6) persistent unique;
--connection master
--echo #entering duplicate value for slave persistent column
insert into t1 values(7);
select * from t1 order by a;
--connection slave
--let $slave_sql_errno= 1062
--source include/wait_for_slave_sql_error.inc
select * from t1 order by a;
alter table t1 drop column z4;
start slave;
--source include/wait_for_slave_sql_to_start.inc
--connection master
--sync_slave_with_master
select * from t1 order by a;
--connection master
select * from t1 order by a;
drop table t1;
--source include/rpl_end.inc

View file

@ -28,6 +28,7 @@ CHANGE MASTER TO master_use_gtid=current_pos;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
FLUSH LOGS;
--shutdown_server 30
--source include/wait_until_disconnected.inc
@ -92,6 +93,7 @@ INSERT INTO t1 VALUES(5);
--connection server_2
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--echo *** Test that @@gtid_slave_pos and @@gtid_current_pos are correctly loaded even if slave threads have not started. ***
@ -136,6 +138,7 @@ INSERT INTO t1 VALUES (7);
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
# Now we restart the slave server. When it restarts, there is nothing new
@ -177,6 +180,7 @@ INSERT INTO t1 VALUES (8);
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--source include/stop_slave.inc
@ -210,6 +214,7 @@ INSERT INTO t1 VALUES (9);
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
# Put things back as they were.
@ -248,6 +253,7 @@ INSERT INTO t1 VALUES (11);
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
@ -270,6 +276,7 @@ INSERT INTO t1 VALUES (13);
--connection server_2
--sync_with_master
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id;

View file

@ -29,6 +29,7 @@ INSERT INTO t1 VALUES (1);
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1;
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1;
--source include/stop_slave.inc
@ -54,6 +55,7 @@ INSERT INTO t1 VALUES (2);
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1;
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--source include/stop_slave.inc
@ -79,6 +81,7 @@ INSERT INTO t1 VALUES (3);
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1;
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--source include/stop_slave.inc
@ -104,6 +107,7 @@ INSERT INTO t1 VALUES (4);
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1;
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--source include/stop_slave.inc
@ -129,6 +133,7 @@ INSERT INTO t1 VALUES (5);
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1;
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
FLUSH NO_WRITE_TO_BINLOG TABLES;
SELECT * FROM t1 ORDER BY a;
--source include/stop_slave.inc

View file

@ -3,24 +3,60 @@ source include/have_binlog_format_statement.inc;
call mtr.add_suppression("Unsafe statement written to the binary log");
# Make sure that the start time of the first event is certainly different
# from the next event
--let $timestamp= `SELECT @@timestamp`
--disable_query_log
eval SET TIMESTAMP= $timestamp-100;
--enable_query_log
CREATE TABLE t1 (a int);
# Make sure that the slave is done with the first event, and all checks
# that we'll perform later will be really against the second event
sync_slave_with_master;
connection master;
# Restore the timestamp now. It doesn't matter that it's not precise,
# it just needs to be very different from the earlier event
--disable_query_log
eval SET TIMESTAMP= $timestamp;
--enable_query_log
send INSERT INTO t1 VALUES(SLEEP(2));
connection slave;
let $run = 10;
# When the slave starts executing the event, Seconds_Behind_Master
# should start growing steadilly. The bugfix ensures that they are
# calculated based on the start time of the current event, rather
# than the start time of the previous event. To check it, we only need
# the first non-zero value
let $run = 20;
while ($run)
{
dec $run;
let $sbm=query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1);
# for debugging uncomment echo and remove the if()
#echo Seconds_Behind_Master: $sbm;
# echo Seconds_Behind_Master: $sbm;
if ($sbm)
{
let $run = 0;
}
sleep 0.5;
}
echo Seconds_Behind_Master: $sbm;
# Normally the first non-zero value should be 1. However, due to race
# conditions on slow servers, sometimes the check might miss the value 1,
# and only catch a higher one. It does not matter, we just need to make
# sure it didn't start with 100+, as it would have with bug MDEV-5114
--disable_query_log
eval SELECT $sbm > 0 and $sbm < 99 AS Seconds_Behind_Master_is_less_than_100;
--enable_query_log
connection master;
reap;
drop table t1;

View file

@ -1,3 +1,4 @@
call mtr.add_suppression("InnoDB: Failed to set NUMA memory policy");
SELECT @@GLOBAL.innodb_numa_interleave;
@@GLOBAL.innodb_numa_interleave
1

View file

@ -43,14 +43,40 @@ set global innodb_spin_wait_delay=0;
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
0
set global innodb_spin_wait_delay=5000;
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
5000
set global innodb_spin_wait_delay=65535;
Warnings:
Warning 1292 Truncated incorrect innodb_spin_wait_delay value: '65535'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
65535
6000
set global innodb_spin_wait_delay=4294967295;
Warnings:
Warning 1292 Truncated incorrect innodb_spin_wait_delay value: '4294967295'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
4294967295
6000
set @@global.innodb_spin_wait_delay = 4294967296;
Warnings:
Warning 1292 Truncated incorrect innodb_spin_wait_delay value: '4294967296'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
6000
set @@global.innodb_spin_wait_delay = 12345678901;
Warnings:
Warning 1292 Truncated incorrect innodb_spin_wait_delay value: '12345678901'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
6000
set @@global.innodb_spin_wait_delay = 18446744073709551615;
Warnings:
Warning 1292 Truncated incorrect innodb_spin_wait_delay value: '18446744073709551615'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
6000
set global innodb_spin_wait_delay=1.1;
ERROR 42000: Incorrect argument type to variable 'innodb_spin_wait_delay'
set global innodb_spin_wait_delay=1e1;
@ -61,12 +87,12 @@ set global innodb_spin_wait_delay=' ';
ERROR 42000: Incorrect argument type to variable 'innodb_spin_wait_delay'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
4294967295
6000
set global innodb_spin_wait_delay=" ";
ERROR 42000: Incorrect argument type to variable 'innodb_spin_wait_delay'
select @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay
4294967295
6000
set global innodb_spin_wait_delay=-7;
Warnings:
Warning 1292 Truncated incorrect innodb_spin_wait_delay value: '-7'
@ -82,18 +108,6 @@ select @@global.innodb_spin_wait_delay;
select * from information_schema.global_variables where variable_name='innodb_spin_wait_delay';
VARIABLE_NAME VARIABLE_VALUE
INNODB_SPIN_WAIT_DELAY 0
SET @@global.innodb_spin_wait_delay = 4294967296;
SELECT @@global.innodb_spin_wait_delay IN (4294967296,4294967295);
@@global.innodb_spin_wait_delay IN (4294967296,4294967295)
1
SET @@global.innodb_spin_wait_delay = 12345678901;
SELECT @@global.innodb_spin_wait_delay IN (12345678901,4294967295);
@@global.innodb_spin_wait_delay IN (12345678901,4294967295)
1
SET @@global.innodb_spin_wait_delay = 18446744073709551615;
SELECT @@global.innodb_spin_wait_delay IN (18446744073709551615,4294967295);
@@global.innodb_spin_wait_delay IN (18446744073709551615,4294967295)
1
SET @@global.innodb_spin_wait_delay = @start_global_value;
SELECT @@global.innodb_spin_wait_delay;
@@global.innodb_spin_wait_delay

View file

@ -1,20 +1,20 @@
select @@global.innodb_use_atomic_writes;
@@global.innodb_use_atomic_writes
0
1
select @@session.innodb_use_atomic_writes;
ERROR HY000: Variable 'innodb_use_atomic_writes' is a GLOBAL variable
show global variables like 'innodb_use_atomic_writes';
Variable_name Value
innodb_use_atomic_writes OFF
innodb_use_atomic_writes ON
show session variables like 'innodb_use_atomic_writes';
Variable_name Value
innodb_use_atomic_writes OFF
innodb_use_atomic_writes ON
select * from information_schema.global_variables where variable_name='innodb_use_atomic_writes';
VARIABLE_NAME VARIABLE_VALUE
INNODB_USE_ATOMIC_WRITES OFF
INNODB_USE_ATOMIC_WRITES ON
select * from information_schema.session_variables where variable_name='innodb_use_atomic_writes';
VARIABLE_NAME VARIABLE_VALUE
INNODB_USE_ATOMIC_WRITES OFF
INNODB_USE_ATOMIC_WRITES ON
set global innodb_use_atomic_writes=1;
ERROR HY000: Variable 'innodb_use_atomic_writes' is a read only variable
set session innodb_use_atomic_writes=1;

View file

@ -1,5 +1,5 @@
--- r/sysvars_innodb.result
+++ r/sysvars_innodb,32bit.result~
--- ./suite/sys_vars/r/sysvars_innodb.result 2017-01-03 12:06:25.401683053 +0200
+++ ./suite/sys_vars/r/sysvars_innodb,32bit.reject 2017-01-04 18:26:46.741752657 +0200
@@ -53,7 +53,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 8
@ -103,7 +103,7 @@
VARIABLE_COMMENT Helps in performance tuning in heavily concurrent environments.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1000
@@ -543,7 +543,7 @@
@@ -557,7 +557,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 5
VARIABLE_SCOPE GLOBAL
@ -112,7 +112,7 @@
VARIABLE_COMMENT If the compression failure rate of a table is greater than this number more padding is added to the pages to reduce the failures. A value of zero implies no padding
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 100
@@ -571,7 +571,7 @@
@@ -585,7 +585,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 50
VARIABLE_SCOPE GLOBAL
@ -121,7 +121,7 @@
VARIABLE_COMMENT Percentage of empty space on a data page that can be reserved to make the page compressible.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 75
@@ -599,10 +599,10 @@
@@ -613,10 +613,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 5000
VARIABLE_SCOPE GLOBAL
@ -134,7 +134,16 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -837,7 +837,7 @@
@@ -641,7 +641,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT InnoDB system tablespace size to be set in recovery.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -865,7 +865,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 120
VARIABLE_SCOPE GLOBAL
@ -143,7 +152,7 @@
VARIABLE_COMMENT Number of pages reserved in doublewrite buffer for batch flushing
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 127
@@ -921,7 +921,7 @@
@@ -949,7 +949,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
@ -152,7 +161,7 @@
VARIABLE_COMMENT Speeds up the shutdown process of the InnoDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like).
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 2
@@ -935,7 +935,7 @@
@@ -963,7 +963,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 600
VARIABLE_SCOPE GLOBAL
@ -161,7 +170,7 @@
VARIABLE_COMMENT Maximum number of seconds that semaphore times out in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 4294967295
@@ -1005,7 +1005,7 @@
@@ -1033,7 +1033,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 100
VARIABLE_SCOPE GLOBAL
@ -170,7 +179,7 @@
VARIABLE_COMMENT Percentage of B-tree page filled during bulk insert
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 100
@@ -1019,7 +1019,7 @@
@@ -1047,7 +1047,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -179,7 +188,7 @@
VARIABLE_COMMENT Make the first page of the given tablespace dirty.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -1033,7 +1033,7 @@
@@ -1061,7 +1061,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 30
VARIABLE_SCOPE GLOBAL
@ -188,7 +197,7 @@
VARIABLE_COMMENT Number of iterations over which the background flushing is averaged.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1000
@@ -1061,7 +1061,7 @@
@@ -1089,7 +1089,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
@ -197,7 +206,7 @@
VARIABLE_COMMENT Controls the durability/speed trade-off for commits. Set to 0 (write and flush redo log to disk only once per second), 1 (flush to disk at each commit), 2 (write to log at commit but flush to disk only once per second) or 3 (flush to disk at prepare and at commit, slower and usually redundant). 1 and 3 guarantees that after a crash, committed transactions will not be lost and will be consistent with the binlog and other transactional engines. 2 can get inconsistent and lose transactions if there is a power failure or kernel crash but not if mysqld crashes. 0 has no guarantees in case of crash. 0 and 2 can be faster than 1 or 3.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 3
@@ -1089,7 +1089,7 @@
@@ -1117,7 +1117,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
@ -206,7 +215,7 @@
VARIABLE_COMMENT Set to 0 (don't flush neighbors from buffer pool), 1 (flush contiguous neighbors from buffer pool) or 2 (flush neighbors from buffer pool), when flushing a block
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 2
@@ -1145,7 +1145,7 @@
@@ -1173,7 +1173,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -215,7 +224,7 @@
VARIABLE_COMMENT Helps to save your data in case the disk image of the database becomes corrupt.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 6
@@ -1159,7 +1159,7 @@
@@ -1187,7 +1187,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -224,7 +233,7 @@
VARIABLE_COMMENT Kills the server during crash recovery.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 100
@@ -1187,7 +1187,7 @@
@@ -1215,7 +1215,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 8000000
VARIABLE_SCOPE GLOBAL
@ -233,7 +242,7 @@
VARIABLE_COMMENT InnoDB Fulltext search cache size in bytes
NUMERIC_MIN_VALUE 1600000
NUMERIC_MAX_VALUE 80000000
@@ -1229,7 +1229,7 @@
@@ -1257,7 +1257,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 84
VARIABLE_SCOPE GLOBAL
@ -242,7 +251,7 @@
VARIABLE_COMMENT InnoDB Fulltext search maximum token size in characters
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 84
@@ -1243,7 +1243,7 @@
@@ -1271,7 +1271,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 3
VARIABLE_SCOPE GLOBAL
@ -251,7 +260,7 @@
VARIABLE_COMMENT InnoDB Fulltext search minimum token size in characters
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 16
@@ -1257,7 +1257,7 @@
@@ -1285,7 +1285,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 2000
VARIABLE_SCOPE GLOBAL
@ -260,7 +269,7 @@
VARIABLE_COMMENT InnoDB Fulltext search number of words to optimize for each optimize table call
NUMERIC_MIN_VALUE 1000
NUMERIC_MAX_VALUE 10000
@@ -1271,7 +1271,7 @@
@@ -1299,7 +1299,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 2000000000
VARIABLE_SCOPE GLOBAL
@ -269,7 +278,7 @@
VARIABLE_COMMENT InnoDB Fulltext search query result cache limit in bytes
NUMERIC_MIN_VALUE 1000000
NUMERIC_MAX_VALUE 4294967295
@@ -1299,7 +1299,7 @@
@@ -1327,7 +1327,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 2
VARIABLE_SCOPE GLOBAL
@ -278,7 +287,7 @@
VARIABLE_COMMENT InnoDB Fulltext search parallel sort degree, will round up to nearest power of 2 number
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 16
@@ -1313,7 +1313,7 @@
@@ -1341,7 +1341,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 640000000
VARIABLE_SCOPE GLOBAL
@ -287,7 +296,7 @@
VARIABLE_COMMENT Total memory allocated for InnoDB Fulltext Search cache
NUMERIC_MIN_VALUE 32000000
NUMERIC_MAX_VALUE 1600000000
@@ -1341,7 +1341,7 @@
@@ -1369,7 +1369,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 100
VARIABLE_SCOPE GLOBAL
@ -296,7 +305,7 @@
VARIABLE_COMMENT Up to what percentage of dirty pages should be flushed when innodb finds it has spare resources to do so.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 100
@@ -1383,10 +1383,10 @@
@@ -1411,10 +1411,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 200
VARIABLE_SCOPE GLOBAL
@ -309,7 +318,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -1395,12 +1395,12 @@
@@ -1423,12 +1423,12 @@
SESSION_VALUE NULL
GLOBAL_VALUE 2000
GLOBAL_VALUE_ORIGIN COMPILE-TIME
@ -325,7 +334,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -1453,7 +1453,7 @@
@@ -1495,7 +1495,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 50
VARIABLE_SCOPE SESSION
@ -334,7 +343,7 @@
VARIABLE_COMMENT Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1073741824
@@ -1467,10 +1467,10 @@
@@ -1509,10 +1509,10 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 16777216
VARIABLE_SCOPE GLOBAL
@ -347,7 +356,7 @@
NUMERIC_BLOCK_SIZE 1024
ENUM_VALUE_LIST NULL
READ_ONLY YES
@@ -1523,7 +1523,7 @@
@@ -1565,7 +1565,7 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 2
VARIABLE_SCOPE GLOBAL
@ -356,7 +365,7 @@
VARIABLE_COMMENT Number of log files in the log group. InnoDB writes to the files in a circular fashion.
NUMERIC_MIN_VALUE 2
NUMERIC_MAX_VALUE 100
@@ -1565,7 +1565,7 @@
@@ -1607,7 +1607,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 8192
VARIABLE_SCOPE GLOBAL
@ -365,7 +374,7 @@
VARIABLE_COMMENT Redo log write ahead unit size to avoid read-on-write, it should match the OS cache block IO size
NUMERIC_MIN_VALUE 512
NUMERIC_MAX_VALUE 16384
@@ -1579,10 +1579,10 @@
@@ -1621,10 +1621,10 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 1024
VARIABLE_SCOPE GLOBAL
@ -378,7 +387,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -1635,10 +1635,10 @@
@@ -1677,10 +1677,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -391,7 +400,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -1649,7 +1649,7 @@
@@ -1691,7 +1691,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -400,7 +409,7 @@
VARIABLE_COMMENT Maximum delay of user threads in micro-seconds
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 10000000
@@ -1747,7 +1747,7 @@
@@ -1789,7 +1789,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 8
VARIABLE_SCOPE GLOBAL
@ -409,7 +418,7 @@
VARIABLE_COMMENT Number of multi-threaded flush threads
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
@@ -1803,10 +1803,10 @@
@@ -1845,10 +1845,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -422,7 +431,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY YES
@@ -1831,7 +1831,7 @@
@@ -1873,7 +1873,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
@ -431,7 +440,7 @@
VARIABLE_COMMENT Page cleaner threads can be from 1 to 64. Default is 4.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
@@ -1859,7 +1859,7 @@
@@ -1901,7 +1901,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 16
VARIABLE_SCOPE GLOBAL
@ -440,7 +449,7 @@
VARIABLE_COMMENT Number of rw_locks protecting buffer pool page_hash. Rounded up to the next power of 2
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1024
@@ -1873,7 +1873,7 @@
@@ -1915,7 +1915,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 16384
VARIABLE_SCOPE GLOBAL
@ -449,7 +458,7 @@
VARIABLE_COMMENT Page size to use for all InnoDB tablespaces.
NUMERIC_MIN_VALUE 4096
NUMERIC_MAX_VALUE 65536
@@ -1915,7 +1915,7 @@
@@ -1957,7 +1957,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 300
VARIABLE_SCOPE GLOBAL
@ -458,7 +467,7 @@
VARIABLE_COMMENT Number of UNDO log pages to purge in one batch from the history list.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 5000
@@ -1929,7 +1929,7 @@
@@ -1971,7 +1971,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 128
VARIABLE_SCOPE GLOBAL
@ -467,7 +476,7 @@
VARIABLE_COMMENT Dictates rate at which UNDO records are purged. Value N means purge rollback segment(s) on every Nth iteration of purge invocation
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 128
@@ -1971,7 +1971,7 @@
@@ -2013,7 +2013,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
@ -476,7 +485,7 @@
VARIABLE_COMMENT Purge threads can be from 1 to 32. Default is 4.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 32
@@ -1999,7 +1999,7 @@
@@ -2041,7 +2041,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 56
VARIABLE_SCOPE GLOBAL
@ -485,7 +494,7 @@
VARIABLE_COMMENT Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 64
@@ -2013,7 +2013,7 @@
@@ -2055,7 +2055,7 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
@ -494,7 +503,7 @@
VARIABLE_COMMENT Number of background read I/O threads in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
@@ -2041,10 +2041,10 @@
@@ -2083,10 +2083,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -507,7 +516,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -2069,7 +2069,7 @@
@@ -2111,7 +2111,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 128
VARIABLE_SCOPE GLOBAL
@ -516,7 +525,7 @@
VARIABLE_COMMENT Number of undo logs to use (deprecated).
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 128
@@ -2083,7 +2083,7 @@
@@ -2125,7 +2125,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -525,7 +534,7 @@
VARIABLE_COMMENT An InnoDB page number.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
@@ -2139,7 +2139,7 @@
@@ -2181,7 +2181,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1048576
VARIABLE_SCOPE GLOBAL
@ -534,7 +543,7 @@
VARIABLE_COMMENT Memory buffer size for index creation
NUMERIC_MIN_VALUE 65536
NUMERIC_MAX_VALUE 67108864
@@ -2153,10 +2153,10 @@
@@ -2195,10 +2195,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 6
VARIABLE_SCOPE GLOBAL
@ -547,7 +556,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -2349,7 +2349,7 @@
@@ -2391,7 +2391,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 1
VARIABLE_SCOPE GLOBAL
@ -556,7 +565,7 @@
VARIABLE_COMMENT Size of the mutex/lock wait array.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 1024
@@ -2377,10 +2377,10 @@
@@ -2419,10 +2419,10 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 30
VARIABLE_SCOPE GLOBAL
@ -569,7 +578,7 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -2419,7 +2419,7 @@
@@ -2461,7 +2461,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -578,7 +587,7 @@
VARIABLE_COMMENT Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1000
@@ -2433,7 +2433,7 @@
@@ -2475,7 +2475,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 10000
VARIABLE_SCOPE GLOBAL
@ -587,7 +596,7 @@
VARIABLE_COMMENT Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a sleep
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 1000000
@@ -2503,7 +2503,7 @@
@@ -2545,7 +2545,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 128
VARIABLE_SCOPE GLOBAL
@ -596,7 +605,7 @@
VARIABLE_COMMENT Number of undo logs to use.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 128
@@ -2531,7 +2531,7 @@
@@ -2573,7 +2573,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
@ -605,7 +614,7 @@
VARIABLE_COMMENT Number of undo tablespaces to use.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 95
@@ -2615,7 +2615,7 @@
@@ -2657,7 +2657,7 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL

View file

@ -2,6 +2,7 @@ select * from information_schema.system_variables
where variable_name like 'innodb%' and
variable_name not in (
'innodb_disallow_writes', # only available WITH_WSREP
'innodb_numa_interleave', # only available WITH_NUMA
'innodb_sched_priority_cleaner', # linux only
'innodb_use_native_aio') # default value depends on OS
order by variable_name;
@ -635,6 +636,20 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_DATA_FILE_SIZE_DEBUG
SESSION_VALUE NULL
GLOBAL_VALUE 0
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT InnoDB system tablespace size to be set in recovery.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_DATA_HOME_DIR
SESSION_VALUE NULL
GLOBAL_VALUE
@ -2181,10 +2196,10 @@ GLOBAL_VALUE 6
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 6
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Maximum delay between polling for a spin lock (6 by default)
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 18446744073709551615
NUMERIC_MAX_VALUE 6000
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@ -2569,12 +2584,26 @@ READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_USE_ATOMIC_WRITES
SESSION_VALUE NULL
GLOBAL_VALUE ON
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE ON
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Enable atomic writes, instead of using the doublewrite buffer, for files on devices that supports atomic writes. To use this option one must use file_per_table=1, flush_method=O_DIRECT and use_fallocate=1. This option only works on Linux with either FusionIO cards using the directFS filesystem or with Shannon cards using any file system.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT NONE
VARIABLE_NAME INNODB_USE_FALLOCATE
SESSION_VALUE NULL
GLOBAL_VALUE OFF
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE OFF
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Prevent partial page writes, via atomic writes.The option is used to prevent partial writes in case of a crash/poweroff, as faster alternative to doublewrite buffer.Currently this option works only on Linux only with FusionIO device, and directFS filesystem.
VARIABLE_COMMENT Use posix_fallocate() to allocate files. DEPRECATED, has no effect.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL

View file

@ -1,6 +1,7 @@
--source include/have_innodb.inc
--source include/have_numa.inc
--source include/have_64bit.inc
call mtr.add_suppression("InnoDB: Failed to set NUMA memory policy");
SELECT @@GLOBAL.innodb_numa_interleave;

View file

@ -46,10 +46,21 @@ select @@global.innodb_spin_wait_delay;
#
set global innodb_spin_wait_delay=0;
select @@global.innodb_spin_wait_delay;
set global innodb_spin_wait_delay=5000;
select @@global.innodb_spin_wait_delay;
#
# invalid values
#
set global innodb_spin_wait_delay=65535;
select @@global.innodb_spin_wait_delay;
set global innodb_spin_wait_delay=4294967295;
select @@global.innodb_spin_wait_delay;
set @@global.innodb_spin_wait_delay = 4294967296;
select @@global.innodb_spin_wait_delay;
set @@global.innodb_spin_wait_delay = 12345678901;
select @@global.innodb_spin_wait_delay;
set @@global.innodb_spin_wait_delay = 18446744073709551615;
select @@global.innodb_spin_wait_delay;
#
# incorrect types
@ -74,26 +85,6 @@ select @@global.innodb_spin_wait_delay;
select * from information_schema.global_variables where variable_name='innodb_spin_wait_delay';
--enable_warnings
#
# Check for out of bounds
#
# With a 64 bit mysqld:18446744073709551615,with a 32 bit mysqld: 4294967295
--disable_warnings
SET @@global.innodb_spin_wait_delay = 4294967296;
--enable_warnings
SELECT @@global.innodb_spin_wait_delay IN (4294967296,4294967295);
--disable_warnings
SET @@global.innodb_spin_wait_delay = 12345678901;
--enable_warnings
SELECT @@global.innodb_spin_wait_delay IN (12345678901,4294967295);
--disable_warnings
SET @@global.innodb_spin_wait_delay = 18446744073709551615;
--enable_warnings
SELECT @@global.innodb_spin_wait_delay IN (18446744073709551615,4294967295);
#
# cleanup
#

View file

@ -9,6 +9,7 @@ select * from information_schema.system_variables
where variable_name like 'innodb%' and
variable_name not in (
'innodb_disallow_writes', # only available WITH_WSREP
'innodb_numa_interleave', # only available WITH_NUMA
'innodb_sched_priority_cleaner', # linux only
'innodb_use_native_aio') # default value depends on OS
order by variable_name;

View file

@ -314,3 +314,68 @@ select * from t1;
drop table t1,t2;
--echo #
--echo # Test error handling with virtual columns
--echo #
CREATE TABLE IF NOT EXISTS t1 (
f1 DOUBLE,
f2 DOUBLE NOT NULL DEFAULT '0',
f3 DOUBLE,
f4 DOUBLE NOT NULL DEFAULT '0',
v1 DOUBLE AS ( ( f1 DIV ( f1 ) ) <= f2 ) VIRTUAL,
v2 DOUBLE AS ( ( f2 DIV ( f2 ) ) <= f2 ) VIRTUAL,
KEY (v2)
);
set sql_mode='strict_all_tables,error_for_division_by_zero';
--error ER_DIVISION_BY_ZERO
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 0, 0, 0);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 1, 1, 1);
--error ER_DIVISION_BY_ZERO
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
INSERT IGNORE INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 1, 1, 1);
select v1 from t1;
--error ER_DIVISION_BY_ZERO
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0,0,0,0), (2,2,2,2);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (3,3,3,3), (4,4,4,4);
--error ER_DIVISION_BY_ZERO
INSERT INTO t1 (f1, f2, f3, f4) VALUES (5,5,5,5), (1,0,0,0);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (6,6,0,0);
--error ER_DIVISION_BY_ZERO
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT f3, f4, f3, f4 FROM t1;
select count(*) from t1;
DELETE FROM t1 WHERE v2 != f1 and f1 < 5;
select count(*) from t1;
select * from t1;
--error ER_BAD_NULL_ERROR
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1;
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1 where f2 !=0;
UPDATE t1 SET f3 = v1 WHERE f2 = 2 AND v2 is null;
SELECT * FROM t1;
TRUNCATE TABLE t1;
set sql_mode='error_for_division_by_zero';
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 0, 0, 0);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 1, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 1, 1, 1);
select v1 from t1;
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0,0,0,0), (2,2,2,2);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (3,3,3,3), (4,4,4,4);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (5,5,5,5), (1,0,0,0);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (6,6,0,0);
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT f3, f4, f3, f4 FROM t1;
select count(*) from t1;
DELETE FROM t1 WHERE v2 != f1 and f1 < 5;
select count(*) from t1;
select * from t1;
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1;
UPDATE t1 SET f3 = v1 WHERE f2 = 2 AND v2 is null;
drop table t1;
set sql_mode=@@global.sql_mode;

View file

@ -181,3 +181,54 @@ create table t1 (a int, b double as (rand()));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
alter table t1 add index (b);
drop table t1;
#
# MDEV-11598 Assertion `!table || (!table->read_set... failed
#
CREATE OR REPLACE TABLE t1 (
f2 DOUBLE NOT NULL DEFAULT '0',
f3 DOUBLE NOT NULL DEFAULT '0',
f4 DOUBLE,
f5 DOUBLE DEFAULT '0',
v4 DOUBLE AS (IF(f4,f3,f2)) VIRTUAL,
KEY (f5),
KEY (v4)
);
INSERT INTO t1 (f2,f3,f4,f5) VALUES (5,4,1,0),(5,7,NULL,0);
INSERT INTO t1 (f2,f3,f4,f5) SELECT f2, f3, f5, f3 FROM t1;
INSERT INTO t1 (f2,f3,f4,f5) VALUES (5,0,NULL,1);
INSERT INTO t1 (f2,f3,f4,f5) SELECT f2, f5, f5, f3 FROM t1;
DELETE FROM t1 WHERE f5 = 1 OR v4 = 4 ORDER BY f5,v4 LIMIT 9;
SELECT * from t1;
DROP TABLE t1;
# Another similar failure
CREATE TABLE t1 (
d DECIMAL(63,0) NOT NULL DEFAULT 0,
c VARCHAR(64) NOT NULL DEFAULT '',
vd DECIMAL(63,0) AS (d) VIRTUAL,
vc VARCHAR(2048) AS (c) VIRTUAL,
pk BIGINT AUTO_INCREMENT,
PRIMARY KEY(pk));
INSERT INTO t1 (d,c) VALUES (0.5,'foo');
SELECT * FROM t1 WHERE vc != 'bar' ORDER BY vd;
DROP TABLE t1;
#
# MDEV-11729: Crash when using partial indexed virtual fields
#
CREATE TABLE t1 (
pk BIGINT,
c CHAR(64) NOT NULL DEFAULT '',
vc CHAR(64) AS (c) VIRTUAL,
PRIMARY KEY(pk),
INDEX(vc(32))
);
DELETE FROM t1 WHERE vc IS NULL ORDER BY pk;
DROP TABLE t1;

View file

@ -149,3 +149,135 @@ DROP TRIGGER t1_ins_aft;
DROP TRIGGER t1_del_bef;
DROP TABLE t1,t2;
--echo #
--echo # Examine the number of times triggers are recalculated for updates
--echo #
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
b CHAR(10) NULL DEFAULT NULL,
c blob NULL DEFAULT NULL,
blob_a blob GENERATED ALWAYS AS (last_value(@a:=@a+1,a)) VIRTUAL,
blob_b blob GENERATED ALWAYS AS (last_value(@b:=@b+1,b)) VIRTUAL,
blob_c blob GENERATED ALWAYS AS (last_value(@c:=@c+1,c)) VIRTUAL
);
DELIMITER |;
CREATE TRIGGER t1_ins
BEFORE INSERT
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL THEN
SET NEW.b="generated before insert";
END IF;
END |
CREATE TRIGGER t1_update
BEFORE UPDATE
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL or NEW.c IS NULL THEN
SET NEW.b="generated before update";
SET NEW.c="generated before update";
END IF;
END |
DELIMITER ;|
--echo # Inserts
set @a=0,@b=0,@c=0;
insert into t1 (a) values(1);
insert into t1 (a,b) values(2, "*2*");
insert into t1 (a,b,c) values(3, "*3*", "**3**");
insert into t1 (a,c) values(4, "**4**");
select * from t1;
select @a,@b,@c;
select * from t1;
select @a,@b,@c;
select a,b,c from t1;
select @a,@b,@c;
select a,b,c,blob_a from t1;
select @a,@b,@c;
--echo # updates
set @a=0,@b=0,@c=0;
update t1 set a=a+100 where a=1;
update t1 set a=a+100, b="*102*" where a=2;
update t1 set a=a+100, b=NULL where a=3;
update t1 set a=a+100, b="invisible", c=NULL where a=4;
select @a,@b,@c;
select * from t1;
drop trigger t1_ins;
drop trigger t1_update;
drop table t1;
--echo #
--echo # Same test, but with virtual keys
--echo #
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
b CHAR(10) NULL DEFAULT NULL,
c blob NULL DEFAULT NULL,
blob_a blob GENERATED ALWAYS AS (a) VIRTUAL,
blob_b blob GENERATED ALWAYS AS (b) VIRTUAL,
blob_c blob GENERATED ALWAYS AS (c) VIRTUAL,
key (a),
key (blob_a(10)),
key (blob_b(10)),
key (blob_c(10))
);
DELIMITER |;
CREATE TRIGGER t1_ins
BEFORE INSERT
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL THEN
SET NEW.b="generated before insert";
END IF;
END |
CREATE TRIGGER t1_update
BEFORE UPDATE
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL or NEW.c IS NULL THEN
SET NEW.b="generated before update";
SET NEW.c="generated before update";
END IF;
END |
DELIMITER ;|
--echo # Inserts
insert into t1 (a) values(1);
insert into t1 (a,b) values(2, "*2*");
insert into t1 (a,b,c) values(3, "*3*", "**3**");
insert into t1 (a,c) values(4, "**4**");
select * from t1;
select @a,@b,@c;
select * from t1;
select @a,@b,@c;
select a,b,c from t1;
select @a,@b,@c;
select a,b,c,blob_a from t1;
select @a,@b,@c;
--echo # updates
update t1 set a=a+100 where a=1;
update t1 set a=a+100, b="*102*" where a=2;
update t1 set a=a+100, b=NULL where a=3;
update t1 set a=a+100, b="invisible", c=NULL where a=4;
select * from t1;
drop trigger t1_ins;
drop trigger t1_update;
drop table t1;

View file

@ -4,14 +4,14 @@ set time_zone='+10:00';
set div_precision_increment=20;
create table t1 (a int, b int, v decimal(20,19) as (a/3));
create table t2 (a int, b int, v int as (a+@a));
ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
drop table t2;
create table t2 (a int, b int, v int as (a+@a) PERSISTENT);
ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t3_ok (a int, b int, v int as (a+@@error_count));
create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
ERROR HY000: Function or expression '@@error_count' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t4 (a int, b int, v int as (@a:=a));
ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
drop table t4;
create table t4 (a int, b int, v int as (@a:=a) PERSISTENT);
ERROR HY000: Function or expression '@a' cannot be used in the GENERATED ALWAYS AS clause of `v`
create table t8 (a int, b int, v varchar(100) as (from_unixtime(a)));

View file

@ -451,3 +451,223 @@ id name name_hash
2050 name1 9b46b0dd3a8083c070c3b9953bb5f3f95c5ab4da
2051 name2+1 fd4f236320db3956a5ec073c5ec39707d7f05708
drop table t1,t2;
#
# Test error handling with virtual columns
#
CREATE TABLE IF NOT EXISTS t1 (
f1 DOUBLE,
f2 DOUBLE NOT NULL DEFAULT '0',
f3 DOUBLE,
f4 DOUBLE NOT NULL DEFAULT '0',
v1 DOUBLE AS ( ( f1 DIV ( f1 ) ) <= f2 ) VIRTUAL,
v2 DOUBLE AS ( ( f2 DIV ( f2 ) ) <= f2 ) VIRTUAL,
KEY (v2)
);
set sql_mode='strict_all_tables,error_for_division_by_zero';
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 0, 0, 0);
ERROR 22012: Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 1, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
ERROR 22012: Division by 0
INSERT IGNORE INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 1, 1, 1);
select v1 from t1;
v1
1
0
NULL
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0,0,0,0), (2,2,2,2);
ERROR 22012: Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (3,3,3,3), (4,4,4,4);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (5,5,5,5), (1,0,0,0);
ERROR 22012: Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (6,6,0,0);
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT f3, f4, f3, f4 FROM t1;
ERROR 22012: Division by 0
select count(*) from t1;
count(*)
6
DELETE FROM t1 WHERE v2 != f1 and f1 < 5;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
select count(*) from t1;
count(*)
3
select * from t1;
f1 f2 f3 f4 v1 v2
1 1 1 1 1 1
1 0 1 1 0 NULL
6 6 0 0 1 1
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1;
ERROR 23000: Column 'f2' cannot be null
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1 where f2 !=0;
Warnings:
Warning 1365 Division by 0
UPDATE t1 SET f3 = v1 WHERE f2 = 2 AND v2 is null;
Warnings:
Warning 1365 Division by 0
SELECT * FROM t1;
f1 f2 f3 f4 v1 v2
1 1 1 1 1 1
1 0 1 1 0 NULL
6 6 0 0 1 1
1 1 10 10 1 1
1 1 10 10 1 1
Warnings:
Warning 1365 Division by 0
TRUNCATE TABLE t1;
set sql_mode='error_for_division_by_zero';
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 0, 0, 0);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 1, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 1, 1, 1);
select v1 from t1;
v1
NULL
1
0
NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0,0,0,0), (2,2,2,2);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (3,3,3,3), (4,4,4,4);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (5,5,5,5), (1,0,0,0);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (6,6,0,0);
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT f3, f4, f3, f4 FROM t1;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
select count(*) from t1;
count(*)
22
DELETE FROM t1 WHERE v2 != f1 and f1 < 5;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
select count(*) from t1;
count(*)
15
select * from t1;
f1 f2 f3 f4 v1 v2
0 0 0 0 NULL NULL
1 1 1 1 1 1
1 0 1 1 0 NULL
0 0 0 0 NULL NULL
5 5 5 5 1 1
1 0 0 0 0 NULL
6 6 0 0 1 1
0 0 0 0 NULL NULL
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 0 NULL NULL
5 5 5 5 1 1
0 0 0 0 NULL NULL
0 0 0 0 NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
UPDATE t1 SET f3 = v1 WHERE f2 = 2 AND v2 is null;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
drop table t1;
set sql_mode=@@global.sql_mode;

View file

@ -389,3 +389,240 @@ id name name_hash
2051 name2+1 fd4f236320db3956a5ec073c5ec39707d7f05708
2041 name3+1 93c9096df48221428de46e146abc9f4f94bf7d2e
drop table t1,t2;
#
# Test error handling with virtual columns
#
CREATE TABLE IF NOT EXISTS t1 (
f1 DOUBLE,
f2 DOUBLE NOT NULL DEFAULT '0',
f3 DOUBLE,
f4 DOUBLE NOT NULL DEFAULT '0',
v1 DOUBLE AS ( ( f1 DIV ( f1 ) ) <= f2 ) VIRTUAL,
v2 DOUBLE AS ( ( f2 DIV ( f2 ) ) <= f2 ) VIRTUAL,
KEY (v2)
);
set sql_mode='strict_all_tables,error_for_division_by_zero';
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 0, 0, 0);
ERROR 22012: Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 1, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
ERROR 22012: Division by 0
INSERT IGNORE INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 1, 1, 1);
select v1 from t1;
v1
1
0
NULL
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0,0,0,0), (2,2,2,2);
ERROR 22012: Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (3,3,3,3), (4,4,4,4);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (5,5,5,5), (1,0,0,0);
ERROR 22012: Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (6,6,0,0);
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT f3, f4, f3, f4 FROM t1;
ERROR 22012: Division by 0
select count(*) from t1;
count(*)
13
DELETE FROM t1 WHERE v2 != f1 and f1 < 5;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
select count(*) from t1;
count(*)
8
select * from t1;
f1 f2 f3 f4 v1 v2
1 1 1 1 1 1
1 0 1 1 0 NULL
5 5 5 5 1 1
6 6 0 0 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
5 5 5 5 1 1
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1;
ERROR 23000: Column 'f2' cannot be null
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1 where f2 !=0;
Warnings:
Warning 1365 Division by 0
UPDATE t1 SET f3 = v1 WHERE f2 = 2 AND v2 is null;
Warnings:
Warning 1365 Division by 0
SELECT * FROM t1;
f1 f2 f3 f4 v1 v2
1 1 1 1 1 1
1 0 1 1 0 NULL
1 1 10 10 1 1
1 1 10 10 1 1
1 1 10 10 1 1
5 5 5 5 1 1
6 6 0 0 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 10 10 1 1
1 1 10 10 1 1
5 5 5 5 1 1
1 1 10 10 1 1
1 1 10 10 1 1
1 1 10 10 1 1
1 1 10 10 1 1
Warnings:
Warning 1365 Division by 0
TRUNCATE TABLE t1;
set sql_mode='error_for_division_by_zero';
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 0, 0, 0);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 1, 1, 1);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (1, 0, 1, 1);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0, 1, 1, 1);
select v1 from t1;
v1
NULL
1
0
NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (0,0,0,0), (2,2,2,2);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (3,3,3,3), (4,4,4,4);
INSERT INTO t1 (f1, f2, f3, f4) VALUES (5,5,5,5), (1,0,0,0);
Warnings:
Warning 1365 Division by 0
INSERT INTO t1 (f1, f2, f3, f4) VALUES (6,6,0,0);
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT f3, f4, f3, f4 FROM t1;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
select count(*) from t1;
count(*)
22
DELETE FROM t1 WHERE v2 != f1 and f1 < 5;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
select count(*) from t1;
count(*)
15
select * from t1;
f1 f2 f3 f4 v1 v2
0 0 0 0 NULL NULL
1 1 1 1 1 1
1 0 1 1 0 NULL
0 0 0 0 NULL NULL
5 5 5 5 1 1
1 0 0 0 0 NULL
6 6 0 0 1 1
0 0 0 0 NULL NULL
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 0 NULL NULL
5 5 5 5 1 1
0 0 0 0 NULL NULL
0 0 0 0 NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
INSERT INTO t1 ( f1, f2, f3, f4 ) SELECT v1, v2, 10,10 FROM t1;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
Warning 1048 Column 'f2' cannot be null
Warning 1365 Division by 0
UPDATE t1 SET f3 = v1 WHERE f2 = 2 AND v2 is null;
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
drop table t1;
set sql_mode=@@global.sql_mode;

View file

@ -168,3 +168,60 @@ create table t1 (a int, b double as (rand()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
CREATE OR REPLACE TABLE t1 (
f2 DOUBLE NOT NULL DEFAULT '0',
f3 DOUBLE NOT NULL DEFAULT '0',
f4 DOUBLE,
f5 DOUBLE DEFAULT '0',
v4 DOUBLE AS (IF(f4,f3,f2)) VIRTUAL,
KEY (f5),
KEY (v4)
);
INSERT INTO t1 (f2,f3,f4,f5) VALUES (5,4,1,0),(5,7,NULL,0);
INSERT INTO t1 (f2,f3,f4,f5) SELECT f2, f3, f5, f3 FROM t1;
INSERT INTO t1 (f2,f3,f4,f5) VALUES (5,0,NULL,1);
INSERT INTO t1 (f2,f3,f4,f5) SELECT f2, f5, f5, f3 FROM t1;
DELETE FROM t1 WHERE f5 = 1 OR v4 = 4 ORDER BY f5,v4 LIMIT 9;
SELECT * from t1;
f2 f3 f4 f5 v4
5 7 NULL 0 5
5 4 0 4 5
5 7 0 7 5
5 0 0 4 5
5 0 0 7 5
5 7 7 7 7
5 1 1 0 1
DROP TABLE t1;
CREATE TABLE t1 (
d DECIMAL(63,0) NOT NULL DEFAULT 0,
c VARCHAR(64) NOT NULL DEFAULT '',
vd DECIMAL(63,0) AS (d) VIRTUAL,
vc VARCHAR(2048) AS (c) VIRTUAL,
pk BIGINT AUTO_INCREMENT,
PRIMARY KEY(pk));
INSERT INTO t1 (d,c) VALUES (0.5,'foo');
Warnings:
Note 1265 Data truncated for column 'd' at row 1
SELECT * FROM t1 WHERE vc != 'bar' ORDER BY vd;
d c vd vc pk
1 foo 1 foo 1
DROP TABLE t1;
CREATE TABLE t1 (
pk BIGINT,
c CHAR(64) NOT NULL DEFAULT '',
vc CHAR(64) AS (c) VIRTUAL,
PRIMARY KEY(pk),
INDEX(vc(32))
);
DELETE FROM t1 WHERE vc IS NULL ORDER BY pk;
DROP TABLE t1;
#
# MDEV-11737 Failing assertion: block->magic_n == MEM_BLOCK_MAGIC_N
#
CREATE TABLE t1 (i INT PRIMARY KEY, vi INT AS (i*2) VIRTUAL UNIQUE)
ENGINE=InnoDB;
CREATE TABLE t2 (i INT) ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN col INT;
SELECT * FROM t1 WHERE vi < 2;
i vi col
DROP TABLE t1, t2;

View file

@ -1,119 +1,3 @@
create table t1 (a int, b int as (a+1), c int, index(b));
insert t1 (a,c) values (0x7890abcd, 0x76543210);
insert t1 (a,c) select seq, sin(seq)*10000 from seq_1_to_1000;
explain select * from t1 where b=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref b b 5 const 1
select * from t1 where b=10;
a b c
9 10 4121
MyISAM file: datadir/test/t1
Record format: Fixed length
Character set: latin1_swedish_ci (8)
Data records: 1001 Deleted blocks: 0
Recordlength: 9
table description:
Key Start Len Index Type
1 10 4 multip. long NULL
update t1 set a=20 where b=10;
select * from t1 where b=10;
a b c
select * from t1 where b=21;
a b c
20 21 4121
20 21 9129
delete from t1 where b=21;
select * from t1 where b=21;
a b c
alter table t1 add column d char(20) as (concat(a,c));
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
create index i on t1 (d);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
check table t1 quick;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
check table t1 medium;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 b 1 b A 999 NULL NULL YES BTREE
t1 1 i 1 d A 999 NULL NULL YES BTREE
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
delete from t1 where b=12;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 b 1 b A 998 NULL NULL YES BTREE
t1 1 i 1 d A 998 NULL NULL YES BTREE
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 b 1 b A 998 NULL NULL YES BTREE
t1 1 i 1 d A 998 NULL NULL YES BTREE
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1 quick;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1 extended;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 998
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
update t1 set a=30 where b=11;
select * from t1 where b=11;
a b c d
select * from t1 where b=31;
a b c d
30 31 -5440 30-5440
30 31 -9880 30-9880
drop table t1;
SET @@session.storage_engine = 'MyISAM';
# - UNIQUE KEY
# - INDEX
@ -278,3 +162,204 @@ create table t1 (a int, b double as (rand()));
alter table t1 add index (b);
ERROR HY000: Function or expression 'rand()' cannot be used in the GENERATED ALWAYS AS clause of `b`
drop table t1;
CREATE OR REPLACE TABLE t1 (
f2 DOUBLE NOT NULL DEFAULT '0',
f3 DOUBLE NOT NULL DEFAULT '0',
f4 DOUBLE,
f5 DOUBLE DEFAULT '0',
v4 DOUBLE AS (IF(f4,f3,f2)) VIRTUAL,
KEY (f5),
KEY (v4)
);
INSERT INTO t1 (f2,f3,f4,f5) VALUES (5,4,1,0),(5,7,NULL,0);
INSERT INTO t1 (f2,f3,f4,f5) SELECT f2, f3, f5, f3 FROM t1;
INSERT INTO t1 (f2,f3,f4,f5) VALUES (5,0,NULL,1);
INSERT INTO t1 (f2,f3,f4,f5) SELECT f2, f5, f5, f3 FROM t1;
DELETE FROM t1 WHERE f5 = 1 OR v4 = 4 ORDER BY f5,v4 LIMIT 9;
SELECT * from t1;
f2 f3 f4 f5 v4
5 7 NULL 0 5
5 4 0 4 5
5 7 0 7 5
5 0 0 4 5
5 0 0 7 5
5 7 7 7 7
5 1 1 0 1
DROP TABLE t1;
CREATE TABLE t1 (
d DECIMAL(63,0) NOT NULL DEFAULT 0,
c VARCHAR(64) NOT NULL DEFAULT '',
vd DECIMAL(63,0) AS (d) VIRTUAL,
vc VARCHAR(2048) AS (c) VIRTUAL,
pk BIGINT AUTO_INCREMENT,
PRIMARY KEY(pk));
INSERT INTO t1 (d,c) VALUES (0.5,'foo');
Warnings:
Note 1265 Data truncated for column 'd' at row 1
SELECT * FROM t1 WHERE vc != 'bar' ORDER BY vd;
d c vd vc pk
1 foo 1 foo 1
DROP TABLE t1;
CREATE TABLE t1 (
pk BIGINT,
c CHAR(64) NOT NULL DEFAULT '',
vc CHAR(64) AS (c) VIRTUAL,
PRIMARY KEY(pk),
INDEX(vc(32))
);
DELETE FROM t1 WHERE vc IS NULL ORDER BY pk;
DROP TABLE t1;
#
# Original test
#
create table t1 (a int, b int as (a+1), c int, index(b));
insert t1 (a,c) values (0x7890abcd, 0x76543210);
insert t1 (a,c) select seq, sin(seq)*10000 from seq_1_to_1000;
explain select * from t1 where b=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref b b 5 const 1
select * from t1 where b=10;
a b c
9 10 4121
MyISAM file: datadir/test/t1
Record format: Fixed length
Character set: latin1_swedish_ci (8)
Data records: 1001 Deleted blocks: 0
Recordlength: 9
table description:
Key Start Len Index Type
1 10 4 multip. long NULL
update t1 set a=20 where b=10;
select * from t1 where b=10;
a b c
select * from t1 where b=21;
a b c
20 21 4121
20 21 9129
delete from t1 where b=21;
select * from t1 where b=21;
a b c
alter table t1 add column d char(20) as (concat(a,c));
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
create index i on t1 (d);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
check table t1 quick;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
check table t1 medium;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 b 1 b A 999 NULL NULL YES BTREE
t1 1 i 1 d A 999 NULL NULL YES BTREE
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
delete from t1 where b=12;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 b 1 b A 998 NULL NULL YES BTREE
t1 1 i 1 d A 998 NULL NULL YES BTREE
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 b 1 b A 998 NULL NULL YES BTREE
t1 1 i 1 d A 998 NULL NULL YES BTREE
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1 quick;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1 extended;
Table Op Msg_type Msg_text
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 998
test.t1 repair status OK
select * from t1 where b=11;
a b c d
10 11 -5440 10-5440
update t1 set a=30 where b=11;
select * from t1 where b=11;
a b c d
select * from t1 where b=31;
a b c d
30 31 -5440 30-5440
30 31 -9880 30-9880
drop table t1;
#
# MDEV-11606 Server crashes in mi_make_key / sort_key_read
#
CREATE TABLE t1 (
pk BIGINT AUTO_INCREMENT,
col_date DATE NULL,
col_datetime DATETIME(1) NULL,
col_int TINYINT(13) UNSIGNED ZEROFILL NULL,
col_varchar VARBINARY(2222) NULL,
col_timestamp TIMESTAMP(2) NULL,
col_bit BIT(64) NOT NULL DEFAULT 0,
col_blob MEDIUMBLOB NULL,
col_dec DECIMAL(10,9) ZEROFILL NOT NULL DEFAULT 0,
col_time TIME(4) NULL,
col_year YEAR NOT NULL DEFAULT '1970',
col_char CHAR(129) NULL,
col_enum SET('','a','b','c','d','e','f','foo','bar') NULL,
vcol_dec DECIMAL(50,18) ZEROFILL AS (col_dec) VIRTUAL,
vcol_bit BIT(48) AS (col_bit) VIRTUAL,
vcol_char CHAR(224) AS (col_char) VIRTUAL,
vcol_datetime DATETIME(4) AS (col_datetime) VIRTUAL,
vcol_year YEAR AS (col_year) VIRTUAL,
vcol_varchar VARBINARY(356) AS (col_varchar) VIRTUAL,
vcol_blob MEDIUMBLOB AS (col_blob) VIRTUAL,
vcol_timestamp TIMESTAMP(5) AS (col_timestamp) VIRTUAL,
vcol_int BIGINT(46) AS (col_int) VIRTUAL,
vcol_time TIME(1) AS (col_time) VIRTUAL,
vcol_date DATE AS (col_date) VIRTUAL,
vcol_enum SET('','a','b','c','d','e','f','foo','bar') AS (col_enum) VIRTUAL,
UNIQUE(pk),
PRIMARY KEY(pk)
) ENGINE=MyISAM;
ALTER TABLE t1 ADD INDEX(col_enum,vcol_int);
ALTER TABLE t1 ADD INDEX(col_year);
DROP TABLE t1;

View file

@ -125,3 +125,182 @@ c
DROP TRIGGER t1_ins_aft;
DROP TRIGGER t1_del_bef;
DROP TABLE t1,t2;
#
# Examine the number of times triggers are recalculated for updates
#
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
b CHAR(10) NULL DEFAULT NULL,
c blob NULL DEFAULT NULL,
blob_a blob GENERATED ALWAYS AS (last_value(@a:=@a+1,a)) VIRTUAL,
blob_b blob GENERATED ALWAYS AS (last_value(@b:=@b+1,b)) VIRTUAL,
blob_c blob GENERATED ALWAYS AS (last_value(@c:=@c+1,c)) VIRTUAL
);
CREATE TRIGGER t1_ins
BEFORE INSERT
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL THEN
SET NEW.b="generated before insert";
END IF;
END |
CREATE TRIGGER t1_update
BEFORE UPDATE
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL or NEW.c IS NULL THEN
SET NEW.b="generated before update";
SET NEW.c="generated before update";
END IF;
END |
# Inserts
set @a=0,@b=0,@c=0;
insert into t1 (a) values(1);
insert into t1 (a,b) values(2, "*2*");
insert into t1 (a,b,c) values(3, "*3*", "**3**");
insert into t1 (a,c) values(4, "**4**");
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
8 8 8
select a,b,c from t1;
a b c
1 generated NULL
2 *2* NULL
3 *3* **3**
4 generated **4**
select @a,@b,@c;
@a @b @c
8 8 8
select a,b,c,blob_a from t1;
a b c blob_a
1 generated NULL 1
2 *2* NULL 2
3 *3* **3** 3
4 generated **4** 4
select @a,@b,@c;
@a @b @c
12 8 8
# updates
set @a=0,@b=0,@c=0;
update t1 set a=a+100 where a=1;
update t1 set a=a+100, b="*102*" where a=2;
update t1 set a=a+100, b=NULL where a=3;
update t1 set a=a+100, b="invisible", c=NULL where a=4;
select @a,@b,@c;
@a @b @c
0 0 0
select * from t1;
a b c blob_a blob_b blob_c
101 generated generated before update 101 generated generated before update
102 generated generated before update 102 generated generated before update
103 generated generated before update 103 generated generated before update
104 generated generated before update 104 generated generated before update
drop trigger t1_ins;
drop trigger t1_update;
drop table t1;
#
# Same test, but with virtual keys
#
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
b CHAR(10) NULL DEFAULT NULL,
c blob NULL DEFAULT NULL,
blob_a blob GENERATED ALWAYS AS (a) VIRTUAL,
blob_b blob GENERATED ALWAYS AS (b) VIRTUAL,
blob_c blob GENERATED ALWAYS AS (c) VIRTUAL,
key (a),
key (blob_a(10)),
key (blob_b(10)),
key (blob_c(10))
);
CREATE TRIGGER t1_ins
BEFORE INSERT
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL THEN
SET NEW.b="generated before insert";
END IF;
END |
CREATE TRIGGER t1_update
BEFORE UPDATE
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL or NEW.c IS NULL THEN
SET NEW.b="generated before update";
SET NEW.c="generated before update";
END IF;
END |
# Inserts
insert into t1 (a) values(1);
insert into t1 (a,b) values(2, "*2*");
insert into t1 (a,b,c) values(3, "*3*", "**3**");
insert into t1 (a,c) values(4, "**4**");
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select a,b,c from t1;
a b c
1 generated NULL
2 *2* NULL
3 *3* **3**
4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select a,b,c,blob_a from t1;
a b c blob_a
1 generated NULL 1
2 *2* NULL 2
3 *3* **3** 3
4 generated **4** 4
select @a,@b,@c;
@a @b @c
4 4 4
# updates
update t1 set a=a+100 where a=1;
update t1 set a=a+100, b="*102*" where a=2;
update t1 set a=a+100, b=NULL where a=3;
update t1 set a=a+100, b="invisible", c=NULL where a=4;
select * from t1;
a b c blob_a blob_b blob_c
101 generated generated before update 101 generated generated before update
102 generated generated before update 102 generated generated before update
103 generated generated before update 103 generated generated before update
104 generated generated before update 104 generated generated before update
drop trigger t1_ins;
drop trigger t1_update;
drop table t1;

View file

@ -125,3 +125,182 @@ c
DROP TRIGGER t1_ins_aft;
DROP TRIGGER t1_del_bef;
DROP TABLE t1,t2;
#
# Examine the number of times triggers are recalculated for updates
#
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
b CHAR(10) NULL DEFAULT NULL,
c blob NULL DEFAULT NULL,
blob_a blob GENERATED ALWAYS AS (last_value(@a:=@a+1,a)) VIRTUAL,
blob_b blob GENERATED ALWAYS AS (last_value(@b:=@b+1,b)) VIRTUAL,
blob_c blob GENERATED ALWAYS AS (last_value(@c:=@c+1,c)) VIRTUAL
);
CREATE TRIGGER t1_ins
BEFORE INSERT
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL THEN
SET NEW.b="generated before insert";
END IF;
END |
CREATE TRIGGER t1_update
BEFORE UPDATE
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL or NEW.c IS NULL THEN
SET NEW.b="generated before update";
SET NEW.c="generated before update";
END IF;
END |
# Inserts
set @a=0,@b=0,@c=0;
insert into t1 (a) values(1);
insert into t1 (a,b) values(2, "*2*");
insert into t1 (a,b,c) values(3, "*3*", "**3**");
insert into t1 (a,c) values(4, "**4**");
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
8 8 8
select a,b,c from t1;
a b c
1 generated NULL
2 *2* NULL
3 *3* **3**
4 generated **4**
select @a,@b,@c;
@a @b @c
8 8 8
select a,b,c,blob_a from t1;
a b c blob_a
1 generated NULL 1
2 *2* NULL 2
3 *3* **3** 3
4 generated **4** 4
select @a,@b,@c;
@a @b @c
12 8 8
# updates
set @a=0,@b=0,@c=0;
update t1 set a=a+100 where a=1;
update t1 set a=a+100, b="*102*" where a=2;
update t1 set a=a+100, b=NULL where a=3;
update t1 set a=a+100, b="invisible", c=NULL where a=4;
select @a,@b,@c;
@a @b @c
0 0 0
select * from t1;
a b c blob_a blob_b blob_c
101 generated generated before update 101 generated generated before update
102 generated generated before update 102 generated generated before update
103 generated generated before update 103 generated generated before update
104 generated generated before update 104 generated generated before update
drop trigger t1_ins;
drop trigger t1_update;
drop table t1;
#
# Same test, but with virtual keys
#
CREATE TABLE t1 (
a INTEGER UNSIGNED NULL DEFAULT NULL,
b CHAR(10) NULL DEFAULT NULL,
c blob NULL DEFAULT NULL,
blob_a blob GENERATED ALWAYS AS (a) VIRTUAL,
blob_b blob GENERATED ALWAYS AS (b) VIRTUAL,
blob_c blob GENERATED ALWAYS AS (c) VIRTUAL,
key (a),
key (blob_a(10)),
key (blob_b(10)),
key (blob_c(10))
);
CREATE TRIGGER t1_ins
BEFORE INSERT
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL THEN
SET NEW.b="generated before insert";
END IF;
END |
CREATE TRIGGER t1_update
BEFORE UPDATE
ON t1
FOR EACH ROW
BEGIN
IF NEW.b IS NULL or NEW.c IS NULL THEN
SET NEW.b="generated before update";
SET NEW.c="generated before update";
END IF;
END |
# Inserts
insert into t1 (a) values(1);
insert into t1 (a,b) values(2, "*2*");
insert into t1 (a,b,c) values(3, "*3*", "**3**");
insert into t1 (a,c) values(4, "**4**");
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select * from t1;
a b c blob_a blob_b blob_c
1 generated NULL 1 generated NULL
2 *2* NULL 2 *2* NULL
3 *3* **3** 3 *3* **3**
4 generated **4** 4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select a,b,c from t1;
a b c
1 generated NULL
2 *2* NULL
3 *3* **3**
4 generated **4**
select @a,@b,@c;
@a @b @c
4 4 4
select a,b,c,blob_a from t1;
a b c blob_a
1 generated NULL 1
2 *2* NULL 2
3 *3* **3** 3
4 generated **4** 4
select @a,@b,@c;
@a @b @c
4 4 4
# updates
update t1 set a=a+100 where a=1;
update t1 set a=a+100, b="*102*" where a=2;
update t1 set a=a+100, b=NULL where a=3;
update t1 set a=a+100, b="invisible", c=NULL where a=4;
select * from t1;
a b c blob_a blob_b blob_c
101 generated generated before update 101 generated generated before update
102 generated generated before update 102 generated generated before update
103 generated generated before update 103 generated generated before update
104 generated generated before update 104 generated generated before update
drop trigger t1_ins;
drop trigger t1_update;
drop table t1;

View file

@ -2,7 +2,7 @@
# MDEV-7113 difference between check_vcol_func_processor and check_partition_func_processor
#
# the following functions must not be supported in virtual columns.
# the following functions must not be supported in persistent columns.
# but for compatibility reasons it won't be done in a GA version,
# we'll only fix most critical issues (inconsistent results, crashes)
@ -13,15 +13,13 @@ set time_zone='+10:00';
set div_precision_increment=20;
create table t1 (a int, b int, v decimal(20,19) as (a/3));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t2 (a int, b int, v int as (a+@a));
create table t2 (a int, b int, v int as (a+@a)); drop table t2;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t2 (a int, b int, v int as (a+@a) PERSISTENT);
create table t3_ok (a int, b int, v int as (a+@@error_count));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t3 (a int, b int, v int as (a+@@error_count) PERSISTENT);
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t4 (a int, b int, v int as (@a:=a));
create table t4 (a int, b int, v int as (@a:=a)); drop table t4;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
create table t4 (a int, b int, v int as (@a:=a) PERSISTENT);
create table t8 (a int, b int, v varchar(100) as (from_unixtime(a)));

View file

@ -1,34 +1,34 @@
################################################################################
# t/vcol_keys_innodb.test #
# #
# Purpose: #
# Testing keys, indexes defined upon virtual columns. #
# #
# InnoDB branch #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
###############################################################################
# t/vcol_keys_innodb.test #
# #
# Purpose: #
# Testing keys, indexes defined upon virtual columns. #
# #
# InnoDB branch #
# #
#-----------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
###############################################################################
#
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
#------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source suite/vcol/inc/vcol_init_vars.pre
#------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Cleanup
--source suite/vcol/inc/vcol_cleanup.inc
#------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
@ -39,14 +39,25 @@ SET @@session.storage_engine = 'InnoDB';
##### Workarounds for known open engine specific bugs
# none
#------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
let $with_foreign_keys = 1;
--source suite/vcol/inc/vcol_keys.inc
#------------------------------------------------------------------------------#
# Execute storage engine specific tests
#------------------------------------------------------------------------------#
# Cleanup
--source suite/vcol/inc/vcol_cleanup.inc
#-----------------------------------------------------------------------------#
# Execute storage engine specific tests
#-----------------------------------------------------------------------------#
--echo #
--echo # MDEV-11737 Failing assertion: block->magic_n == MEM_BLOCK_MAGIC_N
--echo #
CREATE TABLE t1 (i INT PRIMARY KEY, vi INT AS (i*2) VIRTUAL UNIQUE)
ENGINE=InnoDB;
CREATE TABLE t2 (i INT) ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN col INT;
SELECT * FROM t1 WHERE vi < 2;
DROP TABLE t1, t2;

View file

@ -1,6 +1,59 @@
--source include/have_sequence.inc
--let $datadir= `select @@datadir`
###############################################################################
# t/vcol_keys_myisam.test #
# #
# Purpose: #
# Testing keys, indexes defined upon virtual columns. #
# #
# MyISAM branch #
# #
#-----------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
###############################################################################
#
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
#------------------------------------------------------------------------------
# General not engine specific settings and requirements
--source suite/vcol/inc/vcol_init_vars.pre
#------------------------------------------------------------------------------
# Cleanup
--source suite/vcol/inc/vcol_cleanup.inc
#------------------------------------------------------------------------------
# Engine specific settings and requirements
##### Storage engine to be tested
# Set the session storage engine
SET @@session.storage_engine = 'MyISAM';
##### Workarounds for known open engine specific bugs
# none
#------------------------------------------------------------------------------
# Execute the tests to be applied to all storage engines
--source suite/vcol/inc/vcol_keys.inc
# Cleanup
--source suite/vcol/inc/vcol_cleanup.inc
#-----------------------------------------------------------------------------#
# Execute storage engine specific test
#-----------------------------------------------------------------------------#
--echo #
--echo # Original test
--echo #
create table t1 (a int, b int as (a+1), c int, index(b));
insert t1 (a,c) values (0x7890abcd, 0x76543210);
@ -49,56 +102,148 @@ select * from t1 where b=31;
--exec $MYISAMCHK $datadir/test/t1
--error 1
--exec $MYISAMCHK -r $datadir/test/t1
drop table t1;
################################################################################
# t/vcol_keys_myisam.test #
# #
# Purpose: #
# Testing keys, indexes defined upon virtual columns. #
# #
# MyISAM branch #
# #
#------------------------------------------------------------------------------#
# Original Author: Andrey Zhakov #
# Original Date: 2008-09-04 #
# Change Author: #
# Change Date: #
# Change: #
################################################################################
--echo #
--echo # MDEV-11606 Server crashes in mi_make_key / sort_key_read
--echo #
#
# NOTE: PLEASE DO NOT ADD NOT MYISAM SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
CREATE TABLE t1 (
pk BIGINT AUTO_INCREMENT,
col_date DATE NULL,
col_datetime DATETIME(1) NULL,
col_int TINYINT(13) UNSIGNED ZEROFILL NULL,
col_varchar VARBINARY(2222) NULL,
col_timestamp TIMESTAMP(2) NULL,
col_bit BIT(64) NOT NULL DEFAULT 0,
col_blob MEDIUMBLOB NULL,
col_dec DECIMAL(10,9) ZEROFILL NOT NULL DEFAULT 0,
col_time TIME(4) NULL,
col_year YEAR NOT NULL DEFAULT '1970',
col_char CHAR(129) NULL,
col_enum SET('','a','b','c','d','e','f','foo','bar') NULL,
vcol_dec DECIMAL(50,18) ZEROFILL AS (col_dec) VIRTUAL,
vcol_bit BIT(48) AS (col_bit) VIRTUAL,
vcol_char CHAR(224) AS (col_char) VIRTUAL,
vcol_datetime DATETIME(4) AS (col_datetime) VIRTUAL,
vcol_year YEAR AS (col_year) VIRTUAL,
vcol_varchar VARBINARY(356) AS (col_varchar) VIRTUAL,
vcol_blob MEDIUMBLOB AS (col_blob) VIRTUAL,
vcol_timestamp TIMESTAMP(5) AS (col_timestamp) VIRTUAL,
vcol_int BIGINT(46) AS (col_int) VIRTUAL,
vcol_time TIME(1) AS (col_time) VIRTUAL,
vcol_date DATE AS (col_date) VIRTUAL,
vcol_enum SET('','a','b','c','d','e','f','foo','bar') AS (col_enum) VIRTUAL,
UNIQUE(pk),
PRIMARY KEY(pk)
) ENGINE=MyISAM;
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source suite/vcol/inc/vcol_init_vars.pre
#------------------------------------------------------------------------------#
# Cleanup
--source suite/vcol/inc/vcol_cleanup.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
# Set the session storage engine
SET @@session.storage_engine = 'MyISAM';
##### Workarounds for known open engine specific bugs
# none
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/vcol/inc/vcol_keys.inc
#------------------------------------------------------------------------------#
# Execute storage engine specific tests
#------------------------------------------------------------------------------#
# Cleanup
--source suite/vcol/inc/vcol_cleanup.inc
--disable_query_log
INSERT INTO t1 (col_date,col_datetime,col_int,col_varchar,col_timestamp,col_bit,col_blob,col_dec,col_time,col_year,col_char,col_enum) VALUES
(NULL,'2011-04-17 15:46:11.056462',6,'rsprn','1980-01-01 00:00:00',b'0001011111000111001110000110100110010101101','spr',0.0,'00:00:00',1988,'p',''),
('2007-05-18',NULL,5,'rnwg','2009-07-07 23:46:32.052699',b'01010','n',0.6,'04:35:56.018027',1995,'wgrpq',''),
('1994-03-16','2006-03-15 22:48:25.013225',7,'grpquarw','2034-05-17 10:51:23.048265',b'0001011101001011000111101','rp',0.3,'15:13:22.043368',2004,'pq',''),
('1980-01-01','1987-06-01 04:14:04.027480',1,'qu','1989-07-05 09:46:16.038513',b'001111011000100011100111010100101010000100010100101','uar',0.6,'11:56:35.031314',1986,'',''),
('2014-08-16','2021-01-08 20:59:16.041252',0,'arw','2022-12-20 22:48:53.014627',b'110110101100001011001110110100','m',0.6,'17:26:26.039855',2008,'rw',''),
('1981-12-02','1992-02-10 09:29:41.028674',6,'wk','2017-09-25 10:37:25.043516',b'010101001110111010101001101000101010',NULL,0.7,'00:00:00',2035,'kaz',''),
('2022-11-11','2029-03-07 17:24:19.043489',122,'a','1980-01-01 00:00:00',b'0001100111011','z',0.0,'10:23:45.050733',2018,'a',''),
('2004-03-12','1979-02-18 00:00:00',0,'zjeiwvd','1998-07-03 16:09:05.053954',b'0000110101111001001110100100111001111111100001110','',0.4,'07:43:46.015324',2028,'je',''),
('2016-08-08','1986-03-10 00:00:00',3,'eiwv','2025-08-07 12:24:53.040869',b'010001101110100111111','iw',0.3,'02:48:45.058781',2020,'',''),
('1979-02-25',NULL,2,'wvd','1980-01-01 00:00:00',b'010','vdm',0.1,'13:35:24.021296',1995,'dmd',''),
('2012-04-19','2034-10-06 23:29:21.057367',9,'mdiv','2022-05-16 05:28:40.005808',b'110111111101000010011011001','divj',0.3,'11:24:50.017885',1997,'iv',''),
('2009-10-13','1997-01-21 13:04:34.011524',1,'vjqs','1980-01-01 00:00:00',b'11110011100101011100001110110000101001100010000011110110011','j',0.7,'00:00:00',2008,'qsxmh',''),
('2012-01-01','2011-06-23 06:11:33.014723',9,'r','2022-04-27 05:29:32.023395',b'1001011010101100100111','',0.5,'03:34:01.048002',1976,'sx',''),
('2007-08-24','2012-01-24 22:16:53.014811',2,'fpp','2005-10-11 08:58:32.021273',b'011011111011',NULL,0.4,'18:11:17.036115',2026,'m',''),
(NULL,'1985-05-28 00:00:00',7,'hjw','2030-06-10 10:15:54.061818',b'0011110101001100011011000101010','',0.5,'02:03:21.020237',1994,'z',''),
('2006-09-09','2002-11-10 06:16:27.008631',0,'jw','2030-07-16 00:00:00',b'11101110111101000010101110000010001110110001001101110100','wa',0.8,'00:00:00',1974,'',''),
('1993-04-22','1980-01-01 00:00:00',3,'a','2020-02-06 08:11:00.051515',b'001110110010','gew',0.4,'11:59:05.013933',1998,NULL,''),
('1985-11-05','2019-12-24 04:13:43.062741',7,'foo','1986-07-02 00:00:00',b'10100110001010100011111111101011011101001110010110101100110000','',0.5,'17:32:55.060182',1978,'w',''),
('2007-02-20','2033-10-16 18:47:42.006517',1,'clc','1971-10-14 00:00:00',b'100001010','',0.1,'20:38:42.062598',2004,'lcfy',''),
('1979-12-10','1972-08-04 00:00:00',8,'','2021-12-24 04:51:09.011443',b'011010010010010010011101000010110011110110110010100010','e',0.1,'23:08:10.014396',2026,'cfykywl',''),
('2002-07-04',NULL,NULL,'fyky','1980-11-02 00:00:00',b'10000010111010000110','f',0.6,'13:07:14.014203',1979,'ykywl',''),
('2019-02-15','2004-08-28 10:16:46.053753',8,'kywl','2004-12-01 00:00:00',b'010111010110001110110011000010110111011','ywlcne',0.2,'09:10:39.028897',2031,'wlcnemiuaab',''),
('1989-05-15','1973-09-04 00:00:00',2,'lcne',NULL,b'100001100101110110000011110','',0.9,'19:22:16.015548',2013,'cnemiuaa',''),
('2023-04-20','2018-12-04 04:19:46.040664',8,NULL,'1985-04-18 05:32:12.013509',b'111011011111100100000001','nem',0.1,'23:18:05.007794',2026,'emiua',''),
(NULL,'2024-08-10 03:52:31.047182',2,'miua','2035-09-03 06:07:22.008308',b'000111','',0.1,'03:58:02.003946',1988,'iua',''),
('1977-09-01','1987-02-01 03:44:00.061840',5,'u','1997-11-27 04:02:13.014551',b'111110001001100101101000100010001011101000011',NULL,0.3,'00:00:00',1985,'aab',''),
(NULL,'1980-01-01 00:00:00',6,'a','1989-03-02 09:07:11.058643',b'10101001011110110010111010010100001010000110000110010',NULL,0.8,'17:41:15.057101',1975,'br',''),
('1980-01-01','2019-02-10 20:56:51.063985',NULL,'rr','2000-02-28 01:38:27.004468',b'0101001011110001010001','rifnhu',0.5,'20:55:57.029281',1973,'if',''),
(NULL,'2019-04-15 02:13:03.019581',7,'fnhu','2000-03-25 18:48:46.063113',b'011000110','nhuu',0.0,'00:00:00',2030,'h',''),
('1997-04-01',NULL,3,NULL,'1976-05-22 04:48:42.013754',b'101110101010000111101',NULL,0.1,'12:09:48.030076',2031,'u',''),
(NULL,'1993-10-10 15:11:03.021823',NULL,'ufzasunkrcpvasdqkxbwptigbpnesqigwegcnfeuvrgnecpthm','1986-06-12 04:29:01.017855',b'11110','fza',0.9,NULL,1994,'zasun',''),
('1997-02-13','2001-04-08 02:01:53.018388',0,'as','1975-09-18 00:00:00',b'00111000101001001101001000100100010101110011010111000001011011','su',0.3,'15:15:31.011102',1972,'unk',''),
('1975-07-26','2022-12-24 00:00:00',0,'foo','1986-01-22 21:27:38.024505',b'1111110000000001000010111','krc',0.9,'05:46:08.055789',1996,'rcp',''),
('2000-08-04','1980-01-01 00:00:00',48,'foo','2015-12-21 17:04:06.008790',b'0100001110011001011101011101110110100010000101101100011010','g',0.7,'18:31:50.046211',2025,'pvasdq',''),
('2001-03-26','2032-03-19 13:15:13.063368',NULL,'foo','2026-09-05 02:46:10.026919',b'11','a',0.3,'03:12:20.039599',2019,'sdqkx',''),
('2035-01-14','1987-09-15 05:46:00.041527',4,'p','1980-01-01 00:00:00',b'1111100111','dqkxbwpt',0.0,'09:57:41.059145',1995,'q',''),
('2035-07-13','2011-04-13 04:05:14.025091',212,'kxbw','1985-02-14 11:58:32.002055',b'1010100011110101011111111011010','x',0.2,'19:35:02.024655',1975,'bwptig',''),
('2026-02-08','2015-05-04 09:31:22.017074',4,'wpt','2024-01-26 11:06:03.057899',b'011000010000100000011000011011000100101111001100000111011010','ptig',0.0,'00:00:00',1977,'tig',''),
('1981-05-11',NULL,NULL,'foo','1981-12-09 10:10:34.008107',b'01000100100100110011111','gbp',0.0,'13:05:42.035253',2019,'bpn',''),
('1977-05-16',NULL,9,'pne',NULL,b'001101100111001110110010111001110100','s',0.0,'15:09:37.063819',1998,'ne',''),
('1980-01-01','2018-12-02 00:27:35.056455',2,'','1981-07-07 23:39:32.028644',b'0000101001010111010001101000','es',0.3,'15:43:30.016638',2013,NULL,''),
('2027-09-05','1998-05-14 04:15:42.009728',1,'s','2015-07-16 00:00:00',b'01011101101010000110011010000111001000001000011','',0.6,'08:39:24.041879',2035,'qigweg',''),
('2005-02-04',NULL,2,'i','1974-01-11 11:02:16.024653',b'01001101110001001101101010011001001101010010000','gw',0.6,'03:28:30.012172',1978,'weg',''),
(NULL,'1976-06-21 00:00:00',5,NULL,'2023-11-25 15:49:52.021725',b'101011010001100','e',0.1,'00:00:00',1977,'gcn',''),
('1989-07-13',NULL,1,'c','1978-02-22 02:55:14.047104',b'01101010100001100110111011101000111011101101110011','f',0.8,NULL,1987,'nfeu',''),
('2004-04-27','2019-06-28 08:04:35.039213',0,'f','1990-01-09 14:22:27.065127',b'00101001011','eu',0.0,'13:33:09.039791',2007,'uvrgne',''),
('2008-09-08','1990-11-05 00:00:00',1,'w','2026-12-23 00:00:00',b'0001101','vrgnec',0.3,'19:13:14.037732',1983,'d',''),
('2026-08-12','2026-11-23 11:18:35.012315',4,'rgnec','1988-09-06 07:11:55.057710',b'11010111001001101100100010110011100001000100001011000000000010','',0.9,NULL,1982,'gnecpth',''),
('1992-12-03','2033-08-18 04:47:11.033829',65,'n','1989-11-21 17:42:13.012747',b'11011011110000000',NULL,0.9,'10:08:34.006377',1971,'ecpth',''),
('1976-10-11','1975-05-18 00:00:00',3,'c','2017-11-06 03:33:38.002741',b'0111100010000111000111111100111100111000101100111111100','p',0.7,'03:28:07.039921',2014,'thmhf',''),
('2014-04-19','2023-08-07 16:18:59.024013',0,'','2006-05-04 23:01:46.019351',b'0101101011011101101011101110000001001000110100101000011001110','h',0.5,'00:00:00',1995,'m',''),
('1990-07-16','1980-01-01 00:00:00',8,'hffqbythjwpukqubzpomntrddrwhzjtqvb','1985-08-04 05:33:20.030471',b'001101111111100110101111000011100','ff',0.0,'00:00:00',2002,'fqbythj',''),
(NULL,'2019-01-12 00:00:00',0,NULL,'2009-01-25 00:00:00',b'100111111010000110010011100100000011101001010101111','qb',0.4,'20:35:33.059895',1981,'byt',''),
('1991-10-07',NULL,2,'yt','2027-04-19 06:38:46.020191',b'001','t',0.4,'10:02:06.014126',2004,'h',''),
(NULL,'2009-07-05 00:00:00',241,'j','1981-06-26 12:35:20.061910',b'10101110001101001000011010010111000','wpukqu',0.5,'00:00:00',1973,'pukqu',''),
('2001-05-26','2007-01-06 00:57:02.048605',0,'u',NULL,b'111100','k',0.7,'03:19:10.052988',2026,'q',NULL),
('2008-03-15','1990-09-11 00:00:00',5,'ubz','1980-01-01 00:00:00',b'11010111011110001101111000000011000111101100111','b',0.5,'00:34:27.006616',2013,NULL,''),
('1984-08-01','2000-09-20 09:35:47.025609',3,'zp','2016-11-22 19:38:52.053299',b'00000010','po',0.7,'19:47:19.014687',1996,'o',''),
('1978-02-05','1978-05-08 04:30:57.023271',7,'foo','2000-04-06 08:42:13.019650',b'11000110111100101010001110111101111000001101','n',0.8,NULL,1980,'trdd',''),
('2017-04-11','2002-09-26 12:59:43.051659',8,'rd','1972-03-27 13:09:07.017459',b'00011110001001001000000100110100101010','ddrwh',0.7,'00:00:00',2021,'drwhzj',''),
('1980-01-01','1986-05-04 05:15:19.008418',0,'r','2005-10-04 09:21:09.020131',b'1101100010101001010011010001011101001111110010101111011','wh',0.0,'00:00:00',1975,'hzjtqv',''),
('2035-12-12','1980-01-01 00:00:00',0,'x',NULL,b'0010000101010110111100000110000010001000100001000110111000010110','zjt',0.4,'15:51:12.040679',1984,'jtqvbji',''),
('1993-05-12','2000-11-11 20:54:49.053753',0,'tqvb','2022-02-26 14:26:36.004981',b'110000101110000111011','qv',0.7,'00:00:00',1972,'v',''),
('1971-08-22','2029-02-15 16:39:35.007278',2,NULL,'2033-09-22 08:28:19.057517',b'11111101011101110111100011011111001','bji',0.8,'08:34:37.000701',2000,'o',''),
(NULL,NULL,5,'foo','1982-02-24 00:00:00',b'00111111000111111111010111010111011101','iklce',0.8,'01:23:11.014485',2021,'klcek',''),
(NULL,NULL,8,'lce','1988-07-28 11:48:23.011427',b'101101000101010000000100000001011','',0.3,'17:15:34.034697',1991,'cekxqy',''),
('2029-12-07','1993-12-24 00:45:29.060155',3,'ekx','1980-01-01 00:00:00',b'01001010110110000100100100111010110000000101001011111110001100','q',0.7,'10:39:47.004022',2006,'foo',''),
('2015-10-20','1980-01-01 00:00:00',189,'xqy','2028-12-19 00:00:00',b'101001011011100101110010101000101110100110','qy',0.5,'15:16:59.059052',1993,'foo',''),
('1998-08-07','2017-08-07 01:53:34.056737',5,'oxsolbx',NULL,b'1000111010110010110','xsolbxth',0.3,'22:56:09.003450',2014,'s',''),
('2016-01-25','2000-09-14 22:35:41.048328',6,'foo','2004-10-11 00:00:00',b'001','olbxt',0.0,'14:15:54.033066',1983,'lbxt',''),
('1979-09-02','2027-01-19 09:34:15.034597',4,'bxth','1989-10-23 09:11:09.055445',b'011011001110000011011011',NULL,0.8,'05:31:31.006489',1978,'xthdc',''),
('1980-01-01',NULL,8,'th','2012-02-07 00:00:00',b'00101011001100111001101011010110','hdc',0.0,'22:09:17.054381',2013,'dcprs',''),
(NULL,'2018-08-03 17:37:14.049040',2,'cprswpj','1990-07-28 07:56:50.026324',b'0000010111011110100100010010011011010010001111011010000010011101','',0.1,NULL,1971,'prswpjx',''),
('1984-05-07','2012-05-07 00:00:00',1,'rswp','2030-05-09 07:42:25.003848',b'1001','swp',0.4,'13:27:32.040813',1997,'wpj',''),
(NULL,'2030-03-22 14:03:46.000742',7,'pjxixm','2022-05-11 00:00:00',b'00111110011001010010001111010001111110010010000111','j',0.8,'00:00:00',1996,'x',NULL),
('2000-12-03','2020-08-13 16:03:09.041436',8,'ix','1985-05-19 11:28:09.002728',b'11011010000101000110111111010111','xmvfwm',0.9,'19:06:00.002417',1976,'m',''),
('1990-03-13','2035-09-08 21:29:04.011731',5,'vfwmsys','2029-11-03 04:28:54.058532',b'0110001011001010100','fw',0.6,'20:30:32.032224',1994,'wmsys',''),
('2035-06-04','2027-06-07 11:27:21.038934',8,'ms','1987-09-02 00:00:00',b'001101101101111110010110110011','syse',0.1,'01:10:53.060943',2027,'yse',''),
(NULL,'1993-06-06 07:29:56.029103',NULL,'','1971-06-08 23:51:55.054403',b'11001110001111111001001010101110111011000100111010','se',0.2,'10:24:53.013058',1995,'eb',''),
('2018-06-12','2020-08-06 23:47:35.060301',5,NULL,NULL,b'110011110111010111','blwc',0.6,NULL,1971,'lwc',''),
('2005-02-03','2016-10-11 00:00:00',0,'w','2005-03-25 00:00:00',b'0101001001001','',0.2,'21:56:26.025743',1971,'c',''),
('2025-10-10',NULL,1,'vumvyv','2034-05-06 18:17:26.004829',b'10110101101100100001000011001111100100111101100','um',0.3,'19:42:29.005509',1992,'m',''),
('2014-01-27','1980-01-01 00:00:00',2,'vyvb','1975-04-08 10:13:06.052060',b'111011110111111010011111011011101111','yv',0.4,'15:13:32.059509',2011,NULL,''),
('2016-08-04','2008-12-03 01:55:41.030042',6,'vb','1993-09-08 00:01:40.016566',b'000101110101100111001101010110','b',0.5,'08:39:05.055786',1993,'it',''),
('1980-01-01','1980-01-01 00:00:00',9,'tx','1991-07-19 05:37:43.056696',b'110110111010111101010001100010111100110011111010100100100','k',0.9,'00:00:00',1999,'h',''),
(NULL,'2007-06-14 15:47:29.017306',9,'foo',NULL,b'0100111000001011111000111010000011011000011000101010','qjxdzd',0.3,'13:52:31.035851',2001,'jxdzd',''),
(NULL,'2022-04-28 18:27:19.060240',4,'foo','2018-02-28 02:49:16.013066',b'10000100000000110011011110101110100001100011101110011011100','d',0.0,'15:01:48.022368',1987,'zdytun',''),
('1987-10-10','1975-06-02 02:47:57.012240',9,'dy','1980-06-10 00:00:00',b'110000111','',0.7,'08:13:44.003967',1981,'',''),
('2015-09-28',NULL,4,'d','2005-08-09 08:35:04.039832',b'00','b',0.1,'00:47:43.048164',1973,'yt',''),
('2030-01-18','2011-12-09 00:00:00',6,NULL,'1982-05-13 00:00:00',b'111110100001000010001110110010111100001011010','v',0.2,'00:39:24.001557',2027,'tun',''),
('1980-06-28','2016-04-07 00:00:00',8,'y','1980-01-01 00:00:00',b'01011100100001010110101110111110110','unq',0.7,'00:00:00',2016,'foo',''),
('2018-09-16','1975-01-03 00:00:00',NULL,'qv','2028-05-10 00:00:00',b'0001100101001011100110','vv',0.0,'23:54:42.064230',2000,'vr',''),
('2033-12-11','2021-07-23 12:20:17.025201',3,'rm','1996-07-16 00:00:00',b'1011001110','mpyx',0.7,'04:04:01.055956',2009,'pyx',''),
('1982-12-18','1996-09-16 00:00:00',9,'yx','2003-10-14 03:54:44.012072',b'11001011011000001111011000101111101110100101','x',0.9,NULL,1981,'rencqh',''),
('1980-01-01','2009-01-17 12:11:34.030449',7,'encqh','1980-01-01 00:00:00',b'1101001101001000101010001100100100','ncq',0.4,'23:44:22.012217',2030,'b',''),
('2015-05-03','1987-03-19 17:37:53.053429',6,'','2012-08-03 00:00:00',b'0','cq',0.0,'17:16:43.030750',2035,'qh',NULL),
(NULL,'1980-01-01 00:00:00',1,'huyr','2012-02-11 14:15:13.004778',b'110011001100010100001101011001011110010000011001110101','',0.7,'09:33:00.034425',2024,'uyr',''),
('2019-06-05','2020-08-05 23:53:07.028129',1,'yr',NULL,b'1001011110101010001111101000011001011111100','rflu',0.3,NULL,2016,'fluezqe',''),
('1980-01-10','2025-05-12 08:22:39.039097',1,'lu','1975-07-24 00:00:00',b'10100111001111101001110000110011','',0.1,'23:58:28.031575',2005,NULL,''),
('2008-03-17','1982-05-27 11:44:53.038339',NULL,'uezqe','2024-10-12 02:16:04.063095',b'1001010110101101000101011011000011','e',0.9,'19:37:29.063243',1987,'zqekmq','')
;
--enable_query_log
--disable_warnings
ALTER TABLE t1 ADD INDEX(col_enum,vcol_int);
ALTER TABLE t1 ADD INDEX(col_year);
--enable_warnings
DROP TABLE t1;

View file

@ -1735,6 +1735,25 @@ SHOW CREATE TABLE `tab1`;
ALTER TABLE `tab1` CHANGE COLUMN v_col `v_col` varchar(128) AS (IF(field11='option1',CONCAT_WS(":","field1",field2,field3,field4,field5,field6,field7,field8,field9,field10), CONCAT_WS(":","field1",field11,field2,field3,field4,field5,field6,field7,field8,field9,field10))) PERSISTENT;
SHOW CREATE TABLE `tab1`;
DROP TABLE `tab1`;
--echo #
--echo # MDEV-11548 Reproducible server crash after the 2nd ALTER TABLE ADD FOREIGN KEY IF NOT EXISTS
--echo #
CREATE TABLE t1 (id INT UNSIGNED NOT NULL PRIMARY KEY);
CREATE TABLE t2 (id1 INT UNSIGNED NOT NULL);
ALTER TABLE t2
ADD FOREIGN KEY IF NOT EXISTS (id1)
REFERENCES t1 (id);
ALTER TABLE t2
ADD FOREIGN KEY IF NOT EXISTS (id1)
REFERENCES t1 (id);
DROP TABLE t2;
DROP TABLE t1;
--echo #
--echo # Start of 10.1 tests
--echo #

View file

@ -1484,3 +1484,24 @@ ORDER BY a, dist, b;
DROP VIEW edges2;
DROP TABLE edges;
--echo #
--echo # MDEV-11674: recursive CTE table that cannot be stored
--echo # in a heap table
--echo #
create table t1 (id int, test_data varchar(36));
insert into t1(id, test_data)
select id, test_data
from (
with recursive data_generator(id, test_data) as (
select 1 as id, uuid() as test_data
union all
select id + 1, uuid() from data_generator where id < 150000
)
select * from data_generator
) as a;
drop table t1;

View file

@ -359,6 +359,8 @@ insert into t1 (b) values(2);
insert into t1 (a,b) values(3,4);
select * from t1;
drop table t1;
CREATE OR REPLACE TABLE t1 (a INT DEFAULT @v); drop table t1;
CREATE TABLE t1 (a INT DEFAULT @v:=1); drop table t1;
--echo #
--echo # Error handling
@ -407,12 +409,6 @@ CREATE TABLE t1 (a INT DEFAULT(?));
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
CREATE TABLE t1 (a INT DEFAULT (b), b INT DEFAULT(a));
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT @v);
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT @v:=1);
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a INT DEFAULT(NAME_CONST('xxx', 'yyy'));

View file

@ -1,3 +1,4 @@
--source include/not_valgrind.inc
--disable_ps_protocol
SET GLOBAL net_write_timeout = 900;

View file

@ -7,8 +7,5 @@ loose-thread_pool_max_threads= 2
extra-port= @ENV.MASTER_EXTRA_PORT
extra-max-connections=1
[client]
connect-timeout= 2
[ENV]
MASTER_EXTRA_PORT= @OPT.port

View file

@ -15,23 +15,26 @@ SET optimizer_switch=@save_optimizer_switch;
# connections on the extra port.
# First set two connections running, and check that extra connection
# on normal port fails due to--thread-pool-max_threads=2
connection default;
# on normal port fails due to --thread-pool-max-threads=2.
# We can afford using a really long sleep, because we won't wait
# till it ends, we'll interrupt it as soon as we don't need it anymore
# Sleep for slightly longer than 5 sec to trigger MDEV-4566
# (abort in interruptible wait connection check)
send SELECT sleep(5.5);
connection default;
--let $con1_id= `SELECT CONNECTION_ID()`
send SELECT sleep(50);
--sleep 1
connect(con2,localhost,root,,);
connection con2;
send SELECT sleep(5);
--let $con2_id= `SELECT CONNECTION_ID()`
send SELECT sleep(50);
--sleep 0.5
--disable_abort_on_error
--disable_result_log
--disable_query_log
connect(con3,localhost,root,,);
connect(con3,localhost,root,,,,,connect_timeout=2);
--enable_query_log
--enable_result_log
--enable_abort_on_error
@ -45,24 +48,15 @@ if ($error)
--echo # -- Success: more than --thread_pool_max_threads normal connections not possible
}
connection default;
--reap
connection con2;
--reap
# Now try again, but this time use the extra port to successfully connect.
connection default;
send SELECT sleep(5);
connection con2;
send SELECT sleep(5);
--sleep 1
connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connection extracon;
SELECT 'Connection on extra port ok';
# Here, sleep just for slightly longer than 5 sec to trigger MDEV-4566
# (abort in interruptible wait connection check).
send SELECT sleep(5.5);
connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connection extracon2;
SELECT 'Connection on extra port 2 ok';
@ -70,7 +64,7 @@ SELECT 'Connection on extra port 2 ok';
--disable_abort_on_error
--disable_result_log
--disable_query_log
connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,,connect_timeout=2);
--enable_query_log
--enable_result_log
--enable_abort_on_error
@ -84,7 +78,16 @@ if ($error)
--echo # -- Success: more than --extra-max-connections + 1 normal connections not possible
}
connection extracon2;
--replace_result $con1_id <default_connection_ID>
eval KILL QUERY $con1_id;
--replace_result $con2_id <con2_connection_ID>
eval KILL QUERY $con2_id;
connection default;
--reap
connection con2;
--reap
connection extracon;
--reap

View file

@ -414,3 +414,33 @@ SELECT f1();
DROP FUNCTION f1;
DROP VIEW v1;
DROP TABLE t1,t2;
--echo #
--echo # Bug #16672723 "CAN'T FIND TEMPORARY TABLE".
--echo #
CREATE FUNCTION f1() RETURNS INT RETURN 1;
CREATE TEMPORARY TABLE tmp1(a INT);
PREPARE stmt1 FROM "CREATE TEMPORARY TABLE tmp2 AS SELECT b FROM (SELECT f1() AS b FROM tmp1) AS t";
--echo # The below statement failed before the fix.
EXECUTE stmt1;
DROP TEMPORARY TABLES tmp1, tmp2;
DEALLOCATE PREPARE stmt1;
DROP FUNCTION f1;
#
# MDEV-9084 Calling a stored function from a nested select from temporary table causes unpredictable behavior
#
delimiter $$;
create procedure sp1()
begin
drop table if exists t1, t2;
create temporary table t1 select 1 v;
create table t2 (col varchar(45)) select distinct col from (select sf1() as col from t1) t;
end$$
delimiter ;$$
create function sf1() returns text return 'blah';
call test.sp1();
call test.sp1();
drop procedure sp1;
drop function sf1;
drop table t2;

View file

@ -5702,6 +5702,28 @@ drop table t1, t2;
--error ER_BAD_FIELD_ERROR
SELECT 1 FROM (SELECT 1 as a) AS b HAVING (SELECT `SOME_GARBAGE`.b.a)=1;
--echo #
--echo # MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1
--echo # FOR UPDATE
--echo #
CREATE TABLE t1 (a INT);
insert into t1 values (1),(2);
CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE;
SHOW CREATE VIEW v1;
select * from v1;
DROP VIEW v1;
CREATE VIEW v1 AS SELECT * FROM t1 LOCK IN SHARE MODE;
SHOW CREATE VIEW v1;
select * from v1;
DROP VIEW v1;
DROP TABLE t1;
--echo # -----------------------------------------------------------------
--echo # -- End of 10.0 tests.
--echo # -----------------------------------------------------------------

View file

@ -357,6 +357,17 @@
fun:_dl_init
}
# This one is on OpenSuse 10.3 with gcc 5.4
{
memory "loss" from _dl_init 2
Memcheck:Leak
fun:malloc
fun:pool
...
fun:call_init*
fun:_dl_init
}
#
# dlclose can allocate memory for error message, the memory will be
# freed by dlerror or other dl* function.
@ -1064,6 +1075,16 @@
fun:SSL_library_init
}
{
OpenSSL still reachable.
Memcheck:Leak
fun:*alloc
fun:CRYPTO_malloc
fun:sk_new
fun:SSL_COMP_get_compression_methods
fun:SSL_library_init
}
{
libcrypto 2.2.1 leak
Memcheck:Leak

View file

@ -42,6 +42,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c my_default.c
my_atomic.c my_getncpus.c my_safehash.c my_chmod.c my_rnd.c
my_uuid.c wqueue.c waiting_threads.c ma_dyncol.c ../sql-common/my_time.c
my_rdtsc.c my_context.c psi_noop.c
my_atomic_writes.c
file_logger.c)
IF (WIN32)
@ -96,6 +97,10 @@ ADD_EXECUTABLE(thr_timer thr_timer.c)
TARGET_LINK_LIBRARIES(thr_timer mysys)
SET_TARGET_PROPERTIES(thr_timer PROPERTIES COMPILE_FLAGS "-DMAIN")
ADD_EXECUTABLE(test_hash hash.c)
TARGET_LINK_LIBRARIES(test_hash mysys)
SET_TARGET_PROPERTIES(test_hash PROPERTIES COMPILE_FLAGS "-DMAIN")
IF(MSVC)
INSTALL_DEBUG_TARGET(mysys DESTINATION ${INSTALL_LIBDIR}/debug)
ENDIF()

View file

@ -23,14 +23,15 @@
#include <m_ctype.h>
#include "hash.h"
#define NO_RECORD ((uint) -1)
#define NO_RECORD ~((my_hash_value_type) 0)
#define LOWFIND 1
#define LOWUSED 2
#define HIGHFIND 4
#define HIGHUSED 8
typedef struct st_hash_info {
uint next; /* index to next key */
uint32 next; /* index to next key */
my_hash_value_type hash_nr;
uchar *data; /* data for current entry */
} HASH_LINK;
@ -196,13 +197,10 @@ static uint my_hash_mask(my_hash_value_type hashnr, size_t buffmax,
return (uint) (hashnr & ((buffmax >> 1) -1));
}
static uint my_hash_rec_mask(const HASH *hash, HASH_LINK *pos,
size_t buffmax, size_t maxlength)
static inline uint my_hash_rec_mask(HASH_LINK *pos,
size_t buffmax, size_t maxlength)
{
size_t length;
uchar *key= (uchar*) my_hash_key(hash, pos->data, &length, 0);
return my_hash_mask(hash->hash_function(hash->charset, key, length), buffmax,
maxlength);
return my_hash_mask(pos->hash_nr, buffmax, maxlength);
}
@ -248,13 +246,13 @@ uchar* my_hash_first(const HASH *hash, const uchar *key, size_t length,
HASH_SEARCH_STATE *current_record)
{
uchar *res;
if (my_hash_inited(hash))
res= my_hash_first_from_hash_value(hash,
hash->hash_function(hash->charset, key,
length ? length : hash->key_length),
key, length, current_record);
else
res= 0;
DBUG_ASSERT(my_hash_inited(hash));
res= my_hash_first_from_hash_value(hash,
hash->hash_function(hash->charset, key,
length ? length :
hash->key_length),
key, length, current_record);
return res;
}
@ -266,14 +264,13 @@ uchar* my_hash_first_from_hash_value(const HASH *hash,
HASH_SEARCH_STATE *current_record)
{
HASH_LINK *pos;
uint flag,idx;
DBUG_ENTER("my_hash_first_from_hash_value");
flag=1;
if (hash->records)
{
idx= my_hash_mask(hash_value,
hash->blength, hash->records);
uint flag= 1;
uint idx= my_hash_mask(hash_value,
hash->blength, hash->records);
do
{
pos= dynamic_element(&hash->array,idx,HASH_LINK*);
@ -286,7 +283,7 @@ uchar* my_hash_first_from_hash_value(const HASH *hash,
if (flag)
{
flag=0; /* Reset flag */
if (my_hash_rec_mask(hash, pos, hash->blength, hash->records) != idx)
if (my_hash_rec_mask(pos, hash->blength, hash->records) != idx)
break; /* Wrong link */
}
}
@ -378,15 +375,19 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
my_bool my_hash_insert(HASH *info, const uchar *record)
{
int flag;
size_t idx,halfbuff,first_index;
my_hash_value_type hash_nr;
uchar *UNINIT_VAR(ptr_to_rec),*UNINIT_VAR(ptr_to_rec2);
uint idx, halfbuff, first_index;
size_t length;
my_hash_value_type current_hash_nr, UNINIT_VAR(rec_hash_nr),
UNINIT_VAR(rec2_hash_nr);
uchar *UNINIT_VAR(rec_data),*UNINIT_VAR(rec2_data), *key;
HASH_LINK *data,*empty,*UNINIT_VAR(gpos),*UNINIT_VAR(gpos2),*pos;
key= (uchar*) my_hash_key(info, record, &length, 1);
current_hash_nr= info->hash_function(info->charset, key, length);
if (info->flags & HASH_UNIQUE)
{
uchar *key= (uchar*) my_hash_key(info, record, &idx, 1);
if (my_hash_search(info, key, idx))
if (my_hash_search_using_hash_value(info, current_hash_nr, key, length))
return(TRUE); /* Duplicate entry */
}
@ -402,8 +403,9 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
{
do
{
my_hash_value_type hash_nr;
pos=data+idx;
hash_nr=rec_hashnr(info,pos->data);
hash_nr= pos->hash_nr;
if (flag == 0) /* First loop; Check if ok */
if (my_hash_mask(hash_nr, info->blength, info->records) != first_index)
break;
@ -413,17 +415,19 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
{
if (flag & HIGHFIND)
{
flag=LOWFIND | HIGHFIND;
flag= LOWFIND | HIGHFIND;
/* key shall be moved to the current empty position */
gpos=empty;
ptr_to_rec=pos->data;
gpos= empty;
rec_data= pos->data;
rec_hash_nr= pos->hash_nr;
empty=pos; /* This place is now free */
}
else
{
flag=LOWFIND | LOWUSED; /* key isn't changed */
gpos=pos;
ptr_to_rec=pos->data;
flag= LOWFIND | LOWUSED; /* key isn't changed */
gpos= pos;
rec_data= pos->data;
rec_hash_nr= pos->hash_nr;
}
}
else
@ -431,12 +435,14 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
if (!(flag & LOWUSED))
{
/* Change link of previous LOW-key */
gpos->data=ptr_to_rec;
gpos->next= (uint) (pos-data);
gpos->data= rec_data;
gpos->hash_nr= rec_hash_nr;
gpos->next= (uint) (pos-data);
flag= (flag & HIGHFIND) | (LOWFIND | LOWUSED);
}
gpos=pos;
ptr_to_rec=pos->data;
gpos= pos;
rec_data= pos->data;
rec_hash_nr= pos->hash_nr;
}
}
else
@ -445,20 +451,24 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
{
flag= (flag & LOWFIND) | HIGHFIND;
/* key shall be moved to the last (empty) position */
gpos2 = empty; empty=pos;
ptr_to_rec2=pos->data;
gpos2= empty;
empty= pos;
rec2_data= pos->data;
rec2_hash_nr= pos->hash_nr;
}
else
{
if (!(flag & HIGHUSED))
{
/* Change link of previous hash-key and save */
gpos2->data=ptr_to_rec2;
gpos2->next=(uint) (pos-data);
gpos2->data= rec2_data;
gpos2->hash_nr= rec2_hash_nr;
gpos2->next= (uint) (pos-data);
flag= (flag & LOWFIND) | (HIGHFIND | HIGHUSED);
}
gpos2=pos;
ptr_to_rec2=pos->data;
gpos2= pos;
rec2_data= pos->data;
rec2_hash_nr= pos->hash_nr;
}
}
}
@ -466,41 +476,44 @@ my_bool my_hash_insert(HASH *info, const uchar *record)
if ((flag & (LOWFIND | LOWUSED)) == LOWFIND)
{
gpos->data=ptr_to_rec;
gpos->next=NO_RECORD;
gpos->data= rec_data;
gpos->hash_nr= rec_hash_nr;
gpos->next= NO_RECORD;
}
if ((flag & (HIGHFIND | HIGHUSED)) == HIGHFIND)
{
gpos2->data=ptr_to_rec2;
gpos2->next=NO_RECORD;
gpos2->data= rec2_data;
gpos2->hash_nr= rec2_hash_nr;
gpos2->next= NO_RECORD;
}
}
/* Check if we are at the empty position */
idx= my_hash_mask(rec_hashnr(info, record), info->blength, info->records + 1);
pos=data+idx;
idx= my_hash_mask(current_hash_nr, info->blength, info->records + 1);
pos= data+idx;
/* Check if we are at the empty position */
if (pos == empty)
{
pos->data=(uchar*) record;
pos->next=NO_RECORD;
}
else
{
/* Check if more records in same hash-nr family */
empty[0]=pos[0];
gpos= data + my_hash_rec_mask(info, pos, info->blength, info->records + 1);
/* Move conflicting record to empty position (last) */
empty[0]= pos[0];
/* Check if the moved record was in same hash-nr family */
gpos= data + my_hash_rec_mask(pos, info->blength, info->records + 1);
if (pos == gpos)
{
pos->data=(uchar*) record;
pos->next=(uint) (empty - data);
/* Point to moved record */
pos->next= (uint32) (empty - data);
}
else
{
pos->data=(uchar*) record;
pos->next=NO_RECORD;
pos->next= NO_RECORD;
movelink(data,(uint) (pos-data),(uint) (gpos-data),(uint) (empty-data));
}
}
pos->data= (uchar*) record;
pos->hash_nr= current_hash_nr;
if (++info->records == info->blength)
info->blength+= info->blength;
return(0);
@ -557,15 +570,14 @@ my_bool my_hash_delete(HASH *hash, uchar *record)
else if (pos->next != NO_RECORD)
{
empty=data+(empty_index=pos->next);
pos->data=empty->data;
pos->next=empty->next;
pos[0]= empty[0];
}
if (empty == lastpos) /* last key at wrong pos or no next link */
if (empty == lastpos) /* last key at wrong pos or no next link */
goto exit;
/* Move the last key (lastpos) */
lastpos_hashnr=rec_hashnr(hash,lastpos->data);
lastpos_hashnr= lastpos->hash_nr;
/* pos is where lastpos should be */
pos= data + my_hash_mask(lastpos_hashnr, hash->blength, hash->records);
if (pos == empty) /* Move to empty position. */
@ -573,7 +585,7 @@ my_bool my_hash_delete(HASH *hash, uchar *record)
empty[0]=lastpos[0];
goto exit;
}
pos_hashnr=rec_hashnr(hash,pos->data);
pos_hashnr= pos->hash_nr;
/* pos3 is where the pos should be */
pos3= data + my_hash_mask(pos_hashnr, hash->blength, hash->records);
if (pos != pos3)
@ -616,23 +628,30 @@ exit:
my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
size_t old_key_length)
{
uint new_index,new_pos_index,records;
size_t idx, empty, blength;
uint new_index, new_pos_index, org_index, records, idx;
size_t length, empty, blength;
my_hash_value_type hash_nr;
HASH_LINK org_link,*data,*previous,*pos;
uchar *new_key;
DBUG_ENTER("my_hash_update");
new_key= (uchar*) my_hash_key(hash, record, &length, 1);
hash_nr= hash->hash_function(hash->charset, new_key, length);
if (HASH_UNIQUE & hash->flags)
{
HASH_SEARCH_STATE state;
uchar *found, *new_key= (uchar*) my_hash_key(hash, record, &idx, 1);
if ((found= my_hash_first(hash, new_key, idx, &state)))
uchar *found;
if ((found= my_hash_first_from_hash_value(hash, hash_nr, new_key, length,
&state)))
{
do
{
if (found != record)
DBUG_RETURN(1); /* Duplicate entry */
}
while ((found= my_hash_next(hash, new_key, idx, &state)));
while ((found= my_hash_next(hash, new_key, length, &state)));
}
}
@ -645,19 +664,24 @@ my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
(old_key_length ? old_key_length :
hash->key_length)),
blength, records);
new_index= my_hash_mask(rec_hashnr(hash, record), blength, records);
if (idx == new_index)
DBUG_RETURN(0); /* Nothing to do (No record check) */
org_index= idx;
new_index= my_hash_mask(hash_nr, blength, records);
previous=0;
for (;;)
{
if ((pos= data+idx)->data == record)
break;
previous=pos;
if ((idx=pos->next) == NO_RECORD)
DBUG_RETURN(1); /* Not found in links */
}
if (org_index == new_index)
{
data[idx].hash_nr= hash_nr; /* Hash number may have changed */
DBUG_RETURN(0); /* Record is in right position */
}
org_link= *pos;
empty=idx;
@ -692,21 +716,24 @@ my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
data[empty]= org_link;
}
data[empty].next= NO_RECORD;
data[empty].hash_nr= hash_nr;
DBUG_RETURN(0);
}
pos=data+new_index;
new_pos_index= my_hash_rec_mask(hash, pos, blength, records);
new_pos_index= my_hash_rec_mask(pos, blength, records);
if (new_index != new_pos_index)
{ /* Other record in wrong position */
data[empty] = *pos;
data[empty]= *pos;
movelink(data,new_index,new_pos_index, (uint) empty);
org_link.next=NO_RECORD;
data[new_index]= org_link;
data[new_index].hash_nr= hash_nr;
}
else
{ /* Link in chain at right position */
org_link.next=data[new_index].next;
data[empty]=org_link;
data[empty].hash_nr= hash_nr;
data[new_index].next= (uint) empty;
}
DBUG_RETURN(0);
@ -765,7 +792,7 @@ my_bool my_hash_iterate(HASH *hash, my_hash_walk_action action, void *argument)
}
#ifndef DBUG_OFF
#if !defined(DBUG_OFF) || defined(MAIN)
my_bool my_hash_check(HASH *hash)
{
@ -781,7 +808,15 @@ my_bool my_hash_check(HASH *hash)
for (i=found=max_links=seek=0 ; i < records ; i++)
{
if (my_hash_rec_mask(hash, data + i, blength, records) == i)
size_t length;
uchar *key= (uchar*) my_hash_key(hash, data[i].data, &length, 0);
if (data[i].hash_nr != hash->hash_function(hash->charset, key, length))
{
DBUG_PRINT("error", ("record at %d has wrong hash", i));
error= 1;
}
if (my_hash_rec_mask(data + i, blength, records) == i)
{
found++; seek++; links=1;
for (idx=data[i].next ;
@ -797,7 +832,7 @@ my_bool my_hash_check(HASH *hash)
}
hash_info=data+idx;
seek+= ++links;
if ((rec_link= my_hash_rec_mask(hash, hash_info,
if ((rec_link= my_hash_rec_mask(hash_info,
blength, records)) != i)
{
DBUG_PRINT("error", ("Record in wrong link at %d: Start %d "
@ -820,6 +855,71 @@ my_bool my_hash_check(HASH *hash)
DBUG_PRINT("info",
("records: %u seeks: %d max links: %d hitrate: %.2f",
records,seek,max_links,(float) seek / (float) records));
DBUG_ASSERT(error == 0);
return error;
}
#endif
#ifdef MAIN
#define RECORDS 1000
uchar *test_get_key(uchar *data, size_t *length,
my_bool not_used __attribute__((unused)))
{
*length= 2;
return data;
}
int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
{
uchar records[RECORDS][2], copy[2];
HASH hash_test;
uint i;
MY_INIT(argv[0]);
DBUG_PUSH("d:t:O,/tmp/test_hash.trace");
printf("my_hash_init\n");
if (my_hash_init2(&hash_test, 100, &my_charset_bin, 20,
0, 0, (my_hash_get_key) test_get_key, 0, 0, HASH_UNIQUE))
{
fprintf(stderr, "hash init failed\n");
exit(1);
}
printf("my_hash_insert\n");
for (i= 0 ; i < RECORDS ; i++)
{
int2store(records[i],i);
my_hash_insert(&hash_test, records[i]);
my_hash_check(&hash_test);
}
printf("my_hash_update\n");
for (i= 0 ; i < RECORDS ; i+=2)
{
memcpy(copy, records[i], 2);
int2store(records[i],i + RECORDS);
if (my_hash_update(&hash_test, records[i], copy, 2))
{
fprintf(stderr, "hash update failed\n");
exit(1);
}
my_hash_check(&hash_test);
}
printf("my_hash_delete\n");
for (i= 0 ; i < RECORDS ; i++)
{
if (my_hash_delete(&hash_test, records[i]))
{
fprintf(stderr, "hash delete failed\n");
exit(1);
}
my_hash_check(&hash_test);
}
my_hash_free(&hash_test);
printf("ok\n");
my_end(MY_CHECK_ERROR);
return(0);
}
#endif /* MAIN */

333
mysys/my_atomic_writes.c Normal file
View file

@ -0,0 +1,333 @@
/* Copyright (c) 2016, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "mysys_priv.h"
my_bool my_may_have_atomic_write= 0;
#ifdef __linux__
my_bool has_shannon_atomic_write= 0, has_fusion_io_atomic_write= 0;
#include <sys/ioctl.h>
/***********************************************************************
FUSION_IO
************************************************************************/
/** FusionIO atomic write control info */
#define DFS_IOCTL_ATOMIC_WRITE_SET _IOW(0x95, 2, uint)
/**
Check if the system has a funsion_io card
@return TRUE Card exists
*/
static my_bool test_if_fusion_io_card_exists()
{
/* Fusion card requires fallocate to exists */
#ifndef HAVE_POSIX_FALLOCATE
return 0;
#else
return (access("/dev/fcta", F_OK)) == 0;
#endif
}
/**
Check if a file is on a Fusion_IO device and that it supports atomic_write
@param[in] file OS file handle
@param[in] page_size page size
@return TRUE Atomic write supported
*/
static my_bool fusion_io_has_atomic_write(File file, int page_size)
{
int atomic= 1;
if (page_size <= 32768 &&
ioctl(file, DFS_IOCTL_ATOMIC_WRITE_SET, &atomic) != -1)
return(TRUE);
return(FALSE);
}
/***********************************************************************
SHANNON
************************************************************************/
#define SHANNON_IOMAGIC 'x'
#define SHANNON_IOCQATOMIC_SIZE _IO(SHANNON_IOMAGIC, 22)
#define SHANNON_MAX_DEVICES 32
#define SHANNON_NO_ATOMIC_SIZE_YET -2
struct shannon_dev
{
char dev_name[32];
dev_t st_dev;
int atomic_size;
};
static struct shannon_dev shannon_devices[SHANNON_MAX_DEVICES+1];
/**
Check if the system has a Shannon card
If card exists, record device numbers to allow us to later check if
a given file is on this device.
@return TRUE Card exists
*/
static my_bool test_if_shannon_card_exists()
{
uint shannon_found_devices= 0;
char dev_part;
uint dev_no;
if (access("/dev/scta", F_OK) < 0)
return 0;
/*
The Shannon devices are /dev/dfX, where X can be from a-z.
We have to check all of them as some may be missing if the user
removed one with the U.2 interface.
*/
for (dev_part= 'a' ; dev_part < 'z' ; dev_part++)
{
char path[32];
struct stat stat_buff;
sprintf(path, "/dev/df%c", dev_part);
#ifdef TEST_SHANNON
if (lstat(path, &stat_buff) < 0)
{
printf("%s(): lstat failed.\n", __func__);
break;
}
#endif
shannon_devices[shannon_found_devices].st_dev= stat_buff.st_rdev;
sprintf(shannon_devices[shannon_found_devices].dev_name, "/dev/sct%c",
dev_part);
#ifdef TEST_SHANNON
printf("%s(): i=%d, stat_buff.st_dev=0x%lx, stat_buff.st_rdev=0x%lx, st_rdev=0x%lx, dev_name=%s\n",
__func__,
shannon_found_devices,
(ulong) stat_buff.st_dev,
(ulong) stat_buff.st_rdev,
(ulong) shannon_devices[shannon_found_devices].st_dev,
shannon_devices[shannon_found_devices].dev_name);
#endif
/*
The atomic size will be checked on first access. This is needed
as a normal user can't open the /dev/scta file
*/
shannon_devices[shannon_found_devices].atomic_size=
SHANNON_NO_ATOMIC_SIZE_YET;
if (++shannon_found_devices== SHANNON_MAX_DEVICES)
goto end;
for (dev_no= 1 ; dev_no < 9 ; dev_no++)
{
sprintf(path, "/dev/df%c%d", dev_part, dev_no);
if (lstat(path, &stat_buff) < 0)
break;
shannon_devices[shannon_found_devices].st_dev= stat_buff.st_rdev;
sprintf(shannon_devices[shannon_found_devices].dev_name, "/dev/sct%c%d",
dev_part, dev_no);
#ifdef TEST_SHANNON
printf("%s(): i=%d, st_dev=0x%lx, st_rdev=0x%lx, dev_name=%s\n",
__func__,
shannon_found_devices,
(ulong) stat_buff.st_dev,
(ulong) shannon_devices[shannon_found_devices].st_dev,
shannon_devices[shannon_found_devices].dev_name);
#endif
/*
The atomic size will be checked on first access. This is needed
as a normal user can't open the /dev/scta file
*/
shannon_devices[shannon_found_devices].atomic_size=
SHANNON_NO_ATOMIC_SIZE_YET;
if (++shannon_found_devices == SHANNON_MAX_DEVICES)
goto end;
}
}
end:
shannon_devices[shannon_found_devices].st_dev= 0;
return shannon_found_devices > 0;
}
static my_bool shannon_dev_has_atomic_write(struct shannon_dev *dev,
int page_size)
{
#ifdef TEST_SHANNON
printf("%s: enter: page_size=%d, atomic_size=%d, dev_name=%s\n",
__func__,
page_size,
dev->atomic_size,
dev->dev_name);
#endif
if (dev->atomic_size == SHANNON_NO_ATOMIC_SIZE_YET)
{
int fd= open(dev->dev_name, 0);
if (fd < 0)
{
perror("open() failed!");
dev->atomic_size= 0; /* Don't try again */
return FALSE;
}
dev->atomic_size= ioctl(fd, SHANNON_IOCQATOMIC_SIZE);
close(fd);
}
#ifdef TEST_SHANNON
printf("%s: exit: page_size=%d, atomic_size=%d, dev_name=%s\n",
__func__,
page_size,
dev->atomic_size,
dev->dev_name);
#endif
return (page_size <= dev->atomic_size);
}
/**
Check if a file is on a Shannon device and that it supports atomic_write
@param[in] file OS file handle
@param[in] page_size page size
@return TRUE Atomic write supported
@notes
This is called only at first open of a file. In this case it's doesn't
matter so much that we loop over all cards.
We update the atomic size on first access.
*/
static my_bool shannon_has_atomic_write(File file, int page_size)
{
struct shannon_dev *dev;
struct stat stat_buff;
if (fstat(file, &stat_buff) < 0)
{
#ifdef TEST_SHANNON
printf("%s(): fstat failed\n", __func__);
#endif
return 0;
}
#ifdef TEST_SHANNON
printf("%s(): st_dev=0x%lx, st_rdev=0x%lx\n", __func__,
(ulong) stat_buff.st_dev, (ulong) stat_buff.st_rdev);
#endif
for (dev= shannon_devices ; dev->st_dev; dev++)
{
#ifdef TEST_SHANNON
printf("%s(): st_rdev=0x%lx\n", __func__, (ulong) dev->st_dev);
#endif
if (stat_buff.st_dev == dev->st_dev)
return shannon_dev_has_atomic_write(dev, page_size);
}
return 0;
}
/***********************************************************************
Generic atomic write code
************************************************************************/
/*
Initalize automic write sub systems.
Checks if we have any devices that supports atomic write
*/
void my_init_atomic_write(void)
{
if ((has_shannon_atomic_write= test_if_shannon_card_exists()) ||
(has_fusion_io_atomic_write= test_if_fusion_io_card_exists()))
my_may_have_atomic_write= 1;
#ifdef TEST_SHANNON
printf("%s(): has_shannon_atomic_write=%d, my_may_have_atomic_write=%d\n",
__func__,
has_shannon_atomic_write,
my_may_have_atomic_write);
#endif
}
/**
Check if a file supports atomic write
@return FALSE No atomic write support
TRUE File supports atomic write
*/
my_bool my_test_if_atomic_write(File handle, int page_size)
{
#ifdef TEST_SHANNON
printf("%s(): has_shannon_atomic_write=%d, my_may_have_atomic_write=%d\n",
__func__,
has_shannon_atomic_write,
my_may_have_atomic_write);
#endif
if (!my_may_have_atomic_write)
return 0;
if (has_shannon_atomic_write &&
shannon_has_atomic_write(handle, page_size))
return 1;
if (has_fusion_io_atomic_write &&
fusion_io_has_atomic_write(handle, page_size))
return 1;
return 0;
}
#ifdef TEST_SHANNON
int main()
{
int fd, ret;
my_init_atomic_write();
fd= open("/u01/1.file", O_RDWR);
ret= my_test_if_atomic_write(fd, 4096);
if (ret)
printf("support atomic_write\n");
else
printf("do not support atomic_write\n");
close(fd);
return 0;
}
#endif
#else /* __linux__ */
/* Dummy functions to provide the interfaces for other systems */
void my_init_atomic_write(void)
{
}
#endif /* __linux__ */

View file

@ -90,7 +90,7 @@ static my_bool defaults_already_read= FALSE;
/* Which directories are searched for options (and in which order) */
#define MAX_DEFAULT_DIRS 6
#define MAX_DEFAULT_DIRS 7
#define DEFAULT_DIRS_SIZE (MAX_DEFAULT_DIRS + 1) /* Terminate with NULL */
static const char **default_directories = NULL;
@ -1182,7 +1182,12 @@ static const char **init_default_directories(MEM_ROOT *alloc)
errors += add_directory(alloc, "C:/", dirs);
if (my_get_module_parent(fname_buffer, sizeof(fname_buffer)) != NULL)
{
errors += add_directory(alloc, fname_buffer, dirs);
strncat(fname_buffer, "/data", sizeof(fname_buffer));
errors += add_directory(alloc, fname_buffer, dirs);
}
}
#else

View file

@ -413,6 +413,7 @@ IF(WIN32)
${CMAKE_CURRENT_BINARY_DIR}/mysql_bootstrap_sql.c
COMPONENT Server
)
SET_TARGET_PROPERTIES(mysql_install_db PROPERTIES COMPILE_FLAGS -DINSTALL_PLUGINDIR=${INSTALL_PLUGINDIR})
TARGET_LINK_LIBRARIES(mysql_install_db mysys)
ADD_LIBRARY(winservice STATIC winservice.c)

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