summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-31 00:12:01 +0100
committerChristian Grothoff <christian@grothoff.org>2020-10-31 00:12:01 +0100
commit77842546903ef7296c863987f9a60e5f0ead14d1 (patch)
treead7e987bd8bc22ce09e4e1ff84050505e76bb16c /src
parentbe928bb303f6100c40e4d84b2b350da690171987 (diff)
only call PGntuples once
Diffstat (limited to 'src')
-rw-r--r--src/pq/pq_eval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pq/pq_eval.c b/src/pq/pq_eval.c
index 5bcf8ca0e..8d8b5b0f2 100644
--- a/src/pq/pq_eval.c
+++ b/src/pq/pq_eval.c
@@ -263,6 +263,7 @@ GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db,
{
PGresult *result;
enum GNUNET_DB_QueryStatus qs;
+ int ntuples;
result = GNUNET_PQ_exec_prepared (db,
statement_name,
@@ -277,12 +278,13 @@ GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db,
PQclear (result);
return qs;
}
- if (0 == PQntuples (result))
+ ntuples = PQntuples (result);
+ if (0 == ntuples)
{
PQclear (result);
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
- if (1 != PQntuples (result))
+ if (1 != ntuples)
{
/* more than one result, but there must be at most one */
GNUNET_break (0);