Maintain-views should have a way to detect which existing views need updating. This is both so we can have an alert when there's unapplied changes, as well as to make the script more efficient by not replacing views that don't need replacing without the need to specify --tables.
The major problem here is that SQL text format that maintain-views comes up with differs from the one produced by SHOW CREATE VIEW. Here's the definition of enwiki_p.ip_changes to demonstrate this problem:
CREATE OR REPLACE DEFINER= viewmaster VIEW `enwiki_p`.`ip_changes` AS select ipc_rev_id, ipc_rev_timestamp, ipc_hex FROM `enwiki`.`ip_changes`, `enwiki`.`revision` WHERE ipc_rev_id = rev_id AND (rev_deleted & 4) = 0 CREATE ALGORITHM=UNDEFINED DEFINER=`viewmaster`@`%` SQL SECURITY DEFINER VIEW `enwiki_p`.`ip_changes` AS select `enwiki`.`ip_changes`.`ipc_rev_id` AS `ipc_rev_id`,`enwiki`.`ip_changes`.`ipc_rev_timestamp` AS `ipc_rev_timestamp`,`enwiki`.`ip_changes`.`ipc_hex` AS `ipc_hex` from (`enwiki`.`ip_changes` join `enwiki`.`revision`) where `enwiki`.`ip_changes`.`ipc_rev_id` = `enwiki`.`revision`.`rev_id` and `enwiki`.`revision`.`rev_deleted` & 4 = 0
The first line is the definition from maintain-views, second one is MariaDB's SHOW CREATE VIEW format. Whitespace was formatted by me to make the side-by-side difference easier to see, otherwise that's exactly the text both of these tools came up with.
So I roughly see three options here:
- Update maintain-views and its config to produce identical SQL text, and then compare the two strings
- Update maintain-views to parse the SQL text somehow, at which point you can compare what they parse to instead of comparing the raw text
- Store the currently live definition as produced by maintain-views somewhere, and compare that instead of comparing to the SHOW CREATE VIEW format.