From 8f254866dc993d2e832ef12ea7b4179f87ab3bd9 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 3 Jun 2017 23:33:43 +0200 Subject: more pq work --- src/pq/pq_eval.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/pq/pq_eval.c') diff --git a/src/pq/pq_eval.c b/src/pq/pq_eval.c index d6c10e2c5..9296dce2e 100644 --- a/src/pq/pq_eval.c +++ b/src/pq/pq_eval.c @@ -119,9 +119,9 @@ 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. + * codes to `enum GNUNET_PQ_QueryStatus`. If the + * statement was a DELETE or UPDATE statement, the + * number of affected rows is returned. */ enum GNUNET_PQ_QueryStatus GNUNET_PQ_eval_prepared_non_select (PGconn *connection, @@ -137,6 +137,15 @@ 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) + { + const char *tuples; + + /* What an awful API, this function really does return a string */ + tuples = PQcmdTuples (result); + if (NULL != tuples) + qs = strtol (tuples, NULL, 10); + } PQclear (result); return qs; } -- cgit v1.2.3