aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-30 08:57:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-30 08:57:37 +0200
commit3ed6a781cf4aad7986f805dc8a8e5c487d10a805 (patch)
tree1aa8eb896bcad843b3a3428059af200784f0f452
parente7ff893718d5ba3759d1c10d8ba82b611ee78b11 (diff)
Merge LOB callback function and context into struct
This allows us to have one less member in the bind struct.
-rw-r--r--odb/oracle/oracle-types.hxx26
-rw-r--r--odb/oracle/statement.cxx28
2 files changed, 27 insertions, 27 deletions
diff --git a/odb/oracle/oracle-types.hxx b/odb/oracle/oracle-types.hxx
index 4b58c08..bd62fe1 100644
--- a/odb/oracle/oracle-types.hxx
+++ b/odb/oracle/oracle-types.hxx
@@ -60,16 +60,19 @@ namespace odb
ub4 size, // [in] The result data size in bytes.
chunk_position); // [in] The position of this chunk.
- union lob_callback
+ struct lob_callback
{
- param_callback_type param;
- result_callback_type result;
- };
+ union
+ {
+ param_callback_type param;
+ result_callback_type result;
+ } callback;
- union lob_context
- {
- const void* param;
- void* result;
+ union
+ {
+ const void* param;
+ void* result;
+ } context;
};
struct bind
@@ -112,15 +115,10 @@ namespace odb
// bindings, this is interpreted as the OCIDefine
// handle associated with the LOB result parameter.
ub4 capacity; // The maximum number of bytes that can be stored in
- // buffer.
+ // the buffer.
sb2* indicator; // Pointer to an OCI indicator variable.
lob_callback* callback;
-
- // This pointer is provided to the user through the context argument
- // in both parameter and result callback functions.
- //
- lob_context* context;
};
// An instance of this structure specifies the function to invoke and
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx
index 0bc4014..921a826 100644
--- a/odb/oracle/statement.cxx
+++ b/odb/oracle/statement.cxx
@@ -89,13 +89,14 @@ namespace odb
if (*b.indicator != -1)
{
chunk_position pos;
- if (!(*b.callback->param) (b.context->param,
- &l->position,
- const_cast<const void**> (buffer),
- size,
- &pos,
- l->buffer->data (),
- l->buffer->capacity ()))
+ if (!(*b.callback->callback.param) (
+ b.callback->context.param,
+ &l->position,
+ const_cast<const void**> (buffer),
+ size,
+ &pos,
+ l->buffer->data (),
+ l->buffer->capacity ()))
return OCI_ERROR;
switch (pos)
@@ -982,7 +983,7 @@ namespace odb
b->type == bind::clob ||
b->type == bind::nclob) &&
(b->indicator == 0 || *b->indicator != -1) &&
- b->callback->result != 0)
+ b->callback->callback.result != 0)
{
lob* l (static_cast<lob*> (b->buffer));
@@ -1038,11 +1039,12 @@ namespace odb
// OCI generates and ORA-24343 error when an error code is
// returned from a user callback. We simulate this.
//
- if (!(*b->callback->result) (b->context->result,
- &position,
- lob_buffer.data (),
- static_cast<ub4> (read),
- cp))
+ if (!(*b->callback->callback.result) (
+ b->callback->context.result,
+ &position,
+ lob_buffer.data (),
+ static_cast<ub4> (read),
+ cp))
throw database_exception (24343, "user defined callback error");
} while (r == OCI_NEED_DATA);