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

mysql "Create temporary table if it not exists" fails to parse #2693

Closed
fumal4evr opened this issue Mar 1, 2020 · 0 comments
Closed

mysql "Create temporary table if it not exists" fails to parse #2693

fumal4evr opened this issue Mar 1, 2020 · 0 comments
Assignees
Milestone

Comments

@fumal4evr
Copy link

fumal4evr commented Mar 1, 2020

Which version and edition of Flyway are you using?

Flyway Community Edition 6.2.4 by Redgate

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)

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

Command-line

Which database are you using (type & version)?

mysql 8.0

Which operating system are you using?

Windows 10

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)

Migration file:

DELIMITER $$
CREATE TEMPORARY TABLE IF NOT EXISTS sometemporarytable
    (
        MonthId INT,
        YearId  INT
    )$$

Command:

flyway -X -outputFile="flywayoutput.txt" -configFiles="flyway.conf" -user=root -password="mypassword" -schemas="myschema" -defaultSchema="myschema" -locations="filesystem:../sql" migrate

in config file:
flyway.url=jdbc:mysql://localhost:3306

What did you expect to see?

Successful parsing and execution.

What did you see instead?
ERROR: Unexpected error
org.flywaydb.core.api.FlywayException: Unable to parse statement in ..\sql\V0014__CreateObjects.sql at line 2 col 1: Incomplete statement at line 2 col 1: CREATE TEMPORARY TABLE IF NOT EXISTS sometemporarytable
    (
        MonthId INT,
        YearId  INT
    )$$

        at org.flywaydb.core.internal.parser.Parser.getNextStatement(Parser.java:288)
        at org.flywaydb.core.internal.parser.Parser.access$000(Parser.java:41)
        at org.flywaydb.core.internal.parser.Parser$ParserSqlStatementIterator.<init>(Parser.java:692)
        at org.flywaydb.core.internal.parser.Parser.parse(Parser.java:109)
        at org.flywaydb.core.internal.sqlscript.ParserSqlScript.parse(ParserSqlScript.java:79)
        at org.flywaydb.core.internal.sqlscript.ParserSqlScript.validate(ParserSqlScript.java:127)
        at org.flywaydb.core.internal.sqlscript.ParserSqlScript.executeInTransaction(ParserSqlScript.java:196)
        at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.canExecuteInTransaction(SqlMigrationExecutor.java:93)
        at org.flywaydb.core.internal.command.DbMigrate.isExecuteGroupInTransaction(DbMigrate.java:312)
        at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:275)
        at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:244)
        at org.flywaydb.core.internal.command.DbMigrate.access$100(DbMigrate.java:54)
        at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:162)
        at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:159)
        at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(MySQLNamedLockTemplate.java:60)
        at org.flywaydb.core.internal.database.mysql.MySQLConnection.lock(MySQLConnection.java:161)
        at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:139)
        at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:159)
        at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:137)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:193)
        at org.flywaydb.core.Flyway$1.execute(Flyway.java:153)
        at org.flywaydb.core.Flyway.execute(Flyway.java:521)
        at org.flywaydb.core.Flyway.migrate(Flyway.java:153)
        at org.flywaydb.commandline.Main.executeOperation(Main.java:174)
        at org.flywaydb.commandline.Main.main(Main.java:126)
Caused by: org.flywaydb.core.api.FlywayException: Incomplete statement at line 2 col 1: CREATE TEMPORARY TABLE IF NOT EXISTS sometemporarytable
    (
        MonthId INT,
        YearId  INT
    )$$

        at org.flywaydb.core.internal.parser.Parser.getNextStatement(Parser.java:224)
        ... 24 more

If I remove the keywords "IF NOT EXISTS" then command succeeds parsing and creating the table.

@Lyeeedar Lyeeedar self-assigned this Mar 2, 2020
@Lyeeedar Lyeeedar added this to the Flyway 6.3 milestone Mar 2, 2020
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