GNUnet 0.28.0-dev.2-27-gc87478450
 
Loading...
Searching...
No Matches
pq.h
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2017, 2019 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
25#ifndef PQ_H
26#define PQ_H
27
28#include "gnunet_util_lib.h"
29#include "gnunet_pq_lib.h"
30
31
36{
40 PGconn *conn;
41
46
51
56
60 char *load_path;
61
66
72
77
82
87
94
99
104
109 struct
110 {
111 /* Allocated number of elements array the table */
112 unsigned int cap;
113
114 /* Number of entries in the table */
115 unsigned int num;
116
117 /* The table of (name, oid) pairs.
118 * Note that the names are 'const char *' and the pointers should be point
119 * to the same string throughout the lifetime of the program.*/
120 struct name2oid
121 {
122 const char *name;
123 Oid oid;
125
127};
128
129
147
154{
155 uint32_t ndim; /* number of dimensions. we only support ndim = 1 */
156 uint32_t has_nulls; /* not zero if array contains NULL elements */
157 uint32_t oid;
158 uint32_t dim; /* size of the array */
159 uint32_t lbound; /* index value of first element in the db (default: 1). */
160} __attribute__((packed));
161
162
169void
171
172
180void
182 int fd);
183
184
185#endif
static struct GNUNET_FS_DirectoryBuilder * db
helper functions for Postgres DB interactions
void(* GNUNET_PQ_ReconnectCallback)(void *cls, struct GNUNET_PQ_Context *pq)
Function called each time we connect or reconnect to the database.
struct GNUNET_PQ_ResultSpec __attribute__
#define GNUNET_PQ_RECONNECT_CALLBACK_CLOSURE
GNUNET_GenericReturnValue
Named constants for return values.
void GNUNET_PQ_event_reconnect_(struct GNUNET_PQ_Context *db, int fd)
Internal API.
Definition pq_event.c:434
array_types
Internal types that are supported as array types.
Definition pq.h:135
@ 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
void GNUNET_PQ_reconnect_(struct GNUNET_PQ_Context *db)
Reinitialize the database db.
Definition pq_connect.c:552
Internal representation of the hash map.
handle to a socket
Definition network.c:53
Handle to Postgres database.
Definition pq.h:36
struct GNUNET_NETWORK_Handle * rfd
File descriptor wrapper for event_task.
Definition pq.h:81
bool prepared_check_patch
Did we prepare the gnunet_pq_check_patch statement?
Definition pq.h:98
GNUNET_PQ_ReconnectCallback rc
Function to call whenever we needed to reconnect conn.
Definition pq.h:45
enum GNUNET_GenericReturnValue versioning_ok
Set to GNUNET_OK if versioning schema is properly setup, GNUNET_NO if it is definitively not setup,...
Definition pq.h:93
struct GNUNET_SCHEDULER_Task * poller_task
Task responsible for polling events directly after having posted an event.
Definition pq.h:71
struct GNUNET_SCHEDULER_Task * event_task
Task responsible for processing events.
Definition pq.h:76
bool prepared_get_oid_by_name
Did we prepare the gnunet_pq_get_oid_by_name statement?
Definition pq.h:103
char * load_path
Path to load SQL files from.
Definition pq.h:60
struct GNUNET_TIME_Relative resubscribe_backoff
How fast should we resubscribe again?
Definition pq.h:86
unsigned int num
Definition pq.h:115
struct GNUNET_CONTAINER_MultiShortmap * channel_map
Map managing event subscriptions.
Definition pq.h:65
unsigned int cap
Definition pq.h:112
struct GNUNET_PQ_Context::@42::name2oid * table
const char * name
Definition pq.h:122
char * config_str
Configuration to use to connect to the DB.
Definition pq.h:55
PGconn * conn
Actual connection.
Definition pq.h:40
struct GNUNET_PQ_Context::@42 oids
Mapping between array types and Oid's, pre-filled at reconnect.
GNUNET_PQ_RECONNECT_CALLBACK_CLOSURE * rc_cls
Closure for rc.
Definition pq.h:50
Entry in list of pending tasks.
Definition scheduler.c:141
Time for relative time used by GNUnet, in microseconds.
The header for a postgresql array in binary format.
Definition pq.h:154
uint32_t lbound
Definition pq.h:159
uint32_t has_nulls
Definition pq.h:156
uint32_t oid
Definition pq.h:157
uint32_t ndim
Definition pq.h:155
uint32_t dim
Definition pq.h:158