2 This file is part of GNUnet
3 Copyright (C) 2018 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
9 GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License along with
14 GNUnet; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
17 * @file sq/sq_prepare.c
18 * @brief helper functions for executing SQL statements
19 * @author Christian Grothoff
22 #include "gnunet_sq_lib.h"
26 * Create a `struct GNUNET_SQ_PrepareStatement`
28 * @param sql actual SQL statement
29 * @param pstmt where to store the handle
30 * @return initialized struct
32 struct GNUNET_SQ_PrepareStatement
33 GNUNET_SQ_make_prepare (const char *sql,
36 struct GNUNET_SQ_PrepareStatement ps = {
47 * Prepare all statements given in the (NULL,NULL)-terminated
50 * @param dbh database to use
51 * @param ps array of statements to prepare
52 * @return #GNUNET_OK on success
55 GNUNET_SQ_prepare (sqlite3 *dbh,
56 const struct GNUNET_SQ_PrepareStatement *ps)
58 for (unsigned int i=0;NULL != ps[i].sql;i++)
60 const char *epos = NULL;
64 (ret = sqlite3_prepare_v2 (dbh,
70 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
71 "Failed to prepare SQL `%s': error %d at %s\n",
81 /* end of sq_prepare.c */