connection-factory.hxx | connection-factory.hxx | |||
---|---|---|---|---|
skipping to change at line 83 | skipping to change at line 83 | |||
// of the existing connections are in use. | // of the existing connections are in use. | |||
// | // | |||
// The min_connections argument specifies the minimum number of | // The min_connections argument specifies the minimum number of | |||
// connections that should be maintained by the pool. If the | // connections that should be maintained by the pool. If the | |||
// number of connections maintained by the pool exceeds this | // number of connections maintained by the pool exceeds this | |||
// number and there are no active waiters for a new connection, | // number and there are no active waiters for a new connection, | |||
// then the pool will release the excess connections. If this | // then the pool will release the excess connections. If this | |||
// value is 0 then the pool will maintain all the connections | // value is 0 then the pool will maintain all the connections | |||
// that were ever created. | // that were ever created. | |||
// | // | |||
// The ping argument specifies whether to ping the connection to | ||||
// make sure it is still alive before returning it to the caller. | ||||
// | ||||
connection_pool_factory (std::size_t max_connections = 0, | connection_pool_factory (std::size_t max_connections = 0, | |||
std::size_t min_connections = 0) | std::size_t min_connections = 0, | |||
bool ping = true) | ||||
: max_ (max_connections), | : max_ (max_connections), | |||
min_ (min_connections), | min_ (min_connections), | |||
ping_ (ping), | ||||
in_use_ (0), | in_use_ (0), | |||
waiters_ (0), | waiters_ (0), | |||
db_ (0), | db_ (0), | |||
cond_ (mutex_) | cond_ (mutex_) | |||
{ | { | |||
// @@ check min_ <= max_ | // @@ check min_ <= max_ | |||
} | } | |||
virtual details::shared_ptr<connection> | virtual details::shared_ptr<connection> | |||
connect (); | connect (); | |||
skipping to change at line 117 | skipping to change at line 122 | |||
private: | private: | |||
class pooled_connection: public connection | class pooled_connection: public connection | |||
{ | { | |||
public: | public: | |||
// NULL pool value indicates that the connection is not in use. | // NULL pool value indicates that the connection is not in use. | |||
// | // | |||
pooled_connection (database_type&, connection_pool_factory*); | pooled_connection (database_type&, connection_pool_factory*); | |||
private: | private: | |||
static void | static bool | |||
zero_counter (void*); | zero_counter (void*); | |||
private: | private: | |||
friend class connection_pool_factory; | friend class connection_pool_factory; | |||
shared_base::refcount_callback callback_; | shared_base::refcount_callback callback_; | |||
connection_pool_factory* pool_; | connection_pool_factory* pool_; | |||
}; | }; | |||
friend class pooled_connection; | friend class pooled_connection; | |||
typedef std::vector<details::shared_ptr<pooled_connection> > connecti ons; | typedef std::vector<details::shared_ptr<pooled_connection> > connecti ons; | |||
private: | private: | |||
void | // Return true if the connection should be deleted, false otherwise. | |||
// | ||||
bool | ||||
release (pooled_connection*); | release (pooled_connection*); | |||
private: | private: | |||
const std::size_t max_; | const std::size_t max_; | |||
const std::size_t min_; | const std::size_t min_; | |||
const bool ping_; | ||||
std::size_t in_use_; // Number of connections currently in use. | std::size_t in_use_; // Number of connections currently in use. | |||
std::size_t waiters_; // Number of threads waiting for a connection. | std::size_t waiters_; // Number of threads waiting for a connection. | |||
database_type* db_; | database_type* db_; | |||
connections connections_; | connections connections_; | |||
details::mutex mutex_; | details::mutex mutex_; | |||
details::condition cond_; | details::condition cond_; | |||
}; | }; | |||
End of changes. 6 change blocks. | ||||
3 lines changed or deleted | 11 lines changed or added | |||
connection.hxx | connection.hxx | |||
---|---|---|---|---|
skipping to change at line 49 | skipping to change at line 49 | |||
connection (database_type&); | connection (database_type&); | |||
database_type& | database_type& | |||
database () | database () | |||
{ | { | |||
return db_; | return db_; | |||
} | } | |||
public: | public: | |||
bool | ||||
failed () const | ||||
{ | ||||
return failed_; | ||||
} | ||||
void | ||||
mark_failed () | ||||
{ | ||||
failed_ = true; | ||||
} | ||||
// Ping the server to make sure the connection is still alive. Return | ||||
// true if successful, mark the connection as failed and return false | ||||
// otherwise. This function can also throw database_exception. | ||||
// | ||||
bool | ||||
ping (); | ||||
public: | ||||
MYSQL* | MYSQL* | |||
handle () | handle () | |||
{ | { | |||
return handle_; | return handle_; | |||
} | } | |||
statement_cache_type& | statement_cache_type& | |||
statement_cache () | statement_cache () | |||
{ | { | |||
return *statement_cache_; | return *statement_cache_; | |||
skipping to change at line 77 | skipping to change at line 97 | |||
void | void | |||
active (statement* s) | active (statement* s) | |||
{ | { | |||
active_ = s; | active_ = s; | |||
if (s == 0 && stmt_handles_.size () > 0) | if (s == 0 && stmt_handles_.size () > 0) | |||
free_stmt_handles (); | free_stmt_handles (); | |||
} | } | |||
// Cancel and clear the active statement, if any. | ||||
// | ||||
void | ||||
clear () | ||||
{ | ||||
if (active_ != 0) | ||||
clear_ (); | ||||
} | ||||
public: | public: | |||
MYSQL_STMT* | MYSQL_STMT* | |||
alloc_stmt_handle (); | alloc_stmt_handle (); | |||
void | void | |||
free_stmt_handle (MYSQL_STMT*); | free_stmt_handle (MYSQL_STMT*); | |||
private: | private: | |||
connection (const connection&); | connection (const connection&); | |||
connection& operator= (const connection&); | connection& operator= (const connection&); | |||
private: | private: | |||
void | void | |||
free_stmt_handles (); | free_stmt_handles (); | |||
void | ||||
clear_ (); | ||||
private: | private: | |||
database_type& db_; | database_type& db_; | |||
bool failed_; | ||||
MYSQL mysql_; | MYSQL mysql_; | |||
MYSQL* handle_; | MYSQL* handle_; | |||
statement* active_; | statement* active_; | |||
std::auto_ptr<statement_cache_type> statement_cache_; | std::auto_ptr<statement_cache_type> statement_cache_; | |||
typedef std::vector<MYSQL_STMT*> stmt_handles; | typedef std::vector<MYSQL_STMT*> stmt_handles; | |||
stmt_handles stmt_handles_; | stmt_handles stmt_handles_; | |||
}; | }; | |||
End of changes. 4 change blocks. | ||||
0 lines changed or deleted | 33 lines changed or added | |||
exceptions.hxx | exceptions.hxx | |||
---|---|---|---|---|
skipping to change at line 15 | skipping to change at line 15 | |||
#ifndef ODB_MYSQL_EXCEPTIONS_HXX | #ifndef ODB_MYSQL_EXCEPTIONS_HXX | |||
#define ODB_MYSQL_EXCEPTIONS_HXX | #define ODB_MYSQL_EXCEPTIONS_HXX | |||
#include <odb/pre.hxx> | #include <odb/pre.hxx> | |||
#include <string> | #include <string> | |||
#include <odb/exceptions.hxx> | #include <odb/exceptions.hxx> | |||
#include <odb/mysql/mysql.hxx> | ||||
#include <odb/mysql/version.hxx> | #include <odb/mysql/version.hxx> | |||
#include <odb/mysql/details/export.hxx> | #include <odb/mysql/details/export.hxx> | |||
namespace odb | namespace odb | |||
{ | { | |||
namespace mysql | namespace mysql | |||
{ | { | |||
struct LIBODB_MYSQL_EXPORT database_exception: odb::database_exception | struct LIBODB_MYSQL_EXPORT database_exception: odb::database_exception | |||
{ | { | |||
database_exception (MYSQL*); | ||||
database_exception (MYSQL_STMT*); | ||||
database_exception (unsigned int, | database_exception (unsigned int, | |||
const std::string& sqlstate, | const std::string& sqlstate, | |||
const std::string& message); | const std::string& message); | |||
~database_exception () throw (); | ~database_exception () throw (); | |||
unsigned int | unsigned int | |||
error () const | error () const | |||
{ | { | |||
return error_; | return error_; | |||
skipping to change at line 56 | skipping to change at line 53 | |||
const std::string& | const std::string& | |||
message () const | message () const | |||
{ | { | |||
return message_; | return message_; | |||
} | } | |||
virtual const char* | virtual const char* | |||
what () const throw (); | what () const throw (); | |||
private: | private: | |||
void | ||||
init (); | ||||
private: | ||||
unsigned int error_; | unsigned int error_; | |||
std::string sqlstate_; | std::string sqlstate_; | |||
std::string message_; | std::string message_; | |||
std::string what_; | std::string what_; | |||
}; | }; | |||
struct LIBODB_MYSQL_EXPORT cli_exception: odb::exception | struct LIBODB_MYSQL_EXPORT cli_exception: odb::exception | |||
{ | { | |||
cli_exception (const std::string& what); | cli_exception (const std::string& what); | |||
~cli_exception () throw (); | ~cli_exception () throw (); | |||
End of changes. 3 change blocks. | ||||
7 lines changed or deleted | 0 lines changed or added | |||
result.txx | result.txx | |||
---|---|---|---|---|
skipping to change at line 103 | skipping to change at line 103 | |||
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++; | |||
} | } | |||
} | } | |||
while (count_ > statement_->fetched ()) | while (!this->end_ && count_ > statement_->fetched ()) | |||
{ | { | |||
select_statement::result r (statement_->fetch ()); | select_statement::result r (statement_->fetch ()); | |||
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 ()) | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
statement.hxx | statement.hxx | |||
---|---|---|---|---|
skipping to change at line 138 | skipping to change at line 138 | |||
~insert_statement (); | ~insert_statement (); | |||
insert_statement (connection& conn, | insert_statement (connection& conn, | |||
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> ( | return static_cast<unsigned long long> ( | |||
mysql_stmt_insert_id (stmt_)); | mysql_stmt_insert_id (stmt_)); | |||
} | } | |||
private: | private: | |||
insert_statement (const insert_statement&); | insert_statement (const insert_statement&); | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 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 != 10100 | #if ODB_VERSION != 10200 | |||
# 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 1010000 | #define LIBODB_MYSQL_VERSION 1020000 | |||
#define LIBODB_MYSQL_VERSION_STR "1.1.0" | #define LIBODB_MYSQL_VERSION_STR "1.2.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 | |||