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

COPY ... FROM fails if run after a single-line comment #2143

Closed
cowwoc opened this issue Sep 15, 2018 · 2 comments
Closed

COPY ... FROM fails if run after a single-line comment #2143

cowwoc opened this issue Sep 15, 2018 · 2 comments

Comments

@cowwoc
Copy link

@cowwoc cowwoc commented Sep 15, 2018

Which version and edition of Flyway are you using?

5.1.4

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

Java API

Which database are you using (type & version)?

Postgresql 10.5

Which operating system are you using?

Microsoft Windows [Version 10.0.17134.285]

What did you do?

Ran SQL migration file containing:

-- COPY ... FROM is much faster than INSERT: https://stackoverflow.com/q/46715354/14731
COPY currency (id, code) FROM stdin;
1	SPHR
2	SCS
3	AGLC
\.
SELECT pg_catalog.setval('currency_id_sequence', 3, true);```
What did you expect to see?

Statement ran successfully

What did you see instead?
org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException: 
Migration V100__Added_currencies.sql failed
-------------------------------------------
SQL State  : 57014
Error Code : 0
Message    : ERROR: COPY from stdin failed: The JDBC driver currently does not support COPY operations.
  Where: COPY currency, line 1
Location   : com/mycompany/myproject/database/V100__Added_currencies.sql (C:\Users\Gili\Documents\myproject\my-module\target\test-classes\com\mycompany\myproject\database\V100__Added_currencies.sql)
Line       : 1
Statement  : -- COPY ... FROM is much faster than INSERT: https://stackoverflow.com/q/46715354/14731
COPY currency (id, code) FROM stdin

	at org.flywaydb.core.internal.database.ExecutableSqlScript.handleException(ExecutableSqlScript.java:331)
	at org.flywaydb.core.internal.database.ExecutableSqlScript.executeStatement(ExecutableSqlScript.java:301)
	at org.flywaydb.core.internal.database.ExecutableSqlScript.execute(ExecutableSqlScript.java:243)
	at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:91)
	at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:352)
	... 42 more
Caused by: org.postgresql.util.PSQLException: ERROR: COPY from stdin failed: The JDBC driver currently does not support COPY operations.
  Where: COPY currency, line 1
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266)
	at com.p6spy.engine.wrapper.StatementWrapper.execute(StatementWrapper.java:114)
	at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
	at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
	at org.flywaydb.core.internal.util.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:244)
	at org.flywaydb.core.internal.database.StandardSqlStatement.execute(StandardSqlStatement.java:44)
	at org.flywaydb.core.internal.database.ExecutableSqlScript.executeStatement(ExecutableSqlScript.java:280)
	... 45 more
@cowwoc
Copy link
Author

@cowwoc cowwoc commented Sep 15, 2018

It turns out that if I add an empty line between the comment on line 1 and the COPY command on line 2 the statement runs just fine.

This seems like a simple parsing bug to me because (to my understanding) Flyway does not require an empty line after comments.

@cowwoc cowwoc changed the title COPY ... FROM against Postgresql COPY ... FROM fails if run after a single-line comment Sep 15, 2018
@axelfontaine axelfontaine added this to the Flyway 5.2.0 milestone Sep 17, 2018
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Sep 18, 2018
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Sep 18, 2018

Good catch! That was it indeed. Fixed.

dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.