| object-statements.txx | | object-statements.txx | |
| // file : odb/mysql/object-statements.txx | | // file : odb/mysql/object-statements.txx | |
| // author : Boris Kolpackov <boris@codesynthesis.com> | | // author : Boris Kolpackov <boris@codesynthesis.com> | |
| // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC | | // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
| #include <cstddef> // std::size_t | | #include <cstddef> // std::size_t | |
| #include <cstring> // std::memset | | #include <cstring> // std::memset | |
| | | | |
| #include <odb/session.hxx> | | #include <odb/session.hxx> | |
|
| | | #include <odb/callback.hxx> | |
| #include <odb/exceptions.hxx> | | #include <odb/exceptions.hxx> | |
| | | | |
| #include <odb/mysql/connection.hxx> | | #include <odb/mysql/connection.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace mysql | | namespace mysql | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| object_statements<T>:: | | object_statements<T>:: | |
| | | | |
| skipping to change at line 46 | | skipping to change at line 47 | |
| std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); | | std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); | |
| | | | |
| for (std::size_t i (0); i < object_traits::out_column_count; ++i) | | for (std::size_t i (0); i < object_traits::out_column_count; ++i) | |
| out_image_bind_[i].error = out_image_truncated_ + i; | | out_image_bind_[i].error = out_image_truncated_ + i; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void object_statements<T>:: | | void object_statements<T>:: | |
| load_delayed_ () | | load_delayed_ () | |
| { | | { | |
|
| // We should be careful here: the delayed vector can change | | | |
| // from under us as a result of a recursive load. | | | |
| // | | | |
| database& db (connection ().database ()); | | database& db (connection ().database ()); | |
| | | | |
|
| while (!delayed_.empty ()) | | delayed_loads dls; | |
| | | swap_guard sg (*this, dls); | |
| | | | |
| | | while (!dls.empty ()) | |
| { | | { | |
|
| delayed_load l (delayed_.back ()); | | delayed_load l (dls.back ()); | |
| typename object_cache_traits::insert_guard g (l.pos); | | typename object_cache_traits::insert_guard g (l.pos); | |
|
| delayed_.pop_back (); | | dls.pop_back (); | |
| | | | |
| if (!object_traits::find_ (*this, l.id)) | | if (!object_traits::find_ (*this, l.id)) | |
| throw object_not_persistent (); | | throw object_not_persistent (); | |
| | | | |
|
| | | object_traits::callback (db, *l.obj, callback_event::pre_load); | |
| | | | |
| | | // Our calls to init/load below can result in additional delayed | |
| | | // loads being added to the delayed_ vector. We need to process | |
| | | // those before we call the post callback. | |
| | | // | |
| object_traits::init (*l.obj, image (), db); | | object_traits::init (*l.obj, image (), db); | |
| object_traits::load_ (*this, *l.obj); // Load containers, etc. | | object_traits::load_ (*this, *l.obj); // Load containers, etc. | |
|
| | | | |
| | | if (!delayed_.empty ()) | |
| | | load_delayed_ (); | |
| | | | |
| | | object_traits::callback (db, *l.obj, callback_event::post_load); | |
| | | | |
| g.release (); | | g.release (); | |
| } | | } | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void object_statements<T>:: | | void object_statements<T>:: | |
| clear_delayed_ () | | clear_delayed_ () | |
| { | | { | |
| // Remove the objects from the session cache. | | // Remove the objects from the session cache. | |
| // | | // | |
| | | | |
End of changes. 7 change blocks. |
| 6 lines changed or deleted | | 19 lines changed or added | |
|
| query.hxx | | query.hxx | |
| | | | |
| skipping to change at line 1376 | | skipping to change at line 1376 | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
| bool dummy; | | bool dummy; | |
|
| std::size_t size, cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
| value_traits<T, id_decimal>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_decimal>::set_image (buffer_, size, dummy, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 1586 | | skipping to change at line 1586 | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
| bool dummy; | | bool dummy; | |
|
| std::size_t size, cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
| value_traits<T, id_string>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_string>::set_image (buffer_, size, dummy, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 1625 | | skipping to change at line 1625 | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
| bool dummy; | | bool dummy; | |
|
| std::size_t size, cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
| value_traits<T, id_blob>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_blob>::set_image (buffer_, size, dummy, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| | | | |
| | | | |
| skipping to change at line 1665 | | skipping to change at line 1665 | |
| b->buffer = buffer_; | | b->buffer = buffer_; | |
| b->buffer_length = static_cast<unsigned long> (sizeof (buffer_)); | | b->buffer_length = static_cast<unsigned long> (sizeof (buffer_)); | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| void | | void | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
| bool dummy; | | bool dummy; | |
|
| std::size_t size; | | std::size_t size (0); | |
| value_traits<T, id_bit>::set_image ( | | value_traits<T, id_bit>::set_image ( | |
| buffer_, sizeof (buffer_), size, dummy, v); | | buffer_, sizeof (buffer_), size, dummy, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| } | | } | |
| | | | |
| private: | | private: | |
| // Max 64 bit. | | // Max 64 bit. | |
| // | | // | |
| unsigned char buffer_[8]; | | unsigned char buffer_[8]; | |
| unsigned long size_; | | unsigned long size_; | |
| | | | |
| skipping to change at line 1741 | | skipping to change at line 1741 | |
| b->buffer = buffer_.data (); | | b->buffer = buffer_.data (); | |
| b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | | b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
; | |
| b->length = &size_; | | b->length = &size_; | |
| } | | } | |
| | | | |
| private: | | private: | |
| bool | | bool | |
| init (const T& v) | | init (const T& v) | |
| { | | { | |
| bool dummy; | | bool dummy; | |
|
| std::size_t size, cap (buffer_.capacity ()); | | std::size_t size (0), cap (buffer_.capacity ()); | |
| value_traits<T, id_set>::set_image (buffer_, size, dummy, v); | | value_traits<T, id_set>::set_image (buffer_, size, dummy, v); | |
| size_ = static_cast<unsigned long> (size); | | size_ = static_cast<unsigned long> (size); | |
| return cap != buffer_.capacity (); | | return cap != buffer_.capacity (); | |
| } | | } | |
| | | | |
| private: | | private: | |
| details::buffer buffer_; | | details::buffer buffer_; | |
| unsigned long size_; | | unsigned long size_; | |
| }; | | }; | |
| } | | } | |
| | | | |
End of changes. 5 change blocks. |
| 5 lines changed or deleted | | 5 lines changed or added | |
|
| result.txx | | result.txx | |
| // file : odb/mysql/result.txx | | // file : odb/mysql/result.txx | |
| // author : Boris Kolpackov <boris@codesynthesis.com> | | // author : Boris Kolpackov <boris@codesynthesis.com> | |
| // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC | | // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
|
| | | #include <odb/callback.hxx> | |
| #include <odb/exceptions.hxx> | | #include <odb/exceptions.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace mysql | | namespace mysql | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| result_impl<T>:: | | result_impl<T>:: | |
| ~result_impl () | | ~result_impl () | |
| { | | { | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 43 | |
| load (object_type& obj) | | load (object_type& obj) | |
| { | | { | |
| if (count_ > statement_->fetched ()) | | if (count_ > statement_->fetched ()) | |
| fetch (); | | fetch (); | |
| | | | |
| // This is a top-level call so the statements cannot be locked. | | // This is a top-level call so the statements cannot be locked. | |
| // | | // | |
| assert (!statements_.locked ()); | | assert (!statements_.locked ()); | |
| typename object_statements<object_type>::auto_lock l (statements_); | | typename object_statements<object_type>::auto_lock l (statements_); | |
| | | | |
|
| | | odb::database& db (this->database ()); | |
| | | object_traits::callback (db, obj, callback_event::pre_load); | |
| | | | |
| typename object_traits::image_type& i (statements_.image ()); | | typename object_traits::image_type& i (statements_.image ()); | |
|
| object_traits::init (obj, i, this->database ()); | | object_traits::init (obj, i, db); | |
| | | | |
| // Initialize the id image and binding and load the rest of the objec
t | | // Initialize the id image and binding and load the rest of the objec
t | |
| // (containers, etc). | | // (containers, etc). | |
| // | | // | |
| typename object_traits::id_image_type& idi (statements_.id_image ()); | | typename object_traits::id_image_type& idi (statements_.id_image ()); | |
| object_traits::init (idi, object_traits::id (i)); | | object_traits::init (idi, object_traits::id (i)); | |
| | | | |
| binding& idb (statements_.id_image_binding ()); | | binding& idb (statements_.id_image_binding ()); | |
| if (idi.version != statements_.id_image_version () || idb.version ==
0) | | if (idi.version != statements_.id_image_version () || idb.version ==
0) | |
| { | | { | |
| object_traits::bind (idb.bind, idi); | | object_traits::bind (idb.bind, idi); | |
| statements_.id_image_version (idi.version); | | statements_.id_image_version (idi.version); | |
| idb.version++; | | idb.version++; | |
| } | | } | |
| | | | |
| object_traits::load_ (statements_, obj); | | object_traits::load_ (statements_, obj); | |
|
| | | | |
| statements_.load_delayed (); | | statements_.load_delayed (); | |
|
| | | object_traits::callback (db, obj, callback_event::post_load); | |
| | | | |
| l.unlock (); | | l.unlock (); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| typename result_impl<T>::id_type result_impl<T>:: | | typename result_impl<T>::id_type result_impl<T>:: | |
| load_id () | | load_id () | |
| { | | { | |
| if (count_ > statement_->fetched ()) | | if (count_ > statement_->fetched ()) | |
| fetch (); | | fetch (); | |
| | | | |
| | | | |
End of changes. 5 change blocks. |
| 2 lines changed or deleted | | 7 lines changed or added | |
|
| version.hxx | | version.hxx | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 40 | |
| // Version AABBCCDD | | // Version AABBCCDD | |
| // 2.0.0 02000000 | | // 2.0.0 02000000 | |
| // 2.1.0 02010000 | | // 2.1.0 02010000 | |
| // 2.1.1 02010100 | | // 2.1.1 02010100 | |
| // 2.2.0.a1 02019901 | | // 2.2.0.a1 02019901 | |
| // 3.0.0.b2 02999952 | | // 3.0.0.b2 02999952 | |
| // | | // | |
| | | | |
| // Check that we have compatible ODB version. | | // Check that we have compatible ODB version. | |
| // | | // | |
|
| #if ODB_VERSION != 10400 | | #if ODB_VERSION != 10500 | |
| # error incompatible odb interface version detected | | # error incompatible odb interface version detected | |
| #endif | | #endif | |
| | | | |
| // Check that we have a compatible MySQL version (5.0.3 or later). | | // Check that we have a compatible MySQL version (5.0.3 or later). | |
| // | | // | |
| #if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID < 50003 | | #if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID < 50003 | |
| # error incompatible MySQL version detected | | # error incompatible MySQL version detected | |
| #endif | | #endif | |
| | | | |
| // libodb-mysql version: odb interface version plus the bugfix | | // libodb-mysql version: odb interface version plus the bugfix | |
| // version. | | // version. | |
| // | | // | |
|
| #define LIBODB_MYSQL_VERSION 1040000 | | #define LIBODB_MYSQL_VERSION 1050000 | |
| #define LIBODB_MYSQL_VERSION_STR "1.4.0" | | #define LIBODB_MYSQL_VERSION_STR "1.5.0" | |
| | | | |
| #include <odb/post.hxx> | | #include <odb/post.hxx> | |
| | | | |
| #endif // ODB_MYSQL_VERSION_HXX | | #endif // ODB_MYSQL_VERSION_HXX | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 3 lines changed or added | |
|