summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_pq_lib.h5
-rw-r--r--src/pq/pq_eval.c22
2 files changed, 25 insertions, 2 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h
index ff4df563d..0f6b88b78 100644
--- a/src/include/gnunet_pq_lib.h
+++ b/src/include/gnunet_pq_lib.h
@@ -525,7 +525,10 @@ GNUNET_PQ_eval_result (PGconn *connection,
525 * @return status code from the result, mapping PQ status 525 * @return status code from the result, mapping PQ status
526 * codes to `enum GNUNET_PQ_QueryStatus`. If the 526 * codes to `enum GNUNET_PQ_QueryStatus`. If the
527 * statement was a DELETE or UPDATE statement, the 527 * statement was a DELETE or UPDATE statement, the
528 * number of affected rows is returned. 528 * number of affected rows is returned; if the
529 * statment was an INSERT statement, and no row
530 * was added due to a UNIQUE violation, we return
531 * zero; if INSERT was successful, we return one.
529 */ 532 */
530enum GNUNET_PQ_QueryStatus 533enum GNUNET_PQ_QueryStatus
531GNUNET_PQ_eval_prepared_non_select (PGconn *connection, 534GNUNET_PQ_eval_prepared_non_select (PGconn *connection,
diff --git a/src/pq/pq_eval.c b/src/pq/pq_eval.c
index 9296dce2e..b19742bba 100644
--- a/src/pq/pq_eval.c
+++ b/src/pq/pq_eval.c
@@ -93,6 +93,23 @@ GNUNET_PQ_eval_result (PGconn *connection,
93 PQerrorMessage (connection)); 93 PQerrorMessage (connection));
94 return GNUNET_PQ_STATUS_SOFT_ERROR; 94 return GNUNET_PQ_STATUS_SOFT_ERROR;
95 } 95 }
96 if (0 == strcmp (sqlstate,
97 PQ_DIAG_SQLSTATE_UNIQUE_VIOLATION))
98 {
99 /* Likely no need to retry, INSERT of "same" data. */
100 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
101 "pq",
102 "Query `%s' failed with unique violation: %s/%s/%s/%s/%s\n",
103 statement_name,
104 PQresultErrorField (result,
105 PG_DIAG_MESSAGE_PRIMARY),
106 PQresultErrorField (result,
107 PG_DIAG_MESSAGE_DETAIL),
108 PQresultErrorMessage (result),
109 PQresStatus (PQresultStatus (result)),
110 PQerrorMessage (connection));
111 return GNUNET_PQ_STATUS_SUCCESS_NO_RESULTS;
112 }
96 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 113 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
97 "pq", 114 "pq",
98 "Query `%s' failed with result: %s/%s/%s/%s/%s\n", 115 "Query `%s' failed with result: %s/%s/%s/%s/%s\n",
@@ -121,7 +138,10 @@ GNUNET_PQ_eval_result (PGconn *connection,
121 * @return status code from the result, mapping PQ status 138 * @return status code from the result, mapping PQ status
122 * codes to `enum GNUNET_PQ_QueryStatus`. If the 139 * codes to `enum GNUNET_PQ_QueryStatus`. If the
123 * statement was a DELETE or UPDATE statement, the 140 * statement was a DELETE or UPDATE statement, the
124 * number of affected rows is returned. 141 * number of affected rows is returned.; if the
142 * statment was an INSERT statement, and no row
143 * was added due to a UNIQUE violation, we return
144 * zero; if INSERT was successful, we return one.
125 */ 145 */
126enum GNUNET_PQ_QueryStatus 146enum GNUNET_PQ_QueryStatus
127GNUNET_PQ_eval_prepared_non_select (PGconn *connection, 147GNUNET_PQ_eval_prepared_non_select (PGconn *connection,