GNUnet 0.21.0
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
55 unsigned int ps_len;
56
60 unsigned int ps_off;
61
66
70 char *load_path;
71
76
81
86
91
96
101
106 struct
107 {
108 /* Allocated number of elements array the table */
109 unsigned int cap;
110
111 /* Number of entries in the table */
112 unsigned int num;
113
114 /* The table of (name, oid) pairs.
115 * Note that the names are 'const char *' and the pointers should be point
116 * to the same string throughout the lifetime of the program.*/
117 struct name2oid
118 {
119 const char *name;
120 Oid oid;
122
124};
125
126
132{
137 array_of_byte, /* buffers of (char *), (void *), ... */
138 array_of_string, /* NULL-terminated (char *) */
142 array_of_MAX, /* must be last */
143};
144
151{
152 uint32_t ndim; /* number of dimensions. we only support ndim = 1 */
153 uint32_t has_null;
154 uint32_t oid;
155 uint32_t dim; /* size of the array */
156 uint32_t lbound; /* index value of first element in the db (default: 1). */
157} __attribute__((packed));
158
159
167void
169 int fd);
170
171
172#endif
static struct GNUNET_FS_DirectoryBuilder * db
Definition: gnunet-search.c:97
helper functions for Postgres DB interactions
GNUNET_PQ_Options
Flags to control PQ operation.
void GNUNET_PQ_event_reconnect_(struct GNUNET_PQ_Context *db, int fd)
Internal API.
Definition: pq_event.c:412
array_types
Internal types that are supported as array types.
Definition: pq.h:132
@ array_of_byte
Definition: pq.h:137
@ array_of_uint32
Definition: pq.h:135
@ array_of_MAX
Definition: pq.h:142
@ array_of_string
Definition: pq.h:138
@ array_of_rel_time
Definition: pq.h:140
@ array_of_uint16
Definition: pq.h:134
@ array_of_uint64
Definition: pq.h:136
@ array_of_abs_time
Definition: pq.h:139
@ array_of_timestamp
Definition: pq.h:141
@ array_of_bool
Definition: pq.h:133
struct pq_array_header __attribute__((packed))
Internal representation of the hash map.
handle to a socket
Definition: network.c:53
Handle to Postgres database.
Definition: pq.h:36
struct GNUNET_PQ_ExecuteStatement * es
Statements to execute upon connection.
Definition: pq.h:45
enum GNUNET_PQ_Options flags
Flags controlling the connection.
Definition: pq.h:100
struct GNUNET_PQ_Context::@35::name2oid * table
struct GNUNET_NETWORK_Handle * rfd
File descriptor wrapper for event_task.
Definition: pq.h:90
struct GNUNET_PQ_Context::@35 oids
Mapping between array types and Oid's, pre-filled at reconnect.
unsigned int ps_off
Last used offset in the ps array.
Definition: pq.h:60
struct GNUNET_SCHEDULER_Task * event_task
Task responsible for processing events.
Definition: pq.h:85
char * load_path
Path to load SQL files from.
Definition: pq.h:70
unsigned int ps_len
Length of the ps array.
Definition: pq.h:55
struct GNUNET_TIME_Relative resubscribe_backoff
How fast should we resubscribe again?
Definition: pq.h:95
struct GNUNET_PQ_PreparedStatement * ps
Prepared statements.
Definition: pq.h:50
unsigned int num
Definition: pq.h:112
struct GNUNET_CONTAINER_MultiShortmap * channel_map
Map managing event subscriptions.
Definition: pq.h:80
unsigned int cap
Definition: pq.h:109
const char * name
Definition: pq.h:119
char * config_str
Configuration to use to connect to the DB.
Definition: pq.h:65
PGconn * conn
Actual connection.
Definition: pq.h:40
char * auto_suffix
Suffix to append to path to load on startup.
Definition: pq.h:75
Information needed to run a list of SQL statements using GNUNET_PQ_exec_statements().
Information needed to prepare a list of SQL statements using GNUNET_PQ_prepare_statements().
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for relative time used by GNUnet, in microseconds.
the header for a postgresql array in binary format.
Definition: pq.h:151
uint32_t lbound
Definition: pq.h:156
uint32_t has_null
Definition: pq.h:153
uint32_t oid
Definition: pq.h:154
uint32_t ndim
Definition: pq.h:152
uint32_t dim
Definition: pq.h:155