• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "rdb_store.h"
16 
17 #include "logger.h"
18 #include "sqlite_sql_builder.h"
19 #include "sqlite_utils.h"
20 #include "traits.h"
21 namespace OHOS::NativeRdb {
22 using namespace OHOS::Rdb;
ModifyTime(std::shared_ptr<ResultSet> result,std::map<std::vector<uint8_t>,PRIKey> hashKeys,bool isFromRowId)23 RdbStore::ModifyTime::ModifyTime(
24     std::shared_ptr<ResultSet> result, std::map<std::vector<uint8_t>, PRIKey> hashKeys, bool isFromRowId)
25     : result_(std::move(result)), hash_(std::move(hashKeys)), isFromRowId_(isFromRowId)
26 {
27     for (auto &[_, priKey] : hash_) {
28         if (priKey.index() != Traits::variant_index_of_v<std::string, PRIKey>) {
29             break;
30         }
31         auto *val = Traits::get_if<std::string>(&priKey);
32         if (val != nullptr && maxOriginKeySize_ <= val->length()) {
33             maxOriginKeySize_ = val->length() + 1;
34         }
35     }
36 }
37 
operator std::map<PRIKey,Date>()38 RdbStore::ModifyTime::operator std::map<PRIKey, Date>()
39 {
40     if (result_ == nullptr) {
41         return {};
42     }
43     int count = 0;
44     if (result_->GetRowCount(count) != E_OK || count <= 0) {
45         return {};
46     }
47     std::map<PRIKey, Date> result;
48     for (int i = 0; i < count; i++) {
49         result_->GoToRow(i);
50         int64_t timeStamp = 0;
51         result_->GetLong(1, timeStamp);
52         PRIKey index = 0;
53         if (isFromRowId_) {
54             int64_t rowid = 0;
55             result_->GetLong(0, rowid);
56             index = rowid;
57         } else {
58             std::vector<uint8_t> hashKey;
59             result_->GetBlob(0, hashKey);
60             index = hash_[hashKey];
61         }
62         result[index] = Date(timeStamp);
63     }
64     return result;
65 }
66 
operator std::shared_ptr<ResultSet>()67 RdbStore::ModifyTime::operator std::shared_ptr<ResultSet>()
68 {
69     return result_;
70 }
71 
GetOriginKey(const std::vector<uint8_t> & hash)72 RdbStore::PRIKey RdbStore::ModifyTime::GetOriginKey(const std::vector<uint8_t> &hash)
73 {
74     auto it = hash_.find(hash);
75     return it != hash_.end() ? it->second : std::monostate();
76 }
77 
GetMaxOriginKeySize()78 size_t RdbStore::ModifyTime::GetMaxOriginKeySize()
79 {
80     return maxOriginKeySize_;
81 }
82 
NeedConvert() const83 bool RdbStore::ModifyTime::NeedConvert() const
84 {
85     return !hash_.empty();
86 }
87 
ToValues(const std::vector<std::string> & args)88 static std::vector<ValueObject> ToValues(const std::vector<std::string> &args)
89 {
90     std::vector<ValueObject> newArgs;
91     std::for_each(args.begin(), args.end(), [&newArgs](const auto &it) {
92         newArgs.push_back(ValueObject(it));
93     });
94     return newArgs;
95 }
96 
ColHasSpecificField(const std::vector<std::string> & columns)97 static bool ColHasSpecificField(const std::vector<std::string> &columns)
98 {
99     for (const std::string &column : columns) {
100         if (column.find(SqliteUtils::REP) != std::string::npos) {
101             return true;
102         }
103     }
104     return false;
105 }
106 
Insert(const std::string & table,const Row & row,Resolution resolution)107 std::pair<int, int64_t> RdbStore::Insert(const std::string &table, const Row &row, Resolution resolution)
108 {
109     (void)table;
110     (void)row;
111     (void)resolution;
112     return { E_NOT_SUPPORT, -1 };
113 }
114 
Insert(int64_t & outRowId,const std::string & table,const Row & row)115 int RdbStore::Insert(int64_t &outRowId, const std::string &table, const Row &row)
116 {
117     auto [errCode, rowid] = Insert(table, row, NO_ACTION);
118     if (errCode == E_OK) {
119         outRowId = rowid;
120     }
121     return errCode;
122 }
123 
InsertWithConflictResolution(int64_t & outRowId,const std::string & table,const Row & row,Resolution resolution)124 int RdbStore::InsertWithConflictResolution(
125     int64_t &outRowId, const std::string &table, const Row &row, Resolution resolution)
126 {
127     auto [errCode, rowid] = Insert(table, row, resolution);
128     if (errCode == E_OK) {
129         outRowId = rowid;
130     }
131     return errCode;
132 }
133 
Replace(int64_t & outRowId,const std::string & table,const Row & row)134 int RdbStore::Replace(int64_t &outRowId, const std::string &table, const Row &row)
135 {
136     auto [errCode, rowid] = Insert(table, row, Resolution::ON_CONFLICT_REPLACE);
137     if (errCode == E_OK) {
138         outRowId = rowid;
139     }
140     return errCode;
141 }
142 
143 // Old version implementation, cannot be modified
BatchInsert(const std::string & table,const RefRows & rows)144 std::pair<int, int64_t> RdbStore::BatchInsert(const std::string &table, const RefRows &rows)
145 {
146     return { E_NOT_SUPPORT, -1 };
147 }
148 
BatchInsert(int64_t & outInsertNum,const std::string & table,const Rows & rows)149 int RdbStore::BatchInsert(int64_t &outInsertNum, const std::string &table, const Rows &rows)
150 {
151     ValuesBuckets refRows;
152     for (auto &row : rows) {
153         refRows.Put(row);
154     }
155     auto [errCode, count] = BatchInsert(table, refRows);
156     if (errCode == E_OK) {
157         outInsertNum = count;
158     }
159     return errCode;
160 }
161 
BatchInsert(const std::string & table,const RefRows & rows,Resolution resolution)162 std::pair<int, int64_t> RdbStore::BatchInsert(const std::string &table, const RefRows &rows, Resolution resolution)
163 {
164     auto [code, result] = BatchInsert(table, rows, {}, resolution);
165     return { code, result.changed };
166 }
167 
BatchInsert(const std::string & table,const RefRows & rows,const std::vector<std::string> & returningFields,Resolution resolution)168 std::pair<int, Results> RdbStore::BatchInsert(const std::string &table, const RefRows &rows,
169     const std::vector<std::string> &returningFields, Resolution resolution)
170 {
171     return { E_NOT_SUPPORT, -1 };
172 }
173 
Update(const std::string & table,const Row & row,const std::string & where,const Values & args,Resolution resolution)174 std::pair<int, int> RdbStore::Update(
175     const std::string &table, const Row &row, const std::string &where, const Values &args, Resolution resolution)
176 {
177     AbsRdbPredicates predicates(table);
178     predicates.SetWhereClause(where);
179     predicates.SetBindArgs(args);
180     auto [code, result] = Update(row, predicates, {}, resolution);
181     return { code, result.changed };
182 }
183 
Update(int & changedRows,const std::string & table,const Row & row,const std::string & whereClause,const Values & args)184 int RdbStore::Update(
185     int &changedRows, const std::string &table, const Row &row, const std::string &whereClause, const Values &args)
186 {
187     auto [errCode, changes] = Update(table, row, whereClause, args, NO_ACTION);
188     if (errCode == E_OK) {
189         changedRows = changes;
190     }
191     return errCode;
192 }
193 
Update(int & changedRows,const Row & row,const AbsRdbPredicates & predicates)194 int RdbStore::Update(int &changedRows, const Row &row, const AbsRdbPredicates &predicates)
195 {
196     return Update(changedRows, predicates.GetTableName(), row, predicates.GetWhereClause(), predicates.GetBindArgs());
197 }
198 
Update(int & changedRows,const std::string & table,const Row & row,const std::string & whereClause,const Olds & args)199 int RdbStore::Update(
200     int &changedRows, const std::string &table, const Row &row, const std::string &whereClause, const Olds &args)
201 {
202     return Update(changedRows, table, row, whereClause, ToValues(args));
203 };
204 
Update(const Row & row,const AbsRdbPredicates & predicates,const std::vector<std::string> & returningFields,Resolution resolution)205 std::pair<int32_t, Results> RdbStore::Update(const Row &row, const AbsRdbPredicates &predicates,
206     const std::vector<std::string> &returningFields, Resolution resolution)
207 {
208     return { E_NOT_SUPPORT, -1 };
209 }
210 
UpdateWithConflictResolution(int & changedRows,const std::string & table,const Row & row,const std::string & whereClause,const Olds & args,Resolution resolution)211 int RdbStore::UpdateWithConflictResolution(int &changedRows, const std::string &table, const Row &row,
212     const std::string &whereClause, const Olds &args, Resolution resolution)
213 {
214     auto [errCode, changes] = Update(table, row, whereClause, ToValues(args), resolution);
215     if (errCode == E_OK) {
216         changedRows = changes;
217     }
218     return errCode;
219 }
220 
UpdateWithConflictResolution(int & changedRows,const std::string & table,const Row & row,const std::string & whereClause,const Values & args,Resolution resolution)221 int RdbStore::UpdateWithConflictResolution(int &changedRows, const std::string &table, const Row &row,
222     const std::string &whereClause, const Values &args, Resolution resolution)
223 {
224     auto [errCode, changes] = Update(table, row, whereClause, args, resolution);
225     if (errCode == E_OK) {
226         changedRows = changes;
227     }
228     return errCode;
229 }
230 
Delete(int & deletedRows,const std::string & table,const std::string & whereClause,const Olds & args)231 int RdbStore::Delete(int &deletedRows, const std::string &table, const std::string &whereClause, const Olds &args)
232 {
233     return Delete(deletedRows, table, whereClause, ToValues(args));
234 }
235 
Delete(int & deletedRows,const AbsRdbPredicates & predicates)236 int RdbStore::Delete(int &deletedRows, const AbsRdbPredicates &predicates)
237 {
238     return Delete(deletedRows, predicates.GetTableName(), predicates.GetWhereClause(), predicates.GetBindArgs());
239 }
240 
Delete(int & deletedRows,const std::string & table,const std::string & whereClause,const RdbStore::Values & args)241 int RdbStore::Delete(
242     int &deletedRows, const std::string &table, const std::string &whereClause, const RdbStore::Values &args)
243 {
244     AbsRdbPredicates predicates(table);
245     predicates.SetWhereClause(whereClause);
246     predicates.SetBindArgs(args);
247     auto [code, result] = Delete(predicates);
248     deletedRows = result.changed;
249     return code;
250 }
251 
Delete(const AbsRdbPredicates & predicates,const std::vector<std::string> & returningFields)252 std::pair<int32_t, Results> RdbStore::Delete(
253     const AbsRdbPredicates &predicates, const std::vector<std::string> &returningFields)
254 {
255     return { E_NOT_SUPPORT, -1 };
256 }
257 
Query(int & errCode,bool distinct,const std::string & table,const Fields & columns,const std::string & whereClause,const Values & args,const std::string & groupBy,const std::string & indexName,const std::string & orderBy,const int & limit,const int & offset)258 std::shared_ptr<AbsSharedResultSet> RdbStore::Query(int &errCode, bool distinct, const std::string &table,
259     const Fields &columns, const std::string &whereClause, const Values &args, const std::string &groupBy,
260     const std::string &indexName, const std::string &orderBy, const int &limit, const int &offset)
261 {
262     std::string sql;
263     errCode = SqliteSqlBuilder::BuildQueryString(
264         distinct, table, "", columns, whereClause, groupBy, indexName, orderBy, limit, offset, sql);
265     if (errCode != E_OK) {
266         return nullptr;
267     }
268     return QuerySql(sql, args);
269 }
270 
Query(const AbsRdbPredicates & predicates,const Fields & columns)271 std::shared_ptr<AbsSharedResultSet> RdbStore::Query(const AbsRdbPredicates &predicates, const Fields &columns)
272 {
273     std::string sql;
274     std::pair<bool, bool> queryStatus = { ColHasSpecificField(columns), predicates.HasSpecificField() };
275     if (queryStatus.first || queryStatus.second) {
276         std::string logTable = GetLogTableName(predicates.GetTableName());
277         sql = SqliteSqlBuilder::BuildCursorQueryString(predicates, columns, logTable, queryStatus);
278     } else {
279         sql = SqliteSqlBuilder::BuildQueryString(predicates, columns);
280     }
281     return QuerySql(sql, predicates.GetBindArgs());
282 }
283 
QuerySql(const std::string & sql,const Olds & args)284 std::shared_ptr<AbsSharedResultSet> RdbStore::QuerySql(const std::string &sql, const Olds &args)
285 {
286     return QuerySql(sql, ToValues(args));
287 }
288 
QueryByStep(const std::string & sql,const Olds & args)289 std::shared_ptr<ResultSet> RdbStore::QueryByStep(const std::string &sql, const Olds &args)
290 {
291     return QueryByStep(sql, ToValues(args));
292 }
293 
QueryByStep(const AbsRdbPredicates & predicates,const RdbStore::Fields & columns,bool preCount)294 std::shared_ptr<ResultSet> RdbStore::QueryByStep(const AbsRdbPredicates &predicates, const RdbStore::Fields &columns,
295     bool preCount)
296 {
297     std::string sql;
298     std::pair<bool, bool> queryStatus = { ColHasSpecificField(columns), predicates.HasSpecificField() };
299     if (queryStatus.first || queryStatus.second) {
300         std::string table = predicates.GetTableName();
301         std::string logTable = GetLogTableName(table);
302         sql = SqliteSqlBuilder::BuildLockRowQueryString(predicates, columns, logTable);
303     } else {
304         sql = SqliteSqlBuilder::BuildQueryString(predicates, columns);
305     }
306     return QueryByStep(sql, predicates.GetBindArgs(), preCount);
307 }
308 
RemoteQuery(const std::string & device,const AbsRdbPredicates & predicates,const Fields & columns,int & errCode)309 std::shared_ptr<ResultSet> RdbStore::RemoteQuery(
310     const std::string &device, const AbsRdbPredicates &predicates, const Fields &columns, int &errCode)
311 {
312     (void)device;
313     (void)predicates;
314     (void)columns;
315     errCode = E_NOT_SUPPORT;
316     return nullptr;
317 }
318 
QuerySharingResource(const AbsRdbPredicates & predicates,const Fields & columns)319 std::pair<int32_t, std::shared_ptr<ResultSet>> RdbStore::QuerySharingResource(
320     const AbsRdbPredicates &predicates, const Fields &columns)
321 {
322     (void)predicates;
323     (void)columns;
324     return { E_NOT_SUPPORT, nullptr };
325 }
326 
ExecuteSql(const std::string & sql,const Values & args)327 int RdbStore::ExecuteSql(const std::string &sql, const Values &args)
328 {
329     auto [errCode, value] = Execute(sql, args, 0);
330     return errCode;
331 }
332 
Execute(const std::string & sql,const Values & args,int64_t trxId)333 std::pair<int32_t, ValueObject> RdbStore::Execute(const std::string &sql, const Values &args, int64_t trxId)
334 {
335     return { E_NOT_SUPPORT, ValueObject() };
336 }
337 
ExecuteExt(const std::string & sql,const Values & args)338 std::pair<int32_t, Results> RdbStore::ExecuteExt(const std::string &sql, const Values &args)
339 {
340     return { E_NOT_SUPPORT, -1 };
341 }
342 
ExecuteAndGetLong(int64_t & outValue,const std::string & sql,const Values & args)343 int RdbStore::ExecuteAndGetLong(int64_t &outValue, const std::string &sql, const Values &args)
344 {
345     auto [errCode, value] = Execute(sql, args);
346     if (errCode == E_OK) {
347         outValue = static_cast<int64_t>(value);
348     }
349     return errCode;
350 }
351 
ExecuteAndGetString(std::string & outValue,const std::string & sql,const Values & args)352 int RdbStore::ExecuteAndGetString(std::string &outValue, const std::string &sql, const Values &args)
353 {
354     auto [errCode, value] = Execute(sql, args);
355     if (errCode == E_OK) {
356         outValue = static_cast<std::string>(value);
357     }
358     return errCode;
359 }
360 
ExecuteForLastInsertedRowId(int64_t & outValue,const std::string & sql,const Values & args)361 int RdbStore::ExecuteForLastInsertedRowId(int64_t &outValue, const std::string &sql, const Values &args)
362 {
363     auto [errCode, value] = Execute(sql, args);
364     if (errCode == E_OK) {
365         (void)value.GetLong(outValue);
366     }
367     return errCode;
368 }
369 
ExecuteForChangedRowCount(int64_t & outValue,const std::string & sql,const Values & args)370 int RdbStore::ExecuteForChangedRowCount(int64_t &outValue, const std::string &sql, const Values &args)
371 {
372     auto [errCode, value] = Execute(sql, args);
373     if (errCode == E_OK) {
374         (void)value.GetLong(outValue);
375     }
376     return errCode;
377 }
378 
Backup(const std::string & databasePath,const std::vector<uint8_t> & encryptKey)379 int RdbStore::Backup(const std::string &databasePath, const std::vector<uint8_t> &encryptKey)
380 {
381     return Backup(databasePath, encryptKey, true);
382 }
383 
Backup(const std::string & databasePath,const std::vector<uint8_t> & encryptKey,bool verifyDb)384 int RdbStore::Backup(const std::string &databasePath, const std::vector<uint8_t> &encryptKey, bool verifyDb)
385 {
386     (void)verifyDb;
387     (void)databasePath;
388     (void)encryptKey;
389     return E_NOT_SUPPORT;
390 }
391 
Attach(const std::string & alias,const std::string & pathName,const std::vector<uint8_t> encryptKey)392 int RdbStore::Attach(const std::string &alias, const std::string &pathName, const std::vector<uint8_t> encryptKey)
393 {
394     (void)alias;
395     (void)pathName;
396     (void)encryptKey;
397     return E_OK;
398 }
399 
Count(int64_t & outValue,const AbsRdbPredicates & predicates)400 int RdbStore::Count(int64_t &outValue, const AbsRdbPredicates &predicates)
401 {
402     (void)outValue;
403     (void)predicates;
404     return E_NOT_SUPPORT;
405 }
406 
CreateTransaction(int32_t type)407 std::pair<int32_t, std::shared_ptr<Transaction>> RdbStore::CreateTransaction(int32_t type)
408 {
409     (void)type;
410     return { E_NOT_SUPPORT, nullptr };
411 }
412 
BeginTransaction()413 int RdbStore::BeginTransaction()
414 {
415     return E_NOT_SUPPORT;
416 }
417 
BeginTrans()418 std::pair<int, int64_t> RdbStore::BeginTrans()
419 {
420     return { E_NOT_SUPPORT, 0 };
421 }
422 
RollBack()423 int RdbStore::RollBack()
424 {
425     return E_NOT_SUPPORT;
426 }
427 
RollBack(int64_t trxId)428 int RdbStore::RollBack(int64_t trxId)
429 {
430     (void)trxId;
431     return E_NOT_SUPPORT;
432 }
433 
Commit()434 int RdbStore::Commit()
435 {
436     return E_NOT_SUPPORT;
437 }
438 
Commit(int64_t trxId)439 int RdbStore::Commit(int64_t trxId)
440 {
441     (void)trxId;
442     return E_NOT_SUPPORT;
443 }
444 
IsInTransaction()445 bool RdbStore::IsInTransaction()
446 {
447     return true;
448 }
449 
GetPath()450 std::string RdbStore::GetPath()
451 {
452     return "";
453 }
454 
IsHoldingConnection()455 bool RdbStore::IsHoldingConnection()
456 {
457     return true;
458 }
459 
IsOpen() const460 bool RdbStore::IsOpen() const
461 {
462     return true;
463 }
464 
IsReadOnly() const465 bool RdbStore::IsReadOnly() const
466 {
467     return false;
468 }
469 
IsMemoryRdb() const470 bool RdbStore::IsMemoryRdb() const
471 {
472     return false;
473 }
474 
Restore(const std::string & backupPath,const std::vector<uint8_t> & newKey)475 int RdbStore::Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey)
476 {
477     (void)backupPath;
478     (void)newKey;
479     return E_NOT_SUPPORT;
480 }
481 
SetDistributedTables(const std::vector<std::string> & tables,int32_t type,const DistributedRdb::DistributedConfig & distributedConfig)482 int RdbStore::SetDistributedTables(
483     const std::vector<std::string> &tables, int32_t type, const DistributedRdb::DistributedConfig &distributedConfig)
484 {
485     (void)tables;
486     (void)type;
487     (void)distributedConfig;
488     return E_NOT_SUPPORT;
489 }
490 
Rekey(const RdbStoreConfig::CryptoParam & cryptoParam)491 int RdbStore::Rekey(const RdbStoreConfig::CryptoParam &cryptoParam)
492 {
493     (void)cryptoParam;
494     return E_NOT_SUPPORT;
495 }
496 
ObtainDistributedTableName(const std::string & device,const std::string & table,int & errCode)497 std::string RdbStore::ObtainDistributedTableName(const std::string &device, const std::string &table, int &errCode)
498 {
499     errCode = E_NOT_SUPPORT;
500     return table + "_" + device;
501 }
502 
Sync(const SyncOption & option,const AbsRdbPredicates & predicate,const AsyncBrief & async)503 int RdbStore::Sync(const SyncOption &option, const AbsRdbPredicates &predicate, const AsyncBrief &async)
504 {
505     (void)option;
506     (void)predicate;
507     (void)async;
508     return E_NOT_SUPPORT;
509 }
510 
Sync(const SyncOption & option,const std::vector<std::string> & tables,const AsyncDetail & async)511 int RdbStore::Sync(const SyncOption &option, const std::vector<std::string> &tables, const AsyncDetail &async)
512 {
513     (void)option;
514     (void)tables;
515     (void)async;
516     return E_NOT_SUPPORT;
517 }
518 
Sync(const SyncOption & option,const AbsRdbPredicates & predicate,const AsyncDetail & async)519 int RdbStore::Sync(const SyncOption &option, const AbsRdbPredicates &predicate, const AsyncDetail &async)
520 {
521     (void)option;
522     (void)predicate;
523     (void)async;
524     return E_NOT_SUPPORT;
525 }
526 
Subscribe(const SubscribeOption & option,std::shared_ptr<RdbStoreObserver> observer)527 int RdbStore::Subscribe(const SubscribeOption &option, std::shared_ptr<RdbStoreObserver> observer)
528 {
529     (void)option;
530     (void)observer;
531     return E_NOT_SUPPORT;
532 }
533 
UnSubscribe(const SubscribeOption & option,std::shared_ptr<RdbStoreObserver> observer)534 int RdbStore::UnSubscribe(const SubscribeOption &option, std::shared_ptr<RdbStoreObserver> observer)
535 {
536     (void)option;
537     (void)observer;
538     return E_NOT_SUPPORT;
539 }
540 
SubscribeObserver(const SubscribeOption & option,const std::shared_ptr<RdbStoreObserver> & observer)541 int RdbStore::SubscribeObserver(const SubscribeOption &option, const std::shared_ptr<RdbStoreObserver> &observer)
542 {
543     (void)option;
544     (void)observer;
545     return E_NOT_SUPPORT;
546 }
547 
UnsubscribeObserver(const SubscribeOption & option,const std::shared_ptr<RdbStoreObserver> & observer)548 int RdbStore::UnsubscribeObserver(const SubscribeOption &option, const std::shared_ptr<RdbStoreObserver> &observer)
549 {
550     (void)option;
551     (void)observer;
552     return E_NOT_SUPPORT;
553 }
554 
RegisterAutoSyncCallback(std::shared_ptr<DetailProgressObserver> observer)555 int RdbStore::RegisterAutoSyncCallback(std::shared_ptr<DetailProgressObserver> observer)
556 {
557     (void)observer;
558     return E_NOT_SUPPORT;
559 }
560 
UnregisterAutoSyncCallback(std::shared_ptr<DetailProgressObserver> observer)561 int RdbStore::UnregisterAutoSyncCallback(std::shared_ptr<DetailProgressObserver> observer)
562 {
563     (void)observer;
564     return E_NOT_SUPPORT;
565 }
566 
Notify(const std::string & event)567 int RdbStore::Notify(const std::string &event)
568 {
569     (void)event;
570     return E_NOT_SUPPORT;
571 }
572 
IsSlaveDiffFromMaster() const573 bool RdbStore::IsSlaveDiffFromMaster() const
574 {
575     return false;
576 }
577 
GetDbType() const578 int32_t RdbStore::GetDbType() const
579 {
580     return DB_SQLITE;
581 }
582 
LockCloudContainer()583 std::pair<int32_t, uint32_t> RdbStore::LockCloudContainer()
584 {
585     return { E_OK, 0 };
586 }
587 
UnlockCloudContainer()588 int32_t RdbStore::UnlockCloudContainer()
589 {
590     return E_OK;
591 }
592 
InterruptBackup()593 int RdbStore::InterruptBackup()
594 {
595     return E_OK;
596 }
597 
GetBackupStatus() const598 int32_t RdbStore::GetBackupStatus() const
599 {
600     return SlaveStatus::UNDEFINED;
601 }
602 
GetModifyTime(const std::string & table,const std::string & column,std::vector<PRIKey> & keys)603 RdbStore::ModifyTime RdbStore::GetModifyTime(
604     const std::string &table, const std::string &column, std::vector<PRIKey> &keys)
605 {
606     (void)table;
607     (void)column;
608     (void)keys;
609     return {};
610 }
611 
CleanDirtyData(const std::string & table,uint64_t cursor)612 int RdbStore::CleanDirtyData(const std::string &table, uint64_t cursor)
613 {
614     (void)table;
615     (void)cursor;
616     return E_NOT_SUPPORT;
617 }
618 
GetRebuilt(RebuiltType & rebuilt)619 int RdbStore::GetRebuilt(RebuiltType &rebuilt)
620 {
621     (void)rebuilt;
622     return E_NOT_SUPPORT;
623 }
624 
Attach(const RdbStoreConfig & config,const std::string & attachName,int32_t waitTime)625 std::pair<int32_t, int32_t> RdbStore::Attach(
626     const RdbStoreConfig &config, const std::string &attachName, int32_t waitTime)
627 {
628     (void)config;
629     (void)attachName;
630     (void)waitTime;
631     return { E_NOT_SUPPORT, 0 };
632 }
633 
Detach(const std::string & attachName,int32_t waitTime)634 std::pair<int32_t, int32_t> RdbStore::Detach(const std::string &attachName, int32_t waitTime)
635 {
636     (void)attachName;
637     (void)waitTime;
638     return { E_NOT_SUPPORT, 0 };
639 }
640 
ModifyLockStatus(const AbsRdbPredicates & predicates,bool isLock)641 int RdbStore::ModifyLockStatus(const AbsRdbPredicates &predicates, bool isLock)
642 {
643     (void)predicates;
644     (void)isLock;
645     return E_NOT_SUPPORT;
646 }
647 
SetSearchable(bool isSearchable)648 int RdbStore::SetSearchable(bool isSearchable)
649 {
650     (void)isSearchable;
651     return E_NOT_SUPPORT;
652 }
653 
GetLogTableName(const std::string & tableName)654 std::string RdbStore::GetLogTableName(const std::string &tableName)
655 {
656     return "naturalbase_rdb_aux_" + tableName + "_log";
657 }
658 
CleanDirtyLog(const std::string & table,uint64_t cursor)659 int RdbStore::CleanDirtyLog([[gnu::unused]] const std::string &table, [[gnu::unused]] uint64_t cursor)
660 {
661     return E_NOT_SUPPORT;
662 }
663 
ConfigLocale(const std::string & localeStr)664 int RdbStore::ConfigLocale(const std::string &localeStr)
665 {
666     (void)localeStr;
667     return E_NOT_SUPPORT;
668 }
669 
InitKnowledgeSchema(const DistributedRdb::RdbKnowledgeSchema & schema)670 int RdbStore::InitKnowledgeSchema(const DistributedRdb::RdbKnowledgeSchema &schema)
671 {
672     return E_NOT_SUPPORT;
673 }
674 
RegisterAlgo(const std::string & clstAlgoName,ClusterAlgoFunc func)675 int RdbStore::RegisterAlgo(const std::string &clstAlgoName, ClusterAlgoFunc func)
676 {
677     (void)func;
678     (void)clstAlgoName;
679     return E_NOT_SUPPORT;
680 }
681 } // namespace OHOS::NativeRdb