33# This file is included by /etc/mysql/debian-start
44#
55
6- # # Is there MyISAM or Aria unclosed tables.
7- # - Requires the server to be up.
8- # - Is supposed to run silently in background.
9- function check_for_crashed_tables() {
10- set -e
11- set -u
12-
13- # But do it in the background to not stall the boot process.
14- logger -p daemon.info -i -t" $0 " " Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables"
15-
16- # Checking for $? is unreliable so the size of the output is checked.
17- # Some table handlers like HEAP do not support CHECK TABLE.
18- tempfile=$( mktemp)
19-
20- # We have to use xargs in this case, because a for loop barfs on the
21- # spaces in the thing to be looped over.
22-
23- # If a crashed table is encountered, the "mariadb" command will return with a status different from 0
24- #
25- # The first query will generate lines like.
26- # select count(*) into @discard from 'mysql'.'db'
27- # The second line will load all tables without printing any actual results,
28- # but may show warnings and definitely is expected to have some error and
29- # exit code if crashed tables are encountered.
30- #
31- # Note that inside single quotes must be quoted with '\'' (to be outside of single quotes).
32- set +e
33- # The $MARIADB is intentionally used to expand into a command and arguments
34- # shellcheck disable=SC2086
35- echo '
36- SELECT CONCAT("select count(*) into @discard from ' \' ' ", TABLE_SCHEMA, "' \' ' .' \' ' ", TABLE_NAME, "' \' ' ")
37- FROM information_schema.TABLES WHERE TABLE_SCHEMA<>"INFORMATION_SCHEMA" AND TABLE_SCHEMA<>"PERFORMANCE_SCHEMA"
38- AND (ENGINE="MyISAM" OR ENGINE="Aria")
39- ' | \
40- LC_ALL=C $MARIADB --skip-column-names --batch | \
41- xargs --no-run-if-empty -i $MARIADB --skip-column-names --silent --batch --force -e " {}" & > " ${tempfile} "
42- set -e
43-
44- if [ -s " $tempfile " ]
45- then
46- (
47- /bin/echo -e " \n" \
48- " Improperly closed tables are also reported if clients are accessing\n" \
49- " the tables *now*. A list of current connections is below.\n" ;
50- $MYADMIN processlist status
51- ) >> " ${tempfile} "
52- # Check for presence as a dependency on mailx would require an MTA.
53- if [ -x /usr/bin/mailx ]
54- then
55- mailx -e -s" $MYCHECK_SUBJECT " " $MYCHECK_RCPT " < " $tempfile "
56- fi
57- (echo " $MYCHECK_SUBJECT " ; cat " ${tempfile} " ) | logger -p daemon.warn -i -t" $0 "
58- fi
59- rm " ${tempfile} "
60- }
61-
626# # Check for tables needing an upgrade.
637# - Requires the server to be up.
648# - Is supposed to run silently in background.
@@ -70,7 +14,7 @@ function upgrade_system_tables_if_necessary() {
7014
7115 # Filter all "duplicate column", "duplicate key" and "unknown column"
7216 # errors as the script is designed to be idempotent.
73- LC_ALL=C $ MYUPGRADE \
17+ LC_ALL=C " ${ MYUPGRADE[@]} " \
7418 2>&1 \
7519 | grep -E -v ' ^(1|@had|ERROR (1051|1054|1060|1061|1146|1347|1348))' \
7620 | logger -p daemon.warn -i -t" $0 "
@@ -90,9 +34,9 @@ function check_root_accounts() {
9034 JSON_VALUE(priv, '$.plugin') in ('mysql_native_password', 'mysql_old_password', 'parsec') AND
9135 JSON_VALUE(priv, '$.authentication_string') = '' AND
9236 JSON_VALUE(priv, '$.password_last_changed') != 0
93- " | $ MARIADB --skip-column-names)
37+ " | " ${ MARIADB[@]} " --skip-column-names)
9438 if [ " $ret " -ne " 0" ]
9539 then
96- logger -p daemon.warn -i -t" $0 " " WARNING: mysql.user contains $ret root accounts without password!"
40+ logger -p daemon.warn -i -t" $0 " " WARNING: mysql.global_priv contains $ret root accounts without password!"
9741 fi
9842}
0 commit comments