Skip to content

Commit 433b774

Browse files
committed
MDEV-34902: debian-start erroneously reports issues
Due to table names not being escaped properly. Also the CHECK TABLES on all tables was excessive. This was original there for MyISAM only tables that required repair. Aria and InnoDB will auto-recover. Rather than script, take the input via the shell and attempt to push that back into SQL keeping all the quoting correclty, just use a stored procedure that is temporarly created.
1 parent 680b0cd commit 433b774

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

debian/additions/debian-start.inc.sh

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,31 @@ function check_for_crashed_tables() {
3030
#
3131
# Note that inside single quotes must be quoted with '\'' (to be outside of single quotes).
3232
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}"
33+
"$MARIADB" --skip-column-names --silent --batch --force -e '
34+
DELIMITER //
35+
CREATE OR REPLACE PROCEDURE mysql.check_myisam()
36+
BEGIN
37+
DECLARE done INT DEFAULT FALSE;
38+
DECLARE db TYPE OF information_schema.TABLES.TABLE_SCHEMA;
39+
DECLARE tbl TYPE OF information_schema.TABLES.TABLE_NAME;
40+
DECLARE cur CURSOR FOR SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE ENGINE="MyISAM";
41+
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=TRUE;
42+
OPEN cur;
43+
read_loop: LOOP
44+
FETCH cur INTO db, tbl;
45+
IF done THEN
46+
LEAVE read_loop;
47+
END IF;
48+
EXECUTE IMMEDIATE CONCAT("CHECK TABLE `", db, "`.`", REPLACE(tbl, "`", "``"), "` FAST");
49+
END LOOP;
50+
CLOSE cur;
51+
END;
52+
//
53+
DELIMITER ;
54+
CALL mysql.check_myisam;
55+
DROP PROCEDURE mysql.check_myisam;
56+
' \
57+
&> "${tempfile}"
4258
set -e
4359

4460
if [ -s "$tempfile" ]

0 commit comments

Comments
 (0)