From d20629df902528e9112d146d97e0523104a46619 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Oct 2012 12:25:58 +0200 Subject: Fix issue with unbind data management in query with descriptors --- odb/oracle/statement.cxx | 31 ++++++++++++++----------------- odb/oracle/statement.hxx | 5 +++-- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index 309a5ce..7eb65c1 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -150,36 +150,30 @@ namespace odb for (size_t i (0); i < usize_; ++i) { ub4 t; - bind& b (*udata_[i].bind); + bind* b (udata_[i].bind); - switch (b.type) + switch (udata_[i].type) { case bind::timestamp: { - datetime* dt (static_cast (b.buffer)); - - if (dt->flags & descriptor_cache) - dt->descriptor = 0; + if (b != 0) + static_cast (b->buffer)->descriptor = 0; t = OCI_DTYPE_TIMESTAMP; break; } case bind::interval_ym: { - interval_ym* iym (static_cast (b.buffer)); - - if (iym->flags & descriptor_cache) - iym->descriptor = 0; + if (b != 0) + static_cast (b->buffer)->descriptor = 0; t = OCI_DTYPE_INTERVAL_YM; break; } case bind::interval_ds: { - interval_ds* ids (static_cast (b.buffer)); - - if (ids->flags & descriptor_cache) - ids->descriptor = 0; + if (b != 0) + static_cast (b->buffer)->descriptor = 0; t = OCI_DTYPE_INTERVAL_DS; break; @@ -352,7 +346,8 @@ namespace odb { unbind& u (udata_[usize_++]); - u.bind = b; + u.type = bind::timestamp; + u.bind = (dt->flags & descriptor_cache) ? b : 0; u.value = d; value = &u.value; } @@ -416,7 +411,8 @@ namespace odb { unbind& u (udata_[usize_++]); - u.bind = b; + u.type = bind::interval_ym; + u.bind = (iym->flags & descriptor_cache) ? b : 0; u.value = d; value = &u.value; } @@ -473,7 +469,8 @@ namespace odb { unbind& u (udata_[usize_++]); - u.bind = b; + u.type = bind::interval_ds; + u.bind = (ids->flags & descriptor_cache) ? b : 0; u.value = d; value = &u.value; } diff --git a/odb/oracle/statement.hxx b/odb/oracle/statement.hxx index ed8f298..bedddbc 100644 --- a/odb/oracle/statement.hxx +++ b/odb/oracle/statement.hxx @@ -51,8 +51,9 @@ namespace odb protected: struct unbind { - oracle::bind* bind; // Corresponding bind entry. - void* value; // Actual value passed to OCIBindByPos. + oracle::bind::buffer_type type; // Bind type. + oracle::bind* bind; // Corresponding bind entry. + void* value; // Actual value passed to OCIBindByPos. }; // Bind parameters for this statement. This function must only -- cgit v1.1