From c90ae1921559d990c179800ac392b0a5358758fb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 11 Jun 2017 01:23:16 +0200 Subject: [PATCH] rename GNUNET_PQ_QueryStatus to GNUNET_DB_QueryStatus --- src/datacache/plugin_datacache_postgres.c | 16 +++---- src/datastore/plugin_datastore_postgres.c | 18 ++++---- src/include/Makefile.am | 1 + src/include/gnunet_db_lib.h | 54 +++++++++++++++++++++++ src/include/gnunet_pq_lib.h | 52 +++++----------------- src/namecache/plugin_namecache_postgres.c | 14 +++--- src/namestore/plugin_namestore_postgres.c | 10 ++--- src/pq/pq_eval.c | 44 +++++++++--------- src/psycstore/plugin_psycstore_postgres.c | 30 ++++++------- 9 files changed, 132 insertions(+), 107 deletions(-) create mode 100644 src/include/gnunet_db_lib.h diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index c99f5fd68..5c497cdf8 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c @@ -170,7 +170,7 @@ postgres_plugin_put (void *cls, path_info_len * sizeof (struct GNUNET_PeerIdentity)), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus ret; + enum GNUNET_DB_QueryStatus ret; ret = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "put", @@ -311,7 +311,7 @@ postgres_plugin_get (void *cls, GNUNET_PQ_query_param_uint32 (&type32), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; struct HandleResultContext hr_ctx; hr_ctx.iter = iter; @@ -354,7 +354,7 @@ postgres_plugin_del (void *cls) &key), GNUNET_PQ_result_spec_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; struct GNUNET_PQ_QueryParam dparam[] = { GNUNET_PQ_query_param_uint32 (&oid), GNUNET_PQ_query_param_end @@ -366,7 +366,7 @@ postgres_plugin_del (void *cls) rs); if (0 > res) return GNUNET_SYSERR; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS == res) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res) { /* no result */ LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -412,7 +412,7 @@ postgres_plugin_get_random (void *cls, struct GNUNET_PeerIdentity *path; struct GNUNET_HashCode key; uint32_t type; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint32 (&off), GNUNET_PQ_query_param_end @@ -448,7 +448,7 @@ postgres_plugin_get_random (void *cls, GNUNET_break (0); return 0; } - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS == res) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res) { GNUNET_break (0); return 0; @@ -595,7 +595,7 @@ postgres_plugin_get_closest (void *cls, GNUNET_PQ_query_param_uint32 (&num_results32), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; struct ExtractResultContext erc; erc.iter = iter; @@ -611,7 +611,7 @@ postgres_plugin_get_closest (void *cls, "Ending iteration (postgres error)\n"); return 0; } - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS == res) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res) { /* no result */ LOG (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 9380a56c0..fd1a533bb 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -198,7 +198,7 @@ postgres_plugin_estimate_size (void *cls, &total), GNUNET_PQ_result_spec_end }; - enum GNUNET_PQ_QueryStatus ret; + enum GNUNET_DB_QueryStatus ret; if (NULL == estimate) return; @@ -206,7 +206,7 @@ postgres_plugin_estimate_size (void *cls, "estimate_size", params, rs); - if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT != ret) + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != ret) { *estimate = 0LL; return; @@ -247,7 +247,7 @@ postgres_plugin_put (void *cls, { struct Plugin *plugin = cls; struct GNUNET_HashCode vhash; - enum GNUNET_PQ_QueryStatus ret; + enum GNUNET_DB_QueryStatus ret; GNUNET_CRYPTO_hash (data, size, @@ -510,7 +510,7 @@ postgres_plugin_get_key (void *cls, GNUNET_PQ_query_param_end }; struct ProcessResultContext prc; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; if (random) { @@ -564,7 +564,7 @@ postgres_plugin_get_zero_anonymity (void *cls, GNUNET_PQ_query_param_end }; struct ProcessResultContext prc; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; prc.plugin = plugin; prc.proc = proc; @@ -644,7 +644,7 @@ repl_proc (void *cls, GNUNET_PQ_query_param_uint32 (&oid), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus qret; + enum GNUNET_DB_QueryStatus qret; ret = rc->proc (rc->proc_cls, key, @@ -689,7 +689,7 @@ postgres_plugin_get_replication (void *cls, }; struct ReplCtx rc; struct ProcessResultContext prc; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; rc.plugin = plugin; rc.proc = proc; @@ -872,7 +872,7 @@ postgres_plugin_remove_key (void *cls, void *cont_cls) { struct Plugin *plugin = cls; - enum GNUNET_PQ_QueryStatus ret; + enum GNUNET_DB_QueryStatus ret; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (key), GNUNET_PQ_query_param_fixed_size (data, size), @@ -891,7 +891,7 @@ postgres_plugin_remove_key (void *cls, _("Postgress exec failure")); return; } - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS == ret) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == ret) { cont (cont_cls, key, diff --git a/src/include/Makefile.am b/src/include/Makefile.am index a1240b05c..e5abec416 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -48,6 +48,7 @@ gnunetinclude_HEADERS = \ gnunet_datacache_plugin.h \ gnunet_datastore_service.h \ gnunet_datastore_plugin.h \ + gnunet_db_lib.h \ gnunet_dht_service.h \ gnunet_disk_lib.h \ gnunet_dnsparser_lib.h \ diff --git a/src/include/gnunet_db_lib.h b/src/include/gnunet_db_lib.h new file mode 100644 index 000000000..71ac4aae9 --- /dev/null +++ b/src/include/gnunet_db_lib.h @@ -0,0 +1,54 @@ +/* + This file is part of GNUnet + Copyright (C) 2017 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, If not, see +*/ +/** + * @file include/gnunet_db_lib.h + * @brief shared defintions for transactional databases + * @author Christian Grothoff + */ +#ifndef GNUNET_DB_LIB_H +#define GNUNET_DB_LIB_H + + +/** + * Status code returned from functions running database commands. + * Can be combined with a function that returns the number + * of results, so non-negative values indicate success. + */ +enum GNUNET_DB_QueryStatus +{ + /** + * A hard error occurred, retrying will not help. + */ + GNUNET_DB_STATUS_HARD_ERROR = -2, + + /** + * A soft error occurred, retrying the transaction may succeed. + */ + GNUNET_DB_STATUS_SOFT_ERROR = -1, + + /** + * The transaction succeeded, but yielded zero results. + */ + GNUNET_DB_STATUS_SUCCESS_NO_RESULTS = 0, + + /** + * The transaction succeeded, and yielded one result. + */ + GNUNET_DB_STATUS_SUCCESS_ONE_RESULT = 1 + +}; + +#endif diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index 0f6b88b78..ed295b500 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet - Copyright (C) 2016 GNUnet e.V. + Copyright (C) 2016, 2017 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 @@ -23,7 +23,7 @@ #include #include "gnunet_util_lib.h" - +#include "gnunet_db_lib.h" /* ************************* pq_query_helper.c functions ************************ */ @@ -465,36 +465,6 @@ GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs); /* ******************** pq_eval.c functions ************** */ -/** - * Status code returned from functions running PQ commands. - * Can be combined with a function that returns the number - * of results, so non-negative values indicate success. - */ -enum GNUNET_PQ_QueryStatus -{ - /** - * A hard error occurred, retrying will not help. - */ - GNUNET_PQ_STATUS_HARD_ERROR = -2, - - /** - * A soft error occurred, retrying the transaction may succeed. - */ - GNUNET_PQ_STATUS_SOFT_ERROR = -1, - - /** - * The transaction succeeded, but yielded zero results. - */ - GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS = 0, - - /** - * The transaction succeeded, and yielded one result. - */ - GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT = 1 - -}; - - /** * Check the @a result's error code to see what happened. * Also logs errors. @@ -503,12 +473,12 @@ enum GNUNET_PQ_QueryStatus * @param statement_name name of the statement that created @a result * @param result result to check * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. Never + * codes to `enum GNUNET_DB_QueryStatus`. Never * returns positive values as this function does * not look at the result set. * @deprecated (low level, let's see if we can do with just the high-level functions) */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_result (PGconn *connection, const char *statement_name, PGresult *result); @@ -523,14 +493,14 @@ GNUNET_PQ_eval_result (PGconn *connection, * @param statement_name name of the statement * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated) * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. If the + * codes to `enum GNUNET_DB_QueryStatus`. If the * statement was a DELETE or UPDATE statement, the * number of affected rows is returned; if the * statment was an INSERT statement, and no row * was added due to a UNIQUE violation, we return * zero; if INSERT was successful, we return one. */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_non_select (PGconn *connection, const char *statement_name, const struct GNUNET_PQ_QueryParam *params); @@ -563,9 +533,9 @@ typedef void * @param rh function to call with the result set, NULL to ignore * @param rh_cls closure to pass to @a rh * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. + * codes to `enum GNUNET_DB_QueryStatus`. */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, const char *statement_name, const struct GNUNET_PQ_QueryParam *params, @@ -578,7 +548,7 @@ GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, * which must return a single result in @a connection using the given * @a params. Stores the result (if any) in @a rs, which the caller * must then clean up using #GNUNET_PQ_cleanup_result() if the return - * value was #GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT. Returns the + * value was #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT. Returns the * resulting session status. * * @param connection connection to execute the statement in @@ -586,9 +556,9 @@ GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated) * @param[in,out] rs result specification to use for storing the result of the query * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. + * codes to `enum GNUNET_DB_QueryStatus`. */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_singleton_select (PGconn *connection, const char *statement_name, const struct GNUNET_PQ_QueryParam *params, diff --git a/src/namecache/plugin_namecache_postgres.c b/src/namecache/plugin_namecache_postgres.c index 3cf11f1d8..d943b0cd8 100644 --- a/src/namecache/plugin_namecache_postgres.c +++ b/src/namecache/plugin_namecache_postgres.c @@ -153,12 +153,12 @@ namecache_postgres_expire_blocks (struct Plugin *plugin) GNUNET_PQ_query_param_absolute_time (&now), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "expire_blocks", params); - GNUNET_break (GNUNET_PQ_STATUS_HARD_ERROR != res); + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != res); } @@ -179,12 +179,12 @@ delete_old_block (struct Plugin *plugin, GNUNET_PQ_query_param_absolute_time_nbo (&expiration_time), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "delete_block", params); - GNUNET_break (GNUNET_PQ_STATUS_HARD_ERROR != res); + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != res); } @@ -210,7 +210,7 @@ namecache_postgres_cache_block (void *cls, GNUNET_PQ_query_param_absolute_time_nbo (&block->expiration_time), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; namecache_postgres_expire_blocks (plugin); GNUNET_CRYPTO_hash (&block->derived_key, @@ -263,7 +263,7 @@ namecache_postgres_lookup_block (void *cls, &bsize), GNUNET_PQ_result_spec_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; res = GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, "lookup_block", @@ -275,7 +275,7 @@ namecache_postgres_lookup_block (void *cls, "Failing lookup block in namecache (postgres error)\n"); return GNUNET_SYSERR; } - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS == res) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == res) { /* no result */ LOG (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c index 5a607cac5..b1a6529aa 100644 --- a/src/namestore/plugin_namestore_postgres.c +++ b/src/namestore/plugin_namestore_postgres.c @@ -216,7 +216,7 @@ namestore_postgres_store_records (void *cls, GNUNET_PQ_query_param_string (label), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; if (data_size != GNUNET_GNSRECORD_records_serialize (rd_count, rd, @@ -229,7 +229,7 @@ namestore_postgres_store_records (void *cls, res = GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "store_records", params); - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != res) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != res) return GNUNET_SYSERR; } return GNUNET_OK; @@ -362,7 +362,7 @@ namestore_postgres_lookup_records (void *cls, GNUNET_PQ_query_param_end }; struct ParserContext pc; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; pc.iter = iter; pc.iter_cls = iter_cls; @@ -397,7 +397,7 @@ namestore_postgres_iterate_records (void *cls, void *iter_cls) { struct Plugin *plugin = cls; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; struct ParserContext pc; pc.iter = iter; @@ -459,7 +459,7 @@ namestore_postgres_zone_to_name (void *cls, GNUNET_PQ_query_param_auto_from_type (value_zone), GNUNET_PQ_query_param_end }; - enum GNUNET_PQ_QueryStatus res; + enum GNUNET_DB_QueryStatus res; struct ParserContext pc; pc.iter = iter; diff --git a/src/pq/pq_eval.c b/src/pq/pq_eval.c index b19742bba..0f28aec7e 100644 --- a/src/pq/pq_eval.c +++ b/src/pq/pq_eval.c @@ -47,12 +47,12 @@ * @param statement_name name of the statement that created @a result * @param result result to check * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. Never + * codes to `enum GNUNET_DB_QueryStatus`. Never * returns positive values as this function does * not look at the result set. * @deprecated (low level, let's see if we can do with just the high-level functions) */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_result (PGconn *connection, const char *statement_name, PGresult *result) @@ -71,7 +71,7 @@ GNUNET_PQ_eval_result (PGconn *connection, { /* very unexpected... */ GNUNET_break (0); - return GNUNET_PQ_STATUS_HARD_ERROR; + return GNUNET_DB_STATUS_HARD_ERROR; } if ( (0 == strcmp (sqlstate, PQ_DIAG_SQLSTATE_DEADLOCK)) || @@ -91,7 +91,7 @@ GNUNET_PQ_eval_result (PGconn *connection, PQresultErrorMessage (result), PQresStatus (PQresultStatus (result)), PQerrorMessage (connection)); - return GNUNET_PQ_STATUS_SOFT_ERROR; + return GNUNET_DB_STATUS_SOFT_ERROR; } if (0 == strcmp (sqlstate, PQ_DIAG_SQLSTATE_UNIQUE_VIOLATION)) @@ -108,7 +108,7 @@ GNUNET_PQ_eval_result (PGconn *connection, PQresultErrorMessage (result), PQresStatus (PQresultStatus (result)), PQerrorMessage (connection)); - return GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS; + return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; } GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "pq", @@ -121,9 +121,9 @@ GNUNET_PQ_eval_result (PGconn *connection, PQresultErrorMessage (result), PQresStatus (PQresultStatus (result)), PQerrorMessage (connection)); - return GNUNET_PQ_STATUS_HARD_ERROR; + return GNUNET_DB_STATUS_HARD_ERROR; } - return GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS; + return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; } @@ -136,20 +136,20 @@ GNUNET_PQ_eval_result (PGconn *connection, * @param statement_name name of the statement * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated) * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. If the + * codes to `enum GNUNET_DB_QueryStatus`. If the * statement was a DELETE or UPDATE statement, the * number of affected rows is returned.; if the * statment was an INSERT statement, and no row * was added due to a UNIQUE violation, we return * zero; if INSERT was successful, we return one. */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_non_select (PGconn *connection, const char *statement_name, const struct GNUNET_PQ_QueryParam *params) { PGresult *result; - enum GNUNET_PQ_QueryStatus qs; + enum GNUNET_DB_QueryStatus qs; result = GNUNET_PQ_exec_prepared (connection, statement_name, @@ -157,7 +157,7 @@ GNUNET_PQ_eval_prepared_non_select (PGconn *connection, qs = GNUNET_PQ_eval_result (connection, statement_name, result); - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS == qs) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { const char *tuples; @@ -184,9 +184,9 @@ GNUNET_PQ_eval_prepared_non_select (PGconn *connection, * @param rh function to call with the result set, NULL to ignore * @param rh_cls closure to pass to @a rh * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. + * codes to `enum GNUNET_DB_QueryStatus`. */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, const char *statement_name, const struct GNUNET_PQ_QueryParam *params, @@ -194,7 +194,7 @@ GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, void *rh_cls) { PGresult *result; - enum GNUNET_PQ_QueryStatus qs; + enum GNUNET_DB_QueryStatus qs; unsigned int ret; result = GNUNET_PQ_exec_prepared (connection, @@ -223,7 +223,7 @@ GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, * which must return a single result in @a connection using the given * @a params. Stores the result (if any) in @a rs, which the caller * must then clean up using #GNUNET_PQ_cleanup_result() if the return - * value was #GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT. Returns the + * value was #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT. Returns the * resulting session status. * * @param connection connection to execute the statement in @@ -231,16 +231,16 @@ GNUNET_PQ_eval_prepared_multi_select (PGconn *connection, * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated) * @param[in,out] rs result specification to use for storing the result of the query * @return status code from the result, mapping PQ status - * codes to `enum GNUNET_PQ_QueryStatus`. + * codes to `enum GNUNET_DB_QueryStatus`. */ -enum GNUNET_PQ_QueryStatus +enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_singleton_select (PGconn *connection, const char *statement_name, const struct GNUNET_PQ_QueryParam *params, struct GNUNET_PQ_ResultSpec *rs) { PGresult *result; - enum GNUNET_PQ_QueryStatus qs; + enum GNUNET_DB_QueryStatus qs; result = GNUNET_PQ_exec_prepared (connection, statement_name, @@ -256,14 +256,14 @@ GNUNET_PQ_eval_prepared_singleton_select (PGconn *connection, if (0 == PQntuples (result)) { PQclear (result); - return GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS; + return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; } if (1 != PQntuples (result)) { /* more than one result, but there must be at most one */ GNUNET_break (0); PQclear (result); - return GNUNET_PQ_STATUS_HARD_ERROR; + return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_OK != GNUNET_PQ_extract_result (result, @@ -271,10 +271,10 @@ GNUNET_PQ_eval_prepared_singleton_select (PGconn *connection, 0)) { PQclear (result); - return GNUNET_PQ_STATUS_HARD_ERROR; + return GNUNET_DB_STATUS_HARD_ERROR; } PQclear (result); - return GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT; + return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } diff --git a/src/psycstore/plugin_psycstore_postgres.c b/src/psycstore/plugin_psycstore_postgres.c index de4b6e43f..b8010af0a 100644 --- a/src/psycstore/plugin_psycstore_postgres.c +++ b/src/psycstore/plugin_psycstore_postgres.c @@ -391,7 +391,7 @@ exec_channel (struct Plugin *plugin, const char *stmt, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params)) return GNUNET_SYSERR; @@ -409,7 +409,7 @@ transaction_begin (struct Plugin *plugin, enum Transactions transaction) GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_begin", params)) return GNUNET_SYSERR; @@ -428,7 +428,7 @@ transaction_commit (struct Plugin *plugin) GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_commit", params)) return GNUNET_SYSERR; @@ -447,7 +447,7 @@ transaction_rollback (struct Plugin *plugin) GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "transaction_rollback", params)) return GNUNET_SYSERR; @@ -465,7 +465,7 @@ channel_key_store (struct Plugin *plugin, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_channel_key", params)) return GNUNET_SYSERR; @@ -482,7 +482,7 @@ slave_key_store (struct Plugin *plugin, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_slave_key", params)) return GNUNET_SYSERR; @@ -535,7 +535,7 @@ postgres_membership_store (void *cls, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_membership", params)) return GNUNET_SYSERR; @@ -572,7 +572,7 @@ membership_test (void *cls, GNUNET_PQ_result_spec_end }; - if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT != + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, "select_membership", params_select, results_select)) return GNUNET_SYSERR; @@ -635,7 +635,7 @@ fragment_store (void *cls, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "insert_fragment", params_insert)) return GNUNET_SYSERR; @@ -664,7 +664,7 @@ message_add_flags (void *cls, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, "update_message_flags", params_update)) return GNUNET_SYSERR; @@ -994,7 +994,7 @@ counters_message_get (void *cls, GNUNET_PQ_result_spec_end }; - if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT != + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt, params_select, results_select)) return GNUNET_SYSERR; @@ -1028,7 +1028,7 @@ counters_state_get (void *cls, GNUNET_PQ_result_spec_end }; - if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT != + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt, params_select, results_select)) return GNUNET_SYSERR; @@ -1054,7 +1054,7 @@ state_assign (struct Plugin *plugin, const char *stmt, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params)) return GNUNET_SYSERR; @@ -1074,7 +1074,7 @@ update_message_id (struct Plugin *plugin, GNUNET_PQ_query_param_end }; - if (GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS != + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != GNUNET_PQ_eval_prepared_non_select (plugin->dbh, stmt, params)) return GNUNET_SYSERR; @@ -1305,7 +1305,7 @@ state_get (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, GNUNET_PQ_result_spec_end }; - if (GNUNET_PQ_STATUS_SUCCESS_ONE_RESULT != + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != GNUNET_PQ_eval_prepared_singleton_select (plugin->dbh, stmt, params_select, results_select)) return GNUNET_SYSERR; -- 2.25.1