Skip to content

fix drop publication if exists statement (#1.2-dev) - #16464

Merged
sukki37 merged 6 commits into
matrixorigin:1.2-devfrom
YANGGMM:fix-pub-drop
Jun 2, 2024
Merged

sukki37 merged 6 commits into
matrixorigin:1.2-devfrom
YANGGMM:fix-pub-drop

Conversation

@YANGGMM

@YANGGMM YANGGMM commented May 29, 2024 •

Copy link
Copy Markdown
Contributor

User description

fix drop publication if exists statement


PR Type

Bug fix, Tests


Description

  • Added condition to handle IF EXISTS clause in DROP PUBLICATION statement to prevent internal errors when the publication does not exist.
  • Added tests to verify the behavior of the DROP PUBLICATION IF EXISTS statement.
  • Included setup and teardown steps in the test cases to ensure proper testing environment.

Changes walkthrough 📝

Relevant files
Bug fix
authenticate.go
Handle `IF EXISTS` clause in `DROP PUBLICATION` statement

pkg/frontend/authenticate.go

  • Added condition to handle IF EXISTS clause in DROP PUBLICATION
    statement.
  • Prevented internal error when publication does not exist and IF EXISTS
    is specified.
  • +5/-1     
    Tests
    pub_sub2.result
    Add tests for `DROP PUBLICATION IF EXISTS` statement         

    test/distributed/cases/tenant/pub_sub2.result

  • Added tests for DROP PUBLICATION IF EXISTS statement.
  • Verified behavior when publication does not exist.
  • +7/-0     
    pub_sub2.sql
    Add SQL commands to test `DROP PUBLICATION IF EXISTS`       

    test/distributed/cases/tenant/pub_sub2.sql

  • Added SQL commands to test DROP PUBLICATION IF EXISTS.
  • Included setup and teardown steps for the test.
  • +12/-1   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Approved by: @daviszhen, @heni02

    What type of PR is this?

    • API-change
    • BUG
    • Improvement
    • Documentation
    • Feature
    • Test and CI
    • Code Refactoring

    Which issue(s) this PR fixes:

    issue #16447

    What this PR does / why we need it:

    fix drop publication if exists statement


    PR Type

    Bug fix, Tests


    Description

    • Added condition to handle IF EXISTS clause in DROP PUBLICATION statement to prevent internal errors when the publication does not exist.
    • Added tests to verify the behavior of the DROP PUBLICATION IF EXISTS statement.
    • Included setup and teardown steps in the test cases to ensure proper testing environment.

    Changes walkthrough 📝

    Relevant files
    Bug fix
    authenticate.go
    Handle `IF EXISTS` clause in `DROP PUBLICATION` statement

    pkg/frontend/authenticate.go

  • Added condition to handle IF EXISTS clause in DROP PUBLICATION
    statement.
  • Prevented internal error when publication does not exist and IF EXISTS
    is specified.
  • +5/-1     
    Tests
    pub_sub2.result
    Add tests for `DROP PUBLICATION IF EXISTS` statement         

    test/distributed/cases/tenant/pub_sub2.result

  • Added tests for DROP PUBLICATION IF EXISTS statement.
  • Included setup and teardown steps for testing environment.
  • +7/-0     
    pub_sub2.sql
    Add tests for `DROP PUBLICATION IF EXISTS` statement         

    test/distributed/cases/tenant/pub_sub2.sql

  • Added tests for DROP PUBLICATION IF EXISTS statement.
  • Included setup and teardown steps for testing environment.
  • +12/-1   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    fix drop publication if exists statement
    
    
    ___
    
    ### **PR Type**
    Bug fix, Tests
    
    
    ___
    
    ### **Description**
    - Added condition to handle `IF EXISTS` clause in `DROP PUBLICATION` statement to prevent internal errors when the publication does not exist.
    - Added tests to verify the behavior of the `DROP PUBLICATION IF EXISTS` statement.
    - Included setup and teardown steps in the test cases to ensure proper testing environment.
    
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix
    </strong></td><td><table>
    <tr>
    <td>
    <details>
    <summary><strong>authenticate.go</strong><dd><code>Handle `IF EXISTS` clause in `DROP PUBLICATION` statement</code></dd></summary>
    <hr>
    
    pkg/frontend/authenticate.go
    
    <li>Added condition to handle <code>IF EXISTS</code> clause in <code>DROP PUBLICATION</code> <br>statement.<br> <li> Prevented internal error when publication does not exist and <code>IF EXISTS</code> <br>is specified.<br>
    
    
    </details>
    
    
    </td>
    <td><a href="https://github.com/matrixorigin/matrixone/pull/16449/files#diff-849f201c351210bd95807e99d1538e2602a5244b256c35e58467afe304c509e6">+5/-1</a>&nbsp; &nbsp; &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
    <td>
    <details>
    <summary><strong>pub_sub2.result</strong><dd><code>Add tests for `DROP PUBLICATION IF EXISTS` statement</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    test/distributed/cases/tenant/pub_sub2.result
    
    <li>Added tests for <code>DROP PUBLICATION IF EXISTS</code> statement.<br> <li> Verified behavior when publication does not exist.<br>
    
    
    </details>
    
    
    </td>
    <td><a href="https://github.com/matrixorigin/matrixone/pull/16449/files#diff-b8d12747873e9eca46444acc746b3157e5715dcee599fa5353c036a19b550b13">+7/-0</a>&nbsp; &nbsp; &nbsp; </td>
    
    </tr>
    
    <tr>
    <td>
    <details>
    <summary><strong>pub_sub2.sql</strong><dd><code>Add SQL commands to test `DROP PUBLICATION IF EXISTS`</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    test/distributed/cases/tenant/pub_sub2.sql
    
    <li>Added SQL commands to test <code>DROP PUBLICATION IF EXISTS</code>.<br> <li> Included setup and teardown steps for the test.<br>
    
    
    </details>
    
    
    </td>
    <td><a href="https://github.com/matrixorigin/matrixone/pull/16449/files#diff-d185c58ec352113c102571a08f1f6b69a4cb33e75b69c5d6ed221cbc47c7df91">+12/-1</a>&nbsp; &nbsp; </td>
    
    </tr>
    </table></td></tr></tr></tbody></table>
    
    ___
    
    > 💡 **PR-Agent usage**:
    >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
    
    Approved by: @daviszhen, @heni02
    @qodo-code-review

    Copy link
    Copy Markdown

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are localized and straightforward, involving a conditional check and corresponding test cases.

    🧪 Relevant tests

    Yes

    ⚡ Possible issues

    Possible Bug: The else block in the modified if statement returns err which might not be initialized or relevant at this point. It should probably return a specific message or handle the case differently.

    🔒 Security concerns

    No

    @matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label May 29, 2024
    @mergify
    mergify Bot requested a review from sukki37 May 29, 2024 02:02
    @mergify mergify Bot added the kind/bug Something isn't working label May 29, 2024
    @qodo-code-review

    Copy link
    Copy Markdown

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Remove the redundant else block to improve code readability

    The else block is redundant here since the if block already returns a value. Removing the
    else block will make the code cleaner and more readable.

    pkg/frontend/authenticate.go [4029-4033]

     if !dp.IfExists {
         return moerr.NewInternalError(ctx, "publication '%s' does not exist", dp.Name)
    -} else {
    -    return err
     }
    +return err
     
    Suggestion importance[1-10]: 7

    Why: The suggestion correctly identifies an unnecessary else block that can be removed to simplify the code. This improves readability and maintainability.

    7
    Enhancement
    Add a drop publication statement to test the if exists clause more thoroughly

    Adding a drop publication pub1; statement before the drop publication if exists pub1;
    statements can help verify that the if exists clause works correctly when the publication
    does not exist.

    test/distributed/cases/tenant/pub_sub2.result [123-125]

     create publication pub1 database sub1;
    +drop publication pub1;
     drop publication if exists pub1;
     drop publication if exists pub1;
     
    Suggestion importance[1-10]: 5

    Why: The suggestion is valid for enhancing the test to ensure the if exists clause works as expected. However, it's a minor enhancement and not critical to functionality.

    5

    @sukki37
    sukki37 merged commit 36b7fcb into matrixorigin:1.2-dev Jun 2, 2024
    @aylei aylei mentioned this pull request Jun 5, 2024
    @YANGGMM
    YANGGMM deleted the fix-pub-drop branch November 28, 2024 06:00
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    Bug fix kind/bug Something isn't working Review effort [1-5]: 2 size/S Denotes a PR that changes [10,99] lines Tests

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    5 participants