mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 04:58:14 +00:00
fix(MainDb): use transactions in unsafe functions
This commit is contained in:
parent
30389fd9ab
commit
b51fd2e414
1 changed files with 20 additions and 5 deletions
|
|
@ -2010,12 +2010,16 @@ static constexpr string &blobToString (string &in) {
|
|||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
soci::transaction tr(*session);
|
||||
|
||||
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
|
||||
|
||||
d->invalidConferenceEventsFromQuery(query, dbChatRoomId);
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
*session << "DELETE FROM event WHERE id IN (" + query + ")", soci::use(dbChatRoomId);
|
||||
|
||||
tr.commit();
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
}
|
||||
|
||||
|
|
@ -2044,6 +2048,7 @@ static constexpr string &blobToString (string &in) {
|
|||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
soci::transaction tr(*session);
|
||||
|
||||
soci::rowset<soci::row> rows = (session->prepare << query);
|
||||
for (const auto &row : rows) {
|
||||
|
|
@ -2152,6 +2157,8 @@ static constexpr string &blobToString (string &in) {
|
|||
chatRooms.push_back(chatRoom);
|
||||
}
|
||||
|
||||
tr.commit();
|
||||
|
||||
return chatRooms;
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
|
|
@ -2200,6 +2207,9 @@ static constexpr string &blobToString (string &in) {
|
|||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
soci::transaction tr(*session);
|
||||
|
||||
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
|
||||
|
||||
d->invalidConferenceEventsFromQuery(
|
||||
|
|
@ -2207,9 +2217,10 @@ static constexpr string &blobToString (string &in) {
|
|||
dbChatRoomId
|
||||
);
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
*session << "DELETE FROM chat_room WHERE id = :chatRoomId", soci::use(dbChatRoomId);
|
||||
|
||||
tr.commit();
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
}
|
||||
|
||||
|
|
@ -2229,13 +2240,13 @@ static constexpr string &blobToString (string &in) {
|
|||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
const long long &dbChatRoomId = d->selectChatRoomId(basicChatRoom->getChatRoomId());
|
||||
|
||||
// TODO: Update events and chat messages. (Or wait signals.)
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
soci::transaction tr(*session);
|
||||
|
||||
const long long &dbChatRoomId = d->selectChatRoomId(basicChatRoom->getChatRoomId());
|
||||
|
||||
const ChatRoomId &newChatRoomId = clientGroupChatRoom->getChatRoomId();
|
||||
const long long &peerSipAddressId = d->insertSipAddress(newChatRoomId.getPeerAddress().asString());
|
||||
const long long &localSipAddressId = d->insertSipAddress(newChatRoomId.getLocalAddress().asString());
|
||||
|
|
@ -2282,9 +2293,11 @@ static constexpr string &blobToString (string &in) {
|
|||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
soci::transaction tr(*session);
|
||||
|
||||
const long long &dbChatRoomId = d->selectChatRoomId(chatRoomId);
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
int capabilities = 0;
|
||||
*session << "SELECT capabilities FROM chat_room WHERE id = :chatRoomId",
|
||||
soci::use(dbChatRoomId), soci::into(capabilities);
|
||||
|
|
@ -2295,6 +2308,8 @@ static constexpr string &blobToString (string &in) {
|
|||
*session << "UPDATE chat_room SET capabilities = :capabilities WHERE id = :chatRoomId",
|
||||
soci::use(capabilities), soci::use(dbChatRoomId);
|
||||
|
||||
tr.commit();
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue