|
8 | 8 |
|
9 | 9 | #include "duckdb/catalog/catalog.hpp" |
10 | 10 | #include "duckdb/parser/parsed_data/create_table_function_info.hpp" |
11 | | -#include "duckdb/main/extension_util.hpp" |
| 11 | +#include "duckdb/main/extension/extension_loader.hpp" |
12 | 12 | #include "duckdb/common/helper.hpp" |
13 | 13 | #include "duckdb/main/database_manager.hpp" |
14 | 14 | #include "duckdb/main/attached_database.hpp" |
@@ -125,41 +125,41 @@ void SetPostgresNullByteReplacement(ClientContext &context, SetScope scope, Valu |
125 | 125 | } |
126 | 126 | } |
127 | 127 |
|
128 | | -static void LoadInternal(DatabaseInstance &db) { |
| 128 | +static void LoadInternal(ExtensionLoader &loader) { |
129 | 129 | PostgresScanFunction postgres_fun; |
130 | | - ExtensionUtil::RegisterFunction(db, postgres_fun); |
| 130 | + loader.RegisterFunction(postgres_fun); |
131 | 131 |
|
132 | 132 | PostgresScanFunctionFilterPushdown postgres_fun_filter_pushdown; |
133 | | - ExtensionUtil::RegisterFunction(db, postgres_fun_filter_pushdown); |
| 133 | + loader.RegisterFunction(postgres_fun_filter_pushdown); |
134 | 134 |
|
135 | 135 | PostgresAttachFunction attach_func; |
136 | | - ExtensionUtil::RegisterFunction(db, attach_func); |
| 136 | + loader.RegisterFunction(attach_func); |
137 | 137 |
|
138 | 138 | PostgresClearCacheFunction clear_cache_func; |
139 | | - ExtensionUtil::RegisterFunction(db, clear_cache_func); |
| 139 | + loader.RegisterFunction(clear_cache_func); |
140 | 140 |
|
141 | 141 | PostgresQueryFunction query_func; |
142 | | - ExtensionUtil::RegisterFunction(db, query_func); |
| 142 | + loader.RegisterFunction(query_func); |
143 | 143 |
|
144 | 144 | PostgresExecuteFunction execute_func; |
145 | | - ExtensionUtil::RegisterFunction(db, execute_func); |
| 145 | + loader.RegisterFunction(execute_func); |
146 | 146 |
|
147 | 147 | PostgresBinaryCopyFunction binary_copy; |
148 | | - ExtensionUtil::RegisterFunction(db, binary_copy); |
| 148 | + loader.RegisterFunction(binary_copy); |
149 | 149 |
|
150 | 150 | // Register the new type |
151 | 151 | SecretType secret_type; |
152 | 152 | secret_type.name = "postgres"; |
153 | 153 | secret_type.deserializer = KeyValueSecret::Deserialize<KeyValueSecret>; |
154 | 154 | secret_type.default_provider = "config"; |
155 | 155 |
|
156 | | - ExtensionUtil::RegisterSecretType(db, secret_type); |
| 156 | + loader.RegisterSecretType(secret_type); |
157 | 157 |
|
158 | 158 | CreateSecretFunction postgres_secret_function = {"postgres", "config", CreatePostgresSecretFunction}; |
159 | 159 | SetPostgresSecretParameters(postgres_secret_function); |
160 | | - ExtensionUtil::RegisterFunction(db, postgres_secret_function); |
| 160 | + loader.RegisterFunction(postgres_secret_function); |
161 | 161 |
|
162 | | - auto &config = DBConfig::GetConfig(db); |
| 162 | + auto &config = DBConfig::GetConfig(loader.GetDatabaseInstance()); |
163 | 163 | config.storage_extensions["postgres_scanner"] = make_uniq<PostgresStorageExtension>(); |
164 | 164 |
|
165 | 165 | config.AddExtensionOption("pg_use_binary_copy", "Whether or not to use BINARY copy to read data", |
@@ -193,26 +193,18 @@ static void LoadInternal(DatabaseInstance &db) { |
193 | 193 | config.optimizer_extensions.push_back(std::move(postgres_optimizer)); |
194 | 194 |
|
195 | 195 | config.extension_callbacks.push_back(make_uniq<PostgresExtensionCallback>()); |
196 | | - for (auto &connection : ConnectionManager::Get(db).GetConnectionList()) { |
| 196 | + for (auto &connection : ConnectionManager::Get(loader.GetDatabaseInstance()).GetConnectionList()) { |
197 | 197 | connection->registered_state->Insert("postgres_extension", make_shared_ptr<PostgresExtensionState>()); |
198 | 198 | } |
199 | 199 | } |
200 | 200 |
|
201 | | -void PostgresScannerExtension::Load(DuckDB &db) { |
202 | | - LoadInternal(*db.instance); |
| 201 | +void PostgresScannerExtension::Load(ExtensionLoader &loader) { |
| 202 | + LoadInternal(loader); |
203 | 203 | } |
204 | 204 |
|
205 | 205 | extern "C" { |
206 | 206 |
|
207 | | -DUCKDB_EXTENSION_API void postgres_scanner_init(duckdb::DatabaseInstance &db) { |
208 | | - LoadInternal(db); |
209 | | -} |
210 | | - |
211 | | -DUCKDB_EXTENSION_API const char *postgres_scanner_version() { |
212 | | - return DuckDB::LibraryVersion(); |
213 | | -} |
214 | | - |
215 | | -DUCKDB_EXTENSION_API void postgres_scanner_storage_init(DBConfig &config) { |
216 | | - config.storage_extensions["postgres_scanner"] = make_uniq<PostgresStorageExtension>(); |
| 207 | +DUCKDB_CPP_EXTENSION_ENTRY(postgres_scanner, loader) { |
| 208 | + LoadInternal(loader); |
217 | 209 | } |
218 | 210 | } |
0 commit comments