From: Christian Grothoff Date: Tue, 6 Jun 2017 16:01:43 +0000 (+0200) Subject: removing dead libgnunetpostgres X-Git-Tag: gnunet-0.11.0rc0~246 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=08912967ec589efc267c1e5d296cf9e25ab1e95c;p=oweals%2Fgnunet.git removing dead libgnunetpostgres --- 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 pkgconfig/gnunetnse.pc pkgconfig/gnunetpeerinfo.pc pkgconfig/gnunetpq.pc -pkgconfig/gnunetpostgres.pc pkgconfig/gnunetpsyc.pc pkgconfig/gnunetpsycstore.pc 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 endif if HAVE_POSTGRESQL - POSTGRES_DIR = pq postgres + POSTGRES_DIR = pq endif 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 = \ gnunet_peerstore_service.h \ gnunet_plugin_lib.h \ gnunet_pq_lib.h \ - gnunet_postgres_lib.h \ gnunet_psycstore_plugin.h \ gnunet_psycstore_service.h \ 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 @@ -/* - This file is part of GNUnet - Copyright (C) 2012 GNUnet e.V. - - GNUnet is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, or (at your - option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -/** - * @author Christian Grothoff - * - * @file - * Helper library to access a PostgreSQL database - * - * @defgroup postgres PostgreSQL library - * Helper library to access a PostgreSQL database. - * @{ - */ -#ifndef GNUNET_POSTGRES_LIB_H -#define GNUNET_POSTGRES_LIB_H - -#include "gnunet_util_lib.h" -#include - -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - - -/** - * Check if the result obtained from Postgres has - * the desired status code. If not, log an error, clear the - * result and return #GNUNET_SYSERR. - * - * @param dbh database handle - * @param ret return value from database operation to check - * @param expected_status desired status - * @param command description of the command that was run - * @param args arguments given to the command - * @param filename name of the source file where the command was run - * @param line line number in the source file - * @return #GNUNET_OK if the result is acceptable - */ -int -GNUNET_POSTGRES_check_result_ (PGconn *dbh, - PGresult *ret, - int expected_status, - const char *command, - const char *args, - const char *filename, - int line); - - -/** - * Check if the result obtained from Postgres has - * the desired status code. If not, log an error, clear the - * result and return #GNUNET_SYSERR. - * - * @param dbh database handle - * @param ret return value from database operation to check - * @param expected_status desired status - * @param command description of the command that was run - * @param args arguments given to the command - * @return #GNUNET_OK if the result is acceptable - */ -#define GNUNET_POSTGRES_check_result(dbh,ret,expected_status,command,args) GNUNET_POSTGRES_check_result_(dbh,ret,expected_status,command,args,__FILE__,__LINE__) - - -/** - * Run simple SQL statement (without results). - * - * @param dbh database handle - * @param sql statement to run - * @param filename filename for error reporting - * @param line code line for error reporting - * @return #GNUNET_OK on success - */ -int -GNUNET_POSTGRES_exec_ (PGconn *dbh, - const char *sql, - const char *filename, - int line); - - -/** - * Run simple SQL statement (without results). - * - * @param dbh database handle - * @param sql statement to run - * @return #GNUNET_OK on success - */ -#define GNUNET_POSTGRES_exec(dbh,sql) GNUNET_POSTGRES_exec_(dbh,sql,__FILE__,__LINE__) - - -/** - * Prepare SQL statement. - * - * @param dbh database handle - * @param name name for the prepared SQL statement - * @param sql SQL code to prepare - * @param nparams number of parameters in sql - * @param filename filename for error reporting - * @param line code line for error reporting - * @return #GNUNET_OK on success - */ -int -GNUNET_POSTGRES_prepare_ (PGconn *dbh, - const char *name, - const char *sql, - int nparams, - const char *filename, - int line); - - -/** - * Prepare SQL statement. - * - * @param dbh database handle - * @param name name for the prepared SQL statement - * @param sql SQL code to prepare - * @param nparams number of parameters in sql - * @return #GNUNET_OK on success - */ -#define GNUNET_POSTGRES_prepare(dbh,name,sql,nparams) GNUNET_POSTGRES_prepare_(dbh,name,sql,nparams,__FILE__,__LINE__) - - -/** - * Connect to a postgres database - * - * @param cfg configuration - * @param section configuration section to use to get Postgres configuration options - * @return the postgres handle - */ -PGconn * -GNUNET_POSTGRES_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *section); - - -/** - * Delete the row identified by the given rowid (qid - * in postgres). - * - * @param dbh database handle - * @param stmt name of the prepared statement - * @param rowid which row to delete - * @return #GNUNET_OK on success - */ -int -GNUNET_POSTGRES_delete_by_rowid (PGconn *dbh, - const char *stmt, - uint32_t rowid); - - -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif - -#endif - -/** @} */ /* 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 @@ -# This Makefile.am is in the public domain -AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS) - -if MINGW - WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols -endif - -if USE_COVERAGE - AM_CFLAGS = --coverage -endif - -if HAVE_POSTGRESQL -lib_LTLIBRARIES = libgnunetpostgres.la -endif - -libgnunetpostgres_la_SOURCES = \ - postgres.c -libgnunetpostgres_la_LIBADD = -lpq \ - $(top_builddir)/src/util/libgnunetutil.la -libgnunetpostgres_la_LDFLAGS = \ - $(POSTGRESQL_LDFLAGS) \ - $(GN_LIB_LDFLAGS) \ - -version-info 0:0:0 - 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 @@ -/* - This file is part of GNUnet - Copyright (C) 2009, 2010, 2012 GNUnet e.V. - - GNUnet is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, or (at your - option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -/** - * @file postgres/postgres.c - * @brief library to help with access to a Postgres database - * @author Christian Grothoff - */ -#include "platform.h" -#include "gnunet_postgres_lib.h" - - -/** - * Check if the result obtained from Postgres has - * the desired status code. If not, log an error, clear the - * result and return GNUNET_SYSERR. - * - * @param dbh database handle - * @param ret return value from database operation to check - * @param expected_status desired status - * @param command description of the command that was run - * @param args arguments given to the command - * @param filename name of the source file where the command was run - * @param line line number in the source file - * @return #GNUNET_OK if the result is acceptable - */ -int -GNUNET_POSTGRES_check_result_ (PGconn *dbh, - PGresult *ret, - int expected_status, - const char *command, - const char *args, - const char *filename, - int line) -{ - if (ret == NULL) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - "postgres", - "Postgres failed to allocate result for `%s:%s' at %s:%d\n", - command, - args, - filename, - line); - return GNUNET_SYSERR; - } - if (PQresultStatus (ret) != expected_status) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, - "postgres", - _("`%s:%s' failed at %s:%d with error: %s\n"), - command, - args, - filename, - line, - PQerrorMessage (dbh)); - PQclear (ret); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -/** - * Run simple SQL statement (without results). - * - * @param dbh database handle - * @param sql statement to run - * @param filename filename for error reporting - * @param line code line for error reporting - * @return #GNUNET_OK on success - */ -int -GNUNET_POSTGRES_exec_ (PGconn * dbh, - const char *sql, - const char *filename, - int line) -{ - PGresult *ret; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Executing SQL statement `%s' at %s:%d\n", - sql, - filename, - line); - ret = PQexec (dbh, - sql); - if (GNUNET_OK != - GNUNET_POSTGRES_check_result_ (dbh, - ret, - PGRES_COMMAND_OK, - "PQexec", - sql, - filename, - line)) - return GNUNET_SYSERR; - PQclear (ret); - return GNUNET_OK; -} - - -/** - * Prepare SQL statement. - * - * @param dbh database handle - * @param name name for the prepared SQL statement - * @param sql SQL code to prepare - * @param nparams number of parameters in sql - * @param filename filename for error reporting - * @param line code line for error reporting - * @return #GNUNET_OK on success - */ -int -GNUNET_POSTGRES_prepare_ (PGconn *dbh, - const char *name, - const char *sql, - int nparams, - const char *filename, - int line) -{ - PGresult *ret; - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Preparing SQL statement `%s' as `%s' at %s:%d\n", - sql, - name, - filename, - line); - ret = PQprepare (dbh, - name, - sql, - nparams, NULL); - if (GNUNET_OK != - GNUNET_POSTGRES_check_result_ (dbh, - ret, - PGRES_COMMAND_OK, - "PQprepare", - sql, - filename, - line)) - return GNUNET_SYSERR; - PQclear (ret); - return GNUNET_OK; -} - - -/** - * Delete the row identified by the given rowid (qid - * in postgres). - * - * @param dbh database handle - * @param stmt name of the prepared statement - * @param rowid which row to delete - * @return #GNUNET_OK on success - */ -int -GNUNET_POSTGRES_delete_by_rowid (PGconn * dbh, - const char *stmt, - uint32_t rowid) -{ - uint32_t brow = htonl (rowid); - const char *paramValues[] = { (const char *) &brow }; - int paramLengths[] = { sizeof (brow) }; - const int paramFormats[] = { 1 }; - PGresult *ret; - - ret = PQexecPrepared (dbh, - stmt, - 1, - paramValues, - paramLengths, - paramFormats, - 1); - if (GNUNET_OK != - GNUNET_POSTGRES_check_result_ (dbh, ret, - PGRES_COMMAND_OK, - "PQexecPrepared", - "delrow", - __FILE__, - __LINE__)) - { - return GNUNET_SYSERR; - } - PQclear (ret); - return GNUNET_OK; -} - - -/* 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 = \ plugin_psycstore_postgres.c libgnunet_plugin_psycstore_postgres_la_LIBADD = \ libgnunetpsycstore.la \ - $(top_builddir)/src/postgres/libgnunetpostgres.la \ $(top_builddir)/src/pq/libgnunetpq.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(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 @@ #include "gnunet_crypto_lib.h" #include "gnunet_psyc_util_lib.h" #include "psycstore.h" -#include "gnunet_postgres_lib.h" #include "gnunet_pq_lib.h" /**