Skip to content

COBOL translator: rowset FETCH with host-variable arrays, proven on Db2 (Part of #4269) - #7093

Merged
squid-shepherd[bot] merged 3 commits into
mainfrom
churn/4269-20261030T0632Z
Oct 30, 2026
Merged

squid-shepherd[bot] merged 3 commits into
mainfrom
churn/4269-20261030T0632Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #4269

What

Multi-row (ROWSET) FETCH with host-variable arrays in the det port, proven on the Db2 oracle: FETCH [NEXT] ROWSET FROM c FOR n ROWS INTO :A1 [:I1], :A2 against a cursor declared WITH ROWSET POSITIONING. One OCCURS table per column, optional indicator tables.

  • det/sql.py: parses the form, emits DetSql.fetchRowset + DetSql.intoRows; a cursor not declared WITH ROWSET POSITIONING, SENSITIVE/DYNAMIC, a count above the smallest table or below 1 are refused by name. OCCURS host variables outside a rowset FETCH are refused (register Q4).
  • DetSql.java: runtime (RT-SQL-ROWSET-FETCH). A rowset reaching end of data is +100 with SQLERRD(3) = rows read, a full rowset is 0, zero rows is +100, a closed cursor is -501.
  • Oracle: ggsql.c loops SQLFetch n times into strided arrays; equivalence_sql.py Precompiler emits NAME OF QUAL (1) and the rowset token.
  • Forge: _CURSOR_FOR learns WITH ROWSET POSITIONING (without it the DECLARE text leaked into the query).
  • Register Q4 updated; new tests in test_sql_dynamic.py incl. an inline ROWDEMO estate proved on Db2 (full, short and empty rowsets, a NULL column, a closed cursor).

Evidence

  • det_port.py check: no translated program changed; the only diff is DetSql.java (additive) in 82 ports. All 82 re-proved: 82 PROVED, 0 not.
  • pr_gates --fast 9/9, --ratchets all pass, audit_check.py clear, ruff format --check clean, test_cobolrt_rules + test_sql_dynamic 172 passed.
  • Not run: the full pytest suite and the golden crucible (no parsing-logic change).

Plan changes

The plan said a partial rowset is SQLCODE 0; the oracle returns +100 with SQLERRD(3) = rows read, so the runtime matches that. The estate is built inline, no committed estate dir.

Cap

Six hand-written files (sql.py, DetSql.java, ggsql.c, equivalence_sql.py, the forge, test_sql_dynamic.py), plus the register and rule catalogue docs.

File-cap exception: translator, runtime, oracle shim and precompiler must move together for the rowset form to be provable on Db2; any smaller cut would ship an unproven form.

Remaining slices

  • INSERT ... FOR n ROWS [ATOMIC|NOT ATOMIC]
  • rowset positioning beyond forward: STARTING AT, PRIOR/FIRST/LAST/ABSOLUTE/RELATIVE ROWSET
  • positioned UPDATE/DELETE on a rowset

Class / Sibling gaps

Class: host-variable arrays in embedded SQL. Fixed here: ROWSET FETCH, and OCCURS host variables elsewhere are now refused by name instead of mistranslated. Sibling gaps (multi-row INSERT, STARTING AT/orientations, positioned UPDATE/DELETE on a rowset): none is used by a burned-estate program today (the burned-estate pin _SCROLL_OR_ROWSET_SQL is unchanged), so none is needed by CardDemo, CBSA, GenApp, zECS, DBB MortgageApplication or cicsdev async.

Lessons for agents

  • The forge _CURSOR_FOR regex must learn every new DECLARE CURSOR clause, or the clause leaks into the repository query and every Java FETCH returns -501.
  • The oracle find_cursor must prefer the OPEN statement whose handle is set, or a re-OPEN through a second OPEN statement gives -501.
  • cobc wants a subscripted qualified name as NAME OF QUAL (1).

Cross-repo: none; no companion PRs.

🤖 Generated with Claude Code

@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 30, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review October 30, 2026 07:45
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) October 30, 2026 07:48
@squid-shepherd
squid-shepherd Bot merged commit 3612f6b into main Oct 30, 2026
96 checks passed
@squid-shepherd
squid-shepherd Bot deleted the churn/4269-20261030T0632Z branch October 30, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant