diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_pq_lib.h | 158 | ||||
-rw-r--r-- | src/pq/pq.h | 16 | ||||
-rw-r--r-- | src/pq/pq_connect.c | 226 | ||||
-rw-r--r-- | src/pq/pq_query_helper.c | 112 | ||||
-rw-r--r-- | src/pq/pq_result_helper.c | 70 |
5 files changed, 301 insertions, 281 deletions
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index ff59a63b9..3408362a6 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -132,13 +132,13 @@ GNUNET_PQ_cleanup_query_params_closures ( | |||
132 | * End of query parameter specification. | 132 | * End of query parameter specification. |
133 | */ | 133 | */ |
134 | #define GNUNET_PQ_query_param_end \ | 134 | #define GNUNET_PQ_query_param_end \ |
135 | { \ | 135 | { \ |
136 | .conv = NULL, \ | 136 | .conv = NULL, \ |
137 | .conv_cls = NULL, \ | 137 | .conv_cls = NULL, \ |
138 | .data = NULL, \ | 138 | .data = NULL, \ |
139 | .size = 0, \ | 139 | .size = 0, \ |
140 | .num_params = 0 \ | 140 | .num_params = 0 \ |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | /** | 144 | /** |
@@ -182,34 +182,6 @@ GNUNET_PQ_query_param_string (const char *ptr); | |||
182 | struct GNUNET_PQ_QueryParam | 182 | struct GNUNET_PQ_QueryParam |
183 | GNUNET_PQ_query_param_bool (bool b); | 183 | GNUNET_PQ_query_param_bool (bool b); |
184 | 184 | ||
185 | |||
186 | /** | ||
187 | * Array types (in Postgres) that are supported in GNUnet. | ||
188 | */ | ||
189 | enum GNUNET_PQ_DataTypes | ||
190 | { | ||
191 | GNUNET_PQ_DATATYPE_UNKNOWN, /* Unsupported type */ | ||
192 | GNUNET_PQ_DATATYPE_BOOL, | ||
193 | GNUNET_PQ_DATATYPE_INT2, | ||
194 | GNUNET_PQ_DATATYPE_INT4, | ||
195 | GNUNET_PQ_DATATYPE_INT8, | ||
196 | GNUNET_PQ_DATATYPE_BYTEA, | ||
197 | GNUNET_PQ_DATATYPE_VARCHAR, | ||
198 | GNUNET_PQ_DATATYPE_MAX, /* Must be last */ | ||
199 | }; | ||
200 | |||
201 | /** | ||
202 | * Returns the oid for a given, basic datatype | ||
203 | * | ||
204 | * @param db The db-connection | ||
205 | * @param typ the Datatype | ||
206 | * @return The oid | ||
207 | */ | ||
208 | Oid | ||
209 | GNUNET_PQ_get_oid ( | ||
210 | const struct GNUNET_PQ_Context *db, | ||
211 | enum GNUNET_PQ_DataTypes typ); | ||
212 | |||
213 | /** | 185 | /** |
214 | * Returns the oid for a given datatype by name. | 186 | * Returns the oid for a given datatype by name. |
215 | * | 187 | * |
@@ -254,7 +226,7 @@ struct GNUNET_PQ_QueryParam | |||
254 | GNUNET_PQ_query_param_array_bool ( | 226 | GNUNET_PQ_query_param_array_bool ( |
255 | unsigned int num, | 227 | unsigned int num, |
256 | const bool *elements, | 228 | const bool *elements, |
257 | const struct GNUNET_PQ_Context *db); | 229 | struct GNUNET_PQ_Context *db); |
258 | 230 | ||
259 | /** | 231 | /** |
260 | * Generate query parameter for an array of uint16_t in host byte order. | 232 | * Generate query parameter for an array of uint16_t in host byte order. |
@@ -269,7 +241,7 @@ struct GNUNET_PQ_QueryParam | |||
269 | GNUNET_PQ_query_param_array_uint16 ( | 241 | GNUNET_PQ_query_param_array_uint16 ( |
270 | unsigned int num, | 242 | unsigned int num, |
271 | const uint16_t *elements, | 243 | const uint16_t *elements, |
272 | const struct GNUNET_PQ_Context *db); | 244 | struct GNUNET_PQ_Context *db); |
273 | 245 | ||
274 | /** | 246 | /** |
275 | * Generate query parameter for an array of uint32_t in host byte order. | 247 | * Generate query parameter for an array of uint32_t in host byte order. |
@@ -284,7 +256,7 @@ struct GNUNET_PQ_QueryParam | |||
284 | GNUNET_PQ_query_param_array_uint32 ( | 256 | GNUNET_PQ_query_param_array_uint32 ( |
285 | unsigned int num, | 257 | unsigned int num, |
286 | const uint32_t *elements, | 258 | const uint32_t *elements, |
287 | const struct GNUNET_PQ_Context *db); | 259 | struct GNUNET_PQ_Context *db); |
288 | 260 | ||
289 | /** | 261 | /** |
290 | * Generate query parameter for an array of uint64 in host byte order. | 262 | * Generate query parameter for an array of uint64 in host byte order. |
@@ -299,7 +271,7 @@ struct GNUNET_PQ_QueryParam | |||
299 | GNUNET_PQ_query_param_array_uint64 ( | 271 | GNUNET_PQ_query_param_array_uint64 ( |
300 | unsigned int num, | 272 | unsigned int num, |
301 | const uint64_t *elements, | 273 | const uint64_t *elements, |
302 | const struct GNUNET_PQ_Context *db); | 274 | struct GNUNET_PQ_Context *db); |
303 | 275 | ||
304 | /** | 276 | /** |
305 | * Generate query parameter for an array of buffers @a elements, each of | 277 | * Generate query parameter for an array of buffers @a elements, each of |
@@ -316,7 +288,7 @@ GNUNET_PQ_query_param_array_bytes ( | |||
316 | unsigned int num, | 288 | unsigned int num, |
317 | const void *elements, | 289 | const void *elements, |
318 | const size_t *sizes, | 290 | const size_t *sizes, |
319 | const struct GNUNET_PQ_Context *db); | 291 | struct GNUNET_PQ_Context *db); |
320 | 292 | ||
321 | /** | 293 | /** |
322 | * Generate query parameter for an array of buffers @a elements, | 294 | * Generate query parameter for an array of buffers @a elements, |
@@ -333,7 +305,7 @@ GNUNET_PQ_query_param_array_bytes_same_size ( | |||
333 | unsigned int num, | 305 | unsigned int num, |
334 | const void *elements, | 306 | const void *elements, |
335 | size_t same_size, | 307 | size_t same_size, |
336 | const struct GNUNET_PQ_Context *db); | 308 | struct GNUNET_PQ_Context *db); |
337 | 309 | ||
338 | /** | 310 | /** |
339 | * Generate array of equal-sized query parameter with size determined | 311 | * Generate array of equal-sized query parameter with size determined |
@@ -345,10 +317,10 @@ GNUNET_PQ_query_param_array_bytes_same_size ( | |||
345 | * @return query parameter to use | 317 | * @return query parameter to use |
346 | */ | 318 | */ |
347 | #define GNUNET_PQ_query_param_array_auto_from_type(num, elements, db) \ | 319 | #define GNUNET_PQ_query_param_array_auto_from_type(num, elements, db) \ |
348 | GNUNET_PQ_query_param_array_bytes_same_size ((num), \ | 320 | GNUNET_PQ_query_param_array_bytes_same_size ((num), \ |
349 | (elements), \ | 321 | (elements), \ |
350 | sizeof(*(elements)), \ | 322 | sizeof(*(elements)), \ |
351 | (db)) | 323 | (db)) |
352 | 324 | ||
353 | /** | 325 | /** |
354 | * Generate query parameter for an array of pointers to buffers @a elements, | 326 | * Generate query parameter for an array of pointers to buffers @a elements, |
@@ -365,7 +337,7 @@ GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | |||
365 | unsigned int num, | 337 | unsigned int num, |
366 | const void *elements[], | 338 | const void *elements[], |
367 | size_t same_size, | 339 | size_t same_size, |
368 | const struct GNUNET_PQ_Context *db); | 340 | struct GNUNET_PQ_Context *db); |
369 | 341 | ||
370 | /** | 342 | /** |
371 | * Generate array of equal-sized query parameter with size determined by | 343 | * Generate array of equal-sized query parameter with size determined by |
@@ -378,10 +350,10 @@ GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | |||
378 | * @return query parameter to use | 350 | * @return query parameter to use |
379 | */ | 351 | */ |
380 | #define GNUNET_PQ_query_param_array_ptrs_auto_from_type(num, elements, db) \ | 352 | #define GNUNET_PQ_query_param_array_ptrs_auto_from_type(num, elements, db) \ |
381 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ((num), \ | 353 | GNUNET_PQ_query_param_array_ptrs_bytes_same_size ((num), \ |
382 | (elements), \ | 354 | (elements), \ |
383 | sizeof(*(elements[0])), \ | 355 | sizeof(*(elements[0])), \ |
384 | (db)) | 356 | (db)) |
385 | 357 | ||
386 | 358 | ||
387 | /** | 359 | /** |
@@ -396,7 +368,7 @@ struct GNUNET_PQ_QueryParam | |||
396 | GNUNET_PQ_query_param_array_string ( | 368 | GNUNET_PQ_query_param_array_string ( |
397 | unsigned int num, | 369 | unsigned int num, |
398 | const char *elements, | 370 | const char *elements, |
399 | const struct GNUNET_PQ_Context *db); | 371 | struct GNUNET_PQ_Context *db); |
400 | 372 | ||
401 | 373 | ||
402 | /** | 374 | /** |
@@ -411,7 +383,7 @@ struct GNUNET_PQ_QueryParam | |||
411 | GNUNET_PQ_query_param_array_ptrs_string ( | 383 | GNUNET_PQ_query_param_array_ptrs_string ( |
412 | unsigned int num, | 384 | unsigned int num, |
413 | const char *elements[], | 385 | const char *elements[], |
414 | const struct GNUNET_PQ_Context *db); | 386 | struct GNUNET_PQ_Context *db); |
415 | 387 | ||
416 | /** | 388 | /** |
417 | * Generate fixed-size query parameter with size determined | 389 | * Generate fixed-size query parameter with size determined |
@@ -421,7 +393,7 @@ GNUNET_PQ_query_param_array_ptrs_string ( | |||
421 | * @return query parameter to use | 393 | * @return query parameter to use |
422 | */ | 394 | */ |
423 | #define GNUNET_PQ_query_param_auto_from_type(x) \ | 395 | #define GNUNET_PQ_query_param_auto_from_type(x) \ |
424 | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) | 396 | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) |
425 | 397 | ||
426 | /** | 398 | /** |
427 | * Generate query parameter for an array of absolute time stamps (continuous) | 399 | * Generate query parameter for an array of absolute time stamps (continuous) |
@@ -434,7 +406,7 @@ struct GNUNET_PQ_QueryParam | |||
434 | GNUNET_PQ_query_param_array_abs_time ( | 406 | GNUNET_PQ_query_param_array_abs_time ( |
435 | unsigned int num, | 407 | unsigned int num, |
436 | const struct GNUNET_TIME_Absolute *elements, | 408 | const struct GNUNET_TIME_Absolute *elements, |
437 | const struct GNUNET_PQ_Context *db); | 409 | struct GNUNET_PQ_Context *db); |
438 | 410 | ||
439 | /** | 411 | /** |
440 | * Generate query parameter for an array of absolute time stamps (pointers) | 412 | * Generate query parameter for an array of absolute time stamps (pointers) |
@@ -447,7 +419,7 @@ struct GNUNET_PQ_QueryParam | |||
447 | GNUNET_PQ_query_param_array_ptrs_abs_time ( | 419 | GNUNET_PQ_query_param_array_ptrs_abs_time ( |
448 | unsigned int num, | 420 | unsigned int num, |
449 | const struct GNUNET_TIME_Absolute *elements[], | 421 | const struct GNUNET_TIME_Absolute *elements[], |
450 | const struct GNUNET_PQ_Context *db); | 422 | struct GNUNET_PQ_Context *db); |
451 | 423 | ||
452 | /** | 424 | /** |
453 | * Generate query parameter for an array of relative time stamps (continuous) | 425 | * Generate query parameter for an array of relative time stamps (continuous) |
@@ -460,7 +432,7 @@ struct GNUNET_PQ_QueryParam | |||
460 | GNUNET_PQ_query_param_array_rel_time ( | 432 | GNUNET_PQ_query_param_array_rel_time ( |
461 | unsigned int num, | 433 | unsigned int num, |
462 | const struct GNUNET_TIME_Relative *elements, | 434 | const struct GNUNET_TIME_Relative *elements, |
463 | const struct GNUNET_PQ_Context *db); | 435 | struct GNUNET_PQ_Context *db); |
464 | 436 | ||
465 | /** | 437 | /** |
466 | * Generate query parameter for an array of relative time stamps (pointers) | 438 | * Generate query parameter for an array of relative time stamps (pointers) |
@@ -473,7 +445,7 @@ struct GNUNET_PQ_QueryParam | |||
473 | GNUNET_PQ_query_param_array_ptrs_rel_time ( | 445 | GNUNET_PQ_query_param_array_ptrs_rel_time ( |
474 | unsigned int num, | 446 | unsigned int num, |
475 | const struct GNUNET_TIME_Relative *elements[], | 447 | const struct GNUNET_TIME_Relative *elements[], |
476 | const struct GNUNET_PQ_Context *db); | 448 | struct GNUNET_PQ_Context *db); |
477 | 449 | ||
478 | /** | 450 | /** |
479 | * Generate query parameter for an array of time stamps (continuous) | 451 | * Generate query parameter for an array of time stamps (continuous) |
@@ -486,7 +458,7 @@ struct GNUNET_PQ_QueryParam | |||
486 | GNUNET_PQ_query_param_array_timestamp ( | 458 | GNUNET_PQ_query_param_array_timestamp ( |
487 | unsigned int num, | 459 | unsigned int num, |
488 | const struct GNUNET_TIME_Timestamp *elements, | 460 | const struct GNUNET_TIME_Timestamp *elements, |
489 | const struct GNUNET_PQ_Context *db); | 461 | struct GNUNET_PQ_Context *db); |
490 | 462 | ||
491 | /** | 463 | /** |
492 | * Generate query parameter for an array of time stamps (pointers) | 464 | * Generate query parameter for an array of time stamps (pointers) |
@@ -499,7 +471,7 @@ struct GNUNET_PQ_QueryParam | |||
499 | GNUNET_PQ_query_param_array_ptrs_timestamp ( | 471 | GNUNET_PQ_query_param_array_ptrs_timestamp ( |
500 | unsigned int num, | 472 | unsigned int num, |
501 | const struct GNUNET_TIME_Timestamp *elements[], | 473 | const struct GNUNET_TIME_Timestamp *elements[], |
502 | const struct GNUNET_PQ_Context *db); | 474 | struct GNUNET_PQ_Context *db); |
503 | 475 | ||
504 | /** | 476 | /** |
505 | * Generate query parameter for an RSA public key. The | 477 | * Generate query parameter for an RSA public key. The |
@@ -712,17 +684,17 @@ struct GNUNET_PQ_ResultSpec | |||
712 | * @return array last entry for the result specification to use | 684 | * @return array last entry for the result specification to use |
713 | */ | 685 | */ |
714 | #define GNUNET_PQ_result_spec_end \ | 686 | #define GNUNET_PQ_result_spec_end \ |
715 | { \ | 687 | { \ |
716 | .conv = NULL, \ | 688 | .conv = NULL, \ |
717 | .cleaner = NULL, \ | 689 | .cleaner = NULL, \ |
718 | .cls = NULL, \ | 690 | .cls = NULL, \ |
719 | .dst = NULL, \ | 691 | .dst = NULL, \ |
720 | .dst_size = 0, \ | 692 | .dst_size = 0, \ |
721 | .fname = NULL, \ | 693 | .fname = NULL, \ |
722 | .result_size = NULL, \ | 694 | .result_size = NULL, \ |
723 | .is_nullable = false, \ | 695 | .is_nullable = false, \ |
724 | .is_null = NULL \ | 696 | .is_null = NULL \ |
725 | } | 697 | } |
726 | 698 | ||
727 | 699 | ||
728 | /** | 700 | /** |
@@ -775,7 +747,7 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, | |||
775 | * @return array entry for the result specification to use | 747 | * @return array entry for the result specification to use |
776 | */ | 748 | */ |
777 | #define GNUNET_PQ_result_spec_auto_from_type(name, dst) \ | 749 | #define GNUNET_PQ_result_spec_auto_from_type(name, dst) \ |
778 | GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof(*(dst))) | 750 | GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof(*(dst))) |
779 | 751 | ||
780 | 752 | ||
781 | /** | 753 | /** |
@@ -932,7 +904,7 @@ GNUNET_PQ_result_spec_uint64 (const char *name, | |||
932 | */ | 904 | */ |
933 | struct GNUNET_PQ_ResultSpec | 905 | struct GNUNET_PQ_ResultSpec |
934 | GNUNET_PQ_result_spec_array_bool ( | 906 | GNUNET_PQ_result_spec_array_bool ( |
935 | const struct GNUNET_PQ_Context *db, | 907 | struct GNUNET_PQ_Context *db, |
936 | const char *name, | 908 | const char *name, |
937 | size_t *num, | 909 | size_t *num, |
938 | bool **bools); | 910 | bool **bools); |
@@ -948,7 +920,7 @@ GNUNET_PQ_result_spec_array_bool ( | |||
948 | */ | 920 | */ |
949 | struct GNUNET_PQ_ResultSpec | 921 | struct GNUNET_PQ_ResultSpec |
950 | GNUNET_PQ_result_spec_array_uint16 ( | 922 | GNUNET_PQ_result_spec_array_uint16 ( |
951 | const struct GNUNET_PQ_Context *db, | 923 | struct GNUNET_PQ_Context *db, |
952 | const char *name, | 924 | const char *name, |
953 | size_t *num, | 925 | size_t *num, |
954 | uint16_t **dst); | 926 | uint16_t **dst); |
@@ -964,7 +936,7 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
964 | */ | 936 | */ |
965 | struct GNUNET_PQ_ResultSpec | 937 | struct GNUNET_PQ_ResultSpec |
966 | GNUNET_PQ_result_spec_array_uint32 ( | 938 | GNUNET_PQ_result_spec_array_uint32 ( |
967 | const struct GNUNET_PQ_Context *db, | 939 | struct GNUNET_PQ_Context *db, |
968 | const char *name, | 940 | const char *name, |
969 | size_t *num, | 941 | size_t *num, |
970 | uint32_t **dst); | 942 | uint32_t **dst); |
@@ -980,7 +952,7 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
980 | */ | 952 | */ |
981 | struct GNUNET_PQ_ResultSpec | 953 | struct GNUNET_PQ_ResultSpec |
982 | GNUNET_PQ_result_spec_array_uint64 ( | 954 | GNUNET_PQ_result_spec_array_uint64 ( |
983 | const struct GNUNET_PQ_Context *db, | 955 | struct GNUNET_PQ_Context *db, |
984 | const char *name, | 956 | const char *name, |
985 | size_t *num, | 957 | size_t *num, |
986 | uint64_t **dst); | 958 | uint64_t **dst); |
@@ -997,7 +969,7 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
997 | */ | 969 | */ |
998 | struct GNUNET_PQ_ResultSpec | 970 | struct GNUNET_PQ_ResultSpec |
999 | GNUNET_PQ_result_spec_array_abs_time ( | 971 | GNUNET_PQ_result_spec_array_abs_time ( |
1000 | const struct GNUNET_PQ_Context *db, | 972 | struct GNUNET_PQ_Context *db, |
1001 | const char *name, | 973 | const char *name, |
1002 | size_t *num, | 974 | size_t *num, |
1003 | struct GNUNET_TIME_Absolute **dst); | 975 | struct GNUNET_TIME_Absolute **dst); |
@@ -1013,7 +985,7 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1013 | */ | 985 | */ |
1014 | struct GNUNET_PQ_ResultSpec | 986 | struct GNUNET_PQ_ResultSpec |
1015 | GNUNET_PQ_result_spec_array_rel_time ( | 987 | GNUNET_PQ_result_spec_array_rel_time ( |
1016 | const struct GNUNET_PQ_Context *db, | 988 | struct GNUNET_PQ_Context *db, |
1017 | const char *name, | 989 | const char *name, |
1018 | size_t *num, | 990 | size_t *num, |
1019 | struct GNUNET_TIME_Relative **dst); | 991 | struct GNUNET_TIME_Relative **dst); |
@@ -1030,7 +1002,7 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1030 | 1002 | ||
1031 | struct GNUNET_PQ_ResultSpec | 1003 | struct GNUNET_PQ_ResultSpec |
1032 | GNUNET_PQ_result_spec_array_timestamp ( | 1004 | GNUNET_PQ_result_spec_array_timestamp ( |
1033 | const struct GNUNET_PQ_Context *db, | 1005 | struct GNUNET_PQ_Context *db, |
1034 | const char *name, | 1006 | const char *name, |
1035 | size_t *num, | 1007 | size_t *num, |
1036 | struct GNUNET_TIME_Timestamp **dst); | 1008 | struct GNUNET_TIME_Timestamp **dst); |
@@ -1047,7 +1019,7 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1047 | */ | 1019 | */ |
1048 | struct GNUNET_PQ_ResultSpec | 1020 | struct GNUNET_PQ_ResultSpec |
1049 | GNUNET_PQ_result_spec_array_variable_size ( | 1021 | GNUNET_PQ_result_spec_array_variable_size ( |
1050 | const struct GNUNET_PQ_Context *db, | 1022 | struct GNUNET_PQ_Context *db, |
1051 | const char *name, | 1023 | const char *name, |
1052 | size_t *num, | 1024 | size_t *num, |
1053 | size_t **sizes, | 1025 | size_t **sizes, |
@@ -1066,7 +1038,7 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1066 | */ | 1038 | */ |
1067 | struct GNUNET_PQ_ResultSpec | 1039 | struct GNUNET_PQ_ResultSpec |
1068 | GNUNET_PQ_result_spec_array_fixed_size ( | 1040 | GNUNET_PQ_result_spec_array_fixed_size ( |
1069 | const struct GNUNET_PQ_Context *db, | 1041 | struct GNUNET_PQ_Context *db, |
1070 | const char *name, | 1042 | const char *name, |
1071 | size_t size, | 1043 | size_t size, |
1072 | size_t *num, | 1044 | size_t *num, |
@@ -1083,12 +1055,12 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1083 | * @return array entry for the result specification to use | 1055 | * @return array entry for the result specification to use |
1084 | */ | 1056 | */ |
1085 | #define GNUNET_PQ_result_spec_auto_array_from_type(db, name, num, dst) \ | 1057 | #define GNUNET_PQ_result_spec_auto_array_from_type(db, name, num, dst) \ |
1086 | GNUNET_PQ_result_spec_array_fixed_size ( \ | 1058 | GNUNET_PQ_result_spec_array_fixed_size ( \ |
1087 | (db), \ | 1059 | (db), \ |
1088 | (name), \ | 1060 | (name), \ |
1089 | sizeof(*(dst)), \ | 1061 | sizeof(*(dst)), \ |
1090 | (num), \ | 1062 | (num), \ |
1091 | (void *) &(dst)) | 1063 | (void *) &(dst)) |
1092 | 1064 | ||
1093 | 1065 | ||
1094 | /** | 1066 | /** |
@@ -1102,7 +1074,7 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1102 | */ | 1074 | */ |
1103 | struct GNUNET_PQ_ResultSpec | 1075 | struct GNUNET_PQ_ResultSpec |
1104 | GNUNET_PQ_result_spec_array_string ( | 1076 | GNUNET_PQ_result_spec_array_string ( |
1105 | const struct GNUNET_PQ_Context *db, | 1077 | struct GNUNET_PQ_Context *db, |
1106 | const char *name, | 1078 | const char *name, |
1107 | size_t *num, | 1079 | size_t *num, |
1108 | char **dst); | 1080 | char **dst); |
@@ -1280,9 +1252,9 @@ struct GNUNET_PQ_PreparedStatement | |||
1280 | * Terminator for prepared statement list. | 1252 | * Terminator for prepared statement list. |
1281 | */ | 1253 | */ |
1282 | #define GNUNET_PQ_PREPARED_STATEMENT_END \ | 1254 | #define GNUNET_PQ_PREPARED_STATEMENT_END \ |
1283 | { \ | 1255 | { \ |
1284 | NULL, NULL \ | 1256 | NULL, NULL \ |
1285 | } | 1257 | } |
1286 | 1258 | ||
1287 | 1259 | ||
1288 | /** | 1260 | /** |
@@ -1352,9 +1324,9 @@ struct GNUNET_PQ_ExecuteStatement | |||
1352 | * Terminator for executable statement list. | 1324 | * Terminator for executable statement list. |
1353 | */ | 1325 | */ |
1354 | #define GNUNET_PQ_EXECUTE_STATEMENT_END \ | 1326 | #define GNUNET_PQ_EXECUTE_STATEMENT_END \ |
1355 | { \ | 1327 | { \ |
1356 | NULL, GNUNET_SYSERR \ | 1328 | NULL, GNUNET_SYSERR \ |
1357 | } | 1329 | } |
1358 | 1330 | ||
1359 | 1331 | ||
1360 | /** | 1332 | /** |
diff --git a/src/pq/pq.h b/src/pq/pq.h index 0c011a6ef..46d749fcc 100644 --- a/src/pq/pq.h +++ b/src/pq/pq.h | |||
@@ -102,7 +102,21 @@ struct GNUNET_PQ_Context | |||
102 | /** | 102 | /** |
103 | * Mapping between array types and Oid's, filled at reconnect | 103 | * Mapping between array types and Oid's, filled at reconnect |
104 | */ | 104 | */ |
105 | Oid oids[GNUNET_PQ_DATATYPE_MAX]; | 105 | struct |
106 | { | ||
107 | /* allocated number of elements array @table */ | ||
108 | unsigned int cap; | ||
109 | |||
110 | /* number of entries in @table */ | ||
111 | unsigned int num; | ||
112 | |||
113 | struct name2oid | ||
114 | { | ||
115 | const char *name; | ||
116 | Oid oid; | ||
117 | } *table; | ||
118 | |||
119 | } oids; | ||
106 | }; | 120 | }; |
107 | 121 | ||
108 | 122 | ||
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c index ba272bce4..5a42d1ae9 100644 --- a/src/pq/pq_connect.c +++ b/src/pq/pq_connect.c | |||
@@ -322,149 +322,103 @@ GNUNET_PQ_reconnect_if_down (struct GNUNET_PQ_Context *db) | |||
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | /** | 325 | enum GNUNET_GenericReturnValue |
326 | * Retrieves the Oid's for the supported array types and sets db->arraytype2oid | 326 | GNUNET_PQ_get_oid_by_name ( |
327 | * on succes. | 327 | struct GNUNET_PQ_Context *db, |
328 | * | 328 | const char *name, |
329 | * @param[in,out] db Context for the database connection | 329 | Oid *oid) |
330 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
331 | */ | ||
332 | static enum GNUNET_GenericReturnValue | ||
333 | get_array_type_oids (struct GNUNET_PQ_Context *db) | ||
334 | { | 330 | { |
335 | PGresult *res; | 331 | /* Check if the entry is in the cache already */ |
336 | ExecStatusType est; | 332 | for (unsigned int i = 0; i < db->oids.num; i++) |
337 | |||
338 | GNUNET_assert (NULL != db); | ||
339 | /* Initialize to Oid(0) (= unknown) */ | ||
340 | memset (db->oids, | ||
341 | 0, | ||
342 | sizeof(db->oids)); | ||
343 | |||
344 | res = PQexec (db->conn, | ||
345 | "SELECT" | ||
346 | " typname, oid" | ||
347 | " FROM pg_type " | ||
348 | " WHERE typname in " | ||
349 | " ('bool', 'int2', 'int4', 'int8', 'bytea', 'varchar');"); | ||
350 | |||
351 | est = PQresultStatus (res); | ||
352 | if ( (PGRES_COMMAND_OK != est) && | ||
353 | (PGRES_TUPLES_OK != est)) | ||
354 | { | 333 | { |
355 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 334 | /* Pointer comparison */ |
356 | "Failed to run statement to retrieve Oids for array types!\n"); | 335 | if (name == db->oids.table[i].name) |
357 | return GNUNET_SYSERR; | 336 | { |
337 | *oid = db->oids.table[i].oid; | ||
338 | return GNUNET_OK; | ||
339 | } | ||
358 | } | 340 | } |
359 | 341 | ||
360 | if ( (2 != PQnfields (res)) || | 342 | /* No entry found in cache, ask database */ |
361 | (0 != PQfnumber (res, "typname")) || | ||
362 | (1 != PQfnumber (res, "oid")) | ||
363 | ) | ||
364 | { | 343 | { |
365 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 344 | enum GNUNET_DB_QueryStatus qs; |
366 | "Unexpected table retrieved for array types\n"); | 345 | struct GNUNET_PQ_QueryParam params[] = { |
367 | return GNUNET_SYSERR; | 346 | GNUNET_PQ_query_param_string (name), |
347 | GNUNET_PQ_query_param_end | ||
348 | }; | ||
349 | struct GNUNET_PQ_ResultSpec spec[] = { | ||
350 | GNUNET_PQ_result_spec_uint32 ("oid", | ||
351 | oid), | ||
352 | GNUNET_PQ_result_spec_end | ||
353 | }; | ||
354 | |||
355 | GNUNET_assert (NULL != db); | ||
356 | |||
357 | qs = GNUNET_PQ_eval_prepared_singleton_select (db, | ||
358 | "gnunet_pq_get_oid_by_name", | ||
359 | params, | ||
360 | spec); | ||
361 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | ||
362 | return GNUNET_SYSERR; | ||
368 | } | 363 | } |
369 | 364 | ||
365 | /* Add the entry to the cache */ | ||
366 | if (NULL == db->oids.table) | ||
370 | { | 367 | { |
371 | int nrows = PQntuples (res); | 368 | db->oids.table = GNUNET_new_array (8, |
372 | int nfound = 1; /* skip GNUNET_PQ_DATATYPE_UNKNOWN */ | 369 | typeof(*db->oids.table)); |
373 | char dummy; | 370 | db->oids.cap = 8; |
374 | 371 | db->oids.num = 0; | |
375 | for (int r = 0; r < nrows; r++) | ||
376 | { | ||
377 | enum GNUNET_PQ_DataTypes atype = GNUNET_PQ_DATATYPE_UNKNOWN; | ||
378 | char *typ_s = PQgetvalue (res,r,0); | ||
379 | char *oid_s = PQgetvalue (res,r,1); | ||
380 | GNUNET_assert (NULL != typ_s); | ||
381 | GNUNET_assert (NULL != oid_s); | ||
382 | |||
383 | if (! strcmp (typ_s,"bool")) | ||
384 | atype = GNUNET_PQ_DATATYPE_BOOL; | ||
385 | else if (! strcmp (typ_s,"int2")) | ||
386 | atype = GNUNET_PQ_DATATYPE_INT2; | ||
387 | else if (! strcmp (typ_s,"int4")) | ||
388 | atype = GNUNET_PQ_DATATYPE_INT4; | ||
389 | else if (! strcmp (typ_s,"int8")) | ||
390 | atype = GNUNET_PQ_DATATYPE_INT8; | ||
391 | else if (! strcmp (typ_s,"bytea")) | ||
392 | atype = GNUNET_PQ_DATATYPE_BYTEA; | ||
393 | else if (! strcmp (typ_s,"varchar")) | ||
394 | atype = GNUNET_PQ_DATATYPE_VARCHAR; | ||
395 | else | ||
396 | continue; | ||
397 | |||
398 | GNUNET_assert (GNUNET_PQ_DATATYPE_MAX > atype); | ||
399 | |||
400 | if ( (GNUNET_PQ_DATATYPE_UNKNOWN != atype) && | ||
401 | (1 == sscanf (oid_s, | ||
402 | "%u%c", | ||
403 | &db->oids[atype], | ||
404 | &dummy))) | ||
405 | { | ||
406 | nfound++; | ||
407 | } | ||
408 | } | ||
409 | |||
410 | if (GNUNET_PQ_DATATYPE_MAX != nfound) | ||
411 | { | ||
412 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
413 | "Couldn't find all array types, only found %d of %d!\n", | ||
414 | nfound - 1, | ||
415 | GNUNET_PQ_DATATYPE_MAX - 1); | ||
416 | return GNUNET_SYSERR; | ||
417 | } | ||
418 | } | 372 | } |
419 | return GNUNET_OK; | ||
420 | } | ||
421 | 373 | ||
374 | if (db->oids.cap <= db->oids.num) | ||
375 | GNUNET_array_grow (db->oids.table, | ||
376 | db->oids.cap, | ||
377 | db->oids.cap + 8); | ||
422 | 378 | ||
423 | Oid | 379 | db->oids.table[db->oids.num].name = name; |
424 | GNUNET_PQ_get_oid ( | 380 | db->oids.table[db->oids.num].oid = *oid; |
425 | const struct GNUNET_PQ_Context *db, | 381 | db->oids.num++; |
426 | enum GNUNET_PQ_DataTypes typ) | 382 | |
427 | { | 383 | return GNUNET_OK; |
428 | GNUNET_assert (GNUNET_PQ_DATATYPE_MAX > typ); | ||
429 | return db->oids[typ]; | ||
430 | } | 384 | } |
431 | 385 | ||
432 | 386 | ||
387 | /** | ||
388 | * Load the initial set of OIDs for the supported | ||
389 | * array-datatypes | ||
390 | * | ||
391 | * @param db The database context | ||
392 | * @return GNUNET_OK on success, GNUNET_SYSERR if any of the types couldn't be found | ||
393 | */ | ||
394 | static | ||
433 | enum GNUNET_GenericReturnValue | 395 | enum GNUNET_GenericReturnValue |
434 | GNUNET_PQ_get_oid_by_name ( | 396 | load_initial_oids (struct GNUNET_PQ_Context *db) |
435 | struct GNUNET_PQ_Context *db, | ||
436 | const char *name, | ||
437 | Oid *oid) | ||
438 | { | 397 | { |
439 | char *typname; | 398 | static const char *typnames[] = { |
440 | enum GNUNET_DB_QueryStatus qs; | 399 | "bool", |
441 | struct GNUNET_PQ_QueryParam params[] = { | 400 | "int2", |
442 | GNUNET_PQ_query_param_string (name), | 401 | "int4", |
443 | GNUNET_PQ_query_param_end | 402 | "int8", |
444 | }; | 403 | "bytea", |
445 | struct GNUNET_PQ_ResultSpec rs[] = { | 404 | "varchar" |
446 | GNUNET_PQ_result_spec_string ("typname", | ||
447 | &typname), | ||
448 | GNUNET_PQ_result_spec_uint32 ("oid", | ||
449 | oid), | ||
450 | GNUNET_PQ_result_spec_end | ||
451 | }; | 405 | }; |
406 | Oid oid; | ||
452 | 407 | ||
453 | GNUNET_assert (NULL != db); | 408 | for (size_t i = 0; i< sizeof(typnames) / sizeof(*typnames); i++) |
454 | 409 | { | |
455 | /* Initialize to Oid(0) (= unknown) */ | 410 | if (GNUNET_OK != |
456 | *oid = 0; | 411 | GNUNET_PQ_get_oid_by_name (db, |
457 | 412 | typnames[i], | |
458 | qs = GNUNET_PQ_eval_prepared_singleton_select (db, | 413 | &oid)) |
459 | "gnunet_pq_get_oid_by_name", | 414 | { |
460 | params, | 415 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
461 | rs); | 416 | "pq", |
462 | if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) | 417 | "Couldn't retrieve OID for type %s\n", |
463 | return GNUNET_SYSERR; | 418 | typnames[i]); |
464 | 419 | return GNUNET_SYSERR; | |
465 | if (0 != strcasecmp (typname, name)) | 420 | } |
466 | return GNUNET_SYSERR; | 421 | } |
467 | |||
468 | return GNUNET_OK; | 422 | return GNUNET_OK; |
469 | } | 423 | } |
470 | 424 | ||
@@ -559,16 +513,6 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
559 | } | 513 | } |
560 | } | 514 | } |
561 | 515 | ||
562 | /* Retrieve the OIDs for the supported Array types */ | ||
563 | if (GNUNET_SYSERR == get_array_type_oids (db)) | ||
564 | { | ||
565 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
566 | "Failed to retrieve OID information for array types!\n"); | ||
567 | PQfinish (db->conn); | ||
568 | db->conn = NULL; | ||
569 | return; | ||
570 | } | ||
571 | |||
572 | /* Prepare statement for OID lookup by name */ | 516 | /* Prepare statement for OID lookup by name */ |
573 | { | 517 | { |
574 | PGresult *res; | 518 | PGresult *res; |
@@ -596,6 +540,18 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) | |||
596 | PQclear (res); | 540 | PQclear (res); |
597 | } | 541 | } |
598 | 542 | ||
543 | /* Reset the OID-cache and retrieve the OIDs for the supported Array types */ | ||
544 | db->oids.num = 0; | ||
545 | if (GNUNET_SYSERR == load_initial_oids (db)) | ||
546 | { | ||
547 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
548 | "Failed to retrieve OID information for array types!\n"); | ||
549 | PQfinish (db->conn); | ||
550 | db->conn = NULL; | ||
551 | return; | ||
552 | } | ||
553 | |||
554 | |||
599 | if (NULL != db->auto_suffix) | 555 | if (NULL != db->auto_suffix) |
600 | { | 556 | { |
601 | PGresult *res; | 557 | PGresult *res; |
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index 0199f21dd..71421345f 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c | |||
@@ -962,15 +962,18 @@ struct GNUNET_PQ_QueryParam | |||
962 | GNUNET_PQ_query_param_array_bool ( | 962 | GNUNET_PQ_query_param_array_bool ( |
963 | unsigned int num, | 963 | unsigned int num, |
964 | const bool *elements, | 964 | const bool *elements, |
965 | const struct GNUNET_PQ_Context *db) | 965 | struct GNUNET_PQ_Context *db) |
966 | { | 966 | { |
967 | Oid oid; | ||
968 | GNUNET_assert (GNUNET_OK == | ||
969 | GNUNET_PQ_get_oid_by_name (db,"bool",&oid)); | ||
967 | return query_param_array_generic (num, | 970 | return query_param_array_generic (num, |
968 | true, | 971 | true, |
969 | elements, | 972 | elements, |
970 | NULL, | 973 | NULL, |
971 | sizeof(bool), | 974 | sizeof(bool), |
972 | array_of_bool, | 975 | array_of_bool, |
973 | db->oids[GNUNET_PQ_DATATYPE_BOOL]); | 976 | oid); |
974 | } | 977 | } |
975 | 978 | ||
976 | 979 | ||
@@ -978,15 +981,18 @@ struct GNUNET_PQ_QueryParam | |||
978 | GNUNET_PQ_query_param_array_uint16 ( | 981 | GNUNET_PQ_query_param_array_uint16 ( |
979 | unsigned int num, | 982 | unsigned int num, |
980 | const uint16_t *elements, | 983 | const uint16_t *elements, |
981 | const struct GNUNET_PQ_Context *db) | 984 | struct GNUNET_PQ_Context *db) |
982 | { | 985 | { |
986 | Oid oid; | ||
987 | GNUNET_assert (GNUNET_OK == | ||
988 | GNUNET_PQ_get_oid_by_name (db,"int2",&oid)); | ||
983 | return query_param_array_generic (num, | 989 | return query_param_array_generic (num, |
984 | true, | 990 | true, |
985 | elements, | 991 | elements, |
986 | NULL, | 992 | NULL, |
987 | sizeof(uint16_t), | 993 | sizeof(uint16_t), |
988 | array_of_uint16, | 994 | array_of_uint16, |
989 | db->oids[GNUNET_PQ_DATATYPE_INT2]); | 995 | oid); |
990 | } | 996 | } |
991 | 997 | ||
992 | 998 | ||
@@ -994,15 +1000,18 @@ struct GNUNET_PQ_QueryParam | |||
994 | GNUNET_PQ_query_param_array_uint32 ( | 1000 | GNUNET_PQ_query_param_array_uint32 ( |
995 | unsigned int num, | 1001 | unsigned int num, |
996 | const uint32_t *elements, | 1002 | const uint32_t *elements, |
997 | const struct GNUNET_PQ_Context *db) | 1003 | struct GNUNET_PQ_Context *db) |
998 | { | 1004 | { |
1005 | Oid oid; | ||
1006 | GNUNET_assert (GNUNET_OK == | ||
1007 | GNUNET_PQ_get_oid_by_name (db,"int4",&oid)); | ||
999 | return query_param_array_generic (num, | 1008 | return query_param_array_generic (num, |
1000 | true, | 1009 | true, |
1001 | elements, | 1010 | elements, |
1002 | NULL, | 1011 | NULL, |
1003 | sizeof(uint32_t), | 1012 | sizeof(uint32_t), |
1004 | array_of_uint32, | 1013 | array_of_uint32, |
1005 | db->oids[GNUNET_PQ_DATATYPE_INT4]); | 1014 | oid); |
1006 | } | 1015 | } |
1007 | 1016 | ||
1008 | 1017 | ||
@@ -1010,15 +1019,18 @@ struct GNUNET_PQ_QueryParam | |||
1010 | GNUNET_PQ_query_param_array_uint64 ( | 1019 | GNUNET_PQ_query_param_array_uint64 ( |
1011 | unsigned int num, | 1020 | unsigned int num, |
1012 | const uint64_t *elements, | 1021 | const uint64_t *elements, |
1013 | const struct GNUNET_PQ_Context *db) | 1022 | struct GNUNET_PQ_Context *db) |
1014 | { | 1023 | { |
1024 | Oid oid; | ||
1025 | GNUNET_assert (GNUNET_OK == | ||
1026 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1015 | return query_param_array_generic (num, | 1027 | return query_param_array_generic (num, |
1016 | true, | 1028 | true, |
1017 | elements, | 1029 | elements, |
1018 | NULL, | 1030 | NULL, |
1019 | sizeof(uint64_t), | 1031 | sizeof(uint64_t), |
1020 | array_of_uint64, | 1032 | array_of_uint64, |
1021 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1033 | oid); |
1022 | } | 1034 | } |
1023 | 1035 | ||
1024 | 1036 | ||
@@ -1027,15 +1039,18 @@ GNUNET_PQ_query_param_array_bytes ( | |||
1027 | unsigned int num, | 1039 | unsigned int num, |
1028 | const void *elements, | 1040 | const void *elements, |
1029 | const size_t *sizes, | 1041 | const size_t *sizes, |
1030 | const struct GNUNET_PQ_Context *db) | 1042 | struct GNUNET_PQ_Context *db) |
1031 | { | 1043 | { |
1044 | Oid oid; | ||
1045 | GNUNET_assert (GNUNET_OK == | ||
1046 | GNUNET_PQ_get_oid_by_name (db,"bytea",&oid)); | ||
1032 | return query_param_array_generic (num, | 1047 | return query_param_array_generic (num, |
1033 | true, | 1048 | true, |
1034 | elements, | 1049 | elements, |
1035 | sizes, | 1050 | sizes, |
1036 | 0, | 1051 | 0, |
1037 | array_of_byte, | 1052 | array_of_byte, |
1038 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1053 | oid); |
1039 | } | 1054 | } |
1040 | 1055 | ||
1041 | 1056 | ||
@@ -1044,15 +1059,18 @@ GNUNET_PQ_query_param_array_ptrs_bytes ( | |||
1044 | unsigned int num, | 1059 | unsigned int num, |
1045 | const void *elements[], | 1060 | const void *elements[], |
1046 | const size_t *sizes, | 1061 | const size_t *sizes, |
1047 | const struct GNUNET_PQ_Context *db) | 1062 | struct GNUNET_PQ_Context *db) |
1048 | { | 1063 | { |
1064 | Oid oid; | ||
1065 | GNUNET_assert (GNUNET_OK == | ||
1066 | GNUNET_PQ_get_oid_by_name (db,"bytea",&oid)); | ||
1049 | return query_param_array_generic (num, | 1067 | return query_param_array_generic (num, |
1050 | false, | 1068 | false, |
1051 | elements, | 1069 | elements, |
1052 | sizes, | 1070 | sizes, |
1053 | 0, | 1071 | 0, |
1054 | array_of_byte, | 1072 | array_of_byte, |
1055 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1073 | oid); |
1056 | } | 1074 | } |
1057 | 1075 | ||
1058 | 1076 | ||
@@ -1061,15 +1079,18 @@ GNUNET_PQ_query_param_array_bytes_same_size ( | |||
1061 | unsigned int num, | 1079 | unsigned int num, |
1062 | const void *elements, | 1080 | const void *elements, |
1063 | size_t same_size, | 1081 | size_t same_size, |
1064 | const struct GNUNET_PQ_Context *db) | 1082 | struct GNUNET_PQ_Context *db) |
1065 | { | 1083 | { |
1084 | Oid oid; | ||
1085 | GNUNET_assert (GNUNET_OK == | ||
1086 | GNUNET_PQ_get_oid_by_name (db,"bytea",&oid)); | ||
1066 | return query_param_array_generic (num, | 1087 | return query_param_array_generic (num, |
1067 | true, | 1088 | true, |
1068 | elements, | 1089 | elements, |
1069 | NULL, | 1090 | NULL, |
1070 | same_size, | 1091 | same_size, |
1071 | array_of_byte, | 1092 | array_of_byte, |
1072 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1093 | oid); |
1073 | } | 1094 | } |
1074 | 1095 | ||
1075 | 1096 | ||
@@ -1078,15 +1099,18 @@ GNUNET_PQ_query_param_array_ptrs_bytes_same_size ( | |||
1078 | unsigned int num, | 1099 | unsigned int num, |
1079 | const void *elements[], | 1100 | const void *elements[], |
1080 | size_t same_size, | 1101 | size_t same_size, |
1081 | const struct GNUNET_PQ_Context *db) | 1102 | struct GNUNET_PQ_Context *db) |
1082 | { | 1103 | { |
1104 | Oid oid; | ||
1105 | GNUNET_assert (GNUNET_OK == | ||
1106 | GNUNET_PQ_get_oid_by_name (db,"bytea",&oid)); | ||
1083 | return query_param_array_generic (num, | 1107 | return query_param_array_generic (num, |
1084 | false, | 1108 | false, |
1085 | elements, | 1109 | elements, |
1086 | NULL, | 1110 | NULL, |
1087 | same_size, | 1111 | same_size, |
1088 | array_of_byte, | 1112 | array_of_byte, |
1089 | db->oids[GNUNET_PQ_DATATYPE_BYTEA]); | 1113 | oid); |
1090 | } | 1114 | } |
1091 | 1115 | ||
1092 | 1116 | ||
@@ -1094,15 +1118,18 @@ struct GNUNET_PQ_QueryParam | |||
1094 | GNUNET_PQ_query_param_array_string ( | 1118 | GNUNET_PQ_query_param_array_string ( |
1095 | unsigned int num, | 1119 | unsigned int num, |
1096 | const char *elements, | 1120 | const char *elements, |
1097 | const struct GNUNET_PQ_Context *db) | 1121 | struct GNUNET_PQ_Context *db) |
1098 | { | 1122 | { |
1123 | Oid oid; | ||
1124 | GNUNET_assert (GNUNET_OK == | ||
1125 | GNUNET_PQ_get_oid_by_name (db,"varchar",&oid)); | ||
1099 | return query_param_array_generic (num, | 1126 | return query_param_array_generic (num, |
1100 | true, | 1127 | true, |
1101 | elements, | 1128 | elements, |
1102 | NULL, | 1129 | NULL, |
1103 | 0, | 1130 | 0, |
1104 | array_of_string, | 1131 | array_of_string, |
1105 | db->oids[GNUNET_PQ_DATATYPE_VARCHAR]); | 1132 | oid); |
1106 | } | 1133 | } |
1107 | 1134 | ||
1108 | 1135 | ||
@@ -1110,15 +1137,18 @@ struct GNUNET_PQ_QueryParam | |||
1110 | GNUNET_PQ_query_param_array_ptrs_string ( | 1137 | GNUNET_PQ_query_param_array_ptrs_string ( |
1111 | unsigned int num, | 1138 | unsigned int num, |
1112 | const char *elements[], | 1139 | const char *elements[], |
1113 | const struct GNUNET_PQ_Context *db) | 1140 | struct GNUNET_PQ_Context *db) |
1114 | { | 1141 | { |
1142 | Oid oid; | ||
1143 | GNUNET_assert (GNUNET_OK == | ||
1144 | GNUNET_PQ_get_oid_by_name (db,"varchar",&oid)); | ||
1115 | return query_param_array_generic (num, | 1145 | return query_param_array_generic (num, |
1116 | false, | 1146 | false, |
1117 | elements, | 1147 | elements, |
1118 | NULL, | 1148 | NULL, |
1119 | 0, | 1149 | 0, |
1120 | array_of_string, | 1150 | array_of_string, |
1121 | db->oids[GNUNET_PQ_DATATYPE_VARCHAR]); | 1151 | oid); |
1122 | } | 1152 | } |
1123 | 1153 | ||
1124 | 1154 | ||
@@ -1126,15 +1156,18 @@ struct GNUNET_PQ_QueryParam | |||
1126 | GNUNET_PQ_query_param_array_abs_time ( | 1156 | GNUNET_PQ_query_param_array_abs_time ( |
1127 | unsigned int num, | 1157 | unsigned int num, |
1128 | const struct GNUNET_TIME_Absolute *elements, | 1158 | const struct GNUNET_TIME_Absolute *elements, |
1129 | const struct GNUNET_PQ_Context *db) | 1159 | struct GNUNET_PQ_Context *db) |
1130 | { | 1160 | { |
1161 | Oid oid; | ||
1162 | GNUNET_assert (GNUNET_OK == | ||
1163 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1131 | return query_param_array_generic (num, | 1164 | return query_param_array_generic (num, |
1132 | true, | 1165 | true, |
1133 | elements, | 1166 | elements, |
1134 | NULL, | 1167 | NULL, |
1135 | sizeof(struct GNUNET_TIME_Absolute), | 1168 | sizeof(struct GNUNET_TIME_Absolute), |
1136 | array_of_abs_time, | 1169 | array_of_abs_time, |
1137 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1170 | oid); |
1138 | } | 1171 | } |
1139 | 1172 | ||
1140 | 1173 | ||
@@ -1142,15 +1175,18 @@ struct GNUNET_PQ_QueryParam | |||
1142 | GNUNET_PQ_query_param_array_ptrs_abs_time ( | 1175 | GNUNET_PQ_query_param_array_ptrs_abs_time ( |
1143 | unsigned int num, | 1176 | unsigned int num, |
1144 | const struct GNUNET_TIME_Absolute *elements[], | 1177 | const struct GNUNET_TIME_Absolute *elements[], |
1145 | const struct GNUNET_PQ_Context *db) | 1178 | struct GNUNET_PQ_Context *db) |
1146 | { | 1179 | { |
1180 | Oid oid; | ||
1181 | GNUNET_assert (GNUNET_OK == | ||
1182 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1147 | return query_param_array_generic (num, | 1183 | return query_param_array_generic (num, |
1148 | false, | 1184 | false, |
1149 | elements, | 1185 | elements, |
1150 | NULL, | 1186 | NULL, |
1151 | sizeof(struct GNUNET_TIME_Absolute), | 1187 | sizeof(struct GNUNET_TIME_Absolute), |
1152 | array_of_abs_time, | 1188 | array_of_abs_time, |
1153 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1189 | oid); |
1154 | } | 1190 | } |
1155 | 1191 | ||
1156 | 1192 | ||
@@ -1158,15 +1194,18 @@ struct GNUNET_PQ_QueryParam | |||
1158 | GNUNET_PQ_query_param_array_rel_time ( | 1194 | GNUNET_PQ_query_param_array_rel_time ( |
1159 | unsigned int num, | 1195 | unsigned int num, |
1160 | const struct GNUNET_TIME_Relative *elements, | 1196 | const struct GNUNET_TIME_Relative *elements, |
1161 | const struct GNUNET_PQ_Context *db) | 1197 | struct GNUNET_PQ_Context *db) |
1162 | { | 1198 | { |
1199 | Oid oid; | ||
1200 | GNUNET_assert (GNUNET_OK == | ||
1201 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1163 | return query_param_array_generic (num, | 1202 | return query_param_array_generic (num, |
1164 | true, | 1203 | true, |
1165 | elements, | 1204 | elements, |
1166 | NULL, | 1205 | NULL, |
1167 | sizeof(struct GNUNET_TIME_Relative), | 1206 | sizeof(struct GNUNET_TIME_Relative), |
1168 | array_of_abs_time, | 1207 | array_of_abs_time, |
1169 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1208 | oid); |
1170 | } | 1209 | } |
1171 | 1210 | ||
1172 | 1211 | ||
@@ -1174,15 +1213,18 @@ struct GNUNET_PQ_QueryParam | |||
1174 | GNUNET_PQ_query_param_array_ptrs_rel_time ( | 1213 | GNUNET_PQ_query_param_array_ptrs_rel_time ( |
1175 | unsigned int num, | 1214 | unsigned int num, |
1176 | const struct GNUNET_TIME_Relative *elements[], | 1215 | const struct GNUNET_TIME_Relative *elements[], |
1177 | const struct GNUNET_PQ_Context *db) | 1216 | struct GNUNET_PQ_Context *db) |
1178 | { | 1217 | { |
1218 | Oid oid; | ||
1219 | GNUNET_assert (GNUNET_OK == | ||
1220 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1179 | return query_param_array_generic (num, | 1221 | return query_param_array_generic (num, |
1180 | false, | 1222 | false, |
1181 | elements, | 1223 | elements, |
1182 | NULL, | 1224 | NULL, |
1183 | sizeof(struct GNUNET_TIME_Relative), | 1225 | sizeof(struct GNUNET_TIME_Relative), |
1184 | array_of_abs_time, | 1226 | array_of_abs_time, |
1185 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1227 | oid); |
1186 | } | 1228 | } |
1187 | 1229 | ||
1188 | 1230 | ||
@@ -1190,15 +1232,18 @@ struct GNUNET_PQ_QueryParam | |||
1190 | GNUNET_PQ_query_param_array_timestamp ( | 1232 | GNUNET_PQ_query_param_array_timestamp ( |
1191 | unsigned int num, | 1233 | unsigned int num, |
1192 | const struct GNUNET_TIME_Timestamp *elements, | 1234 | const struct GNUNET_TIME_Timestamp *elements, |
1193 | const struct GNUNET_PQ_Context *db) | 1235 | struct GNUNET_PQ_Context *db) |
1194 | { | 1236 | { |
1237 | Oid oid; | ||
1238 | GNUNET_assert (GNUNET_OK == | ||
1239 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1195 | return query_param_array_generic (num, | 1240 | return query_param_array_generic (num, |
1196 | true, | 1241 | true, |
1197 | elements, | 1242 | elements, |
1198 | NULL, | 1243 | NULL, |
1199 | sizeof(struct GNUNET_TIME_Timestamp), | 1244 | sizeof(struct GNUNET_TIME_Timestamp), |
1200 | array_of_timestamp, | 1245 | array_of_timestamp, |
1201 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1246 | oid); |
1202 | } | 1247 | } |
1203 | 1248 | ||
1204 | 1249 | ||
@@ -1206,15 +1251,18 @@ struct GNUNET_PQ_QueryParam | |||
1206 | GNUNET_PQ_query_param_array_ptrs_timestamp ( | 1251 | GNUNET_PQ_query_param_array_ptrs_timestamp ( |
1207 | unsigned int num, | 1252 | unsigned int num, |
1208 | const struct GNUNET_TIME_Timestamp *elements[], | 1253 | const struct GNUNET_TIME_Timestamp *elements[], |
1209 | const struct GNUNET_PQ_Context *db) | 1254 | struct GNUNET_PQ_Context *db) |
1210 | { | 1255 | { |
1256 | Oid oid; | ||
1257 | GNUNET_assert (GNUNET_OK == | ||
1258 | GNUNET_PQ_get_oid_by_name (db,"int8",&oid)); | ||
1211 | return query_param_array_generic (num, | 1259 | return query_param_array_generic (num, |
1212 | false, | 1260 | false, |
1213 | elements, | 1261 | elements, |
1214 | NULL, | 1262 | NULL, |
1215 | sizeof(struct GNUNET_TIME_Timestamp), | 1263 | sizeof(struct GNUNET_TIME_Timestamp), |
1216 | array_of_timestamp, | 1264 | array_of_timestamp, |
1217 | db->oids[GNUNET_PQ_DATATYPE_INT8]); | 1265 | oid); |
1218 | } | 1266 | } |
1219 | 1267 | ||
1220 | 1268 | ||
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 5f6215fc1..d0cb8c4b6 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -1429,7 +1429,7 @@ array_cleanup (void *cls, | |||
1429 | 1429 | ||
1430 | struct GNUNET_PQ_ResultSpec | 1430 | struct GNUNET_PQ_ResultSpec |
1431 | GNUNET_PQ_result_spec_array_bool ( | 1431 | GNUNET_PQ_result_spec_array_bool ( |
1432 | const struct GNUNET_PQ_Context *db, | 1432 | struct GNUNET_PQ_Context *db, |
1433 | const char *name, | 1433 | const char *name, |
1434 | size_t *num, | 1434 | size_t *num, |
1435 | bool **dst) | 1435 | bool **dst) |
@@ -1439,7 +1439,10 @@ GNUNET_PQ_result_spec_array_bool ( | |||
1439 | 1439 | ||
1440 | info->num = num; | 1440 | info->num = num; |
1441 | info->typ = array_of_bool; | 1441 | info->typ = array_of_bool; |
1442 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BOOL]; | 1442 | GNUNET_assert (GNUNET_OK == |
1443 | GNUNET_PQ_get_oid_by_name (db, | ||
1444 | "bool", | ||
1445 | &info->oid)); | ||
1443 | 1446 | ||
1444 | struct GNUNET_PQ_ResultSpec res = { | 1447 | struct GNUNET_PQ_ResultSpec res = { |
1445 | .conv = extract_array_generic, | 1448 | .conv = extract_array_generic, |
@@ -1454,7 +1457,7 @@ GNUNET_PQ_result_spec_array_bool ( | |||
1454 | 1457 | ||
1455 | struct GNUNET_PQ_ResultSpec | 1458 | struct GNUNET_PQ_ResultSpec |
1456 | GNUNET_PQ_result_spec_array_uint16 ( | 1459 | GNUNET_PQ_result_spec_array_uint16 ( |
1457 | const struct GNUNET_PQ_Context *db, | 1460 | struct GNUNET_PQ_Context *db, |
1458 | const char *name, | 1461 | const char *name, |
1459 | size_t *num, | 1462 | size_t *num, |
1460 | uint16_t **dst) | 1463 | uint16_t **dst) |
@@ -1464,7 +1467,10 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
1464 | 1467 | ||
1465 | info->num = num; | 1468 | info->num = num; |
1466 | info->typ = array_of_uint16; | 1469 | info->typ = array_of_uint16; |
1467 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT2]; | 1470 | GNUNET_assert (GNUNET_OK == |
1471 | GNUNET_PQ_get_oid_by_name (db, | ||
1472 | "int2", | ||
1473 | &info->oid)); | ||
1468 | 1474 | ||
1469 | struct GNUNET_PQ_ResultSpec res = { | 1475 | struct GNUNET_PQ_ResultSpec res = { |
1470 | .conv = extract_array_generic, | 1476 | .conv = extract_array_generic, |
@@ -1479,7 +1485,7 @@ GNUNET_PQ_result_spec_array_uint16 ( | |||
1479 | 1485 | ||
1480 | struct GNUNET_PQ_ResultSpec | 1486 | struct GNUNET_PQ_ResultSpec |
1481 | GNUNET_PQ_result_spec_array_uint32 ( | 1487 | GNUNET_PQ_result_spec_array_uint32 ( |
1482 | const struct GNUNET_PQ_Context *db, | 1488 | struct GNUNET_PQ_Context *db, |
1483 | const char *name, | 1489 | const char *name, |
1484 | size_t *num, | 1490 | size_t *num, |
1485 | uint32_t **dst) | 1491 | uint32_t **dst) |
@@ -1489,7 +1495,10 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
1489 | 1495 | ||
1490 | info->num = num; | 1496 | info->num = num; |
1491 | info->typ = array_of_uint32; | 1497 | info->typ = array_of_uint32; |
1492 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT4]; | 1498 | GNUNET_assert (GNUNET_OK == |
1499 | GNUNET_PQ_get_oid_by_name (db, | ||
1500 | "int4", | ||
1501 | &info->oid)); | ||
1493 | 1502 | ||
1494 | struct GNUNET_PQ_ResultSpec res = { | 1503 | struct GNUNET_PQ_ResultSpec res = { |
1495 | .conv = extract_array_generic, | 1504 | .conv = extract_array_generic, |
@@ -1504,7 +1513,7 @@ GNUNET_PQ_result_spec_array_uint32 ( | |||
1504 | 1513 | ||
1505 | struct GNUNET_PQ_ResultSpec | 1514 | struct GNUNET_PQ_ResultSpec |
1506 | GNUNET_PQ_result_spec_array_uint64 ( | 1515 | GNUNET_PQ_result_spec_array_uint64 ( |
1507 | const struct GNUNET_PQ_Context *db, | 1516 | struct GNUNET_PQ_Context *db, |
1508 | const char *name, | 1517 | const char *name, |
1509 | size_t *num, | 1518 | size_t *num, |
1510 | uint64_t **dst) | 1519 | uint64_t **dst) |
@@ -1514,7 +1523,10 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
1514 | 1523 | ||
1515 | info->num = num; | 1524 | info->num = num; |
1516 | info->typ = array_of_uint64; | 1525 | info->typ = array_of_uint64; |
1517 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1526 | GNUNET_assert (GNUNET_OK == |
1527 | GNUNET_PQ_get_oid_by_name (db, | ||
1528 | "int8", | ||
1529 | &info->oid)); | ||
1518 | 1530 | ||
1519 | struct GNUNET_PQ_ResultSpec res = { | 1531 | struct GNUNET_PQ_ResultSpec res = { |
1520 | .conv = extract_array_generic, | 1532 | .conv = extract_array_generic, |
@@ -1529,7 +1541,7 @@ GNUNET_PQ_result_spec_array_uint64 ( | |||
1529 | 1541 | ||
1530 | struct GNUNET_PQ_ResultSpec | 1542 | struct GNUNET_PQ_ResultSpec |
1531 | GNUNET_PQ_result_spec_array_abs_time ( | 1543 | GNUNET_PQ_result_spec_array_abs_time ( |
1532 | const struct GNUNET_PQ_Context *db, | 1544 | struct GNUNET_PQ_Context *db, |
1533 | const char *name, | 1545 | const char *name, |
1534 | size_t *num, | 1546 | size_t *num, |
1535 | struct GNUNET_TIME_Absolute **dst) | 1547 | struct GNUNET_TIME_Absolute **dst) |
@@ -1539,7 +1551,10 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1539 | 1551 | ||
1540 | info->num = num; | 1552 | info->num = num; |
1541 | info->typ = array_of_abs_time; | 1553 | info->typ = array_of_abs_time; |
1542 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1554 | GNUNET_assert (GNUNET_OK == |
1555 | GNUNET_PQ_get_oid_by_name (db, | ||
1556 | "int8", | ||
1557 | &info->oid)); | ||
1543 | 1558 | ||
1544 | struct GNUNET_PQ_ResultSpec res = { | 1559 | struct GNUNET_PQ_ResultSpec res = { |
1545 | .conv = extract_array_generic, | 1560 | .conv = extract_array_generic, |
@@ -1554,7 +1569,7 @@ GNUNET_PQ_result_spec_array_abs_time ( | |||
1554 | 1569 | ||
1555 | struct GNUNET_PQ_ResultSpec | 1570 | struct GNUNET_PQ_ResultSpec |
1556 | GNUNET_PQ_result_spec_array_rel_time ( | 1571 | GNUNET_PQ_result_spec_array_rel_time ( |
1557 | const struct GNUNET_PQ_Context *db, | 1572 | struct GNUNET_PQ_Context *db, |
1558 | const char *name, | 1573 | const char *name, |
1559 | size_t *num, | 1574 | size_t *num, |
1560 | struct GNUNET_TIME_Relative **dst) | 1575 | struct GNUNET_TIME_Relative **dst) |
@@ -1564,7 +1579,10 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1564 | 1579 | ||
1565 | info->num = num; | 1580 | info->num = num; |
1566 | info->typ = array_of_rel_time; | 1581 | info->typ = array_of_rel_time; |
1567 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1582 | GNUNET_assert (GNUNET_OK == |
1583 | GNUNET_PQ_get_oid_by_name (db, | ||
1584 | "int8", | ||
1585 | &info->oid)); | ||
1568 | 1586 | ||
1569 | struct GNUNET_PQ_ResultSpec res = { | 1587 | struct GNUNET_PQ_ResultSpec res = { |
1570 | .conv = extract_array_generic, | 1588 | .conv = extract_array_generic, |
@@ -1579,7 +1597,7 @@ GNUNET_PQ_result_spec_array_rel_time ( | |||
1579 | 1597 | ||
1580 | struct GNUNET_PQ_ResultSpec | 1598 | struct GNUNET_PQ_ResultSpec |
1581 | GNUNET_PQ_result_spec_array_timestamp ( | 1599 | GNUNET_PQ_result_spec_array_timestamp ( |
1582 | const struct GNUNET_PQ_Context *db, | 1600 | struct GNUNET_PQ_Context *db, |
1583 | const char *name, | 1601 | const char *name, |
1584 | size_t *num, | 1602 | size_t *num, |
1585 | struct GNUNET_TIME_Timestamp **dst) | 1603 | struct GNUNET_TIME_Timestamp **dst) |
@@ -1589,7 +1607,10 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1589 | 1607 | ||
1590 | info->num = num; | 1608 | info->num = num; |
1591 | info->typ = array_of_timestamp; | 1609 | info->typ = array_of_timestamp; |
1592 | info->oid = db->oids[GNUNET_PQ_DATATYPE_INT8]; | 1610 | GNUNET_assert (GNUNET_OK == |
1611 | GNUNET_PQ_get_oid_by_name (db, | ||
1612 | "int8", | ||
1613 | &info->oid)); | ||
1593 | 1614 | ||
1594 | struct GNUNET_PQ_ResultSpec res = { | 1615 | struct GNUNET_PQ_ResultSpec res = { |
1595 | .conv = extract_array_generic, | 1616 | .conv = extract_array_generic, |
@@ -1604,7 +1625,7 @@ GNUNET_PQ_result_spec_array_timestamp ( | |||
1604 | 1625 | ||
1605 | struct GNUNET_PQ_ResultSpec | 1626 | struct GNUNET_PQ_ResultSpec |
1606 | GNUNET_PQ_result_spec_array_variable_size ( | 1627 | GNUNET_PQ_result_spec_array_variable_size ( |
1607 | const struct GNUNET_PQ_Context *db, | 1628 | struct GNUNET_PQ_Context *db, |
1608 | const char *name, | 1629 | const char *name, |
1609 | size_t *num, | 1630 | size_t *num, |
1610 | size_t **sizes, | 1631 | size_t **sizes, |
@@ -1616,7 +1637,10 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1616 | info->num = num; | 1637 | info->num = num; |
1617 | info->sizes = sizes; | 1638 | info->sizes = sizes; |
1618 | info->typ = array_of_byte; | 1639 | info->typ = array_of_byte; |
1619 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BYTEA]; | 1640 | GNUNET_assert (GNUNET_OK == |
1641 | GNUNET_PQ_get_oid_by_name (db, | ||
1642 | "bytea", | ||
1643 | &info->oid)); | ||
1620 | 1644 | ||
1621 | struct GNUNET_PQ_ResultSpec res = { | 1645 | struct GNUNET_PQ_ResultSpec res = { |
1622 | .conv = extract_array_generic, | 1646 | .conv = extract_array_generic, |
@@ -1631,7 +1655,7 @@ GNUNET_PQ_result_spec_array_variable_size ( | |||
1631 | 1655 | ||
1632 | struct GNUNET_PQ_ResultSpec | 1656 | struct GNUNET_PQ_ResultSpec |
1633 | GNUNET_PQ_result_spec_array_fixed_size ( | 1657 | GNUNET_PQ_result_spec_array_fixed_size ( |
1634 | const struct GNUNET_PQ_Context *db, | 1658 | struct GNUNET_PQ_Context *db, |
1635 | const char *name, | 1659 | const char *name, |
1636 | size_t size, | 1660 | size_t size, |
1637 | size_t *num, | 1661 | size_t *num, |
@@ -1643,7 +1667,10 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1643 | info->num = num; | 1667 | info->num = num; |
1644 | info->same_size = size; | 1668 | info->same_size = size; |
1645 | info->typ = array_of_byte; | 1669 | info->typ = array_of_byte; |
1646 | info->oid = db->oids[GNUNET_PQ_DATATYPE_BYTEA]; | 1670 | GNUNET_assert (GNUNET_OK == |
1671 | GNUNET_PQ_get_oid_by_name (db, | ||
1672 | "bytea", | ||
1673 | &info->oid)); | ||
1647 | 1674 | ||
1648 | struct GNUNET_PQ_ResultSpec res = { | 1675 | struct GNUNET_PQ_ResultSpec res = { |
1649 | .conv = extract_array_generic, | 1676 | .conv = extract_array_generic, |
@@ -1658,7 +1685,7 @@ GNUNET_PQ_result_spec_array_fixed_size ( | |||
1658 | 1685 | ||
1659 | struct GNUNET_PQ_ResultSpec | 1686 | struct GNUNET_PQ_ResultSpec |
1660 | GNUNET_PQ_result_spec_array_string ( | 1687 | GNUNET_PQ_result_spec_array_string ( |
1661 | const struct GNUNET_PQ_Context *db, | 1688 | struct GNUNET_PQ_Context *db, |
1662 | const char *name, | 1689 | const char *name, |
1663 | size_t *num, | 1690 | size_t *num, |
1664 | char **dst) | 1691 | char **dst) |
@@ -1668,7 +1695,10 @@ GNUNET_PQ_result_spec_array_string ( | |||
1668 | 1695 | ||
1669 | info->num = num; | 1696 | info->num = num; |
1670 | info->typ = array_of_string; | 1697 | info->typ = array_of_string; |
1671 | info->oid = db->oids[GNUNET_PQ_DATATYPE_VARCHAR]; | 1698 | GNUNET_assert (GNUNET_OK == |
1699 | GNUNET_PQ_get_oid_by_name (db, | ||
1700 | "varchar", | ||
1701 | &info->oid)); | ||
1672 | 1702 | ||
1673 | struct GNUNET_PQ_ResultSpec res = { | 1703 | struct GNUNET_PQ_ResultSpec res = { |
1674 | .conv = extract_array_generic, | 1704 | .conv = extract_array_generic, |