From 47de8aa2077f8b37487beb444bb90b2a0e242d06 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Wed, 12 Jul 2023 19:44:35 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- en/native_sdk/database/rdb/oh_cursor.h | 237 +++++++++++ en/native_sdk/database/rdb/oh_predicates.h | 391 ++++++++++++++++++ en/native_sdk/database/rdb/oh_value_object.h | 118 ++++++ en/native_sdk/database/rdb/oh_values_bucket.h | 142 +++++++ en/native_sdk/database/rdb/relational_store.h | 316 ++++++++++++++ .../rdb/relational_store_error_code.h | 316 ++++++++++++++ 6 files changed, 1520 insertions(+) create mode 100644 en/native_sdk/database/rdb/oh_cursor.h create mode 100644 en/native_sdk/database/rdb/oh_predicates.h create mode 100644 en/native_sdk/database/rdb/oh_value_object.h create mode 100644 en/native_sdk/database/rdb/oh_values_bucket.h create mode 100644 en/native_sdk/database/rdb/relational_store.h create mode 100644 en/native_sdk/database/rdb/relational_store_error_code.h diff --git a/en/native_sdk/database/rdb/oh_cursor.h b/en/native_sdk/database/rdb/oh_cursor.h new file mode 100644 index 00000000..b3dc9771 --- /dev/null +++ b/en/native_sdk/database/rdb/oh_cursor.h @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef OH_CURSOR_H +#define OH_CURSOR_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * A complete set of mechanisms for managing local databases is provided based on the underlying SQLite. + * To satisfy different needs in complicated scenarios, the RDB module provides a series of methods for performing + * operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_cursor.h + * + * @brief Provides methods to access the result set obtained by querying an RDB store. + * + * A result set is a set of results returned by query(). + * + * @since 10 + */ + +#include +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the types of the fields in an RDB store. + * + * @since 10 + */ +enum OH_ColumnType { + /** NULL */ + TYPE_NULL = 0, + /** INT64 */ + TYPE_INT64, + /** REAL */ + TYPE_REAL, + /** Text */ + TYPE_TEXT, + /** BLOB */ + TYPE_BLOB, +}; + +/** + * @brief Defines the result set. + * + * You can use the APIs to access the result set obtained by querying the RDB store. + * + * @since 10 + */ +typedef struct OH_Cursor { + /** @brief Unique identifier of the OH_Cursor struct. */ + int64_t id; + + /** + * @brief Obtains the number of columns in a result set. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param count Indicates the pointer to the number of columns in the result set obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getColumnCount)(OH_Cursor *cursor, int *count); + + /** + * @brief Obtains the type of the data in the column specified by the column index. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param columnType Indicates the pointer to the data type obtained. For details, see {@link OH_ColumnType}. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor, OH_ColumnType. + * @since 10 + */ + int (*getColumnType)(OH_Cursor *cursor, int32_t columnIndex, OH_ColumnType *columnType); + + /** + * @brief Obtains the column index based on the specified column name. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param name Indicates the pointer to the name of the column in the result set. + * @param columnIndex Indicates the pointer to the index of the column obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getColumnIndex)(OH_Cursor *cursor, const char *name, int *columnIndex); + + /** + * @brief Obtains the column name based on the specified column index. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param name Indicates the pointer to the column name obtained. + * @param length Indicates the length of the column name obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getColumnName)(OH_Cursor *cursor, int32_t columnIndex, char *name, int length); + + /** + * @brief Obtains the number of rows in a result set. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param count Indicates the pointer to the number of rows in the result set obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getRowCount)(OH_Cursor *cursor, int *count); + + /** + * @brief Goes to the next row of the result set. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*goToNextRow)(OH_Cursor *cursor); + + /** + * @brief Obtains information about the memory required when the column data type in the result set is BLOB or TEXT. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param size Indicates the pointer to the memory size obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getSize)(OH_Cursor *cursor, int32_t columnIndex, size_t *size); + + /** + * @brief Obtains the value in the form of a string based on the specified column and the current row. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param value Indicates the pointer to the string obtained. + * @param length Indicates the length of the value, which is obtained by getSize(). + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getText)(OH_Cursor *cursor, int32_t columnIndex, char *value, int length); + + /** + * @brief Obtains the value of the int64_t type based on the specified column and the current row. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param value Indicates the pointer to the value obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getInt64)(OH_Cursor *cursor, int32_t columnIndex, int64_t *value); + + /** + * @brief Obtains the value of the double type based on the specified column and the current row. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param value Indicates the pointer to the value obtained. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getReal)(OH_Cursor *cursor, int32_t columnIndex, double *value); + + /** + * @brief Obtains the value in the form of a byte array based on the specified column and the current row. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param value Indicates the pointer to the string obtained. + * @param length Indicates the length of the value, which is obtained by getSize(). + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*getBlob)(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value, int length); + + /** + * @brief Checks whether the value in the specified column is null. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @param columnIndex Indicates the index of the column in the result set. + * @param isNull Indicates the pointer to the check result. The value true means the value is null; + * the value false means the opposite. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*isNull)(OH_Cursor *cursor, int32_t columnIndex, bool *isNull); + + /** + * @brief Closes a result set. + * + * @param cursor Indicates the pointer to the {@link OH_Cursor} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Cursor. + * @since 10 + */ + int (*close)(OH_Cursor *cursor); +} OH_Cursor; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_CURSOR_H diff --git a/en/native_sdk/database/rdb/oh_predicates.h b/en/native_sdk/database/rdb/oh_predicates.h new file mode 100644 index 00000000..266e0e44 --- /dev/null +++ b/en/native_sdk/database/rdb/oh_predicates.h @@ -0,0 +1,391 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef OH_PREDICATES_H +#define OH_PREDICATES_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * A complete set of mechanisms for managing local databases is provided based on the underlying SQLite. + * To satisfy different needs in complicated scenarios, the RDB module provides a series of methods for performing + * operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_predicates.h + * + * @brief Represents a predicate for a relational database (RDB). + * + * @since 10 + */ + +#include +#include +#include "oh_value_object.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the sorting types. + * + * @since 10 + */ +enum OH_OrderType { + /** Ascending order. */ + ASC = 0, + /** Descending order. */ + DESC = 1, +}; + +/** + * @brief Defines a Predicates instance. + * + * @since 10 + */ +typedef struct OH_Predicates { + /** Unique identifier of the OH_Predicates struct. */ + int64_t id; + + /** + * @brief Sets a Predicates instance to match the field whose value is equal to the specified value. + * + * This method is equivalent to "=" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*equalTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field whose value is not equal to the specified value. + * + * This method is equivalent to "!=" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*notEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Adds a left parenthesis to the Predicates instance. + * + * This method is equivalent to "(" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns a Predicates instance with a left parenthesis. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*beginWrap)(OH_Predicates *predicates); + + /** + * @brief Adds a right parenthesis to the Predicates instance. + * + * This method is equivalent to ")" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns a Predicates instance with a right parenthesis. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*endWrap)(OH_Predicates *predicates); + + /** + * @brief Adds the OR operator to the Predicates instance. + * + * This method is equivalent to "OR" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns a Predicates instance with the OR operator. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*orOperate)(OH_Predicates *predicates); + + /** + * @brief Adds the AND operator to the Predicates instance. + * + * This method is equivalent to "AND" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns a Predicates instance with the AND operator. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*andOperate)(OH_Predicates *predicates); + + /** + * @brief Sets a Predicates instance to match the field whose value is null. + * + * This method is equivalent to "IS NULL" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @return Returns the Predicates instance created. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*isNull)(OH_Predicates *predicates, const char *field); + + /** + * @brief Sets a Predicates instance to match the field whose value is not null. + * + * This method is equivalent to "IS NOT NULL" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @return Returns the Predicates instance created. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*isNotNull)(OH_Predicates *predicates, const char *field); + + /** + * @brief Sets a Predicates instance to match a string that is similar to the specified value. + * + * This method is equivalent to "LIKE" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*like)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field whose value is within the specified range. + * + * This method is equivalent to "BETWEEN" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value range to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*between)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field whose value is out of the specified range. + * + * This method is equivalent to "NOT BETWEEN" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the range to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*notBetween)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field with value greater than the specified value. + * + * This method is equivalent to ">" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*greaterThan)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field with value less than the specified value. + * + * This method is equivalent to "<" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*lessThan)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field with value greater than or equal to the specified value. + * + * This method is equivalent to ">=" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*greaterThanOrEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to match the field with value less than or equal to the specified value. + * + * This method is equivalent to "<=" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*lessThanOrEqualTo)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates instance to sort the values in a column in ascending or descending order. + * + * This method is equivalent to "ORDER BY" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the column name in the database table. + * @param type Indicates the sorting type {@link OH_OrderType}. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_OrderType. + * @since 10 + */ + OH_Predicates *(*orderBy)(OH_Predicates *predicates, const char *field, OH_OrderType type); + + /** + * @brief Sets a Predicates instance to filter out duplicate records. + * + * This method is equivalent to "DISTINCT" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns a Predicates instance that can filter duplicate records. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*distinct)(OH_Predicates *predicates); + + /** + * @brief Sets a Predicates instance that specifies the maximum number of records. + * + * This method is equivalent to "LIMIT" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param value Indicates the maximum number of data records. + * @return Returns the Predicates instance created. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*limit)(OH_Predicates *predicates, unsigned int value); + + /** + * @brief Sets a Predicates instance that specifies the start position of the returned result. + * + * This method is equivalent to "OFFSET" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param rowOffset Indicates the start position of the returned result. The value is a positive integer. + * @return Returns the Predicates instance created. + * @see OH_Predicates. + * @since 10 + * @version 1.0 + */ + OH_Predicates *(*offset)(OH_Predicates *predicates, unsigned int rowOffset); + + /** + * @brief Sets a Predicates instance to group rows that have the same value into summary rows. + * + * This method is equivalent to "GROUP BY" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param fields Indicates the pointer to the columns to group. + * @param length Indicates the length of the fields value. + * @return Returns the Predicates instance created. + * @see OH_Predicates. + * @since 10 + */ + OH_Predicates *(*groupBy)(OH_Predicates *predicates, char const *const *fields, int length); + + /** + * @brief Sets a Predicates to match the field with the value within the specified range. + * + * This method is equivalent to "IN" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the name of the column in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + */ + OH_Predicates *(*in)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Sets a Predicates to match the field with the value out of the specified range. + * + * This method is equivalent to "NOT IN" in SQL statements. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @param field Indicates the pointer to the name of the column in the database table. + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance, which is the value to match. + * @return Returns the Predicates instance created. + * @see OH_Predicates, OH_VObject. + * @since 10 + * @version 1.0 + */ + OH_Predicates *(*notIn)(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); + + /** + * @brief Clears a Predicates instance. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns the Predicates instance cleared. + * @see OH_Predicates. + * @since 10 + * @version 1.0 + */ + OH_Predicates *(*clear)(OH_Predicates *predicates); + + /** + * @brief Destroys a {@link OH_Predicates} instance and reclaims the memory occupied. + * + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Predicates. + * @since 10 + */ + int (*destroyPredicates)(OH_Predicates *predicates); +} OH_Predicates; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_PREDICATES_H diff --git a/en/native_sdk/database/rdb/oh_value_object.h b/en/native_sdk/database/rdb/oh_value_object.h new file mode 100644 index 00000000..d2cb0821 --- /dev/null +++ b/en/native_sdk/database/rdb/oh_value_object.h @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2023 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. +*/ + +#ifndef OH_VALUE_OBJECT_H +#define OH_VALUE_OBJECT_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * A complete set of mechanisms for managing local databases is provided based on the underlying SQLite. + * To satisfy different needs in complicated scenarios, the RDB module provides a series of methods for performing + * operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_value_object.h + * + * @brief Provides data conversion methods. + * + * @since 10 + */ + +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the allowed data field types. + * + * @since 10 + */ +typedef struct OH_VObject { + /** Unique identifier of the OH_VObject struct. */ + int64_t id; + + /** + * @brief Converts an int64 value or array into a value of the {@link OH_VObject} type. + * + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. + * @param value Indicates the pointer to the value or array to convert. + * @param count Indicates the number or length of the parameters to convert. If value points to a single + * parameter, count is 1. If value points to an array, count specifies the array length. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VObject. + * @since 10 + */ + int (*putInt64)(OH_VObject *valueObject, int64_t *value, uint32_t count); + + /** + * @brief Converts a double value or array into a value of the {@link OH_VObject} type. + * + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. + * @param value Indicates the pointer to the double value or array to convert. + * @param count Indicates the number or length of the parameters to convert. If value points to a single + * parameter, count is 1. If value points to an array, count specifies the array length. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VObject. + * @since 10 + */ + int (*putDouble)(OH_VObject *valueObject, double *value, uint32_t count); + + /** + * @brief Converts a character array of the char type into a value of the {@link OH_VObject} type. + * + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. + * @param value Indicates the pointer to the character array to convert. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VObject. + * @since 10 + */ + int (*putText)(OH_VObject *valueObject, const char *value); + + /** + * @brief Converts a string array of the char type into a value of the {@link OH_VObject} type. + * + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. + * @param value Indicates the pointer to the string array to convert. + * @param count Indicates the length of the string array to convert. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VObject. + * @since 10 + */ + int (*putTexts)(OH_VObject *valueObject, const char **value, uint32_t count); + + /** + * @brief Destroys a {@link OH_VObject} instance and reclaims the memory occupied. + * + * @param valueObject Indicates the pointer to the {@link OH_VObject} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VObject. + * @since 10 + */ + int (*destroyValueObject)(OH_VObject *valueObject); +} OH_VObject; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_VALUE_OBJECT_H diff --git a/en/native_sdk/database/rdb/oh_values_bucket.h b/en/native_sdk/database/rdb/oh_values_bucket.h new file mode 100644 index 00000000..30677f39 --- /dev/null +++ b/en/native_sdk/database/rdb/oh_values_bucket.h @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef OH_VALUES_BUCKET_H +#define OH_VALUES_BUCKET_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * A complete set of mechanisms for managing local databases is provided based on the underlying SQLite. + * To satisfy different needs in complicated scenarios, the RDB module provides a series of methods for performing + * operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + +/** + * @file oh_values_bucket.h + * + * @brief Defines the types of the key and value in a key-value (KV) pair. + * + * @since 10 + */ + +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the types of the key and value in a KV pair. + * + * @since 10 + */ +typedef struct OH_VBucket { + /** Unique identifier of the OH_VBucket struct. */ + int64_t id; + + /** Number of the KV pairs in the struct. */ + uint16_t capability; + + /** + * @brief Puts a char value into the {@link OH_VBucket} instance in the given column. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param field Indicates the pointer to the column name. + * @param value Indicates the pointer to the value to put. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*putText)(OH_VBucket *bucket, const char *field, const char *value); + + /** + * @brief Puts an int64_t value into the {@link OH_VBucket} instance in the given column. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param field Indicates the pointer to the column name. + * @param value Indicates the value to put. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*putInt64)(OH_VBucket *bucket, const char *field, int64_t value); + + /** + * @brief Puts a double value into the {@link OH_VBucket} instance in the given column. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param field Indicates the pointer to the column name. + * @param value Indicates the value to put. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*putReal)(OH_VBucket *bucket, const char *field, double value); + + /** + * @brief Puts a const uint8_t value into the {@link OH_VBucket} object in the given column. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param field Indicates the pointer to the column name. + * @param value Indicates the pointer to the value to put. + * @param size Indicates the length of the value. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*putBlob)(OH_VBucket *bucket, const char *field, const uint8_t *value, uint32_t size); + + /** + * @brief Puts null into the {@link OH_VBucket} instance in the given column. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @param field Indicates the pointer to the column name. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*putNull)(OH_VBucket *bucket, const char *field); + + /** + * @brief Clears an {@link OH_VBucket} instance. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*clear)(OH_VBucket *bucket); + + /** + * @brief Destroys a {@link OH_VBucket} instance and reclaims the memory occupied. + * + * @param bucket Indicates the pointer to the {@link OH_VBucket} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_VBucket. + * @since 10 + */ + int (*destroyValuesBucket)(OH_VBucket *bucket); +} OH_VBucket; + +#ifdef __cplusplus +}; +#endif + +#endif // OH_VALUES_BUCKET_H diff --git a/en/native_sdk/database/rdb/relational_store.h b/en/native_sdk/database/rdb/relational_store.h new file mode 100644 index 00000000..e214b968 --- /dev/null +++ b/en/native_sdk/database/rdb/relational_store.h @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef RELATIONAL_STORE_H +#define RELATIONAL_STORE_H + +/** + * @addtogroup RDB + * @{ + * + * @brief The relational database (RDB) store manages data based on relational models. + * A complete set of mechanisms for managing local databases is provided based on the underlying SQLite. + * To satisfy different needs in complicated scenarios, the RDB module provides a series of methods for performing + * operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + + +/** + * @file relational_store.h + * + * @brief Provides methods for managing relational database (RDB) stores. + * + * @since 10 + */ + +#include "oh_cursor.h" +#include "oh_predicates.h" +#include "oh_values_bucket.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the RDB store security levels. + * + * @since 10 + */ +enum OH_Rdb_SecurityLevel { + /** + * @brief S1: indicates the low security level. + * + * If data leakage occurs, minor impact will be caused. + */ + S1 = 1, + /** + * @brief S2: indicates the medium security level. + * + * If data leakage occurs, moderate impact will be caused. + */ + S2, + /** + * @brief S3: indicates the high security level. + * + If data leakage occurs, major impact will be caused. + */ + S3, + /** + * @brief S4: indicates the critical security level. + * + * If data leakage occurs, critical impact will be caused. + */ + S4 +}; + +/** + * @brief Defines the RDB store configuration. + * + * @since 10 + */ +typedef struct { + /** Path of the database file. */ + const char *path; + /** Whether to encrypt the RDB store. */ + bool isEncrypt; + /** Security level {@link OH_Rdb_SecurityLevel} of the RDB store. */ + enum OH_Rdb_SecurityLevel securityLevel; +} OH_Rdb_Config; + +/** + * @brief Defines the database type. + * + * @since 10 + */ +typedef struct { + /** Unique identifier of the OH_Rdb_Store struct. */ + int64_t id; +} OH_Rdb_Store; + +/** + * @brief Creates an {@link OH_VObject} instance. + * + * @return Returns the pointer to the {@link OH_VObject} instance created if the operation is successful; + * returns NULL otherwise. + * @see OH_VObject. + * @since 10 + */ +OH_VObject *OH_Rdb_CreateValueObject(void); + +/** + * @brief Creates an {@link OH_VBucket} instance. + * + * @return Returns the pointer to the {@link OH_VBucket} instance created if the operation is successful; + * returns NULL otherwise. + * @see OH_VBucket. + * @since 10 + */ +OH_VBucket *OH_Rdb_CreateValuesBucket(void); + +/** + * @brief Creates an {@link OH_Predicates} instance. + * + * @param table Indicates the pointer to the name of the database table. + * @return Returns the pointer to the {@link OH_Predicates} instance created if the operation is successful; + * returns NULL otherwise. + * @see OH_Predicates. + * @since 10 + */ +OH_Predicates *OH_Rdb_CreatePredicates(const char *table); + +/** + * @brief Obtains an {@link OH_Rdb_Store} instance for RDB store operations. + * + * @param config Indicates the pointer to the {@link OH_Rdb_Config} instance, which is the RDB store configuration. + * @param errCode Indicates the pointer to the function execution status. + * @return Returns the pointer to the {@link OH_Rdb_Store} instance created if the operation is successful; + * returns NULL otherwise. + * @see OH_Rdb_Config, OH_Rdb_Store. + * @since 10 + */ +OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode); + +/** + * @brief Destroys a {@link OH_Rdb_Store} instance and reclaims the memory occupied. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_CloseStore(OH_Rdb_Store *store); + +/** + * @brief Deletes an RDB store based on the specified database file configuration. + * + * @param path Indicates the pointer to the database file path. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @since 10 + */ +int OH_Rdb_DeleteStore(const char *path); + +/** + * @brief Insert a row of data into a table. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param table Indicates the pointer to the name of the target table. + * @param valuesBucket Indicates the pointer to the data row {@link OH_VBucket} to insert. + * @return Returns the row ID if the operation is successful; returns an error code otherwise. + * @see OH_Rdb_Store, OH_VBucket. + * @since 10 + */ +int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket); + +/** + * @brief Updates data in an RDB store based on specified conditions. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param valuesBucket Indicates the pointer to the data {@link OH_VBucket} to be written to the table. + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance, which specifies the update conditions. + * @return Returns the number of updated rows if the operation is successful; returns an error code otherwise. + * @see OH_Rdb_Store, OH_Bucket, OH_Predicates. + * @since 10 + */ +int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates); + +/** + * @brief Deletes data from an RDB store based on specified conditions. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance, which specifies the deletion conditions. + * @return Returns the number of rows deleted if the operation is successful; returns an error code otherwise. + * @see OH_Rdb_Store, OH_Predicates. + * @since 10 + */ +int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates); + +/** + * @brief Queries data in an RDB store based on specified conditions. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param predicates Indicates the pointer to the {@link OH_Predicates} instance, which specifies the query conditions. + * @param columnNames Indicates the pointer to the columns to be queried. If this parameter is not specified, + * the query applies to all columns. + * @param length Indicates the length of the columnNames array. + * @return Returns the pointer to the {@link OH_Cursor} instance if the operation is successful; returns NULL otherwise. + * @see OH_Rdb_Store, OH_Predicates, OH_Cursor. + * @since 10 + */ +OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length); + +/** + * @brief Executes an SQL statement that contains specified arguments but returns no value. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param sql Indicates the pointer to the SQL statement to execute. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql); + +/** + * @brief Executes the SQL statement to query data in an RDB store. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param sql Indicates the pointer to the SQL statement to execute. + * @return Returns the pointer to the {@link OH_Cursor} instance if the operation is successful; returns NULL otherwise. + * @see OH_Rdb_Store. + * @since 10 + */ +OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql); + +/** + * @brief Starts the transaction before executing an SQL statement. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_BeginTransaction(OH_Rdb_Store *store); + +/** + * @brief Rolls back the SQL statements executed. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_RollBack(OH_Rdb_Store *store); + +/** + * @brief Submits the SQL statements executed. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Commit(OH_Rdb_Store *store); + +/** + * @brief Backs up an RDB store in the specified directory. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param databasePath Indicates the pointer to the backup file path of the database. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath); + +/** + * @brief Restores an RDB store from the specified database backup file. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param databasePath Indicates the pointer to the backup file path of the database. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath); + +/** + * @brief Obtains the RDB store version. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param version Indicates the pointer to the version number. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version); + +/** + * @brief Sets the RDB store version. + * + * @param store Indicates the pointer to the {@link OH_Rdb_Store} instance. + * @param version Indicates the version to set. + * @return Returns the operation result. If the operation fails, an error code is returned. + * @see OH_Rdb_Store. + * @since 10 + */ +int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version); + +#ifdef __cplusplus +}; +#endif + +#endif // RELATIONAL_STORE_H diff --git a/en/native_sdk/database/rdb/relational_store_error_code.h b/en/native_sdk/database/rdb/relational_store_error_code.h new file mode 100644 index 00000000..71d32aa4 --- /dev/null +++ b/en/native_sdk/database/rdb/relational_store_error_code.h @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2023 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. + */ + +#ifndef RELATIONAL_STORE_ERRNO_CODE_H +#define RELATIONAL_STORE_ERRNO_CODE_H + +/** + * @addtogroup RDB + * @{ + * + * The relational database (RDB) store manages data based on relational models. + * A complete set of mechanisms for managing local databases is provided based on the underlying SQLite. + * To satisfy different needs in complicated scenarios, the RDB module provides a series of methods for performing + * operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 10 + */ + + +/** + * @file relational_store_error_code.h + * + * @brief Declares the error code information about a relational database (RDB) store. + * + * @since 10 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes. + * + * @since 10 + */ +typedef enum OH_Rdb_ErrCode { + /** + * Execution failed. + */ + RDB_ERR = -1, + + /** + * Execution successful. + */ + RDB_OK = 0, + + /** + * Error code base. + */ + E_BASE = 14800000, + + /** + * Capability not supported. + */ + RDB_E_NOT_SUPPORTED = 801, + + /** + * Error codes for common exceptions. + */ + RDB_E_ERROR = E_BASE, + + /** + * Invalid parameter. + */ + RDB_E_INVALID_ARGS = (E_BASE + 1), + + /** + * Failed to update data because the RDB store is read-only. + */ + RDB_E_CANNOT_UPDATE_READONLY = (E_BASE + 2), + + /** + * Failed to delete the file. + */ + RDB_E_REMOVE_FILE = (E_BASE + 3), + + /** + * The table name is empty. + */ + RDB_E_EMPTY_TABLE_NAME = (E_BASE + 5), + + /** + * The KV pair is empty. + */ + RDB_E_EMPTY_VALUES_BUCKET = (E_BASE + 6), + + /** + * Failed to execute the SQL statement for query. + */ + RDB_E_EXECUTE_IN_STEP_QUERY = (E_BASE + 7), + + /** + * Invalid column index. + */ + RDB_E_INVALID_COLUMN_INDEX = (E_BASE + 8), + + /** + * Invalid column type. + */ + RDB_E_INVALID_COLUMN_TYPE = (E_BASE + 9), + + /** + * The file name is empty. + */ + RDB_E_EMPTY_FILE_NAME = (E_BASE + 10), + + /** + * Invalid file path. + */ + RDB_E_INVALID_FILE_PATH = (E_BASE + 11), + + /** + * Failed to start the transaction. + */ + RDB_E_TRANSACTION_IN_EXECUTE = (E_BASE + 12), + + /** + * Failed to precompile the SQL statement. + */ + RDB_E_INVALID_STATEMENT = (E_BASE + 13), + + /** + * Failed to write data in a read connection. + */ + RDB_E_EXECUTE_WRITE_IN_READ_CONNECTION = (E_BASE + 14), + + /** + * Failed to start the transaction in a read connection. + */ + RDB_E_BEGIN_TRANSACTION_IN_READ_CONNECTION = (E_BASE + 15), + + /** + * The transaction to start does not exist in the database session. + */ + RDB_E_NO_TRANSACTION_IN_SESSION = (E_BASE + 16), + + /** + * Failed to execute multiple queries a database session. + */ + RDB_E_MORE_STEP_QUERY_IN_ONE_SESSION = (E_BASE + 17), + + /** + * The result set does not contain any record. + */ + RDB_E_NO_ROW_IN_QUERY = (E_BASE + 18), + + /** + * The number of bound parameters in the SQL statement is invalid. + */ + RDB_E_INVALID_BIND_ARGS_COUNT = (E_BASE + 19), + + /** + * Invalid object type. + */ + RDB_E_INVALID_OBJECT_TYPE = (E_BASE + 20), + + /** + * Invalid conflict resolution type. + */ + RDB_E_INVALID_CONFLICT_FLAG = (E_BASE + 21), + + /** + * The HAVING keyword can be used only after GROUP BY. + */ + RDB_E_HAVING_CLAUSE_NOT_IN_GROUP_BY = (E_BASE + 22), + + /** + * The result set in step format is not supported. + */ + RDB_E_NOT_SUPPORTED_BY_STEP_RESULT_SET = (E_BASE + 23), + + /** + * Failed to query the result set. + */ + RDB_E_STEP_RESULT_SET_CROSS_THREADS = (E_BASE + 24), + + /** + * The result set query statement is not executed. + */ + RDB_E_STEP_RESULT_QUERY_NOT_EXECUTED = (E_BASE + 25), + + /** + * The cursor is already in the last row of the result set. + */ + RDB_E_STEP_RESULT_IS_AFTER_LAST = (E_BASE + 26), + + /** + * The number of result set query times exceeds the limit. + */ + RDB_E_STEP_RESULT_QUERY_EXCEEDED = (E_BASE + 27), + + /** + * The SQL statement is not precompiled. + */ + RDB_E_STATEMENT_NOT_PREPARED = (E_BASE + 28), + + /** + * Incorrect database execution result. + */ + RDB_E_EXECUTE_RESULT_INCORRECT = (E_BASE + 29), + + /** + * The result set is closed. + */ + RDB_E_STEP_RESULT_CLOSED = (E_BASE + 30), + + /** + * Relative path. + */ + RDB_E_RELATIVE_PATH = (E_BASE + 31), + + /** + * The new encrypt key file is empty. + */ + RDB_E_EMPTY_NEW_ENCRYPT_KEY = (E_BASE + 32), + + /** + * The RDB store is non-encrypted, which is cannot be changed. + */ + RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED = (E_BASE + 33), + + /** + * The database does not respond when the database key is updated. + */ + RDB_E_CHANGE_ENCRYPT_KEY_IN_BUSY = (E_BASE + 34), + + /** + * The precompiled SQL statement is not initialized. + */ + RDB_E_STEP_STATEMENT_NOT_INIT = (E_BASE + 35), + + /** + * The WAL mode does not support the ATTACH operation. + */ + RDB_E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE = (E_BASE + 36), + + /** + * Failed to create the folder. + */ + RDB_E_CREATE_FOLDER_FAIL = (E_BASE + 37), + + /** + * Failed to build the SQL statements. + */ + RDB_E_SQLITE_SQL_BUILDER_NORMALIZE_FAIL = (E_BASE + 38), + + /** + * The database session does not provide a connection. + */ + RDB_E_STORE_SESSION_NOT_GIVE_CONNECTION_TEMPORARILY = (E_BASE + 39), + + /** + * The transaction does not exist in the database session. + */ + RDB_E_STORE_SESSION_NO_CURRENT_TRANSACTION = (E_BASE + 40), + + /** + * The current operation is not supported. + */ + RDB_E_NOT_SUPPORT = (E_BASE + 41), + + /** + * Invalid PARCEL. + */ + RDB_E_INVALID_PARCEL = (E_BASE + 42), + + /** + * Failed to execute query. + */ + RDB_E_QUERY_IN_EXECUTE = (E_BASE + 43), + + /** + * Failed to set the persistence of the database file in WAL mode. + */ + RDB_E_SET_PERSIST_WAL = (E_BASE + 44), + + /** + * The database does not exist. + */ + RDB_E_DB_NOT_EXIST = (E_BASE + 45), + + /** + * The number of read connections to set is greater than the limit. + */ + RDB_E_ARGS_READ_CON_OVERLOAD = (E_BASE + 46), + + /** + * The WAL log file size exceeds the default value. + */ + RDB_E_WAL_SIZE_OVER_LIMIT = (E_BASE + 47), + + /** + * The number of database connections has reached the limit. + */ + RDB_E_CON_OVER_LIMIT = (E_BASE + 48) +} OH_Rdb_ErrCode; + +#ifdef __cplusplus +}; +#endif + +#endif // RELATIONAL_STORE_ERRNO_CODE_H -- Gitee