Skip to content

[skip-ci] Remove deprecated read_only_action implementations from MySQL and PgSQL HostGroups managers#5291

Merged
renecannao merged 1 commit intov3.0from
v3.0-misc260111
Jan 12, 2026
Merged

[skip-ci] Remove deprecated read_only_action implementations from MySQL and PgSQL HostGroups managers#5291
renecannao merged 1 commit intov3.0from
v3.0-misc260111

Conversation

@renecannao
Copy link
Contributor

Summary

  • Remove deprecated read_only_action() implementations that were marked for deletion after 2025-07-14
  • These implementations were replaced with new code that doesn't depend on the admin table
  • Clean up the codebase by removing old code paths
  • Add new regression test for set_warning functionality

Test plan

  • Verify that the new read_only_action implementation works correctly
  • Run existing test suite to ensure no regressions
  • Test new regression test case for set_warning functionality

…QL and PgSQL HostGroups managers

The old read_only_action() implementations were marked for deletion after 2025-07-14.
These were replaced with new implementation that doesn't depend on the admin table.
This change removes the deprecated code paths to clean up the codebase.
@gemini-code-assist
Copy link

Summary of Changes

Hello @renecannao, 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 focuses on improving code hygiene and robustness by removing deprecated read_only_action() logic from both MySQL and PostgreSQL hostgroup managers. This cleanup eliminates reliance on an outdated admin table. Additionally, it introduces a new regression test to specifically address and prevent a false warning related to how UPDATE statements containing SET clauses are parsed in multi-statement queries.

Highlights

  • Deprecated Code Removal: The old implementations of read_only_action() in both MySQL and PgSQL HostGroups managers, which were marked for deletion after 2025-07-14, have been completely removed.
  • Codebase Cleanup: This change streamlines the codebase by eliminating outdated code paths that relied on an 'admin table', as these functionalities have been replaced by newer, independent implementations.
  • New Regression Test: A new regression test (reg_test_5233_set_warning-t.cpp) has been added to prevent a specific warning ('Unable to parse multi-statements command with SET statement') from being incorrectly triggered by UPDATE statements that include SET clauses.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

@sonarqubecloud
Copy link

Copy link

@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

This pull request is a good cleanup, removing deprecated read_only_action implementations from both MySQL and PgSQL host group managers. The removal of this dead code improves maintainability. The addition of the new regression test for issue #5233 is also valuable for ensuring the stability of multi-statement command parsing. The test is well-structured and effectively demonstrates the bug. I've provided a few suggestions for the new test file to enhance resource management and code readability.

// Enable multi-statements
if (!mysql_real_connect(proxy, cl.host, cl.username, cl.password, "test", cl.port, NULL, CLIENT_MULTI_STATEMENTS)) {
diag("Failed to connect to ProxySQL proxy: %s", mysql_error(proxy));
mysql_close(admin);

Choose a reason for hiding this comment

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

high

There is a resource leak in this error handling path. If mysql_real_connect for the proxy connection fails, the proxy handle is not closed before exiting. This can lead to resource leaks, which might affect the stability of the CI environment. The proxy handle should be closed here.

Suggested change
mysql_close(admin);
mysql_close(proxy);
mysql_close(admin);

diag("Using log file: %s", log_path.c_str());

// Create test database and table
MYSQL_QUERY(admin, "CREATE DATABASE IF NOT EXISTS test");

Choose a reason for hiding this comment

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

high

The MYSQL_QUERY macro, as defined in utils.h, uses return EXIT_FAILURE; on error. This causes the function to exit immediately, bypassing the cleanup code at the end of main where mysql_close is called for the admin and proxy connections. This will lead to resource leaks if any of the MYSQL_QUERY calls fail. To make the test more robust and prevent leaks, consider refactoring to use a goto cleanup pattern for error handling, or use RAII wrappers (like std::unique_ptr with a custom deleter) for the MYSQL* resources to ensure they are always closed.

Comment on lines +162 to +166
bool starts_with_set = (digest_text.size() >= 4 &&
(digest_text[0] == 'S' || digest_text[0] == 's') &&
(digest_text[1] == 'E' || digest_text[1] == 'e') &&
(digest_text[2] == 'T' || digest_text[2] == 't') &&
digest_text[3] == ' ');

Choose a reason for hiding this comment

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

medium

This case-insensitive check for whether the digest text starts with "SET " is a bit verbose. It can be simplified for better readability and maintainability by using strncasecmp.

        bool starts_with_set = (digest_text.size() >= 4 && strncasecmp(digest_text.c_str(), "SET ", 4) == 0);

@renecannao renecannao added this to the Release 3.0.5 milestone Jan 12, 2026
@renecannao renecannao merged commit 8b2b299 into v3.0 Jan 12, 2026
5 of 6 checks passed
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.

1 participant