Skip to content

Fix decode crash on a NULL scalar OUT bind from a PL/SQL block (#205)#206

Merged
lemenkov merged 1 commit into
masterfrom
fix-null-outbind-decode
Jun 25, 2026
Merged

Fix decode crash on a NULL scalar OUT bind from a PL/SQL block (#205)#206
lemenkov merged 1 commit into
masterfrom
fix-null-outbind-decode

Conversation

@lemenkov

Copy link
Copy Markdown
Owner

A PL/SQL block / callproc / callfunc with a scalar OUT bind that comes back NULL crashed the response decoder:

BEGIN :1 := NULL; END;   # one VARCHAR2 OUT -> Exception: Can't decode unknown type

Cause: in _read_iov the per-value return code is a variable-length integer, not a fixed byte. A non-NULL value's code is ub4(0) = one 0x00 byte (so the old fixed 1-byte skip happened to work), but a NULL value's is ub4(-1) = 0x81 0x01 (two bytes). Skipping a fixed byte left a stray byte and desynced the decoder.

Fix: consume the return code with decode_ub4 (scalar + associative-array element paths).

Tests: new test_null_scalar_out_bind (mixed NULL/non-NULL OUT binds + a lone NULL OUT). OUT-bind suites — callproc, assoc-array #122 — green on 9i/10g/11g/21c/23ai; offline 522.

Pre-existing bug; surfaced while building SODA (#200), whose documents have NULL fields (created_on / last_modified on a default collection).

Closes #205

🤖 Generated with Claude Code

A PL/SQL block / callproc / callfunc with a scalar OUT bind that returns
NULL crashed the response decoder ("Can't decode unknown type"). In the
IOV OUT-value decode (_read_iov), the per-value return code is a
variable-length integer, not a fixed byte: a non-NULL value's code is
ub4(0) = one 0x00 byte (so the old fixed 1-byte skip happened to work),
but a NULL value's is ub4(-1) = 0x81 0x01 (two bytes). Skipping a fixed
byte left a stray byte and desynced the decoder on the next token.

Consume the return code with decode_ub4 (both the scalar and the
associative-array element paths). Verified on 9i/10g/11g/21c/23ai.

Surfaced while building SODA (#200): SODA documents have NULL fields
(e.g. created_on / last_modified on a default collection).

Closes #205

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
@lemenkov lemenkov added this to the 1.10.0 milestone Jun 25, 2026
@lemenkov lemenkov merged commit 49f0e1e into master Jun 25, 2026
10 checks passed
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.

Decode crash on a NULL scalar OUT bind from a PL/SQL block

1 participant