Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Oct 31, 2024
1 parent 5592c74 commit 75bccad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ opsqlite_execute_raw(std::string const &dbName, std::string const &query,
i++;
}

results->emplace_back(row);
results->emplace_back(row);

break;
}
Expand Down Expand Up @@ -860,16 +860,17 @@ std::string operation_to_string(int operation_type) {
}
}

void update_callback(void *dbName, int operation_type, char const *database,
char const *table, sqlite3_int64 rowid) {
void update_callback(void *dbName, int operation_type,
[[maybe_unused]] char const *database, char const *table,
sqlite3_int64 row_id) {
std::string &strDbName = *(static_cast<std::string *>(dbName));
auto callback = updateCallbackMap[strDbName];
callback(strDbName, std::string(table), operation_to_string(operation_type),
static_cast<int>(rowid));
static_cast<int>(row_id));
}

BridgeResult opsqlite_register_update_hook(std::string const &dbName,
UpdateCallback const callback) {
UpdateCallback const &callback) {
check_db_open(dbName);

sqlite3 *db = dbMap[dbName];
Expand Down Expand Up @@ -908,7 +909,7 @@ int commit_callback(void *dbName) {
}

BridgeResult opsqlite_register_commit_hook(std::string const &dbName,
CommitCallback const callback) {
CommitCallback const &callback) {
check_db_open(dbName);

sqlite3 *db = dbMap[dbName];
Expand Down Expand Up @@ -944,7 +945,7 @@ void rollback_callback(void *dbName) {
}

BridgeResult opsqlite_register_rollback_hook(std::string const &dbName,
RollbackCallback const callback) {
RollbackCallback const &callback) {
check_db_open(dbName);

sqlite3 *db = dbMap[dbName];
Expand Down Expand Up @@ -1019,7 +1020,7 @@ BatchResult opsqlite_execute_batch(std::string &name,
int affectedRows = 0;
opsqlite_execute(name, "BEGIN EXCLUSIVE TRANSACTION", nullptr);
for (int i = 0; i < commandCount; i++) {
auto command = commands->at(i);
const auto &command = commands->at(i);
// We do not provide a datastructure to receive query data because we
// don't need/want to handle this results in a batch execution
auto result = opsqlite_execute(name, command.sql, command.params.get());
Expand Down
6 changes: 3 additions & 3 deletions cpp/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ BridgeResult opsqlite_execute_raw(std::string const &dbName,
void opsqlite_close_all();

BridgeResult opsqlite_register_update_hook(std::string const &dbName,
UpdateCallback callback);
const UpdateCallback& callback);
BridgeResult opsqlite_deregister_update_hook(std::string const &dbName);
BridgeResult opsqlite_register_commit_hook(std::string const &dbName,
CommitCallback callback);
const CommitCallback& callback);
BridgeResult opsqlite_deregister_commit_hook(std::string const &dbName);
BridgeResult opsqlite_register_rollback_hook(std::string const &dbName,
RollbackCallback callback);
const RollbackCallback& callback);
BridgeResult opsqlite_deregister_rollback_hook(std::string const &dbName);

sqlite3_stmt *opsqlite_prepare_statement(std::string const &dbName,
Expand Down

0 comments on commit 75bccad

Please sign in to comment.