1 Star 0 Fork 0

廖永煌/lyh

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
br_0301.diff 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
廖永煌 提交于 2025-03-01 10:32 +08:00 . 12
diff --git a/frameworks/libs/distributeddb/interfaces/include/relational/relational_store_client.h b/frameworks/libs/distributeddb/interfaces/include/relational/relational_store_client.h
index ee2c3a0db..936130637 100644
--- a/frameworks/libs/distributeddb/interfaces/include/relational/relational_store_client.h
+++ b/frameworks/libs/distributeddb/interfaces/include/relational/relational_store_client.h
@@ -51,4 +51,8 @@ DB_API DistributedDB::DBStatus Lock(const std::string &tableName, const std::vec
DB_API DistributedDB::DBStatus UnLock(const std::string &tableName, const std::vector<std::vector<uint8_t>> &hashKey,
sqlite3 *db);
+
+DB_API void RegisterDbHook(sqlite3 *db);
+
+DB_API void UnregisterDbHook(sqlite3 *db);
#endif // RELATIONAL_STORE_CLIENT_H
diff --git a/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp b/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp
index d530d90e3..9897134bc 100644
--- a/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp
+++ b/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp
@@ -401,6 +401,8 @@ std::map<std::string, std::vector<ChangedData>> g_storeChangedDataMap;
std::mutex g_clientCreateTableMutex;
std::set<std::string> g_clientCreateTable;
+std::mutex g_registerSqliteHookMutex;
+
int RegisterFunction(sqlite3 *db, const std::string &funcName, int nArg, void *uData, TransactFunc &func)
{
if (db == nullptr) {
@@ -1774,6 +1776,19 @@ DB_API DistributedDB::DBStatus UnLock(const std::string &tableName, const std::v
return HandleDataLock(tableName, hashKey, db, false);
}
+DB_API void RegisterDbHook(sqlite3 *db)
+{
+ std::lock_guard<std::mutex> lock(g_registerSqliteHookMutex);
+ sqlite3_wal_hook(db, LogCommitHookCallback, db);
+ sqlite3_rollback_hook(db, RollbackHookCallback, db);
+}
+
+DB_API void UnregisterDbHook(sqlite3 *db)
+{
+ std::lock_guard<std::mutex> lock(g_registerSqliteHookMutex);
+ sqlite3_wal_hook(db, nullptr, db);
+ sqlite3_rollback_hook(db, nullptr, db);
+}
// hw export the symbols
#ifdef SQLITE_DISTRIBUTE_RELATIONAL
#if defined(__GNUC__)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liao-yonghuang/lyh.git
git@gitee.com:liao-yonghuang/lyh.git
liao-yonghuang
lyh
lyh
master

搜索帮助