-
Notifications
You must be signed in to change notification settings - Fork 35
/
compat.h
68 lines (60 loc) · 1.62 KB
/
compat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* compat.h
* Definitions for function wrappers compatible between PG versions.
*
* Copyright (c) 2015-2022, Postgres Professional
*
* IDENTIFICATION
* contrib/pg_wait_sampling/compat.h
*/
#ifndef __COMPAT_H__
#define __COMPAT_H__
#include "postgres.h"
#include "access/tupdesc.h"
#include "miscadmin.h"
#include "storage/shm_mq.h"
#include "utils/guc_tables.h"
static inline shm_mq_result
shm_mq_send_compat(shm_mq_handle *mqh, Size nbytes, const void *data,
bool nowait, bool force_flush)
{
#if PG_VERSION_NUM >= 150000
return shm_mq_send(mqh, nbytes, data, nowait, force_flush);
#else
return shm_mq_send(mqh, nbytes, data, nowait);
#endif
}
#if PG_VERSION_NUM < 170000
#define INIT_PG_LOAD_SESSION_LIBS 0x0001
#define INIT_PG_OVERRIDE_ALLOW_CONNS 0x0002
#endif
static inline void
InitPostgresCompat(const char *in_dbname, Oid dboid,
const char *username, Oid useroid,
bits32 flags,
char *out_dbname)
{
#if PG_VERSION_NUM >= 170000
InitPostgres(in_dbname, dboid, username, useroid, flags, out_dbname);
#elif PG_VERSION_NUM >= 150000
InitPostgres(in_dbname, dboid, username, useroid,
flags & INIT_PG_LOAD_SESSION_LIBS,
flags & INIT_PG_OVERRIDE_ALLOW_CONNS, out_dbname);
#else
InitPostgres(in_dbname, dboid, username, useroid, out_dbname,
flags & INIT_PG_OVERRIDE_ALLOW_CONNS);
#endif
}
static inline void
get_guc_variables_compat(struct config_generic ***vars, int *num_vars)
{
Assert(vars != NULL);
Assert(num_vars != NULL);
#if PG_VERSION_NUM >= 160000
*vars = get_guc_variables(num_vars);
#else
*vars = get_guc_variables();
*num_vars = GetNumConfigOptions();
#endif
}
#endif