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