fix(mysql/splitter): distinguish IF control flow from IF() with parenthesized conditions#3336
Conversation
…tion uses parentheses
The splitter treated any IF followed by '(' as the IF() function, so stored
procedures using IF (cond) AND ... THEN were split incorrectly and online
execution failed with MySQL 1064. Use THEN at parenthesis depth zero to detect
control-flow IF blocks instead.
PR Reviewer Guide 🔍(Review updated until commit 5c7e247)
|
PR Code Suggestions ✨Latest suggestions up to 39edb9b
Previous suggestionsSuggestions up to commit 3326f05
|
…in IF fix Keep the CE window-function parser setup when applying the IF control-flow splitter fix; the removal came from copying sqle-ee files that lack this CE change.
|
Persistent review updated to latest commit 39edb9b |
The scanner already sits at currentOffset (right after IF) when entering the branch, so the first SetCursor was a no-op. Keep only the reset after the lookahead scan.
|
Persistent review updated to latest commit 5c7e247 |
PR Code Suggestions ✨No code suggestions found for the PR. |
Fixes #3337
Summary
IF (cond) AND ... THENasIF()function calls.IFblocks by scanning forTHENat parenthesis depth zero.ELSEIF,IF()in triggers, and nestedCASE ... THENin function arguments.EnableWindowFunc(true)that was accidentally dropped during initial cherry-pick from sqle-ee.Problem
When a stored procedure uses a parenthesized condition such as
IF ( v_lng IS NULL OR v_lat IS NULL ) AND Arg0 IS NOT NULL THEN, the splitter skipped theIfEndIfBlockstack entry. The outerBEGIN...ENDblock ended early atEND IF;, the trailingEND;was split into a separate statement, and online execution failed with MySQL 1064.Test plan
go test ./sqle/driver/mysql/splitter/...10.186.63.138:21004: split count 3 → 2, workflow execution succeeds after package replacement