aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_mysql_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_mysql_lib.h')
-rw-r--r--src/include/gnunet_mysql_lib.h157
1 files changed, 0 insertions, 157 deletions
diff --git a/src/include/gnunet_mysql_lib.h b/src/include/gnunet_mysql_lib.h
deleted file mode 100644
index 843d3ccb3..000000000
--- a/src/include/gnunet_mysql_lib.h
+++ /dev/null
@@ -1,157 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012 GNUnet e.V.
4
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.
9
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.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @author Christian Grothoff
22 *
23 * @file
24 * Helper library to access a MySQL database
25 *
26 * @defgroup mysql MySQL library
27 * Helper library to access a MySQL database.
28 * @{
29 */
30#ifndef GNUNET_MYSQL_LIB_H
31#define GNUNET_MYSQL_LIB_H
32
33#include "gnunet_util_lib.h"
34#include <mysql/mysql.h>
35
36#ifdef __cplusplus
37extern "C"
38{
39#if 0 /* keep Emacsens' auto-indent happy */
40}
41#endif
42#endif
43
44#ifdef HAVE_MYSQL8
45 typedef bool MYSQL_BOOL;
46#else
47 typedef my_bool MYSQL_BOOL; //MySQL < 8 wants this
48#endif
49
50
51/**
52 * Mysql context.
53 */
54struct GNUNET_MYSQL_Context;
55
56
57/**
58 * Handle for a prepared statement.
59 */
60struct GNUNET_MYSQL_StatementHandle;
61
62
63/**
64 * Type of a callback that will be called for each
65 * data set returned from MySQL.
66 *
67 * @param cls user-defined argument
68 * @param num_values number of elements in values
69 * @param values values returned by MySQL
70 * @return #GNUNET_OK to continue iterating, #GNUNET_SYSERR to abort
71 */
72typedef int
73(*GNUNET_MYSQL_DataProcessor) (void *cls,
74 unsigned int num_values,
75 MYSQL_BIND *values);
76
77
78/**
79 * Create a mysql context.
80 *
81 * @param cfg configuration
82 * @param section configuration section to use to get MySQL configuration options
83 * @return the mysql context
84 */
85struct GNUNET_MYSQL_Context *
86GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
87 const char *section);
88
89
90/**
91 * Destroy a mysql context. Also frees all associated prepared statements.
92 *
93 * @param mc context to destroy
94 */
95void
96GNUNET_MYSQL_context_destroy (struct GNUNET_MYSQL_Context *mc);
97
98
99/**
100 * Close database connection and all prepared statements (we got a DB
101 * error). The connection will automatically be re-opened and
102 * statements will be re-prepared if they are needed again later.
103 *
104 * @param mc mysql context
105 */
106void
107GNUNET_MYSQL_statements_invalidate (struct GNUNET_MYSQL_Context *mc);
108
109
110/**
111 * Get internal handle for a prepared statement. This function should rarely
112 * be used, and if, with caution! On failures during the interaction with
113 * the handle, you must call #GNUNET_MYSQL_statements_invalidate()!
114 *
115 * @param sh prepared statement to introspect
116 * @return MySQL statement handle, NULL on error
117 */
118MYSQL_STMT *
119GNUNET_MYSQL_statement_get_stmt (struct GNUNET_MYSQL_StatementHandle *sh);
120
121
122/**
123 * Prepare a statement. Prepared statements are automatically discarded
124 * when the MySQL context is destroyed.
125 *
126 * @param mc mysql context
127 * @param query query text
128 * @return prepared statement, NULL on error
129 */
130struct GNUNET_MYSQL_StatementHandle *
131GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc,
132 const char *query);
133
134
135/**
136 * Run a SQL statement.
137 *
138 * @param mc mysql context
139 * @param sql SQL statement to run
140 * @return #GNUNET_OK on success
141 * #GNUNET_SYSERR if there was a problem
142 */
143int
144GNUNET_MYSQL_statement_run (struct GNUNET_MYSQL_Context *mc,
145 const char *sql);
146
147
148#if 0 /* keep Emacsens' auto-indent happy */
149{
150#endif
151#ifdef __cplusplus
152}
153#endif
154
155#endif
156
157/** @} */ /* end of group */