GNUnet 0.28.0-dev.3-7-g31e20e2e6
 
Loading...
Searching...
No Matches
pq.h File Reference

shared internal data structures of libgnunetpq More...

#include "gnunet_util_lib.h"
#include "gnunet_pq_lib.h"
Include dependency graph for pq.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_PQ_Context
 Handle to Postgres database. More...
 
struct  pq_array_header
 The header for a postgresql array in binary format. More...
 

Enumerations

enum  array_types {
  array_of_bool , array_of_uint16 , array_of_uint32 , array_of_uint64 ,
  array_of_byte , array_of_string , array_of_abs_time , array_of_rel_time ,
  array_of_timestamp , array_of_MAX
}
 Internal types that are supported as array types. More...
 

Functions

struct pq_array_header __attribute__ ((packed))
 
void GNUNET_PQ_reconnect_ (struct GNUNET_PQ_Context *db)
 Reinitialize the database db.
 
void GNUNET_PQ_event_reconnect_ (struct GNUNET_PQ_Context *db, int fd)
 Internal API.
 

Variables

uint32_t ndim
 
uint32_t has_nulls
 
uint32_t oid
 
uint32_t dim
 
uint32_t lbound
 

Detailed Description

shared internal data structures of libgnunetpq

Author
Christian Grothoff

Definition in file pq.h.

Enumeration Type Documentation

◆ array_types

Internal types that are supported as array types.

Enumerator
array_of_bool 
array_of_uint16 
array_of_uint32 
array_of_uint64 
array_of_byte 
array_of_string 
array_of_abs_time 
array_of_rel_time 
array_of_timestamp 
array_of_MAX 

Definition at line 134 of file pq.h.

135{
140 array_of_byte, /* buffers of (char *), (void *), ... */
141 array_of_string, /* NULL-terminated (char *) */
145 array_of_MAX, /* must be last */
146};
@ array_of_byte
Definition pq.h:140
@ array_of_uint32
Definition pq.h:138
@ array_of_MAX
Definition pq.h:145
@ array_of_string
Definition pq.h:141
@ array_of_rel_time
Definition pq.h:143
@ array_of_uint16
Definition pq.h:137
@ array_of_uint64
Definition pq.h:139
@ array_of_abs_time
Definition pq.h:142
@ array_of_timestamp
Definition pq.h:144
@ array_of_bool
Definition pq.h:136

Function Documentation

◆ __attribute__()

struct pq_array_header __attribute__ ( (packed)  )

◆ GNUNET_PQ_reconnect_()

void GNUNET_PQ_reconnect_ ( struct GNUNET_PQ_Context db)

Reinitialize the database db.

Parameters
dbdatabase connection to reinitialize
Deprecated:

Definition at line 552 of file pq_connect.c.

553{
555 -1);
557 db->versioning_ok = GNUNET_SYSERR; /* new connection, new game */
558 db->conn = PQconnectdb (db->config_str);
559 if ( (NULL == db->conn) ||
560 (CONNECTION_OK != PQstatus (db->conn)) )
561 {
563 "pq",
564 "Database connection to '%s' failed: %s\n",
565 db->config_str,
566 (NULL != db->conn)
567 ? PQerrorMessage (db->conn)
568 : "PQconnectdb returned NULL");
570 return;
571 }
572 PQsetNoticeReceiver (db->conn,
574 db);
575 PQsetNoticeProcessor (db->conn,
577 db);
578 if (NULL != db->rc)
579 db->rc (db->rc_cls,
580 db);
581
582 /* Prepare statement for OID lookup by name */
583 if (GNUNET_OK !=
585 return;
586
587 /* Reset the OID-cache and retrieve the OIDs for the supported Array types */
588 db->oids.num = 0;
590 {
592 "Failed to retrieve OID information for array types!\n");
594 return;
595 }
597 PQsocket (db->conn));
598}
static struct GNUNET_FS_DirectoryBuilder * db
#define GNUNET_log(kind,...)
#define GNUNET_log_from(kind, comp,...)
@ GNUNET_OK
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_ERROR
void GNUNET_PQ_event_reconnect_(struct GNUNET_PQ_Context *db, int fd)
Internal API.
Definition pq_event.c:434
static void pq_notice_receiver_cb(void *arg, const PGresult *res)
Function called by libpq whenever it wants to log something.
Definition pq_connect.c:265
static void reset_connection(struct GNUNET_PQ_Context *db)
Close connection to db and mark it as uninitialized.
Definition pq_connect.c:37
static enum GNUNET_GenericReturnValue prepare_get_oid_by_name(struct GNUNET_PQ_Context *db)
Prepare the "gnunet_pq_get_oid_by_name" statement.
Definition pq_connect.c:96
static void pq_notice_processor_cb(void *arg, const char *message)
Function called by libpq whenever it wants to log something.
Definition pq_connect.c:282
static enum GNUNET_GenericReturnValue load_initial_oids(struct GNUNET_PQ_Context *db)
Load the initial set of OIDs for the supported array-datatypes.
Definition pq_connect.c:521

References db, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_from, GNUNET_OK, GNUNET_PQ_event_reconnect_(), GNUNET_SYSERR, load_initial_oids(), pq_notice_processor_cb(), pq_notice_receiver_cb(), prepare_get_oid_by_name(), and reset_connection().

Referenced by do_scheduler_notify(), GNUNET_PQ_eval_result(), GNUNET_PQ_event_do_poll(), GNUNET_PQ_exec_prepared(), GNUNET_PQ_init(), and GNUNET_PQ_reconnect_if_down().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_PQ_event_reconnect_()

void GNUNET_PQ_event_reconnect_ ( struct GNUNET_PQ_Context db,
int  fd 
)

Internal API.

Reconnect should re-register notifications after a disconnect.

Parameters
dbthe DB handle
fdsocket to listen on

Definition at line 434 of file pq_event.c.

436{
438 "Change in PQ event FD to %d\n",
439 fd);
441 fd);
444 db);
445}
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_ERROR_TYPE_DEBUG
static enum GNUNET_GenericReturnValue register_notify(void *cls, const struct GNUNET_ShortHashCode *sh, void *value)
Re-subscribe to notifications after disconnect.
Definition pq_event.c:419
static void scheduler_fd_cb(void *cls, int fd)
Function called when the Postgres FD changes and we need to update the scheduler event loop task.
Definition pq_event.c:335

References db, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, register_notify(), and scheduler_fd_cb().

Referenced by GNUNET_PQ_reconnect_().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ndim

uint32_t ndim

Definition at line 0 of file pq.h.

◆ has_nulls

uint32_t has_nulls

Definition at line 1 of file pq.h.

Referenced by qconv_array().

◆ oid

uint32_t oid

Definition at line 2 of file pq.h.

◆ dim

uint32_t dim

Definition at line 3 of file pq.h.

◆ lbound

uint32_t lbound

Definition at line 4 of file pq.h.