-
Notifications
You must be signed in to change notification settings - Fork 14
/
mock.c
327 lines (269 loc) · 6.99 KB
/
mock.c
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
/*-------------------------------------------------------------------------
*
* mock.c
* Mock function calls for filedump
*
* Copyright (c) 2021 VMware, Inc. or its affiliates
* SPDX-License-Identifier: GPL-2.0-or-later
*
*-------------------------------------------------------------------------
*/
#include "pg_filedump.h"
#include "access/tuptoaster.h"
#include "cdb/cdbvars.h"
#include "storage/lwlock.h"
#include "utils/memutils.h"
/****************************************************************************
* src/backend/utils/init/globals.c
***************************************************************************/
#if GP_VERSION_NUM >= 50000
int NBuffers = 4096;
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/storage/buffer/buf_init.c
***************************************************************************/
#if GP_VERSION_NUM >= 50000 && GP_VERSION_NUM < 70000
BufferDesc *BufferDescriptors;
char *BufferBlocks;
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/storage/lmgr/lwlock.c
***************************************************************************/
#if GP_VERSION_NUM >= 60000
bool
LWLockHeldByMe(LWLock *l)
{
return true;
}
#elif GP_VERSION_NUM >= 50000
bool
LWLockHeldByMe(LWLockId lockid)
{
return true;
}
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/storage/buffer/bufmgr.c
***************************************************************************/
#if GP_VERSION_NUM >= 70000
bool
BufferLockHeldByMe(Page page)
{
return true;
}
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/utils/misc/guc.c
***************************************************************************/
bool assert_enabled = true;
/****************************************************************************
* src/backend/utils/misc/guc_gp.c
***************************************************************************/
bool Debug_appendonly_print_storage_headers = false;
bool Debug_appendonly_print_verify_write_block = false;
/****************************************************************************
* src/backend/cdb/cdbvars.c
***************************************************************************/
GpId GpIdentity = {UNINITIALIZED_GP_IDENTITY_VALUE, UNINITIALIZED_GP_IDENTITY_VALUE};
bool gp_reraise_signal = false;
#if GP_VERSION_NUM < 60000
int Gp_segment = -2;
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/access/heap/tuptoaster.c
***************************************************************************/
#if GP_VERSION_NUM >= 60000
Datum
toast_flatten_tuple_to_datum(HeapTupleHeader tup,
uint32 tup_len,
TupleDesc tupleDesc)
{
return PointerGetDatum(NULL);
}
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/utils/mmgr/mcxt.c
***************************************************************************/
MemoryContext CurrentMemoryContext = NULL;
#if GP_VERSION_NUM >= 70000
void
MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
{
}
void
MemoryContextDeleteImpl(MemoryContext context, const char* sfile, const char *func, int sline)
{
}
#endif /* GP_VERSION_NUM */
#if GP_VERSION_NUM < 60000
void *
MemoryContextAllocZeroImpl(MemoryContext context, Size size, const char *sfile, const char *sfunc, int sline)
{
void *ptr = malloc(size);
memset(ptr, 0, size);
return ptr;
}
void
MemoryContextFreeImpl(void *pointer, const char *sfile, const char *sfunc, int sline)
{
free(pointer);
}
void *
MemoryContextAllocImpl(MemoryContext context, Size size, const char *sfile, const char *sfunc, int sline)
{
return malloc(size);
}
void *
MemoryContextReallocImpl(void *pointer, Size size, const char *sfile, const char *sfunc, int sline)
{
return realloc( pointer, size );
}
#endif /* GP_VERSION_NUM */
char *
MemoryContextStrdup(MemoryContext context, const char *string)
{
char *nstr;
Size len = strlen(string) + 1;
nstr = (char *) malloc (len);
memcpy(nstr, string, len);
return nstr;
}
/****************************************************************************
* src/backend/access/heap/tuptoaster.c
***************************************************************************/
#if GP_VERSION_NUM < 60000
Datum
toast_flatten_tuple_attribute(Datum value,
Oid typeId, int32 typeMod)
{
return PointerGetDatum(NULL);
}
#endif /* GP_VERSION_NUM */
/****************************************************************************
* src/backend/utils/error/elog.c
***************************************************************************/
#if PG_VERSION_NUM <= 90600
int
errcode_for_file_access(void)
{
return 0;
}
bool
errstart(int elevel, const char *filename, int lineno,
const char *funcname, const char* domain)
{
return (elevel >= ERROR);
}
void
errfinish(int dummy,...)
{
exit(1);
}
void
elog_start(const char *filename, int lineno, const char *funcname)
{
}
void
elog_finish(int elevel, const char *fmt,...)
{
fprintf(stderr, "ERROR: %s\n", fmt);
exit(1);
}
int
errprintstack(bool printstack)
{
return 0; /* return value does not matter */
}
int
errcode(int sqlerrcode)
{
return 0; /* return value does not matter */
}
int
errmsg(const char *fmt,...)
{
fprintf(stderr, "ERROR: %s\n", fmt);
return 0; /* return value does not matter */
}
int
errmsg_internal(const char *fmt,...)
{
fprintf(stderr, "ERROR: %s\n", fmt);
return 0; /* return value does not matter */
}
int
errdetail(const char *fmt,...)
{
fprintf(stderr, "DETAIL: %s\n", fmt);
return 0; /* return value does not matter */
}
int
errdetail_log(const char *fmt,...)
{
fprintf(stderr, "DETAIL: %s\n", fmt);
return 0; /* return value does not matter */
}
int
errhint(const char *fmt,...)
{
fprintf(stderr, "HINT: %s\n", fmt);
return 0; /* return value does not matter */
}
#else /* PG_VERSION_NUM */
void
errcode_for_file_access(void)
{
}
bool
errstart(int elevel, const char *domain)
{
return (elevel >= ERROR);
}
void
errfinish(const char *filename, int lineno, const char *funcname)
{
exit(1);
}
int
errprintstack(bool printstack)
{
return 0; /* return value does not matter */
}
void
errcode(int sqlerrcode)
{
}
void
errmsg(const char *fmt,...)
{
fprintf(stderr, "ERROR: %s\n", fmt);
}
void
errmsg_internal(const char *fmt,...)
{
fprintf(stderr, "ERROR: %s\n", fmt);
}
void
errdetail(const char *fmt,...)
{
fprintf(stderr, "DETAIL: %s\n", fmt);
}
void
errdetail_log(const char *fmt,...)
{
fprintf(stderr, "DETAIL: %s\n", fmt);
}
void
errhint(const char *fmt,...)
{
fprintf(stderr, "HINT: %s\n", fmt);
}
#endif /* PG_VERSION_NUM */
#if GP_VERSION_NUM < 50000
int
errOmitLocation(bool omitLocation)
{
return 0;
}
#endif /* GP_VERSION_NUM */
/* vi: set ts=4 : */