From fc93ba64df47105950d907260e76982a73024655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E4=BF=8A?= Date: Mon, 14 Apr 2025 14:44:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 邓俊 --- .../include/relational_store.h | 41 +++++++++++++++++++ .../relational_store/libnative_rdb.ndk.json | 6 +++ 2 files changed, 47 insertions(+) diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index dc0cdee93..5c17a6950 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 bd9e55864..c08017cda 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" }, -- Gitee