Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not split SQL on delimiters within BEGIN/END blocks #1553

Closed
nvoxland opened this issue Nov 20, 2020 · 0 comments · Fixed by #1589
Closed

Do not split SQL on delimiters within BEGIN/END blocks #1553

nvoxland opened this issue Nov 20, 2020 · 0 comments · Fixed by #1589

Comments

@nvoxland
Copy link
Contributor

nvoxland commented Nov 20, 2020

Environment

Liquibase Version: 4.2.0

Liquibase Integration & Version: All

Description

Currently the Sql split logic used throughout liquibase splits on delimiters. That works fine, as long as the delimiter characters are not used inside statements.

The main time when delimiters can be in statements are in stored procedures such as:

CREATE PROCEDURE country_hos(IN con CHAR(20))
BEGIN
  SELECT Name, HeadOfState FROM Country
  WHERE Continent = con;
END

were the ; after WHERE Continent = con makes liquibase split that one statement into two.

This causes the SQL to fail with unexpected end of statement type errors.

Change

Most databases use a BEGIN / END keyword pair to delimit the points where we should ignore delimiters, so we should add logic to check for those tokens and NOT split on the delimiters inside them. This will make the SQL parsing significantly smarter.

A common split function is used anywhere we are splitting sql:

  • In formatted sql by default
  • In tags with splitStatements=true
  • In the executeSql command

Requirements

  • Formatted SQL plus and based SQL with splitStatements=true now correctly run stored procedure, function, trigger, etc. definitions with ;'s in the middle of it correctly as long as the statement uses BEGIN/END syntax. Even without changing the endDelimiter setting.

┆Issue is synchronized with this Jira Bug by Unito

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants