Skip to content

Add automatic prefix stripping for mysql_variables, pgsql_variables, and admin_variables configuration #5246

@renecannao

Description

@renecannao

Problem Description

Users frequently make a configuration error by including the module prefix (, , ) when defining variables in the corresponding sections of the ProxySQL configuration file.

For example, in section:

This causes the variable to be stored in the database as (double prefix) instead of . Later lookups via fail because they search for without the prefix.

The same issue occurs with ( prefix) and ( prefix).

Root Cause

The issue is in :

  1. The function reads key-value pairs from section
  2. Inserts them into table with format
  3. When users write , the key becomes
  4. Later searches without prefix

Proposed Solution

Add automatic prefix detection and stripping in :

0 ""

0 ""

0 ""

1 "/usr/include/stdc-predef.h" 1 3 4

0 "" 2

1 ""

Impact

  • Files Modified: (~5 lines added)
  • Sections Affected: , ,
  • Backward Compatibility: Fully maintained - both prefixed and unprefixed forms will work
  • Testing Required: Verify all three sections work correctly with and without prefixes

Testing Considerations

  1. Test mysql_variables with both and
  2. Test pgsql_variables with both and
  3. Test admin_variables with both and
  4. Ensure no regression for variables that legitimately shouldn't have prefixes stripped

Alternative Approaches Considered

  1. Validate and reject: Reject configs with prefixed variables, but breaks backward compatibility
  2. Documentation-only: Better docs/warnings, but users keep making the same mistake
  3. Database-level fix: Strip prefix when loading from database, but double prefix still stored

The proposed solution is most user-friendly as it automatically corrects the common mistake while maintaining compatibility.

Related Issue

This issue was identified while investigating issue #5242 where a user reported not working in the section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions