Skip to content

Commit

Permalink
fixed a bug where prepared statements weren't closed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
FredyH committed Jan 28, 2017
1 parent 3b03bac commit 92aa5bc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MySQLOO/include/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum DatabaseStatus {
DATABASE_CONNECTION_FAILED = 3
};

class Database : LuaObjectBase {
class Database : public LuaObjectBase {
friend class IQuery;
public:
enum {
Expand Down
1 change: 0 additions & 1 deletion MySQLOO/source/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ int Database::createTransaction(lua_State* state) {
void Database::enqueueQuery(IQuery* query, std::shared_ptr<IQueryData> queryData) {
std::unique_lock<std::mutex> qlck(m_queryQueueMutex);
query->canbedestroyed = false;
//std::shared_ptr<IQuery> sharedPtr = query->getSharedPointerInstance();
queryQueue.push_back(std::make_pair(std::dynamic_pointer_cast<IQuery>(query->getSharedPointerInstance()), queryData));
queryData->setStatus(QUERY_WAITING);
this->m_queryWakupVariable.notify_one();
Expand Down
2 changes: 1 addition & 1 deletion MySQLOO/source/PreparedQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PreparedQuery::PreparedQuery(Database* dbase, lua_State* state) : Query(dbase, s
this->m_parameters.push_back(std::unordered_map<unsigned int, std::shared_ptr<PreparedQueryField>>());
//This pointer is used to prevent the database being accessed after it was deleted
//when this preparedq query still owns a MYSQL_STMT*
this->weak_database = std::dynamic_pointer_cast<Database>(((LuaObjectBase*)m_database)->getSharedPointerInstance());
this->weak_database = std::dynamic_pointer_cast<Database>(m_database->getSharedPointerInstance());
}

PreparedQuery::~PreparedQuery(void) {}
Expand Down

0 comments on commit 92aa5bc

Please sign in to comment.