You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Cursor#reparse_between_execs to work around OCI re-exec deadlock
Re-executing the same parsed cursor under CURSOR_SHARING=FORCE (or
SIMILAR) when the SQL contains BOTH a literal AND a RETURNING ... INTO
:bind clause hangs forever on the second exec. The server reports
"SQL*Net more data from client"; the client sits in
OCIStmtExecute -> kpuexec -> ... -> nttfprd -> read().
A SQL*Net wire trace shows OCIStmtExecute constructs a 31-byte fast-path
"execute already-parsed cursor" packet, and that packet differs from the
working (CURSOR_SHARING=EXACT) case by exactly one byte computed inside
libclntsh from cursor state set by exec kubo#1's response. ruby-oci8 calls
OCIStmtExecute with identical arguments in both runs, so the defect is
in the Oracle Client TTC marshalling, not ruby-oci8.
Add an opt-in Cursor#reparse_between_execs accessor (default false) that
releases and re-prepares the underlying statement handle before every
exec after the first, forcing OCI onto the full parse+exec path and
avoiding the buggy fast path. Bind values are preserved.
- ext/oci8/stmt.c: add private __reprepare(sql), and let oci8_bind cleanly
detach a bind object from a previous statement so the same valuep/indp
buffers can be re-attached to a fresh statement handle.
- lib/oci8/cursor.rb: remember the parsed SQL on initialize, expose
reparse_between_execs, and re-bind every entry in @bind_handles after
__reprepare.
- test/test_reparse_between_execs.rb: regression test covering the
literal + RETURNING + same-cursor scenario plus a plain repeated
INSERT to ensure the flag does not affect ordinary cursors.
The flag is off by default; existing cursors keep their fast-path
behavior. Leave it false unless you actually hit the deadlock - the
extra round trip costs measurable latency on hot paths.
Refs: rsim/oracle-enhanced#2619, rsim/oracle-enhanced#2620.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments