From 7fbc5ccbb2c245000af43f3ca13e714af459a1dd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Nov 2011 15:45:43 +0200 Subject: Restore LOB prefetch resetting code (again) --- odb/oracle/statement.cxx | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'odb/oracle/statement.cxx') 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 (b->size)); + OCIError* err (conn_.error_handle ()); sword r (OCIDefineByPos (stmt_, &h, - conn_.error_handle (), + err, i, value, static_cast (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 (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 } } -- cgit v1.1