diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-18 14:58:20 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-18 14:58:20 +0200 |
commit | b2f364f0e1a3c67732c7b54ce4422c6827402572 (patch) | |
tree | a1ee8a67582553637a55c9d46e0073c7b4d6fd7a | |
parent | 7c3e9f3ae4bb1a207fd2443456c3309e8b173ac8 (diff) |
Split object image binding into in and out variants
-rw-r--r-- | odb/mysql/object-statements.hxx | 62 | ||||
-rw-r--r-- | odb/mysql/object-statements.txx | 17 | ||||
-rw-r--r-- | odb/mysql/result.txx | 18 |
3 files changed, 63 insertions, 34 deletions
diff --git a/odb/mysql/object-statements.hxx b/odb/mysql/object-statements.hxx index c2c97e8..4c81a76 100644 --- a/odb/mysql/object-statements.hxx +++ b/odb/mysql/object-statements.hxx @@ -78,27 +78,45 @@ namespace odb } std::size_t - image_version () const + in_image_version () const { - return image_version_; + return in_image_version_; + } + + std::size_t + out_image_version () const + { + return out_image_version_; } void - image_version (std::size_t v) + in_image_version (std::size_t v) { - image_version_ = v; + in_image_version_ = v; + } + + void + out_image_version (std::size_t v) + { + out_image_version_ = v; } binding& - image_binding () + in_image_binding () { - return image_binding_; + return in_image_binding_; + } + + binding& + out_image_binding () + { + return out_image_binding_; } my_bool* - image_error () + out_image_error () { - return image_error_; + return out_image_error_; } // Object id image. @@ -133,7 +151,7 @@ namespace odb if (persist_ == 0) persist_.reset ( new (details::shared) persist_statement_type ( - conn_, object_traits::persist_statement, image_binding_)); + conn_, object_traits::persist_statement, in_image_binding_)); return *persist_; } @@ -147,7 +165,7 @@ namespace odb conn_, object_traits::find_statement, id_image_binding_, - image_binding_)); + out_image_binding_)); return *find_; } @@ -161,7 +179,7 @@ namespace odb conn_, object_traits::update_statement, id_image_binding_, - image_binding_)); + in_image_binding_)); return *update_; } @@ -194,16 +212,24 @@ namespace odb private: container_statement_cache_type container_statement_cache_; - // The last element is the id parameter. The update statement - // depends on this being one contiguous arrays. + image_type image_; + + // In (send) binding. The last element is the id parameter. The + // update statement depends on this being one contiguous arrays. // - MYSQL_BIND image_bind_[object_traits::column_count + 1]; + std::size_t in_image_version_; + binding in_image_binding_; + MYSQL_BIND in_image_bind_[object_traits::in_column_count + 1]; - image_type image_; - std::size_t image_version_; - my_bool image_error_[object_traits::column_count]; - binding image_binding_; + // Out (receive) binding. + // + std::size_t out_image_version_; + binding out_image_binding_; + MYSQL_BIND out_image_bind_[object_traits::out_column_count]; + my_bool out_image_error_[object_traits::out_column_count]; + // Id image binding (only in). + // id_image_type id_image_; std::size_t id_image_version_; binding id_image_binding_; diff --git a/odb/mysql/object-statements.txx b/odb/mysql/object-statements.txx index 4b8e356..32d67f1 100644 --- a/odb/mysql/object-statements.txx +++ b/odb/mysql/object-statements.txx @@ -18,20 +18,23 @@ namespace odb object_statements (connection_type& conn) : object_statements_base (conn), container_statement_cache_ (conn), - image_binding_ (image_bind_, object_traits::column_count), - id_image_binding_ (image_bind_ + object_traits::column_count, 1) + in_image_binding_ (in_image_bind_, object_traits::in_column_count), + out_image_binding_ (out_image_bind_, object_traits::out_column_count), + id_image_binding_ (in_image_bind_ + object_traits::in_column_count, 1) { image_.version = 0; - image_version_ = 0; + in_image_version_ = 0; + out_image_version_ = 0; id_image_.version = 0; id_image_version_ = 0; - std::memset (image_bind_, 0, sizeof (image_bind_)); - std::memset (image_error_, 0, sizeof (image_error_)); + std::memset (in_image_bind_, 0, sizeof (in_image_bind_)); + std::memset (out_image_bind_, 0, sizeof (out_image_bind_)); + std::memset (out_image_error_, 0, sizeof (out_image_error_)); - for (std::size_t i (0); i < object_traits::column_count; ++i) - image_bind_[i].error = image_error_ + i; + for (std::size_t i (0); i < object_traits::out_column_count; ++i) + out_image_bind_[i].error = out_image_error_ + i; } } } diff --git a/odb/mysql/result.txx b/odb/mysql/result.txx index e1e8440..c342b17 100644 --- a/odb/mysql/result.txx +++ b/odb/mysql/result.txx @@ -44,11 +44,11 @@ namespace odb { typename traits::image_type& im (statements_.image ()); - if (im.version != statements_.image_version ()) + if (im.version != statements_.out_image_version ()) { - binding& b (statements_.image_binding ()); - traits::bind (b.bind, im); - statements_.image_version (im.version); + binding& b (statements_.out_image_binding ()); + traits::bind (b.bind, im, true); + statements_.out_image_version (im.version); b.version++; } } @@ -60,13 +60,13 @@ namespace odb case select_statement::truncated: { typename traits::image_type& im (statements_.image ()); - traits::grow (im, statements_.image_error ()); + traits::grow (im, statements_.out_image_error ()); - if (im.version != statements_.image_version ()) + if (im.version != statements_.out_image_version ()) { - binding& b (statements_.image_binding ()); - traits::bind (b.bind, im); - statements_.image_version (im.version); + binding& b (statements_.out_image_binding ()); + traits::bind (b.bind, im, true); + statements_.out_image_version (im.version); b.version++; statement_->refetch (); } |