diff --git a/distributeddatamgr/relational_store/BUILD.gn b/distributeddatamgr/relational_store/BUILD.gn index 560c94d4d153579497dd4bea9a91509e5015cec4..33bffdae58cfcfdfb2b694b71e13efb10924e265 100644 --- a/distributeddatamgr/relational_store/BUILD.gn +++ b/distributeddatamgr/relational_store/BUILD.gn @@ -20,6 +20,7 @@ ohos_ndk_headers("native_rdb_ndk_header") { sources = [ "./include/oh_cursor.h", "./include/oh_predicates.h", + "./include/oh_rdb_crypto_param.h", "./include/oh_rdb_transaction.h", "./include/oh_rdb_types.h", "./include/oh_value_object.h", @@ -52,6 +53,7 @@ ohos_ndk_library("libnative_rdb_ndk") { "$ndk_headers_out_dir/database/data/oh_data_values_buckets.h", "$ndk_headers_out_dir/database/rdb/oh_cursor.h", "$ndk_headers_out_dir/database/rdb/oh_predicates.h", + "$ndk_headers_out_dir/database/rdb/oh_rdb_crypto_param.h", "$ndk_headers_out_dir/database/rdb/oh_rdb_transaction.h", "$ndk_headers_out_dir/database/rdb/oh_rdb_types.h", "$ndk_headers_out_dir/database/rdb/oh_value_object.h", diff --git a/distributeddatamgr/relational_store/include/oh_predicates.h b/distributeddatamgr/relational_store/include/oh_predicates.h index 32d4e3e9eb260012d43dacd6778300c283769565..bfffd0149e33c7d7ce135ea42e4bc13bde29f0ef 100644 --- a/distributeddatamgr/relational_store/include/oh_predicates.h +++ b/distributeddatamgr/relational_store/include/oh_predicates.h @@ -47,6 +47,7 @@ #include #include "database/rdb/oh_value_object.h" +#include "database/rdb/oh_data_values.h" #ifdef __cplusplus extern "C" { @@ -410,6 +411,60 @@ struct OH_Predicates { int (*destroy)(OH_Predicates *predicates); }; +/** + * @brief Sets the OH_Predicates to match the field whose data type is string and value is not like the specified value. + * This method is similar to "Not like" of the SQL statement. + * + * @param predicates Represents a pointer to an instance of OH_Predicates. + * @param field Indicates the column name in the database table. + * @param pattern Indicates the value to compare against. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 +*/ +int OH_Predicates_NotLike(OH_Predicates *predicates, const char *field, const char *pattern); + +/** + * @brief Sets the OH_Predicates to match the specified field whose data type is string and the value contains + * a wildcard. Different from like, the input parameters of this method are case-sensitive. + * + * @param predicates Represents a pointer to an instance of OH_Predicates. + * @param field Indicates the column name in the database table. + * @param pattern Indicates the value to match with the predicate. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 +*/ +int OH_Predicates_Glob(OH_Predicates *predicates, const char *field, const char *pattern); + +/** + * @brief Sets the OH_Predicates to not match the specified field whose data type is string and the value contains + * a wildcard. Different from not like, the input parameters of this method are case-sensitive. + * + * @param predicates Represents a pointer to an instance of OH_Predicates. + * @param field Indicates the column name in the database table. + * @param pattern Indicates the value to compare against. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 +*/ +int OH_Predicates_NotGlob(OH_Predicates *predicates, const char *field, const char *pattern); + +/** + * @brief Sets the OH_Predicates to specify conditions to filter grouped results that will appear in the final result. + * + * @param predicates Represents a pointer to an instance of OH_Predicates. + * @param conditions Indicates filter conditions in the having clause. + * @param values Indicates a pointer to an instance of OH_Data_Values. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 +*/ +int OH_Predicates_Having(OH_Predicates *predicates, const char *conditions, const OH_Data_Values *values); #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/relational_store/include/oh_rdb_crypto_param.h b/distributeddatamgr/relational_store/include/oh_rdb_crypto_param.h new file mode 100755 index 0000000000000000000000000000000000000000..10921ae89180ab0652c0e11ad0cc25a632e0c183 --- /dev/null +++ b/distributeddatamgr/relational_store/include/oh_rdb_crypto_param.h @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases. + * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations + * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @since 10 + */ + +/** + * @file oh_rdb_crypto_param.h + * + * @brief Provides functions and enumerations related to cryptographic parameters of the relational database. + * + * @kit ArkData + * @library libnative_rdb_ndk.z.so + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * + * @since 20 + */ + +#ifndef OH_RDB_CRYPTO_PARAM_H +#define OH_RDB_CRYPTO_PARAM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the database encryption algorithms. + * + * @since 20 + */ +typedef enum Rdb_EncryptionAlgo { + /** + * @brief Indicates the database is encrypted using RDB_AES_256_GCM. + * + * @since 20 + */ + RDB_AES_256_GCM = 0, + /** + * @brief Indicates the database is encrypted using RDB_AES_256_CBC. + * + * @since 20 + */ + RDB_AES_256_CBC, +} Rdb_EncryptionAlgo; + +/** + * @brief Enumerates the supported HMAC algorithm when opening a database. + * + * @since 20 + */ +typedef enum Rdb_HmacAlgo { + /** + * @brief RDB_HMAC_SHA1 algorithm. + * + * @since 20 + */ + RDB_HMAC_SHA1 = 0, + /** + * @brief RDB_HMAC_SHA256 algorithm. + * + * @since 20 + */ + RDB_HMAC_SHA256, + /** + * @brief RDB_HMAC_SHA512 algorithm. + * + * @since 20 + */ + RDB_HMAC_SHA512, +} Rdb_HmacAlgo; + +/** + * @brief Enumerates the supported KDF algorithm when opening a database. + * + * @since 20 + */ +typedef enum Rdb_KdfAlgo { + /** + * @brief RDB_KDF_SHA1 algorithm. + * + * @since 20 + */ + RDB_KDF_SHA1 = 0, + /** + * @brief RDB_KDF_SHA256 algorithm. + * + * @since 20 + */ + RDB_KDF_SHA256, + /** + * @brief RDB_KDF_SHA512 algorithm. + * + * @since 20 + */ + RDB_KDF_SHA512, +} Rdb_KdfAlgo; + +/** + * @brief Specifies the cryptographic parameters used when opening an encrypted database. + * + * @since 20 + */ +typedef struct OH_Rdb_CryptoParam OH_Rdb_CryptoParam; + +/** + * @brief Creates an OH_Rdb_CryptoParam instance object. + * + * @return Returns a pointer to OH_Rdb_CryptoParam instance when the execution is successful. + * Otherwise, nullptr is returned. The memory must be released through the OH_Rdb_DestroyCryptoParam + * interface after the use is complete. + * @see OH_Rdb_DestroyCryptoParam. + * @since 20 + */ +OH_Rdb_CryptoParam *OH_Rdb_CreateCryptoParam(void); + +/** + * @brief Destroys an OH_Rdb_CryptoParam instance object. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Rdb_DestroyCryptoParam(OH_Rdb_CryptoParam *param); + +/** + * @brief Sets key data to the OH_Rdb_CryptoParam object. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @param key Represents a pointer to array data. + * @param length Represents the size of key array. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Crypto_SetEncryptionKey(OH_Rdb_CryptoParam *param, const uint8_t *key, int32_t length); + +/** + * @brief Sets the number of KDF iterations used when opening an encrypted database. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @param iteration Represents iterations times. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Crypto_SetIteration(OH_Rdb_CryptoParam *param, int64_t iteration); + +/** + * @brief Sets the encryption algorithm when opening an encrypted database. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @param algo Represents the encryption algorithm. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Crypto_SetEncryptionAlgo(OH_Rdb_CryptoParam *param, int32_t algo); + +/** + * @brief Sets the HMAC algorithm when opening an encrypted database. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @param algo Represents the HMAC algorithm. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Crypto_SetHmacAlgo(OH_Rdb_CryptoParam *param, int32_t algo); + +/** + * @brief Sets the KDF algorithm when opening an encrypted database. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @param algo Represents the KDF algorithm. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Crypto_SetKdfAlgo(OH_Rdb_CryptoParam *param, int32_t algo); + +/** + * @brief Sets the page size used when opening an encrypted database. + * + * @param param Represents a pointer to an instance of OH_Rdb_CryptoParam. + * @param size Represents the page size. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Crypto_SetCryptoPageSize(OH_Rdb_CryptoParam *param, int64_t size); + +#ifdef __cplusplus +}; +#endif +#endif +/** @} */ diff --git a/distributeddatamgr/relational_store/include/oh_rdb_transaction.h b/distributeddatamgr/relational_store/include/oh_rdb_transaction.h index 99cbfe20af4cf9d691168aacb8541477caa20621..d1c71fb2086f5fe4a0dc272338abf2bf895cc728 100644 --- a/distributeddatamgr/relational_store/include/oh_rdb_transaction.h +++ b/distributeddatamgr/relational_store/include/oh_rdb_transaction.h @@ -193,6 +193,36 @@ int OH_RdbTrans_Rollback(OH_Rdb_Transaction *trans); */ int OH_RdbTrans_Insert(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row, int64_t *rowId); +/** + * @brief Inserts a row of data into the target table and support conflict resolution. + * + * @param trans Represents a pointer to an instance of OH_Rdb_Transaction. + * @param table Represents the target table. + * @param row Represents the row data to be inserted into the table. + * @param resolution Represents the resolution when conflict occurs. + * @param rowId Represents row line number when insert successfully. + * @return Returns the status code of the execution. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_ERROR} database common error. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * Returns {@link RDB_E_ALREADY_CLOSED} database already closed. + * Returns {@link RDB_E_WAL_SIZE_OVER_LIMIT} the WAL file size over default limit. + * Returns {@link RDB_E_SQLITE_FULL} SQLite: The database is full. + * Returns {@link RDB_E_SQLITE_CORRUPT} database corrupted. + * Returns {@link RDB_E_SQLITE_PERM} SQLite: Access permission denied. + * Returns {@link RDB_E_SQLITE_BUSY} SQLite: The database file is locked. + * Returns {@link RDB_E_SQLITE_LOCKED} SQLite: A table in the database is locked. + * Returns {@link RDB_E_SQLITE_NOMEM} SQLite: The database is out of memory. + * Returns {@link RDB_E_SQLITE_READONLY} SQLite: Attempt to write a readonly database. + * Returns {@link RDB_E_SQLITE_IOERR} SQLite: Some kind of disk I/O error occurred. + * Returns {@link RDB_E_SQLITE_TOO_BIG} SQLite: TEXT or BLOB exceeds size limit. + * Returns {@link RDB_E_SQLITE_MISMATCH} SQLite: Data type mismatch. + * Returns {@link RDB_E_SQLITE_CONSTRAINT} SQLite: Abort due to constraint violation. + * @since 20 + */ +int OH_RdbTrans_InsertWithConflictResolution(OH_Rdb_Transaction *trans, const char *table, const OH_VBucket *row, + Rdb_ConflictResolution resolution, int64_t *rowId); + /** * @brief Inserts a batch of data into the target table. * @@ -251,6 +281,36 @@ int OH_RdbTrans_BatchInsert(OH_Rdb_Transaction *trans, const char *table, const int OH_RdbTrans_Update(OH_Rdb_Transaction *trans, const OH_VBucket *row, const OH_Predicates *predicates, int64_t *changes); +/** + * @brief Updates data in the database based on specified conditions and support conflict resolution. + * + * @param trans Represents a pointer to an instance of OH_Rdb_Transaction. + * @param row Represents the row data to be updated into the table. + * @param predicates Represents the specified update condition by the instance object of OH_Predicates. + * @param resolution Represents the resolution when conflict occurs. + * @param changes Represents the number of successful insertions. + * @return Returns the status code of the execution. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_ERROR} database common error. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * Returns {@link RDB_E_ALREADY_CLOSED} database already closed. + * Returns {@link RDB_E_WAL_SIZE_OVER_LIMIT} the WAL file size over default limit. + * Returns {@link RDB_E_SQLITE_FULL} SQLite: The database is full. + * Returns {@link RDB_E_SQLITE_CORRUPT} database corrupted. + * Returns {@link RDB_E_SQLITE_PERM} SQLite: Access permission denied. + * Returns {@link RDB_E_SQLITE_BUSY} SQLite: The database file is locked. + * Returns {@link RDB_E_SQLITE_LOCKED} SQLite: A table in the database is locked. + * Returns {@link RDB_E_SQLITE_NOMEM} SQLite: The database is out of memory. + * Returns {@link RDB_E_SQLITE_READONLY} SQLite: Attempt to write a readonly database. + * Returns {@link RDB_E_SQLITE_IOERR} SQLite: Some kind of disk I/O error occurred. + * Returns {@link RDB_E_SQLITE_TOO_BIG} SQLite: TEXT or BLOB exceeds size limit. + * Returns {@link RDB_E_SQLITE_MISMATCH} SQLite: Data type mismatch. + * Returns {@link RDB_E_SQLITE_CONSTRAINT} SQLite: Abort due to constraint violation. + * @since 20 + */ +int OH_RdbTrans_UpdateWithConflictResolution(OH_Rdb_Transaction *trans, const OH_VBucket *row, + const OH_Predicates *predicates, Rdb_ConflictResolution resolution, int64_t *changes); + /** * @brief Deletes data from the database based on specified conditions * diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index dc0cdee937877e154bd60412d176003c987ae63f..6dd09623a689e065dad1d4d017698eefb8f9399b 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -45,6 +45,7 @@ #include "database/rdb/oh_values_bucket.h" #include "database/rdb/oh_rdb_transaction.h" #include "database/rdb/oh_rdb_types.h" +#include "database/rdb/oh_rdb_crypto_param.h" #ifdef __cplusplus extern "C" { @@ -336,6 +337,55 @@ int OH_Rdb_SetArea(OH_Rdb_ConfigV2 *config, int area); */ int OH_Rdb_SetDbType(OH_Rdb_ConfigV2 *config, int dbType); +/** + * @brief Sets the customized directory relative to the database. + * + * @param config Represents a pointer to a configuration of the database related to this relation database store. + * @param customDir Represents the customized relative to the database directory, the value cannot exceed 128 bytes. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Rdb_SetCustomDir(OH_Rdb_ConfigV2 *config, const char *customDir); + +/** + * @brief Sets the relation database store is read-only mode. + * + * @param config Represents a pointer to a configuration of the database related to this relation database store. + * @param readOnly Represents whether the relation database store is read-only. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Rdb_SetReadOnly(OH_Rdb_ConfigV2 *config, bool readOnly); + +/** + * @brief Sets the dynamic libraries with capabilities such as Full-Text Search (FTS). + * + * @param config Represents a pointer to a configuration of the database related to this relation database store. + * @param plugins Represents the dynamic libraries. + * @param length the size of plugins that the maximum value is 16. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Rdb_SetPlugins(OH_Rdb_ConfigV2 *config, const char **plugins, int32_t length); + +/** + * @brief Sets the custom encryption parameters. + * + * @param config Represents a pointer to a configuration of the database related to this relation database store. + * @param cryptoParam Represents the custom encryption parameters. + * @return Returns the error code. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * @since 20 + */ +int OH_Rdb_SetCryptoParam(OH_Rdb_ConfigV2 *config, const OH_Rdb_CryptoParam *cryptoParam); + /** * @brief Set property tokenizer into config * @param config Represents a pointer to {@link OH_Rdb_ConfigV2} instance. @@ -504,6 +554,36 @@ int OH_Rdb_DeleteStoreV2(const OH_Rdb_ConfigV2 *config); */ int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket); +/** + * @brief Inserts a row of data into the target table and support conflict resolution. + * + * @param store Represents a pointer to an OH_Rdb_Store instance. + * @param table Represents the target table. + * @param row Represents the row data to be inserted into the table. + * @param resolution Represents the resolution when conflict occurs. + * @param rowId Represents the number of successful insertion. + * @return Returns the status code of the execution. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_ERROR} database common error. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * Returns {@link RDB_E_ALREADY_CLOSED} database already closed. + * Returns {@link RDB_E_WAL_SIZE_OVER_LIMIT} the WAL file size over default limit. + * Returns {@link RDB_E_SQLITE_FULL} SQLite: The database is full. + * Returns {@link RDB_E_SQLITE_CORRUPT} database corrupted. + * Returns {@link RDB_E_SQLITE_PERM} SQLite: Access permission denied. + * Returns {@link RDB_E_SQLITE_BUSY} SQLite: The database file is locked. + * Returns {@link RDB_E_SQLITE_LOCKED} SQLite: A table in the database is locked. + * Returns {@link RDB_E_SQLITE_NOMEM} SQLite: The database is out of memory. + * Returns {@link RDB_E_SQLITE_READONLY} SQLite: Attempt to write a readonly database. + * Returns {@link RDB_E_SQLITE_IOERR} SQLite: Some kind of disk I/O error occurred. + * Returns {@link RDB_E_SQLITE_TOO_BIG} SQLite: TEXT or BLOB exceeds size limit. + * Returns {@link RDB_E_SQLITE_MISMATCH} SQLite: Data type mismatch. + * Returns {@link RDB_E_SQLITE_CONSTRAINT} SQLite: Abort due to constraint violation. + * @since 20 + */ +int OH_Rdb_InsertWithConflictResolution(OH_Rdb_Store *store, const char *table, OH_VBucket *row, + Rdb_ConflictResolution resolution, int64_t *rowId); + /** * @brief Inserts a batch of data into the target table. * @@ -550,6 +630,36 @@ int OH_Rdb_BatchInsert(OH_Rdb_Store *store, const char *table, */ int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates); +/** + * @brief Updates data in the database based on specified conditions and support conflict resolution. + * + * @param store Represents a pointer to an OH_Rdb_Store instance. + * @param row Represents the row data to be inserted into the table. + * @param predicates Represents a pointer to an link OH_Predicates instance. + * @param resolution Represents the resolution when conflict occurs. + * @param changes Represents the number of successful update. + * @return Returns the status code of the execution. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_ERROR} database common error. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * Returns {@link RDB_E_ALREADY_CLOSED} database already closed. + * Returns {@link RDB_E_WAL_SIZE_OVER_LIMIT} the WAL file size over default limit. + * Returns {@link RDB_E_SQLITE_FULL} SQLite: The database is full. + * Returns {@link RDB_E_SQLITE_CORRUPT} database corrupted. + * Returns {@link RDB_E_SQLITE_PERM} SQLite: Access permission denied. + * Returns {@link RDB_E_SQLITE_BUSY} SQLite: The database file is locked. + * Returns {@link RDB_E_SQLITE_LOCKED} SQLite: A table in the database is locked. + * Returns {@link RDB_E_SQLITE_NOMEM} SQLite: The database is out of memory. + * Returns {@link RDB_E_SQLITE_READONLY} SQLite: Attempt to write a readonly database. + * Returns {@link RDB_E_SQLITE_IOERR} SQLite: Some kind of disk I/O error occurred. + * Returns {@link RDB_E_SQLITE_TOO_BIG} SQLite: TEXT or BLOB exceeds size limit. + * Returns {@link RDB_E_SQLITE_MISMATCH} SQLite: Data type mismatch. + * Returns {@link RDB_E_SQLITE_CONSTRAINT} SQLite: Abort due to constraint violation. + * @since 20 + */ +int OH_Rdb_UpdateWithConflictResolution(OH_Rdb_Store *store, OH_VBucket *row, OH_Predicates *predicates, + Rdb_ConflictResolution resolution, int64_t *changes); + /** * @brief Deletes data from the database based on specified conditions. * @@ -1408,6 +1518,67 @@ OH_Cursor *OH_Rdb_QueryLockedRow( */ int OH_Rdb_CreateTransaction(OH_Rdb_Store *store, const OH_RDB_TransOptions *options, OH_Rdb_Transaction **trans); +/** + * @brief Attaches a database file to the currently linked database. + * + * @param store Represents a pointer to an OH_Rdb_Store instance. + * @param config Represents a pointer to an OH_Rdb_ConfigV2 configuration of the database related to this RDB store. + * @param attachName Represents the alias of the database. + * @param waitTime Represents the maximum time allowed for attaching the database, vaild range is 1 to 300. + * @param attachedNumber Represents the number of attached databases, It is an output parameter. + * @return Returns the status code of the execution. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_ERROR} database common error. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * Returns {@link RDB_E_ALREADY_CLOSED} database already closed. + * Returns {@link RDB_E_NOT_SUPPORTED} - The error code for not support. + * Returns {@link RDB_E_DATABASE_BUSY} database does not respond. + * Returns {@link RDB_E_SQLITE_FULL} SQLite: The database is full. + * Returns {@link RDB_E_SQLITE_CORRUPT} database corrupted. + * Returns {@link RDB_E_SQLITE_PERM} SQLite: Access permission denied. + * Returns {@link RDB_E_SQLITE_BUSY} SQLite: The database file is locked. + * Returns {@link RDB_E_SQLITE_LOCKED} SQLite: A table in the database is locked. + * Returns {@link RDB_E_SQLITE_NOMEM} SQLite: The database is out of memory. + * Returns {@link RDB_E_SQLITE_READONLY} SQLite: Attempt to write a readonly database. + * Returns {@link RDB_E_SQLITE_IOERR} SQLite: Some kind of disk I/O error occurred. + * Returns {@link RDB_E_SQLITE_TOO_BIG} SQLite: TEXT or BLOB exceeds size limit. + * Returns {@link RDB_E_SQLITE_MISMATCH} SQLite: Data type mismatch. + * Returns {@link RDB_E_SQLITE_CONSTRAINT} SQLite: Abort due to constraint violation. + * @since 20 + */ +int OH_Rdb_Attach(OH_Rdb_Store *store, const OH_Rdb_ConfigV2 *config, const char *attachName, int64_t waitTime, + size_t *attachedNumber); + +/** + * @brief Detaches a database from this database. + * + * @param store Represents a pointer to an OH_Rdb_Store instance. + * @param attachName Represents the alias of the database. + * @param waitTime Represents the maximum time allowed for detaching the database, vaild range is 1 to 300. + * @param attachedNumber Represents the number of attached databases, It is an output parameter. + * @return Returns the status code of the execution. + * Returns {@link RDB_OK} if the execution is successful. + * Returns {@link RDB_E_ERROR} database common error. + * Returns {@link RDB_E_INVALID_ARGS} if invalid input parameter. + * Returns {@link RDB_E_ALREADY_CLOSED} database already closed. + * Returns {@link RDB_E_NOT_SUPPORTED} - The error code for not support. + * Returns {@link RDB_E_DATABASE_BUSY} database does not respond. + * Returns {@link RDB_E_SQLITE_FULL} SQLite: The database is full. + * Returns {@link RDB_E_SQLITE_CORRUPT} database corrupted. + * Returns {@link RDB_E_SQLITE_PERM} SQLite: Access permission denied. + * Returns {@link RDB_E_SQLITE_BUSY} SQLite: The database file is locked. + * Returns {@link RDB_E_SQLITE_LOCKED} SQLite: A table in the database is locked. + * Returns {@link RDB_E_SQLITE_NOMEM} SQLite: The database is out of memory. + * Returns {@link RDB_E_SQLITE_READONLY} SQLite: Attempt to write a readonly database. + * Returns {@link RDB_E_SQLITE_IOERR} SQLite: Some kind of disk I/O error occurred. + * Returns {@link RDB_E_SQLITE_TOO_BIG} SQLite: TEXT or BLOB exceeds size limit. + * Returns {@link RDB_E_SQLITE_MISMATCH} SQLite: Data type mismatch. + * Returns {@link RDB_E_SQLITE_CONSTRAINT} SQLite: Abort due to constraint violation. + * @see OH_Rdb_Store, OH_Rdb_ErrCode. + * @since 20 + */ +int OH_Rdb_Detach(OH_Rdb_Store *store, const char *attachName, int64_t waitTime, size_t *attachedNumber); + #ifdef __cplusplus }; #endif diff --git a/distributeddatamgr/relational_store/libnative_rdb.ndk.json b/distributeddatamgr/relational_store/libnative_rdb.ndk.json index bd9e55864906c6a9433e06c2572124d041db43fb..7263b5c7a5d7f350183de5b375e54f68f5d3e18f 100644 --- a/distributeddatamgr/relational_store/libnative_rdb.ndk.json +++ b/distributeddatamgr/relational_store/libnative_rdb.ndk.json @@ -534,5 +534,93 @@ { "first_introduced": "18", "name":"OH_Cursor_GetFloatVector" + }, + { + "first_introduced": "20", + "name":"OH_Predicates_NotLike" + }, + { + "first_introduced": "20", + "name":"OH_Predicates_Glob" + }, + { + "first_introduced": "20", + "name":"OH_Predicates_NotGlob" + }, + { + "first_introduced": "20", + "name":"OH_Predicates_Having" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_CreateCryptoParam" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_DestroyCryptoParam" + }, + { + "first_introduced": "20", + "name":"OH_Crypto_SetEncryptionKey" + }, + { + "first_introduced": "20", + "name":"OH_Crypto_SetIteration" + }, + { + "first_introduced": "20", + "name":"OH_Crypto_SetEncryptionAlgo" + }, + { + "first_introduced": "20", + "name":"OH_Crypto_SetHmacAlgo" + }, + { + "first_introduced": "20", + "name":"OH_Crypto_SetKdfAlgo" + }, + { + "first_introduced": "20", + "name":"OH_Crypto_SetCryptoPageSize" + }, + { + "first_introduced": "20", + "name":"OH_RdbTrans_InsertWithConflictResolution" + }, + { + "first_introduced": "20", + "name":"OH_RdbTrans_UpdateWithConflictResolution" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_SetCustomDir" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_SetReadOnly" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_SetPlugins" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_SetCryptoParam" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_InsertWithConflictResolution" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_UpdateWithConflictResolution" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_Attach" + }, + { + "first_introduced": "20", + "name":"OH_Rdb_Detach" } ] \ No newline at end of file