feat: structured SQL DML parsing for INSERT/UPDATE/DELETE/DECLARE CURSOR#2842
Closed
allieseb wants to merge 16 commits intoTypeCobolTeam:developfrom
Closed
feat: structured SQL DML parsing for INSERT/UPDATE/DELETE/DECLARE CURSOR#2842allieseb wants to merge 16 commits intoTypeCobolTeam:developfrom
allieseb wants to merge 16 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>
3 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…SOR) Defines architecture for extracting table names, columns, and host variable bindings from embedded SQL to feed XREF CRUD matrix and column-level data lineage in TriangulateSystemOfSystem. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ints Fixes from spec review: - Rename DeleteStatement to SqlDeleteStatement (avoids COBOL collision) - Use existing grammar rules (tableOrViewOrCorrelationName, hostVariable) - Use correct token types (LeftParenthesisSeparator, SQL_CommaSeparator) - Fix WHERE clause to (hostVariable | ~END_EXEC)* for host var extraction - Use FullSelect model in DeclareCursorStatement (not CodeElement) - Add CodeElementType/StatementType enum steps - Separate ANTLR listener and CUP integration steps - Add edge cases section - Exclude ColonSeparator from negated sets Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16 tasks across 4 chunks: 1. Foundation (HostVariableBinding, enums, nodes, visitors, CodeElements) 2. Infrastructure (CUP, builders, dispatcher, listener) 3. Grammar (ANTLR rules, SqlCodeElementBuilder, ANTLR listener) 4. Tests (test files, unit tests, regression, integration) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ucture - Create HostVariableBinding class for tracking host variable bindings with direction - Add CodeElementType and StatementType entries for Insert, Update, SqlDelete, DeclareCursor - Create AST node classes (Insert, Update, SqlDelete, DeclareCursor) in Sql/Nodes - Create CodeElement statement classes (InsertStatement, UpdateStatement, SqlDeleteStatement, DeclareCursorStatement) - Add Visit methods for all new types to IASTVisitor and AbstractAstVisitor - Enrich SelectStatement with IntoHostVariables and WhereHostVariables properties Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ECLARE CURSOR/SELECT INTO Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…DELETE/DECLARE CURSOR) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix file encoding: preserve original Windows-1252 bytes in grammar comments (no more UTF-8 replacement characters in diff) - Remove redundant insertValueList rule, reuse repeatedSourceValue as suggested by reviewer - Add TODO comments in CobolCodeElements.g4 for all incomplete optional clauses (INSERT, UPDATE, DELETE, DECLARE CURSOR) - Update SqlCodeElementBuilder to navigate sourceValue tree for host variable extraction (FindHostVariable helper) - Add Comparator Visit methods for all new SQL statement types (InsertStatement, UpdateStatement, SqlDeleteStatement, DeclareCursorStatement, UnsupportedSqlStatement) - Create dedicated rdzSQL unit tests (one per statement type): ExecSqlWithInsertStatement, ExecSqlWithUpdateStatement, ExecSqlWithDeleteStatement, ExecSqlWithDeclareCursorStatement - Update ExecSqlWithUnsupportedStatement test: remove now-supported statements, keep only OPEN/FETCH/CLOSE - Build verified: 0 errors (885 pre-existing warnings) Addresses review from fm-117 on PR TypeCobolTeam#2838. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix Comparator: use DumpString/DumpStringList for string properties to avoid SqlObject.DumpProperty treating strings as IEnumerable<char> - Regenerate expected .SQL.txt files from actual parser output - Update ExecInDataDivision_NoEndExec expected error message to include new SQL DML statement types in token list - All 63 tests pass (0 failures) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Will be recreated separately. |
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
InsertStatement,UpdateStatement,SqlDeleteStatement,DeclareCursorStatement) with structured properties (table name, column bindings, host variables)HostVariableBindingmodel to track column-to-variable mappings with direction (IN/OUT), enabling column-level data lineage for COBOL DB2 programsMotivation
Previously, INSERT/UPDATE/DELETE/DECLARE CURSOR fell into
UnsupportedSqlStatementwith only a raw SQL keyword available. This made it impossible to reliably extract:This structured parsing is required for CRUD matrix extraction and data lineage analysis in downstream tools (SAST bridges, data flow analysis).
Changes
CobolCodeElements.g4insertStatement,updateStatement,sqlDeleteStatement,declareCursorStatementInsertStatement.cs,UpdateStatement.cs,SqlDeleteStatement.cs,DeclareCursorStatement.csHostVariableBinding.csSqlCodeElementBuilder.csTypeCobolProgram.cup,ProgramClassBuilder.csCobolLanguageLevelVisitor.cs,NodeDispatcher,NodeListenerInsert.cs,Update.cs,SqlDelete.cs,DeclareCursor.csTest plan
EnableSqlParsing = true)🤖 Generated with Claude Code