aboutsummaryrefslogtreecommitdiff
path: root/src/pq/pq.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-06-16 17:09:22 +0200
committerChristian Grothoff <christian@grothoff.org>2021-06-16 17:09:22 +0200
commit1bc1fbda00a9e31d2256c52b29a2c758b7818268 (patch)
tree6480c3ed89990f845c44d51b14dc8d67fc3a79bb /src/pq/pq.c
parentc66e726a8abe565e5f34313e38729f18fde4a73a (diff)
downloadgnunet-1bc1fbda00a9e31d2256c52b29a2c758b7818268.tar.gz
gnunet-1bc1fbda00a9e31d2256c52b29a2c758b7818268.zip
PQ: update libgnunetpq implementation to avoid duplicated nullable tests and to allow for the actual field name to differ from the fname, as done for example by the Taler amounts which are split over two DB fields
Diffstat (limited to 'src/pq/pq.c')
-rw-r--r--src/pq/pq.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/pq/pq.c b/src/pq/pq.c
index e9c960e33..25202a640 100644
--- a/src/pq/pq.c
+++ b/src/pq/pq.c
@@ -133,34 +133,31 @@ GNUNET_PQ_extract_result (PGresult *result,
133 for (unsigned int i = 0; NULL != rs[i].conv; i++) 133 for (unsigned int i = 0; NULL != rs[i].conv; i++)
134 { 134 {
135 struct GNUNET_PQ_ResultSpec *spec; 135 struct GNUNET_PQ_ResultSpec *spec;
136 int ret; 136 enum GNUNET_GenericReturnValue ret;
137 137
138 spec = &rs[i]; 138 spec = &rs[i];
139 if (spec->is_nullable)
140 {
141 int fnum;
142
143 fnum = PQfnumber (result,
144 spec->fname);
145 if (PQgetisnull (result,
146 row,
147 fnum))
148 {
149 if (NULL != spec->is_null)
150 *spec->is_null = true;
151 continue;
152 }
153 if (NULL != spec->is_null)
154 *spec->is_null = false;
155 }
156 ret = spec->conv (spec->cls, 139 ret = spec->conv (spec->cls,
157 result, 140 result,
158 row, 141 row,
159 spec->fname, 142 spec->fname,
160 &spec->dst_size, 143 &spec->dst_size,
161 spec->dst); 144 spec->dst);
162 if (GNUNET_OK != ret) 145 switch (ret)
163 { 146 {
147 case GNUNET_OK:
148 /* canonical case, continue below */
149 if (NULL != spec->is_null)
150 *spec->is_null = false;
151 break;
152 case GNUNET_NO:
153 if (spec->is_nullable)
154 {
155 if (NULL != spec->is_null)
156 *spec->is_null = true;
157 continue;
158 }
159 /* intentional fall-through: NULL value for field that is NOT nullable */
160 case GNUNET_SYSERR:
164 for (unsigned int j = 0; j < i; j++) 161 for (unsigned int j = 0; j < i; j++)
165 if (NULL != rs[j].cleaner) 162 if (NULL != rs[j].cleaner)
166 rs[j].cleaner (rs[j].cls, 163 rs[j].cleaner (rs[j].cls,