aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/oracle/forward.hxx7
-rw-r--r--odb/oracle/object-statements.hxx158
-rw-r--r--odb/oracle/object-statements.txx26
3 files changed, 96 insertions, 95 deletions
diff --git a/odb/oracle/forward.hxx b/odb/oracle/forward.hxx
index 98fc752..c4fb40b 100644
--- a/odb/oracle/forward.hxx
+++ b/odb/oracle/forward.hxx
@@ -23,6 +23,13 @@ namespace odb
// Implementation details.
//
+ enum statement_kind
+ {
+ statement_select,
+ statement_insert,
+ statement_update
+ };
+
class binding;
class select_statement;
diff --git a/odb/oracle/object-statements.hxx b/odb/oracle/object-statements.hxx
index 28370d5..cc10d54 100644
--- a/odb/oracle/object-statements.hxx
+++ b/odb/oracle/object-statements.hxx
@@ -102,10 +102,10 @@ namespace odb
typename object_traits::container_statement_cache_type
container_statement_cache_type;
- typedef oracle::insert_statement persist_statement_type;
- typedef oracle::select_statement find_statement_type;
+ typedef oracle::insert_statement insert_statement_type;
+ typedef oracle::select_statement select_statement_type;
typedef oracle::update_statement update_statement_type;
- typedef oracle::delete_statement erase_statement_type;
+ typedef oracle::delete_statement delete_statement_type;
// Automatic lock.
//
@@ -182,104 +182,79 @@ namespace odb
return image_;
}
+ // Insert binding.
+ //
std::size_t
- in_image_version () const
- {
- return in_image_version_;
- }
-
- std::size_t
- out_image_version () const
- {
- return out_image_version_;
- }
+ insert_image_version () const { return insert_image_version_;}
void
- in_image_version (std::size_t v)
- {
- in_image_version_ = v;
- }
+ insert_image_version (std::size_t v) {insert_image_version_ = v;}
+
+ binding&
+ insert_image_binding () {return insert_image_binding_;}
+
+ // Update binding.
+ //
+ std::size_t
+ update_image_version () const { return update_image_version_;}
void
- out_image_version (std::size_t v)
- {
- out_image_version_ = v;
- }
+ update_image_version (std::size_t v) {update_image_version_ = v;}
binding&
- in_image_binding ()
- {
- return in_image_binding_;
- }
+ update_image_binding () {return update_image_binding_;}
- sb2*
- in_image_indicator ()
- {
- return in_image_indicator_;
- }
+ // Select binding.
+ //
+ std::size_t
+ select_image_version () const { return select_image_version_;}
- binding&
- out_image_binding ()
- {
- return out_image_binding_;
- }
+ void
+ select_image_version (std::size_t v) {select_image_version_ = v;}
- sb2*
- out_image_indicator ()
- {
- return out_image_indicator_;
- }
+ binding&
+ select_image_binding () {return select_image_binding_;}
- // Object id image.
+ // Object id image and binding.
//
id_image_type&
- id_image ()
- {
- return id_image_;
- }
+ id_image () {return id_image_;}
std::size_t
- id_image_version () const
- {
- return id_image_version_;
- }
+ id_image_version () const {return id_image_version_;}
void
- id_image_version (std::size_t v)
- {
- id_image_version_ = v;
- }
+ id_image_version (std::size_t v) {id_image_version_ = v;}
binding&
- id_image_binding ()
- {
- return id_image_binding_;
- }
+ id_image_binding () {return id_image_binding_;}
- persist_statement_type&
+ // Statements.
+ //
+ insert_statement_type&
persist_statement ()
{
if (persist_ == 0)
persist_.reset (
- new (details::shared) persist_statement_type (
+ new (details::shared) insert_statement_type (
conn_,
object_traits::persist_statement,
- in_image_binding_,
+ insert_image_binding_,
object_traits::auto_id));
return *persist_;
}
- find_statement_type&
+ select_statement_type&
find_statement ()
{
if (find_ == 0)
find_.reset (
- new (details::shared) find_statement_type (
+ new (details::shared) select_statement_type (
conn_,
object_traits::find_statement,
id_image_binding_,
- out_image_binding_,
+ select_image_binding_,
4096)); // Hardcode a 4kB LOB prefetch size.
return *find_;
@@ -294,17 +269,17 @@ namespace odb
conn_,
object_traits::update_statement,
id_image_binding_,
- in_image_binding_));
+ update_image_binding_));
return *update_;
}
- erase_statement_type&
+ delete_statement_type&
erase_statement ()
{
if (erase_ == 0)
erase_.reset (
- new (details::shared) erase_statement_type (
+ new (details::shared) delete_statement_type (
conn_,
object_traits::erase_statement,
id_image_binding_));
@@ -332,34 +307,57 @@ namespace odb
clear_delayed_ ();
private:
+ // select = total
+ // insert = total - inverse
+ // update = total - inverse - id - readonly
+ //
+ static const std::size_t select_column_count =
+ object_traits::column_count;
+
+ static const std::size_t insert_column_count =
+ object_traits::column_count - object_traits::inverse_column_count;
+
+ static const std::size_t update_column_count = insert_column_count -
+ object_traits::id_column_count - object_traits::readonly_column_count;
+
+ static const std::size_t id_column_count =
+ object_traits::id_column_count;
+
+ private:
container_statement_cache_type container_statement_cache_;
image_type image_;
- // In (send) binding. The last element is the id parameter.
+ // Select binding.
+ //
+ std::size_t select_image_version_;
+ binding select_image_binding_;
+ bind select_image_bind_[select_column_count];
+
+ // Insert binding.
//
- std::size_t in_image_version_;
- binding in_image_binding_;
- bind in_image_bind_[object_traits::in_column_count + 1];
- sb2 in_image_indicator_[object_traits::in_column_count + 1];
+ std::size_t insert_image_version_;
+ binding insert_image_binding_;
+ bind insert_image_bind_[insert_column_count];
- // Out (receive) binding.
+ // Update binding. The suffix of the bind array is object id. We
+ // do it this way for consistency with other database runtimes.
//
- std::size_t out_image_version_;
- binding out_image_binding_;
- bind out_image_bind_[object_traits::out_column_count];
- sb2 out_image_indicator_[object_traits::out_column_count];
+ std::size_t update_image_version_;
+ binding update_image_binding_;
+ bind update_image_bind_[update_column_count + id_column_count];
- // Id image binding (in only)
+ // Id image binding (only used as a parameter). Uses the suffix in
+ // the update bind.
//
id_image_type id_image_;
std::size_t id_image_version_;
binding id_image_binding_;
- details::shared_ptr<persist_statement_type> persist_;
- details::shared_ptr<find_statement_type> find_;
+ details::shared_ptr<insert_statement_type> persist_;
+ details::shared_ptr<select_statement_type> find_;
details::shared_ptr<update_statement_type> update_;
- details::shared_ptr<erase_statement_type> erase_;
+ details::shared_ptr<delete_statement_type> erase_;
// Delayed loading.
//
diff --git a/odb/oracle/object-statements.txx b/odb/oracle/object-statements.txx
index d7c9f85..900775a 100644
--- a/odb/oracle/object-statements.txx
+++ b/odb/oracle/object-statements.txx
@@ -27,27 +27,23 @@ namespace odb
object_statements (connection_type& conn)
: object_statements_base (conn),
container_statement_cache_ (conn),
- 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)
+ select_image_binding_ (select_image_bind_, select_column_count),
+ insert_image_binding_ (insert_image_bind_, insert_column_count),
+ update_image_binding_ (update_image_bind_, update_column_count),
+ id_image_binding_ (update_image_bind_ + update_column_count,
+ id_column_count)
{
image_.version = 0;
- in_image_version_ = 0;
- out_image_version_ = 0;
+ select_image_version_ = 0;
+ insert_image_version_ = 0;
+ update_image_version_ = 0;
id_image_.version = 0;
id_image_version_ = 0;
- std::memset (in_image_bind_, 0, sizeof (in_image_bind_));
- std::memset (in_image_indicator_, 0, sizeof (in_image_indicator_));
- std::memset (out_image_bind_, 0, sizeof (out_image_bind_));
- std::memset (out_image_indicator_, 0, sizeof (out_image_indicator_));
-
- for (std::size_t i (0); i < object_traits::in_column_count + 1; ++i)
- in_image_bind_[i].indicator = in_image_indicator_ + i;
-
- for (std::size_t i (0); i < object_traits::out_column_count; ++i)
- out_image_bind_[i].indicator = out_image_indicator_ + i;
+ std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_));
+ std::memset (update_image_bind_, 0, sizeof (update_image_bind_));
+ std::memset (select_image_bind_, 0, sizeof (select_image_bind_));
}
template <typename T>