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

Add DB2Z support to Flyway Community DB Support #44

Merged
merged 5 commits into from
Jun 11, 2024
Merged

Add DB2Z support to Flyway Community DB Support #44

merged 5 commits into from
Jun 11, 2024

Conversation

Barry-RG
Copy link
Contributor

This is to transfer flyway/flyway#3577 from flyway/flyway to the Community DB Support repository.

Thank you @gahoekstraibm for all your help.

@gahoekstraibm
Copy link
Contributor

@Barry-RG Do you expect any action from my side at this moment?

@Barry-RG
Copy link
Contributor Author

Not at this point. Thank you

Comment on lines +27 to +34
/**
* The database name for DB2 on z/OS (required for DB2 on z/OS)
*/
private String databaseName = "";
/**
* The SQLID for DB2 on z/OS (does not necessarily match with schema)
*/
private String sqlId = "";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gahoekstraibm Would you be able to give us a little more explanation on these configuration so that we can add them to the documentation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

databaseName (mandatory)
For DB2 for z/OS, as part of the JDBC URL, the DB2 location name is included which identifies a specific DB2 subsystem. Additionally, DB2 for z/OS also knows the concept of a "database name", which is used as a namespace for storage objects like tablespaces, similar to what a schema is for tables and indexes.

sqlId (optional)
Besides the database schema, DB2 for z/OS also uses an SQLID, which is the user under which it will create objects like tables etc. As creator, this user will get all rights on the object. If not explicitly set, the DB2z community support plugin will use the schema name as SQLID.

@Barry-RG Barry-RG merged commit f1df122 into main Jun 11, 2024
1 check passed
@Barry-RG Barry-RG deleted the db2zos branch June 11, 2024 12:48
@Barry-RG
Copy link
Contributor Author

@gahoekstraibm We have started shipping the DB2zOS integration with Flyway. We have yet to push the documentation as we were wondering if you would be able to try the new release and confirm its still as working as expected?

@gahoekstraibm
Copy link
Contributor

gahoekstraibm commented Sep 20, 2024

Hi @Barry-RG ,
Sorry it took me so long to try the new release. Had some busy weeks after returning from my vacation.

I took the latest command line client from the Redgate website (10.18.0) and after some fiddling with the TOML configuration, I managed to have flyway creating database objects on DB2 for z/OS.

However, for some reason, it looks like the db2z plugin's DB2ZJdbcTemplate is not being used for CALL statements, while this is working in my local 9.x fork of flyway.

I get the exception below, which shows that the regular JdbcTemplate is trying to execute the CALL statement, and although detectStatement identifies it as DB2Z CALL statement, it looks like it isn't created as DB2ZCallProcedureParsedStatement (in DB2ZParser.createStatement() ). Actually, I think DB2ZParser.createStatement() is not even called :

DEBUG: Parsing V4.17.4.0.2__MESSAGTS_AlterCompressREORG.sql ...
DEBUG: detectStatementType: simplifiedStatement=CALL
DEBUG: detectStatementType: DB2Z CALL statement found
DEBUG: Found statement at line 1: CALL SYSPROC.DSNUTILU('17401', 'NO','TEMPLATE SYSCOPY DSN(''E&DB(1,3)..&DB..&SN..P&PA(2,4)..DB2&IC.IC.&UQ.'') UNIT SYSDA REORG TABLESPACE GEERTDB.MESSAGTS AUX NO LOG NO NOSYSREC COPYDDN (SYSCOPY) SORTDEVT SYSDA SORTNUM 10 STATISTICS TABLE(ALL) INDEX(ALL) FREQVAL NUMCOLS 5 COUNT 10 SHRLEVEL REFERENCE','')
DEBUG: Starting migration of schema "FLYWTEST" to version "4.17.4.0.2 - MESSAGTS AlterCompressREORG" ...
Migrating schema "FLYWTEST" to version "4.17.4.0.2 - MESSAGTS AlterCompressREORG"
DEBUG: Executing SQL: CALL SYSPROC.DSNUTILU('17401', 'NO','TEMPLATE SYSCOPY DSN(''E&DB(1,3)..&DB..&SN..P&PA(2,4)..DB2&IC.IC.&UQ.'') UNIT SYSDA REORG TABLESPACE GEERTDB.MESSAGTS AUX NO LOG NO NOSYSREC COPYDDN (SYSCOPY) SORTDEVT SYSDA SORTNUM 10 STATISTICS TABLE(ALL) INDEX(ALL) FREQVAL NUMCOLS 5 COUNT 10 SHRLEVEL REFERENCE','')
... 
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: NO AUTHORIZED PROCEDURE NAMED SYSPROC.DSNUTILU HAVING COMPATIBLE ARGUMENTS WAS FOUND. SQLCODE=-440, SQLSTATE=42884, DRIVER=4.32.28
        at com.ibm.db2.jcc.am.b7.a(b7.java:810)
        at com.ibm.db2.jcc.am.b7.a(b7.java:66)
        at com.ibm.db2.jcc.am.b7.a(b7.java:140)
        at com.ibm.db2.jcc.am.lc.b(lc.java:2515)
        at com.ibm.db2.jcc.am.lc.c(lc.java:2496)
        at com.ibm.db2.jcc.t4.ab.n(ab.java:917)
        at com.ibm.db2.jcc.t4.ab.f(ab.java:154)
        at com.ibm.db2.jcc.t4.p.e(p.java:81)
        at com.ibm.db2.jcc.t4.av.k(av.java:175)
        at com.ibm.db2.jcc.am.lc.ao(lc.java:2457)
        at com.ibm.db2.jcc.am.lc.a(lc.java:3429)
        at com.ibm.db2.jcc.am.lc.e(lc.java:1138)
        at com.ibm.db2.jcc.am.lc.execute(lc.java:1117)
        at org.flywaydb.core.internal.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:978)
        at org.flywaydb.core.internal.sqlscript.ParsedSqlStatement.execute(ParsedSqlStatement.java:856)
        at org.flywaydb.core.internal.sqlscript.DefaultSqlScriptExecutor.executeStatement(DefaultSqlScriptExecutor.java:980)
        ... 24 more

@Barry-RG
Copy link
Contributor Author

@gahoekstraibm Thank you for trying. I think the error is due to an API drift between the OSS and Redgate editions of Flyway.
To be sure, could you try again with one of the OSS versions of Flyway 10.18.0?
https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/10.18.0/

@gahoekstraibm
Copy link
Contributor

@Barry-RG The OSS version of Flyway 10.18.0 works fine.

@Barry-RG
Copy link
Contributor Author

@gahoekstraibm we have made the changes to apply to all versions of Flyway. Would you mind trying with our latest release?
https://download.red-gate.com/maven/release/com/redgate/flyway/flyway-commandline/10.18.2/

@gahoekstraibm
Copy link
Contributor

Hi @Barry-RG , also the latest release is working fine now!

@gahoekstraibm
Copy link
Contributor

gahoekstraibm commented Sep 27, 2024

I just created a new PR to update supported DB2z versions: #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants