From b5d025938e78ade2033ed2ce23f6ece3a3c27d4d Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 25 Jul 2014 19:04:38 -0500 Subject: Core/Waypoints: Allow the table waypoint_data to use Takeoff and Land waypoints. --- src/server/shared/Database/Implementation/WorldDatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server/shared/Database') diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index d0e9c463ad7..b06df155a07 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -51,7 +51,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = ? WHERE id = ? and point = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_MAX_ID, "SELECT MAX(id) FROM waypoint_data", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_MAX_POINT, "SELECT MAX(point) FROM waypoint_data WHERE id = ?", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_BY_ID, "SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z FROM waypoint_data WHERE point = 1 AND id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ? ORDER BY point DESC LIMIT 1", CONNECTION_SYNCH); -- cgit v1.2.3 From a03c8795659ff1f259fcb1ba324bf2b796108e8e Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 25 Jul 2014 20:18:43 -0500 Subject: Core/PreparedStatements: Fixed a change I missed in the World prepared statements for waypoints. --- src/server/scripts/Commands/cs_wp.cpp | 2 +- src/server/shared/Database/Implementation/WorldDatabase.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server/shared/Database') diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 18157ba5083..647d8b49c1b 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -543,7 +543,7 @@ public: // Check // Remember: "show" must also be the name of a column! if ((show != "delay") && (show != "action") && (show != "action_chance") - && (show != "move_flag") && (show != "del") && (show != "move") + && (show != "move_type") && (show != "del") && (show != "move") ) { return false; diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index b06df155a07..aa2ca4b7e2e 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -56,7 +56,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z FROM waypoint_data WHERE point = 1 AND id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ? ORDER BY point DESC LIMIT 1", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID, "SELECT id, point FROM waypoint_data WHERE wpguid = ?", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID, "SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = ?", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID, "SELECT id, point, delay, move_type, action, action_chance FROM waypoint_data WHERE wpguid = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_UPD_WAYPOINT_DATA_ALL_WPGUID, "UPDATE waypoint_data SET wpguid = 0", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_POS, "SELECT id, point FROM waypoint_data WHERE (abs(position_x - ?) <= ?) and (abs(position_y - ?) <= ?) and (abs(position_z - ?) <= ?)", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID, "SELECT wpguid FROM waypoint_data WHERE id = ? and wpguid <> 0", CONNECTION_SYNCH); -- cgit v1.2.3 From 6961f957c9d03bff634f0b75466458564845722e Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 26 Jul 2014 16:10:05 +0200 Subject: Core/DBLayer: Fixed possible crashes with async queries retrieving result Closes #12655 --- src/server/game/World/World.cpp | 3 +-- src/server/shared/Database/DatabaseWorkerPool.h | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/server/shared/Database') diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 807e1684c47..533fbe6b2a4 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2732,8 +2732,7 @@ void World::UpdateRealmCharCount(uint32 accountId) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_COUNT); stmt->setUInt32(0, accountId); - PreparedQueryResultFuture result = CharacterDatabase.AsyncQuery(stmt); - m_realmCharCallbacks.push_back(std::move(result)); + m_realmCharCallbacks.push_back(CharacterDatabase.AsyncQuery(stmt)); } void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount) diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index a1ee6407fea..a43d4c9c683 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -297,8 +297,9 @@ class DatabaseWorkerPool QueryResultFuture AsyncQuery(const char* sql) { BasicStatementTask* task = new BasicStatementTask(sql, true); + QueryResultFuture result = task->GetFuture(); Enqueue(task); - return task->GetFuture(); //! Actual return value has no use yet + return result; //! Actual return value has no use yet } //! Enqueues a query in string format -with variable args- that will set the value of the QueryResultFuture return object as soon as the query is executed. @@ -320,8 +321,9 @@ class DatabaseWorkerPool PreparedQueryResultFuture AsyncQuery(PreparedStatement* stmt) { PreparedStatementTask* task = new PreparedStatementTask(stmt, true); + PreparedQueryResultFuture result = task->GetFuture(); Enqueue(task); - return task->GetFuture(); + return result; } //! Enqueues a vector of SQL operations (can be both adhoc and prepared) that will set the value of the QueryResultHolderFuture @@ -331,8 +333,9 @@ class DatabaseWorkerPool QueryResultHolderFuture DelayQueryHolder(SQLQueryHolder* holder) { SQLQueryHolderTask* task = new SQLQueryHolderTask(holder); + QueryResultHolderFuture result = task->GetFuture(); Enqueue(task); - return task->GetFuture(); + return result; } /** -- cgit v1.2.3 From e1c400250c0ff701d9ed1244e9c49483fc6799c8 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 26 Jul 2014 16:14:18 +0200 Subject: Added comments to 6961f957c9d03bff634f0b75466458564845722e to make sure noone decides that storing the result in a variable is unneccessary --- src/server/shared/Database/DatabaseWorkerPool.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/server/shared/Database') diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h index a43d4c9c683..18797b6b12a 100644 --- a/src/server/shared/Database/DatabaseWorkerPool.h +++ b/src/server/shared/Database/DatabaseWorkerPool.h @@ -297,9 +297,10 @@ class DatabaseWorkerPool QueryResultFuture AsyncQuery(const char* sql) { BasicStatementTask* task = new BasicStatementTask(sql, true); + // Store future result before enqueueing - task might get already processed and deleted before returning from this method QueryResultFuture result = task->GetFuture(); Enqueue(task); - return result; //! Actual return value has no use yet + return result; } //! Enqueues a query in string format -with variable args- that will set the value of the QueryResultFuture return object as soon as the query is executed. @@ -321,6 +322,7 @@ class DatabaseWorkerPool PreparedQueryResultFuture AsyncQuery(PreparedStatement* stmt) { PreparedStatementTask* task = new PreparedStatementTask(stmt, true); + // Store future result before enqueueing - task might get already processed and deleted before returning from this method PreparedQueryResultFuture result = task->GetFuture(); Enqueue(task); return result; @@ -333,6 +335,7 @@ class DatabaseWorkerPool QueryResultHolderFuture DelayQueryHolder(SQLQueryHolder* holder) { SQLQueryHolderTask* task = new SQLQueryHolderTask(holder); + // Store future result before enqueueing - task might get already processed and deleted before returning from this method QueryResultHolderFuture result = task->GetFuture(); Enqueue(task); return result; -- cgit v1.2.3