Skip to content

[Bug]: SQL: CREATE OR REPLACE EDITIONABLE/NONEDITIONABLE PROCEDURE|FUNCTION|TRIGGER yields only a file node (0 edges) #5167

Closed

Description

@a9385208438-dev

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

Oracle's default DDL form (what DBMS_METADATA.GET_DDL and most IDE exports emit) is CREATE OR REPLACE EDITIONABLE PROCEDURE ... (also NONEDITIONABLE, and for FUNCTION and TRIGGER). extract_sql returns only the file node and no edges for such a file. The identical statement without the EDITIONABLE keyword gives the routine node plus reads_from / writes_to edges.

Expected: same result with or without [NON]EDITIONABLE.

Root cause: the ERROR-node recovery regexes in graphify/extractors/sql.py allow only CREATE [OR REPLACE|ALTER] directly followed by FUNCTION|PROC[EDURE] (_ROUTINE_RECOVERY_RX, lines 35-41) or TRIGGER (_TRIGGER_RECOVERY_RX, lines 54-59), so the statement is never recovered (used at lines 945 and 966).

Steps to reproduce

mkdir demo && cd demo
cat > t1.sql <<'SQL'
CREATE OR REPLACE EDITIONABLE PROCEDURE hr.load_emp IS
BEGIN
  INSERT INTO hr.emp_copy SELECT * FROM hr.emp;
END;
/
SQL
sed 's/EDITIONABLE //' t1.sql > t1b.sql
python - <<'PY'
from pathlib import Path
from graphify.extractors.sql import extract_sql
for f in ("t1.sql", "t1b.sql"):
    r = extract_sql(Path(f))
    print(f, [n["label"] for n in r["nodes"]], sorted({(e["relation"], e["target"]) for e in r["edges"]}))
PY

Error output or graph output

t1.sql  ['t1.sql'] []
t1b.sql ['t1b.sql', 'hr.load_emp()', 'hr.emp_copy', 'hr.emp'] [('reads_from', 'hr_emp'), ('writes_to', 'hr_emp_copy'), ('contains', ...)]

Same result (file node only) for NONEDITIONABLE, for EDITIONABLE FUNCTION hr.f RETURN NUMBER IS ..., and for EDITIONABLE TRIGGER hr.trg_emp BEFORE INSERT ON hr.emp FOR EACH ROW ....

Proposed fix (verified on a local copy of sql.py)

Allow an optional (?:NON)?EDITIONABLE in both regexes:

-    r"\bCREATE\s+(?:OR\s+(?:REPLACE|ALTER)\s+)?(?:FUNCTION|PROC(?:EDURE)?)\s+"
+    r"\bCREATE\s+(?:OR\s+(?:REPLACE|ALTER)\s+)?(?:(?:NON)?EDITIONABLE\s+)?(?:FUNCTION|PROC(?:EDURE)?)\s+"
@@ _TRIGGER_RECOVERY_RX
-    r"\bCREATE\s+(?:OR\s+(?:REPLACE|ALTER)\s+)?TRIGGER\s+"
+    r"\bCREATE\s+(?:OR\s+(?:REPLACE|ALTER)\s+)?(?:(?:NON)?EDITIONABLE\s+)?TRIGGER\s+"

With this patch all four variants (EDITIONABLE / NONEDITIONABLE procedure, EDITIONABLE function, EDITIONABLE trigger) produce hr.load_emp() / hr.f() / hr.trg_emp nodes with reads_from, writes_to, triggers edges, matching the non-EDITIONABLE output. A regression test (the four statements above, asserting the routine node and edges) would fail before and pass after. Happy to submit the PR.

Graphify version

0.9.104

Operating System

Linux

Python Version

3.12

Installation Method

uv tool install (recommended)

Additional context

Related: #1992 (full PL/SQL grammar, which would subsume this), #3164 (same regex, T-SQL).

Activity

  1. github-actions commented on Nov 12, 2026

    @github-actions

    Thanks for opening this issue, @a9385208438-dev. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Nov 12, 2026

    @safishamsi
    Member

    Fixed by #5183 (131d302), released in graphify 0.9.108. Thanks @a9385208438-dev for the report and @Yi-111-a for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions