1 | #include "postgres_parser.hpp" |
---|---|
2 | |
3 | #include "pg_functions.hpp" |
4 | #include "parser/parser.hpp" |
5 | |
6 | using namespace duckdb; |
7 | using namespace std; |
8 | |
9 | PostgresParser::PostgresParser() : success(false), parse_tree(nullptr), error_message(""), error_location(0) {}; |
10 | |
11 | |
12 | void PostgresParser::Parse(string query) { |
13 | pg_parser_init(); |
14 | parse_result res; |
15 | pg_parser_parse(query.c_str(), &res); |
16 | success = res.success; |
17 | |
18 | if (success) { |
19 | parse_tree = res.parse_tree; |
20 | } else { |
21 | error_message = string(res.error_message); |
22 | error_location = res.error_location; |
23 | } |
24 | }; |
25 | |
26 | PostgresParser::~PostgresParser() { |
27 | pg_parser_cleanup(); |
28 | }; |
29 |