| 1 | #include "duckdb/function/built_in_functions.hpp" |
| 2 | #include "duckdb/parser/parsed_data/create_aggregate_function_info.hpp" |
| 3 | #include "duckdb/parser/parsed_data/create_collation_info.hpp" |
| 4 | #include "duckdb/parser/parsed_data/create_copy_function_info.hpp" |
| 5 | #include "duckdb/parser/parsed_data/create_pragma_function_info.hpp" |
| 6 | #include "duckdb/parser/parsed_data/create_scalar_function_info.hpp" |
| 7 | #include "duckdb/parser/parsed_data/create_table_function_info.hpp" |
| 8 | #include "duckdb/catalog/catalog.hpp" |
| 9 | #include "duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp" |
| 10 | |
| 11 | namespace duckdb { |
| 12 | |
| 13 | BuiltinFunctions::BuiltinFunctions(CatalogTransaction transaction, Catalog &catalog) |
| 14 | : transaction(transaction), catalog(catalog) { |
| 15 | } |
| 16 | |
| 17 | BuiltinFunctions::~BuiltinFunctions() { |
| 18 | } |
| 19 | |
| 20 | void BuiltinFunctions::AddCollation(string name, ScalarFunction function, bool combinable, |
| 21 | bool not_required_for_equality) { |
| 22 | CreateCollationInfo info(std::move(name), std::move(function), combinable, not_required_for_equality); |
| 23 | info.internal = true; |
| 24 | catalog.CreateCollation(transaction, info); |
| 25 | } |
| 26 | |
| 27 | void BuiltinFunctions::AddFunction(AggregateFunctionSet set) { |
| 28 | CreateAggregateFunctionInfo info(std::move(set)); |
| 29 | info.internal = true; |
| 30 | catalog.CreateFunction(transaction, info); |
| 31 | } |
| 32 | |
| 33 | void BuiltinFunctions::AddFunction(AggregateFunction function) { |
| 34 | CreateAggregateFunctionInfo info(std::move(function)); |
| 35 | info.internal = true; |
| 36 | catalog.CreateFunction(transaction, info); |
| 37 | } |
| 38 | |
| 39 | void BuiltinFunctions::AddFunction(PragmaFunction function) { |
| 40 | CreatePragmaFunctionInfo info(std::move(function)); |
| 41 | info.internal = true; |
| 42 | catalog.CreatePragmaFunction(transaction, info); |
| 43 | } |
| 44 | |
| 45 | void BuiltinFunctions::AddFunction(const string &name, PragmaFunctionSet functions) { |
| 46 | CreatePragmaFunctionInfo info(name, std::move(functions)); |
| 47 | info.internal = true; |
| 48 | catalog.CreatePragmaFunction(transaction, info); |
| 49 | } |
| 50 | |
| 51 | void BuiltinFunctions::AddFunction(ScalarFunction function) { |
| 52 | CreateScalarFunctionInfo info(std::move(function)); |
| 53 | info.internal = true; |
| 54 | catalog.CreateFunction(transaction, info); |
| 55 | } |
| 56 | |
| 57 | void BuiltinFunctions::AddFunction(const vector<string> &names, ScalarFunction function) { // NOLINT: false positive |
| 58 | for (auto &name : names) { |
| 59 | function.name = name; |
| 60 | AddFunction(function); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void BuiltinFunctions::AddFunction(ScalarFunctionSet set) { |
| 65 | CreateScalarFunctionInfo info(std::move(set)); |
| 66 | info.internal = true; |
| 67 | catalog.CreateFunction(transaction, info); |
| 68 | } |
| 69 | |
| 70 | void BuiltinFunctions::AddFunction(TableFunction function) { |
| 71 | CreateTableFunctionInfo info(std::move(function)); |
| 72 | info.internal = true; |
| 73 | catalog.CreateTableFunction(transaction, info); |
| 74 | } |
| 75 | |
| 76 | void BuiltinFunctions::AddFunction(TableFunctionSet set) { |
| 77 | CreateTableFunctionInfo info(std::move(set)); |
| 78 | info.internal = true; |
| 79 | catalog.CreateTableFunction(transaction, info); |
| 80 | } |
| 81 | |
| 82 | void BuiltinFunctions::AddFunction(CopyFunction function) { |
| 83 | CreateCopyFunctionInfo info(std::move(function)); |
| 84 | info.internal = true; |
| 85 | catalog.CreateCopyFunction(transaction, info); |
| 86 | } |
| 87 | |
| 88 | } // namespace duckdb |
| 89 | |