forked from pgaudit/set_user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compatibility.h
154 lines (126 loc) · 3.77 KB
/
compatibility.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* -------------------------------------------------------------------------
*
* compatibility.h
*
* Definitions for maintaining compatibility across Postgres versions.
*
* Copyright (c) 2010-2021, PostgreSQL Global Development Group
*
* -------------------------------------------------------------------------
*/
#ifndef SET_USER_COMPAT_H
#define SET_USER_COMPAT_H
#ifndef NO_ASSERT_AUTH_UID_ONCE
#define NO_ASSERT_AUTH_UID_ONCE !USE_ASSERT_CHECKING
#endif
/*
* PostgreSQL version 14+
*
* Introduces ReadOnlyTree boolean
*/
#if PG_VERSION_NUM >= 140000
#define _PU_HOOK \
static void PU_hook(PlannedStmt *pstmt, const char *queryString, bool ReadOnlyTree, \
ProcessUtilityContext context, ParamListInfo params, \
QueryEnvironment *queryEnv, \
DestReceiver *dest, QueryCompletion *qc)
#define _prev_hook \
prev_hook(pstmt, queryString, ReadOnlyTree, context, params, queryEnv, dest, qc)
#define _standard_ProcessUtility \
standard_ProcessUtility(pstmt, queryString, ReadOnlyTree, context, params, queryEnv, dest, qc)
#define getObjectIdentity(address) \
getObjectIdentity(address,false)
#endif /* 14+ */
/*
* PostgreSQL version 13+
*
* Introduces QueryCompletion struct
*/
#if PG_VERSION_NUM >= 130000
#ifndef _PU_HOOK
#define _PU_HOOK \
static void PU_hook(PlannedStmt *pstmt, const char *queryString, \
ProcessUtilityContext context, ParamListInfo params, \
QueryEnvironment *queryEnv, \
DestReceiver *dest, QueryCompletion *qc)
#define _prev_hook \
prev_hook(pstmt, queryString, context, params, queryEnv, dest, qc)
#define _standard_ProcessUtility \
standard_ProcessUtility(pstmt, queryString, context, params, queryEnv, dest, qc)
#endif
#endif /* 13+ */
/*
* PostgreSQL version 12+
*
* - Removes OID column
*/
#if PG_VERSION_NUM >= 120000
#define HEAP_TUPLE_GET_OID
static inline Oid
_heap_tuple_get_oid(HeapTuple roleTup)
{
return ((Form_pg_authid) GETSTRUCT(roleTup))->oid;
}
#endif /* 12+ */
/*
* PostgreSQL version 10+
*
* - Introduces PlannedStmt struct
* - Introduces varlena.h
*/
#if PG_VERSION_NUM >= 100000
#ifndef _PU_HOOK
#define _PU_HOOK \
static void PU_hook(PlannedStmt *pstmt, const char *queryString, \
ProcessUtilityContext context, ParamListInfo params, \
QueryEnvironment *queryEnv, \
DestReceiver *dest, char *completionTag)
#define _prev_hook \
prev_hook(pstmt, queryString, context, params, queryEnv, dest, completionTag)
#define _standard_ProcessUtility \
standard_ProcessUtility(pstmt, queryString, context, params, queryEnv, dest, completionTag)
#endif
#include "utils/varlena.h"
#define parsetree ((Node *) pstmt->utilityStmt)
#endif /* 10+ */
/*
* PostgreSQL version 9.5+
*
* - Introduces two-argument GetUserNameFromId
*/
#if PG_VERSION_NUM >= 90500
#define GETUSERNAMEFROMID(ouserid) GetUserNameFromId(ouserid, false)
#endif
/*
* PostgreSQL version 9.4+
*
* Lowest supported version.
*/
#if PG_VERSION_NUM >= 90400
#ifndef _PU_HOOK
#define _PU_HOOK \
static void PU_hook(Node *parsetree, const char *queryString, \
ProcessUtilityContext context, ParamListInfo params, \
DestReceiver *dest, char *completionTag)
#define _prev_hook \
prev_hook(parsetree, queryString, context, params, dest, completionTag)
#define _standard_ProcessUtility \
standard_ProcessUtility(parsetree, queryString, context, params, dest, completionTag)
#endif
#ifndef GETUSERNAMEFROMID
#define GETUSERNAMEFROMID(ouserid) GetUserNameFromId(ouserid)
#endif
# ifndef HEAP_TUPLE_GET_OID
static inline Oid
_heap_tuple_get_oid(HeapTuple roleTup)
{
return HeapTupleGetOid(roleTup);
}
# endif
#endif
#if !defined(PG_VERSION_NUM) || PG_VERSION_NUM < 90400
#error "This extension only builds with PostgreSQL 9.4 or later"
#endif
/* Use our version-specific static declaration here */
_PU_HOOK;
#endif /* SET_USER_COMPAT_H */