1#include "postgres_parser.hpp"
2
3#include "pg_functions.hpp"
4#include "parser/parser.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9PostgresParser::PostgresParser() : success(false), parse_tree(nullptr), error_message(""), error_location(0) {};
10
11
12void 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
26PostgresParser::~PostgresParser() {
27 pg_parser_cleanup();
28};
29