I’m wondering if there are any known/outstanding issues using ‘endDelimiter’ with MySQL?
I am including this endDelimiter with an sqlFile changeset, and was expecting the liquibase updateSQL to emit a ‘DELIMITER’ line, but no such luck, and the generated SQL fails.
I’m using liquibase via maven, and have tried a number of versions - 3.5.x, 3.7.x, up to 3.8.9. Also tinkered with splitStatements on/off and different endDelimiter characters.
Anyways, as mentioned, I am curious if this is a known issue (haven’t had any luck spotting current bugs in the liquibase github / jira / these forums). It seems hard to believe I’m the first to encounter if it spans 3.5.x to 3.8.9.
-- Changeset com/eyereturn/operations/DBOP-394-dev_segment_budget_tracking_last_update_spoofer/db.changelog.yaml::DBOP-394-DEVONLY-update-segment-budget-tracking-last-update::mstoute CREATE DEFINER=`root`@`%` EVENT IF NOT EXISTS `dev_segment_budget_tracking_sum_updater` ON SCHEDULE EVERY 2 MINUTE STARTS '2019-05-27 13:48:28' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'DEV ONLY!' DO BEGIN update operations.segment_budget_tracking_sum set last_updated = now() where 1=1; END /
The issue (I think) is just that it's missing a "DELIMITER /" statement ahead of the "CREATE" statement. I can fix the SQL by adding "DELIMITER /" manually. So this code below succeeds, I've only added the "DELIMITER /" line.
DELIMITER / CREATE DEFINER=`root`@`%` EVENT `dev_segment_budget_tracking_sum_updater` ON SCHEDULE EVERY 2 MINUTE STARTS '2019-05-27 13:48:28' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'DEV ONLY!' DO BEGIN update operations.segment_budget_tracking_sum set last_updated = now() where 1=1; END/
The Specific error raised by the DB is: "/* SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 9 */". This is where it encounters the default delimiter ";" ("...where 1=1;").
Also as an aside, I noticed if I set "$$" as the endDelimiter, LB also includes a ";" after my custom delimiter. So the last line emitted in that case looks like "END$$;". This isn't the direct issue at hand but it is a different behavior than by using only "/" as the endDelimiter.
To be clear, I have tried running it without modification, both “manually” by copying the complete output of an updateSQL (including the inserts to DATABASECHANGELOG etc.) into a SQL client, and also by running it via update command. In both cases, I get the syntax error at the “;” character. So, I have tried what you suggest, but it does not succeed without modification.
Interesting - thank you! It was just an oddity I noticed when playing around, but the explanation makes sense