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
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,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
16 * @file sq/sq_prepare.c
17 * @brief helper functions for executing SQL statements
18 * @author Christian Grothoff
21 #include "gnunet_sq_lib.h"
25 * Create a `struct GNUNET_SQ_PrepareStatement`
27 * @param sql actual SQL statement
28 * @param pstmt where to store the handle
29 * @return initialized struct
31 struct GNUNET_SQ_PrepareStatement
32 GNUNET_SQ_make_prepare (const char *sql,
35 struct GNUNET_SQ_PrepareStatement ps = {
46 * Prepare all statements given in the (NULL,NULL)-terminated
49 * @param dbh database to use
50 * @param ps array of statements to prepare
51 * @return #GNUNET_OK on success
54 GNUNET_SQ_prepare (sqlite3 *dbh,
55 const struct GNUNET_SQ_PrepareStatement *ps)
57 for (unsigned int i=0;NULL != ps[i].sql;i++)
59 const char *epos = NULL;
63 (ret = sqlite3_prepare_v2 (dbh,
69 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
70 "Failed to prepare SQL `%s': error %d at %s\n",
80 /* end of sq_prepare.c */