Skip to content

Fix INSERT INITIAL LINE into hashed tables - #1774

Merged
larshp merged 2 commits into
mainfrom
copilot/fix-insert-initial-line-issue
Jul 30, 2026
Merged

Fix INSERT INITIAL LINE into hashed tables#1774
larshp merged 2 commits into
mainfrom
copilot/fix-insert-initial-line-issue

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

INSERT INITIAL LINE INTO TABLE threw Error: Hash table insert index when the target was a hashed table:

TYPES: BEGIN OF ty,
         field1 TYPE c LENGTH 10,
         field2 TYPE c LENGTH 10,
       END OF ty.
TYPES ty2 TYPE HASHED TABLE OF ty WITH UNIQUE KEY field1.
DATA tab2 TYPE ty2.
INSERT INITIAL LINE INTO TABLE tab2.

The initial branch of insertInternal unconditionally called insertIndex, which HashedTable does not implement.

Changes

  • packages/runtime/src/statements/insert_internal.ts: the initial branch now routes HashedTable through insert() with the table's row type, setting sy-subrc from the result (4 on duplicate key) and assigning ASSIGNING / REFERENCE INTO targets only on success.
  • test/statements/insert.ts: test covering the issue snippet, including a second insert of the same initial line yielding sy-subrc = 4 and no added row.

Copilot AI linked an issue Jul 30, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix bug with INSERT INITIAL in hashed table Fix INSERT INITIAL LINE into hashed tables Jul 30, 2026
Copilot AI requested a review from larshp July 30, 2026 11:06
@github-actions

Copy link
Copy Markdown

Regression test results:

Repository Result Runtime
abap-openapi/abap-openapi 🟢 21s
abapGit/abapGit 🟢 18s
heliconialabs/abap-opentelemetry 🟢 6s
heliconialabs/abap-protobuf 🟢 7s
larshp/abap-advent-2020 🟢 6s
larshp/abap-wasm 🟢 6s
larshp/abapNTLM 🟢 7s
larshp/abapPGP 🟢 156s
oisee/zork-abap 🟢 8s
open-abap/open-abap-core 🟢 8s
open-abap/open-abap-gui 🟢 6s
open-abap/open-abap-jobs 🟢 15s
open-abap/open-abap-lock 🟢 11s
open-abap/open-abap-odata 🟢 8s
open-abap/open-table-maintenance 🟢 16s
SAP/abap-file-formats-tools 🟢 18s
Sumu-Ning/AES 🟢 7s

Performance test results:

Performance Before After Delta
1: APPEND and DELETE 912ms 936ms 24 🟢
2: READ TABLE, table_line 1051ms 1045ms -6 🟢
3: LOOP USING KEY 1287ms 1264ms -23 🟢
4: Copy, same sorting 275ms 268ms -7 🟢
5: Copy, becomes sorted 61ms 62ms 1 🟢
6: INSERT INDEX 1 740ms 729ms -11 🟢
7: APPEND matching types 373ms 364ms -9 🟢
8: READ TABLE BINARY SEARCH 67ms 68ms 1 🟢
9: INSERT INTO TABLE hashed 377ms 369ms -8 🟢
10: DELETE ADJACENT 1502ms 1496ms -6 🟢
11: READ WITH TABLE KEY HASHED 269ms 269ms 0 🟢
12: READ WITH KEY HASHED, primary 371ms 365ms -6 🟢
13: INSERT INTO TABLE standard 39ms 39ms 0 🟢
14: Constant characters 72ms 71ms -1 🟢
15: Compare characters 127ms 121ms -6 🟢
16: Method number 5 🎶 860ms 821ms -39 🟢
17: Substring and find negative 280ms 266ms -14 🟢
18: CO compare 199ms 195ms -4 🟢
19: Call method, compatible structure 119ms 117ms -2 🟢
20: Call method, identical structure 22ms 22ms 0 🟢
21: CASE many char constants 377ms 366ms -11 🟢
22: READ TABLE WITH KEY secondary 54ms 52ms -2 🟢
23: CASE many int constants 372ms 364ms -8 🟢
24: Copy table contents 314ms 336ms 22 🟢
25: READ TABLE, not found 23ms 23ms 0 🟢
26: REPLACE OCCURRENCES, simple 138ms 141ms 3 🟢
27: READ TABLE, building hash 83ms 74ms -9 🟢
28: CONCATENATE 2ms 2ms 0 🟢
29: Write Hex to Hex via offset 1335ms 1376ms 41 🟢
30: Get Hex from Hex via offset 9ms 10ms 1 🟢
31: SET BIT hex 1344ms 1359ms 15 🟢
32: GET BIT hex 1215ms 1098ms -117 🟢
33: Compare Hex 829ms 838ms 9 🟢
34: Basic CONCATENATE 71ms 71ms 0 🟢
35: gt 370ms 377ms 7 🟢
36: CLEAR char 262ms 262ms 0 🟢
37: CLEAR numc 243ms 242ms -1 🟢
38: Structure copy and APPEND 901ms 874ms -27 🟢
39: eq int 1375ms 1387ms 12 🟢
40: eq string 1266ms 1209ms -57 🟢
41: eq char, different lengths 237ms 245ms 8 🟢
42: eq int with numc 213ms 231ms 18 🟢

Updated: 2026-07-30T11:23:48.308Z

SHA: b1a7fe5

@larshp
larshp marked this pull request as ready for review July 30, 2026 11:26
@larshp
larshp merged commit 552bcc2 into main Jul 30, 2026
4 checks passed
@larshp
larshp deleted the copilot/fix-insert-initial-line-issue branch July 30, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

bug, INSERT INITIAL

2 participants