Skip to content

Add search_path parameter to tracked ProxySQL variables list - PgSQL#5149

Merged
renecannao merged 5 commits intov3.0from
v3.0_track_search_path_param_5148
Oct 14, 2025
Merged

Add search_path parameter to tracked ProxySQL variables list - PgSQL#5149
renecannao merged 5 commits intov3.0from
v3.0_track_search_path_param_5148

Conversation

@rahim-kanji
Copy link
Collaborator

Summary

Add the PostgreSQL search_path parameter to the list of tracked ProxySQL variables. Previously, this parameter was not tracked, which leads to session being locked on a hostgroup.

Closes #5148

@gemini-code-assist
Copy link

Summary of Changes

Hello @rahim-kanji, 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 integrates the PostgreSQL search_path parameter into ProxySQL's variable tracking system to resolve session locking issues. It introduces a new validator for search_path, refines SET statement parsing with a new flag for conditional quote stripping, and cleans up obsolete code.

Highlights

  • Intent: This pull request aims to add the PostgreSQL search_path parameter to the list of variables tracked by ProxySQL. The primary motivation is to prevent sessions from being locked on a hostgroup, which previously occurred because search_path changes were not properly monitored. This change directly addresses issue Add search_path parameter to tracked ProxySQL variables list - PgSQL #5148.
  • Key Changes: The core of this PR involves integrating search_path into ProxySQL's variable tracking mechanism. This required several modifications:
  1. search_path Tracking: A new enum entry PGSQL_SEARCH_PATH was added, along with a dedicated validator function (pgsql_variable_validate_search_path) to handle its specific parsing and validation rules (e.g., quoted identifiers, commas, spaces).
  2. Quote Handling: A new option PGTRACKED_VAR_OPT_NO_STRIP_VALUE was introduced to control whether quotes should be stripped from a variable's value during parsing. This is crucial for search_path values like "$user", public where quotes are significant. The SET statement handling logic was updated to respect this new flag.
  3. SET Statement Parsing Refinement: The PgSQL_Set_Stmt_Parser's regex was updated to be more robust in parsing SET statements, accommodating various syntaxes and operators (e.g., =, TO, or implicit space). An older, unused parse2() method was removed.
  4. Code Cleanup: Unused code related to is_select_NOT_for_update in PgSQL_PreparedStatement and PgSQL_Session was removed, streamlining the codebase.
  5. Minor Improvements: strncasecmp was replaced with strcasecmp for client_encoding comparison, and error handling for SET statements was slightly refined.
  • Impact: By tracking the search_path variable, ProxySQL can now correctly manage session state and prevent hostgroup locking issues that arose from its untracked changes. The improved SET statement parsing and flexible quote handling ensure that PostgreSQL variables, especially those with complex values like search_path, are handled accurately.
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.

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 correctly adds support for tracking the search_path PostgreSQL variable, which resolves an issue with session locking. The changes are well-structured, and the introduction of the PGTRACKED_VAR_OPT_NO_STRIP_VALUE option is a good way to handle variables with special value formats.

I've identified a few areas for improvement, mainly concerning the new validator for search_path and the logic for quote stripping. Addressing these will enhance the correctness and maintainability of the code. Additionally, the new regular expression for parsing SET statements is quite complex, and adding comments to explain it would be beneficial for future maintenance.

@rahim-kanji rahim-kanji force-pushed the v3.0_track_search_path_param_5148 branch from 0ef1d4a to 901fe53 Compare October 8, 2025 21:00
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@renecannao renecannao merged commit 01862a2 into v3.0 Oct 14, 2025
144 of 154 checks passed
@renecannao renecannao deleted the v3.0_track_search_path_param_5148 branch March 7, 2026 20:34
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.

Add search_path parameter to tracked ProxySQL variables list - PgSQL

2 participants