Skip to content

fix: write re-execute cursor/count/options/flags as UB4 (ORA-03106 at 65,536 rows) - #788

Open
chrisfw wants to merge 1 commit into
sijms:masterfrom
chrisfw:fix/reexec-ub4-count
Open

chrisfw wants to merge 1 commit into
sijms:masterfrom
chrisfw:fix/reexec-ub4-count

Conversation

@chrisfw

@chrisfw chrisfw commented Nov 8, 2026

Copy link
Copy Markdown

Fixes #787.

Stmt.write's re-execute branch wrote the cursor id, iteration count, execute options and flags with PutUint(x, 2, true, true). For values over 0xFFFF, PutUint writes a length byte of 2 followed by three bytes, which desynchronizes the message. On 23ai/26ai, executing an array DML of 65,536+ rows a second time fails with ORA-03106.

These fields are UB4, so they are now written with size 4. Values ≤ 0xFFFF encode to exactly the same bytes as before (the compressed form only writes the significant bytes), so nothing changes on the wire for existing callers.

  • v2/command.go: size 4 for the four re-execute fields.
  • v2/network/session_putuint_test.go: the compressed UB4 encodings, including 0x10000 and an exeOf value with 0x40000 set.

Tested against Oracle Database 26ai Free: an array INSERT of 65,536 rows executed twice. Before: ORA-03106 on the second execute. After: 131,072 rows.

Stmt.write's re-execute path wrote the cursor id, iteration count, execute
options and flags with PutUint(x, 2, true, true). A compressed integer is a
length byte followed by that many bytes, but PutUint caps the length byte at
size while still writing every significant byte, so 65,536 is sent as
02 01 00 00. The server reads a count of 256 and every following field one
byte off. Oracle 23ai/26ai reject it with ORA-03106; the same happens for an
exeOf with 0x40000 set.

Repro: prepare an array-bound INSERT, execute it twice with 65,536 rows. The
first execute (parse) is fine, the second fails with ORA-03106; 65,535 rows
work. With this change both executes load all rows (Oracle 26ai, FREEPDB1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array execute of 65,536+ rows fails on re-execute with ORA-03106 (iteration count written with a 2-byte cap)

2 participants