getting DB2i support working in 3.1

Hi,

A month ago support for DB2i database got merged in to 3.1-SNAPSHOT.
But before the 3.1.0 release this was reverted in favour of moving DB2i support in to a separate extension library.
Unfortunately this ext library is incomplete and does not yet include all DB2i support that was in core before.
I’d like to improve the extension library at least to the point where it does everything 3.1-SNAPSHOT did.
But I find it difficult to see how to reimplement the DB2i specific code that was previously in JdbcDatabaseSnapshot?
The constructor of JdbcDatabaseSnaphot is called directly by JdbcDatabaseSnapshot so I don’t see how to override its behaviour for DB2i databases through an exension.
Alternatively much of the ‘if(database instanceof X)’  code in JdbcDatabaseSnapshot and elsewhere could be moved into the Database class. But that requires changes to the core.

Any hints would be much appreciated.

With kind regards,

Bastiaan Bakker



Sorry, I thought the db2i extension had all the logic in it when I pulled support out of core. Since I don’t have access to a db2i database I’m not really able to test it to ensure everything is working, so any help is greatly appreciated. 


The idea is to be able to iterate on the db2i support independently of the core library including being able to have releases of the extension more often than liquibase-core.


The standard extension pattern is to create subclasses in the extension library that return a higher value from getPriority() than the normal classes. 


Are the troubles you are seeing because of the now-gone “if database instanceof DB2iDatabase” logic in getUniqueConstraints? To override that behavior in the extension, you would want to create a subclass of UniquieConstraintSnapshotGenerator and override the listConstraints() method that calls the snapshot.getMetaData() method and instead call the DB2i specific sql. 


The git history says it was:

  1.                         }


Sorry for the slow reply, I was on vacation last week.


Nathan


Hi Nathan,

Thanks for your reply.
Two DB2i specific code snippets have been deleted with commit 66905ca9:
* in UniqueConstraintSnapshotGenerator.listColumns(). That one is easy to fix in the way you already mentioned, with a custom UniqueConstraintSnapshotGenerator.
* in JdbcDatabaseSnaphot.CachingDatabaseMetaData.getUniqueConstraints().  If I understand you correctly you suggest to basically copy to getUniqueConstraints() functionality into a UniqueConstraintSnapshotGeneratorDB2i class and adapt it for DB2i compatibility (read: have it use the sql pasted from git history).
However the original  implementation uses a ResultSetCache and ResultSetExtractor. These are package private classes, not available to an extension, probably for a good reason.
Also it feels wrong to have to copy all this functionality just to be able to supply a different SQL string.
Can you have a deeper look at it?
I’m happy to test our results with a live DB2i instance.

Best regards,

Bastiaan Bakker


    



I can take a look. I created https://github.com/liquibase/liquibase-db2i/issues/1 to better track the issue.


Nathan