40 "Running prepared statement `%s' on %p\n",
45 for (
unsigned int i = 0; 0 != params[i].
num_params; i++)
46 len += params[i].num_params;
65 for (
unsigned int i = 0; 0 != params[i].
num_params; i++)
80 for (off = 0; off < soff; off++)
90 "Executing prepared SQL statement `%s'\n",
92 res = PQexecPrepared (
db->conn,
95 (
const char **) param_values,
101 "Execution of prepared SQL statement `%s' finished (%s)\n",
103 PQresStatus (PQresultStatus (
res)));
104 if ( (PGRES_COMMAND_OK != PQresultStatus (
res)) &&
105 (CONNECTION_OK != (
status = PQstatus (
db->conn))) )
109 "Database disconnected on SQL statement `%s' (reconnecting)\n",
115 for (off = 0; off < soff; off++)
126 for (
unsigned int i = 0; 0 != params[i].
num_params; i++)
141 for (
unsigned int i = 0; NULL != rs[i].
conv; i++)
142 if (NULL != rs[i].cleaner)
157 for (i = 0; NULL != rs[i].
conv; i++)
184 "NULL field encountered for `%s' where non-NULL was required\n",
189 "Failed to extract field `%s'\n",
199 for (
unsigned int j = 0; j < i; j++)
static int ret
Final status code.
static void cleanup(void *cls)
Disconnect and shutdown.
static char * name
Name (label) of the records to list.
static char * res
Currently read line or NULL on EOF.
static int status
The program status; 0 for success.
static int result
Global testing status.
static struct GNUNET_FS_DirectoryBuilder * db
helper functions for Postgres DB interactions
void GNUNET_PQ_reconnect(struct GNUNET_PQ_Context *db)
Reinitialize the database db.
#define GNUNET_log(kind,...)
#define GNUNET_log_from(kind, comp,...)
#define GNUNET_NZL(l)
Macro used to avoid using 0 for the length of a variable-size array (Non-Zero-Length).
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.
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 n...
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.
GNUNET_PQ_QueryConverter_Cleanup conv_cls_cleanup
Function to cleanup the closure conv_cls, may be NULL.
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...