-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwrapper.h
More file actions
56 lines (48 loc) · 1.3 KB
/
Copy pathwrapper.h
File metadata and controls
56 lines (48 loc) · 1.3 KB
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
#include "postgres.h"
#include "pg_query.h"
#include "src/pg_query_internal.h"
#include "nodes/parsenodes.h"
#include "nodes/nodeFuncs.h"
#include "nodes/makefuncs.h"
#include "utils/palloc.h"
#include "utils/memutils.h"
#include "copy_pg_error.h"
static inline MemoryContext get_top_memory_context(void) {
return TopMemoryContext;
}
// Moved definition into copy_pg_error.c.
// Rust links against this symbol directly, so it needs external linkage.
bool wrapped_raw_expression_tree_walker_impl(Node *n, tree_walker_callback w, void *c, Error *error);
static inline StringInfo wrapped_raw_deparse(RawStmt *stmt, ErrorData **error) {
StringInfo str;
PG_TRY();
str = makeStringInfo();
deparseRawStmt(str, stmt);
PG_CATCH();
*error = CopyErrorData();
FlushErrorState();
PG_END_TRY();
return str;
}
// FIXME(sage): libpg_query doesn't compile pnstrdup, which we want
static inline
char *
wrapped_pnstrdup(const char *in, Size len)
{
char *out;
len = strnlen(in, len);
out = palloc(len + 1);
memcpy(out, in, len);
out[len] = '\0';
return out;
}
static inline Node *wrapped_copy_object(Node *node, ErrorData **error) {
Node *result = NULL;
PG_TRY();
result = copyObject(node);
PG_CATCH();
*error = CopyErrorData();
FlushErrorState();
PG_END_TRY();
return result;
}