diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-10-31 00:12:01 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-10-31 00:12:01 +0100 |
commit | 77842546903ef7296c863987f9a60e5f0ead14d1 (patch) | |
tree | ad7e987bd8bc22ce09e4e1ff84050505e76bb16c | |
parent | be928bb303f6100c40e4d84b2b350da690171987 (diff) | |
download | gnunet-77842546903ef7296c863987f9a60e5f0ead14d1.tar.gz gnunet-77842546903ef7296c863987f9a60e5f0ead14d1.zip |
only call PGntuples once
-rwxr-xr-x | bin/rename.sh | 2 | ||||
-rw-r--r-- | src/pq/pq_eval.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/bin/rename.sh b/bin/rename.sh index bf3c767c5..eec77e277 100755 --- a/bin/rename.sh +++ b/bin/rename.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # This script is in the public domain. | 2 | # This script is in the public domain. |
3 | for n in `find * -name "*.c"` `find * -name "*.h"` `find * -name "*.am"` `find * -name "*.conf"` `find * -name "*.conf.in"` | 3 | for n in `find * -name "*.c"` `find * -name "*.h"` `find * -name "*.am"` `find * -name "*.conf"` `find * -name "*.conf.in"` |
4 | do | 4 | do |
5 | cat $n | sed -e "s/$1/$2/g" > $n.new | 5 | cat $n | sed -e "s/$1/$2/g" > $n.new |
6 | mv $n.new $n || echo "Move failed: $n.new to $n" | 6 | mv $n.new $n || echo "Move failed: $n.new to $n" |
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, | |||
263 | { | 263 | { |
264 | PGresult *result; | 264 | PGresult *result; |
265 | enum GNUNET_DB_QueryStatus qs; | 265 | enum GNUNET_DB_QueryStatus qs; |
266 | int ntuples; | ||
266 | 267 | ||
267 | result = GNUNET_PQ_exec_prepared (db, | 268 | result = GNUNET_PQ_exec_prepared (db, |
268 | statement_name, | 269 | statement_name, |
@@ -277,12 +278,13 @@ GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db, | |||
277 | PQclear (result); | 278 | PQclear (result); |
278 | return qs; | 279 | return qs; |
279 | } | 280 | } |
280 | if (0 == PQntuples (result)) | 281 | ntuples = PQntuples (result); |
282 | if (0 == ntuples) | ||
281 | { | 283 | { |
282 | PQclear (result); | 284 | PQclear (result); |
283 | return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; | 285 | return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; |
284 | } | 286 | } |
285 | if (1 != PQntuples (result)) | 287 | if (1 != ntuples) |
286 | { | 288 | { |
287 | /* more than one result, but there must be at most one */ | 289 | /* more than one result, but there must be at most one */ |
288 | GNUNET_break (0); | 290 | GNUNET_break (0); |