|
6 | 6 | #include "duckdb/common/exception.hpp"
|
7 | 7 | #include "duckdb/common/string_util.hpp"
|
8 | 8 | #include "duckdb/function/scalar_function.hpp"
|
9 |
| -#include "duckdb/main/extension_util.hpp" |
10 | 9 |
|
11 |
| -namespace duckdb { |
| 10 | +namespace duckdb |
| 11 | +{ |
12 | 12 |
|
13 |
| -static void LoadInternal(DatabaseInstance &instance) { |
14 |
| - // Register a scalar function |
15 |
| - auto &fs = instance.GetFileSystem(); |
| 13 | + static void LoadInternal(ExtensionLoader &loader) |
| 14 | + { |
| 15 | + // Register a scalar function |
| 16 | + auto &instance = loader.GetDatabaseInstance(); |
| 17 | + auto &fs = instance.GetFileSystem(); |
16 | 18 |
|
17 |
| - fs.RegisterSubSystem(make_uniq<ShellFileSystem>()); |
| 19 | + fs.RegisterSubSystem(make_uniq<ShellFileSystem>()); |
18 | 20 |
|
19 |
| - auto &config = DBConfig::GetConfig(instance); |
| 21 | + auto &config = DBConfig::GetConfig(instance); |
20 | 22 |
|
21 |
| - // When writing to a PIPE ignore the SIGPIPE error and consider that the write succeeded. |
22 |
| - config.AddExtensionOption("ignore_sigpipe", "Ignore SIGPIPE", LogicalType::BOOLEAN, Value(false)); |
| 23 | + // When writing to a PIPE ignore the SIGPIPE error and consider that the write succeeded. |
| 24 | + config.AddExtensionOption("ignore_sigpipe", "Ignore SIGPIPE", LogicalType::BOOLEAN, Value(false)); |
| 25 | + } |
23 | 26 |
|
24 |
| -} |
25 |
| -void ShellfsExtension::Load(DuckDB &db) { |
26 |
| - LoadInternal(*db.instance); |
27 |
| -} |
28 |
| -std::string ShellfsExtension::Name() { |
29 |
| - return "shellfs"; |
30 |
| -} |
| 27 | + void ShellfsExtension::Load(ExtensionLoader &loader) |
| 28 | + { |
| 29 | + LoadInternal(loader); |
| 30 | + } |
31 | 31 |
|
32 |
| -} // namespace duckdb |
| 32 | + std::string ShellfsExtension::Name() |
| 33 | + { |
| 34 | + return "shellfs"; |
| 35 | + } |
33 | 36 |
|
34 |
| -extern "C" { |
| 37 | +} // namespace duckdb |
35 | 38 |
|
36 |
| -DUCKDB_EXTENSION_API void shellfs_init(duckdb::DatabaseInstance &db) { |
37 |
| - duckdb::DuckDB db_wrapper(db); |
38 |
| - db_wrapper.LoadExtension<duckdb::ShellfsExtension>(); |
39 |
| -} |
| 39 | +extern "C" |
| 40 | +{ |
40 | 41 |
|
41 |
| -DUCKDB_EXTENSION_API const char *shellfs_version() { |
42 |
| - return duckdb::DuckDB::LibraryVersion(); |
| 42 | + DUCKDB_CPP_EXTENSION_ENTRY(shellfs, loader) |
| 43 | + { |
| 44 | + duckdb::LoadInternal(loader); |
| 45 | + } |
43 | 46 | }
|
44 |
| -} |
45 |
| - |
46 |
| -#ifndef DUCKDB_EXTENSION_MAIN |
47 |
| -#error DUCKDB_EXTENSION_MAIN not defined |
48 |
| -#endif |
0 commit comments