diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-06-06 18:01:43 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-06-06 18:01:43 +0200 |
commit | 08912967ec589efc267c1e5d296cf9e25ab1e95c (patch) | |
tree | 1b96b88dc9fec9fdd78f5f54af2b671f8cc5ab1e | |
parent | 8f5ab32688caee1758056baa4e52a5a339b931e9 (diff) | |
download | gnunet-08912967ec589efc267c1e5d296cf9e25ab1e95c.tar.gz gnunet-08912967ec589efc267c1e5d296cf9e25ab1e95c.zip |
removing dead libgnunetpostgres
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnunet_postgres_lib.h | 178 | ||||
-rw-r--r-- | src/postgres/Makefile.am | 24 | ||||
-rw-r--r-- | src/postgres/postgres.c | 205 | ||||
-rw-r--r-- | src/psycstore/Makefile.am | 1 | ||||
-rw-r--r-- | src/psycstore/plugin_psycstore_postgres.c | 1 |
8 files changed, 1 insertions, 412 deletions
diff --git a/configure.ac b/configure.ac index a7b90597a..77fd55a19 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1681,7 +1681,6 @@ pkgconfig/gnunetnat.pc | |||
1681 | pkgconfig/gnunetnse.pc | 1681 | pkgconfig/gnunetnse.pc |
1682 | pkgconfig/gnunetpeerinfo.pc | 1682 | pkgconfig/gnunetpeerinfo.pc |
1683 | pkgconfig/gnunetpq.pc | 1683 | pkgconfig/gnunetpq.pc |
1684 | pkgconfig/gnunetpostgres.pc | ||
1685 | pkgconfig/gnunetpsyc.pc | 1684 | pkgconfig/gnunetpsyc.pc |
1686 | pkgconfig/gnunetpsycstore.pc | 1685 | pkgconfig/gnunetpsycstore.pc |
1687 | pkgconfig/gnunetregex.pc | 1686 | pkgconfig/gnunetregex.pc |
diff --git a/src/Makefile.am b/src/Makefile.am index e466cbc28..4e0a5ba94 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -49,7 +49,7 @@ if HAVE_MYSQL | |||
49 | endif | 49 | endif |
50 | 50 | ||
51 | if HAVE_POSTGRESQL | 51 | if HAVE_POSTGRESQL |
52 | POSTGRES_DIR = pq postgres | 52 | POSTGRES_DIR = pq |
53 | endif | 53 | endif |
54 | 54 | ||
55 | if HAVE_MHD | 55 | if HAVE_MHD |
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index b745da125..a1240b05c 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -90,7 +90,6 @@ gnunetinclude_HEADERS = \ | |||
90 | gnunet_peerstore_service.h \ | 90 | gnunet_peerstore_service.h \ |
91 | gnunet_plugin_lib.h \ | 91 | gnunet_plugin_lib.h \ |
92 | gnunet_pq_lib.h \ | 92 | gnunet_pq_lib.h \ |
93 | gnunet_postgres_lib.h \ | ||
94 | gnunet_psycstore_plugin.h \ | 93 | gnunet_psycstore_plugin.h \ |
95 | gnunet_psycstore_service.h \ | 94 | gnunet_psycstore_service.h \ |
96 | gnunet_psyc_service.h \ | 95 | gnunet_psyc_service.h \ |
diff --git a/src/include/gnunet_postgres_lib.h b/src/include/gnunet_postgres_lib.h deleted file mode 100644 index 66fc2a5df..000000000 --- a/src/include/gnunet_postgres_lib.h +++ /dev/null | |||
@@ -1,178 +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 | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @author Christian Grothoff | ||
22 | * | ||
23 | * @file | ||
24 | * Helper library to access a PostgreSQL database | ||
25 | * | ||
26 | * @defgroup postgres PostgreSQL library | ||
27 | * Helper library to access a PostgreSQL database. | ||
28 | * @{ | ||
29 | */ | ||
30 | #ifndef GNUNET_POSTGRES_LIB_H | ||
31 | #define GNUNET_POSTGRES_LIB_H | ||
32 | |||
33 | #include "gnunet_util_lib.h" | ||
34 | #include <libpq-fe.h> | ||
35 | |||
36 | #ifdef __cplusplus | ||
37 | extern "C" | ||
38 | { | ||
39 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
40 | } | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Check if the result obtained from Postgres has | ||
47 | * the desired status code. If not, log an error, clear the | ||
48 | * result and return #GNUNET_SYSERR. | ||
49 | * | ||
50 | * @param dbh database handle | ||
51 | * @param ret return value from database operation to check | ||
52 | * @param expected_status desired status | ||
53 | * @param command description of the command that was run | ||
54 | * @param args arguments given to the command | ||
55 | * @param filename name of the source file where the command was run | ||
56 | * @param line line number in the source file | ||
57 | * @return #GNUNET_OK if the result is acceptable | ||
58 | */ | ||
59 | int | ||
60 | GNUNET_POSTGRES_check_result_ (PGconn *dbh, | ||
61 | PGresult *ret, | ||
62 | int expected_status, | ||
63 | const char *command, | ||
64 | const char *args, | ||
65 | const char *filename, | ||
66 | int line); | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Check if the result obtained from Postgres has | ||
71 | * the desired status code. If not, log an error, clear the | ||
72 | * result and return #GNUNET_SYSERR. | ||
73 | * | ||
74 | * @param dbh database handle | ||
75 | * @param ret return value from database operation to check | ||
76 | * @param expected_status desired status | ||
77 | * @param command description of the command that was run | ||
78 | * @param args arguments given to the command | ||
79 | * @return #GNUNET_OK if the result is acceptable | ||
80 | */ | ||
81 | #define GNUNET_POSTGRES_check_result(dbh,ret,expected_status,command,args) GNUNET_POSTGRES_check_result_(dbh,ret,expected_status,command,args,__FILE__,__LINE__) | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Run simple SQL statement (without results). | ||
86 | * | ||
87 | * @param dbh database handle | ||
88 | * @param sql statement to run | ||
89 | * @param filename filename for error reporting | ||
90 | * @param line code line for error reporting | ||
91 | * @return #GNUNET_OK on success | ||
92 | */ | ||
93 | int | ||
94 | GNUNET_POSTGRES_exec_ (PGconn *dbh, | ||
95 | const char *sql, | ||
96 | const char *filename, | ||
97 | int line); | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Run simple SQL statement (without results). | ||
102 | * | ||
103 | * @param dbh database handle | ||
104 | * @param sql statement to run | ||
105 | * @return #GNUNET_OK on success | ||
106 | */ | ||
107 | #define GNUNET_POSTGRES_exec(dbh,sql) GNUNET_POSTGRES_exec_(dbh,sql,__FILE__,__LINE__) | ||
108 | |||
109 | |||
110 | /** | ||
111 | * Prepare SQL statement. | ||
112 | * | ||
113 | * @param dbh database handle | ||
114 | * @param name name for the prepared SQL statement | ||
115 | * @param sql SQL code to prepare | ||
116 | * @param nparams number of parameters in sql | ||
117 | * @param filename filename for error reporting | ||
118 | * @param line code line for error reporting | ||
119 | * @return #GNUNET_OK on success | ||
120 | */ | ||
121 | int | ||
122 | GNUNET_POSTGRES_prepare_ (PGconn *dbh, | ||
123 | const char *name, | ||
124 | const char *sql, | ||
125 | int nparams, | ||
126 | const char *filename, | ||
127 | int line); | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Prepare SQL statement. | ||
132 | * | ||
133 | * @param dbh database handle | ||
134 | * @param name name for the prepared SQL statement | ||
135 | * @param sql SQL code to prepare | ||
136 | * @param nparams number of parameters in sql | ||
137 | * @return #GNUNET_OK on success | ||
138 | */ | ||
139 | #define GNUNET_POSTGRES_prepare(dbh,name,sql,nparams) GNUNET_POSTGRES_prepare_(dbh,name,sql,nparams,__FILE__,__LINE__) | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Connect to a postgres database | ||
144 | * | ||
145 | * @param cfg configuration | ||
146 | * @param section configuration section to use to get Postgres configuration options | ||
147 | * @return the postgres handle | ||
148 | */ | ||
149 | PGconn * | ||
150 | GNUNET_POSTGRES_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
151 | const char *section); | ||
152 | |||
153 | |||
154 | /** | ||
155 | * Delete the row identified by the given rowid (qid | ||
156 | * in postgres). | ||
157 | * | ||
158 | * @param dbh database handle | ||
159 | * @param stmt name of the prepared statement | ||
160 | * @param rowid which row to delete | ||
161 | * @return #GNUNET_OK on success | ||
162 | */ | ||
163 | int | ||
164 | GNUNET_POSTGRES_delete_by_rowid (PGconn *dbh, | ||
165 | const char *stmt, | ||
166 | uint32_t rowid); | ||
167 | |||
168 | |||
169 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
170 | { | ||
171 | #endif | ||
172 | #ifdef __cplusplus | ||
173 | } | ||
174 | #endif | ||
175 | |||
176 | #endif | ||
177 | |||
178 | /** @} */ /* end of group */ | ||
diff --git a/src/postgres/Makefile.am b/src/postgres/Makefile.am deleted file mode 100644 index 6f37e1918..000000000 --- a/src/postgres/Makefile.am +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | # This Makefile.am is in the public domain | ||
2 | AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS) | ||
3 | |||
4 | if MINGW | ||
5 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols | ||
6 | endif | ||
7 | |||
8 | if USE_COVERAGE | ||
9 | AM_CFLAGS = --coverage | ||
10 | endif | ||
11 | |||
12 | if HAVE_POSTGRESQL | ||
13 | lib_LTLIBRARIES = libgnunetpostgres.la | ||
14 | endif | ||
15 | |||
16 | libgnunetpostgres_la_SOURCES = \ | ||
17 | postgres.c | ||
18 | libgnunetpostgres_la_LIBADD = -lpq \ | ||
19 | $(top_builddir)/src/util/libgnunetutil.la | ||
20 | libgnunetpostgres_la_LDFLAGS = \ | ||
21 | $(POSTGRESQL_LDFLAGS) \ | ||
22 | $(GN_LIB_LDFLAGS) \ | ||
23 | -version-info 0:0:0 | ||
24 | |||
diff --git a/src/postgres/postgres.c b/src/postgres/postgres.c deleted file mode 100644 index 828842d9d..000000000 --- a/src/postgres/postgres.c +++ /dev/null | |||
@@ -1,205 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009, 2010, 2012 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file postgres/postgres.c | ||
22 | * @brief library to help with access to a Postgres database | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #include "platform.h" | ||
26 | #include "gnunet_postgres_lib.h" | ||
27 | |||
28 | |||
29 | /** | ||
30 | * Check if the result obtained from Postgres has | ||
31 | * the desired status code. If not, log an error, clear the | ||
32 | * result and return GNUNET_SYSERR. | ||
33 | * | ||
34 | * @param dbh database handle | ||
35 | * @param ret return value from database operation to check | ||
36 | * @param expected_status desired status | ||
37 | * @param command description of the command that was run | ||
38 | * @param args arguments given to the command | ||
39 | * @param filename name of the source file where the command was run | ||
40 | * @param line line number in the source file | ||
41 | * @return #GNUNET_OK if the result is acceptable | ||
42 | */ | ||
43 | int | ||
44 | GNUNET_POSTGRES_check_result_ (PGconn *dbh, | ||
45 | PGresult *ret, | ||
46 | int expected_status, | ||
47 | const char *command, | ||
48 | const char *args, | ||
49 | const char *filename, | ||
50 | int line) | ||
51 | { | ||
52 | if (ret == NULL) | ||
53 | { | ||
54 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
55 | "postgres", | ||
56 | "Postgres failed to allocate result for `%s:%s' at %s:%d\n", | ||
57 | command, | ||
58 | args, | ||
59 | filename, | ||
60 | line); | ||
61 | return GNUNET_SYSERR; | ||
62 | } | ||
63 | if (PQresultStatus (ret) != expected_status) | ||
64 | { | ||
65 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | ||
66 | "postgres", | ||
67 | _("`%s:%s' failed at %s:%d with error: %s\n"), | ||
68 | command, | ||
69 | args, | ||
70 | filename, | ||
71 | line, | ||
72 | PQerrorMessage (dbh)); | ||
73 | PQclear (ret); | ||
74 | return GNUNET_SYSERR; | ||
75 | } | ||
76 | return GNUNET_OK; | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Run simple SQL statement (without results). | ||
82 | * | ||
83 | * @param dbh database handle | ||
84 | * @param sql statement to run | ||
85 | * @param filename filename for error reporting | ||
86 | * @param line code line for error reporting | ||
87 | * @return #GNUNET_OK on success | ||
88 | */ | ||
89 | int | ||
90 | GNUNET_POSTGRES_exec_ (PGconn * dbh, | ||
91 | const char *sql, | ||
92 | const char *filename, | ||
93 | int line) | ||
94 | { | ||
95 | PGresult *ret; | ||
96 | |||
97 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
98 | "Executing SQL statement `%s' at %s:%d\n", | ||
99 | sql, | ||
100 | filename, | ||
101 | line); | ||
102 | ret = PQexec (dbh, | ||
103 | sql); | ||
104 | if (GNUNET_OK != | ||
105 | GNUNET_POSTGRES_check_result_ (dbh, | ||
106 | ret, | ||
107 | PGRES_COMMAND_OK, | ||
108 | "PQexec", | ||
109 | sql, | ||
110 | filename, | ||
111 | line)) | ||
112 | return GNUNET_SYSERR; | ||
113 | PQclear (ret); | ||
114 | return GNUNET_OK; | ||
115 | } | ||
116 | |||
117 | |||
118 | /** | ||
119 | * Prepare SQL statement. | ||
120 | * | ||
121 | * @param dbh database handle | ||
122 | * @param name name for the prepared SQL statement | ||
123 | * @param sql SQL code to prepare | ||
124 | * @param nparams number of parameters in sql | ||
125 | * @param filename filename for error reporting | ||
126 | * @param line code line for error reporting | ||
127 | * @return #GNUNET_OK on success | ||
128 | */ | ||
129 | int | ||
130 | GNUNET_POSTGRES_prepare_ (PGconn *dbh, | ||
131 | const char *name, | ||
132 | const char *sql, | ||
133 | int nparams, | ||
134 | const char *filename, | ||
135 | int line) | ||
136 | { | ||
137 | PGresult *ret; | ||
138 | |||
139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
140 | "Preparing SQL statement `%s' as `%s' at %s:%d\n", | ||
141 | sql, | ||
142 | name, | ||
143 | filename, | ||
144 | line); | ||
145 | ret = PQprepare (dbh, | ||
146 | name, | ||
147 | sql, | ||
148 | nparams, NULL); | ||
149 | if (GNUNET_OK != | ||
150 | GNUNET_POSTGRES_check_result_ (dbh, | ||
151 | ret, | ||
152 | PGRES_COMMAND_OK, | ||
153 | "PQprepare", | ||
154 | sql, | ||
155 | filename, | ||
156 | line)) | ||
157 | return GNUNET_SYSERR; | ||
158 | PQclear (ret); | ||
159 | return GNUNET_OK; | ||
160 | } | ||
161 | |||
162 | |||
163 | /** | ||
164 | * Delete the row identified by the given rowid (qid | ||
165 | * in postgres). | ||
166 | * | ||
167 | * @param dbh database handle | ||
168 | * @param stmt name of the prepared statement | ||
169 | * @param rowid which row to delete | ||
170 | * @return #GNUNET_OK on success | ||
171 | */ | ||
172 | int | ||
173 | GNUNET_POSTGRES_delete_by_rowid (PGconn * dbh, | ||
174 | const char *stmt, | ||
175 | uint32_t rowid) | ||
176 | { | ||
177 | uint32_t brow = htonl (rowid); | ||
178 | const char *paramValues[] = { (const char *) &brow }; | ||
179 | int paramLengths[] = { sizeof (brow) }; | ||
180 | const int paramFormats[] = { 1 }; | ||
181 | PGresult *ret; | ||
182 | |||
183 | ret = PQexecPrepared (dbh, | ||
184 | stmt, | ||
185 | 1, | ||
186 | paramValues, | ||
187 | paramLengths, | ||
188 | paramFormats, | ||
189 | 1); | ||
190 | if (GNUNET_OK != | ||
191 | GNUNET_POSTGRES_check_result_ (dbh, ret, | ||
192 | PGRES_COMMAND_OK, | ||
193 | "PQexecPrepared", | ||
194 | "delrow", | ||
195 | __FILE__, | ||
196 | __LINE__)) | ||
197 | { | ||
198 | return GNUNET_SYSERR; | ||
199 | } | ||
200 | PQclear (ret); | ||
201 | return GNUNET_OK; | ||
202 | } | ||
203 | |||
204 | |||
205 | /* end of postgres.c */ | ||
diff --git a/src/psycstore/Makefile.am b/src/psycstore/Makefile.am index a342c06e6..557bb42b5 100644 --- a/src/psycstore/Makefile.am +++ b/src/psycstore/Makefile.am | |||
@@ -88,7 +88,6 @@ libgnunet_plugin_psycstore_postgres_la_SOURCES = \ | |||
88 | plugin_psycstore_postgres.c | 88 | plugin_psycstore_postgres.c |
89 | libgnunet_plugin_psycstore_postgres_la_LIBADD = \ | 89 | libgnunet_plugin_psycstore_postgres_la_LIBADD = \ |
90 | libgnunetpsycstore.la \ | 90 | libgnunetpsycstore.la \ |
91 | $(top_builddir)/src/postgres/libgnunetpostgres.la \ | ||
92 | $(top_builddir)/src/pq/libgnunetpq.la \ | 91 | $(top_builddir)/src/pq/libgnunetpq.la \ |
93 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 92 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
94 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lpq \ | 93 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lpq \ |
diff --git a/src/psycstore/plugin_psycstore_postgres.c b/src/psycstore/plugin_psycstore_postgres.c index ef55736fb..de4b6e43f 100644 --- a/src/psycstore/plugin_psycstore_postgres.c +++ b/src/psycstore/plugin_psycstore_postgres.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "gnunet_crypto_lib.h" | 35 | #include "gnunet_crypto_lib.h" |
36 | #include "gnunet_psyc_util_lib.h" | 36 | #include "gnunet_psyc_util_lib.h" |
37 | #include "psycstore.h" | 37 | #include "psycstore.h" |
38 | #include "gnunet_postgres_lib.h" | ||
39 | #include "gnunet_pq_lib.h" | 38 | #include "gnunet_pq_lib.h" |
40 | 39 | ||
41 | /** | 40 | /** |