helper functions for Postgres DB interactions More...
#include <libpq-fe.h>
#include <stdint.h>
#include "gnunet_common.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_db_lib.h"
#include "postgres_ext.h"
Go to the source code of this file.
Data Structures | |
struct | GNUNET_PQ_QueryParam |
Description of a DB query parameter. More... | |
struct | GNUNET_PQ_ArrayHeader_P |
The header for a postgresql array in binary format. More... | |
struct | GNUNET_PQ_ResultSpec |
Description of a DB result cell. More... | |
struct | GNUNET_PQ_PreparedStatement |
Information needed to prepare a list of SQL statements using GNUNET_PQ_prepare_statements(). More... | |
struct | GNUNET_PQ_ExecuteStatement |
Information needed to run a list of SQL statements using GNUNET_PQ_exec_statements(). More... | |
Macros | |
#define | GNUNET_PQ_query_param_end |
End of query parameter specification. More... | |
#define | GNUNET_PQ_query_param_array_auto_from_type(num, elements, db) |
Generate array of equal-sized query parameter with size determined by variable type from a pointer to an continuous array. More... | |
#define | GNUNET_PQ_query_param_array_ptrs_auto_from_type(num, elements, db) |
Generate array of equal-sized query parameter with size determined by variable type from a pointer to an array of pointers to objects of the same type. More... | |
#define | GNUNET_PQ_query_param_auto_from_type(x) GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) |
Generate fixed-size query parameter with size determined by variable type. More... | |
#define | GNUNET_PQ_result_spec_end |
End of result parameter specification. More... | |
#define | GNUNET_PQ_result_spec_auto_from_type(name, dst) GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof(*(dst))) |
We expect a fixed-size result, with size determined by the type of * dst More... | |
#define | GNUNET_PQ_result_spec_auto_array_from_type(db, name, num, dst) |
We expect a fixed-size result, with size determined by the type of * dst More... | |
#define | GNUNET_PQ_PREPARED_STATEMENT_END |
Terminator for prepared statement list. More... | |
#define | GNUNET_PQ_EXECUTE_STATEMENT_END |
Terminator for executable statement list. More... | |
Typedefs | |
typedef int(* | GNUNET_PQ_QueryConverter) (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length) |
Function called to convert input argument into SQL parameters. More... | |
typedef void(* | GNUNET_PQ_QueryConverter_Cleanup) (void *cls) |
Function called to cleanup the closure of SQL parameters converter. More... | |
typedef enum GNUNET_GenericReturnValue(* | GNUNET_PQ_ResultConverter) (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst) |
Extract data from a Postgres database result at row row. More... | |
typedef void(* | GNUNET_PQ_ResultCleanup) (void *cls, void *rd) |
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter. More... | |
typedef void(* | GNUNET_PQ_PostgresResultHandler) (void *cls, PGresult *result, unsigned int num_results) |
Function to be called with the results of a SELECT statement that has returned num_results results. More... | |
Enumerations | |
enum | GNUNET_PQ_Options { GNUNET_PQ_FLAG_NONE = 0 , GNUNET_PQ_FLAG_DROP = 1 , GNUNET_PQ_FLAG_CHECK_CURRENT = 2 } |
Flags to control PQ operation. More... | |
Functions | |
void | GNUNET_PQ_cleanup_query_params_closures (const struct GNUNET_PQ_QueryParam *params) |
Must be called to cleanup memory from closures after the query parameters have been used as much as needed. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_null (void) |
Generate query parameter to create a NULL value. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_fixed_size (const void *ptr, size_t ptr_size) |
Generate query parameter for a buffer ptr of ptr_size bytes. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_string (const char *ptr) |
Generate query parameter for a string. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_bool (bool b) |
Pass a boolean into a query. More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_get_oid_by_name (struct GNUNET_PQ_Context *db, const char *name, Oid *oid) |
Returns the oid for a given datatype by name. More... | |
struct GNUNET_PQ_ArrayHeader_P | __attribute__ ((packed)) |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_bool (unsigned int num, const bool *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of bool in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_uint16 (unsigned int num, const uint16_t *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of uint16_t in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_uint32 (unsigned int num, const uint32_t *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of uint32_t in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_uint64 (unsigned int num, const uint64_t *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of uint64 in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_bytes (unsigned int num, const void *elements, const size_t *sizes, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of buffers elements, each of corresponding size given in sizes. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_ptrs_bytes (unsigned int num, const void *elements[static num], const size_t *sizes, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of buffers elements, with sizes sizes. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_bytes_same_size (unsigned int num, const void *elements, size_t same_size, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of buffers elements, each of the same size size. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_ptrs_bytes_same_size (unsigned int num, const void *elements[static num], size_t same_size, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of pointers to buffers elements, each of the same size size. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_string (unsigned int num, const char *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of strings (continuous) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_ptrs_string (unsigned int num, const char *elements[static num], struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of strings (pointers) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_abs_time (unsigned int num, const struct GNUNET_TIME_Absolute *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of absolute time stamps (continuous) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_ptrs_abs_time (unsigned int num, const struct GNUNET_TIME_Absolute *elements[], struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of absolute time stamps (pointers) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_rel_time (unsigned int num, const struct GNUNET_TIME_Relative *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of relative time stamps (continuous) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_ptrs_rel_time (unsigned int num, const struct GNUNET_TIME_Relative *elements[], struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of relative time stamps (pointers) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_timestamp (unsigned int num, const struct GNUNET_TIME_Timestamp *elements, struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of time stamps (continuous) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_array_ptrs_timestamp (unsigned int num, const struct GNUNET_TIME_Timestamp *elements[], struct GNUNET_PQ_Context *db) |
Generate query parameter for an array of time stamps (pointers) More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *x) |
Generate query parameter for an RSA public key. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *x) |
Generate query parameter for an RSA signature. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_relative_time (const struct GNUNET_TIME_Relative *x) |
Generate query parameter for a relative time value. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_absolute_time (const struct GNUNET_TIME_Absolute *x) |
Generate query parameter for an absolute time value. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_timestamp (const struct GNUNET_TIME_Timestamp *x) |
Generate query parameter for a timestamp. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x) |
Generate query parameter for an absolute time value. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_timestamp_nbo (const struct GNUNET_TIME_TimestampNBO *x) |
Generate query parameter for a timestamp in NBO. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_uint16 (const uint16_t *x) |
Generate query parameter for an uint16_t in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_uint32 (const uint32_t *x) |
Generate query parameter for an uint32_t in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_uint64 (const uint64_t *x) |
Generate query parameter for an uint64_t in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_int64 (const int64_t *x) |
Generate query parameter for an int64_t in host byte order. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_blind_sign_pub (const struct GNUNET_CRYPTO_BlindSignPublicKey *pub) |
Generate query parameter for a blind sign public key. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_blind_sign_priv (const struct GNUNET_CRYPTO_BlindSignPrivateKey *priv) |
Generate query parameter for a blind sign private key of variable size. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_unblinded_sig (const struct GNUNET_CRYPTO_UnblindedSignature *sig) |
Generate query parameter for an unblinded signature of variable size. More... | |
struct GNUNET_PQ_QueryParam | GNUNET_PQ_query_param_blinded_sig (const struct GNUNET_CRYPTO_BlindedSignature *b_sig) |
Generate query parameter for a blinded signature of variable size. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_allow_null (struct GNUNET_PQ_ResultSpec rs, bool *is_null) |
Allow NULL value to be found in the database for the given value. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_variable_size (const char *name, void **dst, size_t *sptr) |
Variable-size result expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size) |
Fixed-size result expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_string (const char *name, char **dst) |
0-terminated string expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_bool (const char *name, bool *dst) |
boolean expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_RsaPublicKey **rsa) |
RSA public key expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_RsaSignature **sig) |
RSA signature expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_absolute_time (const char *name, struct GNUNET_TIME_Absolute *at) |
Absolute time expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_timestamp (const char *name, struct GNUNET_TIME_Timestamp *t) |
Timestamp expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_relative_time (const char *name, struct GNUNET_TIME_Relative *rt) |
Relative time expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_absolute_time_nbo (const char *name, struct GNUNET_TIME_AbsoluteNBO *at) |
Absolute time expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO *tn) |
Timestamp expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_uint16 (const char *name, uint16_t *u16) |
uint16_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_uint32 (const char *name, uint32_t *u32) |
uint32_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_uint64 (const char *name, uint64_t *u64) |
uint64_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_int64 (const char *name, int64_t *i64) |
int64_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_bool (struct GNUNET_PQ_Context *db, const char *name, size_t *num, bool **bools) |
array of bool expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_uint16 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, uint16_t **dst) |
array of uint16_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_uint32 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, uint32_t **dst) |
array of uint32_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_uint64 (struct GNUNET_PQ_Context *db, const char *name, size_t *num, uint64_t **dst) |
array of uint64_t expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_abs_time (struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Absolute **dst) |
array of absolute time expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_rel_time (struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Relative **dst) |
array of relative time expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_timestamp (struct GNUNET_PQ_Context *db, const char *name, size_t *num, struct GNUNET_TIME_Timestamp **dst) |
array of relative time expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_variable_size (struct GNUNET_PQ_Context *db, const char *name, size_t *num, size_t **sizes, void **dst) |
Array of variable-size result expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_fixed_size (struct GNUNET_PQ_Context *db, const char *name, size_t size, size_t *num, void **dst) |
Array of fixed-size result expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_array_string (struct GNUNET_PQ_Context *db, const char *name, size_t *num, char **dst) |
Array of 0-terminated strings expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_blind_sign_pub (const char *name, struct GNUNET_CRYPTO_BlindSignPublicKey **public_key) |
Blind sign public key expected. More... | |
struct GNUNET_PQ_ResultSpec | GNUNET_PQ_result_spec_blind_sign_priv (const char *name, struct GNUNET_CRYPTO_BlindSignPrivateKey **private_key) |
Blind sign private key expected. More... | |
PGresult * | GNUNET_PQ_exec_prepared (struct GNUNET_PQ_Context *db, const char *name, const struct GNUNET_PQ_QueryParam *params) |
Execute a prepared statement. More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_extract_result (PGresult *result, struct GNUNET_PQ_ResultSpec *rs, int row) |
Extract results from a query result according to the given specification. More... | |
void | GNUNET_PQ_cleanup_result (struct GNUNET_PQ_ResultSpec *rs) |
Free all memory that was allocated in rs during GNUNET_PQ_extract_result(). More... | |
enum GNUNET_DB_QueryStatus | GNUNET_PQ_eval_result (struct GNUNET_PQ_Context *db, const char *statement_name, PGresult *result) |
Check the result's error code to see what happened. More... | |
enum GNUNET_DB_QueryStatus | GNUNET_PQ_eval_prepared_non_select (struct GNUNET_PQ_Context *db, const char *statement_name, const struct GNUNET_PQ_QueryParam *params) |
Execute a named prepared statement that is NOT a SELECT statement in connection using the given params. More... | |
enum GNUNET_DB_QueryStatus | GNUNET_PQ_eval_prepared_multi_select (struct GNUNET_PQ_Context *db, const char *statement_name, const struct GNUNET_PQ_QueryParam *params, GNUNET_PQ_PostgresResultHandler rh, void *rh_cls) |
Execute a named prepared statement that is a SELECT statement which may return multiple results in connection using the given params. More... | |
enum GNUNET_DB_QueryStatus | GNUNET_PQ_eval_prepared_singleton_select (struct GNUNET_PQ_Context *db, const char *statement_name, const struct GNUNET_PQ_QueryParam *params, struct GNUNET_PQ_ResultSpec *rs) |
Execute a named prepared statement that is a SELECT statement which must return a single result in connection using the given params. More... | |
struct GNUNET_PQ_PreparedStatement | GNUNET_PQ_make_prepare (const char *name, const char *sql) |
Create a struct GNUNET_PQ_PreparedStatement . More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_prepare_statements (struct GNUNET_PQ_Context *db, const struct GNUNET_PQ_PreparedStatement *ps) |
Request creation of prepared statements ps from Postgres. More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_prepare_once (struct GNUNET_PQ_Context *db, const struct GNUNET_PQ_PreparedStatement *ps) |
Request creation of prepared statements ps from Postgres, but do not automatically re-prepare the statement if we are disconnected from the database. More... | |
struct GNUNET_PQ_ExecuteStatement | GNUNET_PQ_make_execute (const char *sql) |
Create a struct GNUNET_PQ_ExecuteStatement where errors are fatal. More... | |
struct GNUNET_PQ_ExecuteStatement | GNUNET_PQ_make_try_execute (const char *sql) |
Create a struct GNUNET_PQ_ExecuteStatement where errors should be tolerated. More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_exec_statements (struct GNUNET_PQ_Context *db, const struct GNUNET_PQ_ExecuteStatement *es) |
Request execution of an array of statements es from Postgres. More... | |
struct GNUNET_PQ_Context * | GNUNET_PQ_connect (const char *config_str, const char *load_path, const struct GNUNET_PQ_ExecuteStatement *es, const struct GNUNET_PQ_PreparedStatement *ps) |
Create a connection to the Postgres database using config_str for the configuration. More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_exec_sql (struct GNUNET_PQ_Context *db, const char *buf) |
Execute SQL statements from buf against db. More... | |
struct GNUNET_PQ_Context * | GNUNET_PQ_connect2 (const char *config_str, const char *load_path, const char *auto_suffix, const struct GNUNET_PQ_ExecuteStatement *es, const struct GNUNET_PQ_PreparedStatement *ps, enum GNUNET_PQ_Options flags) |
Create a connection to the Postgres database using config_str for the configuration. More... | |
struct GNUNET_PQ_Context * | GNUNET_PQ_connect_with_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *load_path_suffix, const struct GNUNET_PQ_ExecuteStatement *es, const struct GNUNET_PQ_PreparedStatement *ps) |
Connect to a postgres database using the configuration option "CONFIG" in section. More... | |
struct GNUNET_PQ_Context * | GNUNET_PQ_connect_with_cfg2 (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *load_path_suffix, const struct GNUNET_PQ_ExecuteStatement *es, const struct GNUNET_PQ_PreparedStatement *ps, enum GNUNET_PQ_Options flags) |
Connect to a postgres database using the configuration option "CONFIG" in section. More... | |
void | GNUNET_PQ_reconnect_if_down (struct GNUNET_PQ_Context *db) |
Reinitialize the database db if the connection is down. More... | |
void | GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db) |
Reinitialize the database db. More... | |
struct GNUNET_DB_EventHandler * | GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, const struct GNUNET_DB_EventHeaderP *es, struct GNUNET_TIME_Relative timeout, GNUNET_DB_EventCallback cb, void *cb_cls) |
Register callback to be invoked on events of type es. More... | |
void | GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh) |
Stop notifications. More... | |
void | GNUNET_PQ_event_do_poll (struct GNUNET_PQ_Context *db) |
Poll for events right now. More... | |
void | GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db, const struct GNUNET_DB_EventHeaderP *es, const void *extra, size_t extra_size) |
Notify all that listen on es of an event. More... | |
char * | GNUNET_PQ_get_event_notify_channel (const struct GNUNET_DB_EventHeaderP *es) |
Compute the channel that one should notify upon for the given event specification. More... | |
enum GNUNET_GenericReturnValue | GNUNET_PQ_run_sql (struct GNUNET_PQ_Context *db, const char *load_suffix) |
Within the db context, run all the SQL files in the load path where the name starts with the load_suffix and ends with consecutive numbers from "[0000-9999].sql". More... | |
void | GNUNET_PQ_disconnect (struct GNUNET_PQ_Context *db) |
Disconnect from the database, destroying the prepared statements and releasing other associated resources. More... | |
Variables | |
uint32_t | ndim |
uint32_t | has_null |
uint32_t | oid |
uint32_t | dim |
uint32_t | lbound |
struct GNUNET_PQ_ResultSpec | __attribute__ |
helper functions for Postgres DB interactions
Definition in file gnunet_pq_lib.h.
#define GNUNET_PQ_query_param_end |
End of query parameter specification.
Definition at line 134 of file gnunet_pq_lib.h.
#define GNUNET_PQ_query_param_array_auto_from_type | ( | num, | |
elements, | |||
db | |||
) |
Generate array of equal-sized query parameter with size determined by variable type from a pointer to an continuous array.
num | Number of elements in elements |
elements | Continuous array of the query parameter to pass. |
db | Database context, needed for database-depending encoding of elements |
Definition at line 337 of file gnunet_pq_lib.h.
#define GNUNET_PQ_query_param_array_ptrs_auto_from_type | ( | num, | |
elements, | |||
db | |||
) |
Generate array of equal-sized query parameter with size determined by variable type from a pointer to an array of pointers to objects of the same type.
num | Number of elements in elements |
elements | Continuous array of the query parameter to pass. |
db | Database context, needed for database-depending encoding of elements |
Definition at line 371 of file gnunet_pq_lib.h.
#define GNUNET_PQ_query_param_auto_from_type | ( | x | ) | GNUNET_PQ_query_param_fixed_size ((x), sizeof(*(x))) |
Generate fixed-size query parameter with size determined by variable type.
x | pointer to the query parameter to pass. |
Definition at line 417 of file gnunet_pq_lib.h.
#define GNUNET_PQ_result_spec_end |
End of result parameter specification.
Definition at line 759 of file gnunet_pq_lib.h.
#define GNUNET_PQ_result_spec_auto_from_type | ( | name, | |
dst | |||
) | GNUNET_PQ_result_spec_fixed_size (name, (dst), sizeof(*(dst))) |
We expect a fixed-size result, with size determined by the type of * dst
name | name of the field in the table |
dst | point to where to store the result, type fits expected result size |
Definition at line 822 of file gnunet_pq_lib.h.
We expect a fixed-size result, with size determined by the type of * dst
db | Database context, needed for OID lookup for the correct type |
name | name of the field in the table |
num | pointer to where to store the number of elements |
dst | pointer to where to store the results, type fits expected result size |
Definition at line 1143 of file gnunet_pq_lib.h.
#define GNUNET_PQ_PREPARED_STATEMENT_END |
Terminator for prepared statement list.
Definition at line 1366 of file gnunet_pq_lib.h.
#define GNUNET_PQ_EXECUTE_STATEMENT_END |
Terminator for executable statement list.
Definition at line 1438 of file gnunet_pq_lib.h.
typedef int(* GNUNET_PQ_QueryConverter) (void *cls, const void *data, size_t data_len, void *param_values[], int param_lengths[], int param_formats[], unsigned int param_length, void *scratch[], unsigned int scratch_length) |
Function called to convert input argument into SQL parameters.
cls | closure | |
data | pointer to input argument | |
data_len | number of bytes in data (if applicable) | |
[out] | param_values | SQL data to set |
[out] | param_lengths | SQL length data to set |
[out] | param_formats | SQL format data to set |
param_length | number of entries available in the param_values, param_lengths and param_formats arrays | |
[out] | scratch | buffer for dynamic allocations (to be done via GNUNET_malloc() |
scratch_length | number of entries left in scratch |
Definition at line 59 of file gnunet_pq_lib.h.
typedef void(* GNUNET_PQ_QueryConverter_Cleanup) (void *cls) |
Function called to cleanup the closure of SQL parameters converter.
Will be called with GNUNET_PQ_query_params_cleanup
cls | closure |
Definition at line 76 of file gnunet_pq_lib.h.
typedef enum GNUNET_GenericReturnValue(* GNUNET_PQ_ResultConverter) (void *cls, PGresult *result, int row, const char *fname, size_t *dst_size, void *dst) |
Extract data from a Postgres database result at row row.
cls | closure | |
result | where to extract data from | |
int | row to extract data from | |
fname | name (or prefix) of the fields to extract from | |
[in,out] | dst_size | where to store size of result, may be NULL |
[out] | dst | where to store the result |
Definition at line 657 of file gnunet_pq_lib.h.
typedef void(* GNUNET_PQ_ResultCleanup) (void *cls, void *rd) |
Function called to clean up memory allocated by a GNUNET_PQ_ResultConverter.
cls | closure |
rd | result data to clean up |
Definition at line 693 of file gnunet_pq_lib.h.
typedef void(* GNUNET_PQ_PostgresResultHandler) (void *cls, PGresult *result, unsigned int num_results) |
Function to be called with the results of a SELECT statement that has returned num_results results.
cls | closure |
result | the postgres result |
num_result | the number of results in result |
Definition at line 1289 of file gnunet_pq_lib.h.
enum GNUNET_PQ_Options |
Flags to control PQ operation.
Definition at line 1485 of file gnunet_pq_lib.h.
void GNUNET_PQ_cleanup_query_params_closures | ( | const struct GNUNET_PQ_QueryParam * | params | ) |
Must be called to cleanup memory from closures after the query parameters have been used as much as needed.
params | Array of GNUNET_PQ_QueryParam which must terminate with a GNUNET_PQ_query_param_end |
Definition at line 123 of file pq.c.
References GNUNET_PQ_QueryParam::conv_cls, GNUNET_PQ_QueryParam::conv_cls_cleanup, and GNUNET_PQ_QueryParam::num_params.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_null | ( | void | ) |
Generate query parameter to create a NULL value.
Definition at line 71 of file pq_query_helper.c.
References qconv_null(), and res.
Referenced by postgres_plugin_put().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_fixed_size | ( | const void * | ptr, |
size_t | ptr_size | ||
) |
Generate query parameter for a buffer ptr of ptr_size bytes.
ptr | pointer to the query parameter to pass |
ptr_size | number of bytes in ptr |
Definition at line 120 of file pq_query_helper.c.
References qconv_fixed(), res, and GNUNET_PQ_QueryParam::size.
Referenced by GNUNET_PQ_query_param_bool(), GNUNET_PQ_query_param_string(), namecache_postgres_cache_block(), namestore_postgres_store_records(), postgres_plugin_put(), and postgres_plugin_remove_key().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_string | ( | const char * | ptr | ) |
Generate query parameter for a string.
ptr | pointer to the string query parameter to pass |
Definition at line 136 of file pq_query_helper.c.
References GNUNET_PQ_query_param_fixed_size().
Referenced by check_patch_applied(), GNUNET_PQ_get_oid_by_name(), namestore_postgres_clear_editor_hint(), namestore_postgres_edit_records(), namestore_postgres_lookup_records(), and namestore_postgres_store_records().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_bool | ( | bool | b | ) |
Pass a boolean into a query.
b | boolean bit to pass |
Definition at line 144 of file pq_query_helper.c.
References GNUNET_PQ_query_param_fixed_size().
enum GNUNET_GenericReturnValue GNUNET_PQ_get_oid_by_name | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
Oid * | oid | ||
) |
Returns the oid for a given datatype by name.
db | The db-connection | |
name | The name of the datatype | |
[out] | oid | The OID of the datatype. |
Definition at line 461 of file pq_connect.c.
References db, GNUNET_array_grow, GNUNET_assert, GNUNET_DB_STATUS_SUCCESS_ONE_RESULT, GNUNET_new_array, GNUNET_OK, GNUNET_PQ_eval_prepared_singleton_select(), GNUNET_PQ_query_param_end, GNUNET_PQ_query_param_string(), GNUNET_PQ_result_spec_end, GNUNET_PQ_result_spec_uint32(), GNUNET_SYSERR, name, and oid.
Referenced by GNUNET_PQ_query_param_array_abs_time(), GNUNET_PQ_query_param_array_bool(), GNUNET_PQ_query_param_array_bytes(), GNUNET_PQ_query_param_array_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_abs_time(), GNUNET_PQ_query_param_array_ptrs_bytes(), GNUNET_PQ_query_param_array_ptrs_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_rel_time(), GNUNET_PQ_query_param_array_ptrs_string(), GNUNET_PQ_query_param_array_ptrs_timestamp(), GNUNET_PQ_query_param_array_rel_time(), GNUNET_PQ_query_param_array_string(), GNUNET_PQ_query_param_array_timestamp(), GNUNET_PQ_query_param_array_uint16(), GNUNET_PQ_query_param_array_uint32(), GNUNET_PQ_query_param_array_uint64(), GNUNET_PQ_result_spec_array_abs_time(), GNUNET_PQ_result_spec_array_bool(), GNUNET_PQ_result_spec_array_fixed_size(), GNUNET_PQ_result_spec_array_rel_time(), GNUNET_PQ_result_spec_array_string(), GNUNET_PQ_result_spec_array_timestamp(), GNUNET_PQ_result_spec_array_uint16(), GNUNET_PQ_result_spec_array_uint32(), GNUNET_PQ_result_spec_array_uint64(), GNUNET_PQ_result_spec_array_variable_size(), and load_initial_oids().
struct GNUNET_PQ_ArrayHeader_P __attribute__ | ( | (packed) | ) |
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bool | ( | unsigned int | num, |
const bool * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of bool in host byte order.
num | Number of elements in elements |
elements | Continuous array of num boolean elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1029 of file pq_query_helper.c.
References array_of_bool, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint16 | ( | unsigned int | num, |
const uint16_t * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of uint16_t in host byte order.
Note that the (unsigned) elements are not checked to wrap over INT2_MAX
num | Number of elements in elements |
elements | Continuous array of num uint16 elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1051 of file pq_query_helper.c.
References array_of_uint16, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint32 | ( | unsigned int | num, |
const uint32_t * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of uint32_t in host byte order.
Note that the (unsigned) elements are not checked to wrap over INT4_MAX
num | Number of elements in elements |
elements | Continuous Array of num uint32_t elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1073 of file pq_query_helper.c.
References array_of_uint32, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_uint64 | ( | unsigned int | num, |
const uint64_t * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of uint64 in host byte order.
Note that the (unsigned) elements are not checked to wrap over INT8_MAX
num | Number of elements in elements |
elements | Continuous array of num uint64_t elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1095 of file pq_query_helper.c.
References array_of_uint64, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes | ( | unsigned int | num, |
const void * | elements, | ||
const size_t * | sizes, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of buffers elements, each of corresponding size given in sizes.
num | Number of elements in elements |
elements | Continuous array of num buffers, each of corresponding size given in sizes. |
sizes | Pointer to sizes in bytes of each element in elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1117 of file pq_query_helper.c.
References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes | ( | unsigned int | num, |
const void * | elements[static num], | ||
const size_t * | sizes, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of buffers elements, with sizes sizes.
num | Number of elements in elements |
elements | Continuous array of num buffers, each with the same size same_size |
sizes | Sizes in bytes of each element in elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1140 of file pq_query_helper.c.
References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_bytes_same_size | ( | unsigned int | num, |
const void * | elements, | ||
size_t | same_size, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of buffers elements, each of the same size size.
num | Number of elements in elements |
elements | Continuous array of num buffers, each with the same size same_size |
same_size | Size in bytes of each element in elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1163 of file pq_query_helper.c.
References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_bytes_same_size | ( | unsigned int | num, |
const void * | elements[static num], | ||
size_t | same_size, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of pointers to buffers elements, each of the same size size.
num | Number of elements in elements |
elements | Array of num pointers to buffers, each with the same size same_size |
same_size | Size in bytes of each element in elements |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1186 of file pq_query_helper.c.
References array_of_byte, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_string | ( | unsigned int | num, |
const char * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of strings (continuous)
num | Number of elements in elements |
elements | Array of num continuous strings (zero-terminated each) |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1209 of file pq_query_helper.c.
References array_of_string, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_string | ( | unsigned int | num, |
const char * | elements[static num], | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of strings (pointers)
num | Number of elements in elements |
elements | Array of num pointer to strings |
db | Database context, needed for database-depending encoding of elements |
Definition at line 1231 of file pq_query_helper.c.
References array_of_string, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_abs_time | ( | unsigned int | num, |
const struct GNUNET_TIME_Absolute * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of absolute time stamps (continuous)
num | Number of elements in elements |
elements | Array of num absolute timestamps |
Definition at line 1253 of file pq_query_helper.c.
References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_abs_time | ( | unsigned int | num, |
const struct GNUNET_TIME_Absolute * | elements[], | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of absolute time stamps (pointers)
num | Number of elements in elements |
elements | Array of num pointers to absolute timestamps |
Definition at line 1275 of file pq_query_helper.c.
References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_rel_time | ( | unsigned int | num, |
const struct GNUNET_TIME_Relative * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of relative time stamps (continuous)
num | Number of elements in elements |
elements | Array of num relative timestamps |
Definition at line 1297 of file pq_query_helper.c.
References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_rel_time | ( | unsigned int | num, |
const struct GNUNET_TIME_Relative * | elements[], | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of relative time stamps (pointers)
num | Number of elements in elements |
elements | Array of num pointers to relative timestamps |
Definition at line 1319 of file pq_query_helper.c.
References array_of_abs_time, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_timestamp | ( | unsigned int | num, |
const struct GNUNET_TIME_Timestamp * | elements, | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of time stamps (continuous)
num | Number of elements in elements |
elements | Array of num timestamps |
Definition at line 1341 of file pq_query_helper.c.
References array_of_timestamp, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_array_ptrs_timestamp | ( | unsigned int | num, |
const struct GNUNET_TIME_Timestamp * | elements[], | ||
struct GNUNET_PQ_Context * | db | ||
) |
Generate query parameter for an array of time stamps (pointers)
num | Number of elements in elements |
elements | Array of num pointers to relative timestamps |
Definition at line 1363 of file pq_query_helper.c.
References array_of_timestamp, db, GNUNET_assert, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_Context::num, oid, and query_param_array_generic().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_public_key | ( | const struct GNUNET_CRYPTO_RsaPublicKey * | x | ) |
Generate query parameter for an RSA public key.
The database must contain a BLOB type in the respective position.
x | the query parameter to pass. |
Definition at line 425 of file pq_query_helper.c.
References qconv_rsa_public_key(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_rsa_signature | ( | const struct GNUNET_CRYPTO_RsaSignature * | x | ) |
Generate query parameter for an RSA signature.
The database must contain a BLOB type in the respective position.
x | the query parameter to pass |
Definition at line 481 of file pq_query_helper.c.
References qconv_rsa_signature(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_relative_time | ( | const struct GNUNET_TIME_Relative * | x | ) |
Generate query parameter for a relative time value.
The database must store a 64-bit integer.
x | pointer to the query parameter to pass |
Definition at line 539 of file pq_query_helper.c.
References qconv_rel_time(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time | ( | const struct GNUNET_TIME_Absolute * | x | ) |
Generate query parameter for an absolute time value.
The database must store a 64-bit integer.
x | pointer to the query parameter to pass |
Definition at line 598 of file pq_query_helper.c.
References qconv_abs_time(), and res.
Referenced by delete_old_block(), GNUNET_PQ_query_param_timestamp(), namecache_postgres_cache_block(), namecache_postgres_expire_blocks(), postgres_plugin_del(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), and postgres_plugin_put().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp | ( | const struct GNUNET_TIME_Timestamp * | x | ) |
Generate query parameter for a timestamp.
The database must store a 64-bit integer.
x | pointer to the query parameter to pass |
Definition at line 620 of file pq_query_helper.c.
References GNUNET_PQ_query_param_absolute_time().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_absolute_time_nbo | ( | const struct GNUNET_TIME_AbsoluteNBO * | x | ) |
Generate query parameter for an absolute time value.
The database must store a 64-bit integer.
x | pointer to the query parameter to pass |
Definition at line 612 of file pq_query_helper.c.
References GNUNET_PQ_query_param_auto_from_type.
Referenced by GNUNET_PQ_query_param_timestamp_nbo().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_timestamp_nbo | ( | const struct GNUNET_TIME_TimestampNBO * | x | ) |
Generate query parameter for a timestamp in NBO.
The database must store a 64-bit integer.
x | pointer to the query parameter to pass |
Definition at line 627 of file pq_query_helper.c.
References GNUNET_PQ_query_param_absolute_time_nbo().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint16 | ( | const uint16_t * | x | ) |
Generate query parameter for an uint16_t in host byte order.
x | pointer to the query parameter to pass |
Definition at line 198 of file pq_query_helper.c.
References qconv_uint16(), and res.
Referenced by postgres_plugin_get_key().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint32 | ( | const uint32_t * | x | ) |
Generate query parameter for an uint32_t in host byte order.
x | pointer to the query parameter to pass |
Definition at line 255 of file pq_query_helper.c.
References qconv_uint32(), and res.
Referenced by namestore_postgres_store_records(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_key(), postgres_plugin_get_zero_anonymity(), and postgres_plugin_put().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_uint64 | ( | const uint64_t * | x | ) |
Generate query parameter for an uint64_t in host byte order.
x | pointer to the query parameter to pass |
Definition at line 312 of file pq_query_helper.c.
References qconv_uint64(), and res.
Referenced by namestore_postgres_iterate_records(), namestore_postgres_store_records(), postgres_plugin_del(), postgres_plugin_get_key(), postgres_plugin_get_zero_anonymity(), postgres_plugin_put(), process_result(), and repl_proc().
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_int64 | ( | const int64_t * | x | ) |
Generate query parameter for an int64_t in host byte order.
x | pointer to the query parameter to pass |
Definition at line 369 of file pq_query_helper.c.
References qconv_int64(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_pub | ( | const struct GNUNET_CRYPTO_BlindSignPublicKey * | pub | ) |
Generate query parameter for a blind sign public key.
Internally, the various attributes of the public key will be serialized into on variable-size BLOB.
pub | pointer to the query parameter to pass |
Generate query parameter for a blind sign public key.
pub | pointer to the query parameter to pass |
Definition at line 1471 of file pq_query_helper.c.
References pub, qconv_blind_sign_pub(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blind_sign_priv | ( | const struct GNUNET_CRYPTO_BlindSignPrivateKey * | priv | ) |
Generate query parameter for a blind sign private key of variable size.
priv | pointer to the query parameter to pass |
Definition at line 1571 of file pq_query_helper.c.
References qconv_blind_sign_priv(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_unblinded_sig | ( | const struct GNUNET_CRYPTO_UnblindedSignature * | sig | ) |
Generate query parameter for an unblinded signature of variable size.
sig | pointer to the query parameter to pass |
Definition at line 1672 of file pq_query_helper.c.
References qconv_unblinded_sig(), and res.
struct GNUNET_PQ_QueryParam GNUNET_PQ_query_param_blinded_sig | ( | const struct GNUNET_CRYPTO_BlindedSignature * | b_sig | ) |
Generate query parameter for a blinded signature of variable size.
b_sig | pointer to the query parameter to pass |
Definition at line 1773 of file pq_query_helper.c.
References qconv_blinded_sig(), and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_allow_null | ( | struct GNUNET_PQ_ResultSpec | rs, |
bool * | is_null | ||
) |
Allow NULL value to be found in the database for the given value.
rs | result spec entry to modify | |
[out] | is_null | location set to 'true' if the value was indeed NULL, set to 'false' if the value was non-NULL |
Definition at line 35 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::is_null, and GNUNET_PQ_ResultSpec::is_nullable.
Referenced by handle_results().
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_variable_size | ( | const char * | name, |
void ** | dst, | ||
size_t * | sptr | ||
) |
Variable-size result expected.
name | name of the field in the table | |
[out] | dst | where to store the result, allocated |
[out] | sptr | where to store the size of dst |
Definition at line 130 of file pq_result_helper.c.
References clean_varsize_blob(), GNUNET_PQ_ResultSpec::dst, extract_varsize_blob(), name, and res.
Referenced by extract_result_cb(), handle_results(), namecache_postgres_lookup_block(), parse_result_call_iterator(), and process_result().
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_fixed_size | ( | const char * | name, |
void * | dst, | ||
size_t | dst_size | ||
) |
Fixed-size result expected.
name | name of the field in the table | |
[out] | dst | where to store the result |
dst_size | number of bytes in dst |
Definition at line 213 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, extract_fixed_blob(), GNUNET_PQ_ResultSpec::fname, name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_string | ( | const char * | name, |
char ** | dst | ||
) |
0-terminated string expected.
name | name of the field in the table | |
[out] | dst | where to store the result, allocated |
Definition at line 500 of file pq_result_helper.c.
References clean_string(), GNUNET_PQ_ResultSpec::dst, extract_string(), GNUNET_PQ_ResultSpec::fname, name, and res.
Referenced by check_patch_applied(), and parse_result_call_iterator().
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_bool | ( | const char * | name, |
bool * | dst | ||
) |
boolean expected.
name | name of the field in the table | |
[out] | dst | where to store the result |
Definition at line 571 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst, extract_bool(), GNUNET_PQ_ResultSpec::fname, name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_public_key | ( | const char * | name, |
struct GNUNET_CRYPTO_RsaPublicKey ** | rsa | ||
) |
RSA public key expected.
name | name of the field in the table | |
[out] | rsa | where to store the result |
Definition at line 310 of file pq_result_helper.c.
References clean_rsa_public_key(), extract_rsa_public_key(), GNUNET_PQ_ResultSpec::fname, name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature | ( | const char * | name, |
struct GNUNET_CRYPTO_RsaSignature ** | sig | ||
) |
RSA signature expected.
name | name of the field in the table | |
[out] | sig | where to store the result; |
Definition at line 405 of file pq_result_helper.c.
References clean_rsa_signature(), extract_rsa_signature(), GNUNET_PQ_ResultSpec::fname, name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time | ( | const char * | name, |
struct GNUNET_TIME_Absolute * | at | ||
) |
Absolute time expected.
name | name of the field in the table | |
[out] | at | where to store the result |
Definition at line 724 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_abs_time(), name, and res.
Referenced by extract_result_cb(), handle_results(), and process_result().
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp | ( | const char * | name, |
struct GNUNET_TIME_Timestamp * | t | ||
) |
Timestamp expected.
name | name of the field in the table | |
[out] | t | where to store the result |
Definition at line 825 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_timestamp(), name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_relative_time | ( | const char * | name, |
struct GNUNET_TIME_Relative * | rt | ||
) |
Relative time expected.
name | name of the field in the table | |
[out] | rt | where to store the result |
Definition at line 647 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_rel_time(), name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_absolute_time_nbo | ( | const char * | name, |
struct GNUNET_TIME_AbsoluteNBO * | at | ||
) |
Absolute time expected.
name | name of the field in the table | |
[out] | at | where to store the result |
Definition at line 739 of file pq_result_helper.c.
References GNUNET_PQ_result_spec_auto_from_type, name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_timestamp_nbo | ( | const char * | name, |
struct GNUNET_TIME_TimestampNBO * | tn | ||
) |
Timestamp expected.
name | name of the field in the table | |
[out] | tn | where to store the result |
Definition at line 878 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_timestamp_nbo(), name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint16 | ( | const char * | name, |
uint16_t * | u16 | ||
) |
uint16_t expected.
name | name of the field in the table | |
[out] | u16 | where to store the result |
Definition at line 952 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_uint16(), name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint32 | ( | const char * | name, |
uint32_t * | u32 | ||
) |
uint32_t expected.
name | name of the field in the table | |
[out] | u32 | where to store the result |
Definition at line 1026 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_uint32(), name, and res.
Referenced by extract_result_cb(), GNUNET_PQ_get_oid_by_name(), handle_results(), parse_result_call_iterator(), postgres_plugin_del(), and process_result().
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_uint64 | ( | const char * | name, |
uint64_t * | u64 | ||
) |
uint64_t expected.
name | name of the field in the table | |
[out] | u64 | where to store the result |
Definition at line 1110 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_uint64(), name, and res.
Referenced by parse_result_call_iterator(), postgres_plugin_del(), postgres_plugin_estimate_size(), and process_result().
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_int64 | ( | const char * | name, |
int64_t * | i64 | ||
) |
int64_t expected.
name | name of the field in the table | |
[out] | i64 | where to store the result |
Definition at line 1194 of file pq_result_helper.c.
References GNUNET_PQ_ResultSpec::dst_size, extract_int64(), name, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_bool | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
bool ** | bools | ||
) |
array of bool expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array bools. |
[out] | bools | pointer to where to store the result, an array of num bool's. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1529 of file pq_result_helper.c.
References array_cleanup(), array_of_bool, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint16 | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
uint16_t ** | dst | ||
) |
array of uint16_t expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array u16s. |
[out] | dst | pointer to where to store the an array of num uint16_t's. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1559 of file pq_result_helper.c.
References array_cleanup(), array_of_uint16, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint32 | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
uint32_t ** | dst | ||
) |
array of uint32_t expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array u32s. |
[out] | dst | pointer to where to store the array of num uint32_t's. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1589 of file pq_result_helper.c.
References array_cleanup(), array_of_uint32, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_uint64 | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
uint64_t ** | dst | ||
) |
array of uint64_t expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array u64s. |
[out] | dst | pointer to where to store the array of num uint64_t's. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1619 of file pq_result_helper.c.
References array_cleanup(), array_of_uint64, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_abs_time | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
struct GNUNET_TIME_Absolute ** | dst | ||
) |
array of absolute time expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array u64s. |
[out] | dst | pointer to where to store the array of num absolute time. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1647 of file pq_result_helper.c.
References array_cleanup(), array_of_abs_time, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_rel_time | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
struct GNUNET_TIME_Relative ** | dst | ||
) |
array of relative time expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array u64s. |
[out] | dst | pointer to where to store the array of num relate time. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1675 of file pq_result_helper.c.
References array_cleanup(), array_of_rel_time, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_timestamp | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
struct GNUNET_TIME_Timestamp ** | dst | ||
) |
array of relative time expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements in the array u64s. |
[out] | dst | pointer to where to store the array of num timestamps. Allocated by the function, MUST be freed with GNUNET_free. |
Definition at line 1705 of file pq_result_helper.c.
References array_cleanup(), array_of_timestamp, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_variable_size | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
size_t ** | sizes, | ||
void ** | dst | ||
) |
Array of variable-size result expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements |
[out] | sizes | where to store the num size's of byte-buffers in dst |
[out] | dst | where to store the continuous array of num byte-buffers , allocated |
Definition at line 1735 of file pq_result_helper.c.
References array_cleanup(), array_of_byte, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, res, and array_result_cls::sizes.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_fixed_size | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t | size, | ||
size_t * | num, | ||
void ** | dst | ||
) |
Array of fixed-size result expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
size | number of bytes expected in each element of dst | |
[out] | num | where to store the number of elements |
[out] | dst | where to store the results, an continuous array of fixed-size elements |
Definition at line 1767 of file pq_result_helper.c.
References array_cleanup(), array_of_byte, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, res, and size.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_array_string | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
size_t * | num, | ||
char ** | dst | ||
) |
Array of 0-terminated strings expected.
db | Database context, needed for OID lookup for the correct type | |
name | name of the field in the table | |
[out] | num | where to store the number of elements |
[out] | dst | where to store the allocated continuous array of num 0-terminated strings |
Definition at line 1799 of file pq_result_helper.c.
References array_cleanup(), array_of_string, GNUNET_PQ_ResultSpec::cls, db, GNUNET_PQ_ResultSpec::dst, extract_array_generic(), GNUNET_PQ_ResultSpec::fname, GNUNET_assert, GNUNET_new, GNUNET_OK, GNUNET_PQ_get_oid_by_name(), info, name, array_result_cls::num, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_pub | ( | const char * | name, |
struct GNUNET_CRYPTO_BlindSignPublicKey ** | public_key | ||
) |
Blind sign public key expected.
name | name of the field in the table | |
[out] | public_key | where to store the denomination signature |
Definition at line 1952 of file pq_result_helper.c.
References clean_blind_sign_pub(), extract_blind_sign_pub(), GNUNET_PQ_ResultSpec::fname, name, pub, and res.
struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_blind_sign_priv | ( | const char * | name, |
struct GNUNET_CRYPTO_BlindSignPrivateKey ** | private_key | ||
) |
Blind sign private key expected.
name | name of the field in the table | |
[out] | private_key | where to store the denomination signature |
Definition at line 2085 of file pq_result_helper.c.
References clean_blind_sign_priv(), extract_blind_sign_priv(), GNUNET_PQ_ResultSpec::fname, name, and res.
PGresult * GNUNET_PQ_exec_prepared | ( | struct GNUNET_PQ_Context * | db, |
const char * | name, | ||
const struct GNUNET_PQ_QueryParam * | params | ||
) |
Execute a prepared statement.
db | database context |
name | name of the prepared statement |
params | parameters to the statement |
Definition at line 33 of file pq.c.
References GNUNET_PQ_QueryParam::conv, GNUNET_PQ_QueryParam::conv_cls, GNUNET_PQ_QueryParam::data, db, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_log_from, GNUNET_NZL, GNUNET_PQ_reconnect(), name, GNUNET_PQ_QueryParam::num_params, res, ret, GNUNET_PQ_QueryParam::size, and status.
Referenced by GNUNET_PQ_eval_prepared_multi_select(), GNUNET_PQ_eval_prepared_non_select(), and GNUNET_PQ_eval_prepared_singleton_select().
enum GNUNET_GenericReturnValue GNUNET_PQ_extract_result | ( | PGresult * | result, |
struct GNUNET_PQ_ResultSpec * | rs, | ||
int | row | ||
) |
Extract results from a query result according to the given specification.
result | result to process | |
[in,out] | rs | result specification to extract for |
row | row from the result to extract |
Definition at line 149 of file pq.c.
References GNUNET_PQ_ResultSpec::cleaner, cleanup(), GNUNET_PQ_ResultSpec::cls, GNUNET_PQ_ResultSpec::conv, GNUNET_PQ_ResultSpec::dst, GNUNET_PQ_ResultSpec::dst_size, GNUNET_PQ_ResultSpec::fname, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_PQ_ResultSpec::is_null, GNUNET_PQ_ResultSpec::is_nullable, result, GNUNET_PQ_ResultSpec::result_size, and ret.
Referenced by extract_result_cb(), GNUNET_PQ_eval_prepared_singleton_select(), handle_results(), parse_result_call_iterator(), process_keys(), and process_result().
void GNUNET_PQ_cleanup_result | ( | struct GNUNET_PQ_ResultSpec * | rs | ) |
Free all memory that was allocated in rs during GNUNET_PQ_extract_result().
rs | reult specification to clean up |
Definition at line 139 of file pq.c.
References GNUNET_PQ_ResultSpec::cleaner, and GNUNET_PQ_ResultSpec::conv.
Referenced by check_patch_applied(), extract_result_cb(), handle_results(), namecache_postgres_lookup_block(), parse_result_call_iterator(), postgres_plugin_del(), process_keys(), and process_result().
enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_result | ( | struct GNUNET_PQ_Context * | db, |
const char * | statement_name, | ||
PGresult * | result | ||
) |
Check the result's error code to see what happened.
Also logs errors.
db | database to execute the statement in |
statement_name | name of the statement that created result |
result | result to check |
enum GNUNET_DB_QueryStatus
. Never returns positive values as this function does not look at the result set. Definition at line 46 of file pq_eval.c.
References db, GNUNET_break, GNUNET_DB_STATUS_HARD_ERROR, GNUNET_DB_STATUS_SOFT_ERROR, GNUNET_DB_STATUS_SUCCESS_NO_RESULTS, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log_from, GNUNET_PQ_reconnect(), PQ_DIAG_SQLSTATE_DEADLOCK, PQ_DIAG_SQLSTATE_SERIALIZATION_FAILURE, PQ_DIAG_SQLSTATE_UNIQUE_VIOLATION, result, and status.
Referenced by GNUNET_PQ_eval_prepared_multi_select(), GNUNET_PQ_eval_prepared_non_select(), and GNUNET_PQ_eval_prepared_singleton_select().
enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_non_select | ( | struct GNUNET_PQ_Context * | db, |
const char * | statement_name, | ||
const struct GNUNET_PQ_QueryParam * | params | ||
) |
Execute a named prepared statement that is NOT a SELECT statement in connection using the given params.
Returns the resulting session state.
db | database to execute the statement with |
statement_name | name of the statement |
params | parameters to give to the statement (GNUNET_PQ_query_param_end-terminated) |
enum GNUNET_DB_QueryStatus
. If the statement was a DELETE or UPDATE statement, the number of affected rows is returned; if the statement was an INSERT statement, and no row was added due to a UNIQUE violation, we return zero; if INSERT was successful, we return one. Definition at line 135 of file pq_eval.c.
References db, GNUNET_DB_STATUS_SOFT_ERROR, GNUNET_DB_STATUS_SUCCESS_NO_RESULTS, GNUNET_PQ_eval_result(), GNUNET_PQ_exec_prepared(), and result.
Referenced by delete_old_block(), namecache_postgres_cache_block(), namecache_postgres_expire_blocks(), namestore_postgres_clear_editor_hint(), namestore_postgres_store_records(), postgres_plugin_del(), postgres_plugin_put(), postgres_plugin_remove_key(), process_result(), and repl_proc().
enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_multi_select | ( | struct GNUNET_PQ_Context * | db, |
const char * | statement_name, | ||
const struct GNUNET_PQ_QueryParam * | params, | ||
GNUNET_PQ_PostgresResultHandler | rh, | ||
void * | rh_cls | ||
) |
Execute a named prepared statement that is a SELECT statement which may return multiple results in connection using the given params.
Call rh with the results. Returns the query status including the number of results given to rh (possibly zero). rh will not have been called if the return value is negative.
db | database to execute the statement with |
statement_name | name of the statement |
params | parameters to give to the statement (GNUNET_PQ_query_param_end-terminated) |
rh | function to call with the result set, NULL to ignore |
rh_cls | closure to pass to rh |
enum GNUNET_DB_QueryStatus
. Definition at line 165 of file pq_eval.c.
References db, GNUNET_DB_STATUS_SOFT_ERROR, GNUNET_PQ_eval_result(), GNUNET_PQ_exec_prepared(), result, and ret.
Referenced by namestore_postgres_edit_records(), namestore_postgres_iterate_records(), namestore_postgres_lookup_records(), namestore_postgres_zone_to_name(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), postgres_plugin_get_key(), postgres_plugin_get_keys(), postgres_plugin_get_replication(), and postgres_plugin_get_zero_anonymity().
enum GNUNET_DB_QueryStatus GNUNET_PQ_eval_prepared_singleton_select | ( | struct GNUNET_PQ_Context * | db, |
const char * | statement_name, | ||
const struct GNUNET_PQ_QueryParam * | params, | ||
struct GNUNET_PQ_ResultSpec * | rs | ||
) |
Execute a named prepared statement that is a SELECT statement which must return a single result in connection using the given params.
Stores the result (if any) in rs, which the caller must then clean up using GNUNET_PQ_cleanup_result() if the return value was GNUNET_DB_STATUS_SUCCESS_ONE_RESULT. Returns the resulting session status.
db | database to execute the statement with | |
statement_name | name of the statement | |
params | parameters to give to the statement (GNUNET_PQ_query_param_end-terminated) | |
[in,out] | rs | result specification to use for storing the result of the query |
enum GNUNET_DB_QueryStatus
. Definition at line 199 of file pq_eval.c.
References db, GNUNET_break, GNUNET_DB_STATUS_HARD_ERROR, GNUNET_DB_STATUS_SOFT_ERROR, GNUNET_DB_STATUS_SUCCESS_NO_RESULTS, GNUNET_DB_STATUS_SUCCESS_ONE_RESULT, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_OK, GNUNET_PQ_eval_result(), GNUNET_PQ_exec_prepared(), GNUNET_PQ_extract_result(), and result.
Referenced by check_patch_applied(), GNUNET_PQ_get_oid_by_name(), namecache_postgres_lookup_block(), postgres_plugin_del(), and postgres_plugin_estimate_size().
struct GNUNET_PQ_PreparedStatement GNUNET_PQ_make_prepare | ( | const char * | name, |
const char * | sql | ||
) |
Create a struct GNUNET_PQ_PreparedStatement
.
name | name of the statement |
sql | actual SQL statement |
Definition at line 30 of file pq_prepare.c.
References name, ps, and GNUNET_PQ_PreparedStatement::sql.
Referenced by database_prepare(), database_setup(), and init_connection().
enum GNUNET_GenericReturnValue GNUNET_PQ_prepare_statements | ( | struct GNUNET_PQ_Context * | db, |
const struct GNUNET_PQ_PreparedStatement * | ps | ||
) |
Request creation of prepared statements ps from Postgres.
db | database to prepare the statements for |
ps | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared statements. |
Definition at line 88 of file pq_prepare.c.
References db, GNUNET_free, GNUNET_new_array, GNUNET_PQ_prepare_once(), name, and ps.
Referenced by database_prepare(), and GNUNET_PQ_reconnect().
enum GNUNET_GenericReturnValue GNUNET_PQ_prepare_once | ( | struct GNUNET_PQ_Context * | db, |
const struct GNUNET_PQ_PreparedStatement * | ps | ||
) |
Request creation of prepared statements ps from Postgres, but do not automatically re-prepare the statement if we are disconnected from the database.
db | database to prepare the statements for |
ps | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared statements. |
Definition at line 43 of file pq_prepare.c.
References db, GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log_from, GNUNET_OK, GNUNET_SYSERR, name, ps, ret, and GNUNET_PQ_PreparedStatement::sql.
Referenced by GNUNET_PQ_prepare_statements().
struct GNUNET_PQ_ExecuteStatement GNUNET_PQ_make_execute | ( | const char * | sql | ) |
Create a struct GNUNET_PQ_ExecuteStatement
where errors are fatal.
sql | actual SQL statement |
Definition at line 30 of file pq_exec.c.
References GNUNET_NO, and GNUNET_PQ_ExecuteStatement::sql.
Referenced by postgres_plugin_drop().
struct GNUNET_PQ_ExecuteStatement GNUNET_PQ_make_try_execute | ( | const char * | sql | ) |
Create a struct GNUNET_PQ_ExecuteStatement
where errors should be tolerated.
sql | actual SQL statement |
Definition at line 42 of file pq_exec.c.
References GNUNET_YES, and GNUNET_PQ_ExecuteStatement::sql.
Referenced by database_connect(), namestore_postgres_begin_tx(), namestore_postgres_commit_tx(), and namestore_postgres_rollback_tx().
enum GNUNET_GenericReturnValue GNUNET_PQ_exec_statements | ( | struct GNUNET_PQ_Context * | db, |
const struct GNUNET_PQ_ExecuteStatement * | es | ||
) |
Request execution of an array of statements es from Postgres.
db | database to execute the statements in |
es | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of prepared statements. |
Definition at line 54 of file pq_exec.c.
References db, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_from, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_PQ_ExecuteStatement::ignore_errors, result, and GNUNET_PQ_ExecuteStatement::sql.
Referenced by GNUNET_PQ_reconnect(), namestore_postgres_begin_tx(), namestore_postgres_commit_tx(), namestore_postgres_rollback_tx(), and postgres_plugin_drop().
struct GNUNET_PQ_Context * GNUNET_PQ_connect | ( | const char * | config_str, |
const char * | load_path, | ||
const struct GNUNET_PQ_ExecuteStatement * | es, | ||
const struct GNUNET_PQ_PreparedStatement * | ps | ||
) |
Create a connection to the Postgres database using config_str for the configuration.
Initialize logging via GNUnet's log routines and disable Postgres's logger. Also ensures that the statements in load_path and es are executed whenever we (re)connect to the database, and that the prepared statements in ps are "ready". If statements in es fail that were created with GNUNET_PQ_make_execute(), then the entire operation fails.
In load_path, a list of "$XXXX.sql" files is expected where $XXXX must be a sequence of contiguous integer values starting at 0000. These files are then loaded in sequence using "psql $config_str" before running statements from es. The directory is inspected again on reconnect.
config_str | configuration to use |
load_path | path to directory with SQL transactions to run, can be NULL |
es | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of statements to execute upon EACH connection, can be NULL |
ps | array of prepared statements to prepare, can be NULL |
Definition at line 243 of file pq_connect.c.
References GNUNET_PQ_Context::config_str, GNUNET_PQ_Context::es, GNUNET_PQ_connect2(), GNUNET_PQ_FLAG_NONE, GNUNET_PQ_Context::load_path, and ps.
enum GNUNET_GenericReturnValue GNUNET_PQ_exec_sql | ( | struct GNUNET_PQ_Context * | db, |
const char * | buf | ||
) |
Execute SQL statements from buf against db.
The given filename infix in buf is prefixed with the "load_path" and ".sql" is appended to construct the full filename.
db | database context to use |
buf | filename infix (!) with the SQL code to run |
Definition at line 318 of file pq_connect.c.
References db, GNUNET_asprintf(), GNUNET_DISK_file_test_read(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_NO, GNUNET_OK, GNUNET_OS_INHERIT_STD_NONE, GNUNET_OS_process_destroy(), GNUNET_OS_PROCESS_EXITED, GNUNET_OS_process_kill(), GNUNET_OS_process_wait_status(), GNUNET_OS_start_process(), GNUNET_PQ_FLAG_CHECK_CURRENT, GNUNET_SYSERR, GNUNET_YES, ret, and type.
Referenced by GNUNET_PQ_reconnect(), GNUNET_PQ_run_sql(), libgnunet_plugin_datacache_postgres_done(), and namestore_postgres_drop_tables().
struct GNUNET_PQ_Context * GNUNET_PQ_connect2 | ( | const char * | config_str, |
const char * | load_path, | ||
const char * | auto_suffix, | ||
const struct GNUNET_PQ_ExecuteStatement * | es, | ||
const struct GNUNET_PQ_PreparedStatement * | ps, | ||
enum GNUNET_PQ_Options | flags | ||
) |
Create a connection to the Postgres database using config_str for the configuration.
Initialize logging via GNUnet's log routines and disable Postgres's logger. Also ensures that the statements in load_path and es are executed whenever we (re)connect to the database, and that the prepared statements in ps are "ready". If statements in es fail that were created with GNUNET_PQ_make_execute(), then the entire operation fails.
In load_path, a list of "$XXXX.sql" files is expected where $XXXX must be a sequence of contiguous integer values starting at 0000. These files are then loaded in sequence using "psql $config_str" before running statements from es. The directory is inspected again on reconnect.
config_str | configuration to use |
load_path | path to directory with SQL transactions to run, can be NULL |
auto_suffix | infix of SQL series to run on every reconnect; runs multiple (!) files, of the form auto_suffix-XXXX where XXXX is from 0 to 9999 (consecutive). |
es | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of statements to execute upon EACH connection, can be NULL |
ps | array of prepared statements to prepare, can be NULL |
flags | connection flags |
Definition at line 260 of file pq_connect.c.
References GNUNET_PQ_Context::auto_suffix, GNUNET_PQ_Context::config_str, db, GNUNET_PQ_Context::es, GNUNET_PQ_Context::flags, GNUNET_CONTAINER_multishortmap_create(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_free, GNUNET_new, GNUNET_new_array, GNUNET_PQ_reconnect(), GNUNET_strdup, GNUNET_YES, GNUNET_PQ_Context::load_path, name, and ps.
Referenced by GNUNET_PQ_connect(), and GNUNET_PQ_connect_with_cfg2().
struct GNUNET_PQ_Context * GNUNET_PQ_connect_with_cfg | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const char * | section, | ||
const char * | load_path_suffix, | ||
const struct GNUNET_PQ_ExecuteStatement * | es, | ||
const struct GNUNET_PQ_PreparedStatement * | ps | ||
) |
Connect to a postgres database using the configuration option "CONFIG" in section.
Also ensures that the statements in es are executed whenever we (re)connect to the database, and that the prepared statements in ps are "ready".
The caller does not have to ensure that es and ps remain allocated and initialized in memory until GNUNET_PQ_disconnect() is called, as a copy will be made.
cfg | configuration |
section | configuration section to use to get Postgres configuration options |
load_path_suffix | suffix to append to the SQL_DIR in the configuration |
es | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of statements to execute upon EACH connection, can be NULL |
ps | array of prepared statements to prepare, can be NULL |
Definition at line 700 of file pq_connect.c.
References cfg, GNUNET_PQ_Context::es, GNUNET_PQ_connect_with_cfg2(), GNUNET_PQ_FLAG_NONE, and ps.
Referenced by database_connect(), database_setup(), init_connection(), namestore_postgres_create_tables(), and namestore_postgres_drop_tables().
struct GNUNET_PQ_Context * GNUNET_PQ_connect_with_cfg2 | ( | const struct GNUNET_CONFIGURATION_Handle * | cfg, |
const char * | section, | ||
const char * | load_path_suffix, | ||
const struct GNUNET_PQ_ExecuteStatement * | es, | ||
const struct GNUNET_PQ_PreparedStatement * | ps, | ||
enum GNUNET_PQ_Options | flags | ||
) |
Connect to a postgres database using the configuration option "CONFIG" in section.
Also ensures that the statements in es are executed whenever we (re)connect to the database, and that the prepared statements in ps are "ready".
The caller does not have to ensure that es and ps remain allocated and initialized in memory until GNUNET_PQ_disconnect() is called, as a copy will be made.
cfg | configuration |
section | configuration section to use to get Postgres configuration options |
load_path_suffix | suffix to append to the SQL_DIR in the configuration |
es | GNUNET_PQ_PREPARED_STATEMENT_END-terminated array of statements to execute upon EACH connection, can be NULL |
ps | array of prepared statements to prepare, can be NULL |
flags | connection flags |
Definition at line 716 of file pq_connect.c.
References cfg, db, GNUNET_PQ_Context::es, GNUNET_PQ_Context::flags, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log_config_missing(), GNUNET_OK, GNUNET_PQ_connect2(), GNUNET_PQ_Context::load_path, and ps.
Referenced by GNUNET_PQ_connect_with_cfg().
void GNUNET_PQ_reconnect_if_down | ( | struct GNUNET_PQ_Context * | db | ) |
Reinitialize the database db if the connection is down.
db | database connection to reinitialize |
Definition at line 449 of file pq_connect.c.
References db, and GNUNET_PQ_reconnect().
void GNUNET_PQ_reconnect | ( | struct GNUNET_PQ_Context * | db | ) |
Reinitialize the database db.
db | database connection to reinitialize |
Definition at line 562 of file pq_connect.c.
References db, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_log_from, GNUNET_NO, GNUNET_OK, GNUNET_PQ_event_reconnect_(), GNUNET_PQ_exec_sql(), GNUNET_PQ_exec_statements(), GNUNET_PQ_FLAG_CHECK_CURRENT, GNUNET_PQ_FLAG_DROP, GNUNET_PQ_prepare_statements(), GNUNET_PQ_run_sql(), GNUNET_SYSERR, load_initial_oids(), pq_notice_processor_cb(), pq_notice_receiver_cb(), prepare_check_patch(), prepare_get_oid_by_name(), res, reset_connection(), and ret.
Referenced by do_scheduler_notify(), GNUNET_PQ_connect2(), GNUNET_PQ_eval_result(), GNUNET_PQ_event_do_poll(), GNUNET_PQ_exec_prepared(), and GNUNET_PQ_reconnect_if_down().
struct GNUNET_DB_EventHandler * GNUNET_PQ_event_listen | ( | struct GNUNET_PQ_Context * | db, |
const struct GNUNET_DB_EventHeaderP * | es, | ||
struct GNUNET_TIME_Relative | timeout, | ||
GNUNET_DB_EventCallback | cb, | ||
void * | cb_cls | ||
) |
Register callback to be invoked on events of type es.
Unlike many other calls, this function is thread-safe and may be called from threads that are different from the one that setup db. However, the cb will always be called from the thread that runs GNUNET_PQ_event_do_poll() or the GNUnet scheduler.
db | database context to use |
es | specification of the event to listen for |
timeout | when to trigger cb based on timeout |
cb | function to call when the event happens, possibly multiple times (until GNUNET_PQ_event_listen_cancel() is invoked), including on timeout |
cb_cls | closure for cb |
Definition at line 445 of file pq_event.c.
References GNUNET_DB_EventHandler::cb, GNUNET_DB_EventHandler::cb_cls, db, GNUNET_DB_EventHandler::db, es_to_sh(), event_timeout(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), manage_subscribe(), scheduler_fd_cb(), GNUNET_DB_EventHandler::sh, timeout, and GNUNET_DB_EventHandler::timeout_task.
void GNUNET_PQ_event_listen_cancel | ( | struct GNUNET_DB_EventHandler * | eh | ) |
Stop notifications.
Unlike many other calls, this function is thread-safe and may be called from threads that are different from the one that setup db. However, the cb will always be called from the thread that runs GNUNET_PQ_event_do_poll() or the GNUnet scheduler.
eh | handle to unregister. |
Definition at line 487 of file pq_event.c.
References db, GNUNET_DB_EventHandler::db, GNUNET_assert, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_cancel(), manage_subscribe(), GNUNET_DB_EventHandler::sh, and GNUNET_DB_EventHandler::timeout_task.
void GNUNET_PQ_event_do_poll | ( | struct GNUNET_PQ_Context * | db | ) |
Poll for events right now.
Useful if we may have triggered an event for ourselves. Not needed when using GNUNET_PQ_event_notify(), but useful when stored procedures may have triggered events. Does nothing if there are no events.
[in,out] | db | database to check for events |
Definition at line 189 of file pq_event.c.
References channel_to_sh(), ctx, db, do_notify(), GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_PQ_reconnect(), GNUNET_STRINGS_string_to_data_alloc(), and sh.
Referenced by do_scheduler_notify(), and GNUNET_PQ_event_notify().
void GNUNET_PQ_event_notify | ( | struct GNUNET_PQ_Context * | db, |
const struct GNUNET_DB_EventHeaderP * | es, | ||
const void * | extra, | ||
size_t | extra_size | ||
) |
Notify all that listen on es of an event.
Unlike many other calls, this function is thread-safe and may be called from threads that are different from the one that setup db. However, the cb will always be called from the thread that runs GNUNET_PQ_event_do_poll() or the GNUnet scheduler.
db | database context to use |
es | specification of the event to generate |
extra | additional event data provided |
extra_size | number of bytes in extra |
Definition at line 537 of file pq_event.c.
References db, end, GNUNET_PQ_Context::es, es_to_channel(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_log_from, GNUNET_PQ_event_do_poll(), GNUNET_STRINGS_data_to_string(), and result.
char * GNUNET_PQ_get_event_notify_channel | ( | const struct GNUNET_DB_EventHeaderP * | es | ) |
Compute the channel that one should notify upon for the given event specification.
es | event specification |
Definition at line 522 of file pq_event.c.
References end, GNUNET_PQ_Context::es, es_to_channel(), GNUNET_assert, and GNUNET_strdup.
enum GNUNET_GenericReturnValue GNUNET_PQ_run_sql | ( | struct GNUNET_PQ_Context * | db, |
const char * | load_suffix | ||
) |
Within the db context, run all the SQL files in the load path where the name starts with the load_suffix and ends with consecutive numbers from "[0000-9999].sql".
db | database context to use |
load_suffix | suffix to append to the load path to find the XXXX.sql files, usually "subsystem-". |
Definition at line 400 of file pq_connect.c.
References check_patch_applied(), db, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_PQ_exec_sql(), GNUNET_PQ_FLAG_CHECK_CURRENT, GNUNET_snprintf(), GNUNET_SYSERR, and ret.
Referenced by GNUNET_PQ_reconnect().
void GNUNET_PQ_disconnect | ( | struct GNUNET_PQ_Context * | db | ) |
Disconnect from the database, destroying the prepared statements and releasing other associated resources.
db | database handle to disconnect (will be free'd) |
Definition at line 765 of file pq_connect.c.
References db, GNUNET_assert, GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_size(), and GNUNET_free.
Referenced by database_shutdown(), libgnunet_plugin_datacache_postgres_done(), libgnunet_plugin_datastore_postgres_done(), namestore_postgres_create_tables(), and namestore_postgres_drop_tables().
uint32_t ndim |
Definition at line 0 of file gnunet_pq_lib.h.
Referenced by extract_array_generic().
uint32_t has_null |
Definition at line 1 of file gnunet_pq_lib.h.
uint32_t oid |
Definition at line 2 of file gnunet_pq_lib.h.
Referenced by GNUNET_PQ_get_oid_by_name(), GNUNET_PQ_query_param_array_abs_time(), GNUNET_PQ_query_param_array_bool(), GNUNET_PQ_query_param_array_bytes(), GNUNET_PQ_query_param_array_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_abs_time(), GNUNET_PQ_query_param_array_ptrs_bytes(), GNUNET_PQ_query_param_array_ptrs_bytes_same_size(), GNUNET_PQ_query_param_array_ptrs_rel_time(), GNUNET_PQ_query_param_array_ptrs_string(), GNUNET_PQ_query_param_array_ptrs_timestamp(), GNUNET_PQ_query_param_array_rel_time(), GNUNET_PQ_query_param_array_string(), GNUNET_PQ_query_param_array_timestamp(), GNUNET_PQ_query_param_array_uint16(), GNUNET_PQ_query_param_array_uint32(), GNUNET_PQ_query_param_array_uint64(), load_initial_oids(), postgres_plugin_del(), and query_param_array_generic().
uint32_t dim |
Definition at line 3 of file gnunet_pq_lib.h.
Referenced by cores_send_disconnect_info(), and handle_disconnect().
uint32_t lbound |
Definition at line 4 of file gnunet_pq_lib.h.
struct GNUNET_PQ_ResultSpec __attribute__ |