Skip to content

Language Addition: IBM DB2 SQL (db2_sql) #2511

Closed

Description

@squid-protocol

Parent: #2516

Language: IBM DB2 SQL / SQL PL
Extensions: .sql, .ddl, .dml
Lexical Family: standard_block (uses -- for line comments and /* */ for block comments).

Scoping Situation

Currently, GitGalaxy only has a sqlite parser claiming the .sql and .ddl extensions. SQLite is structurally insufficient for parsing enterprise IBM DB2 schemas and Stored Procedures (SQL PL), which contain heavy business logic, physical storage allocations (TABLESPACE), and complex control flow. For mainframe legacy modernization analyses, capturing the logic locked inside DB2 stored procedures is critical.

🚨 Critical Extension Conflict: We must resolve the .sql / .ddl conflict between sqlite and the new db2_sql profile.

  • Action Required: Configure discriminators in the db2_sql profile (e.g., [".cbl", ".jcl", ".bms", ".pli"]) so the detector intelligently routes .sql files to the DB2 parser instead of SQLite when analyzing a mainframe ecosystem.

We need code that covers:

  • x (Topology): func_start targeting CREATE PROCEDURE, CREATE FUNCTION, and CREATE TRIGGER. class_start targeting CREATE TABLE, CREATE VIEW, and CREATE TABLESPACE.
  • y (Business Logic in Stored Procs): branch capturing SQL PL control flow (IF, ELSEIF, CASE, WHILE, REPEAT). state_mutation capturing INSERT, UPDATE, DELETE, SET, and MERGE.
  • z (Database Mechanics): encapsulation for GRANT/REVOKE security boundaries. io capturing FETCH, OPEN, and CLOSE cursor operations.

Implementation Requirements

  1. Follow how_to_add_a_language.md to map DB2 SQL/SQL PL syntax.
  2. Implement the discriminator-based extension conflict resolution for .sql and .ddl.
  3. Write tests/extraction/languages/test_db2_sql_strict.py ensuring the parser correctly handles massive legacy schema dumps without ReDoS or backtracking delays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlegacy-modernizationpriority: high

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions