1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/main/extension_util.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/constants.hpp"
12#include "duckdb/function/cast/cast_function_set.hpp"
13#include "duckdb/function/function_set.hpp"
14
15namespace duckdb {
16struct CreateMacroInfo;
17class DatabaseInstance;
18
19//! The ExtensionUtil class contains methods that are useful for extensions
20class ExtensionUtil {
21public:
22 //! Register a new scalar function - throw an exception if the function already exists
23 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, ScalarFunction function);
24 //! Register a new scalar function set - throw an exception if the function already exists
25 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, ScalarFunctionSet function);
26 //! Register a new table function - throw an exception if the function already exists
27 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, TableFunction function);
28 //! Register a new table function set - throw an exception if the function already exists
29 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, TableFunctionSet function);
30 //! Register a new pragma function - throw an exception if the function already exists
31 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, PragmaFunction function);
32 //! Register a new pragma function set - throw an exception if the function already exists
33 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, PragmaFunctionSet function);
34 //! Register a new copy function - throw an exception if the function already exists
35 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, CopyFunction function);
36 //! Register a new macro function - throw an exception if the function already exists
37 DUCKDB_API static void RegisterFunction(DatabaseInstance &db, CreateMacroInfo &info);
38
39 //! Registers a new type
40 DUCKDB_API static void RegisterType(DatabaseInstance &db, string type_name, LogicalType type);
41
42 //! Registers a cast between two types
43 DUCKDB_API static void RegisterCastFunction(DatabaseInstance &db, const LogicalType &source,
44 const LogicalType &target, BoundCastInfo function,
45 int64_t implicit_cast_cost = -1);
46};
47
48} // namespace duckdb
49