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

gbehrmann opened this Issue Dec 3, 2018 · 1 comment


None yet
2 participants
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
	at org.flywaydb.core.internal.sqlscript.AbstractSqlStatement.stripDelimiter(
	at org.flywaydb.core.internal.sqlscript.AbstractSqlStatement.getSql(
	at org.flywaydb.core.internal.sqlscript.SqlScript.addStatement(
	at org.flywaydb.core.internal.sqlscript.SqlScript.extractStatements(
	at org.flywaydb.core.internal.sqlscript.SqlScript.<init>(
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.addMigrations(
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver.resolveMigrations(
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.collectMigrations(
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.doFindAvailableMigrations(
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(
	at org.flywaydb.core.internal.resolver.CompositeMigrationResolver.resolveMigrations(
	at org.flywaydb.core.internal.command.DbValidate$
	at org.flywaydb.core.internal.command.DbValidate$
	at org.flywaydb.core.internal.jdbc.TransactionTemplate.execute(
	at org.flywaydb.core.internal.command.DbValidate.validate(
	at org.flywaydb.core.Flyway.doValidate(
	at org.flywaydb.core.Flyway.access$100(
	at org.flywaydb.core.Flyway$1.execute(
	at org.flywaydb.core.Flyway$1.execute(
	at org.flywaydb.core.Flyway.execute(
	at org.flywaydb.core.Flyway.migrate(
	at org.flywaydb.commandline.Main.executeOperation(
	at org.flywaydb.commandline.Main.main(

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.


This comment has been minimized.

Copy link

axelfontaine commented Feb 7, 2019

Thanks for reporting. Fixed.

axelfontaine pushed a commit to flyway/ 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.