X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_pq_lib.h;h=492491e94c601ba2964cd4a9a6012eb8c79d61eb;hb=634aea297cc983c3d70f65a004f698f215abe590;hp=5e54813e3de904551760d69663a051167ef70834;hpb=1defd30dfeb1867c2756b3fe6a437f695951d0c9;p=oweals%2Fgnunet.git
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index 5e54813e3..492491e94 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -1,17 +1,21 @@
/*
This file is part of GNUnet
- Copyright (C) 2016 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
+ 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 Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ 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
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
* @file include/gnunet_pq_lib.h
@@ -23,7 +27,7 @@
#include
#include "gnunet_util_lib.h"
-
+#include "gnunet_db_lib.h"
/* ************************* pq_query_helper.c functions ************************ */
@@ -465,36 +469,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 +477,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,11 +497,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`. Never
- * returns positive values as this function does
- * not look at the result set.
- */
-enum GNUNET_PQ_QueryStatus
+ * 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_DB_QueryStatus
GNUNET_PQ_eval_prepared_non_select (PGconn *connection,
const char *statement_name,
const struct GNUNET_PQ_QueryParam *params);
@@ -560,9 +537,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,
@@ -575,7 +552,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
@@ -583,9 +560,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,