Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldoglas committed Sep 30, 2024
1 parent 1a306b2 commit 786e21b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions sqlitecluster/SQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,18 @@ void SQLite::_sqliteLogCallback(void* pArg, int iErrCode, const char* zMsg) {
// This is sort of hacky to parse this from the logging info. If it works we could ask sqlite for a better interface to get this info.
if (SStartsWith(zMsg, "cannot commit")) {
// 17 is the length of "conflict at page" and the following space.
const char* offset = strstr(zMsg, "conflict at page") + 17;
_conflictPage = atol(offset);
const char* pageOffset = strstr(zMsg, "conflict at page") + 17;
_conflictPage = atol(pageOffset);

// 17 is the length of "part of db table" and the following space.
const char* tableOffset = strstr(zMsg, "part of db table") + 17;
const char* tableOffset = strstr(pageOffset, "part of db table") + 17;

// Check if the tableOffset exists since not all conflicts are on tables
if (tableOffset) {
// Based on the SQLite log line, we should always have ';' after the table name,
// so let's use it to finish this loop.
int i = 0;
while (tableOffset[i] != ';') {
_conflictTable += tableOffset[i];
i++;
}
// so let's find it and use it to limit the size of the substring we need
const char* semicolonOffset = strstr(tableOffset, ";");
_conflictTable = string(tableOffset, semicolonOffset - tableOffset);
}
}
}
Expand Down

0 comments on commit 786e21b

Please sign in to comment.