generateChangeLog with --diffTypes=data throws error on LOB-Fields
Description
When trying to run liquibase --diffTypes=data generateChangeLog on a Apache Derby (via org.apache.derby.jdbc.ClientDriver) i get the following error:
liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.Unexpe
ctedLiquibaseException: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:279)
at liquibase.integration.commandline.Main.doMigration(Main.java:1043)
at liquibase.integration.commandline.Main.run(Main.java:191)
at liquibase.integration.commandline.Main.main(Main.java:129)
Caused by: liquibase.command.CommandExecutionException: liquibase.exception.UnexpectedLiquibaseException: java.
sql.SQLException: Stream oder LOB-Wert kann nicht mehrmals abgerufen werden
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:24)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:277)
... 3 common frames omitted
Caused by: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once
at liquibase.diff.output.changelog.core.MissingDataChangeGenerator.fixMissing(MissingDataChangeGenerato
r.java:120)
at liquibase.diff.output.changelog.ChangeGeneratorChain.fixMissing(ChangeGeneratorChain.java:48)
at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixMissing(ChangeGeneratorFactory.java:97)
at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:206)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:146)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:87)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:74)
at liquibase.command.core.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:55)
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:19)
... 4 common frames omitted
Caused by: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ClientResultSet.getString(Unknown Source)
at liquibase.util.JdbcUtils.getResultSetValue(JdbcUtils.java:92)
at liquibase.diff.output.changelog.core.MissingDataChangeGenerator.fixMissing(MissingDataChangeGenerato
r.java:91)
... 12 common frames omitted
Caused by: org.apache.derby.client.am.SqlException: Stream or LOB value cannot be retrieved more than once
at org.apache.derby.client.am.ClientResultSet.checkLOBMultiCall(Unknown Source)
... 15 common frames omitted
When trying to run liquibase --diffTypes=data generateChangeLog on a Apache Derby (via org.apache.derby.jdbc.ClientDriver) i get the following error:
liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.Unexpe ctedLiquibaseException: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:279) at liquibase.integration.commandline.Main.doMigration(Main.java:1043) at liquibase.integration.commandline.Main.run(Main.java:191) at liquibase.integration.commandline.Main.main(Main.java:129) Caused by: liquibase.command.CommandExecutionException: liquibase.exception.UnexpectedLiquibaseException: java. sql.SQLException: Stream oder LOB-Wert kann nicht mehrmals abgerufen werden at liquibase.command.AbstractCommand.execute(AbstractCommand.java:24) at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:277) ... 3 common frames omitted Caused by: liquibase.exception.UnexpectedLiquibaseException: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once at liquibase.diff.output.changelog.core.MissingDataChangeGenerator.fixMissing(MissingDataChangeGenerato r.java:120) at liquibase.diff.output.changelog.ChangeGeneratorChain.fixMissing(ChangeGeneratorChain.java:48) at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixMissing(ChangeGeneratorFactory.java:97) at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:206) at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:146) at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:87) at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:74) at liquibase.command.core.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:55) at liquibase.command.AbstractCommand.execute(AbstractCommand.java:19) ... 4 common frames omitted Caused by: java.sql.SQLException: Stream or LOB value cannot be retrieved more than once at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) at org.apache.derby.client.am.ClientResultSet.getString(Unknown Source) at liquibase.util.JdbcUtils.getResultSetValue(JdbcUtils.java:92) at liquibase.diff.output.changelog.core.MissingDataChangeGenerator.fixMissing(MissingDataChangeGenerato r.java:91) ... 12 common frames omitted Caused by: org.apache.derby.client.am.SqlException: Stream or LOB value cannot be retrieved more than once at org.apache.derby.client.am.ClientResultSet.checkLOBMultiCall(Unknown Source) ... 15 common frames omitted
This is caused by JdbcUtils.getResultSetValue(...) due to this change in derby: https://db.apache.org/derby/releases/release-10.6.1.0.html#Note+for+DERBY-3844
I did a short test; When Checking for MetaData-Types CLOB/BLOB and retrieve the CLOB/BLOB value only once as expected no error was thrown.
Reproducing the error:
create an empty Derby Database; e.g. with jdbcUrl: jdbc:derby://localhost:1527/emptyDBtest;create=true
run the following script for generating blob and clob data:
create table BLOBTEST ( ID int primary key ,BLOBCONTENT blob ) ; INSERT INTO BLOBTEST (ID, BLOBCONTENT) VALUES (0, CAST( x'89504e470d0a1a0a0000000d4948445200000006000000020802000000f43f3a09000000017352474200aece1ce90000000467414d410000b18f0bfc6105000000097048597300000ec300000ec301c76fa8640000001974455874536f667477617265007061696e742e6e657420342e302e3231f12069950000001249444154185763f8cf00422814ba10c37f00e3420bf56c9e968e0000000049454e44ae426082' as BLOB)); ; create table CLOBTEST ( ID int primary key ,CLOBCONTENT clob ) ; insert into CLOBTEST(ID, CLOBCONTENT) values (1, 'large text here') ;
run liquibase from commandline: liquibase --diffTypes=data generateChangeLog