aboutsummaryrefslogtreecommitdiff
path: root/src/postgres/postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-01 21:48:19 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-01 21:48:19 +0200
commit1defd30dfeb1867c2756b3fe6a437f695951d0c9 (patch)
treeb48c0fe6bb32469cfcb4284bfac3142e22417ae8 /src/postgres/postgres.c
parentbbbe0b2404d131cc0d9eda26725b65b47a7e073a (diff)
downloadgnunet-1defd30dfeb1867c2756b3fe6a437f695951d0c9.tar.gz
gnunet-1defd30dfeb1867c2756b3fe6a437f695951d0c9.zip
adding more good helpers to libgnunetpq
Diffstat (limited to 'src/postgres/postgres.c')
-rw-r--r--src/postgres/postgres.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/postgres/postgres.c b/src/postgres/postgres.c
index 14095c5a4..828842d9d 100644
--- a/src/postgres/postgres.c
+++ b/src/postgres/postgres.c
@@ -161,48 +161,6 @@ GNUNET_POSTGRES_prepare_ (PGconn *dbh,
161 161
162 162
163/** 163/**
164 * Connect to a postgres database
165 *
166 * @param cfg configuration
167 * @param section configuration section to use to get Postgres configuration options
168 * @return the postgres handle
169 */
170PGconn *
171GNUNET_POSTGRES_connect (const struct GNUNET_CONFIGURATION_Handle * cfg,
172 const char *section)
173{
174 PGconn *dbh;
175 char *conninfo;
176
177 /* Open database and precompile statements */
178 if (GNUNET_OK !=
179 GNUNET_CONFIGURATION_get_value_string (cfg,
180 section,
181 "CONFIG",
182 &conninfo))
183 conninfo = NULL;
184 dbh = PQconnectdb (conninfo == NULL ? "" : conninfo);
185
186 if (NULL != dbh)
187 {
188 if (PQstatus (dbh) != CONNECTION_OK)
189 {
190 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
191 "postgres",
192 _("Unable to connect to Postgres database '%s': %s\n"),
193 conninfo,
194 PQerrorMessage (dbh));
195 PQfinish (dbh);
196 dbh = NULL;
197 }
198 }
199 // FIXME: warn about out-of-memory when dbh is NULL?
200 GNUNET_free_non_null (conninfo);
201 return dbh;
202}
203
204
205/**
206 * Delete the row identified by the given rowid (qid 164 * Delete the row identified by the given rowid (qid
207 * in postgres). 165 * in postgres).
208 * 166 *