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

Fix query for snapshotting views on DB2/Z #2712

Merged
merged 3 commits into from Jul 28, 2022
Merged

Fix query for snapshotting views on DB2/Z #2712

merged 3 commits into from Jul 28, 2022

Conversation

michaelmatthiaskern
Copy link
Contributor

This is a fix for #2710 .

The view definition may only be fetched by the name and creator. The search with PATHSCHEMAS is ambiguous and may lead to multiple results.

Environment

Liquibase Version: 4.8.0

Liquibase Integration & Version: CLI

Liquibase Extension(s) & Version: -

Database Vendor & Version: DB2Z 12

Operating System Type & Version: Windows 10 Pro

Pull Request Type

  • Bug fix (non-breaking change which fixes an issue.)
  • Enhancement/New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

The diff command does not work with diffTypes=views for DB2Z, DB2LUW is not affected.

The error occurs when comparing the views of the ENTW Schema with another schema.

The obviously happens because we use multiple schemas that have similar names (ENTW, ENTW10, ENTW20, ...) and views with the same names exist in all of the schemas.

Steps To Reproduce

Start the diff command.

Actual Behavior

Liquibase aborts with the stacktrace below.

Expected/Desired Behavior

Liquibase should work correctly.

Additional Context

Stacktrace:


Unexpected error running Liquibase: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@7a0e1b5e but got 7

liquibase.exception.CommandExecutionException: liquibase.exception.LiquibaseException: Unerwarteter Fehler bei der Ausführung von Liquibase: liquibase.exception.DatabaseException: Error getting jdbc:db2://10.1.110.100:50080/DB2EHA view with liquibase.statement.core.GetViewDefinitionStatement@702ed190
at liquibase.command.CommandScope.execute(CommandScope.java:163)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:51)
at liquibase.integration.commandline.CommandRunner.call(CommandRunner.java:1)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at liquibase.integration.commandline.LiquibaseCommandLine.lambda$1(LiquibaseCommandLine.java:325)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.LiquibaseCommandLine.execute(LiquibaseCommandLine.java:291)
at liquibase.integration.commandline.LiquibaseCommandLine.main(LiquibaseCommandLine.java:80)
Caused by: liquibase.exception.LiquibaseException: Unerwarteter Fehler bei der Ausführung von Liquibase: liquibase.exception.DatabaseException: Error getting jdbc:db2://10.1.110.100:50080/DB2EHA view with liquibase.statement.core.GetViewDefinitionStatement@702ed190
at liquibase.integration.commandline.Main$1.run(Main.java:443)
at liquibase.integration.commandline.Main$1.run(Main.java:1)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:165)
at liquibase.integration.commandline.Main.run(Main.java:221)
at liquibase.command.AbstractCliWrapperCommandStep.run(AbstractCliWrapperCommandStep.java:32)
at liquibase.command.CommandScope.execute(CommandScope.java:157)
... 14 more
Caused by: liquibase.exception.LiquibaseException: liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: Error getting jdbc:db2://10.1.110.100:50080/DB2EHA view with liquibase.statement.core.GetViewDefinitionStatement@702ed190
at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:183)
at liquibase.integration.commandline.Main.doMigration(Main.java:1594)
at liquibase.integration.commandline.Main$1.lambda$0(Main.java:398)
at liquibase.Scope.lambda$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.integration.commandline.Main$1.run(Main.java:397)
... 20 more
Caused by: liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: Error getting jdbc:db2://10.1.110.100:50080/DB2EHA view with liquibase.statement.core.GetViewDefinitionStatement@702ed190
at liquibase.command.CommandScope.execute(CommandScope.java:163)
at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:181)
... 27 more
Caused by: liquibase.exception.DatabaseException: Error getting jdbc:db2://10.1.110.100:50080/DB2EHA view with liquibase.statement.core.GetViewDefinitionStatement@702ed190
at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:129)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:66)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:69)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:69)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:312)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:445)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:467)
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:373)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:335)
at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:105)
at liquibase.snapshot.DatabaseSnapshot.(DatabaseSnapshot.java:58)
at liquibase.snapshot.JdbcDatabaseSnapshot.(JdbcDatabaseSnapshot.java:34)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:215)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:188)
at liquibase.command.core.InternalDiffCommandStep.createTargetSnapshot(InternalDiffCommandStep.java:145)
at liquibase.command.core.InternalDiffCommandStep.createDiffResult(InternalDiffCommandStep.java:99)
at liquibase.command.core.InternalDiffCommandStep.run(InternalDiffCommandStep.java:82)
at liquibase.command.CommandScope.execute(CommandScope.java:157)
... 28 more
Caused by: liquibase.exception.DatabaseException: Expected single row from liquibase.statement.core.GetViewDefinitionStatement@7a0e1b5e but got 7
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:192)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:203)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:198)
at liquibase.database.core.AbstractDb2Database.getViewDefinition(AbstractDb2Database.java:150)
at liquibase.snapshot.jvm.ViewSnapshotGenerator.snapshotObject(ViewSnapshotGenerator.java:81)
... 48 more
Caused by: liquibase.exception.DatabaseException: Result set larger than one row
at liquibase.util.JdbcUtil.requiredSingleResult(JdbcUtil.java:135)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:190)
... 52 more

Fast Track PR Acceptance Checklist:

Need Help?

Come chat with us in the Liquibase Forum.

This is a fix for #2710 .

The view definition may only be fetched by the name and creator. The search with PATHSCHEMAS is ambiguous and may lead to multiple results.
@kataggart kataggart linked an issue Apr 4, 2022 that may be closed by this pull request
@kataggart kataggart changed the title Fix issue 2710 Fix diff command to work with diffTypes=views for DB2Z (issue 2710) Apr 4, 2022
@kataggart kataggart added this to To Do in Conditioning++ via automation Apr 4, 2022
@nvoxland nvoxland added the SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions label Jul 27, 2022
@github-actions
Copy link

github-actions bot commented Jul 27, 2022

Unit Test Results

  4 620 files  ±0    4 620 suites  ±0   36m 4s ⏱️ + 1m 54s
  4 594 tests ±0    4 379 ✔️ ±0     215 💤 ±0  0 ±0 
54 300 runs  ±0  49 280 ✔️ ±0  5 020 💤 ±0  0 ±0 

Results for commit abebd8c. ± Comparison against base commit 28631d9.

♻️ This comment has been updated with latest results.

@nvoxland nvoxland self-requested a review as a code owner July 27, 2022 18:24
@nvoxland nvoxland added SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions autocandidate and removed SafeToBuild Indicates that a particular PR contains changes which are safe to build using GitHub actions labels Jul 27, 2022
Copy link
Contributor

@nvoxland nvoxland left a comment

Choose a reason for hiding this comment

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

Code review and test results:

Things to be aware of:

  • Fixes view snapshot logic, only impacting db2/z.

Things to worry about:

  • Code changes makes sense, but I don't know db2/z enough to know unexpected impacts

@nvoxland nvoxland changed the title Fix diff command to work with diffTypes=views for DB2Z (issue 2710) Fix query for snapshotting views on DB2/Z Jul 27, 2022
Copy link
Contributor

@XDelphiGrl XDelphiGrl left a comment

Choose a reason for hiding this comment

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

  • Fix addresses a DB2Z issue impacting snapshotting views.
  • Fix is specific to DB2Z
  • No additional testing required.

APPROVED

Passing Functional Tests
Passing Test Harness Execution

@nvoxland nvoxland merged commit 46ccde7 into liquibase:master Jul 28, 2022
Conditioning++ automation moved this from To Do to Done Jul 28, 2022
@kataggart kataggart added this to the NEXT milestone Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

The diff command does not work with diffTypes=views for DB2Z
5 participants