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

support insert ignore syntax (#1.1-dev) #15053

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

YANGGMM
Copy link
Contributor

@YANGGMM YANGGMM commented Mar 20, 2024

support insert ignore syntax

Approved by: @iamlinjunhong, @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 ##15020

What this PR does / why we need it:

support insert ignore syntax

@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Mar 20, 2024
@mergify mergify bot requested a review from sukki37 March 20, 2024 02:08
@matrix-meow
Copy link
Contributor

@YANGGMM Thanks for your contributions!

Here are review comments for file pkg/sql/parsers/dialect/mysql/mysql_sql.go:

Pull Request Review:

Title:

The title of the pull request is clear and concise, indicating that the purpose of the change is to support the "insert ignore" syntax.

Body:

The body of the pull request provides additional context by mentioning that the change has been approved by specific individuals and references the related issue #15020. It also states the reason for the PR, which is to support the "insert ignore" syntax.

Changes:

Since the diff content is not provided, it is not possible to review the specific code changes made in the pull request. However, based on the description provided in the title and body, it seems that the changes are related to adding support for the "insert ignore" syntax in the MySQL SQL dialect.

Feedback and Suggestions:

  1. Code Changes Review:
    Without the actual code changes, it is challenging to provide a detailed review. It is recommended to include the diff content in the pull request to allow for a thorough review of the changes made.

  2. Security Considerations:
    When implementing new syntax like "insert ignore," it is crucial to consider potential security implications. Ensure that the implementation does not introduce any vulnerabilities such as SQL injection or data manipulation issues.

  3. Testing:
    It is essential to include appropriate tests to cover the new functionality added. Test cases should validate the behavior of the "insert ignore" syntax under various scenarios to ensure its correctness and reliability.

  4. Documentation:
    Update the relevant documentation to reflect the addition of the "insert ignore" syntax. Clear and comprehensive documentation helps users understand and utilize the new feature effectively.

  5. Code Optimization:
    Review the code changes to ensure they follow best practices and coding standards. Optimize the implementation for performance and readability where possible.

  6. Collaboration:
    Encourage collaboration and feedback from team members to ensure the changes align with the project's goals and maintain consistency across the codebase.

Overall:

The pull request seems to address a specific feature enhancement related to supporting the "insert ignore" syntax. To improve the quality of the codebase, consider addressing the feedback and suggestions provided above. Additionally, including the actual code changes in the pull request will facilitate a more thorough review.

Here are review comments for file pkg/sql/parsers/dialect/mysql/mysql_sql.y:

Pull Request Review:

Title:

The title "support insert ignore syntax (#1.1-dev)" is clear and indicates that the pull request is related to adding support for the "insert ignore" syntax.

Body:

The body of the pull request provides a brief description of the changes made and mentions that it is an improvement. It also references the related issue #15020 on GitHub.

Changes:

The changes made in the pull request are focused on the mysql_sql.y file in the pkg/sql/parsers/dialect/mysql directory. The diff shows the addition of a new rule to support the "insert ignore" syntax in the parser. This change allows for the insertion of data into a table while ignoring any duplicate key errors.

Feedback and Suggestions for Improvement:

  1. Security Concerns:

    • When implementing the "insert ignore" functionality, it is crucial to consider potential security implications. Ensure that the implementation does not introduce any vulnerabilities such as SQL injection or data manipulation attacks. Validate and sanitize user input to prevent security risks.
  2. Code Optimization:

    • Instead of initializing ins.OnDuplicateUpdate with an array containing a single nil element, consider using a more concise and clear approach. Initializing it with an empty array or handling the absence of OnDuplicateUpdate separately might improve code readability.
  3. Consistency:

    • Ensure that the new rule for "insert ignore" syntax aligns with the existing syntax rules and conventions in the parser. Consistent formatting and naming conventions help maintain code clarity and readability.
  4. Testing:

    • It is essential to include appropriate test cases to cover the new functionality added by supporting the "insert ignore" syntax. Comprehensive testing helps ensure the correctness and reliability of the parser's behavior.
  5. Documentation:

    • Consider updating the relevant documentation to reflect the addition of the "insert ignore" syntax support. Clear and up-to-date documentation is essential for developers using the parser to understand the available features and syntax options.
  6. Collaboration:

    • Encourage collaboration and feedback from other team members or contributors to review the changes thoroughly. Multiple perspectives can help identify potential issues or improvements that may have been overlooked.

Overall, the pull request is a step towards enhancing the parser's functionality by adding support for the "insert ignore" syntax. By addressing the feedback provided and ensuring code quality, security, and documentation standards are met, the pull request can contribute positively to the codebase.

Here are review comments for file test/distributed/cases/function/func_datetime_extract.result:

Pull Request Review:

Title:

The title of the pull request is clear and concise, indicating that it aims to add support for the "insert ignore" syntax.

Body:

The body of the pull request provides additional context by specifying the type of PR, the related issue, and the reason for the changes. It also lists the approvals from other team members, which is a good practice for transparency.

Changes in test/distributed/cases/function/func_datetime_extract.result:

  1. Issue with "insert ignore" syntax:

    • The change attempts to add support for the "insert ignore" syntax by modifying the SQL query in the test case.
    • However, the change results in an error related to the date value "0000-00-00" being considered as an invalid argument for the parsedate function.
    • Problem: The use of "0000-00-00" as a date value is not standard SQL and can lead to unexpected behavior or errors in some database systems.
    • Suggestion: Instead of using "0000-00-00", consider using a valid date value or NULL to test the "insert ignore" functionality without relying on non-standard date formats.
  2. Error handling and messaging:

    • The error message in the test case mentions a SQL parser error and an internal error, which can be confusing for developers trying to understand the issue.
    • Suggestion: Provide clearer and more specific error messages that indicate the exact nature of the problem, such as the invalid date format or the reason for the internal error.
  3. Code Optimization:

    • The test case could be optimized by ensuring that the test data and queries are valid and conform to standard SQL practices to avoid unnecessary errors and confusion.
    • Suggestion: Review and update the test data and queries to use valid date formats and improve the overall quality of the test case.

General Suggestions:

  • Ensure that test cases reflect real-world scenarios and adhere to standard SQL practices to validate the functionality accurately.
  • Improve error handling by providing informative and actionable error messages to aid developers in troubleshooting issues.
  • Consider optimizing the test cases to maintain consistency and reliability in the test suite.

By addressing the issues mentioned above and implementing the suggestions provided, the pull request can enhance the reliability and effectiveness of the "insert ignore" syntax support while improving the overall quality of the codebase.

@mergify mergify bot merged commit c66274a into matrixorigin:1.1-dev Mar 20, 2024
18 checks passed
@YANGGMM YANGGMM deleted the fix-ignore-1.1-dev branch May 13, 2024 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement size/XXL Denotes a PR that changes 2000+ lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants