1 | #include "duckdb/function/pragma_function.hpp" |
2 | #include "duckdb/common/string_util.hpp" |
3 | |
4 | namespace duckdb { |
5 | |
6 | PragmaFunction::PragmaFunction(string name, PragmaType pragma_type, pragma_query_t query, pragma_function_t function, |
7 | vector<LogicalType> arguments, LogicalType varargs) |
8 | : SimpleNamedParameterFunction(std::move(name), std::move(arguments), std::move(varargs)), type(pragma_type), |
9 | query(query), function(function) { |
10 | } |
11 | |
12 | PragmaFunction PragmaFunction::PragmaCall(const string &name, pragma_query_t query, vector<LogicalType> arguments, |
13 | LogicalType varargs) { |
14 | return PragmaFunction(name, PragmaType::PRAGMA_CALL, query, nullptr, std::move(arguments), std::move(varargs)); |
15 | } |
16 | |
17 | PragmaFunction PragmaFunction::PragmaCall(const string &name, pragma_function_t function, vector<LogicalType> arguments, |
18 | LogicalType varargs) { |
19 | return PragmaFunction(name, PragmaType::PRAGMA_CALL, nullptr, function, std::move(arguments), std::move(varargs)); |
20 | } |
21 | |
22 | PragmaFunction PragmaFunction::PragmaStatement(const string &name, pragma_query_t query) { |
23 | vector<LogicalType> types; |
24 | return PragmaFunction(name, PragmaType::PRAGMA_STATEMENT, query, nullptr, std::move(types), LogicalType::INVALID); |
25 | } |
26 | |
27 | PragmaFunction PragmaFunction::PragmaStatement(const string &name, pragma_function_t function) { |
28 | vector<LogicalType> types; |
29 | return PragmaFunction(name, PragmaType::PRAGMA_STATEMENT, nullptr, function, std::move(types), |
30 | LogicalType::INVALID); |
31 | } |
32 | |
33 | string PragmaFunction::ToString() const { |
34 | switch (type) { |
35 | case PragmaType::PRAGMA_STATEMENT: |
36 | return StringUtil::Format(fmt_str: "PRAGMA %s" , params: name); |
37 | case PragmaType::PRAGMA_CALL: { |
38 | return StringUtil::Format(fmt_str: "PRAGMA %s" , params: SimpleNamedParameterFunction::ToString()); |
39 | } |
40 | default: |
41 | return "UNKNOWN" ; |
42 | } |
43 | } |
44 | |
45 | } // namespace duckdb |
46 | |