WI #2837 Handle unsupported SQL statements avoiding parser hang#2845
Open
allieseb wants to merge 10 commits intoTypeCobolTeam:developfrom
Open
WI #2837 Handle unsupported SQL statements avoiding parser hang#2845allieseb wants to merge 10 commits intoTypeCobolTeam:developfrom
allieseb wants to merge 10 commits intoTypeCobolTeam:developfrom
Conversation
…very Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… infrastructure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New test file with INSERT, UPDATE, DELETE, DECLARE CURSOR, OPEN, FETCH, CLOSE - All 7 unsupported statements parse without errors (catch-all rule works) - Updated expected results for ExecInDataDivision and ExecSqlWithCommit Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The unsupportedSqlStatement rule now matches any SQL tokens until END-EXEC instead of a closed list of 7 keywords. This handles all current and future SQL statements (GRANT, REVOKE, MERGE, CALL, CREATE INDEX, etc.) without requiring grammar updates for each new unsupported keyword. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
…ent set Replace the arbitrary SQL keyword list in unsupportedSqlStatement with a systematic set derived from the DB2 z/OS SQL Reference. The new unsupportedSqlKeyword rule lists all 26 statement-starting keywords that don't have a dedicated parser rule, with documentation of which SQL statements they cover. This eliminates the need to guess which keywords to add — when a new dedicated rule is created, its keyword is simply removed from this list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fm-117
requested changes
Apr 8, 2026
- Revert unwanted encoding change in CobolCodeElements.g4 (preserve cp1252) - Drop maintenance-prone statement list comment in unsupportedSqlStatement; add TODO noting SQL_MERGE (and possibly other SQL keywords) missing from the lexer token set - UnsupportedSqlStatement: drop the per-statement example list in doc and add the missing VisitCodeElement override - SqlCodeElementBuilder.CreateUnsupportedSqlStatement: drop the "UNKNOWN" fallback and pass the ANTLR token text directly (null allowed) - Revert SqlStatementElement.cs changes that were not part of this PR - Add UnsupportedSqlStatementChecker emitting a syntax error per unsupported statement; wire it from CobolCodeElementBuilder - Comparators.SqlStatements: visit UnsupportedSqlStatement so test outputs include them - Update LSR test EmptyExecStatement.tlsp expecting list to include UnsupportedSqlStatement - Refresh expected outputs (ExecSqlWithCommit.Tokens.txt and ExecSqlWithUnsupportedStatement.SQL.txt) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two related fixes that complete the answer to fm-117's "Where is the COMMIT statement from the beginning ??" question on PR TypeCobolTeam#2845. - CommitStatement was missing the VisitCodeElement override, so the AST visitor walked Commit nodes without ever calling Visit(CommitStatement). As a result, COMMIT statements never appeared in test outputs that rely on the SqlStatements comparator. Add the override following the same pattern as RollbackStatement. - SqlObject.DumpProperty matched string values via the IEnumerable case (since string implements IEnumerable<char>) and dumped them character-by-character. Add a dedicated string case before the IEnumerable case so string properties (like UnsupportedSqlStatement. SqlKeyword) are written as a single value. Refresh ExecSqlWithUnsupportedStatement.SQL.txt expected output to include the now-visited COMMIT at line 10 and the readable SqlKeyword values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UnsupportedSqlStatementCodeElement to gracefully handle unrecognized SQL DML/DDL statements (DELETE, DECLARE, OPEN, FETCH, CLOSE, etc.) insideEXEC SQLblocksEND-EXECFixes part of #2837
Test plan
ExecSqlWithUnsupportedStatement.rdz.cblwith 7 unsupported SQL statementsExecInDataDivision_NoEndExec.Mix.txtexpected output🤖 Generated with Claude Code