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

NullPointerException with PostgreSQL multi-statement CREATE RULE #2228

Closed
gbehrmann opened this Issue Dec 3, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@gbehrmann
Copy link

gbehrmann commented Dec 3, 2018

Which version and edition of Flyway are you using?

Flyway Community Edition 5.2.3 by Boxfuse

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

Command-line and Java API.

Which database are you using (type & version)?

PostgreSQL 10.4

Which operating system are you using?

Mac OS, Linux.

What did you do?

The following migration

CREATE TABLE bar (id serial);
CREATE TABLE baz (id int, lastactivity int);
CREATE TABLE token (token int);
CREATE RULE foo AS ON UPDATE TO bar DO INSTEAD (UPDATE baz SET lastactivity = 1 WHERE id = 1; UPDATE token SET token = 2);

executed with flyway -X -url=jdbc:postgresql://localhost:5432/test -user=postgres -password= -locations=filesystem:. migrate.

What did you expect to see?

A successfully applied migration as the above syntax is accepted by PostgreSQL.

What did you see instead?
ERROR: Unexpected error
java.lang.NullPointerException
	at org.flywaydb.core.internal.sqlscript.AbstractSqlStatement.stripDelimiter(AbstractSqlStatement.java:98)
	at org.flywaydb.core.internal.sqlscript.AbstractSqlStatement.getSql(AbstractSqlStatement.java:72)
	at org.flywaydb.core.internal.sqlscript.SqlScript.addStatement(SqlScript.java:169)
	at org.flywaydb.core.internal.sqlscript.SqlScript.extractStatements(SqlScript.java:145)
	at org.flywaydb.core.internal.sqlscript.SqlScript.<init>(SqlScript.java:86)
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.addMigrations(SqlMigrationResolver.java:140)
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:100)
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:47)
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.collectMigrations(CompositeMigrationResolver.java:136)
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.doFindAvailableMigrations(CompositeMigrationResolver.java:118)
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:104)
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:46)
	at org.flywaydb.core.internal.info.MigrationInfoServiceImpl.refresh(MigrationInfoServiceImpl.java:133)
	at org.flywaydb.core.internal.command.DbValidate$2.call(DbValidate.java:138)
	at org.flywaydb.core.internal.command.DbValidate$2.call(DbValidate.java:126)
	at org.flywaydb.core.internal.jdbc.TransactionTemplate.execute(TransactionTemplate.java:74)
	at org.flywaydb.core.internal.command.DbValidate.validate(DbValidate.java:126)
	at org.flywaydb.core.Flyway.doValidate(Flyway.java:1473)
	at org.flywaydb.core.Flyway.access$100(Flyway.java:82)
	at org.flywaydb.core.Flyway$1.execute(Flyway.java:1361)
	at org.flywaydb.core.Flyway$1.execute(Flyway.java:1353)
	at org.flywaydb.core.Flyway.execute(Flyway.java:1708)
	at org.flywaydb.core.Flyway.migrate(Flyway.java:1353)
	at org.flywaydb.commandline.Main.executeOperation(Main.java:161)
	at org.flywaydb.commandline.Main.main(Main.java:108)

The error disappears if a terminating semicolon is included in the rule. Related to issue #2202. Although the original problem was resolved, the problem reoccurs when using a rule with two statements. This is a regression since version 5.0.7.

@axelfontaine

This comment has been minimized.

Copy link
Contributor

axelfontaine commented Feb 7, 2019

Thanks for reporting. Fixed.

axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.