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