1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "mock.h"
17 #include "relational_store_client.h"
18 
19 namespace OHOS {
PathToRealPath(const std::string & path,std::string & realPath)20 __attribute__((visibility("default"))) bool PathToRealPath(const std::string &path, std::string &realPath)
21 {
22     realPath = path;
23     return true;
24 }
25 
ExtractFilePath(const std::string & fileFullName)26 __attribute__((visibility("default"))) std::string ExtractFilePath(const std::string &fileFullName)
27 {
28     return std::string(fileFullName).substr(0, fileFullName.rfind("/") + 1);
29 }
30 
31 namespace NativeRdb {
32 struct SharedBlockInfo;
33 struct sqlite3_stmt;
gettid()34 __attribute__((visibility("default"))) int gettid()
35 {
36     return 0;
37 }
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
FillSharedBlockOpt(SharedBlockInfo * info,sqlite3_stmt * stmt)41 __attribute__((visibility("default"))) int FillSharedBlockOpt(SharedBlockInfo *info, sqlite3_stmt *stmt)
42 {
43     (void)info;
44     (void)stmt;
45     return 0;
46 }
47 
FillSharedBlock(SharedBlockInfo * info,sqlite3_stmt * stmt)48 __attribute__((visibility("default"))) int FillSharedBlock(SharedBlockInfo *info, sqlite3_stmt *stmt)
49 {
50     (void)info;
51     (void)stmt;
52     return 0;
53 }
54 
ResetStatement(SharedBlockInfo * info,sqlite3_stmt * stmt)55 __attribute__((visibility("default"))) bool ResetStatement(SharedBlockInfo *info, sqlite3_stmt *stmt)
56 {
57     (void)info;
58     (void)stmt;
59     return true;
60 }
61 
62 #ifdef __cplusplus
63 }
64 #endif
65 }
66 }
67 
68 using namespace DistributedDB;
UnRegisterClientObserver(sqlite3 * db)69 __attribute__((visibility("default"))) DBStatus UnRegisterClientObserver(sqlite3 *db)
70 {
71     return DBStatus::OK;
72 }
73 
RegisterStoreObserver(sqlite3 * db,const std::shared_ptr<StoreObserver> & storeObserver)74 __attribute__((visibility("default"))) DBStatus RegisterStoreObserver(sqlite3 *db,
75     const std::shared_ptr<StoreObserver> &storeObserver)
76 {
77     return DBStatus::OK;
78 }
79 
UnregisterStoreObserver(sqlite3 * db,const std::shared_ptr<StoreObserver> & storeObserver)80 __attribute__((visibility("default"))) DBStatus UnregisterStoreObserver(sqlite3 *db,
81     const std::shared_ptr<StoreObserver> &storeObserver)
82 {
83     return DBStatus::OK;
84 }
85 
UnregisterStoreObserver(sqlite3 * db)86 __attribute__((visibility("default"))) DBStatus UnregisterStoreObserver(sqlite3 *db)
87 {
88     return DBStatus::OK;
89 }
90 
Lock(const std::string & tableName,const std::vector<std::vector<uint8_t>> & hashKey,sqlite3 * db)91 __attribute__((visibility("default"))) DBStatus Lock(const std::string &tableName,
92     const std::vector<std::vector<uint8_t>> &hashKey, sqlite3 *db)
93 {
94     return DBStatus::OK;
95 }
96 
UnLock(const std::string & tableName,const std::vector<std::vector<uint8_t>> & hashKey,sqlite3 * db)97 __attribute__((visibility("default"))) DBStatus UnLock(
98     const std::string &tableName, const std::vector<std::vector<uint8_t>> &hashKey, sqlite3 *db)
99 {
100     return DBStatus::OK;
101 }
102 
DropLogicDeletedData(sqlite3 * db,const std::string & tableName,uint64_t cursor)103 __attribute__((visibility("default"))) DBStatus DropLogicDeletedData(sqlite3 *db, const std::string &tableName,
104     uint64_t cursor)
105 {
106     (void)db;
107     (void)tableName;
108     (void)cursor;
109     return DBStatus::OK;
110 }
111 
GetDistributedLogTableName(const std::string & tableName)112 __attribute__((visibility("default"))) std::string DistributedDB::RelationalStoreManager::GetDistributedLogTableName(
113     const std::string &tableName)
114 {
115     return "";
116 }