1 | #pragma once |
2 | |
3 | #include <stdlib.h> |
4 | |
5 | #include "pg_definitions.hpp" |
6 | |
7 | #include "nodes/pg_list.hpp" |
8 | #include "nodes/parsenodes.hpp" |
9 | |
10 | typedef struct parse_result_str parse_result; |
11 | struct parse_result_str { |
12 | bool success; |
13 | PGList* parse_tree; |
14 | char* error_message; |
15 | int error_location; |
16 | }; |
17 | |
18 | void pg_parser_init(); |
19 | void pg_parser_parse(const char* query, parse_result *res); |
20 | void pg_parser_cleanup(); |
21 | |
22 | // error handling |
23 | int ereport(int code, ...); |
24 | |
25 | void elog(int code, const char* fmt,...); |
26 | int errcode(int sqlerrcode); |
27 | int errmsg(const char* fmt, ...); |
28 | int errhint(const char* msg); |
29 | int errmsg_internal(const char *fmt,...); |
30 | int errdetail(const char *fmt,...); |
31 | int errposition(int cursorpos); |
32 | char *psprintf(const char *fmt,...); |
33 | |
34 | // memory mgmt |
35 | char *pstrdup(const char *in); |
36 | void* palloc(size_t n); |
37 | void pfree(void* ptr); |
38 | void* palloc0fast(size_t n); |
39 | void* repalloc(void* ptr, size_t n); |
40 | |
41 | char *NameListToString(PGList *names); |
42 | void * copyObject(const void *from); |
43 | bool equal(const void *a, const void *b); |
44 | int exprLocation(const PGNode *expr); |
45 | |
46 | // string gunk |
47 | int pg_database_encoding_max_length(void); |
48 | bool pg_verifymbstr(const char *mbstr, int len, bool noError); |
49 | int pg_mbstrlen_with_len(const char *mbstr, int len); |
50 | int pg_mbcliplen(const char *mbstr, int len, int limit); |
51 | int pg_mblen(const char *mbstr); |
52 | |
53 | PGDefElem * defWithOids(bool value); |
54 | |
55 | typedef unsigned int pg_wchar; |
56 | unsigned char *unicode_to_utf8(pg_wchar c, unsigned char *utf8string); |
57 | |
58 | |