Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update expensify_prod branch #1564

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BedrockCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BedrockCommand::BedrockCommand(SQLiteCommand&& baseCommand, BedrockPlugin* plugi
socket(nullptr),
scheduledTime(request.isSet("commandExecuteTime") ? request.calc64("commandExecuteTime") : STimeNow()),
_plugin(plugin),
_commitEmptyTransactions(false),
_inProgressTiming(INVALID, 0, 0),
_timeout(_getTimeout(request, scheduledTime))
{
Expand Down Expand Up @@ -298,3 +299,7 @@ void BedrockCommand::setTimeout(uint64_t timeoutDurationMS) {
timeoutDurationMS += STimeNow();
_timeout = timeoutDurationMS;
}

bool BedrockCommand::shouldCommitEmptyTransactions() const {
return _commitEmptyTransactions;
}
7 changes: 7 additions & 0 deletions BedrockCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,17 @@ class BedrockCommand : public SQLiteCommand {
// Time at which this command was initially scheduled (typically the time of creation).
const uint64_t scheduledTime;

// Returns _commitEmptyTransactions.
bool shouldCommitEmptyTransactions() const;

protected:
// The plugin that owns this command.
BedrockPlugin* _plugin;

// Commands can set this flag to indicate they want the commit process to be run even though it doesn't appear that any writes have occurred.
// The main use of this is to cause commands that use SQLite::onPrepareHandler to do additional writing to run these final writes.
bool _commitEmptyTransactions;

private:
// Set certain initial state on construction. Common functionality to several constructors.
void _init();
Expand Down
2 changes: 1 addition & 1 deletion BedrockCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ BedrockCore::RESULT BedrockCore::processCommand(unique_ptr<BedrockCommand>& comm
}

// If we have no uncommitted query, just rollback the empty transaction. Otherwise, we need to commit.
if (_db.getUncommittedQuery().empty()) {
if (_db.getUncommittedQuery().empty() && !command->shouldCommitEmptyTransactions()) {
_db.rollback();
} else {
needsCommit = true;
Expand Down