Coverage Report

Created: 2026-03-31 07:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/duckdb/third_party/libpg_query/postgres_parser.cpp
Line
Count
Source
1
#include "postgres_parser.hpp"
2
3
#include "pg_functions.hpp"
4
#include "parser/parser.hpp"
5
#include "parser/scansup.hpp"
6
#include "common/keywords.hpp"
7
8
namespace duckdb {
9
10
818k
PostgresParser::PostgresParser() : success(false), parse_tree(nullptr), error_message(""), error_location(0) {}
11
12
818k
void PostgresParser::Parse(const std::string &query) {
13
818k
  duckdb_libpgquery::pg_parser_init();
14
818k
  duckdb_libpgquery::parse_result res;
15
818k
  pg_parser_parse(query.c_str(), &res);
16
818k
  success = res.success;
17
18
818k
  if (success) {
19
817k
    parse_tree = res.parse_tree;
20
817k
  } else {
21
1.40k
    error_message = std::string(res.error_message);
22
1.40k
    error_location = res.error_location;
23
1.40k
  }
24
818k
}
25
26
0
vector<duckdb_libpgquery::PGSimplifiedToken> PostgresParser::Tokenize(const std::string &query) {
27
0
  duckdb_libpgquery::pg_parser_init();
28
0
  auto tokens = duckdb_libpgquery::tokenize(query.c_str());
29
0
  duckdb_libpgquery::pg_parser_cleanup();
30
0
  return std::move(tokens);
31
0
}
32
33
818k
PostgresParser::~PostgresParser()  {
34
818k
    duckdb_libpgquery::pg_parser_cleanup();
35
818k
}
36
37
1.83M
duckdb_libpgquery::PGKeywordCategory PostgresParser::IsKeyword(const std::string &text) {
38
1.83M
  return duckdb_libpgquery::is_keyword(text.c_str());
39
1.83M
}
40
41
0
vector<duckdb_libpgquery::PGKeyword> PostgresParser::KeywordList() {
42
  // FIXME: because of this, we might need to change the libpg_query library to use duckdb::vector
43
0
  vector<duckdb_libpgquery::PGKeyword> tmp(duckdb_libpgquery::keyword_list());
44
0
  return tmp;
45
0
}
46
47
818k
void PostgresParser::SetPreserveIdentifierCase(bool preserve) {
48
818k
  duckdb_libpgquery::set_preserve_identifier_case(preserve);
49
818k
}
50
51
}