From b90638fdf3fed7e1d5cb5d9a4f748d9413f282c2 Mon Sep 17 00:00:00 2001 From: Ryan Turner Date: Fri, 11 Jul 2025 14:52:16 +0100 Subject: [PATCH] feat(Codestyle/SQL): Ensure InnoDB is used as DB Engine (#22457) --- apps/codestyle/codestyle-sql.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/codestyle/codestyle-sql.py b/apps/codestyle/codestyle-sql.py index 53315ecaa..9fad940e9 100644 --- a/apps/codestyle/codestyle-sql.py +++ b/apps/codestyle/codestyle-sql.py @@ -28,7 +28,8 @@ results = { "INSERT & DELETE safety usage check": "Passed", "Missing semicolon check": "Passed", "Backtick check": "Passed", - "Directory check": "Passed" + "Directory check": "Passed", + "Table engine check": "Passed" } # Collect all files in all directories @@ -78,6 +79,7 @@ def parsing_file(files: list) -> None: insert_delete_safety_check(file, file_path) semicolon_check(file, file_path) backtick_check(file, file_path) + non_innodb_engine_check(file, file_path) except UnicodeDecodeError: print(f"\nāŒ Could not decode file {file_path}") sys.exit(1) @@ -383,6 +385,25 @@ def directory_check(file: io, file_path: str) -> None: error_handler = True results["Directory check"] = "Failed" +def non_innodb_engine_check(file: io, file_path: str) -> None: + global error_handler, results + file.seek(0) + check_failed = False + + engine_pattern = re.compile(r'ENGINE\s*=\s*([a-zA-Z0-9_]+)', re.IGNORECASE) + + for line_number, line in enumerate(file, start=1): + match = engine_pattern.search(line) + if match: + engine = match.group(1).lower() + if engine != "innodb": + print(f"āŒ Non-InnoDB engine found: '{engine}' in {file_path} at line {line_number}") + check_failed = True + + if check_failed: + error_handler = True + results["Table engine check"] = "Failed" + # Collect all files from matching directories all_files = collect_files_from_directories(src_directory) + collect_files_from_directories(base_directory) + collect_files_from_directories(archive_directory)