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

Merge 11.0 into 11.1

This commit is contained in:
Marko Mäkelä
2023-06-08 14:09:21 +03:00
165 changed files with 4391 additions and 1929 deletions

2
.github/CODEOWNERS vendored
View File

@ -1,2 +0,0 @@
/debian @ottok

View File

@ -43,7 +43,7 @@ variables:
CMAKE_FLAGS: "-DWITH_SSL=system -DPLUGIN_COLUMNSTORE=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_S3=NO -DPLUGIN_MROONGA=NO -DPLUGIN_CONNECT=NO -DPLUGIN_MROONGA=NO -DPLUGIN_TOKUDB=NO -DPLUGIN_PERFSCHEMA=NO -DWITH_WSREP=OFF" CMAKE_FLAGS: "-DWITH_SSL=system -DPLUGIN_COLUMNSTORE=NO -DPLUGIN_ROCKSDB=NO -DPLUGIN_S3=NO -DPLUGIN_MROONGA=NO -DPLUGIN_CONNECT=NO -DPLUGIN_MROONGA=NO -DPLUGIN_TOKUDB=NO -DPLUGIN_PERFSCHEMA=NO -DWITH_WSREP=OFF"
# Major version dictates which branches share the same ccache. E.g. 10.6-abc # Major version dictates which branches share the same ccache. E.g. 10.6-abc
# and 10.6-xyz will have the same cache. # and 10.6-xyz will have the same cache.
MARIADB_MAJOR_VERSION: "11.0" MARIADB_MAJOR_VERSION: "11.1"
# NOTE! Currently ccache is only used on the Centos8 build. As each job has # NOTE! Currently ccache is only used on the Centos8 build. As each job has
# sufficiently different environments they are unable to benefit from each # sufficiently different environments they are unable to benefit from each
# other's ccaches. As each build generates about 1 GB of ccache, having # other's ccaches. As each build generates about 1 GB of ccache, having

View File

@ -317,7 +317,7 @@ ELSEIF(RPM MATCHES "sles")
ENDIF() ENDIF()
# MDEV-24629, we need it outside of ELSIFs # MDEV-24629, we need it outside of ELSIFs
IF(RPM MATCHES "fedora3[234]") IF(RPM MATCHES "fedora")
ALTERNATIVE_NAME("common" "mariadb-connector-c-config" ${MARIADB_CONNECTOR_C_VERSION}-1) ALTERNATIVE_NAME("common" "mariadb-connector-c-config" ${MARIADB_CONNECTOR_C_VERSION}-1)
ENDIF() ENDIF()

35
debian/additions/innotop/innotop vendored Normal file → Executable file
View File

@ -20,6 +20,9 @@
# Street, Fifth Floor, Boston, MA 02110-1335 USA # Street, Fifth Floor, Boston, MA 02110-1335 USA
use strict; use strict;
use warnings;
use utf8;
use feature ':5.16';
use warnings FATAL => 'all'; use warnings FATAL => 'all';
our $VERSION = '1.11.4'; our $VERSION = '1.11.4';
@ -265,7 +268,7 @@ sub get_dbh {
$dbh->do($sql); $dbh->do($sql);
MKDEBUG && _d('Enabling charset for STDOUT'); MKDEBUG && _d('Enabling charset for STDOUT');
if ( $charset eq 'utf8' ) { if ( $charset eq 'utf8' ) {
binmode(STDOUT, ':utf8') binmode(STDOUT, ':encoding(UTF-8)')
or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR"; or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
} }
else { else {
@ -612,6 +615,9 @@ sub ts_to_string {
sub parse_innodb_timestamp { sub parse_innodb_timestamp {
my $text = shift; my $text = shift;
if ( ! defined $text ) {
return (0, 0, 0, 0, 0, 0);
}
my ( $y, $m, $d, $h, $i, $s ) my ( $y, $m, $d, $h, $i, $s )
= $text =~ m/^(\d\d)(\d\d)(\d\d) +(\d+):(\d+):(\d+)$/; = $text =~ m/^(\d\d)(\d\d)(\d\d) +(\d+):(\d+):(\d+)$/;
die("Can't get timestamp from $text\n") unless $y; die("Can't get timestamp from $text\n") unless $y;
@ -803,7 +809,8 @@ sub parse_fk_transaction_error {
# TODO: write some tests for this # TODO: write some tests for this
sub parse_innodb_record_dump { sub parse_innodb_record_dump {
my ( $dump, $complete, $debug ) = @_; my ( $dump, $complete, $debug ) = @_;
return undef unless $dump; # Use bare return as recommend in page 199 of PBP
return unless $dump;
my $result = {}; my $result = {};
@ -6769,6 +6776,9 @@ sub set_precision {
my ( $num, $precision ) = @_; my ( $num, $precision ) = @_;
$num = 0 unless defined $num; $num = 0 unless defined $num;
$precision = $config{num_digits}->{val} if !defined $precision; $precision = $config{num_digits}->{val} if !defined $precision;
if ( $num eq "" ) {
$num = int(0);
}
sprintf("%.${precision}f", $num); sprintf("%.${precision}f", $num);
} }
@ -6777,6 +6787,9 @@ sub set_precision {
sub percent { sub percent {
my ( $num ) = @_; my ( $num ) = @_;
$num = 0 unless defined $num; $num = 0 unless defined $num;
if ( $num eq "" ) {
$num = int(0);
}
my $digits = $config{num_digits}->{val}; my $digits = $config{num_digits}->{val};
return sprintf("%.${digits}f", $num * 100) return sprintf("%.${digits}f", $num * 100)
. ($config{show_percent}->{val} ? '%' : ''); . ($config{show_percent}->{val} ? '%' : '');
@ -6841,7 +6854,7 @@ sub make_color_func {
push @criteria, push @criteria,
"( defined \$set->{$spec->{col}} && \$set->{$spec->{col}} $spec->{op} $val ) { return '$spec->{color}'; }"; "( defined \$set->{$spec->{col}} && \$set->{$spec->{col}} $spec->{op} $val ) { return '$spec->{color}'; }";
} }
return undef unless @criteria; return unless @criteria;
my $sub = eval 'sub { my ( $set ) = @_; if ' . join(" elsif ", @criteria) . '}'; my $sub = eval 'sub { my ( $set ) = @_; if ' . join(" elsif ", @criteria) . '}';
die if $EVAL_ERROR; die if $EVAL_ERROR;
return $sub; return $sub;
@ -7521,10 +7534,10 @@ sub choose_connections {
sub do_stmt { sub do_stmt {
my ( $cxn, $stmt_name, @args ) = @_; my ( $cxn, $stmt_name, @args ) = @_;
return undef if $file; return if $file;
# Test if the cxn should not even be tried # Test if the cxn should not even be tried
return undef if $dbhs{$cxn} return if $dbhs{$cxn}
&& $dbhs{$cxn}->{failed} && $dbhs{$cxn}->{failed}
&& ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} ); && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} );
@ -7596,10 +7609,10 @@ sub handle_cxn_error {
sub do_query { sub do_query {
my ( $cxn, $query ) = @_; my ( $cxn, $query ) = @_;
return undef if $file; return if $file;
# Test if the cxn should not even be tried # Test if the cxn should not even be tried
return undef if $dbhs{$cxn} return if $dbhs{$cxn}
&& $dbhs{$cxn}->{failed} && $dbhs{$cxn}->{failed}
&& ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} ); && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} );
@ -7781,7 +7794,7 @@ sub compile_select_stmt {
sub compile_filter { sub compile_filter {
my ( $text ) = @_; my ( $text ) = @_;
my ( $sub, $err ); my ( $sub, $err );
eval "\$sub = sub { my \$set = shift; $text }"; eval { $sub = sub { my $set = shift; $text } };
if ( $EVAL_ERROR ) { if ( $EVAL_ERROR ) {
$EVAL_ERROR =~ s/at \(eval.*$//; $EVAL_ERROR =~ s/at \(eval.*$//;
$sub = sub { return $EVAL_ERROR }; $sub = sub { return $EVAL_ERROR };
@ -8013,7 +8026,7 @@ sub load_config_plugins {
# First, find a list of all plugins that exist on disk, and get information about them. # First, find a list of all plugins that exist on disk, and get information about them.
my $dir = $config{plugin_dir}->{val}; my $dir = $config{plugin_dir}->{val};
foreach my $p_file ( <$dir/*.pm> ) { foreach my $p_file (glob($dir."/*.pm")) {
my ($package, $desc); my ($package, $desc);
eval { eval {
open my $p_in, "<", $p_file or die $OS_ERROR; open my $p_in, "<", $p_file or die $OS_ERROR;
@ -9192,7 +9205,7 @@ sub switch_var_set {
# edit_stmt_sleep_times {{{3 # edit_stmt_sleep_times {{{3
sub edit_stmt_sleep_times { sub edit_stmt_sleep_times {
$clear_screen_sub->(); $clear_screen_sub->();
my $stmt = prompt_list('Specify a statement', '', sub { return sort keys %stmt_maker_for }); my $stmt = prompt_list('Specify a statement', '', sub { my @tmparray = sort keys %stmt_maker_for; return @tmparray });
return unless $stmt && exists $stmt_maker_for{$stmt}; return unless $stmt && exists $stmt_maker_for{$stmt};
$clear_screen_sub->(); $clear_screen_sub->();
my $curr_val = $stmt_sleep_time_for{$stmt} || 0; my $curr_val = $stmt_sleep_time_for{$stmt} || 0;
@ -9843,7 +9856,7 @@ sub get_slave_status {
sub is_func { sub is_func {
my ( $word ) = @_; my ( $word ) = @_;
return defined(&$word) return defined(&$word)
|| eval "my \$x= sub { $word }; 1" || eval { my $x = sub { $word }; 1 }
|| $EVAL_ERROR !~ m/^Bareword/; || $EVAL_ERROR !~ m/^Bareword/;
} }

View File

@ -94,7 +94,6 @@ case "${LSBNAME}"
in in
# Debian # Debian
"buster") "buster")
add_lsb_base_depends
disable_libfmt disable_libfmt
replace_uring_with_aio replace_uring_with_aio
if [ ! "$architecture" = amd64 ] if [ ! "$architecture" = amd64 ]
@ -102,11 +101,10 @@ in
disable_pmem disable_pmem
fi fi
;& ;&
"bullseye"|"bookworm") "bullseye")
if [[ "${LSBNAME}" == "bullseye" ]]
then
add_lsb_base_depends add_lsb_base_depends
fi ;&
"bookworm")
# mariadb-plugin-rocksdb in control is 4 arches covered by the distro rocksdb-tools # mariadb-plugin-rocksdb in control is 4 arches covered by the distro rocksdb-tools
# so no removal is necessary. # so no removal is necessary.
if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]] if [[ ! "$architecture" =~ amd64|arm64|ppc64el ]]
@ -124,17 +122,17 @@ in
;; ;;
# Ubuntu # Ubuntu
"bionic") "bionic")
add_lsb_base_depends
remove_rocksdb_tools remove_rocksdb_tools
[ "$architecture" != amd64 ] && disable_pmem [ "$architecture" != amd64 ] && disable_pmem
;& ;&
"focal") "focal")
add_lsb_base_depends
replace_uring_with_aio replace_uring_with_aio
disable_libfmt disable_libfmt
;& ;&
"impish"|"jammy"|"kinetic"|"lunar") "jammy"|"kinetic")
add_lsb_base_depends add_lsb_base_depends
;&
"lunar"|"mantic")
# mariadb-plugin-rocksdb s390x not supported by us (yet) # mariadb-plugin-rocksdb s390x not supported by us (yet)
# ubuntu doesn't support mips64el yet, so keep this just # ubuntu doesn't support mips64el yet, so keep this just
# in case something changes. # in case something changes.

View File

@ -1,9 +1,15 @@
#!/bin/bash #!/bin/bash
set -e set -e
# shellcheck source=/dev/null
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
then
set -v -x
DEBIAN_SCRIPT_TRACE=1
fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
@ -21,7 +27,9 @@ case "$1" in
# and because changed configuration options should take effect immediately. # and because changed configuration options should take effect immediately.
# In case the server wasn't running at all it should be ok if the stop # In case the server wasn't running at all it should be ok if the stop
# script fails. I can't tell at this point because of the cleaned /run. # script fails. I can't tell at this point because of the cleaned /run.
set +e; invoke-rc.d mariadb stop; set -e set +e
invoke-rc.d mariadb stop
set -e
# An existing /etc/init.d/mysql might be on the system if there was a # An existing /etc/init.d/mysql might be on the system if there was a
# previous MySQL or MariaDB installation, since /etc/init.d files are # previous MySQL or MariaDB installation, since /etc/init.d files are
@ -61,21 +69,26 @@ case "$1" in
# If the following symlink exists, it is a preserved copy the old data dir # If the following symlink exists, it is a preserved copy the old data dir
# created by the preinst script during a upgrade that would have otherwise # created by the preinst script during a upgrade that would have otherwise
# been replaced by an empty mysql dir. This should restore it. # been replaced by an empty mysql dir. This should restore it.
for dir in DATADIR LOGDIR; do for dir in DATADIR LOGDIR
do
if [ "$dir" = "DATADIR" ]; then if [ "$dir" = "DATADIR" ]
then
targetdir=$mysql_datadir targetdir=$mysql_datadir
else else
targetdir=$mysql_logdir targetdir=$mysql_logdir
fi fi
savelink="$mysql_upgradedir/$dir.link" savelink="$mysql_upgradedir/$dir.link"
if [ -L "$savelink" ]; then if [ -L "$savelink" ]
then
# If the targetdir was a symlink before we upgraded it is supposed # If the targetdir was a symlink before we upgraded it is supposed
# to be either still be present or not existing anymore now. # to be either still be present or not existing anymore now.
if [ -L "$targetdir" ]; then if [ -L "$targetdir" ]
then
rm "$savelink" rm "$savelink"
elif [ ! -d "$targetdir" ]; then elif [ ! -d "$targetdir" ]
then
mv "$savelink" "$targetdir" mv "$savelink" "$targetdir"
else else
# this should never even happen, but just in case... # this should never even happen, but just in case...
@ -109,17 +122,29 @@ EOF
# This direct update is needed to enable an authentication mechanism to # This direct update is needed to enable an authentication mechanism to
# perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we # perform mariadb-upgrade, (MDEV-22678). To keep the impact minimal, we
# skip innodb and set key-buffer-size to 0 as it isn't reused. # skip innodb and set key-buffer-size to 0 as it isn't reused.
if [ -f "$mysql_datadir"/auto.cnf ] && [ -f "$mysql_datadir"/mysql/user.MYD ] && if [ -f "$mysql_datadir/auto.cnf" ] &&
[ ! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null ] && [ ! -f "$mysql_datadir"/undo_001 ]; then [ -f "$mysql_datadir/mysql/user.MYD" ] &&
! lsof -nt "$mysql_datadir"/mysql/user.MYD > /dev/null &&
[ ! -f "$mysql_datadir/undo_001" ]
then
echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" | echo "UPDATE mysql.user SET plugin='unix_socket' WHERE plugin='auth_socket';" |
mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null mariadbd --skip-innodb --key_buffer_size=0 --default-storage-engine=MyISAM --bootstrap 2> /dev/null
fi fi
# Ensure the existence and right permissions for the database and # Ensure the existence and right permissions for the database and
# log files. Use mkdir option 'Z' to create with correct SELinux context. # log files. Use mkdir option 'Z' to create with correct SELinux context.
if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]; then mkdir -Z "$mysql_statedir"; fi if [ ! -d "$mysql_statedir" ] && [ ! -L "$mysql_statedir" ]
if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]; then mkdir -Z "$mysql_datadir" ; fi then
if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]; then mkdir -Z "$mysql_logdir" ; fi mkdir -Z "$mysql_statedir"
fi
if [ ! -d "$mysql_datadir" ] && [ ! -L "$mysql_datadir" ]
then
mkdir -Z "$mysql_datadir"
fi
if [ ! -d "$mysql_logdir" ] && [ ! -L "$mysql_logdir" ]
then
mkdir -Z "$mysql_logdir"
fi
# When creating an ext3 jounal on an already mounted filesystem like e.g. # When creating an ext3 jounal on an already mounted filesystem like e.g.
# /var/lib/mysql, you get a .journal file that is not modifiable by chown. # /var/lib/mysql, you get a .journal file that is not modifiable by chown.
# The mysql_statedir must not be writable by the mysql user under any # The mysql_statedir must not be writable by the mysql user under any
@ -180,26 +205,30 @@ EOF
# --defaults-file option for tools (for the sake of upgrades) # --defaults-file option for tools (for the sake of upgrades)
# and thus need /etc/mysql/debian.cnf to exist, even if it's empty. # and thus need /etc/mysql/debian.cnf to exist, even if it's empty.
# In the long run the goal is to obsolete this file. # In the long run the goal is to obsolete this file.
dc=$mysql_cfgdir/debian.cnf; dc="$mysql_cfgdir/debian.cnf"
if [ ! -d "$mysql_cfgdir" ]; then if [ ! -d "$mysql_cfgdir" ]
then
install -o 0 -g 0 -m 0755 -d $mysql_cfgdir install -o 0 -g 0 -m 0755 -d $mysql_cfgdir
fi fi
if [ ! -e "$dc" ]; then if [ ! -e "$dc" ]
then
cat /dev/null > $dc cat /dev/null > $dc
echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE." >>$dc {
echo "# This file exists only for backwards compatibility for" >>$dc echo "# THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE.";
echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'" >>$dc echo "# This file exists only for backwards compatibility for";
echo "# and have root level access to the local filesystem." >>$dc echo "# tools that run '--defaults-file=/etc/mysql/debian.cnf'";
echo "# With those permissions one can run 'mariadb' directly" >>$dc echo "# and have root level access to the local filesystem.";
echo "# anyway thanks to unix socket authentication and hence" >>$dc echo "# With those permissions one can run 'mariadb' directly";
echo "# this file is useless. See package README for more info." >>$dc echo "# anyway thanks to unix socket authentication and hence";
echo "[client]" >>$dc echo "# this file is useless. See package README for more info.";
echo "host = localhost" >>$dc echo "[client]";
echo "user = root" >>$dc echo "host = localhost";
echo "[mysql_upgrade]" >>$dc echo "user = root";
echo "host = localhost" >>$dc echo "[mysql_upgrade]";
echo "user = root" >>$dc echo "host = localhost";
echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE." >>$dc echo "user = root";
echo "# THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.";
} >> $dc
fi fi
# Keep it only root-readable, as it always was # Keep it only root-readable, as it always was
chown 0:0 $dc chown 0:0 $dc
@ -212,8 +241,10 @@ EOF
# on by default) to work both to disable a default profile, and to keep # on by default) to work both to disable a default profile, and to keep
# any profile installed and maintained by users themselves. # any profile installed and maintained by users themselves.
profile="/etc/apparmor.d/usr.sbin.mariadbd" profile="/etc/apparmor.d/usr.sbin.mariadbd"
if [ -f "$profile" ] && aa-status --enabled 2>/dev/null; then if [ -f "$profile" ] && aa-status --enabled 2>/dev/null
if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null ; then then
if grep -q /usr/sbin/mariadbd "$profile" 2>/dev/null
then
apparmor_parser -r "$profile" || true apparmor_parser -r "$profile" || true
else else
echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true echo "/usr/sbin/mariadbd { }" | apparmor_parser --remove 2>/dev/null || true
@ -232,14 +263,14 @@ EOF
# Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic # Note that file cannot be empty, otherwise systemd version in Ubuntu Bionic
# will think the service is masked # will think the service is masked
echo "# empty placeholder" > /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf echo "# empty placeholder" > /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
;; ;;
abort-upgrade|abort-remove|abort-configure) abort-upgrade|abort-remove|abort-configure)
;; ;;
triggered) triggered)
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]
then
systemctl --system daemon-reload systemctl --system daemon-reload
else else
invoke-rc.d mariadb restart invoke-rc.d mariadb restart
@ -259,19 +290,23 @@ db_stop # in case invoke fails
# systemctl. If we upgrade from MySQL mysql.service may be masked, which also # systemctl. If we upgrade from MySQL mysql.service may be masked, which also
# means init.d script is disabled. Unmask mysql service explicitly. # means init.d script is disabled. Unmask mysql service explicitly.
# Check first that the command exists, to avoid emitting any warning messages. # Check first that the command exists, to avoid emitting any warning messages.
if [ -x "$(command -v deb-systemd-helper)" ]; then if [ -x "$(command -v deb-systemd-helper)" ]
then
deb-systemd-helper unmask mysql.service > /dev/null deb-systemd-helper unmask mysql.service > /dev/null
fi fi
#DEBHELPER# #DEBHELPER#
# Modified dh_systemd_start snippet that's not added automatically # Modified dh_systemd_start snippet that's not added automatically
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]
then
systemctl --system daemon-reload >/dev/null || true systemctl --system daemon-reload >/dev/null || true
deb-systemd-invoke start mariadb.service >/dev/null || true deb-systemd-invoke start mariadb.service >/dev/null || true
# Modified dh_installinit snippet to only run with sysvinit # Modified dh_installinit snippet to only run with sysvinit
elif [ -x "/etc/init.d/mariadb" ]; then elif [ -x "/etc/init.d/mariadb" ]
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then then
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]
then
invoke-rc.d mariadb start || exit $? invoke-rc.d mariadb start || exit $?
fi fi
fi fi

View File

@ -1,9 +1,15 @@
#!/bin/bash #!/bin/bash
set -e set -e
# shellcheck source=/dev/null
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
then
set -v -x
DEBIAN_SCRIPT_TRACE=1
fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
@ -14,7 +20,10 @@ MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
stop_server() { stop_server() {
# Return immediately if there are no mysqld processes running # Return immediately if there are no mysqld processes running
# as there is no point in trying to shutdown in that case. # as there is no point in trying to shutdown in that case.
if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null; then return; fi if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null
then
return
fi
set +e set +e
invoke-rc.d mariadb stop invoke-rc.d mariadb stop
@ -23,7 +32,8 @@ stop_server() {
set -e set -e
# systemctl could emit exit code 100=no init script (fresh install) # systemctl could emit exit code 100=no init script (fresh install)
if [ "$errno" != 0 -a "$errno" != 100 ]; then if [ "$errno" != 0 ] && [ "$errno" != 100 ]
then
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
echo "Stop it yourself and try again!" 1>&2 echo "Stop it yourself and try again!" 1>&2
@ -35,7 +45,8 @@ stop_server() {
case "$1" in case "$1" in
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
if [ -n "`$MYADMIN ping 2>/dev/null`" ]; then if [ -n "$($MYADMIN ping 2>/dev/null)" ]
then
stop_server stop_server
sleep 2 sleep 2
fi fi
@ -51,7 +62,8 @@ esac
# - Remove the mysql user only after all his owned files are purged. # - Remove the mysql user only after all his owned files are purged.
# - Cleanup the initscripts only if this was the last provider of them # - Cleanup the initscripts only if this was the last provider of them
# #
if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag" ]; then if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag" ]
then
# we remove the mysql user only after all his owned files are purged # we remove the mysql user only after all his owned files are purged
rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz} rm -f /var/log/mysql.{log,err}{,.0,.[1234567].gz}
rm -rf /var/log/mysql rm -rf /var/log/mysql
@ -59,7 +71,8 @@ if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-__MARIADB_MAJOR_VER__.flag"
db_input high "mariadb-server/postrm_remove_databases" || true db_input high "mariadb-server/postrm_remove_databases" || true
db_go || true db_go || true
db_get "mariadb-server/postrm_remove_databases" || true db_get "mariadb-server/postrm_remove_databases" || true
if [ "$RET" = "true" ]; then if [ "$RET" = "true" ]
then
# never remove the debian.cnf when the databases are still existing # never remove the debian.cnf when the databases are still existing
# else we ran into big trouble on the next install! # else we ran into big trouble on the next install!
rm -f /etc/mysql/debian.cnf rm -f /etc/mysql/debian.cnf
@ -89,6 +102,7 @@ fi
#DEBHELPER# #DEBHELPER#
# Modified dh_systemd_start snippet that's not added automatically # Modified dh_systemd_start snippet that's not added automatically
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]
then
systemctl --system daemon-reload >/dev/null || true systemctl --system daemon-reload >/dev/null || true
fi fi

View File

@ -7,14 +7,20 @@
# * <old-preinst> abort-upgrade <new-version> # * <old-preinst> abort-upgrade <new-version>
# #
# shellcheck source=/dev/null
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
# Just kill the invalid insserv.conf.d directory without fallback # Just kill the invalid insserv.conf.d directory without fallback
if [ -d "/etc/insserv.conf.d/mariadb/" ]; then if [ -d "/etc/insserv.conf.d/mariadb/" ]
then
rm -rf "/etc/insserv.conf.d/mariadb/" rm -rf "/etc/insserv.conf.d/mariadb/"
fi fi
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi if [ -n "$DEBIAN_SCRIPT_DEBUG" ]
then
set -v -x
DEBIAN_SCRIPT_TRACE=1
fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
@ -28,7 +34,10 @@ stop_server() {
# Return immediately if there are no mysqld processes running on a host # Return immediately if there are no mysqld processes running on a host
# (leave containerized processes with the same name in other namespaces) # (leave containerized processes with the same name in other namespaces)
# as there is no point in trying to shutdown in that case. # as there is no point in trying to shutdown in that case.
if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null; then return; fi if ! pgrep -x --nslist pid --ns $$ "mysqld|mariadbd" > /dev/null
then
return
fi
set +e set +e
invoke-rc.d mariadb stop invoke-rc.d mariadb stop
@ -37,7 +46,8 @@ stop_server() {
set -e set -e
# systemctl could emit exit code 100=no init script (fresh install) # systemctl could emit exit code 100=no init script (fresh install)
if [ "$errno" != 0 -a "$errno" != 100 ]; then if [ "$errno" != 0 ] && [ "$errno" != 100 ]
then
echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2 echo "Attempt to stop MariaDB/MySQL server returned exitcode $errno" 1>&2
echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2 echo "There is a MariaDB/MySQL server running, but we failed in our attempts to stop it." 1>&2
echo "Stop it yourself and try again!" 1>&2 echo "Stop it yourself and try again!" 1>&2
@ -56,7 +66,7 @@ max_upgradeable_version=5.7
# Check if a flag file is found that indicates a previous MariaDB or MySQL # Check if a flag file is found that indicates a previous MariaDB or MySQL
# version was installed. If multiple flags are found, check which one was # version was installed. If multiple flags are found, check which one was
# the biggest version number. # the biggest version number.
for flag in $mysql_datadir/debian-*.flag for flag in "$mysql_datadir"/debian-*.flag
do do
# The for loop leaves $flag as the query string if there are no results, # The for loop leaves $flag as the query string if there are no results,
@ -91,7 +101,7 @@ done
# Downgrade is detected if the flag version is bigger than $this_version # Downgrade is detected if the flag version is bigger than $this_version
# (e.g. 10.1 > 10.0) or the flag version is smaller than 10.0 but bigger # (e.g. 10.1 > 10.0) or the flag version is smaller than 10.0 but bigger
# than $max_upgradeable_version. # than $max_upgradeable_version.
if [ ! -z "$found_version" ] if [ -n "$found_version" ]
then then
# MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly # MySQL 8.0 in Ubuntu has a bug in packaging and the file is name wrongly
@ -133,7 +143,7 @@ fi
# Don't abort dpkg if downgrade is detected (as was done previously). # Don't abort dpkg if downgrade is detected (as was done previously).
# Instead simply move the old datadir and create a new for this_version. # Instead simply move the old datadir and create a new for this_version.
if [ ! -z "$downgrade_detected" ] if [ -n "$downgrade_detected" ]
then then
db_input critical "mariadb-server/old_data_directory_saved" || true db_input critical "mariadb-server/old_data_directory_saved" || true
db_go db_go
@ -154,7 +164,8 @@ stop_server
# If we use NIS then errors should be tolerated. It's up to the # If we use NIS then errors should be tolerated. It's up to the
# user to ensure that the mysql user is correctly setup. # user to ensure that the mysql user is correctly setup.
# Beware that there are two ypwhich one of them needs the 2>/dev/null! # Beware that there are two ypwhich one of them needs the 2>/dev/null!
if test -n "$(which ypwhich 2>/dev/null)" && ypwhich >/dev/null 2>&1; then if test -n "$(which ypwhich 2>/dev/null)" && ypwhich >/dev/null 2>&1
then
set +e set +e
fi fi
@ -169,13 +180,15 @@ fi
# #
# creating mysql group if he isn't already there # creating mysql group if he isn't already there
if ! getent group mysql >/dev/null; then if ! getent group mysql >/dev/null
then
# Adding system group: mysql. # Adding system group: mysql.
addgroup --system mysql >/dev/null addgroup --system mysql >/dev/null
fi fi
# creating mysql user if he isn't already there # creating mysql user if he isn't already there
if ! getent passwd mysql >/dev/null; then if ! getent passwd mysql >/dev/null
then
# Adding system user: mysql. # Adding system user: mysql.
adduser \ adduser \
--system \ --system \
@ -193,7 +206,8 @@ set -e
# if there's a symlink, let's store where it's pointing, because otherwise # if there's a symlink, let's store where it's pointing, because otherwise
# it's going to be lost in some situations # it's going to be lost in some situations
for dir in DATADIR LOGDIR; do for dir in DATADIR LOGDIR
do
checkdir=$(eval echo "$"$dir) checkdir=$(eval echo "$"$dir)
if [ -L "$checkdir" ]; then if [ -L "$checkdir" ]; then
# Use mkdir option 'Z' to create with correct SELinux context. # Use mkdir option 'Z' to create with correct SELinux context.
@ -203,19 +217,30 @@ for dir in DATADIR LOGDIR; do
done done
# creating mysql home directory # creating mysql home directory
if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]; then if [ ! -d $mysql_datadir ] && [ ! -L $mysql_datadir ]
then
# Use mkdir option 'Z' to create with correct SELinux context. # Use mkdir option 'Z' to create with correct SELinux context.
mkdir -Z $mysql_datadir mkdir -Z $mysql_datadir
fi fi
# Check if MariaDB datadir is available if not fails.
# There should be symlink or directory available or something will fail.
if [ -d "$mysql_datadir" ] || [ -L "$mysql_datadir" ]
then
# As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024 # As preset blocksize of GNU df is 1024 then available bytes is $df_available_blocks * 1024
# 4096 blocks is then lower than 4 MB # 4096 blocks is then lower than 4 MB
df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)" df_available_blocks="$(LC_ALL=C BLOCKSIZE='' df --output=avail "$mysql_datadir" | tail -n 1)"
if [ "$df_available_blocks" -lt "4096" ]; then if [ "$df_available_blocks" -lt "4096" ]
then
echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2 echo "ERROR: There's not enough space in $mysql_datadir/" 1>&2
db_stop db_stop
exit 1 exit 1
fi fi
else
echo "ERROR: There's no directory or symlink available: $mysql_datadir/" 1>&2
db_stop
exit 1
fi
# Since the home directory was created before putting the user into # Since the home directory was created before putting the user into
# the mysql group and moreover we cannot guarantee that the # the mysql group and moreover we cannot guarantee that the
@ -230,7 +255,6 @@ find $mysql_datadir -follow -not -group mysql -print0 2>/dev/null \
| xargs -0 --no-run-if-empty chgrp mysql | xargs -0 --no-run-if-empty chgrp mysql
set -e set -e
db_stop db_stop
#DEBHELPER# #DEBHELPER#

View File

@ -4,9 +4,11 @@ set -e
#DEBHELPER# #DEBHELPER#
# Modified dh_systemd_start snippet that's not added automatically # Modified dh_systemd_start snippet that's not added automatically
if [ -d /run/systemd/system ]; then if [ -d /run/systemd/system ]
then
deb-systemd-invoke stop mariadb.service >/dev/null deb-systemd-invoke stop mariadb.service >/dev/null
# Modified dh_installinit snippet to only run with sysvinit # Modified dh_installinit snippet to only run with sysvinit
elif [ -x "/etc/init.d/mariadb" ]; then elif [ -x "/etc/init.d/mariadb" ]
then
invoke-rc.d mariadb stop || exit $? invoke-rc.d mariadb stop || exit $?
fi fi

View File

@ -26,6 +26,7 @@ usr/lib/mysql/plugin/qa_auth_interface.so
usr/lib/mysql/plugin/qa_auth_server.so usr/lib/mysql/plugin/qa_auth_server.so
usr/lib/mysql/plugin/test_sql_service.so usr/lib/mysql/plugin/test_sql_service.so
usr/lib/mysql/plugin/test_versioning.so usr/lib/mysql/plugin/test_versioning.so
usr/lib/mysql/plugin/type_mysql_timestamp.so
usr/share/man/man1/mariadb-client-test-embedded.1 usr/share/man/man1/mariadb-client-test-embedded.1
usr/share/man/man1/mariadb-client-test.1 usr/share/man/man1/mariadb-client-test.1
usr/share/man/man1/mariadb-test-embedded.1 usr/share/man/man1/mariadb-test-embedded.1

View File

@ -848,26 +848,48 @@ void mdl_lock_all()
// Convert non-null terminated filename to space name // Convert non-null terminated filename to space name
// Note that in 10.6 the filename may be an undo file name
static std::string filename_to_spacename(const void *filename, size_t len) static std::string filename_to_spacename(const void *filename, size_t len)
{ {
// null- terminate filename char f[FN_REFLEN];
char *f = (char *)malloc(len + 1); char *p= 0, *table, *db;
ut_a(f); DBUG_ASSERT(len < FN_REFLEN);
memcpy(f, filename, len);
f[len] = 0; strmake(f, (const char*) filename, len);
#ifdef _WIN32
for (size_t i = 0; i < len; i++) for (size_t i = 0; i < len; i++)
{
if (f[i] == '\\') if (f[i] == '\\')
f[i] = '/'; f[i] = '/';
char *p = strrchr(f, '.'); }
ut_a(p); #endif
/* Remove extension, if exists */
if (!(p= strrchr(f, '.')))
goto err;
*p= 0; *p= 0;
char *table = strrchr(f, '/');
ut_a(table); /* Find table name */
if (!(table= strrchr(f, '/')))
goto err;
*table = 0; *table = 0;
char *db = strrchr(f, '/');
/* Find database name */
db= strrchr(f, '/');
*table = '/'; *table = '/';
std::string s(db ? db+1 : f); if (!db)
free(f); goto err;
{
std::string s(db+1);
return s;
}
err:
/* Not a database/table. Return original (converted) name */
if (p)
*p= '.'; // Restore removed extension
std::string s(f);
return s; return s;
} }
@ -3170,7 +3192,7 @@ static bool xtrabackup_copy_logfile()
if (log_sys.buf[recv_sys.offset] <= 1) if (log_sys.buf[recv_sys.offset] <= 1)
break; break;
if (recv_sys.parse_mtr(STORE_NO) == recv_sys_t::OK) if (recv_sys.parse_mtr<false>(false) == recv_sys_t::OK)
{ {
do do
{ {
@ -3180,7 +3202,7 @@ static bool xtrabackup_copy_logfile()
sequence_offset)); sequence_offset));
*seq= 1; *seq= 1;
} }
while ((r= recv_sys.parse_mtr(STORE_NO)) == recv_sys_t::OK); while ((r= recv_sys.parse_mtr<false>(false)) == recv_sys_t::OK);
if (ds_write(dst_log_file, log_sys.buf + start_offset, if (ds_write(dst_log_file, log_sys.buf + start_offset,
recv_sys.offset - start_offset)) recv_sys.offset - start_offset))

View File

@ -249,14 +249,15 @@ static inline void lex_string_set3(LEX_CSTRING *lex_str, const char *c_str,
*/ */
static inline int safe_strcpy(char *dst, size_t dst_size, const char *src) static inline int safe_strcpy(char *dst, size_t dst_size, const char *src)
{ {
memset(dst, '\0', dst_size); DBUG_ASSERT(dst_size > 0);
strncpy(dst, src, dst_size - 1); /* Note, strncpy will zerofill end of dst if src shorter than dst_size */
/* strncpy(dst, src, dst_size);
If the first condition is true, we are guaranteed to have src length if (dst[dst_size-1])
>= (dst_size - 1), hence safe to access src[dst_size - 1]. {
*/ /* Ensure string is zero terminated */
if (dst[dst_size - 2] != '\0' && src[dst_size - 1] != '\0') dst[dst_size-1]= 0;
return 1; /* Truncation of src. */ return 1;
}
return 0; return 0;
} }

View File

@ -71,6 +71,7 @@ typedef struct st_myrg_info
ulong cache_size; ulong cache_size;
uint merge_insert_method; uint merge_insert_method;
uint tables,options,reclength,keys; uint tables,options,reclength,keys;
uint key_parts;
my_bool cache_in_use; my_bool cache_in_use;
/* If MERGE children attached to parent. See top comment in ha_myisammrg.cc */ /* If MERGE children attached to parent. See top comment in ha_myisammrg.cc */
my_bool children_attached; my_bool children_attached;

View File

@ -48,6 +48,7 @@ extern "C" {
#define MYSQL_AUDIT_GENERAL_ERROR 1 #define MYSQL_AUDIT_GENERAL_ERROR 1
#define MYSQL_AUDIT_GENERAL_RESULT 2 #define MYSQL_AUDIT_GENERAL_RESULT 2
#define MYSQL_AUDIT_GENERAL_STATUS 3 #define MYSQL_AUDIT_GENERAL_STATUS 3
#define MYSQL_AUDIT_GENERAL_WARNING 4
struct mysql_event_general struct mysql_event_general
{ {

View File

@ -57,6 +57,7 @@ extern struct wsrep_service_st {
my_bool (*wsrep_on_func)(const MYSQL_THD thd); my_bool (*wsrep_on_func)(const MYSQL_THD thd);
bool (*wsrep_prepare_key_for_innodb_func)(MYSQL_THD thd, const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*); bool (*wsrep_prepare_key_for_innodb_func)(MYSQL_THD thd, const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*);
void (*wsrep_thd_LOCK_func)(const MYSQL_THD thd); void (*wsrep_thd_LOCK_func)(const MYSQL_THD thd);
int (*wsrep_thd_TRYLOCK_func)(const MYSQL_THD thd);
void (*wsrep_thd_UNLOCK_func)(const MYSQL_THD thd); void (*wsrep_thd_UNLOCK_func)(const MYSQL_THD thd);
const char * (*wsrep_thd_query_func)(const MYSQL_THD thd); const char * (*wsrep_thd_query_func)(const MYSQL_THD thd);
int (*wsrep_thd_retry_counter_func)(const MYSQL_THD thd); int (*wsrep_thd_retry_counter_func)(const MYSQL_THD thd);
@ -89,7 +90,6 @@ extern struct wsrep_service_st {
ulong (*wsrep_OSU_method_get_func)(const MYSQL_THD thd); ulong (*wsrep_OSU_method_get_func)(const MYSQL_THD thd);
my_bool (*wsrep_thd_has_ignored_error_func)(const MYSQL_THD thd); my_bool (*wsrep_thd_has_ignored_error_func)(const MYSQL_THD thd);
void (*wsrep_thd_set_ignored_error_func)(MYSQL_THD thd, my_bool val); void (*wsrep_thd_set_ignored_error_func)(MYSQL_THD thd, my_bool val);
bool (*wsrep_thd_set_wsrep_aborter_func)(MYSQL_THD bf_thd, MYSQL_THD thd);
void (*wsrep_report_bf_lock_wait_func)(const MYSQL_THD thd, void (*wsrep_report_bf_lock_wait_func)(const MYSQL_THD thd,
unsigned long long trx_id); unsigned long long trx_id);
void (*wsrep_thd_kill_LOCK_func)(const MYSQL_THD thd); void (*wsrep_thd_kill_LOCK_func)(const MYSQL_THD thd);
@ -111,6 +111,7 @@ extern struct wsrep_service_st {
#define wsrep_on(thd) (thd) && WSREP_ON && wsrep_service->wsrep_on_func(thd) #define wsrep_on(thd) (thd) && WSREP_ON && wsrep_service->wsrep_on_func(thd)
#define wsrep_prepare_key_for_innodb(A,B,C,D,E,F,G) wsrep_service->wsrep_prepare_key_for_innodb_func(A,B,C,D,E,F,G) #define wsrep_prepare_key_for_innodb(A,B,C,D,E,F,G) wsrep_service->wsrep_prepare_key_for_innodb_func(A,B,C,D,E,F,G)
#define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T) #define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T)
#define wsrep_thd_TRYLOCK(T) wsrep_service->wsrep_thd_TRYLOCK_func(T)
#define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T) #define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T)
#define wsrep_thd_kill_LOCK(T) wsrep_service->wsrep_thd_kill_LOCK_func(T) #define wsrep_thd_kill_LOCK(T) wsrep_service->wsrep_thd_kill_LOCK_func(T)
#define wsrep_thd_kill_UNLOCK(T) wsrep_service->wsrep_thd_kill_UNLOCK_func(T) #define wsrep_thd_kill_UNLOCK(T) wsrep_service->wsrep_thd_kill_UNLOCK_func(T)
@ -141,7 +142,6 @@ extern struct wsrep_service_st {
#define wsrep_OSU_method_get(T) wsrep_service->wsrep_OSU_method_get_func(T) #define wsrep_OSU_method_get(T) wsrep_service->wsrep_OSU_method_get_func(T)
#define wsrep_thd_has_ignored_error(T) wsrep_service->wsrep_thd_has_ignored_error_func(T) #define wsrep_thd_has_ignored_error(T) wsrep_service->wsrep_thd_has_ignored_error_func(T)
#define wsrep_thd_set_ignored_error(T,V) wsrep_service->wsrep_thd_set_ignored_error_func(T,V) #define wsrep_thd_set_ignored_error(T,V) wsrep_service->wsrep_thd_set_ignored_error_func(T,V)
#define wsrep_thd_set_wsrep_aborter(T) wsrep_service->wsrep_thd_set_wsrep_aborter_func(T1, T2)
#define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait(T,I) #define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait(T,I)
#define wsrep_thd_set_PA_unsafe(T) wsrep_service->wsrep_thd_set_PA_unsafe_func(T) #define wsrep_thd_set_PA_unsafe(T) wsrep_service->wsrep_thd_set_PA_unsafe_func(T)
#else #else
@ -175,6 +175,8 @@ void wsrep_set_data_home_dir(const char *data_dir);
extern "C" my_bool wsrep_on(const MYSQL_THD thd); extern "C" my_bool wsrep_on(const MYSQL_THD thd);
/* Lock thd wsrep lock */ /* Lock thd wsrep lock */
extern "C" void wsrep_thd_LOCK(const MYSQL_THD thd); extern "C" void wsrep_thd_LOCK(const MYSQL_THD thd);
/* Try thd wsrep lock. Return non-zero if lock could not be taken. */
extern "C" int wsrep_thd_TRYLOCK(const MYSQL_THD thd);
/* Unlock thd wsrep lock */ /* Unlock thd wsrep lock */
extern "C" void wsrep_thd_UNLOCK(const MYSQL_THD thd); extern "C" void wsrep_thd_UNLOCK(const MYSQL_THD thd);
@ -197,8 +199,6 @@ extern "C" my_bool wsrep_thd_is_local(const MYSQL_THD thd);
/* Return true if thd is in high priority mode */ /* Return true if thd is in high priority mode */
/* todo: rename to is_high_priority() */ /* todo: rename to is_high_priority() */
extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd); extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd);
/* set wsrep_aborter for the target THD */
extern "C" bool wsrep_thd_set_wsrep_aborter(MYSQL_THD bf_thd, MYSQL_THD victim_thd);
/* Return true if thd is in TOI mode */ /* Return true if thd is in TOI mode */
extern "C" my_bool wsrep_thd_is_toi(const MYSQL_THD thd); extern "C" my_bool wsrep_thd_is_toi(const MYSQL_THD thd);
/* Return true if thd is in replicating TOI mode */ /* Return true if thd is in replicating TOI mode */
@ -249,7 +249,6 @@ extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd);
extern "C" ulong wsrep_OSU_method_get(const MYSQL_THD thd); extern "C" ulong wsrep_OSU_method_get(const MYSQL_THD thd);
extern "C" my_bool wsrep_thd_has_ignored_error(const MYSQL_THD thd); extern "C" my_bool wsrep_thd_has_ignored_error(const MYSQL_THD thd);
extern "C" void wsrep_thd_set_ignored_error(MYSQL_THD thd, my_bool val); extern "C" void wsrep_thd_set_ignored_error(MYSQL_THD thd, my_bool val);
extern "C" bool wsrep_thd_set_wsrep_aborter(MYSQL_THD bf_thd, MYSQL_THD victim_thd);
extern "C" void wsrep_report_bf_lock_wait(const THD *thd, extern "C" void wsrep_report_bf_lock_wait(const THD *thd,
unsigned long long trx_id); unsigned long long trx_id);
/* declare parallel applying unsafety for the THD */ /* declare parallel applying unsafety for the THD */

View File

@ -34,7 +34,7 @@ use strict;
use Exporter; use Exporter;
use base "Exporter"; use base "Exporter";
our @EXPORT= qw /rmtree mkpath copytree/; our @EXPORT= qw /rmtree mkpath copytree make_readonly/;
use File::Find; use File::Find;
use File::Copy; use File::Copy;
@ -184,6 +184,10 @@ sub copytree {
# Only copy plain files # Only copy plain files
next unless -f "$from_dir/$_"; next unless -f "$from_dir/$_";
copy("$from_dir/$_", "$to_dir/$_"); copy("$from_dir/$_", "$to_dir/$_");
if (!$use_umask)
{
chmod(0666, "$to_dir/$_");
}
} }
closedir(DIR); closedir(DIR);
@ -193,4 +197,29 @@ sub copytree {
} }
} }
sub make_readonly {
my ($dir) = @_;
die "Usage: make_readonly(<dir>])"
unless @_ == 1;
opendir(DIR, "$dir")
or croak("Can't find $dir$!");
for(readdir(DIR)) {
next if "$_" eq "." or "$_" eq "..";
if ( -d "$dir/$_" )
{
make_readonly("$dir/$_");
next;
}
# Only copy plain files
next unless -f "$dir/$_";
chmod 0444, "$dir/$_";
}
closedir(DIR);
}
1; 1;

View File

@ -40,7 +40,7 @@ our @EXPORT= qw(create_process);
# Retry a couple of times if fork returns EAGAIN # Retry a couple of times if fork returns EAGAIN
# #
sub _safe_fork { sub _safe_fork {
my $retries= 5; my $retries= 100;
my $pid; my $pid;
FORK: FORK:

View File

@ -470,7 +470,7 @@ t1 CREATE TABLE `t1` (
KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`) KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
flush tables; flush tables;
show create table t1; show create table t1;
Table Create Table Table Create Table
@ -619,7 +619,7 @@ t1 CREATE TABLE `t1` (
KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`) KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int,
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int); c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int);
@ -1092,7 +1092,7 @@ t1 CREATE TABLE `t1` (
KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`) KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
flush tables; flush tables;
show create table t1; show create table t1;
Table Create Table Table Create Table
@ -1241,7 +1241,7 @@ t1 CREATE TABLE `t1` (
KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a126_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`), KEY `a127_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`) KEY `a128_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
alter table t1 add key alter table t1 add key
a129_long_123456789_123456789_123456789_123456789_123456789_1234 ( a129_long_123456789_123456789_123456789_123456789_123456789_1234 (
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16); c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);

View File

@ -1161,3 +1161,27 @@ explain select * from t1 limit 0 offset 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Zero limit
drop table t1, t2; drop table t1, t2;
#
# MDEV-28285 Unexpected result when combining DISTINCT, subselect
# and LIMIT
#
create table t1 (a int primary key);
create table t2 (a int primary key, b int not null);
insert into t1 select seq from seq_1_to_10;
insert into t2 select seq,seq from seq_1_to_10;
select distinct a from t1 where t1.a=1 and t1.a in (select a from t2 where t2.b in (1,2));
a
1
explain select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 Using index; Using temporary
1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using where; FirstMatch(t1)
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
a
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 0,1;
a
1
drop table t1,t2;
#
# end of 10.5 tests
#

View File

@ -893,3 +893,24 @@ explain select * from t1 limit 0;
explain select * from t1 limit 0 offset 10; explain select * from t1 limit 0 offset 10;
drop table t1, t2; drop table t1, t2;
--echo #
--echo # MDEV-28285 Unexpected result when combining DISTINCT, subselect
--echo # and LIMIT
--echo #
create table t1 (a int primary key);
create table t2 (a int primary key, b int not null);
insert into t1 select seq from seq_1_to_10;
insert into t2 select seq,seq from seq_1_to_10;
select distinct a from t1 where t1.a=1 and t1.a in (select a from t2 where t2.b in (1,2));
explain select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 10,10;
select distinct a from t1 where t1.a=1 and t1.a in (select a+0 from t2 where t2.b in (1,2)) limit 0,1;
drop table t1,t2;
--echo #
--echo # end of 10.5 tests
--echo #

View File

@ -2578,6 +2578,30 @@ SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key');
JSON_EXTRACT('{ "my-key": 1 }', '$.my-key') JSON_EXTRACT('{ "my-key": 1 }', '$.my-key')
1 1
# #
# MDEV-23187: Assorted assertion failures in json_find_path with certain collations
#
SET @save_collation_connection= @@collation_connection;
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
NULL
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
SET collation_connection='ucs2_bin';
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
NULL
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
SET sql_mode=0,character_set_connection=utf32;
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
NULL
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
SET sql_mode=0,character_set_connection=utf32;
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
JSON_VALUE(@json,'$.A[last-1][last-1].key1')
NULL
SET @@collation_connection= @save_collation_connection;
#
# End of 10.9 Test # End of 10.9 Test
# #
# Beginning of 11.1 test # Beginning of 11.1 test

View File

@ -1772,6 +1772,32 @@ DROP TABLE t1;
SELECT JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"'); SELECT JSON_EXTRACT('{ "my-key": 1 }', '$."my-key"');
SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key'); SELECT JSON_EXTRACT('{ "my-key": 1 }', '$.my-key');
--echo #
--echo # MDEV-23187: Assorted assertion failures in json_find_path with certain collations
--echo #
SET @save_collation_connection= @@collation_connection;
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
SET @json='{ "A": [ [{"k":"v"},[1]],true],"B": {"C": 1} }';
SET collation_connection='ucs2_bin';
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
SET sql_mode=0,character_set_connection=utf32;
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
SET @json='{ "A": [ [{"k":"v"},[15]],true],"B": {"C": 1} }';
SET sql_mode=0,character_set_connection=utf32;
SELECT JSON_VALUE(@json,'$.A[last-1][last-1].key1');
SET @@collation_connection= @save_collation_connection;
--echo # --echo #
--echo # End of 10.9 Test --echo # End of 10.9 Test
--echo # --echo #

View File

@ -434,7 +434,7 @@ create table t1 as select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'04420435044
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`x` varchar(8) CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL `x` longtext CHARACTER SET ucs2 COLLATE ucs2_general_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1; drop table t1;
set names latin1; set names latin1;
@ -468,3 +468,26 @@ set names latin1;
# #
# End of 10.7 tests # End of 10.7 tests
# #
#
# Start of 10.8 tests
#
#
# MDEV-29646 sformat('Num [{:20}]', 42) gives incorrect result in view
#
create view v1 as select sformat('Num [{:20}]', 42);
select * from v1;
sformat('Num [{:20}]', 42)
Num [ 42]
drop view v1;
create view v1 as SELECT sformat('Square root of [{:d}] is [{:.20}]', 2, sqrt(2));
select * from v1;
sformat('Square root of [{:d}] is [{:.20}]', 2, sqrt(2))
Square root of [2] is [1.4142135623730951455]
drop view v1;
create table t1 (a text, b int, c text);
insert t1 values ('[{} -> {}]', 10, '{}'), ('[{:20} <- {}]', 1, '{:30}');
select sformat(a,b,c) from t1;
sformat(a,b,c)
[10 -> {}]
[ 1 <- {:30}]
drop table t1;

View File

@ -253,3 +253,24 @@ set names latin1;
echo #; echo #;
echo # End of 10.7 tests; echo # End of 10.7 tests;
echo #; echo #;
echo #;
echo # Start of 10.8 tests;
echo #;
echo #;
echo # MDEV-29646 sformat('Num [{:20}]', 42) gives incorrect result in view;
echo #;
create view v1 as select sformat('Num [{:20}]', 42);
select * from v1;
drop view v1;
create view v1 as SELECT sformat('Square root of [{:d}] is [{:.20}]', 2, sqrt(2));
select * from v1;
drop view v1;
create table t1 (a text, b int, c text);
insert t1 values ('[{} -> {}]', 10, '{}'), ('[{:20} <- {}]', 1, '{:30}');
select sformat(a,b,c) from t1;
drop table t1;

View File

@ -4129,6 +4129,140 @@ MIN(pk) a
5 10 5 10
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-6768 Wrong result with agregate with join with no resultset
#
create table t1
(
PARENT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
PARENT_FIELD VARCHAR(10),
PRIMARY KEY (PARENT_ID)
) engine=innodb;
create table t2
(
CHILD_ID INT NOT NULL AUTO_INCREMENT,
PARENT_ID INT NOT NULL,
CHILD_FIELD varchar(10),
PRIMARY KEY (CHILD_ID)
)engine=innodb;
INSERT INTO t1 (PARENT_FIELD)
SELECT 'AAAA';
INSERT INTO t2 (PARENT_ID, CHILD_FIELD)
SELECT 1, 'BBBB';
explain select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
1 SIMPLE t2 ALL NULL NULL NULL NULL 1 Using where
select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
PARENT_ID min(CHILD_FIELD)
NULL NULL
select
1,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
1 min(CHILD_FIELD)
1 NULL
select
IFNULL(t1.PARENT_ID,1),
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
IFNULL(t1.PARENT_ID,1) min(CHILD_FIELD)
1 NULL
# Check that things works with MyISAM (which has different explain)
alter table t1 engine=myisam;
alter table t2 engine=myisam;
explain select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
PARENT_ID min(CHILD_FIELD)
NULL NULL
drop table t1,t2;
# Check that things works if sub queries are re-executed
create table t1 (a int primary key, b int);
create table t2 (a int primary key, b int);
create table t3 (a int primary key, b int);
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1,1),(2,2),(3,3);
insert into t3 values (1,1),(3,3);
explain
select *,
(select
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
from t2,t3
where t2.a=1 and t1.b = t3.a) as s1
from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
2 DEPENDENT SUBQUERY t2 const PRIMARY PRIMARY 4 const 1 Using index
2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1
select *,
(select
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
from t2,t3
where t2.a=1 and t1.b = t3.a) as s1
from t1;
a b s1
1 1 t2:1;min_t3_b:1
2 2 t2:t2a-null;min_t3_b:t3b-null
3 3 t2:1;min_t3_b:3
drop table t1,t2,t3;
#
# MDEV-31380: Assertion `s->table->opt_range_condition_rows <= s->found_records' failed
# (assertion in 10.6+, DBL_MAX costs in 10.5)
#
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a), KEY(b)) ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100;
SET
@tmp=@@optimizer_use_condition_selectivity,
optimizer_use_condition_selectivity = 1,
@tmp2=@@optimizer_trace,
optimizer_trace=1;
SELECT DISTINCT * FROM t1 WHERE a IN (1, 2);
a b
1 1
2 2
select
CAST(json_value(json_extract(trace, '$**.chosen_access_method.cost'), '$[0]')
as DOUBLE) < 1.0e100
from information_schema.optimizer_trace;
CAST(json_value(json_extract(trace, '$**.chosen_access_method.cost'), '$[0]')
as DOUBLE) < 1.0e100
1
set optimizer_use_condition_selectivity = @tmp, optimizer_trace=@tmp2;
drop table t1;
#
# End of 10.5 tests # End of 10.5 tests
# #
# #

View File

@ -7,6 +7,7 @@
--source include/default_optimizer_switch.inc --source include/default_optimizer_switch.inc
--source include/have_sequence.inc --source include/have_sequence.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_sequence.inc
# #
# TODO: # TODO:
# Add queries with: # Add queries with:
@ -1756,6 +1757,140 @@ SELECT MIN(pk), a FROM t1 WHERE pk <> 1 GROUP BY a;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-6768 Wrong result with agregate with join with no resultset
--echo #
create table t1
(
PARENT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
PARENT_FIELD VARCHAR(10),
PRIMARY KEY (PARENT_ID)
) engine=innodb;
create table t2
(
CHILD_ID INT NOT NULL AUTO_INCREMENT,
PARENT_ID INT NOT NULL,
CHILD_FIELD varchar(10),
PRIMARY KEY (CHILD_ID)
)engine=innodb;
INSERT INTO t1 (PARENT_FIELD)
SELECT 'AAAA';
INSERT INTO t2 (PARENT_ID, CHILD_FIELD)
SELECT 1, 'BBBB';
explain select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
select
1,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
select
IFNULL(t1.PARENT_ID,1),
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
--echo # Check that things works with MyISAM (which has different explain)
alter table t1 engine=myisam;
alter table t2 engine=myisam;
explain select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
select
t1.PARENT_ID,
min(CHILD_FIELD)
from t1 straight_join t2
where t1.PARENT_ID = 1
and t1.PARENT_ID = t2.PARENT_ID
and t2.CHILD_FIELD = "ZZZZ";
drop table t1,t2;
--echo # Check that things works if sub queries are re-executed
create table t1 (a int primary key, b int);
create table t2 (a int primary key, b int);
create table t3 (a int primary key, b int);
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1,1),(2,2),(3,3);
insert into t3 values (1,1),(3,3);
explain
select *,
(select
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
from t2,t3
where t2.a=1 and t1.b = t3.a) as s1
from t1;
select *,
(select
CONCAT('t2:', IFNULL(t2.a, 't2a-null'), ';',
'min_t3_b:', IFNULL(min(t3.b), 't3b-null'))
from t2,t3
where t2.a=1 and t1.b = t3.a) as s1
from t1;
drop table t1,t2,t3;
--echo #
--echo # MDEV-31380: Assertion `s->table->opt_range_condition_rows <= s->found_records' failed
--echo # (assertion in 10.6+, DBL_MAX costs in 10.5)
--echo #
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a), KEY(b)) ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_100;
SET
@tmp=@@optimizer_use_condition_selectivity,
optimizer_use_condition_selectivity = 1,
@tmp2=@@optimizer_trace,
optimizer_trace=1;
SELECT DISTINCT * FROM t1 WHERE a IN (1, 2);
select
CAST(json_value(json_extract(trace, '$**.chosen_access_method.cost'), '$[0]')
as DOUBLE) < 1.0e100
from information_schema.optimizer_trace;
set optimizer_use_condition_selectivity = @tmp, optimizer_trace=@tmp2;
drop table t1;
--echo # --echo #
--echo # End of 10.5 tests --echo # End of 10.5 tests
--echo # --echo #

View File

@ -1237,6 +1237,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"rows_after_filter": 100, "rows_after_filter": 100,
"rows_out": 1, "rows_out": 1,
"cost": 0.9604227, "cost": 0.9604227,
"cost_without_join_buffer": 2.56761,
"index_only": false, "index_only": false,
"chosen": false "chosen": false
} }
@ -1291,6 +1292,7 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"rows_after_filter": 100, "rows_after_filter": 100,
"rows_out": 1, "rows_out": 1,
"cost": 0.9604227, "cost": 0.9604227,
"cost_without_join_buffer": 2.56761,
"index_only": false, "index_only": false,
"chosen": false "chosen": false
} }
@ -3465,6 +3467,7 @@ explain extended select * from t1 where a in (select p from t2) {
"rows_after_filter": 101, "rows_after_filter": 101,
"rows_out": 101, "rows_out": 101,
"cost": 0.063593833, "cost": 0.063593833,
"cost_without_join_buffer": 0.10333002,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -5246,6 +5249,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -5389,6 +5393,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -5415,6 +5420,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -5453,6 +5459,7 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.015203373, "cost": 0.015203373,
"cost_without_join_buffer": 0.094543335,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6017,6 +6024,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6043,6 +6051,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6069,6 +6078,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6095,6 +6105,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6121,6 +6132,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6159,6 +6171,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.050443503, "cost": 0.050443503,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6185,6 +6198,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.024600489, "cost": 0.024600489,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6211,6 +6225,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.024600489, "cost": 0.024600489,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6237,6 +6252,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.050443503, "cost": 0.050443503,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6275,6 +6291,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6301,6 +6318,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.067582275, "cost": 0.067582275,
"cost_without_join_buffer": 0.850890015,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6327,6 +6345,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6388,6 +6407,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.034460781, "cost": 0.034460781,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6414,6 +6434,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.080024379, "cost": 0.080024379,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6452,6 +6473,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6532,6 +6554,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6558,6 +6581,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6596,6 +6620,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 6.764540577, "cost": 6.764540577,
"cost_without_join_buffer": 25.02637682,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6715,6 +6740,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.024443331, "cost": 0.024443331,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6741,6 +6767,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.024443331, "cost": 0.024443331,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6767,6 +6794,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.015203373, "cost": 0.015203373,
"cost_without_join_buffer": 0.094543335,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6793,6 +6821,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.024443331, "cost": 0.024443331,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6831,6 +6860,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6857,6 +6887,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.067582275, "cost": 0.067582275,
"cost_without_join_buffer": 0.850890015,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6883,6 +6914,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6939,6 +6971,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.034460781, "cost": 0.034460781,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -6965,6 +6998,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.080024379, "cost": 0.080024379,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7003,6 +7037,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7083,6 +7118,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7109,6 +7145,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7147,6 +7184,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 6.764540577, "cost": 6.764540577,
"cost_without_join_buffer": 25.02637682,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7258,6 +7296,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.017419989, "cost": 0.017419989,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7284,6 +7323,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.012618795, "cost": 0.012618795,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7310,6 +7350,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.017419989, "cost": 0.017419989,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7348,6 +7389,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.034460781, "cost": 0.034460781,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7374,6 +7416,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.080024379, "cost": 0.080024379,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7412,6 +7455,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7492,6 +7536,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.034303623, "cost": 0.034303623,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7518,6 +7563,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.034303623, "cost": 0.034303623,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7556,6 +7602,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7641,6 +7688,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.065233941, "cost": 0.065233941,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7667,6 +7715,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.065233941, "cost": 0.065233941,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7693,6 +7742,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.065233941, "cost": 0.065233941,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7731,6 +7781,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -7757,6 +7808,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8273,6 +8325,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8386,6 +8439,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8607,6 +8661,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8633,6 +8688,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8659,6 +8715,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8685,6 +8742,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.011523207, "cost": 0.011523207,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8711,6 +8769,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.014133225, "cost": 0.014133225,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8749,6 +8808,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.050443503, "cost": 0.050443503,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8775,6 +8835,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.024600489, "cost": 0.024600489,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8801,6 +8862,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.024600489, "cost": 0.024600489,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8827,6 +8889,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.050443503, "cost": 0.050443503,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8865,6 +8928,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8891,6 +8955,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.067582275, "cost": 0.067582275,
"cost_without_join_buffer": 0.850890015,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8917,6 +8982,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -8983,6 +9049,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.034460781, "cost": 0.034460781,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9009,6 +9076,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.080024379, "cost": 0.080024379,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9047,6 +9115,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9180,6 +9249,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.024443331, "cost": 0.024443331,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9206,6 +9276,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.024443331, "cost": 0.024443331,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9232,6 +9303,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.015203373, "cost": 0.015203373,
"cost_without_join_buffer": 0.094543335,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9258,6 +9330,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.024443331, "cost": 0.024443331,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9296,6 +9369,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9322,6 +9396,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.067582275, "cost": 0.067582275,
"cost_without_join_buffer": 0.850890015,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9348,6 +9423,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.172815333, "cost": 0.172815333,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9414,6 +9490,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9440,6 +9517,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9500,6 +9578,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9610,6 +9689,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.017419989, "cost": 0.017419989,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9636,6 +9716,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.012618795, "cost": 0.012618795,
"cost_without_join_buffer": 0.031514445,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9662,6 +9743,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.017419989, "cost": 0.017419989,
"cost_without_join_buffer": 0.034329735,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9700,6 +9782,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 3, "rows_after_filter": 3,
"rows_out": 3, "rows_out": 3,
"cost": 0.034460781, "cost": 0.034460781,
"cost_without_join_buffer": 0.283630005,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9726,6 +9809,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.080024379, "cost": 0.080024379,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9764,6 +9848,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9851,6 +9936,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.034303623, "cost": 0.034303623,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9877,6 +9963,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.034303623, "cost": 0.034303623,
"cost_without_join_buffer": 0.102989205,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -9915,6 +10002,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.261557961, "cost": 0.261557961,
"cost_without_join_buffer": 0.926902845,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10003,6 +10091,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.065233941, "cost": 0.065233941,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10029,6 +10118,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.065233941, "cost": 0.065233941,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10055,6 +10145,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.065233941, "cost": 0.065233941,
"cost_without_join_buffer": 0.308967615,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10093,6 +10184,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10119,6 +10211,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"rows_after_filter": 9, "rows_after_filter": 9,
"rows_out": 9, "rows_out": 9,
"cost": 0.628673451, "cost": 0.628673451,
"cost_without_join_buffer": 2.780708535,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10957,7 +11050,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"rows": 1000, "rows": 1000,
"rows_after_filter": 800, "rows_after_filter": 800,
"rows_out": 800, "rows_out": 800,
"cost": 0.834607, "cost": 0.8329686,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -10967,7 +11060,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"type": "scan", "type": "scan",
"rows_read": 800, "rows_read": 800,
"rows_out": 800, "rows_out": 800,
"cost": 0.834607, "cost": 0.8329686,
"uses_join_buffering": false "uses_join_buffering": false
} }
} }
@ -10978,7 +11071,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"plan_prefix": "A", "plan_prefix": "A",
"table": "B", "table": "B",
"rows_for_plan": 4000, "rows_for_plan": 4000,
"cost_for_plan": 0.84620665 "cost_for_plan": 0.84456825
} }
] ]
}, },
@ -11406,6 +11499,7 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans'))
"rows_after_filter": 10, "rows_after_filter": 10,
"rows_out": 1, "rows_out": 1,
"cost": 0.11055225, "cost": 0.11055225,
"cost_without_join_buffer": 1.159965,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -11792,6 +11886,7 @@ UPDATE t, v SET t.b = t.a, t.a = v.c WHERE v.c < t.a {
"rows_after_filter": 2, "rows_after_filter": 2,
"rows_out": 2, "rows_out": 2,
"cost": 0.012911897, "cost": 0.012911897,
"cost_without_join_buffer": 0.024837402,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }
@ -12873,7 +12968,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"rows": 9, "rows": 9,
"rows_after_filter": 0.189, "rows_after_filter": 0.189,
"rows_out": 0.017766, "rows_out": 0.017766,
"cost": 0.005814057, "cost": 0.006364199,
"chosen": true "chosen": true
} }
], ],
@ -12881,7 +12976,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"type": "range", "type": "range",
"rows_read": 0.189, "rows_read": 0.189,
"rows_out": 0.017766, "rows_out": 0.017766,
"cost": 0.005814057, "cost": 0.006364199,
"uses_join_buffering": false, "uses_join_buffering": false,
"rowid_filter_index": "b" "rowid_filter_index": "b"
} }
@ -12893,7 +12988,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
"plan_prefix": "", "plan_prefix": "",
"table": "t1", "table": "t1",
"rows_for_plan": 0.017766, "rows_for_plan": 0.017766,
"cost_for_plan": 0.005814057, "cost_for_plan": 0.006364199,
"pushdown_cond_selectivity": 0.094, "pushdown_cond_selectivity": 0.094,
"filtered": 0.1974, "filtered": 0.1974,
"rows_out": 0.017766 "rows_out": 0.017766
@ -12903,7 +12998,7 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
{ {
"best_join_order": ["t1"], "best_join_order": ["t1"],
"rows": 0.017766, "rows": 0.017766,
"cost": 0.005814057 "cost": 0.006364199
}, },
{ {
"table": "t1", "table": "t1",
@ -13332,6 +13427,7 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"rows_after_filter": 430.7688, "rows_after_filter": 430.7688,
"rows_out": 323.0766, "rows_out": 323.0766,
"cost": 1.701731924, "cost": 1.701731924,
"cost_without_join_buffer": 4.7319164,
"index_only": false, "index_only": false,
"chosen": true "chosen": true
} }

View File

@ -36,3 +36,24 @@ Warnings:
Warning 1931 Query execution was interrupted. The query examined at least ### rows, which exceeds LIMIT ROWS EXAMINED (1000). The query result may be incomplete Warning 1931 Query execution was interrupted. The query examined at least ### rows, which exceeds LIMIT ROWS EXAMINED (1000). The query result may be incomplete
DROP VIEW v; DROP VIEW v;
DROP TABLE t1, t2, t3, t4, t5, t1000, t2000; DROP TABLE t1, t2, t3, t4, t5, t1000, t2000;
#
# MDEV-31391 Assertion `((best.records_out) == 0.0 &&
# (best.records) == 0.0) ||
# (best.records_out)/(best.records) < 1.0000001' failed
#
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a), KEY(b)) ENGINE=Aria;
INSERT INTO t1 VALUES
(1,13),(2,22),(3,8),(4,88),(5,6),(7,21),(9,64),(10,14),(11,15),(12,8),
(6,20),(8,39),(13,0),(14,3),(15,54),(16,85),(17,1),(18,1),(19,0),(20,0);
CREATE TABLE t2 (c INT) ENGINE=Aria;
INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a FROM t1 JOIN t2 WHERE a = b AND c <> 7 GROUP BY a HAVING a != 6 AND a <= 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY,b PRIMARY 4 NULL 9 Using index condition; Using where; Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
SELECT a FROM t1 JOIN t2 WHERE a = b AND c <> 7 GROUP BY a HAVING a != 6 AND a <= 9;
a
DROP TABLE t1, t2;
#
# End of 11.0 tests
#

View File

@ -46,3 +46,23 @@ SELECT * FROM information_schema.TABLES
# Cleanup # Cleanup
DROP VIEW v; DROP VIEW v;
DROP TABLE t1, t2, t3, t4, t5, t1000, t2000; DROP TABLE t1, t2, t3, t4, t5, t1000, t2000;
--echo #
--echo # MDEV-31391 Assertion `((best.records_out) == 0.0 &&
--echo # (best.records) == 0.0) ||
--echo # (best.records_out)/(best.records) < 1.0000001' failed
--echo #
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a), KEY(b)) ENGINE=Aria;
INSERT INTO t1 VALUES
(1,13),(2,22),(3,8),(4,88),(5,6),(7,21),(9,64),(10,14),(11,15),(12,8),
(6,20),(8,39),(13,0),(14,3),(15,54),(16,85),(17,1),(18,1),(19,0),(20,0);
CREATE TABLE t2 (c INT) ENGINE=Aria;
INSERT INTO t2 VALUES (1),(2),(3);
EXPLAIN SELECT a FROM t1 JOIN t2 WHERE a = b AND c <> 7 GROUP BY a HAVING a != 6 AND a <= 9;
SELECT a FROM t1 JOIN t2 WHERE a = b AND c <> 7 GROUP BY a HAVING a != 6 AND a <= 9;
DROP TABLE t1, t2;
--echo #
--echo # End of 11.0 tests
--echo #

View File

@ -2831,8 +2831,8 @@ alter table t2 drop index idx1, drop index idx2, add index idx3(d,e);
explain select * from t1,t2 explain select * from t1,t2
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx3 idx3 10 NULL 5 Using index condition; Using where 1 SIMPLE t1 range idx idx 5 NULL 15 Using index condition
1 SIMPLE t1 ref idx idx 5 test.t2.d 11 1 SIMPLE t2 range idx3 idx3 10 NULL 5 Using where; Using join buffer (flat, BNL join)
explain format=json select * from t1,t2 explain format=json select * from t1,t2
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
EXPLAIN EXPLAIN
@ -2842,6 +2842,22 @@ EXPLAIN
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"nested_loop": [ "nested_loop": [
{ {
"table": {
"table_name": "t1",
"access_type": "range",
"possible_keys": ["idx"],
"key": "idx",
"key_length": "5",
"used_key_parts": ["a"],
"loops": 1,
"rows": 15,
"cost": "COST_REPLACED",
"filtered": 100,
"index_condition": "1"
}
},
{
"block-nl-join": {
"table": { "table": {
"table_name": "t2", "table_name": "t2",
"access_type": "range", "access_type": "range",
@ -2849,27 +2865,16 @@ EXPLAIN
"key": "idx3", "key": "idx3",
"key_length": "10", "key_length": "10",
"used_key_parts": ["d", "e"], "used_key_parts": ["d", "e"],
"loops": 1, "loops": 15,
"rows": 5, "rows": 5,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"filtered": 100, "filtered": 60,
"index_condition": "t2.d is not null", "attached_condition": "octet_length(t2.f) = 1"
"attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1"
}
}, },
{ "buffer_type": "flat",
"table": { "buffer_size": "461",
"table_name": "t1", "join_type": "BNL",
"access_type": "ref", "attached_condition": "t2.d = t1.a and (t1.a,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8)))"
"possible_keys": ["idx"],
"key": "idx",
"key_length": "5",
"used_key_parts": ["a"],
"ref": ["test.t2.d"],
"loops": 5,
"rows": 11,
"cost": "COST_REPLACED",
"filtered": 100
} }
} }
] ]
@ -2878,14 +2883,14 @@ EXPLAIN
select * from t1,t2 select * from t1,t2
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
a b c d e f a b c d e f
7 7 xxxyy 7 7 h 7 7 xxxya 7 7 h
7 7 xxxya 7 7 h 7 7 xxxya 7 7 h
7 7 xxxyy 7 7 h 7 7 xxxyy 7 7 h
7 7 xxxya 7 7 h 7 7 xxxyy 7 7 h
7 8 xxxxx 7 7 h 7 8 xxxxa 7 7 h
7 8 xxxxa 7 7 h 7 8 xxxxa 7 7 h
7 8 xxxxx 7 7 h 7 8 xxxxx 7 7 h
7 8 xxxxa 7 7 h 7 8 xxxxx 7 7 h
# join order: (t1,t2) with ref access of t2 # join order: (t1,t2) with ref access of t2
# range access to t1 by 1-component keys for index idx # range access to t1 by 1-component keys for index idx
explain select * from t1,t2 explain select * from t1,t2

View File

@ -2024,6 +2024,7 @@ select * from t1,t2
eval explain $q7; eval explain $q7;
--source include/explain-no-costs.inc --source include/explain-no-costs.inc
eval explain format=json $q7; eval explain format=json $q7;
--sorted_result
eval $q7; eval $q7;
--echo # join order: (t1,t2) with ref access of t2 --echo # join order: (t1,t2) with ref access of t2

View File

@ -2824,8 +2824,8 @@ alter table t2 drop index idx1, drop index idx2, add index idx3(d,e);
explain select * from t1,t2 explain select * from t1,t2
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range idx3 idx3 10 NULL 5 Using index condition; Using where; Rowid-ordered scan 1 SIMPLE t1 range idx idx 5 NULL 15 Using index condition; Rowid-ordered scan
1 SIMPLE t1 ref idx idx 5 test.t2.d 11 1 SIMPLE t2 range idx3 idx3 10 NULL 5 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
explain format=json select * from t1,t2 explain format=json select * from t1,t2
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
EXPLAIN EXPLAIN
@ -2835,6 +2835,23 @@ EXPLAIN
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"nested_loop": [ "nested_loop": [
{ {
"table": {
"table_name": "t1",
"access_type": "range",
"possible_keys": ["idx"],
"key": "idx",
"key_length": "5",
"used_key_parts": ["a"],
"loops": 1,
"rows": 15,
"cost": "COST_REPLACED",
"filtered": 100,
"index_condition": "1",
"mrr_type": "Rowid-ordered scan"
}
},
{
"block-nl-join": {
"table": { "table": {
"table_name": "t2", "table_name": "t2",
"access_type": "range", "access_type": "range",
@ -2842,28 +2859,17 @@ EXPLAIN
"key": "idx3", "key": "idx3",
"key_length": "10", "key_length": "10",
"used_key_parts": ["d", "e"], "used_key_parts": ["d", "e"],
"loops": 1, "loops": 15,
"rows": 5, "rows": 5,
"cost": "COST_REPLACED", "cost": "COST_REPLACED",
"filtered": 100, "filtered": 60,
"index_condition": "t2.d is not null", "attached_condition": "octet_length(t2.f) = 1",
"attached_condition": "(t2.d,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8))) and octet_length(t2.f) = 1",
"mrr_type": "Rowid-ordered scan" "mrr_type": "Rowid-ordered scan"
}
}, },
{ "buffer_type": "flat",
"table": { "buffer_size": "461",
"table_name": "t1", "join_type": "BNL",
"access_type": "ref", "attached_condition": "t2.d = t1.a and (t1.a,t2.e) in (<cache>((4,4)),<cache>((7,7)),<cache>((8,8)))"
"possible_keys": ["idx"],
"key": "idx",
"key_length": "5",
"used_key_parts": ["a"],
"ref": ["test.t2.d"],
"loops": 5,
"rows": 11,
"cost": "COST_REPLACED",
"filtered": 100
} }
} }
] ]
@ -2872,14 +2878,14 @@ EXPLAIN
select * from t1,t2 select * from t1,t2
where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1; where a = d and (a,e) in ((4,4),(7,7),(8,8)) and length(f) = 1;
a b c d e f a b c d e f
7 7 xxxyy 7 7 h 7 7 xxxya 7 7 h
7 7 xxxya 7 7 h 7 7 xxxya 7 7 h
7 7 xxxyy 7 7 h 7 7 xxxyy 7 7 h
7 7 xxxya 7 7 h 7 7 xxxyy 7 7 h
7 8 xxxxx 7 7 h 7 8 xxxxa 7 7 h
7 8 xxxxa 7 7 h 7 8 xxxxa 7 7 h
7 8 xxxxx 7 7 h 7 8 xxxxx 7 7 h
7 8 xxxxa 7 7 h 7 8 xxxxx 7 7 h
# join order: (t1,t2) with ref access of t2 # join order: (t1,t2) with ref access of t2
# range access to t1 by 1-component keys for index idx # range access to t1 by 1-component keys for index idx
explain select * from t1,t2 explain select * from t1,t2

View File

@ -681,3 +681,17 @@ drop table t0;
set optimizer_switch='rowid_filter=default'; set optimizer_switch='rowid_filter=default';
drop table name, flag2; drop table name, flag2;
drop table t1; drop table t1;
#
# MDEV-30944 Range_rowid_filter::fill() leaves file->keyread at MAX_KEY
#
CREATE TABLE t1 ( a varchar(30) , i int , id int, UNIQUE KEY id (id), KEY (i ,id ,a), KEY (a(1),i)) engine=myisam;
INSERT INTO t1 VALUES('fej',NULL,1),('jeyw',8,2),(NULL,181,3),('wrkovd',9,4),('',NULL,5),('ko',NULL,6),('vdgzyxkop',217,7),('',7,8),('zy',0,9),('yxkopv',8,10),('kopv',1,11),('opv',4,12),('vc',9,13),('ri',1,14),('tkcn',1,15),('cnm',6,16),('m',0,17),('d',9,18),('e',28,19),(NULL,0,20);
explain SELECT i, MAX( id ) FROM t1 WHERE ( a IS NULL OR a IN ('o','h') ) AND ( id BETWEEN 6 AND 7 OR id IN ( 8, 1) ) GROUP BY i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index id,a i 43 NULL 20 Using where; Using index
SELECT i, MAX( id ) FROM t1 WHERE ( a IS NULL OR a IN ('o','h') ) AND ( id BETWEEN 6 AND 7 OR id IN ( 8, 1) ) GROUP BY i;
i MAX( id )
drop table t1;
#
# End of 11.0 tests
#

View File

@ -2028,3 +2028,17 @@ set optimizer_switch='rowid_filter=default';
drop table name, flag2; drop table name, flag2;
drop table t1; drop table t1;
--echo #
--echo # MDEV-30944 Range_rowid_filter::fill() leaves file->keyread at MAX_KEY
--echo #
CREATE TABLE t1 ( a varchar(30) , i int , id int, UNIQUE KEY id (id), KEY (i ,id ,a), KEY (a(1),i)) engine=myisam;
INSERT INTO t1 VALUES('fej',NULL,1),('jeyw',8,2),(NULL,181,3),('wrkovd',9,4),('',NULL,5),('ko',NULL,6),('vdgzyxkop',217,7),('',7,8),('zy',0,9),('yxkopv',8,10),('kopv',1,11),('opv',4,12),('vc',9,13),('ri',1,14),('tkcn',1,15),('cnm',6,16),('m',0,17),('d',9,18),('e',28,19),(NULL,0,20);
explain SELECT i, MAX( id ) FROM t1 WHERE ( a IS NULL OR a IN ('o','h') ) AND ( id BETWEEN 6 AND 7 OR id IN ( 8, 1) ) GROUP BY i;
SELECT i, MAX( id ) FROM t1 WHERE ( a IS NULL OR a IN ('o','h') ) AND ( id BETWEEN 6 AND 7 OR id IN ( 8, 1) ) GROUP BY i;
drop table t1;
--echo #
--echo # End of 11.0 tests
--echo #

View File

@ -721,7 +721,7 @@ EXPLAIN
{ {
"query_block": { "query_block": {
"select_id": 1, "select_id": 1,
"cost": 300.4906324, "cost": 24.30051963,
"nested_loop": [ "nested_loop": [
{ {
"table": { "table": {
@ -750,7 +750,7 @@ EXPLAIN
"used_key_parts": ["a"], "used_key_parts": ["a"],
"loops": 252.56, "loops": 252.56,
"rows": 961, "rows": 961,
"cost": 299.9325764, "cost": 23.74246363,
"filtered": 56, "filtered": 56,
"index_condition": "t22.a >= '2017-02-01 00:00:00'", "index_condition": "t22.a >= '2017-02-01 00:00:00'",
"attached_condition": "t22.a >= '2017-02-01 00:00:00' and t22.b > '2017-11-01'" "attached_condition": "t22.a >= '2017-02-01 00:00:00' and t22.b > '2017-11-01'"

View File

@ -608,7 +608,7 @@ id select_type table type possible_keys key key_len ref rows Extra
# #
explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index period period 4 NULL 41810 Using index 1 SIMPLE t1 index period period 4 NULL 41810 Using where; Using index
1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index 1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index
explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra

View File

@ -619,7 +619,7 @@ id select_type table type possible_keys key key_len ref rows Extra
# #
explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index period period 4 NULL 41810 Using index 1 SIMPLE t1 index period period 4 NULL 41810 Using where; Using index
1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index 1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index
explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra

View File

@ -608,7 +608,7 @@ id select_type table type possible_keys key key_len ref rows Extra
# #
explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select count(*) from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index period period 4 NULL 41810 Using index 1 SIMPLE t1 index period period 4 NULL 41810 Using where; Using index
1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index 1 SIMPLE t3 ref period period 4 test.t1.period 4181 Using index
explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period; explain select sum(t1.price+t3.price) from t3 as t1,t3 where t1.period=t3.period order by t3.period;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra

View File

@ -1860,7 +1860,6 @@ test.t1 analyze status Table is already up to date
test.t2 analyze status Engine-independent statistics collected test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status Table is already up to date test.t2 analyze status Table is already up to date
set optimizer_switch='exists_to_in=off'; set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
SELECT * FROM t1 SELECT * FROM t1
WHERE WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
@ -1885,18 +1884,39 @@ id a
17 17 17 17
18 18 18 18
19 19 19 19
explain SELECT * FROM t1 set statement optimizer_use_condition_selectivity=2 for explain SELECT * FROM t1
WHERE WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20); WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where 3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; set statement optimizer_use_condition_selectivity=4 for explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
1 SIMPLE B ref a a 5 const 1 3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set @query="EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65";
set statement optimizer_use_condition_selectivity=2 for explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set statement optimizer_use_condition_selectivity=4 for explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
explain SELECT * FROM t1 explain SELECT * FROM t1
WHERE WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
@ -1906,7 +1926,6 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where 2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2; drop table t1,t2;
# #
# MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next # MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next

View File

@ -1262,7 +1262,6 @@ insert into t2 select seq,seq,seq from seq_1_to_100;
analyze table t1,t2 persistent for all; analyze table t1,t2 persistent for all;
set optimizer_switch='exists_to_in=off'; set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
let $query= SELECT * FROM t1 let $query= SELECT * FROM t1
WHERE WHERE
@ -1270,14 +1269,16 @@ let $query= SELECT * FROM t1
WHERE A.a=t1.a AND t2.b < 20); WHERE A.a=t1.a AND t2.b < 20);
eval $query; eval $query;
eval explain $query; eval set statement optimizer_use_condition_selectivity=2 for explain $query;
eval set statement optimizer_use_condition_selectivity=4 for explain $query;
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; set @query="EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65";
eval set statement optimizer_use_condition_selectivity=2 for explain $query;
eval set statement optimizer_use_condition_selectivity=4 for explain $query;
eval explain $query; eval explain $query;
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2; drop table t1,t2;
--echo # --echo #

View File

@ -1867,7 +1867,6 @@ test.t1 analyze status OK
test.t2 analyze status Engine-independent statistics collected test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK test.t2 analyze status OK
set optimizer_switch='exists_to_in=off'; set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
SELECT * FROM t1 SELECT * FROM t1
WHERE WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
@ -1892,18 +1891,39 @@ id a
17 17 17 17
18 18 18 18
19 19 19 19
explain SELECT * FROM t1 set statement optimizer_use_condition_selectivity=2 for explain SELECT * FROM t1
WHERE WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20); WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index 3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where 3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65; set statement optimizer_use_condition_selectivity=4 for explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1 1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
1 SIMPLE B ref a a 5 const 1 Using index 3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set @query="EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65";
set statement optimizer_use_condition_selectivity=2 for explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set statement optimizer_use_condition_selectivity=4 for explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
3 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
3 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
explain SELECT * FROM t1 explain SELECT * FROM t1
WHERE WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
@ -1913,7 +1933,6 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index 2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where 2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set optimizer_switch= @save_optimizer_switch; set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2; drop table t1,t2;
# #
# MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next # MDEV-21495: Conditional jump or move depends on uninitialised value in sel_arg_range_seq_next

View File

@ -1367,8 +1367,8 @@ GROUP BY SQ1_t1.f4));
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1 1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using temporary 3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using temporary
3 SUBQUERY SQ1_t1 index NULL f4 5 NULL 2 Using index; Using join buffer (flat, BNL join) 3 SUBQUERY SQ1_t3 range f4 f4 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE SELECT * FROM t1 WHERE
(SELECT f2 FROM t2 (SELECT f2 FROM t2
WHERE f4 <= ALL WHERE f4 <= ALL

View File

@ -196,8 +196,8 @@ ORDER BY field1 ;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where; Using filesort
1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index 1 PRIMARY alias1 eq_ref PRIMARY PRIMARY 4 alias2.f3 1 Using index
3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join) 3 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
2 DERIVED t2 ALL NULL NULL NULL NULL 2 2 DERIVED t2 ALL NULL NULL NULL NULL 2
SELECT alias2.f2 AS field1 SELECT alias2.f2 AS field1
FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1 FROM t1 AS alias1 JOIN ( SELECT * FROM t2 ) AS alias2 ON alias2.f3 = alias1.f1

View File

@ -340,9 +340,9 @@ t2.Code IN (SELECT Country FROM t3
WHERE Language='English' AND Percentage > 10 AND WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000); t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary 1 PRIMARY t3 ALL PRIMARY,Percentage NULL NULL NULL 22 Using where
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary 1 PRIMARY t1 ref Population,Country Country 3 test.t3.Country 0 Using where; LooseScan
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where 1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t3.Country 1 Using where
set optimizer_switch=@bug35674_save_optimizer_switch; set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
CREATE TABLE t1 ( CREATE TABLE t1 (

View File

@ -346,9 +346,9 @@ t2.Code IN (SELECT Country FROM t3
WHERE Language='English' AND Percentage > 10 AND WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000); t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary 1 PRIMARY t2 ALL PRIMARY,Population NULL NULL NULL 16 Using where
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary; Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Using where; Rowid-ordered scan; FirstMatch(t2); Using join buffer (flat, BNL join)
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t2.Code,const 1 Using index condition; Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
set optimizer_switch=@bug35674_save_optimizer_switch; set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
CREATE TABLE t1 ( CREATE TABLE t1 (

View File

@ -342,9 +342,9 @@ t2.Code IN (SELECT Country FROM t3
WHERE Language='English' AND Percentage > 10 AND WHERE Language='English' AND Percentage > 10 AND
t2.Population > 100000); t2.Population > 100000);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range Population,Country Population 4 NULL 1 Using index condition; Rowid-ordered scan; Start temporary 1 PRIMARY t3 ALL PRIMARY,Percentage NULL NULL NULL 22 Using where
1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t1.Country 1 Using where; End temporary 1 PRIMARY t1 ref Population,Country Country 3 test.t3.Country 0 Using where; LooseScan
1 PRIMARY t3 eq_ref PRIMARY,Percentage PRIMARY 33 test.t1.Country,const 1 Using index condition; Using where 1 PRIMARY t2 eq_ref PRIMARY,Population PRIMARY 3 test.t3.Country 1 Using where
set optimizer_switch=@bug35674_save_optimizer_switch; set optimizer_switch=@bug35674_save_optimizer_switch;
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
CREATE TABLE t1 ( CREATE TABLE t1 (
@ -1951,12 +1951,15 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index; End temporary 1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index; End temporary
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index 1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where; Start temporary; End temporary; Using join buffer (flat, BNL join) 1 PRIMARY <subquery6> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join) 1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join) 1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join)
2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where 2 MATERIALIZED t2_1 ALL id_t2,id_product NULL NULL NULL 223 Using where
4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where
5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where
6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where
set optimizer_switch='rowid_filter=default'; set optimizer_switch='rowid_filter=default';
drop table t1,t2,t3,t4,t5; drop table t1,t2,t3,t4,t5;
set global innodb_stats_persistent= @innodb_stats_persistent_save; set global innodb_stats_persistent= @innodb_stats_persistent_save;

View File

@ -1230,6 +1230,8 @@ SELECT * FROM t1 HAVING MIN(t1.c1) >= ALL(SELECT 'a' UNION SELECT 'r');
c1 c1
Warnings: Warnings:
Warning 1292 Truncated incorrect datetime value: 'r' Warning 1292 Truncated incorrect datetime value: 'r'
SELECT * FROM t1 HAVING MIN(t1.c1) > 0;
c1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 timestamp); CREATE TABLE t1 (c1 timestamp);
INSERT INTO t1 VALUES ('2010-01-01 00:00:00'); INSERT INTO t1 VALUES ('2010-01-01 00:00:00');

View File

@ -810,6 +810,7 @@ DROP TABLE t1;
CREATE TABLE t1 (c1 timestamp); CREATE TABLE t1 (c1 timestamp);
SELECT MIN(t1.c1) AS k1 FROM t1 HAVING (k1 >= ALL(SELECT 'a' UNION SELECT 'r')); SELECT MIN(t1.c1) AS k1 FROM t1 HAVING (k1 >= ALL(SELECT 'a' UNION SELECT 'r'));
SELECT * FROM t1 HAVING MIN(t1.c1) >= ALL(SELECT 'a' UNION SELECT 'r'); SELECT * FROM t1 HAVING MIN(t1.c1) >= ALL(SELECT 'a' UNION SELECT 'r');
SELECT * FROM t1 HAVING MIN(t1.c1) > 0;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 timestamp); CREATE TABLE t1 (c1 timestamp);

View File

@ -410,8 +410,11 @@ sub main {
mark_time_used('collect'); mark_time_used('collect');
mysql_install_db(default_mysqld(), "$opt_vardir/install.db") unless using_extern(); if (!using_extern())
{
mysql_install_db(default_mysqld(), "$opt_vardir/install.db");
make_readonly("$opt_vardir/install.db");
}
if ($opt_dry_run) if ($opt_dry_run)
{ {
for (@$tests) { for (@$tests) {

View File

@ -46,15 +46,23 @@ Warning 1076 The current gtid binlog state is incompatible with a former one mis
Warning 1076 The gtid domain being deleted ('1') is not in the current binlog state Warning 1076 The gtid domain being deleted ('1') is not in the current binlog state
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0); FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0);
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('1') being deleted. Make sure to first purge those files. ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('1') being deleted. Make sure to first purge those files.
MDEV-31140: Missing error from DELETE_DOMAIN_ID when gtid_binlog_state partially matches GTID_LIST.
FLUSH BINARY LOGS; FLUSH BINARY LOGS;
PURGE BINARY LOGS TO 'master-bin.000005'; PURGE BINARY LOGS TO 'master-bin.000005';
SET @@SESSION.gtid_domain_id=8;
SET @@SESSION.server_id=10*8 + 1;
INSERT INTO t SELECT 1+MAX(a) FROM t;
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0);
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('8') being deleted. Make sure to first purge those files.
FLUSH BINARY LOGS;
PURGE BINARY LOGS TO 'master-bin.000006';
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0); FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0);
Warnings: Warnings:
Warning 1076 The gtid domain being deleted ('0') is not in the current binlog state Warning 1076 The gtid domain being deleted ('0') is not in the current binlog state
Gtid_list of the current binlog does not contain 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0: Gtid_list of the current binlog does not contain 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0:
show binlog events in 'master-bin.000006' limit 1,1; show binlog events in 'master-bin.000007' limit 1,1;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000006 # Gtid_list 1 # [] master-bin.000007 # Gtid_list 1 # []
SET @@SESSION.gtid_domain_id=1;; SET @@SESSION.gtid_domain_id=1;;
SET @@SESSION.server_id=1; SET @@SESSION.server_id=1;
SET @@SESSION.gtid_seq_no=1; SET @@SESSION.gtid_seq_no=1;
@ -75,7 +83,7 @@ INSERT INTO t SET a=1;
SELECT @gtid_binlog_state_saved "as original state", @@GLOBAL.gtid_binlog_state as "out of order for 11 domain state"; SELECT @gtid_binlog_state_saved "as original state", @@GLOBAL.gtid_binlog_state as "out of order for 11 domain state";
as original state out of order for 11 domain state as original state out of order for 11 domain state
1-1-1,1-2-2,11-11-11 1-1-1,1-2-2,11-11-1 1-1-1,1-2-2,11-11-11 1-1-1,1-2-2,11-11-1
PURGE BINARY LOGS TO 'master-bin.000007'; PURGE BINARY LOGS TO 'master-bin.000008';
the following command succeeds with warnings the following command succeeds with warnings
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1); FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
Warnings: Warnings:

View File

@ -21,7 +21,6 @@ FLUSH BINARY LOGS DELETE_DOMAIN_ID = ();
--echo but with a warning --echo but with a warning
--let $binlog_pre_flush=query_get_value(SHOW MASTER STATUS, Position, 1) --let $binlog_pre_flush=query_get_value(SHOW MASTER STATUS, Position, 1)
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (99); FLUSH BINARY LOGS DELETE_DOMAIN_ID = (99);
--let $binlog_start=$binlog_pre_flush
--source include/show_binary_logs.inc --source include/show_binary_logs.inc
# Log one event in a specified domain and try to delete the domain # Log one event in a specified domain and try to delete the domain
@ -62,6 +61,8 @@ FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
# expected overrun of the static buffers of underlying dynamic arrays is doing. # expected overrun of the static buffers of underlying dynamic arrays is doing.
--let $domain_cnt=17 --let $domain_cnt=17
--let $server_in_domain_cnt=3 --let $server_in_domain_cnt=3
--let $err_domain_id=`SELECT FLOOR($domain_cnt/2)`
--let $err_server_id=`SELECT FLOOR($server_in_domain_cnt/2)`
--let $domain_list= --let $domain_list=
--disable_query_log --disable_query_log
while ($domain_cnt) while ($domain_cnt)
@ -86,6 +87,16 @@ while ($domain_cnt)
--error ER_BINLOG_CANT_DELETE_GTID_DOMAIN --error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($domain_list) --eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($domain_list)
--echo MDEV-31140: Missing error from DELETE_DOMAIN_ID when gtid_binlog_state partially matches GTID_LIST.
FLUSH BINARY LOGS;
--let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
--eval PURGE BINARY LOGS TO '$purge_to_binlog'
--eval SET @@SESSION.gtid_domain_id=$err_domain_id
--eval SET @@SESSION.server_id=10*$err_domain_id + $err_server_id
eval INSERT INTO t SELECT 1+MAX(a) FROM t;
--error ER_BINLOG_CANT_DELETE_GTID_DOMAIN
--eval FLUSH BINARY LOGS DELETE_DOMAIN_ID = ($domain_list)
# Now satisfy the safety condtion to purge log files containing $domain list # Now satisfy the safety condtion to purge log files containing $domain list
FLUSH BINARY LOGS; FLUSH BINARY LOGS;
--let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1) --let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)

View File

@ -27,3 +27,5 @@ galera_bf_kill_debug : timeout after 900 seconds
galera_ssl_upgrade : [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 130: Incorrect file format 'gtid_slave_pos' galera_ssl_upgrade : [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 130: Incorrect file format 'gtid_slave_pos'
galera_parallel_simple : timeout related to wsrep_sync_wait galera_parallel_simple : timeout related to wsrep_sync_wait
galera_insert_bulk : MDEV-30536 no expected deadlock in galera_insert_bulk test galera_insert_bulk : MDEV-30536 no expected deadlock in galera_insert_bulk test
MDEV-27713 : test is using get_lock(), which is now rejected in cluster
galera_bf_abort_group_commit : MDEV-30855 PR to remove the test exists

View File

@ -0,0 +1,21 @@
connection node_2;
connection node_1;
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1;
set wsrep_sync_wait = 0;
CREATE TABLE t1(a int not null primary key auto_increment, b int) engine=InnoDB;
INSERT INTO t1 VALUES (1,2);
connection node_1a;
BEGIN;
UPDATE t1 SET b=3 WHERE a=1;
connection node_1;
set debug_sync='wsrep_kill_before_awake_no_mutex SIGNAL before_kill WAIT_FOR continue';
connection node_1b;
set debug_sync= 'now WAIT_FOR before_kill';
connection node_2;
UPDATE t1 SET b=7 WHERE a=1;
connection node_1b;
set debug_sync= 'now SIGNAL continue';
connection node_1;
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';

View File

@ -82,6 +82,7 @@ connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
LOCK TABLE t2 WRITE; LOCK TABLE t2 WRITE;
connection node_1; connection node_1;
CREATE TABLE t1 AS SELECT * FROM t2;; CREATE TABLE t1 AS SELECT * FROM t2;;
connection node_1a;
connection node_2; connection node_2;
SELECT COUNT(*) = 5 FROM t2; SELECT COUNT(*) = 5 FROM t2;
COUNT(*) = 5 COUNT(*) = 5

View File

@ -134,6 +134,3 @@ connection node_1;
call mtr.add_suppression("Error in Log_event::read_log_event():.*"); call mtr.add_suppression("Error in Log_event::read_log_event():.*");
CALL mtr.add_suppression("conflict state 7 after post commit"); CALL mtr.add_suppression("conflict state 7 after post commit");
CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
connection node_2;
call mtr.add_suppression("Error in Log_event::read_log_event():.*");
CALL mtr.add_suppression("Skipped GCache ring buffer recovery");

View File

@ -0,0 +1,27 @@
connection node_2;
connection node_1;
connect node_1_kill, 127.0.0.1, root, , test, $NODE_MYPORT_1;
connect node_1_ctrl, 127.0.0.1, root, , test, $NODE_MYPORT_1;
SET SESSION wsrep_sync_wait = 0;
connect node_1_follower, 127.0.0.1, root, , test, $NODE_MYPORT_1;
SET SESSION wsrep_sync_wait = 0;
connection node_1;
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
SET SESSION DEBUG_SYNC = "commit_before_enqueue SIGNAL leader_before_enqueue_reached WAIT_FOR leader_before_enqueue_continue";
INSERT INTO t1 VALUES (1);
connection node_1_ctrl;
SET DEBUG_SYNC = "now WAIT_FOR leader_before_enqueue_reached";
connection node_1_follower;
INSERT INTO t1 VALUES (2);;
connection node_1_ctrl;
connection node_1_kill;
# Execute KILL QUERY for group commit follower
SET DEBUG_SYNC = "now SIGNAL leader_before_enqueue_continue";
connection node_1_follower;
connection node_1;
SELECT * FROM t1;
f1
1
2
SET DEBUG_SYNC = "RESET";
DROP TABLE t1;

View File

@ -36,7 +36,10 @@ SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
connection node_1; connection node_1;
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
1 connection node_1;
SELECT COUNT(*) FROM t1;
COUNT(*)
0
SET DEBUG_SYNC = 'RESET'; SET DEBUG_SYNC = 'RESET';
SET GLOBAL debug_dbug = NULL; SET GLOBAL debug_dbug = NULL;
DROP TABLE t1; DROP TABLE t1;

View File

@ -0,0 +1,41 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
--source include/have_debug_sync.inc
--source include/galera_have_debug_sync.inc
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
set wsrep_sync_wait = 0;
CREATE TABLE t1(a int not null primary key auto_increment, b int) engine=InnoDB;
INSERT INTO t1 VALUES (1,2);
--connection node_1a
--let $victim_id = `SELECT CONNECTION_ID()`
BEGIN;
UPDATE t1 SET b=3 WHERE a=1;
--connection node_1
set debug_sync='wsrep_kill_before_awake_no_mutex SIGNAL before_kill WAIT_FOR continue';
--disable_query_log
--disable_result_log
--send_eval KILL CONNECTION $victim_id
--enable_result_log
--enable_query_log
--connection node_1b
set debug_sync= 'now WAIT_FOR before_kill';
--connection node_2
UPDATE t1 SET b=7 WHERE a=1;
--connection node_1b
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE User = 'system user' AND State LIKE 'Update_rows_log_event%';
--source include/wait_condition.inc
set debug_sync= 'now SIGNAL continue';
--connection node_1
--reap
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';

View File

@ -113,6 +113,10 @@ LOCK TABLE t2 WRITE;
--connection node_1 --connection node_1
--send CREATE TABLE t1 AS SELECT * FROM t2; --send CREATE TABLE t1 AS SELECT * FROM t2;
--connection node_1a
--let $wait_condition = SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE STATE LIKE 'Waiting for table metadata lock%'
--source include/wait_condition.inc
--connection node_2 --connection node_2
SELECT COUNT(*) = 5 FROM t2; SELECT COUNT(*) = 5 FROM t2;
CREATE TABLE t1 AS SELECT * FROM t2; CREATE TABLE t1 AS SELECT * FROM t2;
@ -121,7 +125,7 @@ CREATE TABLE t1 AS SELECT * FROM t2;
UNLOCK TABLES; UNLOCK TABLES;
--connection node_1 --connection node_1
--error ER_TABLE_EXISTS_ERROR,ER_LOCK_DEADLOCK --error ER_TABLE_EXISTS_ERROR,ER_QUERY_INTERRUPTED
--reap --reap
DROP TABLE t1, t2; DROP TABLE t1, t2;

View File

@ -0,0 +1,5 @@
!include ../galera_2nodes.cnf
[mysqld]
log-bin
log-slave-updates

View File

@ -0,0 +1,69 @@
#
# Verify that transaction which has reached group commit queue
# cannot be killed. If the kill succeeds, assertion for
# wsrep transaction state will fail.
#
# If the bug is present, i.e. wsrep transaction gets killed during
# group commit wait, this test is enough to reproduce the crash
# most of the time.
#
--source include/have_innodb.inc
--source include/have_debug_sync.inc
--source include/galera_cluster.inc
# Connection for KILL commands
--connect node_1_kill, 127.0.0.1, root, , test, $NODE_MYPORT_1
# Connection for sync point control
--connect node_1_ctrl, 127.0.0.1, root, , test, $NODE_MYPORT_1
SET SESSION wsrep_sync_wait = 0;
# Connection for group commit follower
--connect node_1_follower, 127.0.0.1, root, , test, $NODE_MYPORT_1
# Need to disable sync wait to reach commit queue when leader
# is blocked.
SET SESSION wsrep_sync_wait = 0;
--let $follower_id = `SELECT CONNECTION_ID()`
--connection node_1
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
SET SESSION DEBUG_SYNC = "commit_before_enqueue SIGNAL leader_before_enqueue_reached WAIT_FOR leader_before_enqueue_continue";
--send INSERT INTO t1 VALUES (1)
--connection node_1_ctrl
SET DEBUG_SYNC = "now WAIT_FOR leader_before_enqueue_reached";
--connection node_1_follower
# SET SESSION DEBUG_SYNC = "group_commit_waiting_for_prior SIGNAL follower_waiting_for_prior_reached WAIT_FOR follower_waiting_for_prior_continue";
--send INSERT INTO t1 VALUES (2);
--connection node_1_ctrl
# TODO: Is it possible to use sync points to enforce group commit to happen?
# The leader will hold commit monitor in commit_before_enqueue sync point,
# which prevents the follower to reach the group commit wait state.
# We now sleep and expect the follower to reach group commit, but this
# may cause false negatives.
--sleep 1
--connection node_1_kill
--echo # Execute KILL QUERY for group commit follower
--disable_query_log
--disable_result_log
# Because it is currently impossible to verify that the
# follower has reached group commit queue, the KILL may
# sometimes return success.
--error 0,ER_KILL_DENIED_ERROR
--eval KILL QUERY $follower_id
--enable_result_log
--enable_query_log
SET DEBUG_SYNC = "now SIGNAL leader_before_enqueue_continue";
--connection node_1_follower
--reap
--connection node_1
--reap
SELECT * FROM t1;
SET DEBUG_SYNC = "RESET";
DROP TABLE t1;

View File

@ -64,6 +64,7 @@ SELECT COUNT(*) FROM t1;
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue'; SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
--connection node_1 --connection node_1
--error 0,ER_LOCK_DEADLOCK
--reap --reap
SELECT COUNT(*) FROM t1; SELECT COUNT(*) FROM t1;

View File

@ -16,7 +16,7 @@ INSERT INTO t1 (f1, f2) VALUES(1,2);
set global debug_dbug="+d,ib_purge_virtual_index_callback"; set global debug_dbug="+d,ib_purge_virtual_index_callback";
connection con1; connection con1;
COMMIT; COMMIT;
InnoDB 0 transactions not purged SET GLOBAL innodb_max_purge_lag_wait=1;
connection con2; connection con2;
commit; commit;
disconnect con1; disconnect con1;

View File

@ -78,7 +78,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR uncommitted';
# enable purge # enable purge
COMMIT; COMMIT;
# wait for purge to process the deleted records. # wait for purge to process the deleted records.
InnoDB 0 transactions not purged InnoDB 1 transactions not purged
SET DEBUG_SYNC= 'now SIGNAL purged'; SET DEBUG_SYNC= 'now SIGNAL purged';
connection default; connection default;
/* connection default */ ALTER TABLE t1 ADD COLUMN c INT GENERATED ALWAYS AS(a+b), ADD INDEX idx (c), ALGORITHM=INPLACE, LOCK=SHARED; /* connection default */ ALTER TABLE t1 ADD COLUMN c INT GENERATED ALWAYS AS(a+b), ADD INDEX idx (c), ALGORITHM=INPLACE, LOCK=SHARED;

View File

@ -23,7 +23,7 @@ set global debug_dbug="+d,ib_purge_virtual_index_callback";
connection con1; connection con1;
COMMIT; COMMIT;
--source ../innodb/include/wait_all_purged.inc SET GLOBAL innodb_max_purge_lag_wait=1;
connection con2; connection con2;
commit; commit;

View File

@ -113,7 +113,9 @@ SET DEBUG_SYNC= 'now WAIT_FOR uncommitted';
COMMIT; COMMIT;
--echo # wait for purge to process the deleted records. --echo # wait for purge to process the deleted records.
let $wait_all_purged = 1;
--source ../../innodb/include/wait_all_purged.inc --source ../../innodb/include/wait_all_purged.inc
let $wait_all_purged = 0;
SET DEBUG_SYNC= 'now SIGNAL purged'; SET DEBUG_SYNC= 'now SIGNAL purged';

View File

@ -1,31 +1,34 @@
SET @save_freq=@@GLOBAL.innodb_purge_rseg_truncate_frequency; SET @save_freq=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
CREATE TABLE t (a int PRIMARY KEY, b int NOT NULL UNIQUE) engine = InnoDB; CREATE TABLE t (a int PRIMARY KEY, b int NOT NULL UNIQUE) engine = InnoDB, STATS_PERSISTENT=0;
InnoDB 0 transactions not purged InnoDB 0 transactions not purged
connect prevent_purge,localhost,root,,; connect prevent_purge,localhost,root,,;
start transaction with consistent snapshot; start transaction with consistent snapshot;
connect con_del_1,localhost,root,,; connect con_del_1,localhost,root,,;
INSERT INTO t VALUES (20,20); INSERT INTO t VALUES (20,20);
SET DEBUG_SYNC = 'innodb_row_search_for_mysql_exit SIGNAL first_del_row_search_mvcc_finished WAIT_FOR first_del_cont'; SET DEBUG_SYNC = 'innodb_row_search_for_mysql_exit SIGNAL first_del_row_search_mvcc_finished WAIT_FOR first_del_cont';
DELETE FROM t WHERE b = 20; DELETE FROM t WHERE b = 20 # trx_1;
connect con_ins_1,localhost,root,,; connect con_ins_1,localhost,root,,;
SET DEBUG_SYNC = 'now WAIT_FOR first_del_row_search_mvcc_finished'; SET DEBUG_SYNC = 'now WAIT_FOR first_del_row_search_mvcc_finished';
SET DEBUG_SYNC = 'lock_wait_start SIGNAL first_ins_locked'; SET DEBUG_SYNC = 'lock_wait_start SIGNAL first_ins_locked';
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR first_ins_cont'; SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR first_ins_cont';
INSERT INTO t VALUES(10, 20); INSERT INTO t VALUES(10, 20) # trx_2;
connect con_del_2,localhost,root,,; connect con_del_2,localhost,root,,;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET DEBUG_SYNC = 'now WAIT_FOR first_ins_locked'; SET DEBUG_SYNC = 'now WAIT_FOR first_ins_locked';
SET DEBUG_SYNC = 'lock_wait_start SIGNAL second_del_locked'; SET DEBUG_SYNC = 'lock_wait_start SIGNAL second_del_locked';
DELETE FROM t WHERE b = 20; DELETE FROM t WHERE b = 20 # trx_3;
connection default; connection default;
SET DEBUG_SYNC = 'now WAIT_FOR second_del_locked'; SET DEBUG_SYNC = 'now WAIT_FOR second_del_locked';
SET @saved_dbug = @@GLOBAL.debug_dbug;
SET @@GLOBAL.debug_dbug="d,enable_row_purge_del_mark_exit_sync_point";
SET DEBUG_SYNC = 'now SIGNAL first_del_cont'; SET DEBUG_SYNC = 'now SIGNAL first_del_cont';
SET DEBUG_SYNC = 'now WAIT_FOR first_ins_row_inserted'; SET DEBUG_SYNC = 'now WAIT_FOR first_ins_row_inserted';
connection con_del_1; connection con_del_1;
connection default; connection default;
disconnect prevent_purge; disconnect prevent_purge;
InnoDB 0 transactions not purged SET DEBUG_SYNC = 'now WAIT_FOR row_purge_del_mark_finished';
SET @@GLOBAL.debug_dbug = @saved_dbug;
SET DEBUG_SYNC = 'now SIGNAL first_ins_cont'; SET DEBUG_SYNC = 'now SIGNAL first_ins_cont';
connection con_del_2; connection con_del_2;
connection con_ins_1; connection con_ins_1;

View File

@ -19,7 +19,7 @@ BEGIN;
UPDATE t1 SET b=4 WHERE a=3; UPDATE t1 SET b=4 WHERE a=3;
disconnect prevent_purge; disconnect prevent_purge;
connection default; connection default;
InnoDB 0 transactions not purged SET GLOBAL innodb_max_purge_lag_wait=1;
connection con1; connection con1;
ROLLBACK; ROLLBACK;
disconnect con1; disconnect con1;

View File

@ -382,11 +382,12 @@ connection stop_purge;
COMMIT; COMMIT;
disconnect stop_purge; disconnect stop_purge;
connection default; connection default;
InnoDB 0 transactions not purged InnoDB 1 transactions not purged
SET DEBUG_SYNC='now SIGNAL s2'; SET DEBUG_SYNC='now SIGNAL s2';
connection dml; connection dml;
disconnect dml; disconnect dml;
connection default; connection default;
InnoDB 0 transactions not purged
SET DEBUG_SYNC=RESET; SET DEBUG_SYNC=RESET;
DROP TABLE t1; DROP TABLE t1;
# End of 10.3 tests # End of 10.3 tests

View File

@ -1,5 +1,6 @@
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
InnoDB 0 transactions not purged
# #
# MDEV-17793 Crash in purge after instant DROP and emptying the table # MDEV-17793 Crash in purge after instant DROP and emptying the table
# #
@ -16,7 +17,7 @@ COMMIT;
START TRANSACTION WITH CONSISTENT SNAPSHOT; START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default; connection default;
ALTER TABLE t1 ADD COLUMN extra TINYINT UNSIGNED NOT NULL DEFAULT 42; ALTER TABLE t1 ADD COLUMN extra TINYINT UNSIGNED NOT NULL DEFAULT 42;
InnoDB 1 transactions not purged SET GLOBAL innodb_max_purge_lag_wait=1;
ALTER TABLE t1 DROP extra; ALTER TABLE t1 DROP extra;
disconnect prevent_purge; disconnect prevent_purge;
InnoDB 0 transactions not purged InnoDB 0 transactions not purged

View File

@ -26,4 +26,60 @@ UPDATE mysql.innodb_table_stats SET last_update=NULL WHERE table_name='t1';
XA END 'test'; XA END 'test';
XA ROLLBACK 'test'; XA ROLLBACK 'test';
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
#
#
# Testing a non-default format: Field_timestamp0 - UINT4 based
#
SET @@global.mysql56_temporal_format=0;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
Field Type Null Key Default Extra
last_update timestamp /* mariadb-5.3 */ NO current_timestamp() on update current_timestamp()
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
Field Type Null Key Default Extra
last_update timestamp /* mariadb-5.3 */ NO current_timestamp() on update current_timestamp()
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
DROP TABLE t1;
#
# Now as the table t1 is dropped, expect no statistics
#
SELECT * FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
database_name table_name last_update n_rows clustered_index_size sum_of_other_index_sizes
SELECT * FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
#
# Testing with the default format: Field_timestampf - BINARY(4) based with the UNSIGNED_FLAG
#
SET @@global.mysql56_temporal_format=1;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
Field Type Null Key Default Extra
last_update timestamp NO current_timestamp() on update current_timestamp()
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
Field Type Null Key Default Extra
last_update timestamp NO current_timestamp() on update current_timestamp()
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
DROP TABLE t1;
# End of 10.6 tests # End of 10.6 tests

View File

@ -5,7 +5,7 @@ source include/have_debug_sync.inc;
SET @save_freq=@@GLOBAL.innodb_purge_rseg_truncate_frequency; SET @save_freq=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
CREATE TABLE t (a int PRIMARY KEY, b int NOT NULL UNIQUE) engine = InnoDB; CREATE TABLE t (a int PRIMARY KEY, b int NOT NULL UNIQUE) engine = InnoDB, STATS_PERSISTENT=0;
--source include/wait_all_purged.inc --source include/wait_all_purged.inc
--connect(prevent_purge,localhost,root,,) --connect(prevent_purge,localhost,root,,)
@ -14,20 +14,20 @@ start transaction with consistent snapshot;
--connect(con_del_1,localhost,root,,) --connect(con_del_1,localhost,root,,)
INSERT INTO t VALUES (20,20); INSERT INTO t VALUES (20,20);
SET DEBUG_SYNC = 'innodb_row_search_for_mysql_exit SIGNAL first_del_row_search_mvcc_finished WAIT_FOR first_del_cont'; SET DEBUG_SYNC = 'innodb_row_search_for_mysql_exit SIGNAL first_del_row_search_mvcc_finished WAIT_FOR first_del_cont';
--send DELETE FROM t WHERE b = 20 --send DELETE FROM t WHERE b = 20 # trx_1
--connect(con_ins_1,localhost,root,,) --connect(con_ins_1,localhost,root,,)
SET DEBUG_SYNC = 'now WAIT_FOR first_del_row_search_mvcc_finished'; SET DEBUG_SYNC = 'now WAIT_FOR first_del_row_search_mvcc_finished';
# It's supposed the following INSERT will be suspended just after # It's supposed the following INSERT will be suspended just after
# lock_wait_start syncpoint, and will be awaken # lock_wait_start syncpoint, and will be awaken
# after the previous DELETE commits. ib_after_row_insert will be executed # after trx_1 DELETE commits. ib_after_row_insert will be executed
# after the INSERT is woken up. The previous DELETE will wait for # after the trx_2 INSERT is woken up. The trx_1 DELETE will wait for
# first_del_cont signal before commit, and this signal will be sent later. # first_del_cont signal before commit, and this signal will be sent later.
# So it's safe to use two signals in a row here, it's guaranted the first # So it's safe to use two signals in a row here, it's guaranted the first
# signal will be received before the second signal is sent. # signal will be received before the second signal is sent.
SET DEBUG_SYNC = 'lock_wait_start SIGNAL first_ins_locked'; SET DEBUG_SYNC = 'lock_wait_start SIGNAL first_ins_locked';
SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR first_ins_cont'; SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR first_ins_cont';
--send INSERT INTO t VALUES(10, 20) --send INSERT INTO t VALUES(10, 20) # trx_2
--connect(con_del_2,localhost,root,,) --connect(con_del_2,localhost,root,,)
# After MDEV-30225 is fixed, the following DELETE creates next-key lock for # After MDEV-30225 is fixed, the following DELETE creates next-key lock for
@ -36,24 +36,26 @@ SET DEBUG_SYNC = 'ib_after_row_insert SIGNAL first_ins_row_inserted WAIT_FOR fir
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET DEBUG_SYNC = 'now WAIT_FOR first_ins_locked'; SET DEBUG_SYNC = 'now WAIT_FOR first_ins_locked';
SET DEBUG_SYNC = 'lock_wait_start SIGNAL second_del_locked'; SET DEBUG_SYNC = 'lock_wait_start SIGNAL second_del_locked';
############################################################################### ##############################################################################
# This DELETE is locked by the previous DELETE, after that DELETE is # trx_3 DELETE is locked by trx_1 DELETE, after trx_1 DELETE is
# committed, it will still be locked by the next INSERT on delete-marked # committed, it will still be locked by trx_2 INSERT on delete-marked
# heap_no 2 record. After that INSERT inserted the record with heap_no 3, # heap_no 2 record. After trx_2 INSERT inserted the record with heap_no 3,
# and after heap_no 2 record is purged, this DELETE will be unlocked and # and after heap_no 2 record is purged, trx_3 DELETE will be unlocked and
# must restore persistent cursor position at heap_no 3 record, as it has the # must restore persistent cursor position at heap_no 3 record, as it has the
# same secondary key value as former heap_no 2 record. Then it must be blocked # same secondary key value as former heap_no 2 record. Then it must be blocked
# by the previous INSERT, and after the INSERT is committed, it must # by trx_2 INSERT, and after trx_2 INSERT is committed, it must
# delete the record, inserted by the previous INSERT, and the last INSERT(see # delete the record, inserted by trx_2 INSERT, and trx_4 INSERT(see
# below) must be finished without error. But instead this DELETE restores # below) must be finished without error. But instead this DELETE restores
# persistent cursor position to supremum, as a result, it does not delete the # persistent cursor position to supremum, as a result, it does not delete the
# record, inserted by the previous INSERT, and the last INSERT is finished with # record, inserted by trx_2 INSERT, and trx_4 INSERT is finished with
# duplicate key check error. # duplicate key check error.
############################################################################### ###############################################################################
--send DELETE FROM t WHERE b = 20 --send DELETE FROM t WHERE b = 20 # trx_3
--connection default --connection default
SET DEBUG_SYNC = 'now WAIT_FOR second_del_locked'; SET DEBUG_SYNC = 'now WAIT_FOR second_del_locked';
SET @saved_dbug = @@GLOBAL.debug_dbug;
SET @@GLOBAL.debug_dbug="d,enable_row_purge_del_mark_exit_sync_point";
SET DEBUG_SYNC = 'now SIGNAL first_del_cont'; SET DEBUG_SYNC = 'now SIGNAL first_del_cont';
SET DEBUG_SYNC = 'now WAIT_FOR first_ins_row_inserted'; SET DEBUG_SYNC = 'now WAIT_FOR first_ins_row_inserted';
--connection con_del_1 --connection con_del_1
@ -61,7 +63,8 @@ SET DEBUG_SYNC = 'now WAIT_FOR first_ins_row_inserted';
--connection default --connection default
--disconnect prevent_purge --disconnect prevent_purge
--source include/wait_all_purged.inc SET DEBUG_SYNC = 'now WAIT_FOR row_purge_del_mark_finished';
SET @@GLOBAL.debug_dbug = @saved_dbug;
SET DEBUG_SYNC = 'now SIGNAL first_ins_cont'; SET DEBUG_SYNC = 'now SIGNAL first_ins_cont';
--connection con_del_2 --connection con_del_2
@ -74,7 +77,7 @@ SET DEBUG_SYNC = 'now SIGNAL first_ins_cont';
############################################################################### ###############################################################################
# Duplicate key error is expected if the bug is not fixed. # Duplicate key error is expected if the bug is not fixed.
############################################################################### ###############################################################################
INSERT INTO t VALUES(30, 20); INSERT INTO t VALUES(30, 20); # trx_4
--disconnect con_ins_1 --disconnect con_ins_1
--disconnect con_del_1 --disconnect con_del_1

View File

@ -32,7 +32,7 @@ UPDATE t1 SET b=4 WHERE a=3;
--connection default --connection default
# Initiate a full purge, which should reset the DB_TRX_ID except for a=3. # Initiate a full purge, which should reset the DB_TRX_ID except for a=3.
--source include/wait_all_purged.inc SET GLOBAL innodb_max_purge_lag_wait=1;
# Initiate a ROLLBACK of the update, which should reset the DB_TRX_ID for a=3. # Initiate a ROLLBACK of the update, which should reset the DB_TRX_ID for a=3.
--connection con1 --connection con1
ROLLBACK; ROLLBACK;

View File

@ -445,7 +445,9 @@ COMMIT;
disconnect stop_purge; disconnect stop_purge;
connection default; connection default;
let $wait_all_purged = 1;
--source include/wait_all_purged.inc --source include/wait_all_purged.inc
let $wait_all_purged = 0;
SET DEBUG_SYNC='now SIGNAL s2'; SET DEBUG_SYNC='now SIGNAL s2';
connection dml; connection dml;
@ -453,6 +455,7 @@ reap;
disconnect dml; disconnect dml;
connection default; connection default;
--source include/wait_all_purged.inc
SET DEBUG_SYNC=RESET; SET DEBUG_SYNC=RESET;
DROP TABLE t1; DROP TABLE t1;

View File

@ -6,6 +6,7 @@ if ($have_debug) {
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
--source include/wait_all_purged.inc
--echo # --echo #
--echo # MDEV-17793 Crash in purge after instant DROP and emptying the table --echo # MDEV-17793 Crash in purge after instant DROP and emptying the table
@ -27,8 +28,7 @@ START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default; connection default;
ALTER TABLE t1 ADD COLUMN extra TINYINT UNSIGNED NOT NULL DEFAULT 42; ALTER TABLE t1 ADD COLUMN extra TINYINT UNSIGNED NOT NULL DEFAULT 42;
let $wait_all_purged= 1; SET GLOBAL innodb_max_purge_lag_wait=1;
--source include/wait_all_purged.inc
ALTER TABLE t1 DROP extra; ALTER TABLE t1 DROP extra;
disconnect prevent_purge; disconnect prevent_purge;
let $wait_all_purged= 0; let $wait_all_purged= 0;

View File

@ -1,6 +1,10 @@
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_sequence.inc --source include/have_sequence.inc
--disable_query_log
call mtr.add_suppression("InnoDB: Difficult to find free blocks in the buffer pool");
--enable_query_log
# Ensure that the history list length will actually be decremented by purge. # Ensure that the history list length will actually be decremented by purge.
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;

View File

@ -28,4 +28,57 @@ XA END 'test';
XA ROLLBACK 'test'; XA ROLLBACK 'test';
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
--echo #
# The following tests demonstrate that these columns:
# - innodb_table_stats.last_update
# - innodb_index_stats.last_update
# have sane values close to NOW(), rather than any garbage,
# with all TIMESTAMP formats.
--echo #
--echo # Testing a non-default format: Field_timestamp0 - UINT4 based
--echo #
SET @@global.mysql56_temporal_format=0;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
DROP TABLE t1;
--echo #
--echo # Now as the table t1 is dropped, expect no statistics
--echo #
SELECT * FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT * FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
--echo #
--echo # Testing with the default format: Field_timestampf - BINARY(4) based with the UNSIGNED_FLAG
--echo #
SET @@global.mysql56_temporal_format=1;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
DROP TABLE t1;
--echo # End of 10.6 tests --echo # End of 10.6 tests

View File

@ -364,8 +364,8 @@ EXPLAIN
SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx) SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx)
WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 16 Using index condition; Rowid-ordered scan 1 SIMPLE t1 index NULL idx 7 NULL 15 Using index
1 SIMPLE t1 index NULL idx 7 NULL 15 Using index; Using join buffer (flat, BNL join) 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 16 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 25 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) 1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 25 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
SELECT COUNT(t1.v) FROM t1, t2, t3 SELECT COUNT(t1.v) FROM t1, t2, t3
WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0; WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;

View File

@ -3898,6 +3898,21 @@ DROP TABLE t1;
DROP TABLE m1; DROP TABLE m1;
set global default_storage_engine=@save_default_storage_engine; set global default_storage_engine=@save_default_storage_engine;
# #
# MDEV-31083 ASAN use-after-poison in myrg_attach_children
#
CREATE TABLE t1 (f TEXT, FULLTEXT (f)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo'),('bar');
CREATE TABLE mrg (f TEXT) ENGINE=MERGE, UNION(t1);
SELECT * FROM mrg;
f
foo
bar
DROP TABLE mrg, t1;
End of 10.5 tests
#
# End of 10.0 tests
#
#
# MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results
# #
create table t (a int, key(a desc)) engine=myisam; create table t (a int, key(a desc)) engine=myisam;

View File

@ -2859,6 +2859,22 @@ set global default_storage_engine=@save_default_storage_engine;
# gone so execution of other tests won't be affected by their presence. # gone so execution of other tests won't be affected by their presence.
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
--echo #
--echo # MDEV-31083 ASAN use-after-poison in myrg_attach_children
--echo #
CREATE TABLE t1 (f TEXT, FULLTEXT (f)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo'),('bar');
CREATE TABLE mrg (f TEXT) ENGINE=MERGE, UNION(t1);
SELECT * FROM mrg;
DROP TABLE mrg, t1;
--echo End of 10.5 tests
--echo #
--echo # End of 10.0 tests
--echo #
--echo # --echo #
--echo # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results --echo # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results
--echo # --echo #

View File

@ -0,0 +1,26 @@
CREATE TABLE t1(f1 INT, f2 INT, INDEX(f1))ENGINE=InnoDB
PARTITION BY LIST(f1) (
PARTITION p1 VALUES in (1, 2, 3),
PARTITION p2 VALUES in (4, 5, 6));
INSERT INTO t1 VALUES(1, 1), (1, 1), (6, 1);
connect con1,localhost,root,,,;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connect con2,localhost,root,,,;
SET DEBUG_SYNC="innodb_rollback_inplace_alter_table SIGNAL default_resume WAIT_FOR alter_resume";
ALTER TABLE t1 ADD UNIQUE INDEX(f1);
connection default;
set DEBUG_SYNC="now WAIT_FOR default_resume";
SET DEBUG_SYNC="innodb_row_update_for_mysql_begin SIGNAL alter_resume WAIT_FOR alter_finish";
DELETE FROM t1;
connection con2;
ERROR 23000: Duplicate entry '1' for key 'f1_2'
SET DEBUG_SYNC="now SIGNAL alter_finish";
connection default;
connection con1;
commit;
connection default;
disconnect con1;
disconnect con2;
InnoDB 0 transactions not purged
drop table t1;
SET DEBUG_SYNC=reset;

View File

@ -0,0 +1 @@
--innodb_purge_threads=1

View File

@ -0,0 +1,37 @@
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
CREATE TABLE t1(f1 INT, f2 INT, INDEX(f1))ENGINE=InnoDB
PARTITION BY LIST(f1) (
PARTITION p1 VALUES in (1, 2, 3),
PARTITION p2 VALUES in (4, 5, 6));
INSERT INTO t1 VALUES(1, 1), (1, 1), (6, 1);
connect(con1,localhost,root,,,);
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connect(con2,localhost,root,,,);
SET DEBUG_SYNC="innodb_rollback_inplace_alter_table SIGNAL default_resume WAIT_FOR alter_resume";
send ALTER TABLE t1 ADD UNIQUE INDEX(f1);
connection default;
set DEBUG_SYNC="now WAIT_FOR default_resume";
SET DEBUG_SYNC="innodb_row_update_for_mysql_begin SIGNAL alter_resume WAIT_FOR alter_finish";
send DELETE FROM t1;
connection con2;
--error ER_DUP_ENTRY
reap;
SET DEBUG_SYNC="now SIGNAL alter_finish";
connection default;
reap;
connection con1;
commit;
connection default;
disconnect con1;
disconnect con2;
--source ../../innodb/include/wait_all_purged.inc
drop table t1;
SET DEBUG_SYNC=reset;

View File

@ -14,6 +14,7 @@ Audit_null_called 9
Audit_null_general_error 1 Audit_null_general_error 1
Audit_null_general_log 3 Audit_null_general_log 3
Audit_null_general_result 2 Audit_null_general_result 2
Audit_null_general_warning 1
create procedure au1(x char(16)) select concat("test1", x); create procedure au1(x char(16)) select concat("test1", x);
call au1("-12"); call au1("-12");
concat("test1", x) concat("test1", x)
@ -24,6 +25,7 @@ Audit_null_called 22
Audit_null_general_error 1 Audit_null_general_error 1
Audit_null_general_log 7 Audit_null_general_log 7
Audit_null_general_result 5 Audit_null_general_result 5
Audit_null_general_warning 1
create table t1 (a int); create table t1 (a int);
insert t1 values (1), (2); insert t1 values (1), (2);
select * from t1; select * from t1;

View File

@ -268,6 +268,13 @@ drop database sa_db;
select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'); select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
length('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 length('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
2750 2750
CREATE TABLE test.t1 (a char(4));
set sql_mode="";
insert into test.t1 value("12345");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
set sql_mode=default;
drop table test.t1;
set global server_audit_file_path='.'; set global server_audit_file_path='.';
show status like 'server_audit_current_log'; show status like 'server_audit_current_log';
Variable_name Value Variable_name Value
@ -505,6 +512,21 @@ TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,proc,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event, TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,event,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop database sa_db',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select length(\'012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'select length(\'012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567',0
TIME,HOSTNAME,root,localhost,ID,ID,CREATE,test,t1,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'CREATE TABLE test.t1 (a char(4))',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set sql_mode=""',0
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,test,t1,
TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,table_stats,
TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,column_stats,
TIME,HOSTNAME,root,localhost,ID,ID,READ,mysql,index_stats,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'insert into test.t1 value("12345")',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'SHOW WARNINGS',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set sql_mode=default',0
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,table_stats,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,column_stats,
TIME,HOSTNAME,root,localhost,ID,ID,WRITE,mysql,index_stats,
TIME,HOSTNAME,root,localhost,ID,ID,DROP,test,t1,
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'drop table test.t1',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'set global server_audit_file_path=\'.\'',0
TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0 TIME,HOSTNAME,root,localhost,ID,ID,QUERY,sa_db,'show status like \'server_audit_current_log\'',0

View File

@ -44,6 +44,13 @@ END|
CALL e1(); CALL e1();
ERROR 42S02: Table 'test.non_exists' doesn't exist ERROR 42S02: Table 'test.non_exists' doesn't exist
DROP PROCEDURE e1; DROP PROCEDURE e1;
CREATE TABLE t1 (a char(4));
set sql_mode="";
insert into t1 value("12345");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
set sql_mode=default;
drop table t1;
uninstall plugin SQL_ERROR_LOG; uninstall plugin SQL_ERROR_LOG;
Warnings: Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown Warning 1620 Plugin is busy and will be uninstalled on shutdown
@ -55,3 +62,5 @@ MYSQL_ERRNO = 1000,
MESSAGE_TEXT = 'new message' MESSAGE_TEXT = 'new message'
TIME HOSTNAME ERROR 1366: Incorrect integer value: 'aa' for column `test`.`t1`.`id` at row 1 : insert into t1 values ('aa') TIME HOSTNAME ERROR 1366: Incorrect integer value: 'aa' for column `test`.`t1`.`id` at row 1 : insert into t1 values ('aa')
TIME HOSTNAME ERROR 1146: Table 'test.non_exists' doesn't exist : INSERT INTO test.non_exists VALUES (0,0,0) /* e1 */ TIME HOSTNAME ERROR 1146: Table 'test.non_exists' doesn't exist : INSERT INTO test.non_exists VALUES (0,0,0) /* e1 */
TIME HOSTNAME WARNING 1265: Data truncated for column 'a' at row 1 : insert into t1 value("12345")
TIME HOSTNAME WARNING 1620: Plugin is busy and will be uninstalled on shutdown : uninstall plugin SQL_ERROR_LOG

View File

@ -218,6 +218,12 @@ drop database sa_db;
select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'); select length('01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789');
CREATE TABLE test.t1 (a char(4));
set sql_mode="";
insert into test.t1 value("12345");
set sql_mode=default;
drop table test.t1;
set global server_audit_file_path='.'; set global server_audit_file_path='.';
--replace_regex /\.[\\\/]/HOME_DIR\// --replace_regex /\.[\\\/]/HOME_DIR\//
show status like 'server_audit_current_log'; show status like 'server_audit_current_log';

View File

@ -1,4 +1,3 @@
--source include/not_embedded.inc --source include/not_embedded.inc
if (!$SQL_ERRLOG_SO) { if (!$SQL_ERRLOG_SO) {
@ -66,10 +65,16 @@ DELIMITER ;|
CALL e1(); CALL e1();
DROP PROCEDURE e1; DROP PROCEDURE e1;
CREATE TABLE t1 (a char(4));
set sql_mode="";
insert into t1 value("12345");
set sql_mode=default;
drop table t1;
uninstall plugin SQL_ERROR_LOG; uninstall plugin SQL_ERROR_LOG;
let $MYSQLD_DATADIR= `SELECT @@datadir`; let $MYSQLD_DATADIR= `SELECT @@datadir`;
# replace the timestamp and the hostname with constant values # replace the timestamp and the hostname with constant values
--replace_regex /[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [^E]*/TIME HOSTNAME / --replace_regex /[1-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [^EW]*/TIME HOSTNAME /
cat_file $MYSQLD_DATADIR/sql_errors.log; cat_file $MYSQLD_DATADIR/sql_errors.log;
remove_file $MYSQLD_DATADIR/sql_errors.log;

View File

@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY
SESSION_VALUE NULL SESSION_VALUE NULL
GLOBAL_VALUE alpha GLOBAL_VALUE alpha
GLOBAL_VALUE_ORIGIN CONFIG GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE beta DEFAULT_VALUE alpha
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE ENUM VARIABLE_TYPE ENUM
VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded

View File

@ -30,6 +30,7 @@
static volatile int ncalls; /* for SHOW STATUS, see below */ static volatile int ncalls; /* for SHOW STATUS, see below */
static volatile int ncalls_general_log; static volatile int ncalls_general_log;
static volatile int ncalls_general_error; static volatile int ncalls_general_error;
static volatile int ncalls_general_warning;
static volatile int ncalls_general_result; static volatile int ncalls_general_result;
FILE *f; FILE *f;
@ -53,6 +54,7 @@ static int audit_null_plugin_init(void *arg __attribute__((unused)))
ncalls= 0; ncalls= 0;
ncalls_general_log= 0; ncalls_general_log= 0;
ncalls_general_error= 0; ncalls_general_error= 0;
ncalls_general_warning= 0;
ncalls_general_result= 0; ncalls_general_result= 0;
f = fopen("audit_null_tables.log", "w"); f = fopen("audit_null_tables.log", "w");
@ -113,6 +115,9 @@ static void audit_null_notify(MYSQL_THD thd __attribute__((unused)),
case MYSQL_AUDIT_GENERAL_ERROR: case MYSQL_AUDIT_GENERAL_ERROR:
ncalls_general_error++; ncalls_general_error++;
break; break;
case MYSQL_AUDIT_GENERAL_WARNING:
ncalls_general_warning++;
break;
case MYSQL_AUDIT_GENERAL_RESULT: case MYSQL_AUDIT_GENERAL_RESULT:
ncalls_general_result++; ncalls_general_result++;
break; break;
@ -179,6 +184,7 @@ static struct st_mysql_show_var simple_status[]=
{ "general_error", (char *) &ncalls_general_error, SHOW_INT }, { "general_error", (char *) &ncalls_general_error, SHOW_INT },
{ "general_log", (char *) &ncalls_general_log, SHOW_INT }, { "general_log", (char *) &ncalls_general_log, SHOW_INT },
{ "general_result", (char *) &ncalls_general_result, SHOW_INT }, { "general_result", (char *) &ncalls_general_result, SHOW_INT },
{ "general_warning", (char *) &ncalls_general_error, SHOW_INT },
{ 0, 0, 0} { 0, 0, 0}
}; };

View File

@ -84,8 +84,11 @@ static void log_sql_errors(MYSQL_THD thd __attribute__((unused)),
const struct mysql_event_general *event = const struct mysql_event_general *event =
(const struct mysql_event_general*)ev; (const struct mysql_event_general*)ev;
if (rate && if (rate &&
event->event_subclass == MYSQL_AUDIT_GENERAL_ERROR) (event->event_subclass == MYSQL_AUDIT_GENERAL_ERROR ||
event->event_subclass == MYSQL_AUDIT_GENERAL_WARNING))
{ {
const char *type= (event->event_subclass == MYSQL_AUDIT_GENERAL_ERROR ?
"ERROR" : "WARNING");
if (++count >= rate) if (++count >= rate)
{ {
struct tm t; struct tm t;
@ -94,10 +97,10 @@ static void log_sql_errors(MYSQL_THD thd __attribute__((unused)),
count = 0; count = 0;
(void) localtime_r(&event_time, &t); (void) localtime_r(&event_time, &t);
logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d " logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d "
"%s ERROR %d: %s : %s\n", "%s %s %d: %s : %s\n",
t.tm_year + 1900, t.tm_mon + 1, t.tm_year + 1900, t.tm_mon + 1,
t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
event->general_user, event->general_error_code, event->general_user, type, event->general_error_code,
event->general_command, event->general_query); event->general_command, event->general_query);
} }
} }

View File

@ -0,0 +1,17 @@
# Copyright (c) 2019, MariaDB corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software 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 Street, Fifth Floor, Boston, MA 02110-1335 USA
MYSQL_ADD_PLUGIN(type_mysql_timestamp plugin.cc RECOMPILE_FOR_EMBEDDED
MODULE_ONLY COMPONENT Test)

View File

@ -0,0 +1 @@
--plugin-load-add=$TYPE_MYSQL_TIMESTAMP_SO

View File

@ -0,0 +1,10 @@
package My::Suite::Type_test;
@ISA = qw(My::Suite);
return "No TYPE_TEST plugin" unless $ENV{TYPE_MYSQL_TIMESTAMP_SO};
sub is_default { 1 }
bless { };

View File

@ -0,0 +1,45 @@
#
# MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
#
SELECT
PLUGIN_NAME,
PLUGIN_VERSION,
PLUGIN_STATUS,
PLUGIN_TYPE,
PLUGIN_AUTHOR,
PLUGIN_DESCRIPTION,
PLUGIN_LICENSE,
PLUGIN_MATURITY,
PLUGIN_AUTH_VERSION
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_TYPE='DATA TYPE'
AND PLUGIN_NAME LIKE 'type_mysql_timestamp';
PLUGIN_NAME type_mysql_timestamp
PLUGIN_VERSION 1.0
PLUGIN_STATUS ACTIVE
PLUGIN_TYPE DATA TYPE
PLUGIN_AUTHOR MariaDB Corporation
PLUGIN_DESCRIPTION Data type TYPE_MYSQL_TIMESTAMP
PLUGIN_LICENSE GPL
PLUGIN_MATURITY Experimental
PLUGIN_AUTH_VERSION 1.0
CREATE TABLE t1 (a TYPE_MYSQL_TIMESTAMP);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` type_mysql_timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;
CREATE TABLE t1 (a TIMESTAMP);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
ALTER TABLE t1 MODIFY a TYPE_MYSQL_TIMESTAMP;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` type_mysql_timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;

View File

@ -0,0 +1,31 @@
--source include/have_innodb.inc
--echo #
--echo # MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
--echo #
--vertical_results
SELECT
PLUGIN_NAME,
PLUGIN_VERSION,
PLUGIN_STATUS,
PLUGIN_TYPE,
PLUGIN_AUTHOR,
PLUGIN_DESCRIPTION,
PLUGIN_LICENSE,
PLUGIN_MATURITY,
PLUGIN_AUTH_VERSION
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_TYPE='DATA TYPE'
AND PLUGIN_NAME LIKE 'type_mysql_timestamp';
--horizontal_results
CREATE TABLE t1 (a TYPE_MYSQL_TIMESTAMP);
SHOW CREATE TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a TIMESTAMP);
SHOW CREATE TABLE t1;
ALTER TABLE t1 MODIFY a TYPE_MYSQL_TIMESTAMP;
SHOW CREATE TABLE t1;
DROP TABLE t1;

View File

@ -0,0 +1,108 @@
#
# MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
#
SET @@global.innodb_stats_persistent=0;
SHOW CREATE TABLE mysql.innodb_table_stats;
Table Create Table
innodb_table_stats CREATE TABLE `innodb_table_stats` (
`database_name` varchar(64) NOT NULL,
`table_name` varchar(199) NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`n_rows` bigint(20) unsigned NOT NULL,
`clustered_index_size` bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_table_stats;
Table Create Table
innodb_table_stats CREATE TABLE `innodb_table_stats` (
`database_name` varchar(64) NOT NULL,
`table_name` varchar(199) NOT NULL,
`last_update` type_mysql_timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`n_rows` bigint(20) unsigned NOT NULL,
`clustered_index_size` bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_index_stats;
Table Create Table
innodb_index_stats CREATE TABLE `innodb_index_stats` (
`database_name` varchar(64) NOT NULL,
`table_name` varchar(199) NOT NULL,
`index_name` varchar(64) NOT NULL,
`last_update` type_mysql_timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`stat_name` varchar(64) NOT NULL,
`stat_value` bigint(20) unsigned NOT NULL,
`sample_size` bigint(20) unsigned DEFAULT NULL,
`stat_description` varchar(1024) NOT NULL,
PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0
SET @@global.innodb_stats_persistent=1;
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (10);
DROP TABLE t1;
SET @@global.innodb_stats_persistent=0;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_table_stats;
Table Create Table
innodb_table_stats CREATE TABLE `innodb_table_stats` (
`database_name` varchar(64) NOT NULL,
`table_name` varchar(199) NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`n_rows` bigint(20) unsigned NOT NULL,
`clustered_index_size` bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`database_name`,`table_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_index_stats;
Table Create Table
innodb_index_stats CREATE TABLE `innodb_index_stats` (
`database_name` varchar(64) NOT NULL,
`table_name` varchar(199) NOT NULL,
`index_name` varchar(64) NOT NULL,
`last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`stat_name` varchar(64) NOT NULL,
`stat_value` bigint(20) unsigned NOT NULL,
`sample_size` bigint(20) unsigned DEFAULT NULL,
`stat_description` varchar(1024) NOT NULL,
PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin STATS_PERSISTENT=0
SET @@global.innodb_stats_persistent=1;
#
# Testing MySQL-5.6-alike Field_timestampf: BINARY(4) based, without UNSIGNED_FLAG
#
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
Field Type Null Key Default Extra
last_update type_mysql_timestamp NO current_timestamp() on update current_timestamp()
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
Field Type Null Key Default Extra
last_update type_mysql_timestamp NO current_timestamp() on update current_timestamp()
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
DROP TABLE t1;
#
# Now as the table t1 is dropped, expect no statistics
#
SELECT * FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
database_name table_name last_update n_rows clustered_index_size sum_of_other_index_sizes
SELECT * FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
#
# Restore the structure of the tables
#
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();

View File

@ -0,0 +1,62 @@
--source include/have_innodb.inc
--echo #
--echo # MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
--echo #
SET @@global.innodb_stats_persistent=0;
SHOW CREATE TABLE mysql.innodb_table_stats;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_table_stats;
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_index_stats;
SET @@global.innodb_stats_persistent=1;
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (10);
DROP TABLE t1;
SET @@global.innodb_stats_persistent=0;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_table_stats;
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW CREATE TABLE mysql.innodb_index_stats;
SET @@global.innodb_stats_persistent=1;
# The following test demonstrate that these columns:
# - innodb_table_stats.last_update
# - innodb_index_stats.last_update
# have sane values close to NOW(), rather than any garbage,
# with MySQL-alike Field_timestampf
--echo #
--echo # Testing MySQL-5.6-alike Field_timestampf: BINARY(4) based, without UNSIGNED_FLAG
--echo #
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TYPE_MYSQL_TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
DROP TABLE t1;
--echo #
--echo # Now as the table t1 is dropped, expect no statistics
--echo #
SELECT * FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT * FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
--echo #
--echo # Restore the structure of the tables
--echo #
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();

View File

@ -0,0 +1,177 @@
/*
Copyright (c) 2023, 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 <my_global.h>
#include <sql_class.h>
#include <mysql/plugin_data_type.h>
#include "sql_type.h"
class Type_collection_local: public Type_collection
{
protected:
const Type_handler *aggregate_common(const Type_handler *h1,
const Type_handler *h2) const;
public:
const Type_handler *handler_by_name(const LEX_CSTRING &name) const override
{
return NULL;
}
const Type_handler *aggregate_for_result(const Type_handler *h1,
const Type_handler *h2)
const override
{
return aggregate_common(h1, h2);
}
const Type_handler *aggregate_for_comparison(const Type_handler *h1,
const Type_handler *h2)
const override
{
return aggregate_common(h1, h2);
}
const Type_handler *aggregate_for_min_max(const Type_handler *h1,
const Type_handler *h2)
const override
{
return aggregate_common(h1, h2);
}
const Type_handler *aggregate_for_num_op(const Type_handler *h1,
const Type_handler *h2)
const override
{
return aggregate_common(h1, h2);
}
};
static Type_collection_local type_collection_local;
/*
A more MySQL compatible Field:
it does not set the UNSIGNED_FLAG.
This is how MySQL's Field_timestampf works.
*/
class Field_mysql_timestampf :public Field_timestampf
{
public:
Field_mysql_timestampf(const LEX_CSTRING &name,
const Record_addr &addr,
enum utype unireg_check_arg,
TABLE_SHARE *share, decimal_digits_t dec_arg)
:Field_timestampf(addr.ptr(), addr.null_ptr(), addr.null_bit(),
unireg_check_arg, &name, share, dec_arg)
{
flags&= ~UNSIGNED_FLAG; // MySQL compatibility
}
void sql_type(String &str) const override
{
sql_type_opt_dec_comment(str,
Field_mysql_timestampf::type_handler()->name(),
dec, type_version_mysql56());
}
const Type_handler *type_handler() const override;
};
class Type_handler_mysql_timestamp2: public Type_handler_timestamp2
{
public:
const Type_collection *type_collection() const override
{
return &type_collection_local;
}
Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *root,
const LEX_CSTRING *name,
const Record_addr &rec, const Bit_addr &bit,
const Column_definition_attributes *attr,
uint32 flags) const override
{
return new (root)
Field_mysql_timestampf(*name, rec, attr->unireg_check, share,
attr->temporal_dec(MAX_DATETIME_WIDTH));
}
void Column_definition_implicit_upgrade(Column_definition *c) const override
{
/*
Suppress the automatic upgrade depending on opt_mysql56_temporal_format,
derived from Type_handler_timestamp_common.
*/
}
};
static Type_handler_mysql_timestamp2 type_handler_mysql_timestamp2;
const Type_handler *Field_mysql_timestampf::type_handler() const
{
return &type_handler_mysql_timestamp2;
}
const Type_handler *
Type_collection_local::aggregate_common(const Type_handler *h1,
const Type_handler *h2) const
{
if (h1 == h2)
return h1;
static const Type_aggregator::Pair agg[]=
{
{
&type_handler_timestamp2,
&type_handler_mysql_timestamp2,
&type_handler_mysql_timestamp2
},
{NULL,NULL,NULL}
};
return Type_aggregator::find_handler_in_array(agg, h1, h2, true);
}
static struct st_mariadb_data_type plugin_descriptor_type_mysql_timestamp=
{
MariaDB_DATA_TYPE_INTERFACE_VERSION,
&type_handler_mysql_timestamp2
};
/*************************************************************************/
maria_declare_plugin(type_mysql_timestamp)
{
MariaDB_DATA_TYPE_PLUGIN, // the plugin type (see include/mysql/plugin.h)
&plugin_descriptor_type_mysql_timestamp, // pointer to type-specific plugin descriptor
"type_mysql_timestamp", // plugin name
"MariaDB Corporation", // plugin author
"Data type TYPE_MYSQL_TIMESTAMP", // the plugin description
PLUGIN_LICENSE_GPL, // the plugin license (see include/mysql/plugin.h)
0, // Pointer to plugin initialization function
0, // Pointer to plugin deinitialization function
0x0100, // Numeric version 0xAABB means AA.BB version
NULL, // Status variables
NULL, // System variables
"1.0", // String version representation
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL // Maturity(see include/mysql/plugin.h)*/
}
maria_declare_plugin_end;

View File

@ -3354,7 +3354,7 @@ public:
/** /**
TIMESTAMP(0..6) - MySQL56 version TIMESTAMP(0..6) - MySQL56 version
*/ */
class Field_timestampf final :public Field_timestamp_with_dec { class Field_timestampf :public Field_timestamp_with_dec {
void store_TIMEVAL(const timeval &tv) override; void store_TIMEVAL(const timeval &tv) override;
public: public:
Field_timestampf(uchar *ptr_arg, Field_timestampf(uchar *ptr_arg,

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