GNUnet 0.22.2
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
111
116 struct
117 {
118 /* Allocated number of elements array the table */
119 unsigned int cap;
120
121 /* Number of entries in the table */
122 unsigned int num;
123
124 /* The table of (name, oid) pairs.
125 * Note that the names are 'const char *' and the pointers should be point
126 * to the same string throughout the lifetime of the program.*/
127 struct name2oid
128 {
129 const char *name;
130 Oid oid;
132
134};
135
136
142{
147 array_of_byte, /* buffers of (char *), (void *), ... */
148 array_of_string, /* NULL-terminated (char *) */
152 array_of_MAX, /* must be last */
153};
154
161{
162 uint32_t ndim; /* number of dimensions. we only support ndim = 1 */
163 uint32_t has_null;
164 uint32_t oid;
165 uint32_t dim; /* size of the array */
166 uint32_t lbound; /* index value of first element in the db (default: 1). */
167} __attribute__((packed));
168
169
177void
179 int fd);
180
181
182#endif
static struct GNUNET_FS_DirectoryBuilder * db
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:142
@ array_of_byte
Definition: pq.h:147
@ array_of_uint32
Definition: pq.h:145
@ array_of_MAX
Definition: pq.h:152
@ array_of_string
Definition: pq.h:148
@ array_of_rel_time
Definition: pq.h:150
@ array_of_uint16
Definition: pq.h:144
@ array_of_uint64
Definition: pq.h:146
@ array_of_abs_time
Definition: pq.h:149
@ array_of_timestamp
Definition: pq.h:151
@ array_of_bool
Definition: pq.h:143
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
bool prepared_check_patch
Did we prepare the gnunet_pq_check_patch statement?
Definition: pq.h:105
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
bool prepared_get_oid_by_name
Did we prepare the gnunet_pq_get_oid_by_name statement?
Definition: pq.h:110
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:122
struct GNUNET_CONTAINER_MultiShortmap * channel_map
Map managing event subscriptions.
Definition: pq.h:80
unsigned int cap
Definition: pq.h:119
const char * name
Definition: pq.h:129
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:161
uint32_t lbound
Definition: pq.h:166
uint32_t has_null
Definition: pq.h:163
uint32_t oid
Definition: pq.h:164
uint32_t ndim
Definition: pq.h:162
uint32_t dim
Definition: pq.h:165