modify GNUNET_PQ_connect_with_cfg to enable flexible loading of .sql files
[oweals/gnunet.git] / src / include / gnunet_pq_lib.h
1 /*
2    This file is part of GNUnet
3    Copyright (C) 2016, 2017 GNUnet e.V.
4
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
7    by the Free Software Foundation, either version 3 of the License,
8    or (at your option) any later version.
9
10    GNUnet is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Affero General Public License for more details.
14
15    You should have received a copy of the GNU Affero General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 /**
21  * @file include/gnunet_pq_lib.h
22  * @brief helper functions for Postgres DB interactions
23  * @author Christian Grothoff
24  */
25 #ifndef GNUNET_PQ_LIB_H
26 #define GNUNET_PQ_LIB_H
27
28 #include <libpq-fe.h>
29 #include "gnunet_util_lib.h"
30 #include "gnunet_db_lib.h"
31
32 /* ************************* pq_query_helper.c functions ************************ */
33
34
35 /**
36  * Function called to convert input argument into SQL parameters.
37  *
38  * @param cls closure
39  * @param data pointer to input argument
40  * @param data_len number of bytes in @a data (if applicable)
41  * @param[out] param_values SQL data to set
42  * @param[out] param_lengths SQL length data to set
43  * @param[out] param_formats SQL format data to set
44  * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays
45  * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc()
46  * @param scratch_length number of entries left in @a scratch
47  * @return -1 on error, number of offsets used in @a scratch otherwise
48  */
49 typedef int
50 (*GNUNET_PQ_QueryConverter) (void *cls,
51                              const void *data,
52                              size_t data_len,
53                              void *param_values[],
54                              int param_lengths[],
55                              int param_formats[],
56                              unsigned int param_length,
57                              void *scratch[],
58                              unsigned int scratch_length);
59
60
61 /**
62  * @brief Description of a DB query parameter.
63  */
64 struct GNUNET_PQ_QueryParam
65 {
66   /**
67    * Function for how to handle this type of entry.
68    */
69   GNUNET_PQ_QueryConverter conv;
70
71   /**
72    * Closure for @e conv.
73    */
74   void *conv_cls;
75
76   /**
77    * Data or NULL.
78    */
79   const void *data;
80
81   /**
82    * Size of @e data
83    */
84   size_t size;
85
86   /**
87    * Number of parameters eaten by this operation.
88    */
89   unsigned int num_params;
90 };
91
92
93 /**
94  * End of query parameter specification.
95  */
96 #define GNUNET_PQ_query_param_end \
97   {                               \
98     NULL, NULL, NULL, 0, 0        \
99   }
100
101
102 /**
103  * Generate query parameter for a buffer @a ptr of
104  * @a ptr_size bytes.
105  *
106  * @param ptr pointer to the query parameter to pass
107  * @oaran ptr_size number of bytes in @a ptr
108  */
109 struct GNUNET_PQ_QueryParam
110 GNUNET_PQ_query_param_fixed_size (const void *ptr, size_t ptr_size);
111
112
113 /**
114  * Generate query parameter for a string.
115  *
116  * @param ptr pointer to the string query parameter to pass
117  */
118 struct GNUNET_PQ_QueryParam
119 GNUNET_PQ_query_param_string (const char *ptr);
120
121
122 /**
123  * Generate fixed-size query parameter with size determined
124  * by variable type.
125  *
126  * @param x pointer to the query parameter to pass.
127  */
128 #define GNUNET_PQ_query_param_auto_from_type(x) \
129   GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x)))
130
131
132 /**
133  * Generate query parameter for an RSA public key.  The
134  * database must contain a BLOB type in the respective position.
135  *
136  * @param x the query parameter to pass.
137  */
138 struct GNUNET_PQ_QueryParam
139 GNUNET_PQ_query_param_rsa_public_key (
140   const struct GNUNET_CRYPTO_RsaPublicKey *x);
141
142
143 /**
144  * Generate query parameter for an RSA signature.  The
145  * database must contain a BLOB type in the respective position.
146  *
147  * @param x the query parameter to pass
148  */
149 struct GNUNET_PQ_QueryParam
150 GNUNET_PQ_query_param_rsa_signature (
151   const struct GNUNET_CRYPTO_RsaSignature *x);
152
153
154 /**
155  * Generate query parameter for an absolute time value.
156  * The database must store a 64-bit integer.
157  *
158  * @param x pointer to the query parameter to pass
159  */
160 struct GNUNET_PQ_QueryParam
161 GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x);
162
163
164 /**
165  * Generate query parameter for an absolute time value.
166  * The database must store a 64-bit integer.
167  *
168  * @param x pointer to the query parameter to pass
169  */
170 struct GNUNET_PQ_QueryParam
171 GNUNET_PQ_query_param_absolute_time_nbo (
172   const struct GNUNET_TIME_AbsoluteNBO *x);
173
174
175 /**
176  * Generate query parameter for an uint16_t in host byte order.
177  *
178  * @param x pointer to the query parameter to pass
179  */
180 struct GNUNET_PQ_QueryParam
181 GNUNET_PQ_query_param_uint16 (const uint16_t *x);
182
183
184 /**
185  * Generate query parameter for an uint32_t in host byte order.
186  *
187  * @param x pointer to the query parameter to pass
188  */
189 struct GNUNET_PQ_QueryParam
190 GNUNET_PQ_query_param_uint32 (const uint32_t *x);
191
192
193 /**
194  * Generate query parameter for an uint16_t in host byte order.
195  *
196  * @param x pointer to the query parameter to pass
197  */
198 struct GNUNET_PQ_QueryParam
199 GNUNET_PQ_query_param_uint64 (const uint64_t *x);
200
201
202 /* ************************* pq_result_helper.c functions ************************ */
203
204
205 /**
206  * Extract data from a Postgres database @a result at row @a row.
207  *
208  * @param cls closure
209  * @param result where to extract data from
210  * @param int row to extract data from
211  * @param fname name (or prefix) of the fields to extract from
212  * @param[in,out] dst_size where to store size of result, may be NULL
213  * @param[out] dst where to store the result
214  * @return
215  *   #GNUNET_YES if all results could be extracted
216  *   #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
217  */
218 typedef int
219 (*GNUNET_PQ_ResultConverter) (void *cls,
220                               PGresult *result,
221                               int row,
222                               const char *fname,
223                               size_t *dst_size,
224                               void *dst);
225
226
227 /**
228  * Function called to clean up memory allocated
229  * by a #GNUNET_PQ_ResultConverter.
230  *
231  * @param cls closure
232  * @param rd result data to clean up
233  */
234 typedef void
235 (*GNUNET_PQ_ResultCleanup) (void *cls,
236                             void *rd);
237
238
239 /**
240  * @brief Description of a DB result cell.
241  */
242 struct GNUNET_PQ_ResultSpec
243 {
244   /**
245    * What is the format of the result?
246    */
247   GNUNET_PQ_ResultConverter conv;
248
249   /**
250    * Function to clean up result data, NULL if cleanup is
251    * not necessary.
252    */
253   GNUNET_PQ_ResultCleanup cleaner;
254
255   /**
256    * Closure for @e conv and @e cleaner.
257    */
258   void *cls;
259
260   /**
261    * Destination for the data.
262    */
263   void *dst;
264
265   /**
266    * Allowed size for the data, 0 for variable-size
267    * (in this case, the type of @e dst is a `void **`
268    * and we need to allocate a buffer of the right size).
269    */
270   size_t dst_size;
271
272   /**
273    * Field name of the desired result.
274    */
275   const char *fname;
276
277   /**
278    * Where to store actual size of the result.
279    */
280   size_t *result_size;
281 };
282
283
284 /**
285  * End of result parameter specification.
286  *
287  * @return array last entry for the result specification to use
288  */
289 #define GNUNET_PQ_result_spec_end         \
290   {                                       \
291     NULL, NULL, NULL, NULL, 0, NULL, NULL \
292   }
293
294
295 /**
296  * Variable-size result expected.
297  *
298  * @param name name of the field in the table
299  * @param[out] dst where to store the result, allocated
300  * @param[out] sptr where to store the size of @a dst
301  * @return array entry for the result specification to use
302  */
303 struct GNUNET_PQ_ResultSpec
304 GNUNET_PQ_result_spec_variable_size (const char *name,
305                                      void **dst,
306                                      size_t *sptr);
307
308
309 /**
310  * Fixed-size result expected.
311  *
312  * @param name name of the field in the table
313  * @param[out] dst where to store the result
314  * @param dst_size number of bytes in @a dst
315  * @return array entry for the result specification to use
316  */
317 struct GNUNET_PQ_ResultSpec
318 GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size);
319
320
321 /**
322  * We expect a fixed-size result, with size determined by the type of `* dst`
323  *
324  * @param name name of the field in the table
325  * @param dst point to where to store the result, type fits expected result size
326  * @return array entry for the result specification to use
327  */
328 #define GNUNET_PQ_result_spec_auto_from_type(name, dst) \
329   GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof(*(dst)))
330
331
332 /**
333  * 0-terminated string expected.
334  *
335  * @param name name of the field in the table
336  * @param[out] dst where to store the result, allocated
337  * @return array entry for the result specification to use
338  */
339 struct GNUNET_PQ_ResultSpec
340 GNUNET_PQ_result_spec_string (const char *name, char **dst);
341
342
343 /**
344  * RSA public key expected.
345  *
346  * @param name name of the field in the table
347  * @param[out] rsa where to store the result
348  * @return array entry for the result specification to use
349  */
350 struct GNUNET_PQ_ResultSpec
351 GNUNET_PQ_result_spec_rsa_public_key (const char *name,
352                                       struct GNUNET_CRYPTO_RsaPublicKey **rsa);
353
354
355 /**
356  * RSA signature expected.
357  *
358  * @param name name of the field in the table
359  * @param[out] sig where to store the result;
360  * @return array entry for the result specification to use
361  */
362 struct GNUNET_PQ_ResultSpec
363 GNUNET_PQ_result_spec_rsa_signature (const char *name,
364                                      struct GNUNET_CRYPTO_RsaSignature **sig);
365
366
367 /**
368  * Absolute time expected.
369  *
370  * @param name name of the field in the table
371  * @param[out] at where to store the result
372  * @return array entry for the result specification to use
373  */
374 struct GNUNET_PQ_ResultSpec
375 GNUNET_PQ_result_spec_absolute_time (const char *name,
376                                      struct GNUNET_TIME_Absolute *at);
377
378
379 /**
380  * Absolute time expected.
381  *
382  * @param name name of the field in the table
383  * @param[out] at where to store the result
384  * @return array entry for the result specification to use
385  */
386 struct GNUNET_PQ_ResultSpec
387 GNUNET_PQ_result_spec_absolute_time_nbo (const char *name,
388                                          struct GNUNET_TIME_AbsoluteNBO *at);
389
390
391 /**
392  * uint16_t expected.
393  *
394  * @param name name of the field in the table
395  * @param[out] u16 where to store the result
396  * @return array entry for the result specification to use
397  */
398 struct GNUNET_PQ_ResultSpec
399 GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16);
400
401
402 /**
403  * uint32_t expected.
404  *
405  * @param name name of the field in the table
406  * @param[out] u32 where to store the result
407  * @return array entry for the result specification to use
408  */
409 struct GNUNET_PQ_ResultSpec
410 GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32);
411
412
413 /**
414  * uint64_t expected.
415  *
416  * @param name name of the field in the table
417  * @param[out] u64 where to store the result
418  * @return array entry for the result specification to use
419  */
420 struct GNUNET_PQ_ResultSpec
421 GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64);
422
423
424 /* ************************* pq.c functions ************************ */
425
426 /**
427  * Postgres context.
428  */
429 struct GNUNET_PQ_Context;
430
431
432 /**
433  * Execute a prepared statement.
434  *
435  * @param db database context
436  * @param name name of the prepared statement
437  * @param params parameters to the statement
438  * @return postgres result
439  * @deprecated (should become an internal API)
440  */
441 PGresult *
442 GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db,
443                          const char *name,
444                          const struct GNUNET_PQ_QueryParam *params);
445
446
447 /**
448  * Extract results from a query result according to the given specification.
449  *
450  * @param result result to process
451  * @param[in,out] rs result specification to extract for
452  * @param row row from the result to extract
453  * @return
454  *   #GNUNET_YES if all results could be extracted
455  *   #GNUNET_SYSERR if a result was invalid (non-existing field)
456  * @deprecated (should become an internal API)
457  */
458 int
459 GNUNET_PQ_extract_result (PGresult *result,
460                           struct GNUNET_PQ_ResultSpec *rs,
461                           int row);
462
463
464 /**
465  * Free all memory that was allocated in @a rs during
466  * #GNUNET_PQ_extract_result().
467  *
468  * @param rs reult specification to clean up
469  */
470 void
471 GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs);
472
473
474 /* ******************** pq_eval.c functions ************** */
475
476
477 /**
478  * Check the @a result's error code to see what happened.
479  * Also logs errors.
480  *
481  * @param db database to execute the statement in
482  * @param statement_name name of the statement that created @a result
483  * @param result result to check
484  * @return status code from the result, mapping PQ status
485  *         codes to `enum GNUNET_DB_QueryStatus`.  Never
486  *         returns positive values as this function does
487  *         not look at the result set.
488  * @deprecated (low level, let's see if we can do with just the high-level functions)
489  */
490 enum GNUNET_DB_QueryStatus
491 GNUNET_PQ_eval_result (struct GNUNET_PQ_Context *db,
492                        const char *statement_name,
493                        PGresult *result);
494
495
496 /**
497  * Execute a named prepared @a statement that is NOT a SELECT
498  * statement in @a connnection using the given @a params.  Returns the
499  * resulting session state.
500  *
501  * @param db database to execute the statement with
502  * @param statement_name name of the statement
503  * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated)
504  * @return status code from the result, mapping PQ status
505  *         codes to `enum GNUNET_DB_QueryStatus`.   If the
506  *         statement was a DELETE or UPDATE statement, the
507  *         number of affected rows is returned; if the
508  *         statment was an INSERT statement, and no row
509  *         was added due to a UNIQUE violation, we return
510  *         zero; if INSERT was successful, we return one.
511  */
512 enum GNUNET_DB_QueryStatus
513 GNUNET_PQ_eval_prepared_non_select (struct GNUNET_PQ_Context *db,
514                                     const char *statement_name,
515                                     const struct GNUNET_PQ_QueryParam *params);
516
517
518 /**
519  * Function to be called with the results of a SELECT statement
520  * that has returned @a num_results results.
521  *
522  * @param cls closure
523  * @param result the postgres result
524  * @param num_result the number of results in @a result
525  */
526 typedef void
527 (*GNUNET_PQ_PostgresResultHandler) (void *cls,
528                                     PGresult *result,
529                                     unsigned int num_results);
530
531
532 /**
533  * Execute a named prepared @a statement that is a SELECT statement
534  * which may return multiple results in @a connection using the given
535  * @a params.  Call @a rh with the results.  Returns the query
536  * status including the number of results given to @a rh (possibly zero).
537  * @a rh will not have been called if the return value is negative.
538  *
539  * @param db database to execute the statement with
540  * @param statement_name name of the statement
541  * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated)
542  * @param rh function to call with the result set, NULL to ignore
543  * @param rh_cls closure to pass to @a rh
544  * @return status code from the result, mapping PQ status
545  *         codes to `enum GNUNET_DB_QueryStatus`.
546  */
547 enum GNUNET_DB_QueryStatus
548 GNUNET_PQ_eval_prepared_multi_select (struct GNUNET_PQ_Context *db,
549                                       const char *statement_name,
550                                       const struct GNUNET_PQ_QueryParam *params,
551                                       GNUNET_PQ_PostgresResultHandler rh,
552                                       void *rh_cls);
553
554
555 /**
556  * Execute a named prepared @a statement that is a SELECT statement
557  * which must return a single result in @a connection using the given
558  * @a params.  Stores the result (if any) in @a rs, which the caller
559  * must then clean up using #GNUNET_PQ_cleanup_result() if the return
560  * value was #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT.  Returns the
561  * resulting session status.
562  *
563  * @param db database to execute the statement with
564  * @param statement_name name of the statement
565  * @param params parameters to give to the statement (#GNUNET_PQ_query_param_end-terminated)
566  * @param[in,out] rs result specification to use for storing the result of the query
567  * @return status code from the result, mapping PQ status
568  *         codes to `enum GNUNET_DB_QueryStatus`.
569  */
570 enum GNUNET_DB_QueryStatus
571 GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db,
572                                           const char *statement_name,
573                                           const struct
574                                           GNUNET_PQ_QueryParam *params,
575                                           struct GNUNET_PQ_ResultSpec *rs);
576
577
578 /* ******************** pq_prepare.c functions ************** */
579
580
581 /**
582  * Information needed to prepare a list of SQL statements using
583  * #GNUNET_PQ_prepare_statements().
584  */
585 struct GNUNET_PQ_PreparedStatement
586 {
587   /**
588    * Name of the statement.
589    */
590   const char *name;
591
592   /**
593    * Actual SQL statement.
594    */
595   const char *sql;
596
597   /**
598    * Number of arguments included in @e sql.
599    */
600   unsigned int num_arguments;
601
602 };
603
604
605 /**
606  * Terminator for prepared statement list.
607  */
608 #define GNUNET_PQ_PREPARED_STATEMENT_END \
609   {                                      \
610     NULL, NULL, 0                        \
611   }
612
613
614 /**
615  * Create a `struct GNUNET_PQ_PreparedStatement`.
616  *
617  * @param name name of the statement
618  * @param sql actual SQL statement
619  * @param num_args number of arguments in the statement
620  * @return initialized struct
621  */
622 struct GNUNET_PQ_PreparedStatement
623 GNUNET_PQ_make_prepare (const char *name,
624                         const char *sql,
625                         unsigned int num_args);
626
627
628 /**
629  * Request creation of prepared statements @a ps from Postgres.
630  *
631  * @param db database to prepare the statements for
632  * @param ps #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared
633  *            statements.
634  * @return #GNUNET_OK on success,
635  *         #GNUNET_SYSERR on error
636  */
637 int
638 GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db,
639                               const struct GNUNET_PQ_PreparedStatement *ps);
640
641
642 /* ******************** pq_exec.c functions ************** */
643
644
645 /**
646  * Information needed to run a list of SQL statements using
647  * #GNUNET_PQ_exec_statements().
648  */
649 struct GNUNET_PQ_ExecuteStatement
650 {
651   /**
652    * Actual SQL statement.
653    */
654   const char *sql;
655
656   /**
657    * Should we ignore errors?
658    */
659   int ignore_errors;
660 };
661
662
663 /**
664  * Terminator for executable statement list.
665  */
666 #define GNUNET_PQ_EXECUTE_STATEMENT_END \
667   {                                     \
668     NULL, GNUNET_SYSERR                 \
669   }
670
671
672 /**
673  * Create a `struct GNUNET_PQ_ExecuteStatement` where errors are fatal.
674  *
675  * @param sql actual SQL statement
676  * @return initialized struct
677  */
678 struct GNUNET_PQ_ExecuteStatement
679 GNUNET_PQ_make_execute (const char *sql);
680
681
682 /**
683  * Create a `struct GNUNET_PQ_ExecuteStatement` where errors should
684  * be tolerated.
685  *
686  * @param sql actual SQL statement
687  * @return initialized struct
688  */
689 struct GNUNET_PQ_ExecuteStatement
690 GNUNET_PQ_make_try_execute (const char *sql);
691
692
693 /**
694  * Request execution of an array of statements @a es from Postgres.
695  *
696  * @param pq database to execute the statements in
697  * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared
698  *            statements.
699  * @return #GNUNET_OK on success (modulo statements where errors can be ignored)
700  *         #GNUNET_SYSERR on error
701  */
702 int
703 GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db,
704                            const struct GNUNET_PQ_ExecuteStatement *es);
705
706
707 /* ******************** pq_connect.c functions ************** */
708
709
710 /**
711  * Create a connection to the Postgres database using @a config_str for the
712  * configuration.  Initialize logging via GNUnet's log routines and disable
713  * Postgres's logger.  Also ensures that the statements in @a load_path and @a
714  * es are executed whenever we (re)connect to the database, and that the
715  * prepared statements in @a ps are "ready".  If statements in @es fail that
716  * were created with #GNUNET_PQ_make_execute(), then the entire operation
717  * fails.
718  *
719  * In @a load_path, a list of "$XXXX.sql" files is expected where $XXXX
720  * must be a sequence of contiguous integer values starting at 0000.
721  * These files are then loaded in sequence using "psql $config_str" before
722  * running statements from @e es.  The directory is inspected again on
723  * reconnect.
724  *
725  * @param config_str configuration to use
726  * @param load_path path to directory with SQL transactions to run, can be NULL
727  * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated
728  *            array of statements to execute upon EACH connection, can be NULL
729  * @param ps array of prepared statements to prepare, can be NULL
730  * @return NULL on error
731  */
732 struct GNUNET_PQ_Context *
733 GNUNET_PQ_connect (const char *config_str,
734                    const char *load_path,
735                    const struct GNUNET_PQ_ExecuteStatement *es,
736                    const struct GNUNET_PQ_PreparedStatement *ps);
737
738
739 /**
740  * Connect to a postgres database using the configuration
741  * option "CONFIG" in @a section.  Also ensures that the
742  * statements in @a es are executed whenever we (re)connect to the
743  * database, and that the prepared statements in @a ps are "ready".
744  *
745  * The caller does not have to ensure that @a es and @a ps remain allocated
746  * and initialized in memory until #GNUNET_PQ_disconnect() is called, as a copy will be made.
747  *
748  * @param cfg configuration
749  * @param section configuration section to use to get Postgres configuration options
750  * @param load_path_suffix suffix to append to the SQL_DIR in the configuration
751  * @param es #GNUNET_PQ_PREPARED_STATEMENT_END-terminated
752  *            array of statements to execute upon EACH connection, can be NULL
753  * @param ps array of prepared statements to prepare, can be NULL
754  * @return the postgres handle, NULL on error
755  */
756 struct GNUNET_PQ_Context *
757 GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
758                             const char *section,
759                             const char *load_path,
760                             const struct GNUNET_PQ_ExecuteStatement *es,
761                             const struct GNUNET_PQ_PreparedStatement *ps);
762
763
764 /**
765  * Reinitialize the database @a db if the connection is down.
766  *
767  * @param db database connection to reinitialize
768  */
769 void
770 GNUNET_PQ_reconnect_if_down (struct GNUNET_PQ_Context *db);
771
772
773 /**
774  * Reinitialize the database @a db.
775  *
776  * @param db database connection to reinitialize
777  */
778 void
779 GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db);
780
781
782 /**
783  * Disconnect from the database, destroying the prepared statements
784  * and releasing other associated resources.
785  *
786  * @param db database handle to disconnect (will be free'd)
787  */
788 void
789 GNUNET_PQ_disconnect (struct GNUNET_PQ_Context *db);
790
791
792 #endif /* GNUNET_PQ_LIB_H_ */
793
794 /* end of include/gnunet_pq_lib.h */