diff options
Diffstat (limited to 'odb/oracle/statement.cxx')
-rw-r--r-- | odb/oracle/statement.cxx | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index b789959..642e928 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -629,10 +629,11 @@ namespace odb // initial call to OCIDefineByPos when binding for the first time. // OCIDefine* h (reinterpret_cast<OCIDefine*> (b->size)); + OCIError* err (conn_.error_handle ()); sword r (OCIDefineByPos (stmt_, &h, - conn_.error_handle (), + err, i, value, static_cast<sb4> (b->capacity), @@ -643,7 +644,37 @@ namespace odb OCI_DEFAULT)); if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) - translate_error (conn_.error_handle (), r); + translate_error (err, r); + + + // LOB prefetching is only supported in OCI version 11.1 and greater + // and in Oracle server 11.1 and greater. If this code is called + // against a pre 11.1 server, the call to OCIAttrSet will return an + // error code. + // + // Note that even though we are re-binding the same handle, we still + // have to reset this attribute. Failing to do so will result in the + // mysterious ORA-03106 fatal two-task communication protocol error. + // +#if (OCI_MAJOR_VERSION == 11 && OCI_MINOR_VERSION >= 1) \ + || OCI_MAJOR_VERSION > 11 + if (p != 0 && (b->type == bind::blob || + b->type == bind::clob || + b->type == bind::nclob)) + { + ub4 n (static_cast<ub4> (p)); + + r = OCIAttrSet (h, + OCI_HTYPE_DEFINE, + &n, + 0, + OCI_ATTR_LOBPREFETCH_SIZE, + err); + + if (r == OCI_ERROR || r == OCI_INVALID_HANDLE) + translate_error (err, r); + } +#endif } } |