Skip to content

Key order: EBCDIC vs the target database's collation -- generated repositories browse and sort differently, MySQL collides case-variant keys #3822

Closed

Description

@squid-protocol

What: A KSDS browse and a DB2 ORDER BY follow EBCDIC order, but the generated repositories leave ordering to the database.

  • PostgreSQL's default is often en_US.UTF-8, which folds case and ignores punctuation at the first comparison level.
  • MySQL's utf8mb4_0900_ai_ci treats ABC = abc and É = E, so distinct COBOL keys collide on the primary key.

Where:

  • java_target.py:32 lists the databases, with postgresql as the default.
  • cobol_to_java_repository_forge.py:699 generates findBy…GreaterThanEqualOrderBy…Asc, with no COLLATE or binary column anywhere.
  • No fact captures COLLATING SEQUENCE, ALPHABET or DFSORT SORT FIELDS= / ALTSEQ / LOCALE=.
  • PORTING_RULES says nothing about collation.

Test: Keys A001 a001 1001 Ä001 A-01 A 01.

  • Expected CP037 browse order: a001 A 01 A-01 A001 1001. Ä001's position depends on the code page, which is itself a gauntlet cell.
  • All six keys survive a load on MySQL.

Fix:

  • Binary key columns (COLLATE "C" / BINARY), or EBCDIC-order sort bytes.
  • Capture collating facts.
  • A porting rule: order by the source code page's byte order.

Found by a cultural-assumptions audit (2026-09-26): confirmed in code or by probe (JDK 17 locales, IBM code-page decoding, the harness's GnuCOBOL image) unless marked plausible.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    legacy-modernization
    priority: high
    on Sep 26, 2026
  2. added a commit that references this issue on Sep 27, 2026
  3. added 2 commits that reference this issue on Sep 27, 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: high

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions