forked from alibaba/AliSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpragma_function.cpp
More file actions
45 lines (37 loc) · 1.85 KB
/
pragma_function.cpp
File metadata and controls
45 lines (37 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "duckdb/function/pragma_function.hpp"
#include "duckdb/common/string_util.hpp"
namespace duckdb {
PragmaFunction::PragmaFunction(string name, PragmaType pragma_type, pragma_query_t query, pragma_function_t function,
vector<LogicalType> arguments, LogicalType varargs)
: SimpleNamedParameterFunction(std::move(name), std::move(arguments), std::move(varargs)), type(pragma_type),
query(query), function(function) {
}
PragmaFunction PragmaFunction::PragmaCall(const string &name, pragma_query_t query, vector<LogicalType> arguments,
LogicalType varargs) {
return PragmaFunction(name, PragmaType::PRAGMA_CALL, query, nullptr, std::move(arguments), std::move(varargs));
}
PragmaFunction PragmaFunction::PragmaCall(const string &name, pragma_function_t function, vector<LogicalType> arguments,
LogicalType varargs) {
return PragmaFunction(name, PragmaType::PRAGMA_CALL, nullptr, function, std::move(arguments), std::move(varargs));
}
PragmaFunction PragmaFunction::PragmaStatement(const string &name, pragma_query_t query) {
vector<LogicalType> types;
return PragmaFunction(name, PragmaType::PRAGMA_STATEMENT, query, nullptr, std::move(types), LogicalType::INVALID);
}
PragmaFunction PragmaFunction::PragmaStatement(const string &name, pragma_function_t function) {
vector<LogicalType> types;
return PragmaFunction(name, PragmaType::PRAGMA_STATEMENT, nullptr, function, std::move(types),
LogicalType::INVALID);
}
string PragmaFunction::ToString() const {
switch (type) {
case PragmaType::PRAGMA_STATEMENT:
return StringUtil::Format("PRAGMA %s", name);
case PragmaType::PRAGMA_CALL: {
return StringUtil::Format("PRAGMA %s", SimpleNamedParameterFunction::ToString());
}
default:
return "UNKNOWN";
}
}
} // namespace duckdb