Skip to content

Complete MySQL expression parsing for SET RHS operators, subqueries, and INTERVAL chains #53

Description

@renecannao

ProxySQL PR #5893 surfaced ParserSQL expression gaps while porting obsolete ProxySQL PR #5088 TAP coverage.

ParserSQL currently emits partial expression ASTs for several valid MySQL SET RHS forms. Representative cases:

SET @generic_var = TRUE XOR FALSE;
SET @generic_var = 5 | 2;
SET @generic_var = 5 & 2;
SET @generic_var = 5 << 1;
SET @generic_var = 10 >> 1;
SET @generic_var = 5 ^ 2;
SET @generic_var = 10 DIV 3;
SET @generic_var = 10 MOD 3;
SET @generic_var = 'abcde' REGEXP '^a.c';
SET @generic_var = 'xyz123' NOT REGEXP '[0-9]$';
SET @generic_var = 'b' MEMBER OF ('["a", "b", "c"]');
SET @generic_var = 'knight' SOUNDS LIKE 'night';
SET @generic_var = NOW() + INTERVAL 1 DAY;
SET @generic_var = '2025-12-25' - INTERVAL 2 MONTH;
SET @generic_var = current_user_id IN (SELECT user_id FROM course_enrollments WHERE course_id = 789);
SET @generic_var = my_value > ALL (SELECT limit_value FROM active_limits WHERE group_id = 'A');
SET @generic_var = 'PROD123' NOT IN (SELECT product_sku FROM discontinued_products WHERE reason_code = 'OBSOLETE');
SET @generic_var = (SELECT SUM(amount) FROM sales WHERE sale_date = CURDATE());

Expected behavior:

  • Parse and emit the full RHS expression instead of stopping at the first supported atom/operator.
  • Add MySQL expression precedence/support for bit operators, shifts, XOR, DIV, MOD, REGEXP, NOT REGEXP, MEMBER [OF], SOUNDS LIKE, and INTERVAL <value> <unit> chains.
  • Preserve subquery expressions in comparison, IN/NOT IN, ALL, and direct parenthesized subquery contexts.

ProxySQL can preserve raw SET RHS text in its adapter as an interim compatibility behavior, but ParserSQL should grow native expression support and tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions