diff options
Diffstat (limited to 'src/pq/pq.c')
-rw-r--r-- | src/pq/pq.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/pq/pq.c b/src/pq/pq.c index eca097e58..e9c960e33 100644 --- a/src/pq/pq.c +++ b/src/pq/pq.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2014, 2015, 2016, 2017, 2019 GNUnet e.V. | 3 | Copyright (C) 2014, 2015, 2016, 2017, 2019, 2020 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -27,14 +27,7 @@ | |||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "pq.h" | 28 | #include "pq.h" |
29 | 29 | ||
30 | /** | 30 | |
31 | * Execute a prepared statement. | ||
32 | * | ||
33 | * @param db database handle | ||
34 | * @param name name of the prepared statement | ||
35 | * @param params parameters to the statement | ||
36 | * @return postgres result | ||
37 | */ | ||
38 | PGresult * | 31 | PGresult * |
39 | GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db, | 32 | GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db, |
40 | const char *name, | 33 | const char *name, |
@@ -120,12 +113,6 @@ GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db, | |||
120 | } | 113 | } |
121 | 114 | ||
122 | 115 | ||
123 | /** | ||
124 | * Free all memory that was allocated in @a rs during | ||
125 | * #GNUNET_PQ_extract_result(). | ||
126 | * | ||
127 | * @param rs reult specification to clean up | ||
128 | */ | ||
129 | void | 116 | void |
130 | GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs) | 117 | GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs) |
131 | { | 118 | { |
@@ -136,17 +123,6 @@ GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs) | |||
136 | } | 123 | } |
137 | 124 | ||
138 | 125 | ||
139 | /** | ||
140 | * Extract results from a query result according to the given | ||
141 | * specification. | ||
142 | * | ||
143 | * @param result result to process | ||
144 | * @param[in,out] rs result specification to extract for | ||
145 | * @param row row from the result to extract | ||
146 | * @return | ||
147 | * #GNUNET_YES if all results could be extracted | ||
148 | * #GNUNET_SYSERR if a result was invalid (non-existing field) | ||
149 | */ | ||
150 | int | 126 | int |
151 | GNUNET_PQ_extract_result (PGresult *result, | 127 | GNUNET_PQ_extract_result (PGresult *result, |
152 | struct GNUNET_PQ_ResultSpec *rs, | 128 | struct GNUNET_PQ_ResultSpec *rs, |
@@ -160,6 +136,23 @@ GNUNET_PQ_extract_result (PGresult *result, | |||
160 | int ret; | 136 | int ret; |
161 | 137 | ||
162 | 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 | } | ||
163 | ret = spec->conv (spec->cls, | 156 | ret = spec->conv (spec->cls, |
164 | result, | 157 | result, |
165 | row, | 158 | row, |