diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/document_type.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/document_type.h index ff525ecbd6d13eab66edd89a2ce53c3b81cc3286..0c767b9aed79fd14136cfdbea0e9c33f38e475c3 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/document_type.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/common/include/document_type.h @@ -28,7 +28,7 @@ struct QueryContext { ProjectionTree projectionTree; bool ifShowId = false; bool viewType = false; - bool isOnlyId = false; + bool isIdExist = false; }; } // namespace DocumentDB #endif // DOCUMENT_TYPE_H \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp index 01513f9f83652c107f714e2e1e4e41d288db0c66..fb87a9aa3c3b566038575b14df9a6145f8f594cf 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.cpp @@ -75,7 +75,7 @@ bool CheckCommon::CheckCollectionName(const std::string &collectionName, std::st return true; } -int CheckCommon::CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector> &filterPath) +int CheckCommon::CheckFilter(JsonObject &filterObj, std::vector> &filterPath, bool &isIdExist) { for (size_t i = 0; i < filterPath.size(); i++) { if (filterPath[i].size() > JSON_DEEP_MAX) { @@ -83,9 +83,6 @@ int CheckCommon::CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector< return -E_INVALID_ARGS; } } - if (!filterObj.GetChild().GetNext().IsNull()) { // check contained other field at the same level as the id node - isOnlyId = false; - } for (size_t i = 0; i < filterPath.size(); i++) { if (filterPath[i].empty()) { return -E_INVALID_JSON_FORMAT; @@ -104,15 +101,11 @@ int CheckCommon::CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector< return -E_INVALID_ARGS; } } - bool isIdExisit = false; - int ret = CheckIdFormat(filterObj, isIdExisit); + int ret = CheckIdFormat(filterObj, isIdExist); if (ret != E_OK) { GLOGE("Filter Id format is illegal"); return ret; } - if (!isIdExisit) { - isOnlyId = false; - } return E_OK; } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.h index 2985bd679b8acbd9e09a3d73d6a282cb3f7dda73..18a01c64519d3c836799dbb4e441825e0b859001 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/executor/document/check_common.h @@ -29,10 +29,10 @@ public: ~CheckCommon() = default; static bool CheckCollectionName(const std::string &collectionName, std::string &formattedName, int &errCode); - static int CheckFilter(JsonObject &filterObj, bool &isOnlyId, std::vector> &filterPath); - static int CheckIdFormat(JsonObject &filterJson, bool &isIdExisit); - static int CheckDocument(JsonObject &documentObj); - static int CheckUpdata(JsonObject &updataObj, std::vector> &path); + static int CheckFilter(JsonObject &document, std::vector> &filterPath, bool &isIdExist); + static int CheckIdFormat(JsonObject &data, bool &isIdExisit); + static int CheckDocument(JsonObject &document); + static int CheckUpdata(JsonObject &updata, std::vector> &path); static int CheckProjection(JsonObject &projectionObj, std::vector> &path); }; using Key = std::vector; diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/collection.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/collection.h index c04f5c7b9007ae17bd1e9b3f975dc6e2eeafb7a1..33158c5e7f2c7a092e143d1d2349768872431177 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/collection.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/collection.h @@ -26,16 +26,17 @@ class Collection { public: Collection(const std::string &name, KvStoreExecutor *executor); Collection(const Collection &other); - Collection() {}; + Collection(){}; ~Collection(); int PutDocument(const Key &key, const Value &document); int InsertDocument(const Key &key, const Value &document); - int GetDocument(const Key &key, Value &document) const; - int GetMatchedDocument(const JsonObject &filterObj, std::vector> &values) const; + int GetDocumentByKey(const Key &key, Value &document) const; + int GetMatchedDocument(const JsonObject &filterObj, const Key &key, std::pair &values, + int isIdExist) const; int DeleteDocument(const Key &key); int IsCollectionExists(int &errCode); - int UpsertDocument(const std::string &id, const std::string &document, bool isReplace = true); + int UpsertDocument(const std::string &id, const std::string &newStr, bool isReplace = true); bool FindDocument(); int UpdateDocument(const std::string &id, const std::string &document, bool isReplace = false); diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/document_store.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/document_store.h index cefdc9e308305435398eaf9b256ecb24bcece392..3437d8ca0d4da139d698fafebf18a7f6e639af29 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/document_store.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/document_store.h @@ -69,13 +69,11 @@ public: private: int UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &update, bool &isReplace); - int UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, JsonObject &documentObj, - bool &isReplace); + int UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &document, + JsonObject &documentObj, bool &isReplace); int InsertDataIntoDB(const std::string &collection, const std::string &document, JsonObject &documentObj); int DeleteDataFromDB(std::shared_ptr &context, JsonObject &filterObj); int InitFindResultSet(GRD_ResultSet *grdResultSet, std::shared_ptr &context); - int CheckUpsertConflict(bool &isIdExist, std::shared_ptr &context, JsonObject &filterObj, - std::string &docId, Collection &coll); KvStoreExecutor *executor_ = nullptr; std::map collections_; std::function closeNotifier_; diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set.h index 65956e090968ca6d263ae318ec4f3c6d499ce1dc..1191c54579b1cc4be8a24bbd70811d5370bfb483 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set.h @@ -30,9 +30,10 @@ class ResultSet { public: ResultSet(); ~ResultSet(); - int Init(std::shared_ptr &context, DocumentStore *store, bool ifField); + int Init(std::shared_ptr &context, DocumentStore *store, bool isCutBranch); int GetNext(bool isNeedTransaction = false, bool isNeedCheckTable = false); int GetValue(char **value); + int GetValue(std::string &value); int GetKey(std::string &key); int EraseCollection(); @@ -44,10 +45,11 @@ private: int GetNextWithField(); DocumentStore *store_ = nullptr; - bool ifField_ = false; + bool isCutBranch_ = false; size_t index_ = 0; std::shared_ptr context_; - std::vector> matchDatas_; + std::pair matchData_; + std::string lastKeyIndex_; }; } // namespace DocumentDB #endif // RESULTSET_H \ No newline at end of file diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set_common.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set_common.h index 0a59f9ffd8ad2962189db64cc468f5d44a0ad85d..abdf5c9b3ce66af2c112ed19fc54bb3fec633915 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set_common.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/include/result_set_common.h @@ -25,6 +25,6 @@ namespace DocumentDB { class ValueObject; -int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool ifField); +int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch); } // namespace DocumentDB #endif // RESULTSET_COMMON_H diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp index 1e6d04f2521cdfdb1dbccbc154f163353ff922fe..88887ff683250a0aed846fa155260cbbefc08187 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/collection.cpp @@ -76,21 +76,21 @@ bool Collection::FindDocument() return executor_->IsCollectionExists(name_, errCode); } -int Collection::GetDocument(const Key &key, Value &document) const +int Collection::GetDocumentByKey(const Key &key, Value &document) const { if (executor_ == nullptr) { return -E_INNER_ERROR; } - return executor_->GetData(name_, key, document); + return executor_->GetDataByKey(name_, key, document); } -int Collection::GetMatchedDocument(const JsonObject &filterObj, - std::vector> &values) const +int Collection::GetMatchedDocument(const JsonObject &filterObj, const Key &key, + std::pair &values, int isIdExist) const { if (executor_ == nullptr) { return -E_INNER_ERROR; } - return executor_->GetFieldedData(name_, filterObj, values); + return executor_->GetDataByFilter(name_, key, filterObj, values, isIdExist); } int Collection::DeleteDocument(const Key &key) @@ -114,7 +114,7 @@ int Collection::IsCollectionExists(int &errCode) return executor_->IsCollectionExists(name_, errCode); } -int Collection::UpsertDocument(const std::string &id, const std::string &document, bool isReplace) +int Collection::UpsertDocument(const std::string &id, const std::string &newStr, bool isReplace) { if (executor_ == nullptr) { return -E_INNER_ERROR; @@ -129,47 +129,12 @@ int Collection::UpsertDocument(const std::string &id, const std::string &documen GLOGE("Collection not created."); return -E_INVALID_ARGS; } - - JsonObject upsertValue = JsonObject::Parse(document, errCode, true); - if (errCode != E_OK) { - GLOGD("Parse upsert value failed. %d", errCode); - return errCode; - } - Key keyId(id.begin(), id.end()); - Value valSet(document.begin(), document.end()); - if (!isReplace) { - Value valueGot; - errCode = executor_->GetData(name_, keyId, valueGot); - std::string valueGotStr = std::string(valueGot.begin(), valueGot.end()); - if (errCode != E_OK && errCode != -E_NOT_FOUND) { - GLOGW("Get original document failed. %d", errCode); - return errCode; - } else if (errCode == E_OK) { // document has been inserted - GLOGD("Document has been inserted, append value."); - JsonObject originValue = JsonObject::Parse(valueGotStr, errCode, true); - if (errCode != E_OK) { - GLOGD("Parse original value failed. %d %s", errCode, valueGotStr.c_str()); - return errCode; - } - - errCode = JsonCommon::Append(originValue, upsertValue, isReplace); - if (errCode != E_OK) { - GLOGD("Append value failed. %d", errCode); - return errCode; - } - std::string valStr = originValue.Print(); - if (valStr.length() >= JSON_LENS_MAX) { - GLOGE("document's length is too long"); - return -E_OVER_LIMIT; - } - valSet = { valStr.begin(), valStr.end() }; - } - } + Value valSet(newStr.begin(), newStr.end()); return executor_->PutData(name_, keyId, valSet); } -int Collection::UpdateDocument(const std::string &id, const std::string &update, bool isReplace) +int Collection::UpdateDocument(const std::string &id, const std::string &newStr, bool isReplace) { if (executor_ == nullptr) { return -E_INNER_ERROR; @@ -184,40 +149,8 @@ int Collection::UpdateDocument(const std::string &id, const std::string &update, GLOGE("Collection not created."); return -E_INVALID_ARGS; } - - JsonObject updateValue = JsonObject::Parse(update, errCode, true); - if (errCode != E_OK) { - GLOGD("Parse upsert value failed. %d", errCode); - return errCode; - } - Key keyId(id.begin(), id.end()); - Value valueGot; - errCode = executor_->GetData(name_, keyId, valueGot); - std::string valueGotStr = std::string(valueGot.begin(), valueGot.end()); - if (errCode == -E_NOT_FOUND) { - GLOGW("Get original document not found."); - return -E_NOT_FOUND; - } else if (errCode != E_OK) { - GLOGE("Get original document failed. %d", errCode); - return errCode; - } - JsonObject originValue = JsonObject::Parse(valueGotStr, errCode, true); - if (errCode != E_OK) { - GLOGD("Parse original value failed. %d %s", errCode, valueGotStr.c_str()); - return errCode; - } - errCode = JsonCommon::Append(originValue, updateValue, isReplace); - if (errCode != E_OK) { - GLOGD("Append value failed. %d", errCode); - return errCode; - } - std::string valStr = originValue.Print(); - if (valStr.length() >= JSON_LENS_MAX) { - GLOGE("document's length is too long"); - return -E_OVER_LIMIT; - } - Value valSet(valStr.begin(), valStr.end()); + Value valSet(newStr.begin(), newStr.end()); return executor_->PutData(name_, keyId, valSet); } } // namespace DocumentDB diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp index cb1947eb1f12c6eef18f91932c972efe84e85e74..c8d99221ae0e0514b6c8c4dd265825d48c23e016 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/document_store.cpp @@ -43,7 +43,6 @@ int DocumentStore::CreateCollection(const std::string &name, const std::string & GLOGE("Check collection name invalid. %d", errCode); return errCode; } - errCode = E_OK; CollectionOption collOption = CollectionOption::ReadOption(option, errCode); if (errCode != E_OK) { @@ -128,7 +127,7 @@ END: return errCode; } -int TranFilter(JsonObject &filterObj, std::vector> &filterAllPath, bool &isOnlyId) +int TranFilter(JsonObject &filterObj, std::vector> &filterAllPath, bool &isIdExist) { int errCode = E_OK; filterAllPath = JsonCommon::ParsePath(filterObj, errCode); @@ -136,7 +135,7 @@ int TranFilter(JsonObject &filterObj, std::vector> &fil GLOGE("filter ParsePath failed"); return errCode; } - return CheckCommon::CheckFilter(filterObj, isOnlyId, filterAllPath); + return CheckCommon::CheckFilter(filterObj, filterAllPath, isIdExist); } int UpdateArgsCheck(const std::string &collection, const std::string &filter, const std::string &update, uint32_t flags) @@ -176,6 +175,41 @@ int UpdateArgsCheck(const std::string &collection, const std::string &filter, co return errCode; } +int GetUpDataRePlaceData(ResultSet &resultSet, const std::string &id, const std::string &update, std::string &valStr, + bool isReplace) +{ + std::string valueGotStr; + int errCode = resultSet.GetValue(valueGotStr); + if (errCode == -E_NO_DATA) { + GLOGW("Get original document not found."); + return -E_NOT_FOUND; + } else if (errCode != E_OK) { + GLOGE("Get original document failed. %d", errCode); + return errCode; + } + JsonObject updateValue = JsonObject::Parse(update, errCode, true); + if (errCode != E_OK) { + GLOGD("Parse upsert value failed. %d", errCode); + return errCode; + } + JsonObject originValue = JsonObject::Parse(valueGotStr, errCode, true); + if (errCode != E_OK) { + GLOGD("Parse original value failed. %d %s", errCode, valueGotStr.c_str()); + return errCode; + } + errCode = JsonCommon::Append(originValue, updateValue, isReplace); + if (errCode != E_OK) { + GLOGD("Append value failed. %d", errCode); + return errCode; + } + valStr = originValue.Print(); + if (valStr.length() >= JSON_LENS_MAX) { + GLOGE("document's length is too long"); + return -E_OVER_LIMIT; + } + return errCode; +} + int DocumentStore::UpdateDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, const std::string &update, bool &isReplace) { @@ -189,27 +223,28 @@ int DocumentStore::UpdateDataIntoDB(std::shared_ptr &context, Json } std::string docId; int count = 0; + std::string valStr; auto coll = Collection(context->collectionName, executor_); - if (context->isOnlyId) { - auto filterObjChild = filterObj.GetChild(); - auto idValue = JsonCommon::GetValueInSameLevel(filterObjChild, KEY_ID); - docId = idValue.GetStringValue(); - } else { - ResultSet resultSet; - std::string filter = filterObj.Print(); - InitResultSet(context, this, resultSet, true); - // no start transaction inner - errCode = resultSet.GetNext(false, true); - if (errCode == -E_NO_DATA) { - // no need to set count - errCode = E_OK; - goto END; - } else if (errCode != E_OK) { - goto END; - } - resultSet.GetKey(docId); + ResultSet resultSet; + errCode = InitResultSet(context, this, resultSet, false); + if (errCode != E_OK) { + goto END; + } + // no start transaction inner + errCode = resultSet.GetNext(false, true); + if (errCode == -E_NO_DATA) { + // no need to set count + errCode = E_OK; + goto END; + } else if (errCode != E_OK) { + goto END; + } + resultSet.GetKey(docId); + errCode = GetUpDataRePlaceData(resultSet, docId, update, valStr, isReplace); + if (errCode != E_OK) { + goto END; } - errCode = coll.UpdateDocument(docId, update, isReplace); + errCode = coll.UpdateDocument(docId, valStr, isReplace); if (errCode == E_OK) { count++; } else if (errCode == -E_NOT_FOUND) { @@ -236,17 +271,17 @@ int DocumentStore::UpdateDocument(const std::string &collection, const std::stri GLOGE("filter Parsed failed"); return errCode; } - bool isOnlyId = true; + bool isIdExist = false; std::vector> filterAllPath; - errCode = TranFilter(filterObj, filterAllPath, isOnlyId); + errCode = TranFilter(filterObj, filterAllPath, isIdExist); if (errCode != E_OK) { return errCode; } bool isReplace = ((flags & GRD_DOC_REPLACE) == GRD_DOC_REPLACE); std::shared_ptr context = std::make_shared(); context->collectionName = collection; - context->isOnlyId = isOnlyId; context->filter = filter; + context->ifShowId = true; return UpdateDataIntoDB(context, filterObj, update, isReplace); } @@ -270,11 +305,8 @@ int UpsertArgsCheck(const std::string &collection, const std::string &filter, co return errCode; } -int DocumentStore::CheckUpsertConflict(bool &isIdExist, std::shared_ptr &context, JsonObject &filterObj, - std::string &docId, Collection &coll) +int CheckUpsertConflict(ResultSet &resultSet, JsonObject &filterObj, std::string &docId, Collection &coll) { - ResultSet resultSet; - InitResultSet(context, this, resultSet, true); int errCode = resultSet.GetNext(false, true); bool isfilterMatch = false; if (errCode == E_OK) { @@ -282,7 +314,7 @@ int DocumentStore::CheckUpsertConflict(bool &isIdExist, std::shared_ptr= JSON_LENS_MAX) { + GLOGE("document's length is too long"); + return -E_OVER_LIMIT; + } + } + return errCode; +} + +int InsertIdToDocument(JsonObject &filterObj, JsonObject &documentObj, bool &isIdExist, std::string &targetDocument, + std::string &docId) +{ + auto filterObjChild = filterObj.GetChild(); + ValueObject idValue = JsonCommon::GetValueInSameLevel(filterObjChild, KEY_ID, isIdExist); + docId = idValue.GetStringValue(); + int errCode = E_OK; + JsonObject idObj = filterObj.GetObjectItem(KEY_ID, errCode); + documentObj.InsertItemObject(0, idObj); + targetDocument = documentObj.Print(); + if (!isIdExist) { + errCode = -E_INVALID_ARGS; + } + return errCode; +} + int DocumentStore::UpsertDataIntoDB(std::shared_ptr &context, JsonObject &filterObj, - JsonObject &documentObj, bool &isReplace) + const std::string &document, JsonObject &documentObj, bool &isReplace) { std::lock_guard lock(dbMutex_); if (executor_ == nullptr) { @@ -303,29 +383,31 @@ int DocumentStore::UpsertDataIntoDB(std::shared_ptr &context, Json } Collection coll = Collection(context->collectionName, executor_); int count = 0; - std::string targetDocument; std::string docId; bool isIdExist; - auto filterObjChild = filterObj.GetChild(); - ValueObject idValue = JsonCommon::GetValueInSameLevel(filterObjChild, KEY_ID, isIdExist); - docId = idValue.GetStringValue(); - JsonObject idObj = filterObj.GetObjectItem(KEY_ID, errCode); - documentObj.InsertItemObject(0, idObj); - targetDocument = documentObj.Print(); - if (!isIdExist) { - errCode = -E_INVALID_ARGS; + ResultSet resultSet; + std::string targetDocument; + std::string newStr; + errCode = InsertIdToDocument(filterObj, documentObj, isIdExist, targetDocument, docId); + if (errCode != E_OK) { + return errCode; + } + context->isIdExist = isIdExist; + errCode = InitResultSet(context, this, resultSet, false); + if (errCode != E_OK) { goto END; } - if (!context->isOnlyId) { - errCode = CheckUpsertConflict(isIdExist, context, filterObj, docId, coll); - // There are only three return values, E_ OK and - E_ NO_DATA is a normal scenario, - // and that situation can continue to move forward - if (errCode == -E_DATA_CONFLICT) { - GLOGE("upsert data conflict"); - goto END; - } + errCode = CheckUpsertConflict(resultSet, filterObj, docId, coll); + // There are only three return values, the two other situation can continue to move forward. + if (errCode == -E_DATA_CONFLICT) { + GLOGE("upsert data conflict"); + goto END; + } + errCode = GetUpsertRePlaceData(resultSet, targetDocument, documentObj, isReplace, newStr); + if (errCode != E_OK) { + goto END; } - errCode = coll.UpsertDocument(docId, targetDocument, isReplace); + errCode = coll.UpsertDocument(docId, newStr, isReplace); if (errCode == E_OK) { count++; } else if (errCode == -E_NOT_FOUND) { @@ -357,6 +439,7 @@ int UpsertDocumentFormatCheck(const std::string &document, JsonObject &documentO } return errCode; } + int DocumentStore::UpsertDocument(const std::string &collection, const std::string &filter, const std::string &document, uint32_t flags) { @@ -379,19 +462,19 @@ int DocumentStore::UpsertDocument(const std::string &collection, const std::stri GLOGE("document format is illegal"); return errCode; } - bool isOnlyId = true; + bool isIdExist = false; std::vector> filterAllPath; - errCode = TranFilter(filterObj, filterAllPath, isOnlyId); + errCode = TranFilter(filterObj, filterAllPath, isIdExist); if (errCode != E_OK) { GLOGE("filter is invalid"); return errCode; } std::shared_ptr context = std::make_shared(); context->filter = filter; - context->isOnlyId = isOnlyId; context->collectionName = collection; + context->ifShowId = true; bool isReplace = ((flags & GRD_DOC_REPLACE) == GRD_DOC_REPLACE); - return UpsertDataIntoDB(context, filterObj, documentObj, isReplace); + return UpsertDataIntoDB(context, filterObj, document, documentObj, isReplace); } int InsertArgsCheck(const std::string &collection, const std::string &document, uint32_t flags) @@ -478,19 +561,16 @@ int DocumentStore::DeleteDataFromDB(std::shared_ptr &context, Json return errCode; } std::string id; - if (context->isOnlyId) { - auto filterObjChild = filterObj.GetChild(); - auto idValue = JsonCommon::GetValueInSameLevel(filterObjChild, KEY_ID); - id = idValue.GetStringValue(); - } else { - ResultSet resultSet; - InitResultSet(context, this, resultSet, true); - errCode = resultSet.GetNext(false, true); - if (errCode != E_OK) { - goto END; - } - resultSet.GetKey(id); + ResultSet resultSet; + errCode = InitResultSet(context, this, resultSet, false); + if (errCode != E_OK) { + goto END; + } + errCode = resultSet.GetNext(false, true); + if (errCode != E_OK) { + goto END; } + resultSet.GetKey(id); END: if (errCode == E_OK) { Key key(id.begin(), id.end()); @@ -513,16 +593,15 @@ int DocumentStore::DeleteDocument(const std::string &collection, const std::stri if (errCode != E_OK) { return errCode; } - bool isOnlyId = true; + bool isIdExist = false; std::vector> filterAllPath; - errCode = TranFilter(filterObj, filterAllPath, isOnlyId); + errCode = TranFilter(filterObj, filterAllPath, isIdExist); if (errCode != E_OK) { return errCode; } std::shared_ptr context = std::make_shared(); context->filter = filter; context->collectionName = collection; - context->isOnlyId = isOnlyId; return DeleteDataFromDB(context, filterObj); } Collection DocumentStore::GetCollection(std::string &collectionName) @@ -667,7 +746,7 @@ int DocumentStore::InitFindResultSet(GRD_ResultSet *grdResultSet, std::shared_pt if (errCode != E_OK) { goto END; } - errCode = InitResultSet(context, this, grdResultSet->resultSet_, false); + errCode = InitResultSet(context, this, grdResultSet->resultSet_, true); if (errCode == E_OK) { collections_[context->collectionName] = nullptr; } @@ -701,14 +780,13 @@ int DocumentStore::FindDocument(const std::string &collection, const std::string if (errCode != E_OK) { return errCode; } - bool isOnlyId = true; + bool isIdExist = false; std::vector> filterAllPath; - errCode = TranFilter(filterObj, filterAllPath, isOnlyId); + errCode = TranFilter(filterObj, filterAllPath, isIdExist); if (errCode != E_OK) { GLOGE("filter is invalid"); return errCode; } - context->isOnlyId = isOnlyId; if (flags == GRD_DOC_ID_DISPLAY) { context->ifShowId = true; } else { diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set.cpp index cadbf6703dd67a83f80cb49358665ba025245c0d..bfbb618121865e4d089173ef6562520975acbc95 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set.cpp @@ -33,9 +33,9 @@ int ResultSet::EraseCollection() } return E_OK; } -int ResultSet::Init(std::shared_ptr &context, DocumentStore *store, bool ifField) +int ResultSet::Init(std::shared_ptr &context, DocumentStore *store, bool isCutBranch) { - ifField_ = ifField; + isCutBranch_ = isCutBranch; context_ = context; store_ = store; return E_OK; @@ -44,47 +44,39 @@ int ResultSet::Init(std::shared_ptr &context, DocumentStore *store int ResultSet::GetNextWithField() { int errCode = E_OK; - if (context_->isOnlyId) { - JsonObject filterObj = JsonObject::Parse(context_->filter, errCode, true, true); - if (errCode != E_OK) { - GLOGE("filter Parsed failed"); - return errCode; - } + JsonObject filterObj = JsonObject::Parse(context_->filter, errCode, true, true); + if (errCode != E_OK) { + GLOGE("filter Parsed failed"); + return errCode; + } + Key key; + if (context_->isIdExist) { // get id from filter or from previous data. JsonObject filterObjChild = filterObj.GetChild(); ValueObject idValue = JsonCommon::GetValueInSameLevel(filterObjChild, KEY_ID); std::string idKey = idValue.GetStringValue(); - if (idKey.empty()) { - return -E_NO_DATA; - } - Key key(idKey.begin(), idKey.end()); - Value document; - Collection coll = store_->GetCollection(context_->collectionName); - errCode = coll.GetDocument(key, document); - if (errCode == -E_NOT_FOUND) { - return -E_NO_DATA; - } - std::string jsonData(document.begin(), document.end()); - CutJsonBranch(jsonData); - std::vector> values; - values.emplace_back(std::make_pair(idKey, jsonData)); - matchDatas_ = values; + key.assign(idKey.begin(), idKey.end()); } else { - Collection coll = store_->GetCollection(context_->collectionName); - std::vector> values; - JsonObject filterObj = JsonObject::Parse(context_->filter, errCode, true, true); + key.assign(lastKeyIndex_.begin(), lastKeyIndex_.end()); + } + matchData_.first.clear(); // Delete previous data. + matchData_.second.clear(); + std::pair value; + Collection coll = store_->GetCollection(context_->collectionName); + errCode = coll.GetMatchedDocument(filterObj, key, value, context_->isIdExist); + if (errCode == -E_NOT_FOUND) { + return -E_NO_DATA; + } + std::string jsonData(value.second.begin(), value.second.end()); + std::string jsonkey(value.first.begin(), value.first.end()); + lastKeyIndex_ = jsonkey; + if (isCutBranch_) { + errCode = CutJsonBranch(jsonData); // cut jsonData branch according to projection. if (errCode != E_OK) { - GLOGE("filter Parsed failed"); + GLOGE("cut branch faild"); return errCode; } - errCode = coll.GetMatchedDocument(filterObj, values); - if (errCode == -E_NOT_FOUND) { - return -E_NO_DATA; - } - for (size_t i = 0; i < values.size(); i++) { - CutJsonBranch(values[i].second); - } - matchDatas_ = values; } + matchData_ = std::make_pair(jsonkey, jsonData); return E_OK; } @@ -104,27 +96,11 @@ int ResultSet::GetNextInner(bool isNeedCheckTable) return -E_INVALID_ARGS; } } - if (!ifField_ && index_ == 0) { - errCode = GetNextWithField(); - if (errCode != E_OK) { - return errCode; - } - } else if (index_ == 0) { - Collection coll = store_->GetCollection(context_->collectionName); - std::vector> values; - JsonObject filterObj = JsonObject::Parse(context_->filter, errCode, true, true); - if (errCode != E_OK) { - GLOGE("filter Parsed failed"); - return errCode; - } - errCode = coll.GetMatchedDocument(filterObj, values); - if (errCode == -E_NOT_FOUND) { - return -E_NO_DATA; - } - matchDatas_ = values; + errCode = GetNextWithField(); + if (errCode != E_OK) { + return errCode; } - index_++; - if (index_ > matchDatas_.size()) { + if (matchData_.second.empty()) { return -E_NO_DATA; } return E_OK; @@ -139,6 +115,7 @@ int ResultSet::GetNext(bool isNeedTransaction, bool isNeedCheckTable) std::lock_guard lock(store_->dbMutex_); errCode = store_->StartTransaction(); if (errCode != E_OK) { + GLOGE("Start transaction faild"); return errCode; } errCode = GetNextInner(isNeedCheckTable); @@ -153,11 +130,11 @@ int ResultSet::GetNext(bool isNeedTransaction, bool isNeedCheckTable) int ResultSet::GetValue(char **value) { std::lock_guard lock(store_->dbMutex_); - if (index_ == 0 || (index_ > matchDatas_.size())) { + if (matchData_.first.empty()) { GLOGE("The value vector in resultSet is empty"); return -E_NO_DATA; } - std::string jsonData = matchDatas_[index_ - 1].second; + std::string jsonData = matchData_.second; char *jsonstr = new char[jsonData.size() + 1]; if (jsonstr == nullptr) { GLOGE("Memory allocation failed!"); @@ -173,13 +150,23 @@ int ResultSet::GetValue(char **value) return E_OK; } -int ResultSet::GetKey(std::string &key) +int ResultSet::GetValue(std::string &value) { - if (index_ == 0 || (index_ > matchDatas_.size())) { + if (matchData_.first.empty()) { GLOGE("The value vector in resultSet is empty"); return -E_NO_DATA; } - key = matchDatas_[index_ - 1].first; + value = matchData_.second; + return E_OK; +} + +int ResultSet::GetKey(std::string &key) +{ + key = matchData_.first; + if (key.empty()) { + GLOGE("can not get data, because it is empty"); + return -E_NO_DATA; + } return E_OK; } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set_common.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set_common.cpp index d6e070aaab416e100a8991ccdb2c068bfae2478e..20d14de2cc502a3bb4e1ba892d4bd03e15aa9a98 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set_common.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/interface/src/result_set_common.cpp @@ -20,14 +20,12 @@ namespace DocumentDB { class ValueObject; -int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool ifField) +int InitResultSet(std::shared_ptr &context, DocumentStore *store, ResultSet &resultSet, bool isCutBranch) { - if (!ifField) { - if (context->projectionTree.ParseTree(context->projectionPath) == -E_INVALID_ARGS) { - GLOGE("Parse ProjectionTree failed"); - return -E_INVALID_ARGS; - } + if (isCutBranch && context->projectionTree.ParseTree(context->projectionPath) == -E_INVALID_ARGS) { + GLOGE("Parse ProjectionTree failed"); + return -E_INVALID_ARGS; } - return resultSet.Init(context, store, ifField); + return resultSet.Init(context, store, isCutBranch); } } // namespace DocumentDB diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h index 7dd31d4ec72776f48475e0ab97bcdcf07e2b2014..a701cddf060a7a0d69aece2f1a8e263f9d6b5b35 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/include/kv_store_executor.h @@ -31,9 +31,9 @@ public: virtual int PutData(const std::string &collName, const Key &key, const Value &value) = 0; virtual int InsertData(const std::string &collName, const Key &key, const Value &value) = 0; - virtual int GetData(const std::string &collName, const Key &key, Value &value) const = 0; - virtual int GetFieldedData(const std::string &collName, const JsonObject &filterObj, - std::vector> &values) const = 0; + virtual int GetDataByKey(const std::string &collName, const Key &key, Value &value) const = 0; + virtual int GetDataByFilter(const std::string &collName, const Key &key, const JsonObject &filterObj, + std::pair &values, int isIdExist) const = 0; virtual int DelData(const std::string &collName, const Key &key) = 0; virtual int CreateCollection(const std::string &name, const std::string &option, bool ignoreExists) = 0; diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp index 7ac3a08c0717fc083ac31ac794a74bb24002bb12..d52c517f6098ba45f4eae28a06744d8b2c46cab1 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/json_object.cpp @@ -102,7 +102,7 @@ JsonObject::~JsonObject() bool JsonObject::operator==(const JsonObject &other) const { - return (cJSON_Compare(this->cjson_, other.cjson_, 0) != 0); + return (cJSON_Compare(this->cjson_, other.cjson_, true) != 0); // CaseSensitive } bool JsonObject::IsNull() const diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp index 1de43e0dc0f6a83750cf3caaedf1758bcf34ff22..5143319a963e011833605b15da1e6dababe6defd 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.cpp @@ -74,7 +74,7 @@ int SqliteStoreExecutorImpl::GetDBConfig(std::string &config) std::string dbConfigKeyStr = "DB_CONFIG"; Key dbConfigKey = { dbConfigKeyStr.begin(), dbConfigKeyStr.end() }; Value dbConfigVal; - int errCode = GetData("grd_meta", dbConfigKey, dbConfigVal); + int errCode = GetDataByKey("grd_meta", dbConfigKey, dbConfigVal); config.assign(dbConfigVal.begin(), dbConfigVal.end()); return errCode; } @@ -152,7 +152,7 @@ int SqliteStoreExecutorImpl::InsertData(const std::string &collName, const Key & return E_OK; } -int SqliteStoreExecutorImpl::GetData(const std::string &collName, const Key &key, Value &value) const +int SqliteStoreExecutorImpl::GetDataByKey(const std::string &collName, const Key &key, Value &value) const { if (dbHandle_ == nullptr) { GLOGE("Invalid db handle."); @@ -166,7 +166,7 @@ int SqliteStoreExecutorImpl::GetData(const std::string &collName, const Key &key SQLiteUtils::BindBlobToStatement(stmt, 1, key); return E_OK; }, - [&value, &innerErrorCode](sqlite3_stmt *stmt) { + [&value, &innerErrorCode](sqlite3_stmt *stmt, bool &isMatchOneData) { SQLiteUtils::GetColumnBlobValue(stmt, 0, value); innerErrorCode = E_OK; return E_OK; @@ -178,8 +178,20 @@ int SqliteStoreExecutorImpl::GetData(const std::string &collName, const Key &key return innerErrorCode; } -int SqliteStoreExecutorImpl::GetFieldedData(const std::string &collName, const JsonObject &filterObj, - std::vector> &values) const +std::string GeneralInsertSql(const std::string &collName, const Key &key, int isIdExist) +{ + std::string sqlEqual = "SELECT key, value FROM '" + collName + "' WHERE key=?;"; + std::string sqlOrder = "SELECT key, value FROM '" + collName + "' ORDER BY KEY;"; + std::string sqlLarger = "SELECT key, value FROM '" + collName + "' WHERE key>?;"; + if (isIdExist) { + return sqlEqual; + } else { + return (key.empty()) ? sqlOrder : sqlLarger; + } +} + +int SqliteStoreExecutorImpl::GetDataByFilter(const std::string &collName, const Key &key, const JsonObject &filterObj, + std::pair &values, int isIdExist) const { if (dbHandle_ == nullptr) { GLOGE("Invalid db handle."); @@ -189,26 +201,34 @@ int SqliteStoreExecutorImpl::GetFieldedData(const std::string &collName, const J Value valueResult; bool isFindMatch = false; int innerErrorCode = -E_NOT_FOUND; - std::string sql = "SELECT key, value FROM '" + collName + "'ORDER BY KEY;"; + std::string sql = GeneralInsertSql(collName, key, isIdExist); + std::string keyStr(key.begin(), key.end()); int errCode = SQLiteUtils::ExecSql( dbHandle_, sql, - [](sqlite3_stmt *stmt) { + [key](sqlite3_stmt *stmt) { + if (!key.empty()) { + SQLiteUtils::BindBlobToStatement(stmt, 1, key); + } return E_OK; }, - [&keyResult, &innerErrorCode, &valueResult, &filterObj, &values, &isFindMatch](sqlite3_stmt *stmt) { + [&keyResult, &innerErrorCode, &valueResult, &filterObj, &values, &isFindMatch](sqlite3_stmt *stmt, + bool &isMatchOneData) { SQLiteUtils::GetColumnBlobValue(stmt, 0, keyResult); SQLiteUtils::GetColumnBlobValue(stmt, 1, valueResult); std::string keyStr(keyResult.begin(), keyResult.end()); std::string valueStr(valueResult.begin(), valueResult.end()); - int externErrCode; - JsonObject srcObj = JsonObject::Parse(valueStr, externErrCode, true); - if (externErrCode != E_OK) { + JsonObject srcObj = JsonObject::Parse(valueStr, innerErrorCode, true); + if (innerErrorCode != E_OK) { GLOGE("srcObj Parsed failed"); - return externErrCode; + return innerErrorCode; } - if (JsonCommon::IsJsonNodeMatch(srcObj, filterObj, externErrCode)) { - isFindMatch = true; - values.emplace_back(std::pair(keyStr, valueStr)); + if (JsonCommon::IsJsonNodeMatch(srcObj, filterObj, innerErrorCode)) { + isFindMatch = true; // this args work in this function + values.first = keyStr; + values.second = valueStr; + innerErrorCode = E_OK; + isMatchOneData = true; // this args work in ExecSql fuction + return E_OK; // match count; } innerErrorCode = E_OK; return E_OK; @@ -231,7 +251,7 @@ int SqliteStoreExecutorImpl::DelData(const std::string &collName, const Key &key } int errCode = 0; Value valueRet; - if (GetData(collName, key, valueRet) != E_OK) { + if (GetDataByKey(collName, key, valueRet) != E_OK) { return -E_NO_DATA; } std::string sql = "DELETE FROM '" + collName + "' WHERE key=?;"; @@ -320,7 +340,7 @@ bool SqliteStoreExecutorImpl::IsCollectionExists(const std::string &name, int &e SQLiteUtils::BindTextToStatement(stmt, 1, name); return E_OK; }, - [&isExists](sqlite3_stmt *stmt) { + [&isExists](sqlite3_stmt *stmt, bool &isMatchOneData) { isExists = true; return E_OK; }); @@ -335,7 +355,7 @@ int SqliteStoreExecutorImpl::GetCollectionOption(const std::string &name, std::s std::string collOptKeyStr = "COLLECTION_OPTION_" + name; Key collOptKey = { collOptKeyStr.begin(), collOptKeyStr.end() }; Value collOptVal; - int errCode = GetData("grd_meta", collOptKey, collOptVal); + int errCode = GetDataByKey("grd_meta", collOptKey, collOptVal); option.assign(collOptVal.begin(), collOptVal.end()); return errCode; } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h index 7b82379e3b78749a0186d83012d4f7eb7e98e610..9cf598711b2a5fc66839863fa4ebb6d6b73717c8 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_store_executor_impl.h @@ -39,9 +39,9 @@ public: int PutData(const std::string &collName, const Key &key, const Value &value) override; int InsertData(const std::string &collName, const Key &key, const Value &value) override; - int GetData(const std::string &collName, const Key &key, Value &value) const override; - int GetFieldedData(const std::string &collName, const JsonObject &filterObj, - std::vector> &values) const override; + int GetDataByKey(const std::string &collName, const Key &key, Value &value) const override; + int GetDataByFilter(const std::string &collName, const Key &key, const JsonObject &filterObj, + std::pair &values, int isIdExist) const override; int DelData(const std::string &collName, const Key &key) override; int CreateCollection(const std::string &name, const std::string &option, bool ignoreExists) override; diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.cpp b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.cpp index 0b40db956d3580017853729965be085fb8d59bdb..6ac7e59d26f01d18ee3047a0cd3f70d301daa9df 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.cpp +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.cpp @@ -22,7 +22,7 @@ namespace DocumentDB { const int MAX_BLOB_READ_SIZE = 5 * 1024 * 1024; // 5M limit const int MAX_TEXT_READ_SIZE = 5 * 1024 * 1024; // 5M limit -const int BUSY_TIMEOUT_MS = 3000; // 3000ms for sqlite busy timeout. +const int BUSY_TIMEOUT_MS = 3000; // 3000ms for sqlite busy timeout. const std::string BEGIN_SQL = "BEGIN TRANSACTION"; const std::string BEGIN_IMMEDIATE_SQL = "BEGIN IMMEDIATE TRANSACTION"; const std::string COMMIT_SQL = "COMMIT TRANSACTION"; @@ -179,7 +179,7 @@ int SQLiteUtils::GetColumnBlobValue(sqlite3_stmt *statement, int index, std::vec if (keySize < 0 || keySize > MAX_BLOB_READ_SIZE) { GLOGW("[SQLiteUtils][Column blob] size over limit:%d", keySize); value.resize(MAX_BLOB_READ_SIZE + 1); // Reset value size to invalid - return E_OK; // Return OK for continue get data, but value is invalid + return E_OK; // Return OK for continue get data, but value is invalid } auto keyRead = static_cast(sqlite3_column_blob(statement, index)); @@ -218,7 +218,7 @@ int SQLiteUtils::GetColumnTextValue(sqlite3_stmt *statement, int index, std::str if (valSize < 0 || valSize > MAX_TEXT_READ_SIZE) { GLOGW("[SQLiteUtils][Column text] size over limit:%d", valSize); value.resize(MAX_TEXT_READ_SIZE + 1); // Reset value size to invalid - return E_OK; // Return OK for continue get data, but value is invalid + return E_OK; // Return OK for continue get data, but value is invalid } const unsigned char *val = sqlite3_column_text(statement, index); @@ -267,18 +267,18 @@ int SQLiteUtils::ExecSql(sqlite3 *db, const std::string &sql) } int SQLiteUtils::ExecSql(sqlite3 *db, const std::string &sql, const std::function &bindCallback, - const std::function &resultCallback) + const std::function &resultCallback) { if (db == nullptr || sql.empty()) { return -E_INVALID_ARGS; } bool bindFinish = true; sqlite3_stmt *stmt = nullptr; + bool isMatchOneData = false; int errCode = SQLiteUtils::GetStatement(db, sql, stmt); if (errCode != E_OK) { goto END; } - do { if (bindCallback) { errCode = bindCallback(stmt); @@ -295,7 +295,8 @@ int SQLiteUtils::ExecSql(sqlite3 *db, const std::string &sql, const std::functio } else if (errCode != SQLITE_ROW) { goto END; // Step return error } - if (resultCallback != nullptr && ((errCode = resultCallback(stmt)) != E_OK)) { + if (resultCallback != nullptr && ((errCode = resultCallback(stmt, isMatchOneData)) != E_OK) || + isMatchOneData) { // find one data, stop stepping. goto END; } } diff --git a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.h b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.h index 3567163c6387ef2022c2400ddc60a279027e72e1..96db40182ec1a1d324cb3bfbf9dc3f325a5cf61c 100644 --- a/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.h +++ b/services/distributeddataservice/service/data_share/gaussdb_rd/src/oh_adapter/src/sqlite_utils.h @@ -48,7 +48,7 @@ public: static int ExecSql(sqlite3 *db, const std::string &sql); static int ExecSql(sqlite3 *db, const std::string &sql, const std::function &bindCallback, - const std::function &resultCallback); + const std::function &resultCallback); private: static void SqliteLogCallback(void *data, int err, const char *msg);