代码拉取完成,页面将自动刷新
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__)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。