Skip to content

Commit

Permalink
skipQueryLog param
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragsalian committed May 31, 2024
1 parent 49b891b commit 82a8cb6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libstuff/libstuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,7 @@ void SQueryLogClose() {

// --------------------------------------------------------------------------
// Executes a SQLite query
int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold, bool skipWarn) {
int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold, bool skipWarn, bool skipQueryLog) {
#define MAX_TRIES 3
// Execute the query and get the results
uint64_t startTime = STimeNow();
Expand Down Expand Up @@ -2666,7 +2666,7 @@ int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int6
}

uint64_t elapsed = STimeNow() - startTime;
if ((int64_t)elapsed > warnThreshold || (int64_t)elapsed > 10000) {
if (!skipQueryLog && ((int64_t)elapsed > warnThreshold || (int64_t)elapsed > 10000)) {
// Avoid logging queries so long that we need dozens of lines to log them.
string sqlToLog = sql.substr(0, 20000);
SRedactSensitiveValues(sqlToLog);
Expand Down
2 changes: 1 addition & 1 deletion libstuff/libstuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ void SQueryLogOpen(const string& logFilename);
void SQueryLogClose();

// Returns an SQLite result code.
int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false);
int SQuery(sqlite3* db, const char* e, const string& sql, SQResult& result, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false, bool skipQueryLog = false);
int SQuery(sqlite3* db, const char* e, const string& sql, int64_t warnThreshold = 2000 * STIME_US_PER_MS, bool skipWarn = false);
bool SQVerifyTable(sqlite3* db, const string& tableName, const string& sql);
bool SQVerifyTableExists(sqlite3* db, const string& tableName);
Expand Down
4 changes: 2 additions & 2 deletions sqlitecluster/SQLite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ string SQLite::read(const string& query) const {
return result[0][0];
}

bool SQLite::read(const string& query, SQResult& result) const {
bool SQLite::read(const string& query, SQResult& result, bool skipQueryLog) const {
uint64_t before = STimeNow();
bool queryResult = false;
_queryCount++;
Expand All @@ -486,7 +486,7 @@ bool SQLite::read(const string& query, SQResult& result) const {
queryResult = true;
} else {
_isDeterministicQuery = true;
queryResult = !SQuery(_db, "read only query", query, result);
queryResult = !SQuery(_db, "read only query", query, result, 2000 * STIME_US_PER_MS, false, skipQueryLog);
if (_isDeterministicQuery && queryResult) {
_queryCache.emplace(make_pair(query, result));
}
Expand Down
2 changes: 1 addition & 1 deletion sqlitecluster/SQLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SQLite {

// Performs a read-only query (eg, SELECT). This can be done inside or outside a transaction. Returns true on
// success, and fills the 'result' with the result of the query.
bool read(const string& query, SQResult& result) const;
bool read(const string& query, SQResult& result, bool skipQueryLog = false) const;

// Performs a read-only query (eg, SELECT) that returns a single value.
string read(const string& query) const;
Expand Down

0 comments on commit 82a8cb6

Please sign in to comment.