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

Block Depth check broken migration contains CREATE JAVA statement #2607

Closed
codicuz opened this issue Dec 18, 2019 · 1 comment
Closed

Block Depth check broken migration contains CREATE JAVA statement #2607

codicuz opened this issue Dec 18, 2019 · 1 comment

Comments

@codicuz
Copy link
Contributor

@codicuz codicuz commented Dec 18, 2019

Which version and edition of Flyway are you using?

Flyway from github, branch master.

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

Oracle EE 12.2.0.1

Which operating system are you using?

Linux and many other distrs.

What did you do?

deploy migration with below code:
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED HW AUTHID CURRENT_USER AS public class Welcome { public static String welcome() { if (false) { return "Welcome " + " World"; } else { return "Welcome simple world"; } } } /

DOC: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/CREATE-JAVA.html#GUID-69E13452-1F91-4F98-B154-CF5B1C198387

What did you expect to see?

migration is deployed

What did you see instead?

ERROR: Unable to parse statement in /home/i3/flyway/sql/V1_01__test.sql at line 1 col 1: Incomplete statement at line 1 col 1: CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED HW AUTHID CURRENT_USER AS ......

Since Flyway-6.1.1 in OracleParser class added method adjustBlockDepth.
if ("BEGIN".equals(keywordText) || (("IF".equals(keywordText) // **<<<-- Here called context.increaseBlockDepth() and variable blockDepth incremented.<<<---** || "CASE".equals(keywordText) || "LOOP".equals(keywordText)) && !containsWithinLast(1, tokens, parensDepth, "END")) || ("TRIGGER".equals(keywordText) && containsWithinLast(1, tokens, parensDepth, "COMPOUND")) || (("AS".equals(keywordText) || "IS".equals(keywordText)) && ( containsWithinLast(4, tokens, parensDepth, "PACKAGE") || containsWithinLast(3, tokens, parensDepth, "PACKAGE", "BODY") || containsWithinLast(3, tokens, parensDepth, "TYPE", "BODY"))) ) { context.increaseBlockDepth(); } else if ("END".equals(keywordText)) { context.decreaseBlockDepth(); // **<<<--- never called because the END keyword does not occur in PLSQL code <<<---** } }

which causes an exception to be thrown from class Parser:

if (TokenType.EOF == tokenType && (parensDepth > 0 || blockDepth > 0)) { throw new FlywayException("Incomplete statement at line " + statementLine + " col " + statementCol + ": " + sql); }

Appreciate a speedy solution to this problem.
Can this type of plsql code be excluded from checking for block depth?

@codicuz codicuz changed the title Block Depth check broken CREATE JAVA statement Block Depth check broken migration contains CREATE JAVA statement Dec 18, 2019
@alextercete alextercete added this to the Flyway 6.1.3 milestone Dec 19, 2019
@alextercete
Copy link
Contributor

@alextercete alextercete commented Dec 19, 2019

@codicuz Thanks for reporting this. We've managed to produce a fix which should go out in the next release.

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

No branches or pull requests

2 participants