39 "Running prepared statement `%s' on %p\n",
44 for (
unsigned int i = 0; 0 != params[i].
num_params; i++)
45 len += params[i].num_params;
52 void *param_values[
len];
53 int param_lengths[
len];
54 int param_formats[
len];
64 for (
unsigned int i = 0; 0 != params[i].
num_params; i++)
79 for (off = 0; off < soff; off++)
89 "Executing prepared SQL statement `%s'\n",
91 res = PQexecPrepared (
db->conn,
94 (
const char **) param_values,
100 "Execution of prepared SQL statement `%s' finished (%s)\n",
102 PQresStatus (PQresultStatus (
res)));
103 if ( (PGRES_COMMAND_OK != PQresultStatus (
res)) &&
104 (CONNECTION_OK != (
status = PQstatus (
db->conn))) )
108 "Database disconnected on SQL statement `%s' (reconnecting)\n",
114 for (off = 0; off < soff; off++)
124 for (
unsigned int i = 0; NULL != rs[i].
conv; i++)
125 if (NULL != rs[i].cleaner)
140 for (i = 0; NULL != rs[i].
conv; i++)
167 "NULL field encountered for `%s' where non-NULL was required\n",
172 "Failed to extract field `%s'\n",
182 for (
unsigned int j = 0; j < i; j++)
static int ret
Return value of the commandline.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
uint16_t status
See PRISM_STATUS_*-constants.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static int result
Global testing status.
static struct GNUNET_FS_DirectoryBuilder * db
void GNUNET_PQ_reconnect(struct GNUNET_PQ_Context *db)
Reinitialize the database db.
#define GNUNET_log(kind,...)
#define GNUNET_log_from(kind, comp,...)
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
PGresult * GNUNET_PQ_exec_prepared(struct GNUNET_PQ_Context *db, const char *name, const struct GNUNET_PQ_QueryParam *params)
Execute a prepared statement.
void GNUNET_PQ_cleanup_result(struct GNUNET_PQ_ResultSpec *rs)
Free all memory that was allocated in rs during GNUNET_PQ_extract_result().
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.
shared internal data structures of libgnunetpq
Handle to Postgres database.
Description of a DB query parameter.
void * conv_cls
Closure for conv.
const void * data
Data or NULL.
GNUNET_PQ_QueryConverter conv
Function for how to handle this type of entry.
unsigned int num_params
Number of parameters eaten by this operation.
Description of a DB result cell.
const char * fname
Field name of the desired result.
bool * is_null
Points to a location where we should store "true" if the result found is NULL, and otherwise "false".
void * dst
Destination for the data.
bool is_nullable
True if NULL is allowed for a value in the database.
void * cls
Closure for conv and cleaner.
GNUNET_PQ_ResultConverter conv
What is the format of the result?
size_t * result_size
Where to store actual size of the result.
GNUNET_PQ_ResultCleanup cleaner
Function to clean up result data, NULL if cleanup is not necessary.
size_t dst_size
Allowed size for the data, 0 for variable-size (in this case, the type of dst is a void ** and we nee...