diff options
Diffstat (limited to 'apps/codestyle/codestyle-sql.py')
-rw-r--r-- | apps/codestyle/codestyle-sql.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/apps/codestyle/codestyle-sql.py b/apps/codestyle/codestyle-sql.py index 53315ecaaa..9fad940e91 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) |