diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index dc0cdee937877e154bd60412d176003c987ae63f..5c17a6950f9bbe30ae39a140a44b3d1fd8ce4bd3 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -1073,6 +1073,35 @@ int OH_Rdb_Subscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_Data */ int OH_Rdb_Unsubscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer); +/** + * @brief Subscribes to SQL error logs. + * When an exception occurs during the SQL execution, the registered callback will be invoked to return the error log. + * + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param callback Callback used to return the error log. For details, see {@link Rdb_GetSqlErrorMessage}. + * @return Returns the status code of the execution. See {@link OH_Rdb_ErrCode}. + * {@link RDB_OK} - The operation is successful. + * {@link RDB_E_INVALID_ARGS} - Invalid parameters are specified. + * @see OH_Rdb_Store. + * @see Rdb_GetSqlErrorMessage. + * @since 20 + */ +int OH_Rdb_SubscribeLog(OH_Rdb_Store *store, Rdb_GetSqlErrorMessage callback); + +/** + * @brief Unsubscribes from SQL error logs. + * + * @param store Pointer to the {@link OH_Rdb_Store} instance. + * @param callback The {@link Rdb_GetSqlErrorMessage} Callback to unregister. + * @return Returns the status code of the execution. See {@link OH_Rdb_ErrCode}. + * {@link RDB_OK} - The operation is successful. + * {@link RDB_E_INVALID_ARGS} - Invalid parameters are specified. + * @see OH_Rdb_Store. + * @see Rdb_GetSqlErrorMessage. + * @since 20 + */ +int OH_Rdb_UnsubscribeLog(OH_Rdb_Store *store); + /** * @brief Indicates the database synchronization mode. * @@ -1289,6 +1318,18 @@ typedef struct Rdb_ProgressObserver { Rdb_ProgressCallback callback; } Rdb_ProgressObserver; +/** + * @brief Callback used to obtain SQL error messages. + * + * @param context Context information. + * @param code Error code. + * @param message Error message. + * @param sql SQL statement executed. + * @see Rdb_SqlExecuteErrorMessage. + * @since 20 + */ +typedef void (*Rdb_GetSqlErrorMessage)(void *context, int code, const char *message, const char *sql); + /** * @brief Sync data to cloud. * diff --git a/distributeddatamgr/relational_store/libnative_rdb.ndk.json b/distributeddatamgr/relational_store/libnative_rdb.ndk.json index bd9e55864906c6a9433e06c2572124d041db43fb..c08017cdad5a0334a3bb0682b27dfa22ed42544d 100644 --- a/distributeddatamgr/relational_store/libnative_rdb.ndk.json +++ b/distributeddatamgr/relational_store/libnative_rdb.ndk.json @@ -216,6 +216,12 @@ { "name":"OH_Rdb_Unsubscribe" }, + { + "name":"OH_Rdb_SubscribeLog" + }, + { + "name":"OH_Rdb_UnsubscribeLog" + }, { "name":"OH_Rdb_SubscribeAutoSyncProgress" },