Skip to content

Generated batch sequential READ of a KSDS is findAll(): records come back in database order, not key order #3945

Closed

Description

@squid-protocol

What: a batch program that reads a KSDS sequentially (ORGANIZATION IS INDEXED, ACCESS MODE IS SEQUENTIAL, READ ... NEXT) gets the records in ascending key order. VSAM compares the key's bytes in the data code page: lower case before upper case, letters before digits. The generated service reads them with a bare findAll():

public List<CustRec> readAllCustFile() {
    return custRecRepository.findAll();
}

findAll() sends no ORDER BY, so the order is whatever the database hands back. This happens on every engine and every code page, even though #3822 (PR #3874) generates the <KEY>_SORT column that the CICS browse finders already order by. Nothing breaks visibly: the records just come back in a different order, which silently changes control breaks, merge/match logic, and the order of report lines.

Found by: the Cultural Gauntlet, part 3, dimension D (#3834). The estate is a PIC X(8) KSDS that CICS browses and a batch step reads sequentially. The generated table was created in real databases, 22 keys were written through the generated CobolRecords.sortKey, and the results were read back:

  • collation-static: fails in all 32 cells (4 targets × 8 columns).
  • collation-db (--db): fails in all 24 executed cells (H2 2.2.224, PostgreSQL 16 with a C database, PostgreSQL 16 with an en_US.UTF-8 database). Every other probe passes in the same cells: STARTBR/READNEXT from LOW-VALUES and from a key, READPREV, and the duplicate on a trailing-space key.
    • PostgreSQL returns heap (insertion) order: ZZ|abc|1A|ÆBLE|ABC|....
    • H2 returns primary-key code-point order: #1|123|1A|@1|A 1|....
    • The mainframe (cp037) returns: é1|ÄRGER|ÅS|ÑANDU|#1|@1|ØRE|abc|aBC|ÆBLE|A 1|A.1|A-1|Abc|ABC|A1|E1|NANDU|ZZ|1A|123.

Expected: a sequential READ of a KSDS reads in key order. For a String key under culture.key_collation: ebcdic that means ordering by the sort column, e.g. findAll(Sort.by("custKeySort")) or a derived findAllByOrderByCustKeySortAsc(). A numeric or binary key orders by the key itself. This only fixes order when the DB has a sort column; keys written by raw SQL still have none (#3874's limit).

Where: gitgalaxy/tools/cobol_to_java/cobol_to_java_repository_forge.py, the batch branch of the service ops (readAll{name} → findAll()).

Ledgered in: tests/cultural_gauntlet/baseline.txt (collation_*|*|collation-static, collation_*|*|collation-db). The fix lowers the baseline.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    legacy-modernization
    priority: high
    on Sep 28, 2026
  2. added 2 commits that reference this issue on Sep 28, 2026
  3. added
    status: pending-release
    on Sep 28, 2026
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

    buglegacy-modernizationpriority: highstatus: pending-release

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions