Problem
When a SET statement contains SET NAMES charset followed by comma-separated variable assignments (e.g., SET NAMES utf8, sql_mode = 'TRADITIONAL'), the parser stops after SET NAMES and does not parse the remaining assignments.
Failing test cases
SET sql_mode = 'TRADITIONAL', NAMES 'utf8' COLLATE 'unicode_ci'
Expected: {"sql_mode": ["TRADITIONAL"], "names": ["utf8", "unicode_ci"]}
Got: {"sql_mode": ["TRADITIONAL"]} (names missing)
SET NAMES utf8, @@SESSION.sql_mode = CONCAT(...), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 3600
Expected: 4 entries (names + 3 assignments)
Got: 1 entry (names only)
SET NAMES utf8, @@LOCAL.sql_mode = CONCAT(...), @@LOCAL.sql_auto_is_null = 0, @@LOCAL.wait_timeout = 3600
Expected: 4 entries
Got: 1 entry (names only)
SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(REPLACE(...))), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 3600
Expected: 4 entries
Got: 1 entry (names only)
Root cause
In set_parser.h, after parsing NODE_SET_NAMES, the parser does not continue to check for comma-separated NODE_VAR_ASSIGNMENT siblings. The SetParser returns after the NAMES clause.
Expected behavior
SET NAMES charset [, var = expr, ...] should produce both a NODE_SET_NAMES child and NODE_VAR_ASSIGNMENT children under the NODE_SET_STMT root.
Context
Discovered during integration testing of ParserSQL into ProxySQL. Test suite: setparser_test_common.h, test arrays multiple[2], multiple[6], multiple[7], Set1_v2[1].
Problem
When a SET statement contains
SET NAMES charsetfollowed by comma-separated variable assignments (e.g.,SET NAMES utf8, sql_mode = 'TRADITIONAL'), the parser stops afterSET NAMESand does not parse the remaining assignments.Failing test cases
Root cause
In
set_parser.h, after parsingNODE_SET_NAMES, the parser does not continue to check for comma-separatedNODE_VAR_ASSIGNMENTsiblings. The SetParser returns after the NAMES clause.Expected behavior
SET NAMES charset [, var = expr, ...]should produce both aNODE_SET_NAMESchild andNODE_VAR_ASSIGNMENTchildren under theNODE_SET_STMTroot.Context
Discovered during integration testing of ParserSQL into ProxySQL. Test suite:
setparser_test_common.h, test arraysmultiple[2],multiple[6],multiple[7],Set1_v2[1].