| container-statements.hxx | | container-statements.hxx | |
| // file : odb/mysql/container-statements.hxx | | // file : odb/mysql/container-statements.hxx | |
| // 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 | |
| | | | |
| #ifndef ODB_MYSQL_CONTAINER_STATEMENTS_HXX | | #ifndef ODB_MYSQL_CONTAINER_STATEMENTS_HXX | |
| #define ODB_MYSQL_CONTAINER_STATEMENTS_HXX | | #define ODB_MYSQL_CONTAINER_STATEMENTS_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
|
| | | #include <cstddef> // std::size_t | |
| | | | |
| #include <odb/forward.hxx> | | #include <odb/forward.hxx> | |
| #include <odb/traits.hxx> | | #include <odb/traits.hxx> | |
| | | | |
| #include <odb/mysql/mysql.hxx> | | #include <odb/mysql/mysql.hxx> | |
| #include <odb/mysql/version.hxx> | | #include <odb/mysql/version.hxx> | |
| #include <odb/mysql/statement.hxx> | | #include <odb/mysql/statement.hxx> | |
| | | | |
| #include <odb/mysql/details/export.hxx> | | #include <odb/mysql/details/export.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| | | | |
| skipping to change at line 153 | | skipping to change at line 155 | |
| data_id_image_version_ = v; | | data_id_image_version_ = v; | |
| } | | } | |
| | | | |
| binding& | | binding& | |
| data_image_binding () | | data_image_binding () | |
| { | | { | |
| return data_image_binding_; | | return data_image_binding_; | |
| } | | } | |
| | | | |
| my_bool* | | my_bool* | |
|
| data_image_error () | | data_image_truncated () | |
| { | | { | |
|
| return data_image_error_; | | return data_image_truncated_; | |
| } | | } | |
| | | | |
| // | | // | |
| // Statements. | | // Statements. | |
| // | | // | |
| | | | |
| insert_statement_type& | | insert_statement_type& | |
| insert_one_statement () | | insert_one_statement () | |
| { | | { | |
| if (insert_one_ == 0) | | if (insert_one_ == 0) | |
| | | | |
| skipping to change at line 219 | | skipping to change at line 221 | |
| std::size_t cond_image_version_; | | std::size_t cond_image_version_; | |
| std::size_t cond_id_image_version_; | | std::size_t cond_id_image_version_; | |
| binding cond_image_binding_; | | binding cond_image_binding_; | |
| MYSQL_BIND cond_image_bind_[traits::cond_column_count]; | | MYSQL_BIND cond_image_bind_[traits::cond_column_count]; | |
| | | | |
| data_image_type data_image_; | | data_image_type data_image_; | |
| std::size_t data_image_version_; | | std::size_t data_image_version_; | |
| std::size_t data_id_image_version_; | | std::size_t data_id_image_version_; | |
| binding data_image_binding_; | | binding data_image_binding_; | |
| MYSQL_BIND data_image_bind_[traits::data_column_count]; | | MYSQL_BIND data_image_bind_[traits::data_column_count]; | |
|
| my_bool data_image_error_[traits::data_column_count]; | | my_bool data_image_truncated_[traits::data_column_count]; | |
| | | | |
| details::shared_ptr<insert_statement_type> insert_one_; | | details::shared_ptr<insert_statement_type> insert_one_; | |
| details::shared_ptr<select_statement_type> select_all_; | | details::shared_ptr<select_statement_type> select_all_; | |
| details::shared_ptr<delete_statement_type> delete_all_; | | details::shared_ptr<delete_statement_type> delete_all_; | |
| }; | | }; | |
| } | | } | |
| } | | } | |
| | | | |
| #include <odb/mysql/container-statements.txx> | | #include <odb/mysql/container-statements.txx> | |
| | | | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 5 lines changed or added | |
|
| container-statements.txx | | container-statements.txx | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| cond_image_.version = 0; | | cond_image_.version = 0; | |
| cond_image_version_ = 0; | | cond_image_version_ = 0; | |
| cond_id_image_version_ = 0; | | cond_id_image_version_ = 0; | |
| | | | |
| data_image_.version = 0; | | data_image_.version = 0; | |
| data_image_version_ = 0; | | data_image_version_ = 0; | |
| data_id_image_version_ = 0; | | data_id_image_version_ = 0; | |
| | | | |
| std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); | | std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); | |
| std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); | | std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); | |
|
| std::memset (data_image_error_, 0, sizeof (data_image_error_)); | | std::memset (data_image_truncated_, 0, sizeof (data_image_truncated_)
); | |
| | | | |
| for (std::size_t i (0); i < traits::data_column_count; ++i) | | for (std::size_t i (0); i < traits::data_column_count; ++i) | |
|
| data_image_bind_[i].error = data_image_error_ + i; | | data_image_bind_[i].error = data_image_truncated_ + i; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| object-statements.hxx | | object-statements.hxx | |
| | | | |
| skipping to change at line 13 | | skipping to change at line 13 | |
| // 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 | |
| | | | |
| #ifndef ODB_MYSQL_OBJECT_STATEMENTS_HXX | | #ifndef ODB_MYSQL_OBJECT_STATEMENTS_HXX | |
| #define ODB_MYSQL_OBJECT_STATEMENTS_HXX | | #define ODB_MYSQL_OBJECT_STATEMENTS_HXX | |
| | | | |
| #include <odb/pre.hxx> | | #include <odb/pre.hxx> | |
| | | | |
| #include <vector> | | #include <vector> | |
| #include <cassert> | | #include <cassert> | |
|
| | | #include <cstddef> // std::size_t | |
| | | | |
| #include <odb/forward.hxx> | | #include <odb/forward.hxx> | |
| #include <odb/traits.hxx> | | #include <odb/traits.hxx> | |
| #include <odb/cache-traits.hxx> | | #include <odb/cache-traits.hxx> | |
| | | | |
| #include <odb/mysql/mysql.hxx> | | #include <odb/mysql/mysql.hxx> | |
| #include <odb/mysql/version.hxx> | | #include <odb/mysql/version.hxx> | |
| #include <odb/mysql/statement.hxx> | | #include <odb/mysql/statement.hxx> | |
| | | | |
| #include <odb/details/shared-ptr.hxx> | | #include <odb/details/shared-ptr.hxx> | |
| | | | |
| skipping to change at line 213 | | skipping to change at line 214 | |
| return in_image_binding_; | | return in_image_binding_; | |
| } | | } | |
| | | | |
| binding& | | binding& | |
| out_image_binding () | | out_image_binding () | |
| { | | { | |
| return out_image_binding_; | | return out_image_binding_; | |
| } | | } | |
| | | | |
| my_bool* | | my_bool* | |
|
| out_image_error () | | out_image_truncated () | |
| { | | { | |
|
| return out_image_error_; | | return out_image_truncated_; | |
| } | | } | |
| | | | |
| // Object id image. | | // Object id image. | |
| // | | // | |
| id_image_type& | | id_image_type& | |
| id_image () | | id_image () | |
| { | | { | |
| return id_image_; | | return id_image_; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 332 | | skipping to change at line 333 | |
| // | | // | |
| std::size_t in_image_version_; | | std::size_t in_image_version_; | |
| binding in_image_binding_; | | binding in_image_binding_; | |
| MYSQL_BIND in_image_bind_[object_traits::in_column_count + 1]; | | MYSQL_BIND in_image_bind_[object_traits::in_column_count + 1]; | |
| | | | |
| // Out (receive) binding. | | // Out (receive) binding. | |
| // | | // | |
| std::size_t out_image_version_; | | std::size_t out_image_version_; | |
| binding out_image_binding_; | | binding out_image_binding_; | |
| MYSQL_BIND out_image_bind_[object_traits::out_column_count]; | | MYSQL_BIND out_image_bind_[object_traits::out_column_count]; | |
|
| my_bool out_image_error_[object_traits::out_column_count]; | | my_bool out_image_truncated_[object_traits::out_column_count]; | |
| | | | |
| // Id image binding (only in). | | // Id image binding (only in). | |
| // | | // | |
| id_image_type id_image_; | | id_image_type id_image_; | |
| std::size_t id_image_version_; | | std::size_t id_image_version_; | |
| binding id_image_binding_; | | binding id_image_binding_; | |
| | | | |
| details::shared_ptr<persist_statement_type> persist_; | | details::shared_ptr<persist_statement_type> persist_; | |
| details::shared_ptr<find_statement_type> find_; | | details::shared_ptr<find_statement_type> find_; | |
| details::shared_ptr<update_statement_type> update_; | | details::shared_ptr<update_statement_type> update_; | |
| | | | |
End of changes. 4 change blocks. |
| 3 lines changed or deleted | | 4 lines changed or added | |
|
| object-statements.txx | | object-statements.txx | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| { | | { | |
| image_.version = 0; | | image_.version = 0; | |
| in_image_version_ = 0; | | in_image_version_ = 0; | |
| out_image_version_ = 0; | | out_image_version_ = 0; | |
| | | | |
| id_image_.version = 0; | | id_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_bind_, 0, sizeof (in_image_bind_)); | |
| std::memset (out_image_bind_, 0, sizeof (out_image_bind_)); | | std::memset (out_image_bind_, 0, sizeof (out_image_bind_)); | |
|
| std::memset (out_image_error_, 0, sizeof (out_image_error_)); | | 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_error_ + 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 | | // We should be careful here: the delayed vector can change | |
| // from under us as a result of a recursive load. | | // from under us as a result of a recursive load. | |
| // | | // | |
| database& db (connection ().database ()); | | database& db (connection ().database ()); | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| result.hxx | | result.hxx | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| #include <odb/mysql/version.hxx> | | #include <odb/mysql/version.hxx> | |
| #include <odb/mysql/forward.hxx> | | #include <odb/mysql/forward.hxx> | |
| #include <odb/mysql/statement.hxx> | | #include <odb/mysql/statement.hxx> | |
| | | | |
| #include <odb/details/shared-ptr.hxx> | | #include <odb/details/shared-ptr.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace mysql | | namespace mysql | |
| { | | { | |
|
| | | class query; | |
| | | | |
| template <typename T> | | template <typename T> | |
| class result_impl: public odb::result_impl<T> | | class result_impl: public odb::result_impl<T> | |
| { | | { | |
| public: | | public: | |
| typedef typename odb::result_impl<T>::pointer_type pointer_type; | | typedef typename odb::result_impl<T>::pointer_type pointer_type; | |
| typedef typename odb::result_impl<T>::pointer_traits pointer_traits; | | typedef typename odb::result_impl<T>::pointer_traits pointer_traits; | |
| | | | |
| typedef typename odb::result_impl<T>::object_type object_type; | | typedef typename odb::result_impl<T>::object_type object_type; | |
| typedef typename odb::result_impl<T>::id_type id_type; | | typedef typename odb::result_impl<T>::id_type id_type; | |
| typedef typename odb::result_impl<T>::object_traits object_traits; | | typedef typename odb::result_impl<T>::object_traits object_traits; | |
| | | | |
| virtual | | virtual | |
| ~result_impl (); | | ~result_impl (); | |
| | | | |
|
| result_impl (details::shared_ptr<select_statement> statement, | | result_impl (const query&, | |
| | | details::shared_ptr<select_statement> statement, | |
| object_statements<object_type>& statements); | | object_statements<object_type>& statements); | |
| | | | |
| virtual void | | virtual void | |
| load (object_type&); | | load (object_type&); | |
| | | | |
| virtual id_type | | virtual id_type | |
| load_id (); | | load_id (); | |
| | | | |
| virtual void | | virtual void | |
| next (); | | next (); | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 4 lines changed or added | |
|
| result.txx | | result.txx | |
| | | | |
| skipping to change at line 20 | | skipping to change at line 20 | |
| namespace mysql | | namespace mysql | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| result_impl<T>:: | | result_impl<T>:: | |
| ~result_impl () | | ~result_impl () | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| result_impl<T>:: | | result_impl<T>:: | |
|
| result_impl (details::shared_ptr<select_statement> statement, | | result_impl (const query&, | |
| | | details::shared_ptr<select_statement> statement, | |
| object_statements<object_type>& statements) | | object_statements<object_type>& statements) | |
| : odb::result_impl<T> (statements.connection ().database ()), | | : odb::result_impl<T> (statements.connection ().database ()), | |
| statement_ (statement), | | statement_ (statement), | |
| statements_ (statements), | | statements_ (statements), | |
| count_ (0) | | count_ (0) | |
| { | | { | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void result_impl<T>:: | | void result_impl<T>:: | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 118 | |
| switch (r) | | switch (r) | |
| { | | { | |
| case select_statement::truncated: | | case select_statement::truncated: | |
| { | | { | |
| // Don't re-fetch data we are skipping. | | // Don't re-fetch data we are skipping. | |
| // | | // | |
| if (count_ != statement_->fetched ()) | | if (count_ != statement_->fetched ()) | |
| continue; | | continue; | |
| | | | |
| typename object_traits::image_type& im (statements_.image ()); | | typename object_traits::image_type& im (statements_.image ()); | |
|
| object_traits::grow (im, statements_.out_image_error ()); | | object_traits::grow (im, statements_.out_image_truncated ()); | |
| | | | |
| if (im.version != statements_.out_image_version ()) | | if (im.version != statements_.out_image_version ()) | |
| { | | { | |
| binding& b (statements_.out_image_binding ()); | | binding& b (statements_.out_image_binding ()); | |
| object_traits::bind (b.bind, im, true); | | object_traits::bind (b.bind, im, true); | |
| statements_.out_image_version (im.version); | | statements_.out_image_version (im.version); | |
| b.version++; | | b.version++; | |
| statement_->refetch (); | | statement_->refetch (); | |
| } | | } | |
| // Fall throught. | | // Fall throught. | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 3 lines changed or added | |
|
| statement.hxx | | statement.hxx | |
| | | | |
| skipping to change at line 141 | | skipping to change at line 141 | |
| const std::string& statement, | | const std::string& statement, | |
| binding& data); | | binding& data); | |
| | | | |
| // Return true if successful and false if the row is a duplicate. | | // Return true if successful and false if the row is a duplicate. | |
| // All other errors are reported by throwing exceptions. | | // All other errors are reported by throwing exceptions. | |
| // | | // | |
| bool | | bool | |
| execute (); | | execute (); | |
| | | | |
| unsigned long long | | unsigned long long | |
|
| id () | | id (); | |
| { | | | |
| return static_cast<unsigned long long> ( | | | |
| mysql_stmt_insert_id (stmt_)); | | | |
| } | | | |
| | | | |
| private: | | private: | |
| insert_statement (const insert_statement&); | | insert_statement (const insert_statement&); | |
| insert_statement& operator= (const insert_statement&); | | insert_statement& operator= (const insert_statement&); | |
| | | | |
| private: | | private: | |
| binding& data_; | | binding& data_; | |
| std::size_t data_version_; | | std::size_t data_version_; | |
| }; | | }; | |
| | | | |
| class LIBODB_MYSQL_EXPORT update_statement: public statement | | class LIBODB_MYSQL_EXPORT update_statement: public statement | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~update_statement (); | | ~update_statement (); | |
| | | | |
|
| | | // Asssumes that cond.bind is a suffix of data.bind. | |
| | | // | |
| update_statement (connection& conn, | | update_statement (connection& conn, | |
| const std::string& statement, | | const std::string& statement, | |
|
| binding& id, | | binding& cond, | |
| binding& image); | | binding& data); | |
| void | | void | |
| execute (); | | execute (); | |
| | | | |
| private: | | private: | |
| update_statement (const update_statement&); | | update_statement (const update_statement&); | |
| update_statement& operator= (const update_statement&); | | update_statement& operator= (const update_statement&); | |
| | | | |
| private: | | private: | |
|
| binding& id_; | | binding& cond_; | |
| std::size_t id_version_; | | std::size_t cond_version_; | |
| | | | |
|
| binding& image_; | | binding& data_; | |
| std::size_t image_version_; | | std::size_t data_version_; | |
| }; | | }; | |
| | | | |
| class LIBODB_MYSQL_EXPORT delete_statement: public statement | | class LIBODB_MYSQL_EXPORT delete_statement: public statement | |
| { | | { | |
| public: | | public: | |
| virtual | | virtual | |
| ~delete_statement (); | | ~delete_statement (); | |
| | | | |
| delete_statement (connection& conn, | | delete_statement (connection& conn, | |
| const std::string& statement, | | const std::string& statement, | |
| | | | |
End of changes. 5 change blocks. |
| 11 lines changed or deleted | | 9 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 != 10200 | | #if ODB_VERSION != 10300 | |
| # 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 1020000 | | #define LIBODB_MYSQL_VERSION 1030000 | |
| #define LIBODB_MYSQL_VERSION_STR "1.2.0" | | #define LIBODB_MYSQL_VERSION_STR "1.3.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 | |
|