1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RELATIONAL_STORE_ERRNO_CODE_H
17 #define RELATIONAL_STORE_ERRNO_CODE_H
18 
19 /**
20  * @addtogroup RDB
21  * @{
22  *
23  * @brief The relational database (RDB) store manages data based on relational models.
24  * With the underlying SQLite database, the RDB store provides a complete mechanism for managing local databases.
25  * To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations
26  * such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
27  *
28  * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
29  * @since 10
30  */
31 
32 
33 /**
34  * @file relational_store_error_code.h
35  *
36  * @brief Declaration error code information.
37  *
38  * @since 10
39  */
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @brief Indicates the error code information.
47  *
48  * @since 10
49  */
50 typedef enum OH_Rdb_ErrCode {
51     /**
52      * Indicates that the function execution exception.
53      */
54     RDB_ERR = -1,
55 
56     /**
57      * The error code in the correct case.
58      */
59     RDB_OK = 0,
60 
61     /**
62      * @brief The base code of the exception error code.
63      */
64     E_BASE = 14800000,
65 
66     /**
67      * @brief The error when the capability not supported.
68      */
69     RDB_E_NOT_SUPPORTED = 801,
70 
71     /**
72      * @brief The error code for common exceptions.
73      */
74     RDB_E_ERROR = E_BASE,
75 
76     /**
77      * @brief The error code for common invalid args.
78      */
79     RDB_E_INVALID_ARGS = (E_BASE + 1),
80 
81     /**
82      * @brief The error code for upgrade the read-only store.
83      */
84     RDB_E_CANNOT_UPDATE_READONLY = (E_BASE + 2),
85 
86     /**
87      * @brief The error code when deleting a file fails.
88      */
89     RDB_E_REMOVE_FILE = (E_BASE + 3),
90 
91     /**
92      * @brief The error code for a table name is empty.
93      */
94     RDB_E_EMPTY_TABLE_NAME = (E_BASE + 5),
95 
96     /**
97      * @brief The error code for a values bucket is empty.
98      */
99     RDB_E_EMPTY_VALUES_BUCKET = (E_BASE + 6),
100 
101     /**
102      * @brief The error code when the sql is not select.
103      */
104     RDB_E_EXECUTE_IN_STEP_QUERY = (E_BASE + 7),
105 
106     /**
107      * @brief The error code for the column index is invalid.
108      */
109     RDB_E_INVALID_COLUMN_INDEX = (E_BASE + 8),
110 
111     /**
112      * @brief The error code for the column type is invalid.
113      */
114     RDB_E_INVALID_COLUMN_TYPE = (E_BASE + 9),
115 
116     /**
117      * @brief The error code for a file name is empty.
118      */
119     RDB_E_EMPTY_FILE_NAME = (E_BASE + 10),
120 
121     /**
122      * @brief The error for the current file path is invalid.
123      */
124     RDB_E_INVALID_FILE_PATH = (E_BASE + 11),
125 
126     /**
127      * @brief The error code when using transactions.
128      */
129     RDB_E_TRANSACTION_IN_EXECUTE = (E_BASE + 12),
130 
131     /**
132      * @brief The error code for the current status is invalid.
133      */
134     RDB_E_INVALID_STATEMENT = (E_BASE + 13),
135 
136     /**
137      * @brief The error code when execute write operation in read connection.
138      */
139     RDB_E_EXECUTE_WRITE_IN_READ_CONNECTION = (E_BASE + 14),
140 
141     /**
142      * @brief The error code for execute begin transaction operation in read connection.
143      */
144     RDB_E_BEGIN_TRANSACTION_IN_READ_CONNECTION = (E_BASE + 15),
145 
146     /**
147      * @brief The error code for there are no transactions in this connection.
148      */
149     RDB_E_NO_TRANSACTION_IN_SESSION = (E_BASE + 16),
150 
151     /**
152      * @brief The error code when begin more step query in one session.
153      */
154     RDB_E_MORE_STEP_QUERY_IN_ONE_SESSION = (E_BASE + 17),
155 
156     /**
157      * @brief The error code when the current statement doesn't contains one row result data.
158      */
159     RDB_E_NO_ROW_IN_QUERY = (E_BASE + 18),
160 
161     /**
162      * @brief The error code for the bind arguments count is invalid.
163      */
164     RDB_E_INVALID_BIND_ARGS_COUNT = (E_BASE + 19),
165 
166     /**
167      * @brief The error code for the object type is invalid.
168      */
169     RDB_E_INVALID_OBJECT_TYPE = (E_BASE + 20),
170 
171     /**
172      * @brief The error code for the conflict flag is invalid.
173      */
174     RDB_E_INVALID_CONFLICT_FLAG = (E_BASE + 21),
175 
176     /**
177      * @brief The error code for having clause not in group.
178      */
179     RDB_E_HAVING_CLAUSE_NOT_IN_GROUP_BY = (E_BASE + 22),
180 
181     /**
182      * @brief The error code for not supported by step result set.
183      */
184     RDB_E_NOT_SUPPORTED_BY_STEP_RESULT_SET = (E_BASE + 23),
185 
186     /**
187      * @brief The error code for step result current tid not equal to object's tid.
188      */
189     RDB_E_STEP_RESULT_SET_CROSS_THREADS = (E_BASE + 24),
190 
191     /**
192      * @brief The error code when the result query was not executed.
193      */
194     RDB_E_STEP_RESULT_QUERY_NOT_EXECUTED = (E_BASE + 25),
195 
196     /**
197      * @brief The error code for the result set cursor is after the last row.
198      */
199     RDB_E_STEP_RESULT_IS_AFTER_LAST = (E_BASE + 26),
200 
201     /**
202      * @brief The error code for the result set query exceeded.
203      */
204     RDB_E_STEP_RESULT_QUERY_EXCEEDED = (E_BASE + 27),
205 
206     /**
207      * @brief The error code for the statement not prepared.
208      */
209     RDB_E_STATEMENT_NOT_PREPARED = (E_BASE + 28),
210 
211     /**
212      * @brief The error code for the result set is incorrect.
213      */
214     RDB_E_EXECUTE_RESULT_INCORRECT = (E_BASE + 29),
215 
216     /**
217      * @brief The error code when the result set is closed.
218      */
219     RDB_E_STEP_RESULT_CLOSED = (E_BASE + 30),
220 
221     /**
222      * @brief The error code when input relative path.
223      */
224     RDB_E_RELATIVE_PATH = (E_BASE + 31),
225 
226     /**
227      * @brief The error code for the new encrypt key is empty.
228      */
229     RDB_E_EMPTY_NEW_ENCRYPT_KEY = (E_BASE + 32),
230 
231     /**
232      * @brief The error code for change unencrypted to encrypted.
233      */
234     RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED = (E_BASE + 33),
235 
236     /**
237      * @brief The error code for change encrypt in busy.
238      */
239     RDB_E_CHANGE_ENCRYPT_KEY_IN_BUSY = (E_BASE + 34),
240 
241     /**
242      * @brief The error code when the statement not initialized.
243      */
244     RDB_E_STEP_STATEMENT_NOT_INIT = (E_BASE + 35),
245 
246     /**
247      * @brief The error code for the attach is not supported in WAL journal mode.
248      */
249     RDB_E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE = (E_BASE + 36),
250 
251     /**
252      * @brief The error code when create folder failed.
253      */
254     RDB_E_CREATE_FOLDER_FAIL = (E_BASE + 37),
255 
256     /**
257      * @brief The error for SQL builder normalize failed.
258      */
259     RDB_E_SQLITE_SQL_BUILDER_NORMALIZE_FAIL = (E_BASE + 38),
260 
261     /**
262      * @brief The error for store session not give connection temporarily.
263      */
264     RDB_E_STORE_SESSION_NOT_GIVE_CONNECTION_TEMPORARILY = (E_BASE + 39),
265 
266     /**
267      * @brief The error for store session not current transaction.
268      */
269     RDB_E_STORE_SESSION_NO_CURRENT_TRANSACTION = (E_BASE + 40),
270 
271     /**
272      * @brief The error for not supported the current operation.
273      */
274     RDB_E_NOT_SUPPORT = (E_BASE + 41),
275 
276     /**
277      * @brief The error for the current parcel is invalid.
278      */
279     RDB_E_INVALID_PARCEL = (E_BASE + 42),
280 
281     /**
282      * @brief The error code when using sqlite3_step function failed.
283      */
284     RDB_E_QUERY_IN_EXECUTE = (E_BASE + 43),
285 
286     /**
287      * @brief The error for set persist WAL.
288      */
289     RDB_E_SET_PERSIST_WAL = (E_BASE + 44),
290 
291     /**
292      * @brief The error when the database does not exist.
293      */
294     RDB_E_DB_NOT_EXIST = (E_BASE + 45),
295 
296     /**
297      * @brief The error when the read connection count is overload.
298      */
299     RDB_E_ARGS_READ_CON_OVERLOAD = (E_BASE + 46),
300 
301     /**
302      * @brief The error when the wal file size over default limit.
303     */
304     RDB_E_WAL_SIZE_OVER_LIMIT = (E_BASE + 47),
305 
306     /**
307      * @brief The error when the connection count is used up.
308      */
309     RDB_E_CON_OVER_LIMIT = (E_BASE + 48),
310 
311     /**
312      * @brief The secret key is corrupted or lost.
313      */
314     RDB_E_INVALID_SECRET_KEY = (E_BASE + 49)
315 } OH_Rdb_ErrCode;
316 
317 #ifdef __cplusplus
318 };
319 #endif
320 
321 #endif // RELATIONAL_STORE_ERRNO_CODE_H
322