diff options
author | randomdan <randomdan@localhost> | 2012-11-21 01:34:51 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2012-11-21 01:34:51 +0000 |
commit | 4d9f046664aa6ae2fff675c9d5872c7082d2f0e5 (patch) | |
tree | ae5346f135a34038257715ac51cb7cb8f02604cb /libmysqlpp/connection.cpp | |
parent | Add a basic MySQL connector, not fully functional, but will suffice for p2tv (diff) | |
download | libdbpp-mysql-4d9f046664aa6ae2fff675c9d5872c7082d2f0e5.tar.bz2 libdbpp-mysql-4d9f046664aa6ae2fff675c9d5872c7082d2f0e5.tar.xz libdbpp-mysql-4d9f046664aa6ae2fff675c9d5872c7082d2f0e5.zip |
Fix error checking on mysql_ping causing db connection reuse failure; always reconnected
Diffstat (limited to 'libmysqlpp/connection.cpp')
-rw-r--r-- | libmysqlpp/connection.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libmysqlpp/connection.cpp b/libmysqlpp/connection.cpp index f2b747a..65e7303 100644 --- a/libmysqlpp/connection.cpp +++ b/libmysqlpp/connection.cpp @@ -60,7 +60,9 @@ int MySQL::Connection::beginTx() const { if (txDepth == 0) { - checkResult(mysql_autocommit(&conn, 0), true); + if (mysql_autocommit(&conn, 0)) { + throw Error(mysql_error(&conn)); + } rolledback = false; } return ++txDepth; @@ -73,7 +75,9 @@ MySQL::Connection::commitTx() const return rollbackTx(); } if (--txDepth == 0) { - checkResult(mysql_commit(&conn), true); + if (mysql_commit(&conn)) { + throw Error(mysql_error(&conn)); + } } return txDepth; } @@ -82,7 +86,9 @@ int MySQL::Connection::rollbackTx() const { if (--txDepth == 0) { - checkResult(mysql_rollback(&conn), true); + if (mysql_rollback(&conn)) { + throw Error(mysql_error(&conn)); + } } else { rolledback = true; @@ -111,7 +117,9 @@ MySQL::Connection::bulkUpdateStyle() const void MySQL::Connection::ping() const { - checkResult(mysql_ping(&conn), true); + if (mysql_ping(&conn)) { + throw Error(mysql_error(&conn)); + } } @@ -128,14 +136,6 @@ MySQL::Connection::newModifyCommand(const std::string & sql) const } void -MySQL::Connection::checkResult(my_bool actual, my_bool expected) const -{ - if (actual != expected) { - throw Error(mysql_error(&conn)); - } -} - -void MySQL::Connection::beginBulkUpload(const char * table, const char * extra) const { (void)table; |