| polymorphic-object-statements.hxx | | polymorphic-object-statements.hxx | |
| | | | |
| skipping to change at line 381 | | skipping to change at line 381 | |
| false)); | | false)); | |
| | | | |
| return *erase_; | | return *erase_; | |
| } | | } | |
| | | | |
| // Container statement cache. | | // Container statement cache. | |
| // | | // | |
| container_statement_cache_type& | | container_statement_cache_type& | |
| container_statment_cache () | | container_statment_cache () | |
| { | | { | |
|
| return container_statement_cache_; | | return container_statement_cache_.get (conn_); | |
| } | | } | |
| | | | |
| public: | | public: | |
| // select = total - id + base::select | | // select = total - id + base::select | |
| // insert = total - inverse | | // insert = total - inverse | |
| // update = total - inverse - id - readonly | | // update = total - inverse - id - readonly | |
| // | | // | |
| static const std::size_t id_column_count = | | static const std::size_t id_column_count = | |
| object_traits::id_column_count; | | object_traits::id_column_count; | |
| | | | |
| | | | |
| skipping to change at line 413 | | skipping to change at line 413 | |
| polymorphic_derived_object_statements ( | | polymorphic_derived_object_statements ( | |
| const polymorphic_derived_object_statements&); | | const polymorphic_derived_object_statements&); | |
| | | | |
| polymorphic_derived_object_statements& | | polymorphic_derived_object_statements& | |
| operator= (const polymorphic_derived_object_statements&); | | operator= (const polymorphic_derived_object_statements&); | |
| | | | |
| private: | | private: | |
| root_statements_type& root_statements_; | | root_statements_type& root_statements_; | |
| base_statements_type& base_statements_; | | base_statements_type& base_statements_; | |
| | | | |
|
| container_statement_cache_type container_statement_cache_; | | container_statement_cache_ptr<container_statement_cache_type> | |
| | | container_statement_cache_; | |
| | | | |
| image_type image_; | | image_type image_; | |
| | | | |
| // Select binding. Here we are have an array of statements/bindings | | // Select binding. Here we are have an array of statements/bindings | |
| // one for each depth. In other words, if we have classes root, base, | | // one for each depth. In other words, if we have classes root, base, | |
| // and derived, then we have the following array of statements: | | // and derived, then we have the following array of statements: | |
| // | | // | |
| // [0] d + b + r | | // [0] d + b + r | |
| // [1] d + b | | // [1] d + b | |
| // [2] d | | // [2] d | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 3 lines changed or added | |
|
| polymorphic-object-statements.txx | | polymorphic-object-statements.txx | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| ~polymorphic_derived_object_statements () | | ~polymorphic_derived_object_statements () | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| polymorphic_derived_object_statements<T>:: | | polymorphic_derived_object_statements<T>:: | |
| polymorphic_derived_object_statements (connection_type& conn) | | polymorphic_derived_object_statements (connection_type& conn) | |
| : statements_base (conn), | | : statements_base (conn), | |
| root_statements_ (conn.statement_cache ().find_object<root_type>
()), | | root_statements_ (conn.statement_cache ().find_object<root_type>
()), | |
| base_statements_ (conn.statement_cache ().find_object<base_type>
()), | | base_statements_ (conn.statement_cache ().find_object<base_type>
()), | |
|
| container_statement_cache_ (conn), | | | |
| insert_image_binding_ (insert_image_bind_, insert_column_count), | | insert_image_binding_ (insert_image_bind_, insert_column_count), | |
| insert_image_native_binding_ (insert_image_values_, | | insert_image_native_binding_ (insert_image_values_, | |
| insert_image_lengths_, | | insert_image_lengths_, | |
| insert_image_formats_, | | insert_image_formats_, | |
| insert_column_count), | | insert_column_count), | |
| update_image_binding_ (update_image_bind_, | | update_image_binding_ (update_image_bind_, | |
| update_column_count + id_column_count), | | update_column_count + id_column_count), | |
| update_image_native_binding_ (update_image_values_, | | update_image_native_binding_ (update_image_values_, | |
| update_image_lengths_, | | update_image_lengths_, | |
| update_image_formats_, | | update_image_formats_, | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 0 lines changed or added | |
|
| simple-object-statements.hxx | | simple-object-statements.hxx | |
| | | | |
| skipping to change at line 32 | | skipping to change at line 32 | |
| #include <odb/pgsql/binding.hxx> | | #include <odb/pgsql/binding.hxx> | |
| #include <odb/pgsql/statement.hxx> | | #include <odb/pgsql/statement.hxx> | |
| #include <odb/pgsql/statements-base.hxx> | | #include <odb/pgsql/statements-base.hxx> | |
| | | | |
| #include <odb/pgsql/details/export.hxx> | | #include <odb/pgsql/details/export.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace pgsql | | namespace pgsql | |
| { | | { | |
|
| | | // The container_statement_cache class is only defined (and used) in | |
| | | // the generated source file. However, object_statements may be | |
| | | // referenced from another source file in the case of a polymorphic | |
| | | // hierarchy (though in this case the container statement cache is | |
| | | // not used). As a result, we cannot have a by-value member and | |
| | | // instead will store a pointer and lazily allocate the cache if | |
| | | // and when needed. We will also need to store a pointer to the | |
| | | // deleter function which will be initialized during allocation | |
| | | // (at that point we know that the cache class is defined). | |
| | | // | |
| | | template <typename T> | |
| | | struct container_statement_cache_ptr | |
| | | { | |
| | | typedef pgsql::connection connection_type; | |
| | | | |
| | | container_statement_cache_ptr (): p_ (0) {} | |
| | | ~container_statement_cache_ptr () {if (p_ != 0) (this->*deleter_) (0) | |
| | | ;} | |
| | | | |
| | | T& | |
| | | get (connection_type& c) | |
| | | { | |
| | | if (p_ == 0) | |
| | | allocate (&c); | |
| | | | |
| | | return *p_; | |
| | | } | |
| | | | |
| | | private: | |
| | | void | |
| | | allocate (connection_type*); | |
| | | | |
| | | private: | |
| | | T* p_; | |
| | | void (container_statement_cache_ptr::*deleter_) (connection_type*); | |
| | | }; | |
| | | | |
| | | template <typename T> | |
| | | void container_statement_cache_ptr<T>:: | |
| | | allocate (connection_type* c) | |
| | | { | |
| | | // To reduce object code size, this function acts as both allocator | |
| | | // and deleter. | |
| | | // | |
| | | if (p_ == 0) | |
| | | { | |
| | | p_ = new T (*c); | |
| | | deleter_ = &container_statement_cache_ptr<T>::allocate; | |
| | | } | |
| | | else | |
| | | delete p_; | |
| | | } | |
| | | | |
| // | | // | |
| // Implementation for objects with object id. | | // Implementation for objects with object id. | |
| // | | // | |
| | | | |
| class LIBODB_PGSQL_EXPORT object_statements_base: public statements_bas
e | | class LIBODB_PGSQL_EXPORT object_statements_base: public statements_bas
e | |
| { | | { | |
| public: | | public: | |
| // Locking. | | // Locking. | |
| // | | // | |
| void | | void | |
| | | | |
| skipping to change at line 383 | | skipping to change at line 435 | |
| false)); | | false)); | |
| | | | |
| return *od_.erase_; | | return *od_.erase_; | |
| } | | } | |
| | | | |
| // Container statement cache. | | // Container statement cache. | |
| // | | // | |
| container_statement_cache_type& | | container_statement_cache_type& | |
| container_statment_cache () | | container_statment_cache () | |
| { | | { | |
|
| return container_statement_cache_; | | return container_statement_cache_.get (conn_); | |
| } | | } | |
| | | | |
| public: | | public: | |
| // select = total | | // select = total | |
| // insert = total - inverse - managed_optimistic | | // insert = total - inverse - managed_optimistic | |
| // update = total - inverse - managed_optimistic - id - readonly | | // update = total - inverse - managed_optimistic - id - readonly | |
| // | | // | |
| static const std::size_t select_column_count = | | static const std::size_t select_column_count = | |
| object_traits::column_count; | | object_traits::column_count; | |
| | | | |
| | | | |
| skipping to change at line 419 | | skipping to change at line 471 | |
| object_statements& operator= (const object_statements&); | | object_statements& operator= (const object_statements&); | |
| | | | |
| private: | | private: | |
| void | | void | |
| load_delayed_ (); | | load_delayed_ (); | |
| | | | |
| void | | void | |
| clear_delayed_ (); | | clear_delayed_ (); | |
| | | | |
| protected: | | protected: | |
|
| container_statement_cache_type container_statement_cache_; | | container_statement_cache_ptr<container_statement_cache_type> | |
| | | container_statement_cache_; | |
| | | | |
| image_type image_; | | image_type image_; | |
| | | | |
| // Select binding. | | // Select binding. | |
| // | | // | |
| std::size_t select_image_version_; | | std::size_t select_image_version_; | |
| binding select_image_binding_; | | binding select_image_binding_; | |
| bind select_image_bind_[select_column_count]; | | bind select_image_bind_[select_column_count]; | |
| bool select_image_truncated_[select_column_count]; | | bool select_image_truncated_[select_column_count]; | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 56 lines changed or added | |
|
| simple-object-statements.txx | | simple-object-statements.txx | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 49 | |
| template <typename T> | | template <typename T> | |
| object_statements<T>:: | | object_statements<T>:: | |
| ~object_statements () | | ~object_statements () | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| object_statements<T>:: | | object_statements<T>:: | |
| object_statements (connection_type& conn) | | object_statements (connection_type& conn) | |
| : object_statements_base (conn), | | : object_statements_base (conn), | |
|
| container_statement_cache_ (conn), | | | |
| // select | | // select | |
| select_image_binding_ (select_image_bind_, select_column_count), | | select_image_binding_ (select_image_bind_, select_column_count), | |
| // insert | | // insert | |
| insert_image_binding_ (insert_image_bind_, insert_column_count), | | insert_image_binding_ (insert_image_bind_, insert_column_count), | |
| insert_image_native_binding_ (insert_image_values_, | | insert_image_native_binding_ (insert_image_values_, | |
| insert_image_lengths_, | | insert_image_lengths_, | |
| insert_image_formats_, | | insert_image_formats_, | |
| insert_column_count), | | insert_column_count), | |
| // update | | // update | |
| update_image_binding_ (update_image_bind_, | | update_image_binding_ (update_image_bind_, | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 0 lines changed or added | |
|