forked from pganalyze/libpg_query
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pg_query.h
61 lines (47 loc) · 1.54 KB
/
pg_query.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
#ifndef PG_QUERY_H
#define PG_QUERY_H
#include "c.h"
#include "lib/stringinfo.h"
typedef struct {
char* message; // exception message
char* funcname; // source function of exception (e.g. SearchSysCache)
char* filename; // source of exception (e.g. parse.l)
int lineno; // source of exception (e.g. 104)
int cursorpos; // char in query at which exception occurred
char* context; // additional context (optional, can be NULL)
} PgQueryError;
typedef struct {
char* parse_tree;
char* stderr_buffer;
PgQueryError* error;
} PgQueryParseResult;
typedef struct {
char* plpgsql_funcs;
PgQueryError* error;
} PgQueryPlpgsqlParseResult;
typedef struct {
char* hexdigest;
char* stderr_buffer;
PgQueryError* error;
} PgQueryFingerprintResult;
typedef struct {
char* normalized_query;
PgQueryError* error;
} PgQueryNormalizeResult;
#ifdef __cplusplus
extern "C" {
#endif
PgQueryNormalizeResult pg_query_normalize(const char* input);
PgQueryParseResult pg_query_parse(const char* input);
PgQueryPlpgsqlParseResult pg_query_parse_plpgsql(const char* input);
PgQueryFingerprintResult pg_query_fingerprint(const char* input);
void pg_query_free_normalize_result(PgQueryNormalizeResult result);
void pg_query_free_parse_result(PgQueryParseResult result);
void pg_query_free_plpgsql_parse_result(PgQueryPlpgsqlParseResult result);
void pg_query_free_fingerprint_result(PgQueryFingerprintResult result);
// Deprecated APIs below
void pg_query_init(void); // Deprecated as of 9.5-1.4.1, this is now run automatically as needed
#ifdef __cplusplus
}
#endif
#endif