Merge branch 'master' of gitee.com:openharmony/distributeddatamgr_relational_store into master

Signed-off-by: LeiiYB <leiyanbo@huawei.com>
This commit is contained in:
LeiiYB 2024-03-11 12:30:49 +00:00 committed by leiiyb
commit 27c62e7880
18 changed files with 110 additions and 55 deletions

View File

@ -111,9 +111,9 @@ public:
const std::vector<ValueObject> &bindArgs) override;
int ExecuteForChangedRowCount(int64_t &outValue, const std::string &sql,
const std::vector<ValueObject> &bindArgs) override;
int Backup(const std::string& databasePath, const std::vector<uint8_t>& destEncryptKey) override;
int Backup(const std::string databasePath, const std::vector<uint8_t> destEncryptKey) override;
int Attach(const std::string &alias, const std::string &pathName,
const std::vector<uint8_t> &destEncryptKey) override;
const std::vector<uint8_t> destEncryptKey) override;
int GetVersion(int &version) override;
int SetVersion(int version) override;
int BeginTransaction() override;
@ -126,7 +126,7 @@ public:
bool IsMemoryRdb() const override;
bool IsHoldingConnection() override;
int ConfigLocale(const std::string &localeStr);
int Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey) override;
int Restore(const std::string backupPath, const std::vector<uint8_t> &newKey) override;
void GetSchema(const RdbStoreConfig &config);
std::string GetName();
std::string GetOrgPath();
@ -209,7 +209,7 @@ private:
static constexpr char SCHEME_RDB[] = "rdb://";
static constexpr uint32_t EXPANSION = 2;
static constexpr uint32_t AUTO_SYNC_MAX_INTERVAL = 3000;
static inline constexpr uint32_t INTERVAL = 200;
static inline constexpr uint32_t INTERVAL = 10;
static constexpr const char *ROW_ID = "ROWID";
const RdbStoreConfig config_;

View File

@ -113,6 +113,7 @@ private:
bool isConfigured_ = false;
int maxVariableNumber_;
bool hasClientObserver_ = false;
};
} // namespace NativeRdb

View File

@ -44,7 +44,7 @@ public:
static const char *GetConflictClause(int conflictResolution);
static std::string StrToUpper(std::string s);
static void Replace(std::string &src, const std::string &rep, const std::string &dst);
static bool DeleteFile(const std::string &path);
static bool DeleteFile(const std::string &filePath);
static int RenameFile(const std::string &srcFile, const std::string &destFile);
static std::string Anonymous(const std::string &srcFile);
static int GetFileSize(const std::string &fileName);

View File

@ -64,9 +64,9 @@ public:
const std::vector<ValueObject> &bindArgs) override;
int ExecuteForChangedRowCount(int64_t &outValue, const std::string &sql,
const std::vector<ValueObject> &bindArgs) override;
int Backup(const std::string& databasePath, const std::vector<uint8_t>& destEncryptKey) override;
int Backup(const std::string databasePath, const std::vector<uint8_t> destEncryptKey) override;
int Attach(const std::string &alias, const std::string &pathName,
const std::vector<uint8_t> &destEncryptKey) override;
const std::vector<uint8_t> destEncryptKey) override;
int GetVersion(int &version) override;
int SetVersion(int version) override;
int BeginTransaction() override;
@ -79,7 +79,7 @@ public:
bool IsMemoryRdb() const override;
bool IsHoldingConnection() override;
int ConfigLocale(const std::string &localeStr);
int Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey) override;
int Restore(const std::string backupPath, const std::vector<uint8_t> &newKey) override;
std::string GetName();
std::string GetOrgPath();
std::string GetFileType();
@ -107,15 +107,15 @@ private:
int ExecuteGetLongInner(const std::string &sql, const std::vector<ValueObject> &bindArgs);
void SetAssetStatus(const ValueObject &val, int32_t status);
void DoCloudSync(const std::string &table);
int InnerBackup(const std::string databasePath,
const std::vector<uint8_t> destEncryptKey = std::vector<uint8_t>());
int InnerBackup(const std::string &databasePath,
const std::vector<uint8_t> &destEncryptKey = std::vector<uint8_t>());
inline std::string GetSqlArgs(size_t size);
int RegisterDataChangeCallback();
static constexpr char SCHEME_RDB[] = "rdb://";
static constexpr uint32_t EXPANSION = 2;
static constexpr uint32_t AUTO_SYNC_MAX_INTERVAL = 20000;
static inline constexpr uint32_t INTERVAL = 200;
static inline constexpr uint32_t INTERVAL = 10;
static constexpr const char *ROW_ID = "ROWID";
const RdbStoreConfig config_;

View File

@ -107,6 +107,7 @@ private:
bool isConfigured_ = false;
int maxVariableNumber_;
bool hasClientObserver_ = false;
};
} // namespace NativeRdb
} // namespace OHOS

View File

@ -173,7 +173,7 @@ RdbStoreDataServiceProxy::RdbStoreDataServiceProxy(const sptr<IRemoteObject> &im
sptr<IRemoteObject> RdbStoreDataServiceProxy::GetFeatureInterface(const std::string &name)
{
LOG_INFO("%s", name.c_str());
LOG_INFO("%{public}s", name.c_str());
MessageParcel data;
if (!data.WriteInterfaceToken(RdbStoreDataServiceProxy::GetDescriptor())) {
LOG_ERROR("write descriptor failed");

View File

@ -63,9 +63,8 @@ using namespace std::chrono;
int RdbStoreImpl::InnerOpen()
{
LOG_DEBUG("open %{public}s.", SqliteUtils::Anonymous(config_.GetPath()).c_str());
int errCode = E_OK;
pool_ = TaskExecutor::GetInstance().GetExecutor();
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) && !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM)
pool_ = TaskExecutor::GetInstance().GetExecutor();
syncerParam_.bundleName_ = config_.GetBundleName();
syncerParam_.hapName_ = config_.GetModuleName();
syncerParam_.storeName_ = config_.GetName();
@ -83,7 +82,7 @@ int RdbStoreImpl::InnerOpen()
GetSchema(config_);
}
errCode = RegisterDataChangeCallback();
int errCode = RegisterDataChangeCallback();
if (errCode != E_OK) {
LOG_ERROR("RegisterCallBackObserver is failed, err is %{public}d.", errCode);
}
@ -286,21 +285,19 @@ std::string RdbStoreImpl::GetSqlArgs(size_t size)
return args;
}
RdbStoreImpl::RdbStoreImpl(const RdbStoreConfig &config, int &errCode)
: config_(config), connectionPool_(nullptr), isOpen_(false), path_(config.GetPath()), orgPath_(config.GetPath()),
isReadOnly_(config.IsReadOnly()), isMemoryRdb_(config.IsMemoryRdb()), name_(config.GetName()),
fileType_(config.GetDatabaseFileType()), isEncrypt_(config.IsEncrypt())
: config_(config), connectionPool_(nullptr), isOpen_(false), isReadOnly_(config.IsReadOnly()),
isMemoryRdb_(config.IsMemoryRdb()), isEncrypt_(config.IsEncrypt()), path_(config.GetPath()),
orgPath_(config.GetPath()), name_(config.GetName()), fileType_(config.GetDatabaseFileType())
{
connectionPool_ = SqliteConnectionPool::Create(config_, errCode);
if (connectionPool_ == nullptr || errCode != E_OK) {
connectionPool_ = nullptr;
LOG_ERROR("InnerOpen failed, err is %{public}d, path:%{public}s", errCode, path.c_str());
LOG_ERROR("InnerOpen failed, err is %{public}d, path:%{public}s",
errCode, SqliteUtils::Anonymous(path_).c_str());
return;
}
InnerOpen();
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) && !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM)
RegisterDataChangeCallback();
#endif
}
RdbStoreImpl::~RdbStoreImpl()
@ -311,7 +308,6 @@ RdbStoreImpl::~RdbStoreImpl()
#ifdef WINDOWS_PLATFORM
void RdbStoreImpl::Clear()
{
delete connectionPool_;
connectionPool_ = nullptr;
}
#endif
@ -347,9 +343,11 @@ int RdbStoreImpl::BatchInsert(int64_t &outInsertNum, const std::string &table, c
return E_INVALID_ARGS;
}
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) && !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM)
if (delayNotifier_ != nullptr) {
delayNotifier_->SetAutoSyncInterval(AUTO_SYNC_MAX_INTERVAL);
}
#endif
for (const auto &[sql, bindArgs] : executeSqlArgs) {
for (const auto &args : bindArgs) {
@ -389,7 +387,7 @@ RdbStoreImpl::ExecuteSqls RdbStoreImpl::GenerateSql(const std::string& table, co
if (it == fields.end()) {
values.emplace_back(std::vector<ValueObject>(buckets.size()));
col = valuePosition;
fields.insert(std::pair{key, col});
fields.insert(std::make_pair(key, col));
valuePosition++;
} else {
col = it->second;
@ -938,7 +936,7 @@ int RdbStoreImpl::GetDataBasePath(const std::string &databasePath, std::string &
backupFilePath = databasePath;
}
if (backupFilePath == path) {
if (backupFilePath == path_) {
LOG_ERROR("The backupPath and path should not be same.");
return E_INVALID_FILE_PATH;
}
@ -980,7 +978,7 @@ int RdbStoreImpl::ExecuteGetLongInner(const std::string &sql, const std::vector<
/**
* Backup a database from a specified encrypted or unencrypted database file.
*/
int RdbStoreImpl::Backup(const std::string &databasePath, const std::vector<uint8_t> &destEncryptKey)
int RdbStoreImpl::Backup(const std::string databasePath, const std::vector<uint8_t> destEncryptKey)
{
if (config_.GetRoleType() == VISITOR) {
return E_NOT_SUPPORT;
@ -1092,7 +1090,7 @@ bool RdbStoreImpl::IsHoldingConnection()
* Attaches a database.
*/
int RdbStoreImpl::Attach(const std::string &alias, const std::string &pathName,
const std::vector<uint8_t> &destEncryptKey)
const std::vector<uint8_t> destEncryptKey)
{
std::shared_ptr<SqliteConnection> connection;
std::string sql = GlobalExpr::PRAGMA_JOUR_MODE_EXP;
@ -1187,10 +1185,12 @@ int RdbStoreImpl::BeginTransaction()
if (errCode != E_OK) {
LOG_ERROR("transaction id: %{public}zu, storeName: %{public}s, errCode: %{public}d",
transactionId, name_.c_str(), errCode);
return errCode;
}
connection->SetInTransaction(true);
connectionPool_->GetTransactionStack().push(transaction);
// 1 means the number of transactions in process
@ -1262,7 +1262,7 @@ int RdbStoreImpl::Commit()
BaseTransaction transaction = connectionPool_->GetTransactionStack().top();
std::string sqlStr = transaction.GetCommitStr();
if (sqlStr.size() <= 1) {
LOG_ERROR("transaction id: %{public}zu, storeName: %{public}s", transactionId, name_.c_str());
LOG_INFO("transaction id: %{public}zu, storeName: %{public}s", transactionId, name_.c_str());
connectionPool_->GetTransactionStack().pop();
return E_OK;
}
@ -1487,7 +1487,7 @@ int RdbStoreImpl::ConfigLocale(const std::string &localeStr)
return connectionPool_->ConfigLocale(localeStr);
}
int RdbStoreImpl::Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey)
int RdbStoreImpl::Restore(const std::string backupPath, const std::vector<uint8_t> &newKey)
{
if (!isOpen_) {
LOG_ERROR("The connection pool has been closed.");
@ -1883,15 +1883,15 @@ int RdbStoreImpl::RegisterDataChangeCallback()
return E_NOT_SUPPORT;
}
InitDelayNotifier();
auto callBack = [this](ClientChangedData &clientChangedData) {
auto callBack = [delayNotifier = delayNotifier_](ClientChangedData &clientChangedData) {
DistributedRdb::RdbChangedData rdbChangedData;
for (const auto& entry : clientChangedData.tableData) {
DistributedRdb::RdbChangeProperties rdbProperties;
rdbProperties.isTrackedDataChange = entry.second.isTrackedDataChange;
rdbChangedData.tableData[entry.first] = rdbProperties;
}
if (delayNotifier_ != nullptr) {
delayNotifier_->UpdateNotify(rdbChangedData);
if (delayNotifier != nullptr) {
delayNotifier->UpdateNotify(rdbChangedData);
}
};
auto connection = connectionPool_->AcquireConnection(false);

View File

@ -32,6 +32,7 @@
#include "logger.h"
#include "raw_data_parser.h"
#include "rdb_errno.h"
#include "relational_store_client.h"
#include "sqlite_errno.h"
#include "sqlite_global_config.h"
#include "sqlite_utils.h"
@ -39,7 +40,6 @@
#include "directory_ex.h"
#include "rdb_security_manager.h"
#include "relational/relational_store_sqlite_ext.h"
#include "relational_store_client.h"
#include "share_block.h"
#include "shared_block_serializer_info.h"
#endif
@ -47,7 +47,6 @@
namespace OHOS {
namespace NativeRdb {
using namespace OHOS::Rdb;
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
// error status
const int ERROR_STATUS = -1;
@ -295,6 +294,11 @@ SqliteConnection::~SqliteConnection()
if (stepStatement != nullptr) {
stepStatement->Finalize();
}
if (hasClientObserver_) {
UnRegisterClientObserver(dbHandle);
}
int errCode = sqlite3_close_v2(dbHandle);
if (errCode != SQLITE_OK) {
LOG_ERROR("SqliteConnection ~SqliteConnection: could not close database err = %{public}d", errCode);
@ -685,12 +689,11 @@ int SqliteConnection::ExecuteForLastInsertedRowId(
errCode = statement.Step();
if (errCode == SQLITE_ROW) {
LOG_ERROR("SqliteConnection ExecuteForLastInsertedRowId : Queries can be performed using query or QuerySql "
"methods only");
LOG_ERROR("failed: %{public}d. sql: %{public}s", errCode, SqliteUtils::Anonymous(sql).c_str());
statement.ResetStatementAndClearBindings();
return E_QUERY_IN_EXECUTE;
} else if (errCode != SQLITE_DONE) {
LOG_ERROR("SqliteConnection ExecuteForLastInsertedRowId : failed %{public}d", errCode);
LOG_ERROR("failed: %{public}d. sql: %{public}s", errCode, SqliteUtils::Anonymous(sql).c_str());
statement.ResetStatementAndClearBindings();
return SQLiteError::ErrNo(errCode);
}
@ -870,23 +873,25 @@ int SqliteConnection::ExecuteForSharedBlock(int &rowNum, std::string sql, const
AppDataFwk::SharedBlock *sharedBlock, int startPos, int requiredPos, bool isCountAllRows)
{
if (sharedBlock == nullptr) {
LOG_ERROR("ExecuteForSharedBlock:sharedBlock is null.");
LOG_ERROR("sharedBlock null.");
return E_ERROR;
}
SqliteConnectionS connection(this->dbHandle, this->openFlags, this->filePath);
int errCode = PrepareAndBind(sql, bindArgs);
if (errCode != E_OK) {
LOG_ERROR("PrepareAndBind sql and bindArgs error = %{public}d ", errCode);
LOG_ERROR("error: %{public}d sql: %{public}s startPos: %{public}d requiredPos: %{public}d"
"isCountAllRows: %{public}d", errCode, SqliteUtils::Anonymous(sql).c_str(),
startPos, requiredPos, isCountAllRows);
return errCode;
}
if (ClearSharedBlock(sharedBlock) == ERROR_STATUS) {
LOG_ERROR("ExecuteForSharedBlock:sharedBlock is null.");
LOG_ERROR("failed. %{public}d. sql: %{public}s.", errCode, SqliteUtils::Anonymous(sql).c_str());
return E_ERROR;
}
sqlite3_stmt *tempSqlite3St = statement.GetSql3Stmt();
int columnNum = sqlite3_column_count(tempSqlite3St);
if (SharedBlockSetColumnNum(sharedBlock, columnNum) == ERROR_STATUS) {
LOG_ERROR("ExecuteForSharedBlock:sharedBlock is null.");
LOG_ERROR("failed.columnNum: %{public}d,sql: %{public}s", columnNum, SqliteUtils::Anonymous(sql).c_str());
return E_ERROR;
}
@ -904,7 +909,7 @@ int SqliteConnection::ExecuteForSharedBlock(int &rowNum, std::string sql, const
}
if (!ResetStatement(&sharedBlockInfo)) {
LOG_ERROR("ExecuteForSharedBlock:ResetStatement Failed.");
LOG_ERROR("err.startPos:%{public}d,addedRows:%{public}d", sharedBlockInfo.startPos, sharedBlockInfo.addedRows);
return E_ERROR;
}
sharedBlock->SetStartPos(sharedBlockInfo.startPos);
@ -927,6 +932,7 @@ int SqliteConnection::CleanDirtyData(const std::string &table, uint64_t cursor)
int SqliteConnection::RegisterCallBackObserver(const DataChangeCallback &clientChangedData)
{
if (isWriteConnection && clientChangedData != nullptr) {
hasClientObserver_ = true;
int32_t status = RegisterClientObserver(dbHandle, clientChangedData);
if (status != E_OK) {
LOG_ERROR("RegisterClientObserver error, status:%{public}d", status);

View File

@ -57,6 +57,7 @@ SqliteConnectionPool::SqliteConnectionPool(const RdbStoreConfig& storeConfig)
int SqliteConnectionPool::Init()
{
if (config_.GetRoleType() == OWNER) {
// write connect count is 1
auto errCode = writers_.Initialize(1, writeTimeout_, [this]() {
int32_t errCode = E_OK;
auto conn = SqliteConnection::Open(config_, true, errCode);
@ -139,7 +140,8 @@ int SqliteConnectionPool::AcquireTransaction()
{
std::unique_lock<std::mutex> lock(transMutex_);
if (transCondition_.wait_for(lock, std::chrono::seconds(TRANSACTION_TIMEOUT), [this] {
return !transactionUsed_; })) {
return !transactionUsed_;
})) {
transactionUsed_ = true;
return E_OK;
}
@ -227,7 +229,9 @@ SqliteConnectionPool::ConnNode::ConnNode(std::shared_ptr<SqliteConnection> conn)
std::shared_ptr<SqliteConnection> SqliteConnectionPool::ConnNode::GetConnect()
{
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM) && !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM)
tid_ = gettid();
#endif
time_ = std::chrono::steady_clock::now();
return connect_;
}
@ -283,7 +287,7 @@ int32_t SqliteConnectionPool::Container::ConfigLocale(const std::string& locale)
if (max_ != count_) {
return E_NO_ROW_IN_QUERY;
}
for (auto it = details_.begin(); it != details_.end(); ) {
for (auto it = details_.begin(); it != details_.end();) {
auto conn = it->lock();
if (conn == nullptr || conn->connect_ == nullptr) {
it = details_.erase(it);
@ -358,6 +362,7 @@ int32_t SqliteConnectionPool::Container::Dump(const char *header)
.append(",")
.append(std::to_string(node->GetUsingTime()))
.append(">");
// 256 represent that limit to info length
if (info.size() > 256) {
LOG_WARN("%{public}s: %{public}s", header, info.c_str());
info.clear();

View File

@ -85,12 +85,12 @@ int SqliteSharedResultSet::GetAllColumnNames(std::vector<std::string> &columnNam
if (errCode != E_OK) {
return errCode;
}
std::lock_guard<std::mutex> lock(columnNamesLock_);
for (int i = 0; i < columnCount; i++) {
std::string columnName;
errCode = sqliteStatement->GetColumnName(i, columnName);
if (errCode) {
if (errCode != E_OK) {
columnNames_.clear();
return errCode;
}

View File

@ -42,7 +42,7 @@ constexpr const char *REPLACE_CHAIN = "***";
constexpr const char *DEFAULT_ANONYMOUS = "******";
constexpr SqliteUtils::SqlType SqliteUtils::SQL_TYPE_MAP[];
constexpr const char * SqliteUtils::ON_CONFLICT_CLAUSE[];
constexpr const char *SqliteUtils::ON_CONFLICT_CLAUSE[];
int SqliteUtils::GetSqlStatementType(const std::string &sql)
{

View File

@ -258,7 +258,6 @@ int StepResultSet::PrepareStep()
}
auto pool = connectionPool_.lock();
if (pool == nullptr) {
LOG_ERROR("not a select sql_!");
return E_STEP_RESULT_CLOSED;
}

View File

@ -210,6 +210,7 @@ if (is_ohos && !build_ohos_sdk) {
visibility = [ ":*" ]
include_dirs = [
"${relational_store_mock_path}/frameworks/native/rdb/mock",
"mock/include",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/mock/include",
@ -307,6 +308,7 @@ if (is_ohos && !build_ohos_sdk) {
visibility = [ ":*" ]
include_dirs = [
"${relational_store_mock_path}/frameworks/native/rdb/mock",
"mock/include",
"${relational_store_common_path}/include",
"${relational_store_native_path}/rdb/mock/include",
@ -426,6 +428,7 @@ if (is_ohos && !build_ohos_sdk) {
visibility = [ ":*" ]
include_dirs = [
"${relational_store_mock_path}/frameworks/native/rdb/mock",
"mock/include",
"include",
"${relational_store_native_path}/mock/rdb/include",
@ -466,6 +469,7 @@ if (is_ohos && !build_ohos_sdk) {
visibility = [ ":*" ]
include_dirs = [
"${relational_store_mock_path}/frameworks/native/rdb/mock",
"${distributedfile_path}/mod_securitylabel",
"${relational_store_common_path}/include",
"${relational_store_innerapi_path}/rdb/mock/include",

View File

@ -318,7 +318,7 @@ public:
* @param databasePath Indicates the database file path.
* @param destEncryptKey Indicates the database encrypt key.
*/
virtual int Backup(const std::string &databasePath, const std::vector<uint8_t> &destEncryptKey = {}) = 0;
virtual int Backup(const std::string databasePath, const std::vector<uint8_t> destEncryptKey = {}) = 0;
/**
* @brief Attaches a database.
@ -328,7 +328,7 @@ public:
* @param destEncryptKey Indicates the database encrypt key.
*/
virtual int Attach(
const std::string &alias, const std::string &pathName, const std::vector<uint8_t> &destEncryptKey) = 0;
const std::string &alias, const std::string &pathName, const std::vector<uint8_t> destEncryptKey) = 0;
/**
* @brief Get the value of the column based on specified conditions.
@ -454,7 +454,7 @@ public:
* @param backupPath Indicates the name that saves the database file path.
* @param newKey Indicates the database new key.
*/
virtual int Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey = {}) = 0;
virtual int Restore(const std::string backupPath, const std::vector<uint8_t> &newKey = {}) = 0;
/**
* @brief Set table to be distributed table.

View File

@ -73,9 +73,9 @@ public:
const std::vector<ValueObject> &bindArgs = {}) = 0;
virtual int ExecuteForChangedRowCount(int64_t &outValue, const std::string &sql,
const std::vector<ValueObject> &bindArgs = {}) = 0;
virtual int Backup(const std::string &databasePath, const std::vector<uint8_t> &destEncryptKey = {}) = 0;
virtual int Backup(const std::string databasePath, const std::vector<uint8_t> destEncryptKey = {}) = 0;
virtual int Attach(
const std::string &alias, const std::string &pathName, const std::vector<uint8_t> &destEncryptKey) = 0;
const std::string &alias, const std::string &pathName, const std::vector<uint8_t> destEncryptKey) = 0;
virtual int Count(int64_t &outValue, const AbsRdbPredicates &predicates) = 0;
virtual std::shared_ptr<ResultSet> Query(
@ -94,7 +94,7 @@ public:
virtual bool IsOpen() const = 0;
virtual bool IsReadOnly() const = 0;
virtual bool IsMemoryRdb() const = 0;
virtual int Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey = {}) = 0;
virtual int Restore(const std::string backupPath, const std::vector<uint8_t> &newKey = {}) = 0;
};
} // namespace OHOS::NativeRdb
#endif

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RELATIONAL_STORE_RELATIONAL_STORE_CLIENT_H
#define RELATIONAL_STORE_RELATIONAL_STORE_CLIENT_H
#include "sqlite3sym.h"
namespace OHOS {
namespace NativeRdb {
namespace DistributedDB {
enum DBStatus {
DB_ERROR = -1,
OK = 0,
};
}
DistributedDB::DBStatus UnRegisterClientObserver(sqlite3 *db)
{
return DistributedDB::DBStatus::OK;
};
}
}
#endif //RELATIONAL_STORE_RELATIONAL_STORE_CLIENT_H

View File

@ -20,6 +20,8 @@ distributeddata_base_path = "//foundation/distributeddatamgr"
relational_store_base_path = "//foundation/distributeddatamgr/relational_store"
relational_store_mock_path = "${relational_store_base_path}/rdbmock"
relational_store_js_common_path =
"${relational_store_base_path}/frameworks/js/napi/common"

View File

@ -102,7 +102,7 @@ void RdbRekeyTest::TearDown()
RdbHelper::DeleteRdbStore(RdbRekeyTest::encryptedDatabasePath);
}
std::string RdbRekeyTest::RemoveSuffix(const string &name)
std::string RdbRekeyTest::RemoveSuffix(const std::string &name)
{
std::string suffix(".db");
auto pos = name.rfind(suffix);