Skip to content

Commit

Permalink
Merge pull request #45 from smradCZ/gcc_6_3_compile_error
Browse files Browse the repository at this point in the history
GCC 6.3 warning - throwing an exception from noexcept method
  • Loading branch information
majcl committed Dec 13, 2017
2 parents 39dde65 + 8c2bf1a commit 2549735
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion include/superior_mysqlpp/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace SuperiorMySqlpp {
*/

/*
* You are to choose to derive either from class Interface or class Empty
* You are to choose to derive either from class Interface or class Base
* so you shall either implement all logging functions or only those you want.
*/

Expand Down Expand Up @@ -150,6 +150,7 @@ namespace SuperiorMySqlpp {
virtual void logMySqlStmtMetadataNullableToNonNullableWarning(std::uint_fast64_t /*connectionId*/, std::uint_fast64_t /*id*/, std::size_t /*index*/) const noexcept = 0;

virtual void logMySqlStmtClose(std::uint_fast64_t /*connectionId*/, std::uint_fast64_t /*id*/) const noexcept = 0;
virtual void logMySqlStmtCloseError(std::uint_fast64_t /*connectionId*/, std::uint_fast64_t /*id*/, const StringView& /*mysqlError*/) const noexcept = 0;
virtual void logMySqlTransactionRollbackFailed(std::uint_fast64_t /*connectionId*/, std::exception&) const noexcept = 0;
virtual void logMySqlTransactionRollbackFailed(std::uint_fast64_t /*connectionId*/) const noexcept = 0;
};
Expand Down Expand Up @@ -244,6 +245,7 @@ namespace SuperiorMySqlpp {
virtual void logMySqlStmtMetadataNullableToNonNullableWarning(std::uint_fast64_t /*connectionId*/, std::uint_fast64_t /*id*/, std::size_t /*index*/) const noexcept override {}

virtual void logMySqlStmtClose(std::uint_fast64_t /*connectionId*/, std::uint_fast64_t /*id*/) const noexcept override {}
virtual void logMySqlStmtCloseError(std::uint_fast64_t /*connectionId*/, std::uint_fast64_t /*id*/, const StringView& /*mysqlError*/) const noexcept override {}
virtual void logMySqlTransactionRollbackFailed(std::uint_fast64_t /*connectionId*/, std::exception&) const noexcept override {}
virtual void logMySqlTransactionRollbackFailed(std::uint_fast64_t /*connectionId*/) const noexcept override {}
};
Expand Down Expand Up @@ -397,6 +399,12 @@ namespace SuperiorMySqlpp {
std::cerr << stringify("Connection [", connectionId, "]: PS [", id, "]: Closing.\n") << std::flush;
}

virtual void logMySqlStmtCloseError(std::uint_fast64_t connectionId, std::uint_fast64_t id, const StringView& mysqlError) const noexcept override
{
SpinGuard guard{lock};
std::cerr << stringify("Connection [", connectionId, "]: PS [", id, "]: Closing statement failed with error:\n", mysqlError) << std::flush;
}

virtual void logMySqlTransactionRollbackFailed(std::uint_fast64_t connectionId, std::exception& e) const noexcept override
{
SpinGuard guard{lock};
Expand Down
5 changes: 3 additions & 2 deletions include/superior_mysqlpp/low_level/dbdriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,10 +631,11 @@ namespace SuperiorMySqlpp { namespace LowLevel
if (statementPtr != nullptr)
{
loggerPtr->logMySqlStmtClose(driverId, id);
MYSQL* mysql = statementPtr->mysql;
if (mysql_stmt_close(statementPtr))
{
throw MysqlInternalError("Failed to close statement!",
mysql_stmt_error(statementPtr), mysql_stmt_errno(statementPtr));
loggerPtr->logMySqlStmtCloseError(driverId, id, StringView{mysql_error(mysql)});
std::terminate();
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/_debian-common/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ libsuperiormysqlpp (0.3.1) UNRELEASED; urgency=medium

[ Radek Smejdir ]
* Fix ostream operator for null values in Row
* noexcept Statement::close will not throw MysqlInternalError anymore,
error message is logged and std::terminate is called instead

[ Peter Opatril ]
* Fix incorrect Clang detection in test makefile
Expand Down

0 comments on commit 2549735

Please sign in to comment.