aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-20 10:04:51 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-20 10:04:51 +0200
commit04c8011390f5ae406cd0357559ab0b1c6e079e8a (patch)
tree0ad07ed30a40d00d22a7ecb4d2b1b7dc601251ef
parent693b99238ad003daa9e79c09fc10bcb0289669c0 (diff)
Correct usage of details::buffer instance during callbacks and LOB streaming
-rw-r--r--odb/oracle/statement.cxx28
1 files changed, 19 insertions, 9 deletions
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx
index 2f7311d..e069d43 100644
--- a/odb/oracle/statement.cxx
+++ b/odb/oracle/statement.cxx
@@ -76,6 +76,9 @@ namespace odb
{
bind& b (*static_cast<bind*> (context));
+ details::buffer* lob_buffer (
+ reinterpret_cast<details::buffer*>(b.buffer));
+
// Only call the callback if the parameter is not NULL.
//
if (*b.indicator != -1)
@@ -86,8 +89,8 @@ namespace odb
const_cast<const void**> (buffer),
size,
&pos,
- b.buffer,
- b.capacity))
+ lob_buffer->data (),
+ lob_buffer->capacity ()))
return OCI_ERROR;
switch (pos)
@@ -214,8 +217,12 @@ namespace odb
if (callback)
{
- b->buffer = conn_.lob_buffer ().data ();
- b->capacity = conn_.lob_buffer ().capacity ();
+ details::buffer& lob_buffer (conn_.lob_buffer ());
+
+ if (lob_buffer.capacity () == 0)
+ lob_buffer.capacity (4096);
+
+ b->buffer = &lob_buffer;
r = OCIBindDynamic (h, err, b, &param_callback_proxy, 0, 0);
@@ -363,7 +370,7 @@ namespace odb
*b->indicator != -1 && b->callback->result != 0)
{
auto_descriptor<OCILobLocator>& locator (
- *reinterpret_cast<auto_descriptor<OCILobLocator>* > (b->buffer));
+ *reinterpret_cast<auto_descriptor<OCILobLocator>*> (b->buffer));
ub1 piece (OCI_FIRST_PIECE);
@@ -377,7 +384,10 @@ namespace odb
// Allocate buffer space if necessary.
//
- conn_.lob_buffer ().capacity (4096);
+ details::buffer& lob_buffer (conn_.lob_buffer ());
+
+ if (lob_buffer.capacity () == 0)
+ lob_buffer.capacity (4096);
sword r;
do
@@ -388,8 +398,8 @@ namespace odb
&read,
0,
1,
- conn_.lob_buffer ().data (),
- conn_.lob_buffer ().capacity (),
+ lob_buffer.data (),
+ lob_buffer.capacity (),
piece,
0,
0,
@@ -414,7 +424,7 @@ namespace odb
// returned from a user callback. We simulate this.
//
if (!(*b->callback->result) (b->context->result,
- conn_.lob_buffer ().data (),
+ lob_buffer.data (),
static_cast<ub4> (read),
cp))
throw database_exception (24343, "user defined callback error");