Skip to content

DetSql: SELECT INTO a binary (COMP) host variable gives -304 for an INTEGER beyond the PICTURE's digits; Db2 assigns the fullword #4579

Closed

Description

@squid-protocol

Found by #4507's generated Db2 rows (case cbsa-updacc-generated, PR #4577).

What. CBSA UPDACC selects ACCOUNT_OVERDRAFT_LIMIT INTEGER into HV-ACCOUNT-OVERDRAFT-LIM PIC S9(9) COMP. A generated row holds the INTEGER boundary 2147483647 (and -2147483648).

  • COBOL side (tests/equivalence/db2/ggsql.c, num_store): a binary host variable takes any value its 2/4/8 bytes hold -- -304 only beyond the halfword/fullword range. The row is assigned, the program goes on to UPDATE.
  • det port (gitgalaxy/tools/cobol_to_java/det/cobolrt/sql/DetSql.java, Cobol.storeChecked around line 293): the value is checked against the PICTURE's 9 digits, so 2147483647 is SQLCODE -304 / 22003; the det UPDACC reports "UPDACC returned -00000304 on SELECT" and skips the UPDATE.

Db2 for z/OS assigns an INTEGER to an S9(9) COMP host variable as a fullword (the precompiler declares S9(9) COMP as INTEGER), so the oracle's behaviour is the expected one; the hand-written cbsa-updacc port agrees with it.

Effect. det_port.py run cbsa-updacc-generated: DIFFERS on the tasks whose account row has an overdraft limit beyond 999999999 (3 of 40 scenarios, each in runTask and java-facade). Listed in tests/equivalence/det_sweep_baseline.json under this issue by #4577.

Fix. In DetSql, for a binary host variable check the value against the binary range of its length (as ggsql.c does), not the PICTURE's digits (with TRUNC(BIN) semantics as the rest of the det runtime models them).

Metadata

Metadata

Assignees

No one assigned

    Labels

    era:2scope:core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions