diff options
Diffstat (limited to 'src/sq/sq_prepare.c')
-rw-r--r-- | src/sq/sq_prepare.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/sq/sq_prepare.c b/src/sq/sq_prepare.c index ab5ee09f5..3df4b80bc 100644 --- a/src/sq/sq_prepare.c +++ b/src/sq/sq_prepare.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2018 GNUnet e.V. | 3 | Copyright (C) 2018 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file sq/sq_prepare.c | 21 | * @file sq/sq_prepare.c |
22 | * @brief helper functions for executing SQL statements | 22 | * @brief helper functions for executing SQL statements |
@@ -34,8 +34,8 @@ | |||
34 | * @return initialized struct | 34 | * @return initialized struct |
35 | */ | 35 | */ |
36 | struct GNUNET_SQ_PrepareStatement | 36 | struct GNUNET_SQ_PrepareStatement |
37 | GNUNET_SQ_make_prepare (const char *sql, | 37 | GNUNET_SQ_make_prepare(const char *sql, |
38 | sqlite3_stmt **pstmt) | 38 | sqlite3_stmt **pstmt) |
39 | { | 39 | { |
40 | struct GNUNET_SQ_PrepareStatement ps = { | 40 | struct GNUNET_SQ_PrepareStatement ps = { |
41 | .sql = sql, | 41 | .sql = sql, |
@@ -56,29 +56,29 @@ GNUNET_SQ_make_prepare (const char *sql, | |||
56 | * @return #GNUNET_OK on success | 56 | * @return #GNUNET_OK on success |
57 | */ | 57 | */ |
58 | int | 58 | int |
59 | GNUNET_SQ_prepare (sqlite3 *dbh, | 59 | GNUNET_SQ_prepare(sqlite3 *dbh, |
60 | const struct GNUNET_SQ_PrepareStatement *ps) | 60 | const struct GNUNET_SQ_PrepareStatement *ps) |
61 | { | 61 | { |
62 | for (unsigned int i=0;NULL != ps[i].sql;i++) | 62 | for (unsigned int i = 0; NULL != ps[i].sql; i++) |
63 | { | ||
64 | const char *epos = NULL; | ||
65 | int ret; | ||
66 | |||
67 | if (SQLITE_OK != | ||
68 | (ret = sqlite3_prepare_v2 (dbh, | ||
69 | ps[i].sql, | ||
70 | strlen (ps[i].sql), | ||
71 | ps[i].pstmt, | ||
72 | &epos))) | ||
73 | { | 63 | { |
74 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 64 | const char *epos = NULL; |
75 | "Failed to prepare SQL `%s': error %d at %s\n", | 65 | int ret; |
76 | ps[i].sql, | 66 | |
77 | ret, | 67 | if (SQLITE_OK != |
78 | epos); | 68 | (ret = sqlite3_prepare_v2(dbh, |
79 | return GNUNET_SYSERR; | 69 | ps[i].sql, |
70 | strlen(ps[i].sql), | ||
71 | ps[i].pstmt, | ||
72 | &epos))) | ||
73 | { | ||
74 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
75 | "Failed to prepare SQL `%s': error %d at %s\n", | ||
76 | ps[i].sql, | ||
77 | ret, | ||
78 | epos); | ||
79 | return GNUNET_SYSERR; | ||
80 | } | ||
80 | } | 81 | } |
81 | } | ||
82 | return GNUNET_OK; | 82 | return GNUNET_OK; |
83 | } | 83 | } |
84 | 84 | ||