aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/mysql/container-statements.hxx35
-rw-r--r--odb/mysql/container-statements.txx6
-rw-r--r--odb/mysql/forward.hxx1
-rw-r--r--odb/mysql/result.txx18
4 files changed, 35 insertions, 25 deletions
diff --git a/odb/mysql/container-statements.hxx b/odb/mysql/container-statements.hxx
index 2801210..a5e93a1 100644
--- a/odb/mysql/container-statements.hxx
+++ b/odb/mysql/container-statements.hxx
@@ -33,7 +33,6 @@ namespace odb
public:
typedef T traits;
- typedef typename traits::id_image_type id_image_type;
typedef typename traits::data_image_type data_image_type;
typedef typename traits::cond_image_type cond_image_type;
@@ -61,18 +60,18 @@ namespace odb
return functions_;
}
- // Id image (external).
+ // Id image binding (external).
//
- id_image_type&
- id_image ()
+ const binding&
+ id_binding ()
{
- return *id_image_;
+ return *id_binding_;
}
void
- id_image (id_image_type& i)
+ id_binding (const binding& b)
{
- id_image_ = &i;
+ id_binding_ = &b;
}
// Condition image.
@@ -96,15 +95,15 @@ namespace odb
}
std::size_t
- cond_id_image_version () const
+ cond_id_binding_version () const
{
- return cond_id_image_version_;
+ return cond_id_binding_version_;
}
void
- cond_id_image_version (std::size_t v)
+ cond_id_binding_version (std::size_t v)
{
- cond_id_image_version_ = v;
+ cond_id_binding_version_ = v;
}
binding&
@@ -134,15 +133,15 @@ namespace odb
}
std::size_t
- data_id_image_version () const
+ data_id_binding_version () const
{
- return data_id_image_version_;
+ return data_id_binding_version_;
}
void
- data_id_image_version (std::size_t v)
+ data_id_binding_version (std::size_t v)
{
- data_id_image_version_ = v;
+ data_id_binding_version_ = v;
}
binding&
@@ -205,17 +204,17 @@ namespace odb
connection_type& conn_;
functions_type functions_;
- id_image_type* id_image_;
+ const binding* id_binding_;
cond_image_type cond_image_;
std::size_t cond_image_version_;
- std::size_t cond_id_image_version_;
+ std::size_t cond_id_binding_version_;
binding cond_image_binding_;
MYSQL_BIND cond_image_bind_[traits::cond_column_count];
data_image_type data_image_;
std::size_t data_image_version_;
- std::size_t data_id_image_version_;
+ std::size_t data_id_binding_version_;
binding data_image_binding_;
MYSQL_BIND data_image_bind_[traits::data_column_count];
my_bool data_image_truncated_[traits::data_column_count];
diff --git a/odb/mysql/container-statements.txx b/odb/mysql/container-statements.txx
index d5e4750..ba6827c 100644
--- a/odb/mysql/container-statements.txx
+++ b/odb/mysql/container-statements.txx
@@ -21,17 +21,17 @@ namespace odb
&traits::insert_one,
&traits::load_all,
&traits::delete_all),
- id_image_ (0),
+ id_binding_ (0),
cond_image_binding_ (cond_image_bind_, traits::cond_column_count),
data_image_binding_ (data_image_bind_, traits::data_column_count)
{
cond_image_.version = 0;
cond_image_version_ = 0;
- cond_id_image_version_ = 0;
+ cond_id_binding_version_ = 0;
data_image_.version = 0;
data_image_version_ = 0;
- data_id_image_version_ = 0;
+ data_id_binding_version_ = 0;
std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_));
std::memset (data_image_bind_, 0, sizeof (data_image_bind_));
diff --git a/odb/mysql/forward.hxx b/odb/mysql/forward.hxx
index a9809a4..75aeff0 100644
--- a/odb/mysql/forward.hxx
+++ b/odb/mysql/forward.hxx
@@ -20,6 +20,7 @@ namespace odb
// Implementation details.
//
+ class binding;
class select_statement;
template <typename T>
diff --git a/odb/mysql/result.txx b/odb/mysql/result.txx
index db444eb..f6d0a79 100644
--- a/odb/mysql/result.txx
+++ b/odb/mysql/result.txx
@@ -39,13 +39,23 @@ namespace odb
assert (!statements_.locked ());
typename object_statements<object_type>::auto_lock l (statements_);
- typename object_traits::image_type& im (statements_.image ());
- object_traits::init (obj, im, this->database ());
+ typename object_traits::image_type& i (statements_.image ());
+ object_traits::init (obj, i, this->database ());
- // Initialize the id image and load the rest of the object
+ // Initialize the id image and binding and load the rest of the object
// (containers, etc).
//
- object_traits::init (statements_.id_image (), object_traits::id (im));
+ typename object_traits::id_image_type& idi (statements_.id_image ());
+ object_traits::init (idi, object_traits::id (i));
+
+ binding& idb (statements_.id_image_binding ());
+ if (idi.version != statements_.id_image_version () || idb.version == 0)
+ {
+ object_traits::bind (idb.bind, idi);
+ statements_.id_image_version (idi.version);
+ idb.version++;
+ }
+
object_traits::load_ (statements_, obj);
statements_.load_delayed ();