1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Merge 10.6 into 10.8

This commit is contained in:
Marko Mäkelä
2023-05-11 09:00:27 +03:00
10 changed files with 277 additions and 156 deletions

View File

@@ -1,12 +1,18 @@
#!/bin/bash #!/bin/bash
set -e set -e
# shellcheck source=/dev/null
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file # Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}" MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
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
@@ -24,7 +30,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
@@ -64,21 +72,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...
@@ -112,17 +125,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
@@ -183,26 +208,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
@@ -215,8 +244,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
@@ -228,14 +259,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
@@ -255,19 +286,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,12 +1,18 @@
#!/bin/bash #!/bin/bash
set -e set -e
# shellcheck source=/dev/null
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file # Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}" MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
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"
@@ -17,7 +23,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
@@ -26,7 +35,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
@@ -38,7 +48,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
@@ -54,7 +65,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-$MAJOR_VER.flag" ]; then if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-$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
@@ -62,7 +74,8 @@ if [ "$1" = "purge" ] && [ -f "/var/lib/mysql/debian-$MAJOR_VER.flag" ]; then
db_input high "mariadb-server-$MAJOR_VER/postrm_remove_databases" || true db_input high "mariadb-server-$MAJOR_VER/postrm_remove_databases" || true
db_go || true db_go || true
db_get "mariadb-server-$MAJOR_VER/postrm_remove_databases" || true db_get "mariadb-server-$MAJOR_VER/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
@@ -92,6 +105,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,17 +7,23 @@
# * <old-preinst> abort-upgrade <new-version> # * <old-preinst> abort-upgrade <new-version>
# #
# shellcheck source=/dev/null
. /usr/share/debconf/confmodule . /usr/share/debconf/confmodule
# Automatically set version to ease maintenance of this file # Automatically set version to ease maintenance of this file
MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}" MAJOR_VER="${DPKG_MAINTSCRIPT_PACKAGE#mariadb-server-}"
# 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
@@ -31,7 +37,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
@@ -40,7 +49,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
@@ -57,7 +67,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,
@@ -92,7 +102,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
@@ -134,7 +144,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-$MAJOR_VER/old_data_directory_saved" || true db_input critical "mariadb-server-$MAJOR_VER/old_data_directory_saved" || true
db_go db_go
@@ -155,7 +165,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
@@ -170,13 +181,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 \
@@ -194,7 +207,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.
@@ -204,7 +218,8 @@ 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
@@ -212,7 +227,8 @@ fi
# 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 "$datadir" | tail -n 1` df_available_blocks=`LC_ALL=C BLOCKSIZE= df --output=avail "$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
@@ -231,7 +247,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

@@ -608,4 +608,25 @@ SET GLOBAL innodb_compression_level=0;
INSERT INTO t1 VALUES (''); INSERT INTO t1 VALUES ('');
SET GLOBAL innodb_compression_level= @save_innodb_compression_level; SET GLOBAL innodb_compression_level= @save_innodb_compression_level;
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-31158 Assertion ...MTR_MEMO_X_LOCKED in btr_attach_half_pages()
#
SET @save_compression_level=@@GLOBAL.innodb_compression_level;
SET GLOBAL innodb_compression_level=0;
CREATE TEMPORARY TABLE t(a SERIAL, prefix VARBINARY(4), pad INT);
INSERT INTO t(prefix, pad) VALUES
(_binary 0xff,160),('',19),(_binary 0x0001,253),(_binary 0x0b11,169),
(_binary 0x0b010001,23),(_binary 0x0b100001,251),(_binary 0x0d,163),
(_binary 0xb3,254),(_binary 0x96,254),(_binary 0xeb,61),
(_binary 0xf231,253),(_binary 0x1db0,253),(_binary 0x0005,101),
(_binary 0x6370,253),(_binary 0x0b12,112),(_binary 0x0b010002,23),
(_binary 0x0b100002,80),(_binary 0x181984,163),(_binary 0x181926,168),
(_binary 0xe1,176),(_binary 0xe2,187),(_binary 0xe6,254),(_binary 0xbb,51),
(_binary 0x1c,248),(_binary 0x8a,94),(_binary 0x14,254);
CREATE TABLE u(a SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
b VARBINARY(255), KEY(b)) ENGINE=InnoDB
KEY_BLOCK_SIZE=1 ROW_FORMAT=COMPRESSED;
INSERT INTO u SELECT a,CONCAT(prefix,REPEAT(chr(0),pad)) FROM t;
DROP TABLE u, t;
SET GLOBAL innodb_compression_level=@save_compression_level;
# End of 10.6 tests # End of 10.6 tests

View File

@@ -888,4 +888,28 @@ INSERT INTO t1 VALUES ('');
SET GLOBAL innodb_compression_level= @save_innodb_compression_level; SET GLOBAL innodb_compression_level= @save_innodb_compression_level;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-31158 Assertion ...MTR_MEMO_X_LOCKED in btr_attach_half_pages()
--echo #
--source include/have_innodb.inc
SET @save_compression_level=@@GLOBAL.innodb_compression_level;
SET GLOBAL innodb_compression_level=0;
CREATE TEMPORARY TABLE t(a SERIAL, prefix VARBINARY(4), pad INT);
INSERT INTO t(prefix, pad) VALUES
(_binary 0xff,160),('',19),(_binary 0x0001,253),(_binary 0x0b11,169),
(_binary 0x0b010001,23),(_binary 0x0b100001,251),(_binary 0x0d,163),
(_binary 0xb3,254),(_binary 0x96,254),(_binary 0xeb,61),
(_binary 0xf231,253),(_binary 0x1db0,253),(_binary 0x0005,101),
(_binary 0x6370,253),(_binary 0x0b12,112),(_binary 0x0b010002,23),
(_binary 0x0b100002,80),(_binary 0x181984,163),(_binary 0x181926,168),
(_binary 0xe1,176),(_binary 0xe2,187),(_binary 0xe6,254),(_binary 0xbb,51),
(_binary 0x1c,248),(_binary 0x8a,94),(_binary 0x14,254);
CREATE TABLE u(a SMALLINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
b VARBINARY(255), KEY(b)) ENGINE=InnoDB
KEY_BLOCK_SIZE=1 ROW_FORMAT=COMPRESSED;
INSERT INTO u SELECT a,CONCAT(prefix,REPEAT(chr(0),pad)) FROM t;
DROP TABLE u, t;
SET GLOBAL innodb_compression_level=@save_compression_level;
--echo # End of 10.6 tests --echo # End of 10.6 tests

View File

@@ -8526,9 +8526,10 @@ best_access_path(JOIN *join,
fanout= hash_join_fanout(join, s, remaining_tables, rnd_records, fanout= hash_join_fanout(join, s, remaining_tables, rnd_records,
hj_start_key, &stats_found); hj_start_key, &stats_found);
join_sel= 1.0; // Don't do the "10% heuristic" join_sel= 1.0; // Don't do the "10% heuristic"
if (stats_found)
goto fanout_computed;
} }
if (!stats_found)
{
/* /*
No OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY or no field statistics No OPTIMIZER_SWITCH_HASH_JOIN_CARDINALITY or no field statistics
found. found.
@@ -8543,8 +8544,8 @@ best_access_path(JOIN *join,
rnd_records= use_found_constraint(rnd_records); rnd_records= use_found_constraint(rnd_records);
fanout= rnd_records; fanout= rnd_records;
join_sel= 0.1; join_sel= 0.1;
}
fanout_computed:
tmp= s->quick ? s->quick->read_time : s->scan_time(); tmp= s->quick ? s->quick->read_time : s->scan_time();
double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE; double cmp_time= (s->records - rnd_records)/TIME_FOR_COMPARE;
tmp= COST_ADD(tmp, cmp_time); tmp= COST_ADD(tmp, cmp_time);

View File

@@ -748,18 +748,24 @@ btr_cur_will_modify_tree(
/** Detects whether the modifying record might need a opposite modification /** Detects whether the modifying record might need a opposite modification
to the intention. to the intention.
@param page page @param bpage buffer pool page
@param is_clust whether this is a clustered index
@param lock_intention lock intention for the tree operation @param lock_intention lock intention for the tree operation
@param node_ptr_max_size the maximum size of a node pointer @param node_ptr_max_size the maximum size of a node pointer
@param compress_limit BTR_CUR_PAGE_COMPRESS_LIMIT(index) @param compress_limit BTR_CUR_PAGE_COMPRESS_LIMIT(index)
@param rec record (current node_ptr) @param rec record (current node_ptr)
@return true if tree modification is needed */ @return true if tree modification is needed */
static bool btr_cur_need_opposite_intention(const page_t *page, static bool btr_cur_need_opposite_intention(const buf_page_t &bpage,
bool is_clust,
btr_intention_t lock_intention, btr_intention_t lock_intention,
ulint node_ptr_max_size, ulint node_ptr_max_size,
ulint compress_limit, ulint compress_limit,
const rec_t *rec) const rec_t *rec)
{ {
if (UNIV_LIKELY_NULL(bpage.zip.data) &&
!page_zip_available(&bpage.zip, is_clust, node_ptr_max_size, 1))
return true;
const page_t *const page= bpage.frame;
if (lock_intention != BTR_INTENTION_INSERT) if (lock_intention != BTR_INTENTION_INSERT)
{ {
/* We compensate also for btr_cur_compress_recommendation() */ /* We compensate also for btr_cur_compress_recommendation() */
@@ -1343,7 +1349,8 @@ release_tree:
!btr_block_get(*index(), btr_page_get_next(block->page.frame), !btr_block_get(*index(), btr_page_get_next(block->page.frame),
RW_X_LATCH, false, mtr, &err)) RW_X_LATCH, false, mtr, &err))
goto func_exit; goto func_exit;
if (btr_cur_need_opposite_intention(block->page.frame, lock_intention, if (btr_cur_need_opposite_intention(block->page, index()->is_clust(),
lock_intention,
node_ptr_max_size, compress_limit, node_ptr_max_size, compress_limit,
page_cur.rec)) page_cur.rec))
goto need_opposite_intention; goto need_opposite_intention;
@@ -1399,7 +1406,8 @@ release_tree:
default: default:
break; break;
case BTR_MODIFY_TREE: case BTR_MODIFY_TREE:
if (btr_cur_need_opposite_intention(block->page.frame, lock_intention, if (btr_cur_need_opposite_intention(block->page, index()->is_clust(),
lock_intention,
node_ptr_max_size, compress_limit, node_ptr_max_size, compress_limit,
page_cur.rec)) page_cur.rec))
/* If the rec is the first or last in the page for pessimistic /* If the rec is the first or last in the page for pessimistic
@@ -1949,7 +1957,7 @@ index_locked:
break; break;
if (!index->lock.have_x() && if (!index->lock.have_x() &&
btr_cur_need_opposite_intention(block->page.frame, btr_cur_need_opposite_intention(block->page, index->is_clust(),
lock_intention, lock_intention,
node_ptr_max_size, node_ptr_max_size,
compress_limit, page_cur.rec)) compress_limit, page_cur.rec))
@@ -1996,7 +2004,8 @@ index_locked:
ut_ad(latch_mode != BTR_MODIFY_TREE || upper_rw_latch == RW_X_LATCH); ut_ad(latch_mode != BTR_MODIFY_TREE || upper_rw_latch == RW_X_LATCH);
if (latch_mode != BTR_MODIFY_TREE); if (latch_mode != BTR_MODIFY_TREE);
else if (btr_cur_need_opposite_intention(block->page.frame, lock_intention, else if (btr_cur_need_opposite_intention(block->page, index->is_clust(),
lock_intention,
node_ptr_max_size, compress_limit, node_ptr_max_size, compress_limit,
page_cur.rec)) page_cur.rec))
{ {