Skip to content

Conversation

@KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Jul 31, 2025

Description

In Db2, users must specify the schema name when dropping an index that was created by another user.

However, the current implementation of JdbcAdmin does not do this, leading to a NotFound error when attempting to drop the index.

This PR fixes the issue by specifying the schema name when creating or dropping an index in Db2.

Related issues and/or PRs

This is the similar issue to the one fixed for Oracle in #2888.

Changes made

  • Specify the schema name when preparing CREATE INDEX or DROP INDEX SQL statements in Db2 engine.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@KodaiD KodaiD self-assigned this Jul 31, 2025
@KodaiD KodaiD added the bugfix label Jul 31, 2025
@KodaiD KodaiD requested a review from Copilot July 31, 2025 07:30
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @KodaiD, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue in the Db2 engine integration where index creation and deletion operations were failing due to the omission of schema names in the generated SQL. By ensuring that all CREATE INDEX and DROP INDEX statements for Db2 explicitly include the schema, the PR enhances the robustness and correctness of database administration operations for Db2 users, mirroring a similar fix previously applied for Oracle.

Highlights

  • Db2 Index Management Fix: This PR addresses a bug in the Db2 engine integration where DROP INDEX operations would fail with a NotFound error if the index was created by another user, due to the lack of schema specification in the SQL statement. The fix ensures that both CREATE INDEX and DROP INDEX statements for Db2 now correctly include the schema name.
  • SQL Statement Generation Update: The RdbEngineDb2 class has been updated to modify the dropIndexSql method and introduce a new createIndexSql method. Both now generate SQL statements that explicitly qualify index names with their respective schemas, aligning with Db2's requirements for index management.
  • Test Case Adjustments: Existing test cases within JdbcAdminTest.java related to Db2 index creation and dropping have been updated. The expected SQL strings in these tests now include the schema qualification for index names, reflecting the changes made to the SQL generation logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue with DB2 index operations where schema names were not being properly specified in CREATE INDEX and DROP INDEX SQL statements. In DB2, users must specify the schema name when creating or dropping indexes that may be accessed by other users, preventing NotFound errors during index operations.

Key changes:

  • Updated RdbEngineDb2 to include schema names in index creation SQL statements by overriding createIndexSql
  • Modified dropIndexSql in RdbEngineDb2 to include schema names in DROP INDEX statements
  • Updated test expectations in JdbcAdminTest to verify the new SQL format with schema-qualified index names

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineDb2.java Added schema qualification to CREATE INDEX and DROP INDEX SQL statements for DB2
core/src/test/java/com/scalar/db/storage/jdbc/JdbcAdminTest.java Updated test expectations to match new schema-qualified index SQL format

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot 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

The changes address the Db2 index creation and deletion by specifying the schema. The tests have also been updated to reflect these changes, ensuring the new SQL statement format is verified.

@KodaiD KodaiD marked this pull request as ready for review July 31, 2025 08:16
@KodaiD KodaiD requested review from a team, Torch3333, brfrn169, feeblefakie and komamitsu and removed request for a team July 31, 2025 08:16
Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@komamitsu
Copy link
Contributor

In Db2, users must specify the schema name when dropping an index that was created by another user.

Great catch! Maybe we should add a test case to reproduce this scenario?

@KodaiD
Copy link
Contributor Author

KodaiD commented Aug 1, 2025

In Db2, users must specify the schema name when dropping an index that was created by another user.

Great catch! Maybe we should add a test case to reproduce this scenario?

We can reproduce the issue in the permission test (#2923).
@brfrn169 @komamitsu Should we also prepare cases for that in the normal integration test side?

@komamitsu
Copy link
Contributor

Dependent bug-fix PRs:

Ah, sorry. I overlooked it. I think that's enough to check the behavior in the permission test.

Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Should we also prepare cases for that in the normal integration test side?

I think the permission test is enough, too. Thanks!

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants