1 /* 2 * Copyright (c) 2022 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 #ifndef NATIVE_RDB_RDB_STORE_H 17 #define NATIVE_RDB_RDB_STORE_H 18 19 #include <memory> 20 #include <stdint.h> 21 #include <string> 22 #include <vector> 23 24 #include "abs_rdb_predicates.h" 25 #include "abs_shared_result_set.h" 26 #include "rdb_common.h" 27 #include "rdb_errno.h" 28 #include "rdb_store_config.h" 29 #include "rdb_types.h" 30 #include "result_set.h" 31 #include "transaction.h" 32 #include "value_object.h" 33 #include "values_bucket.h" 34 #include "values_buckets.h" 35 36 namespace OHOS::NativeRdb { 37 class API_EXPORT RdbStore { 38 public: 39 /** 40 * @brief Use SyncOption replace DistributedRdb::SyncOption namespace. 41 */ 42 using SyncOption = DistributedRdb::SyncOption; 43 44 /** 45 * @brief Use AsyncBrief replace DistributedRdb::AsyncBrief namespace. 46 */ 47 using Briefs = DistributedRdb::Briefs; 48 using AsyncBrief = DistributedRdb::AsyncBrief; 49 50 /** 51 * @brief Use AsyncBrief replace DistributedRdb::AsyncBrief namespace. 52 */ 53 using Details = DistributedRdb::Details; 54 using AsyncDetail = DistributedRdb::AsyncDetail; 55 56 /** 57 * @brief Use SubscribeMode replace DistributedRdb::SubscribeMode namespace. 58 */ 59 using SubscribeMode = DistributedRdb::SubscribeMode; 60 61 /** 62 * @brief Use SubscribeOption replace DistributedRdb::SubscribeOption namespace. 63 */ 64 using SubscribeOption = DistributedRdb::SubscribeOption; 65 66 /** 67 * @brief Use DropOption replace DistributedRdb::DropOption namespace. 68 */ 69 using DropOption = DistributedRdb::DropOption; 70 71 /** 72 * @brief Use RdbStoreObserver replace DistributedRdb::RdbStoreObserver namespace. 73 */ 74 using RdbStoreObserver = DistributedRdb::RdbStoreObserver; 75 using PRIKey = RdbStoreObserver::PrimaryKey; 76 77 /** 78 * @brief Use RdbSyncObserver replace DistributedRdb::RdbSyncObserver namespace. 79 */ 80 using DetailProgressObserver = DistributedRdb::DetailProgressObserver; 81 82 /** 83 * @brief Use Date replace DistributedRdb::Date namespace. 84 */ 85 using Date = DistributedRdb::Date; 86 87 /** 88 * @brief Use Fields replace std::vector<std::string> columns. 89 */ 90 using Fields = std::vector<std::string>; 91 92 /** 93 * @brief Use Olds replace std::vector<std::string> args. 94 */ 95 using Olds = std::vector<std::string>; 96 97 /** 98 * @brief Use Values replace std::vector<ValueObject> args. 99 */ 100 using Values = std::vector<ValueObject>; 101 102 /** 103 * @brief Use Row replace ValuesBucket. 104 */ 105 using Row = ValuesBucket; 106 107 /** 108 * @brief Use Rows replace std::vector<Row>. 109 */ 110 using Rows = std::vector<Row>; 111 112 /** 113 * @brief Use Rows replace std::vector<Row>. 114 */ 115 using RefRows = ValuesBuckets; 116 117 /** 118 * @brief Use Resolution replace ConflictResolution. 119 */ 120 using Resolution = ConflictResolution; 121 122 class API_EXPORT ModifyTime { 123 public: 124 ModifyTime() = default; 125 API_EXPORT ModifyTime(std::shared_ptr<ResultSet> result, std::map<std::vector<uint8_t>, PRIKey> hashKeys, 126 bool isFromRowId); 127 API_EXPORT operator std::map<PRIKey, Date>(); 128 API_EXPORT operator std::shared_ptr<ResultSet>(); 129 API_EXPORT PRIKey GetOriginKey(const std::vector<uint8_t> &hash); 130 API_EXPORT size_t GetMaxOriginKeySize(); 131 API_EXPORT bool NeedConvert() const; 132 133 private: 134 std::shared_ptr<ResultSet> result_; 135 std::map<std::vector<uint8_t>, PRIKey> hash_; 136 size_t maxOriginKeySize_ = sizeof(int64_t); 137 bool isFromRowId_{ false }; 138 }; 139 140 static constexpr Resolution NO_ACTION = ConflictResolution::ON_CONFLICT_NONE; 141 142 /** 143 * @brief Destructor. 144 */ 145 virtual ~RdbStore() = default; 146 147 /** 148 * @brief Inserts a row of data into the target table. 149 * 150 * @param table Indicates the target table. 151 * @param row Indicates the row of data {@link ValuesBucket} to be inserted into the table. 152 * @param resolution Indicates the {@link ConflictResolution} to insert data into the table. 153 */ 154 virtual std::pair<int, int64_t> Insert(const std::string &table, const Row &row, Resolution resolution = NO_ACTION); 155 156 /** 157 * @brief Inserts a row of data into the target table. 158 * 159 * @param table Indicates the target table. 160 * @param row Indicates the row of data {@link ValuesBucket} to be inserted into the table. 161 */ 162 virtual int Insert(int64_t &outRowId, const std::string &table, const Row &row); 163 164 /** 165 * @brief Inserts a row of data into the target table. 166 * 167 * @param table Indicates the target table. 168 * @param row Indicates the row of data {@link ValuesBucket} to be inserted into the table. 169 * @param resolution Indicates the {@link ConflictResolution} to insert data into the table. 170 */ 171 [[deprecated("Use Insert(const std::string &, const Row &, Resolution) instead.")]] 172 virtual int InsertWithConflictResolution(int64_t &outRowId, const std::string &table, const Row &row, 173 Resolution resolution = NO_ACTION); 174 175 /** 176 * @brief Replaces a row of data into the target table. 177 * 178 * @param table Indicates the target table. 179 * @param row Indicates the row of data {@link ValuesBucket} to be replaced into the table. 180 */ 181 virtual int Replace(int64_t &outRowId, const std::string &table, const Row &row); 182 183 /** 184 * @brief Inserts a batch of data into the target table. 185 * 186 * @param table Indicates the target table. 187 * @param rows Indicates the rows of data {@link ValuesBucket} to be inserted into the table. 188 */ 189 virtual int BatchInsert(int64_t &outInsertNum, const std::string &table, const Rows &rows); 190 191 /** 192 * @brief Inserts a batch of data into the target table. 193 * 194 * @param table Indicates the target table. 195 * @param values Indicates the rows of data {@link ValuesBuckets} to be inserted into the table. 196 */ 197 virtual std::pair<int, int64_t> BatchInsert(const std::string &table, const RefRows &rows); 198 199 /** 200 * @brief Updates data in the database based on specified conditions. 201 * 202 * @param table Indicates the target table. 203 * @param row Indicates the row of data to be updated in the database. 204 * The key-value pairs are associated with column names of the database table. 205 * @param whereClause Indicates the where clause. 206 * @param args Indicates the where arguments. 207 */ 208 virtual std::pair<int, int> Update(const std::string &table, const Row &row, const std::string &where = "", 209 const Values &args = {}, Resolution resolution = NO_ACTION); 210 211 /** 212 * @brief Updates data in the database based on specified conditions. 213 * 214 * @param table Indicates the target table. 215 * @param row Indicates the row of data to be updated in the database. 216 * The key-value pairs are associated with column names of the database table. 217 * @param whereClause Indicates the where clause. 218 * @param args Indicates the where arguments. 219 */ 220 virtual int Update(int &changedRows, const std::string &table, const Row &row, const std::string &whereClause = "", 221 const Values &args = {}); 222 223 /** 224 * @brief Updates data in the database based on a a specified instance object of AbsRdbPredicates. 225 * 226 * @param values Indicates the row of data to be updated in the database. 227 * The key-value pairs are associated with column names of the database table. 228 * @param predicates Indicates the specified update condition by the instance object of {@link AbsRdbPredicates}. 229 */ 230 virtual int Update(int &changedRows, const Row &row, const AbsRdbPredicates &predicates); 231 232 /** 233 * @brief Updates data in the database based on specified conditions. 234 * 235 * @param table Indicates the target table. 236 * @param row Indicates the row of data to be updated in the database. 237 * The key-value pairs are associated with column names of the database table. 238 * @param whereClause Indicates the where clause. 239 * @param args Indicates the where arguments. 240 */ 241 [[deprecated("Use Update(int &, const std::string &, const Row &, const std::string &, const Values &) instead.")]] 242 virtual int Update(int &changedRows, const std::string &table, const Row &row, const std::string &whereClause, 243 const Olds &args); 244 245 /** 246 * @brief Updates data in the database based on a a specified instance object of RdbPredicates. 247 * 248 * @param table Indicates the target table. 249 * @param row Indicates the row of data to be updated in the database. 250 * The key-value pairs are associated with column names of the database table. 251 * @param whereClause Indicates the where clause. 252 * @param args Indicates the where arguments. 253 * @param resolution Indicates the {@link ConflictResolution} to insert data into the table. 254 */ 255 [[deprecated("Use UpdateWithConflictResolution(int &, const std::string &, const Row &, const std::string &, " 256 "const Values &, ConflictResolution conflictResolution) instead.")]] 257 virtual int UpdateWithConflictResolution(int &changedRows, const std::string &table, const Row &row, 258 const std::string &whereClause, const Olds &args, Resolution resolution = NO_ACTION); 259 260 /** 261 * @brief Updates data in the database based on a a specified instance object of RdbPredicates. 262 * 263 * @param table Indicates the target table. 264 * @param row Indicates the row of data to be updated in the database. 265 * The key-value pairs are associated with column names of the database table. 266 * @param whereClause Indicates the where clause. 267 * @param args Indicates the where arguments. 268 * @param resolution Indicates the {@link ConflictResolution} to update data into the table. 269 */ 270 virtual int UpdateWithConflictResolution(int &changedRows, const std::string &table, const Row &row, 271 const std::string &whereClause = "", const Values &args = {}, Resolution resolution = NO_ACTION); 272 273 /** 274 * @brief Deletes data from the database based on specified conditions. 275 * 276 * @param table Indicates the target table. 277 * @param whereClause Indicates the where clause. 278 * @param args Indicates the where arguments. 279 */ 280 [[deprecated("Use Delete(int &, const std::string &, const std::string &, const Values &) instead.")]] 281 virtual int Delete(int &deletedRows, const std::string &table, const std::string &whereClause, 282 const Olds &args); 283 284 /** 285 * @brief Deletes data from the database based on a specified instance object of AbsRdbPredicates. 286 * 287 * @param predicates Indicates the specified update condition by the instance object of {@link AbsRdbPredicates}. 288 */ 289 virtual int Delete(int &deletedRows, const AbsRdbPredicates &predicates); 290 291 /** 292 * @brief Deletes data from the database based on specified conditions. 293 * 294 * @param table Indicates the target table. 295 * @param whereClause Indicates the where clause. 296 * @param args Indicates the where arguments. 297 */ 298 virtual int Delete(int &deletedRows, const std::string &table, const std::string &whereClause = "", 299 const Values &args = {}) = 0; 300 301 /** 302 * @brief Queries data in the database based on specified conditions. 303 * 304 * @param distinct Indicates whether to eliminate all duplicate records in the result set. 305 * @param table Indicates the target table. 306 * @param columns Indicates the columns to query. If the value is empty array, the query applies to all columns. 307 * @param whereClause Indicates the selection. 308 * @param args Indicates the selection arguments. 309 * @param groupBy Indicates the groupBy argument. 310 * @param indexName Indicates the index by argument. 311 * @param orderBy Indicates the orderBy argument. 312 * @param limit Indicates the limit argument. 313 */ 314 [[deprecated("Use Query(int &, const std::string &, const std::string &, const Values &) instead.")]] 315 virtual std::shared_ptr<AbsSharedResultSet> Query(int &errCode, bool distinct, const std::string &table, 316 const Fields &columns, const std::string &whereClause = "", const Values &args = {}, 317 const std::string &groupBy = "", const std::string &indexName = "", const std::string &orderBy = "", 318 const int &limit = AbsPredicates::INIT_LIMIT_VALUE, const int &offset = AbsPredicates::INIT_LIMIT_VALUE); 319 320 /** 321 * @brief Queries data in the database based on specified conditions. 322 * 323 * @param predicates Indicates the specified query condition by the instance object of {@link AbsRdbPredicates}. 324 * @param columns Indicates the columns to query. If the value is empty array, the query applies to all columns. 325 */ 326 virtual std::shared_ptr<AbsSharedResultSet> Query(const AbsRdbPredicates &predicates, const Fields &columns = {}); 327 328 /** 329 * @brief Queries data in the database based on SQL statement. 330 * 331 * @param sql Indicates the SQL statement to execute. 332 * @param args Indicates the selection arguments. 333 */ 334 [[deprecated("Use QuerySql(const std::string &, const Values &) instead.")]] 335 virtual std::shared_ptr<AbsSharedResultSet> QuerySql(const std::string &sql, const Olds &args); 336 337 /** 338 * @brief Queries data in the database based on SQL statement. 339 * 340 * @param sql Indicates the SQL statement to execute. 341 * @param args Indicates the selection arguments. 342 */ 343 virtual std::shared_ptr<AbsSharedResultSet> QuerySql(const std::string &sql, const Values &args = {}) = 0; 344 345 /** 346 * @brief Queries data in the database based on SQL statement. 347 * 348 * @param sql Indicates the SQL statement to execute. 349 * @param args Indicates the selection arguments. 350 */ 351 [[deprecated("Use QueryByStep(const std::string &, const Values &) instead.")]] 352 virtual std::shared_ptr<ResultSet> QueryByStep(const std::string &sql, const Olds &args); 353 354 /** 355 * @brief Queries data in the database based on SQL statement. 356 * 357 * @param sql Indicates the SQL statement to execute. 358 * @param args Indicates the selection arguments. 359 */ 360 virtual std::shared_ptr<ResultSet> QueryByStep(const std::string &sql, const Values &args = {}) = 0; 361 362 /** 363 * @brief Queries data in the database based on specified conditions. 364 * 365 * @param predicates Indicates the specified query condition by the instance object of {@link AbsRdbPredicates}. 366 * @param columns Indicates the columns to query. If the value is empty array, the query applies to all columns. 367 */ 368 virtual std::shared_ptr<ResultSet> QueryByStep(const AbsRdbPredicates &predicates, const Fields &columns = {}); 369 370 /** 371 * @brief Queries remote data in the database based on specified conditions before Synchronizing Data. 372 * 373 * @param device Indicates specified remote device. 374 * @param predicates Indicates the specified query condition by the instance object of {@link AbsRdbPredicates}. 375 * @param columns Indicates the columns to query. If the value is empty array, the query applies to all columns. 376 */ 377 virtual std::shared_ptr<ResultSet> RemoteQuery(const std::string &device, const AbsRdbPredicates &predicates, 378 const Fields &columns, int &errCode); 379 380 /** 381 * @brief Queries data in the database based on specified conditions. 382 * 383 * @param predicates Indicates the specified query condition by the instance object of {@link AbsRdbPredicates}. 384 * @param columns Indicates the columns to query. If the value is empty array, the query applies to all columns. 385 */ 386 virtual std::pair<int32_t, std::shared_ptr<ResultSet>> QuerySharingResource(const AbsRdbPredicates &predicates, 387 const Fields &columns); 388 389 /** 390 * @brief Executes an SQL statement that contains specified parameters. 391 * 392 * @param sql Indicates the SQL statement to execute. 393 * @param args Indicates the {@link ValueObject} values of the parameters in the SQL statement. 394 */ 395 [[deprecated("Use Execute(const std::string &, const Values &, int64_t) instead.")]] 396 virtual int ExecuteSql(const std::string &sql, const Values &args = {}); 397 398 /** 399 * @brief Executes an SQL statement that contains specified parameters and 400 * get two values of type int and ValueObject. 401 * 402 * @param sql Indicates the SQL statement to execute. 403 * @param args Indicates the {@link ValueObject} values of the parameters in the SQL statement. 404 */ 405 virtual std::pair<int32_t, ValueObject> Execute(const std::string &sql, const Values &args = {}, int64_t trxId = 0); 406 407 /** 408 * @brief Executes an SQL statement that contains specified parameters and get a long integer value. 409 * 410 * @param sql Indicates the SQL statement to execute. 411 * @param args Indicates the {@link ValueObject} values of the parameters in the SQL statement. 412 */ 413 [[deprecated("Use Execute(const std::string &, const Values &, int64_t) instead.")]] 414 virtual int ExecuteAndGetLong(int64_t &outValue, const std::string &sql, const Values &args = {}); 415 416 /** 417 * @brief Executes an SQL statement that contains specified parameters. 418 * 419 * @param sql Indicates the SQL statement to execute. 420 * @param args Indicates the {@link ValueObject} values of the parameters in the SQL statement. 421 */ 422 [[deprecated("Use Execute(const std::string &, const Values &, int64_t) instead.")]] 423 virtual int ExecuteAndGetString(std::string &outValue, const std::string &sql, const Values &args = {}); 424 425 /** 426 * @brief Executes for last insert row id that contains specified parameters. 427 * 428 * @param sql Indicates the SQL statement to execute. 429 * @param args Indicates the {@link ValueObject} values of the parameters in the SQL statement. 430 */ 431 virtual int ExecuteForLastInsertedRowId(int64_t &outValue, const std::string &sql, const Values &args = {}); 432 433 /** 434 * @brief Executes for change row count that contains specified parameters. 435 * 436 * @param sql Indicates the SQL statement to execute. 437 * @param args Indicates the {@link ValueObject} values of the parameters in the SQL statement. 438 */ 439 virtual int ExecuteForChangedRowCount(int64_t &outValue, const std::string &sql, const Values &args = {}); 440 441 /** 442 * @brief Restores a database from a specified encrypted or unencrypted database file. 443 * 444 * @param databasePath Indicates the database file path. 445 * @param encryptKey Indicates the database encrypt key. 446 */ 447 virtual int Backup(const std::string &databasePath, const std::vector<uint8_t> &encryptKey = {}); 448 449 /** 450 * @brief Attaches a database. 451 * 452 * @param alias Indicates the database alias. 453 * @param pathName Indicates the database file pathname. 454 * @param destEncryptKey Indicates the database encrypt key. 455 */ 456 [[deprecated("Use Attach(const RdbStoreConfig &, const std::string &, int32_t) instead.")]] 457 virtual int Attach(const std::string &alias, const std::string &pathName, const std::vector<uint8_t> encryptKey); 458 459 /** 460 * @brief Get the value of the column based on specified conditions. 461 * 462 * @param predicates Indicates the {@link AbsRdbPredicates} AbsRdbPredicates object. 463 */ 464 virtual int Count(int64_t &outValue, const AbsRdbPredicates &predicates); 465 466 /** 467 * @brief Gets the version of the database. 468 */ 469 virtual int GetVersion(int &version) = 0; 470 471 /** 472 * @brief Sets the version of a new database. 473 */ 474 virtual int SetVersion(int version) = 0; 475 476 /** 477 * @brief Create a transaction of a new database connection. 478 */ 479 virtual std::pair<int32_t, std::shared_ptr<Transaction>> CreateTransaction(int32_t type); 480 481 /** 482 * @brief Begins a transaction in EXCLUSIVE mode. 483 */ 484 [[deprecated("Use CreateTransaction(int32_t) instead.")]] 485 virtual int BeginTransaction(); 486 virtual std::pair<int, int64_t> BeginTrans(); 487 488 /** 489 * @brief Rollback a transaction in EXCLUSIVE mode. 490 */ 491 [[deprecated("Use CreateTransaction(int32_t) instead.")]] 492 virtual int RollBack(); 493 virtual int RollBack(int64_t trxId); 494 495 /** 496 * @brief Commit a transaction in EXCLUSIVE mode. 497 */ 498 [[deprecated("Use CreateTransaction(int32_t) instead.")]] 499 virtual int Commit(); 500 virtual int Commit(int64_t trxId); 501 502 /** 503 * @brief Check the current connection is in transaction. 504 */ 505 virtual bool IsInTransaction(); 506 507 /** 508 * @brief Get database path. 509 */ 510 virtual std::string GetPath(); 511 512 /** 513 * @brief Check the current connection pool is holding connection. 514 */ 515 virtual bool IsHoldingConnection(); 516 517 /** 518 * @brief Check the current database is open. 519 */ 520 virtual bool IsOpen() const; 521 522 /** 523 * @brief Check the current database is read only. 524 */ 525 virtual bool IsReadOnly() const; 526 527 /** 528 * @brief Check the current database is memory database. 529 */ 530 virtual bool IsMemoryRdb() const; 531 532 /** 533 * @brief Restores a database from a specified database file. 534 * 535 * @param backupPath Indicates the name that saves the database file path. 536 * @param newKey Indicates the database new key. 537 */ 538 virtual int Restore(const std::string &backupPath, const std::vector<uint8_t> &newKey = {}); 539 540 /** 541 * @brief Set table to be distributed table. 542 * 543 * @param tables Indicates the tables name you want to set. 544 */ 545 virtual int SetDistributedTables(const std::vector<std::string> &tables, 546 int32_t type = DistributedRdb::DistributedTableType::DISTRIBUTED_DEVICE, 547 const DistributedRdb::DistributedConfig &distributedConfig = { true }); 548 549 /** 550 * @brief Obtain distributed table name of specified remote device according to local table name. 551 * When query remote device database, distributed table name is needed. 552 * 553 * @param device Indicates the remote device. 554 * 555 * @return Returns the distributed table name. 556 */ 557 virtual std::string ObtainDistributedTableName(const std::string &device, const std::string &table, int &errCode); 558 559 /** 560 * @brief Sync data between devices or cloud. 561 * 562 * @param device Indicates the remote device. 563 * @param predicate Indicates the AbsRdbPredicates {@link AbsRdbPredicates} object. 564 */ 565 virtual int Sync(const SyncOption &option, const AbsRdbPredicates &predicate, const AsyncBrief &async); 566 567 /** 568 * @brief Sync data between devices or cloud. 569 * 570 * @param device Indicates the remote device. 571 * @param predicate Indicates the AbsRdbPredicates {@link AbsRdbPredicates} object. 572 */ 573 virtual int Sync(const SyncOption &option, const std::vector<std::string> &tables, const AsyncDetail &async); 574 575 /** 576 * @brief Sync data between devices or cloud. 577 * 578 * @param device Indicates the remote device. 579 * @param predicate Indicates the AbsRdbPredicates {@link AbsRdbPredicates} object. 580 */ 581 virtual int Sync(const SyncOption &option, const AbsRdbPredicates &predicate, const AsyncDetail &async); 582 583 /** 584 * @brief Subscribe to event changes. 585 */ 586 virtual int Subscribe(const SubscribeOption& option, RdbStoreObserver *observer); 587 588 /** 589 * @brief UnSubscribe to event changes. 590 */ 591 virtual int UnSubscribe(const SubscribeOption& option, RdbStoreObserver *observer); 592 593 /** 594 * @brief SubscribeObserver to event changes. 595 */ 596 virtual int SubscribeObserver(const SubscribeOption& option, const std::shared_ptr<RdbStoreObserver> &observer); 597 598 /** 599 * @brief UnsubscribeObserver to event changes. 600 */ 601 virtual int UnsubscribeObserver(const SubscribeOption& option, const std::shared_ptr<RdbStoreObserver> &observer); 602 603 /** 604 * @brief Register message for auto sync operation. 605 */ 606 virtual int RegisterAutoSyncCallback(std::shared_ptr<DetailProgressObserver> observer); 607 608 /** 609 * @brief UnRegister message for auto sync operation. 610 */ 611 virtual int UnregisterAutoSyncCallback(std::shared_ptr<DetailProgressObserver> observer); 612 613 /** 614 * @brief When SubscribeMode is LOCAL or LOCALSHARED, this function needs to be called to trigger callback. 615 */ 616 virtual int Notify(const std::string &event); 617 618 /** 619 * @brief Check the slave database is different from current database. 620 */ 621 virtual bool IsSlaveDiffFromMaster() const; 622 623 virtual int32_t GetDbType() const; 624 625 virtual std::pair<int32_t, uint32_t> LockCloudContainer(); 626 627 virtual int32_t UnlockCloudContainer(); 628 629 virtual int InterruptBackup(); 630 631 virtual int32_t GetBackupStatus() const; 632 633 /** 634 * @brief Get the the specified column modify time. 635 * 636 * @param table Indicates the specified table. 637 * @param column Indicates the column. 638 * @param keys Indicates the primary key. 639 * 640 * @return Returns the specified column modify time. 641 */ 642 virtual ModifyTime GetModifyTime(const std::string &table, const std::string &column, std::vector<PRIKey> &keys); 643 644 /** 645 * @brief Cleans dirty data deleted in the cloud. 646 * 647 * If a cursor is specified, data with a cursor smaller than the specified cursor will be cleaned up. 648 * otherwise clean all. 649 * 650 * @param table Indicates the specified table. 651 */ 652 virtual int CleanDirtyData(const std::string &table, uint64_t cursor = UINT64_MAX); 653 654 /** 655 * @brief Gets the rebuilt_ status of the database. 656 */ 657 virtual int GetRebuilt(RebuiltType &rebuilt); 658 659 /** 660 * @brief Attaches a database file to the currently linked database. 661 * 662 * @param config Indicates the {@link RdbStoreConfig} configuration of the database related to this RDB store. 663 * @param attachName Indicates the alias of the database. 664 * @param waitTime Indicates the maximum time allowed for attaching the database file. 665 */ 666 virtual std::pair<int32_t, int32_t> Attach( 667 const RdbStoreConfig &config, const std::string &attachName, int32_t waitTime = 2); 668 669 /** 670 * @brief Detaches a database from this database. 671 * 672 * @param attachName Indicates the alias of the database. 673 * @param waitTime Indicates the maximum time allowed for attaching the database file. 674 */ 675 virtual std::pair<int32_t, int32_t> Detach(const std::string &attachName, int32_t waitTime = 2); 676 677 /** 678 * @brief Locks/Unlocks data from the database based on a specified instance object of AbsRdbPredicates. 679 * 680 * @param predicates Indicates the specified update condition by the instance object of {@link AbsRdbPredicates}. 681 */ 682 virtual int ModifyLockStatus(const AbsRdbPredicates &predicates, bool isLock); 683 684 /** 685 * @brief Set search enable or disable. 686 * 687 * @param isSearchable Indicates enable or disable. 688 */ 689 virtual int SetSearchable(bool isSearchable); 690 691 protected: 692 virtual std::string GetLogTableName(const std::string &tableName); 693 }; 694 } // namespace OHOS::NativeRdb 695 #endif 696