diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-10-25 22:32:14 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-10-25 22:32:14 +0100 |
commit | f7c320990c64ec5f29dc87340c24d5d9ebf7a835 (patch) | |
tree | 543a72c6a80ca898dfb83922e5635644c3a736e6 /src/include | |
parent | d8cf5cbfc9862d9187d9b15d12f7be523b757791 (diff) | |
download | gnunet-f7c320990c64ec5f29dc87340c24d5d9ebf7a835.tar.gz gnunet-f7c320990c64ec5f29dc87340c24d5d9ebf7a835.zip |
implement #6524
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_pq_lib.h | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index ca549f77c..de717526c 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2016, 2017 GNUnet e.V. | 3 | Copyright (C) 2016, 2017, 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 |
@@ -87,6 +87,7 @@ struct GNUNET_PQ_QueryParam | |||
87 | * Number of parameters eaten by this operation. | 87 | * Number of parameters eaten by this operation. |
88 | */ | 88 | */ |
89 | unsigned int num_params; | 89 | unsigned int num_params; |
90 | |||
90 | }; | 91 | }; |
91 | 92 | ||
92 | 93 | ||
@@ -100,20 +101,32 @@ struct GNUNET_PQ_QueryParam | |||
100 | 101 | ||
101 | 102 | ||
102 | /** | 103 | /** |
104 | * Generate query parameter to create a NULL value. | ||
105 | * | ||
106 | * @return query parameter to use to insert NULL into DB | ||
107 | */ | ||
108 | struct GNUNET_PQ_QueryParam | ||
109 | GNUNET_PQ_query_param_null (void); | ||
110 | |||
111 | |||
112 | /** | ||
103 | * Generate query parameter for a buffer @a ptr of | 113 | * Generate query parameter for a buffer @a ptr of |
104 | * @a ptr_size bytes. | 114 | * @a ptr_size bytes. |
105 | * | 115 | * |
106 | * @param ptr pointer to the query parameter to pass | 116 | * @param ptr pointer to the query parameter to pass |
107 | * @oaran ptr_size number of bytes in @a ptr | 117 | * @oaran ptr_size number of bytes in @a ptr |
118 | * @return query parameter to use | ||
108 | */ | 119 | */ |
109 | struct GNUNET_PQ_QueryParam | 120 | struct GNUNET_PQ_QueryParam |
110 | GNUNET_PQ_query_param_fixed_size (const void *ptr, size_t ptr_size); | 121 | GNUNET_PQ_query_param_fixed_size (const void *ptr, |
122 | size_t ptr_size); | ||
111 | 123 | ||
112 | 124 | ||
113 | /** | 125 | /** |
114 | * Generate query parameter for a string. | 126 | * Generate query parameter for a string. |
115 | * | 127 | * |
116 | * @param ptr pointer to the string query parameter to pass | 128 | * @param ptr pointer to the string query parameter to pass |
129 | * @return query parameter to use | ||
117 | */ | 130 | */ |
118 | struct GNUNET_PQ_QueryParam | 131 | struct GNUNET_PQ_QueryParam |
119 | GNUNET_PQ_query_param_string (const char *ptr); | 132 | GNUNET_PQ_query_param_string (const char *ptr); |
@@ -124,6 +137,7 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
124 | * by variable type. | 137 | * by variable type. |
125 | * | 138 | * |
126 | * @param x pointer to the query parameter to pass. | 139 | * @param x pointer to the query parameter to pass. |
140 | * @return query parameter to use | ||
127 | */ | 141 | */ |
128 | #define GNUNET_PQ_query_param_auto_from_type(x) \ | 142 | #define GNUNET_PQ_query_param_auto_from_type(x) \ |
129 | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) | 143 | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) |
@@ -134,6 +148,7 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
134 | * database must contain a BLOB type in the respective position. | 148 | * database must contain a BLOB type in the respective position. |
135 | * | 149 | * |
136 | * @param x the query parameter to pass. | 150 | * @param x the query parameter to pass. |
151 | * @return query parameter to use | ||
137 | */ | 152 | */ |
138 | struct GNUNET_PQ_QueryParam | 153 | struct GNUNET_PQ_QueryParam |
139 | GNUNET_PQ_query_param_rsa_public_key ( | 154 | GNUNET_PQ_query_param_rsa_public_key ( |
@@ -145,6 +160,7 @@ GNUNET_PQ_query_param_rsa_public_key ( | |||
145 | * database must contain a BLOB type in the respective position. | 160 | * database must contain a BLOB type in the respective position. |
146 | * | 161 | * |
147 | * @param x the query parameter to pass | 162 | * @param x the query parameter to pass |
163 | * @return query parameter to use | ||
148 | */ | 164 | */ |
149 | struct GNUNET_PQ_QueryParam | 165 | struct GNUNET_PQ_QueryParam |
150 | GNUNET_PQ_query_param_rsa_signature ( | 166 | GNUNET_PQ_query_param_rsa_signature ( |
@@ -156,6 +172,7 @@ GNUNET_PQ_query_param_rsa_signature ( | |||
156 | * The database must store a 64-bit integer. | 172 | * The database must store a 64-bit integer. |
157 | * | 173 | * |
158 | * @param x pointer to the query parameter to pass | 174 | * @param x pointer to the query parameter to pass |
175 | * @return query parameter to use | ||
159 | */ | 176 | */ |
160 | struct GNUNET_PQ_QueryParam | 177 | struct GNUNET_PQ_QueryParam |
161 | GNUNET_PQ_query_param_relative_time (const struct GNUNET_TIME_Relative *x); | 178 | GNUNET_PQ_query_param_relative_time (const struct GNUNET_TIME_Relative *x); |
@@ -166,6 +183,7 @@ GNUNET_PQ_query_param_relative_time (const struct GNUNET_TIME_Relative *x); | |||
166 | * The database must store a 64-bit integer. | 183 | * The database must store a 64-bit integer. |
167 | * | 184 | * |
168 | * @param x pointer to the query parameter to pass | 185 | * @param x pointer to the query parameter to pass |
186 | * @return query parameter to use | ||
169 | */ | 187 | */ |
170 | struct GNUNET_PQ_QueryParam | 188 | struct GNUNET_PQ_QueryParam |
171 | GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); | 189 | GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); |
@@ -176,6 +194,7 @@ GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x); | |||
176 | * The database must store a 64-bit integer. | 194 | * The database must store a 64-bit integer. |
177 | * | 195 | * |
178 | * @param x pointer to the query parameter to pass | 196 | * @param x pointer to the query parameter to pass |
197 | * @return query parameter to use | ||
179 | */ | 198 | */ |
180 | struct GNUNET_PQ_QueryParam | 199 | struct GNUNET_PQ_QueryParam |
181 | GNUNET_PQ_query_param_absolute_time_nbo ( | 200 | GNUNET_PQ_query_param_absolute_time_nbo ( |
@@ -186,6 +205,7 @@ GNUNET_PQ_query_param_absolute_time_nbo ( | |||
186 | * Generate query parameter for an uint16_t in host byte order. | 205 | * Generate query parameter for an uint16_t in host byte order. |
187 | * | 206 | * |
188 | * @param x pointer to the query parameter to pass | 207 | * @param x pointer to the query parameter to pass |
208 | * @return query parameter to use | ||
189 | */ | 209 | */ |
190 | struct GNUNET_PQ_QueryParam | 210 | struct GNUNET_PQ_QueryParam |
191 | GNUNET_PQ_query_param_uint16 (const uint16_t *x); | 211 | GNUNET_PQ_query_param_uint16 (const uint16_t *x); |
@@ -195,6 +215,7 @@ GNUNET_PQ_query_param_uint16 (const uint16_t *x); | |||
195 | * Generate query parameter for an uint32_t in host byte order. | 215 | * Generate query parameter for an uint32_t in host byte order. |
196 | * | 216 | * |
197 | * @param x pointer to the query parameter to pass | 217 | * @param x pointer to the query parameter to pass |
218 | * @return query parameter to use | ||
198 | */ | 219 | */ |
199 | struct GNUNET_PQ_QueryParam | 220 | struct GNUNET_PQ_QueryParam |
200 | GNUNET_PQ_query_param_uint32 (const uint32_t *x); | 221 | GNUNET_PQ_query_param_uint32 (const uint32_t *x); |
@@ -204,6 +225,7 @@ GNUNET_PQ_query_param_uint32 (const uint32_t *x); | |||
204 | * Generate query parameter for an uint16_t in host byte order. | 225 | * Generate query parameter for an uint16_t in host byte order. |
205 | * | 226 | * |
206 | * @param x pointer to the query parameter to pass | 227 | * @param x pointer to the query parameter to pass |
228 | * @return query parameter to use | ||
207 | */ | 229 | */ |
208 | struct GNUNET_PQ_QueryParam | 230 | struct GNUNET_PQ_QueryParam |
209 | GNUNET_PQ_query_param_uint64 (const uint64_t *x); | 231 | GNUNET_PQ_query_param_uint64 (const uint64_t *x); |
@@ -288,6 +310,20 @@ struct GNUNET_PQ_ResultSpec | |||
288 | * Where to store actual size of the result. | 310 | * Where to store actual size of the result. |
289 | */ | 311 | */ |
290 | size_t *result_size; | 312 | size_t *result_size; |
313 | |||
314 | /** | ||
315 | * True if NULL is allowed for a value in the database. | ||
316 | */ | ||
317 | bool is_nullable; | ||
318 | |||
319 | /** | ||
320 | * Points to a location where we should store | ||
321 | * "true" if the result found is NULL, and | ||
322 | * otherwise "false". Only used if @e is_nullable | ||
323 | * is true. | ||
324 | */ | ||
325 | bool *is_null; | ||
326 | |||
291 | }; | 327 | }; |
292 | 328 | ||
293 | 329 | ||
@@ -303,6 +339,21 @@ struct GNUNET_PQ_ResultSpec | |||
303 | 339 | ||
304 | 340 | ||
305 | /** | 341 | /** |
342 | * Allow NULL value to be found in the database | ||
343 | * for the given value. | ||
344 | * | ||
345 | * @param rs result spec entry to modify | ||
346 | * @param[out] is_null location set to 'true' if the | ||
347 | * value was indeed NULL, set to 'false' if the | ||
348 | * value was non-NULL | ||
349 | * @return array entry for the result specification to use | ||
350 | */ | ||
351 | struct GNUNET_PQ_ResultSpec | ||
352 | GNUNET_PQ_result_spec_allow_null (struct GNUNET_PQ_ResultSpec rs, | ||
353 | bool *is_null); | ||
354 | |||
355 | |||
356 | /** | ||
306 | * Variable-size result expected. | 357 | * Variable-size result expected. |
307 | * | 358 | * |
308 | * @param name name of the field in the table | 359 | * @param name name of the field in the table |