enhancement
major
minor
major
minor
defect
major
#26808
Replay migration with H2 fails with long CLOB and BLOB values
Similar to issue #26790, the length restriction on string literals in the H2 SQL dialect causes an SQL dump generated during replay migration to become unimportable if the data contains long CLOB or BLOB values.
Although the SQL is generated correctly, the error “Value too long for column ‘CHARACTER VARYING’” occurs when importing into the new schema, and the application fails to start.
Analysis
When creating a database dump with H2 using the built-in tools, the following construct is used to export long CLOB and BLOB values to SQL:
CREATE CACHED LOCAL TEMPORARY TABLE IF NOT EXISTS SYSTEM_LOB_STREAM(ID INT NOT NULL, PART INT NOT NULL, CDATA VARCHAR, BDATA VARBINARY); ALTER TABLE SYSTEM_LOB_STREAM ADD CONSTRAINT SYSTEM_LOB_STREAM_PRIMARY_KEY PRIMARY KEY(ID, PART); CREATE ALIAS IF NOT EXISTS SYSTEM_COMBINE_CLOB FOR 'org.h2.command.dml.ScriptCommand.combineClob'; CREATE ALIAS IF NOT EXISTS SYSTEM_COMBINE_BLOB FOR 'org.h2.command.dml.ScriptCommand.combineBlob'; INSERT INTO SYSTEM_LOB_STREAM VALUES(4711, 0, "Long value part1", NULL); INSERT INTO SYSTEM_LOB_STREAM VALUES(4711, 1, "Long value part2", NULL); ... INSERT INTO "PUBLIC"."TL_PROPERTIES" VALUES (..., SYSTEM_COMBINE_CLOB(4711)); DROP TABLE IF EXISTS SYSTEM_LOB_STREAM; DROP ALIAS IF EXISTS SYSTEM_COMBINE_CLOB; DROP ALIAS IF EXISTS SYSTEM_COMBINE_BLOB;
The same schema should also be used for the TopLogic dump.
Test
- test-app-rewrite from #26798