Core/DBUpdater: Apply each sql update file in a separate transaction

This commit is contained in:
Shauren
2022-01-30 15:50:35 +01:00
parent 9a0a56dc88
commit b79a91039b

View File

@@ -364,7 +364,7 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
Path const& path)
{
std::vector<std::string> args;
args.reserve(7);
args.reserve(9);
// CLI Client connection info
args.emplace_back("-h" + host);
@@ -414,13 +414,17 @@ void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& hos
#endif
// Execute sql file
args.emplace_back("-e");
args.emplace_back(Trinity::StringFormat("BEGIN; SOURCE %s; COMMIT;", path.generic_string().c_str()));
// Database
if (!database.empty())
args.emplace_back(database);
// Invokes a mysql process which doesn't leak credentials to logs
int const ret = Trinity::StartProcess(DBUpdaterUtil::GetCorrectedMySQLExecutable(), args,
"sql.updates", path.generic_string(), true);
"sql.updates", "", true);
if (ret != EXIT_SUCCESS)
{