diff --git a/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h b/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h index e588c5fd65e4633671dcc911a283f9a79aed7b41..a631122e4fb68f5c0d4ceefb8e27b666aa0570d4 100644 --- a/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h +++ b/datamgr_service/services/distributeddataservice/framework/include/store/cursor.h @@ -46,6 +46,8 @@ public: virtual int32_t Get(const std::string &col, Value &value) = 0; virtual int32_t Close() = 0; + + virtual bool IsEnd() = 0; }; } // namespace OHOS::DistributedData #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_STORE_CURSOR_H diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp index e0ee3e9fd848506bb2e7c8ca39acb3abbd6b5830..8929f73f79a7f8dbc0309cb6f85b03a392370d7f 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cloud.cpp @@ -71,13 +71,17 @@ DBStatus RdbCloud::Query(const std::string &tableName, DBVBucket &extend, std::v err = cursor->MoveToNext(); count--; } + if (cursor->IsEnd()) { + ZLOGD("query end, table:%{public}s", tableName.c_str()); + return DBStatus::QUERY_END; + } return ConvertStatus(static_cast(err)); } std::pair RdbCloud::Lock() { auto error = cloudDB_->Lock(); - return std::make_pair(ConvertStatus(static_cast(error)), 0); + return std::make_pair(ConvertStatus(static_cast(error)), cloudDB_->AliveTime() * 1000); // int64_t <-> uint32_t, s <-> ms } DBStatus RdbCloud::UnLock() diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp index c0baf75eaf024e610c89db3fcd0e581f5529e94d..619e7d3a7baba2a767f9c41490822216cf0f40b8 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.cpp @@ -102,4 +102,9 @@ int32_t RdbCursor::Close() { return resultSet_->Close(); } + +bool RdbCursor::IsEnd() +{ + return false; +} } // namespace OHOS::DistributedRdb diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h index f51a44929b42dded4a2cc3d9eba62c0a9a18a8ea..dd184d49edcab33eec31ae8e798db18e77d94c83 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_cursor.h @@ -33,6 +33,7 @@ public: int32_t Get(int32_t col, DistributedData::Value &value) override; int32_t Get(const std::string &col, DistributedData::Value &value) override; int32_t Close() override; + bool IsEnd() override; private: std::shared_ptr resultSet_; diff --git a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp index c69cb9f714a03d1a90a066ffd874be0317b0a24c..87049d11679196bd3dcebae0ca346c0fed1c2a8b 100644 --- a/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp +++ b/datamgr_service/services/distributeddataservice/service/rdb/rdb_general_store.cpp @@ -140,6 +140,7 @@ int32_t RdbGeneralStore::Close() bindInfo_.loader_ = nullptr; bindInfo_.db_->Close(); bindInfo_.db_ = nullptr; + rdbCloud_ = nullptr; return 0; }