aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/statement.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-08 15:45:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-08 15:45:43 +0200
commit7fbc5ccbb2c245000af43f3ca13e714af459a1dd (patch)
treee07699981aa9c0323f69862c436855d6204ba9c4 /odb/oracle/statement.cxx
parentf46601155e09b17576d2ff6272dde5fc3f2d9620 (diff)
Restore LOB prefetch resetting code (again)
Diffstat (limited to 'odb/oracle/statement.cxx')
-rw-r--r--odb/oracle/statement.cxx35
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
}
}