Skip to content

Commit e58cd1d

Browse files
authored
Merge pull request #357 from Mytherin/main
Bump to main
2 parents 9c1a5bd + e7397d3 commit e58cd1d

14 files changed

+56
-57
lines changed

.github/workflows/MainDistributionPipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: Build extension binaries
1717
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
1818
with:
19-
duckdb_version: v1.3.2
19+
duckdb_version: main
2020
ci_tools_version: v1.3.2
2121
extension_name: postgres_scanner
2222
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw'
@@ -27,7 +27,7 @@ jobs:
2727
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
2828
secrets: inherit
2929
with:
30-
duckdb_version: v1.3.2
30+
duckdb_version: main
3131
ci_tools_version: v1.3.2
3232
extension_name: postgres_scanner
3333
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_mingw'

duckdb

Submodule duckdb updated 1771 files

src/include/postgres_scanner_extension.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ class PostgresScannerExtension : public Extension {
1313
std::string Name() override {
1414
return "postgres_scanner";
1515
}
16-
void Load(DuckDB &db) override;
16+
void Load(ExtensionLoader &loader) override;
1717
};
1818

1919
extern "C" {
20-
DUCKDB_EXTENSION_API void postgres_scanner_init(duckdb::DatabaseInstance &db);
21-
DUCKDB_EXTENSION_API const char *postgres_scanner_version();
22-
DUCKDB_EXTENSION_API void postgres_scanner_storage_init(DBConfig &config);
20+
DUCKDB_CPP_EXTENSION_ENTRY(postgres_scanner, loader);
2321
}

src/include/storage/postgres_delete.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace duckdb {
1414

1515
class PostgresDelete : public PhysicalOperator {
1616
public:
17-
PostgresDelete(LogicalOperator &op, TableCatalogEntry &table, idx_t row_id_index);
17+
PostgresDelete(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table, idx_t row_id_index);
1818

1919
//! The table to delete from
2020
TableCatalogEntry &table;

src/include/storage/postgres_index.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ namespace duckdb {
1616
//! PhysicalCreateSequence represents a CREATE SEQUENCE command
1717
class PostgresCreateIndex : public PhysicalOperator {
1818
public:
19-
explicit PostgresCreateIndex(unique_ptr<CreateIndexInfo> info, TableCatalogEntry &table);
19+
explicit PostgresCreateIndex(PhysicalPlan &physical_plan, unique_ptr<CreateIndexInfo> info,
20+
TableCatalogEntry &table);
2021

2122
unique_ptr<CreateIndexInfo> info;
2223
TableCatalogEntry &table;

src/include/storage/postgres_insert.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ namespace duckdb {
1616
class PostgresInsert : public PhysicalOperator {
1717
public:
1818
//! INSERT INTO
19-
PostgresInsert(LogicalOperator &op, TableCatalogEntry &table, physical_index_vector_t<idx_t> column_index_map);
19+
PostgresInsert(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
20+
physical_index_vector_t<idx_t> column_index_map);
2021
//! CREATE TABLE AS
21-
PostgresInsert(LogicalOperator &op, SchemaCatalogEntry &schema, unique_ptr<BoundCreateTableInfo> info);
22+
PostgresInsert(PhysicalPlan &physical_plan, LogicalOperator &op, SchemaCatalogEntry &schema,
23+
unique_ptr<BoundCreateTableInfo> info);
2224

2325
//! The table to insert into
2426
optional_ptr<TableCatalogEntry> table;

src/include/storage/postgres_update.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace duckdb {
1515

1616
class PostgresUpdate : public PhysicalOperator {
1717
public:
18-
PostgresUpdate(LogicalOperator &op, TableCatalogEntry &table, vector<PhysicalIndex> columns);
18+
PostgresUpdate(PhysicalPlan &physical_plan, LogicalOperator &op, TableCatalogEntry &table,
19+
vector<PhysicalIndex> columns);
1920

2021
//! The table to delete from
2122
TableCatalogEntry &table;

src/postgres_extension.cpp

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "duckdb/catalog/catalog.hpp"
1010
#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"
1212
#include "duckdb/common/helper.hpp"
1313
#include "duckdb/main/database_manager.hpp"
1414
#include "duckdb/main/attached_database.hpp"
@@ -125,41 +125,41 @@ void SetPostgresNullByteReplacement(ClientContext &context, SetScope scope, Valu
125125
}
126126
}
127127

128-
static void LoadInternal(DatabaseInstance &db) {
128+
static void LoadInternal(ExtensionLoader &loader) {
129129
PostgresScanFunction postgres_fun;
130-
ExtensionUtil::RegisterFunction(db, postgres_fun);
130+
loader.RegisterFunction(postgres_fun);
131131

132132
PostgresScanFunctionFilterPushdown postgres_fun_filter_pushdown;
133-
ExtensionUtil::RegisterFunction(db, postgres_fun_filter_pushdown);
133+
loader.RegisterFunction(postgres_fun_filter_pushdown);
134134

135135
PostgresAttachFunction attach_func;
136-
ExtensionUtil::RegisterFunction(db, attach_func);
136+
loader.RegisterFunction(attach_func);
137137

138138
PostgresClearCacheFunction clear_cache_func;
139-
ExtensionUtil::RegisterFunction(db, clear_cache_func);
139+
loader.RegisterFunction(clear_cache_func);
140140

141141
PostgresQueryFunction query_func;
142-
ExtensionUtil::RegisterFunction(db, query_func);
142+
loader.RegisterFunction(query_func);
143143

144144
PostgresExecuteFunction execute_func;
145-
ExtensionUtil::RegisterFunction(db, execute_func);
145+
loader.RegisterFunction(execute_func);
146146

147147
PostgresBinaryCopyFunction binary_copy;
148-
ExtensionUtil::RegisterFunction(db, binary_copy);
148+
loader.RegisterFunction(binary_copy);
149149

150150
// Register the new type
151151
SecretType secret_type;
152152
secret_type.name = "postgres";
153153
secret_type.deserializer = KeyValueSecret::Deserialize<KeyValueSecret>;
154154
secret_type.default_provider = "config";
155155

156-
ExtensionUtil::RegisterSecretType(db, secret_type);
156+
loader.RegisterSecretType(secret_type);
157157

158158
CreateSecretFunction postgres_secret_function = {"postgres", "config", CreatePostgresSecretFunction};
159159
SetPostgresSecretParameters(postgres_secret_function);
160-
ExtensionUtil::RegisterFunction(db, postgres_secret_function);
160+
loader.RegisterFunction(postgres_secret_function);
161161

162-
auto &config = DBConfig::GetConfig(db);
162+
auto &config = DBConfig::GetConfig(loader.GetDatabaseInstance());
163163
config.storage_extensions["postgres_scanner"] = make_uniq<PostgresStorageExtension>();
164164

165165
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) {
193193
config.optimizer_extensions.push_back(std::move(postgres_optimizer));
194194

195195
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()) {
197197
connection->registered_state->Insert("postgres_extension", make_shared_ptr<PostgresExtensionState>());
198198
}
199199
}
200200

201-
void PostgresScannerExtension::Load(DuckDB &db) {
202-
LoadInternal(*db.instance);
201+
void PostgresScannerExtension::Load(ExtensionLoader &loader) {
202+
LoadInternal(loader);
203203
}
204204

205205
extern "C" {
206206

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);
217209
}
218210
}

src/postgres_scanner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <libpq-fe.h>
44

5-
#include "duckdb/main/extension_util.hpp"
5+
#include "duckdb/main/extension/extension_loader.hpp"
66
#include "duckdb/common/shared_ptr.hpp"
77
#include "duckdb/common/helper.hpp"
88
#include "duckdb/parser/parsed_data/create_table_function_info.hpp"

src/postgres_storage.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace duckdb {
99

10-
static unique_ptr<Catalog> PostgresAttach(StorageExtensionInfo *storage_info, ClientContext &context,
10+
static unique_ptr<Catalog> PostgresAttach(optional_ptr<StorageExtensionInfo> storage_info, ClientContext &context,
1111
AttachedDatabase &db, const string &name, AttachInfo &info,
12-
AccessMode access_mode) {
12+
AttachOptions &attach_options) {
1313
auto &config = DBConfig::GetConfig(context);
1414
if (!config.options.enable_external_access) {
1515
throw PermissionException("Attaching Postgres databases is disabled through configuration");
@@ -19,11 +19,9 @@ static unique_ptr<Catalog> PostgresAttach(StorageExtensionInfo *storage_info, Cl
1919
string secret_name;
2020
string schema_to_load;
2121
PostgresIsolationLevel isolation_level = PostgresIsolationLevel::REPEATABLE_READ;
22-
for (auto &entry : info.options) {
22+
for (auto &entry : attach_options.options) {
2323
auto lower_name = StringUtil::Lower(entry.first);
24-
if (lower_name == "type" || lower_name == "read_only" || lower_name == "read_write") {
25-
// already handled
26-
} else if (lower_name == "secret") {
24+
if (lower_name == "secret") {
2725
secret_name = entry.second.ToString();
2826
} else if (lower_name == "schema") {
2927
schema_to_load = entry.second.ToString();
@@ -46,11 +44,11 @@ static unique_ptr<Catalog> PostgresAttach(StorageExtensionInfo *storage_info, Cl
4644
}
4745
}
4846
auto connection_string = PostgresCatalog::GetConnectionString(context, attach_path, secret_name);
49-
return make_uniq<PostgresCatalog>(db, std::move(connection_string), std::move(attach_path), access_mode,
50-
std::move(schema_to_load), isolation_level);
47+
return make_uniq<PostgresCatalog>(db, std::move(connection_string), std::move(attach_path),
48+
attach_options.access_mode, std::move(schema_to_load), isolation_level);
5149
}
5250

53-
static unique_ptr<TransactionManager> PostgresCreateTransactionManager(StorageExtensionInfo *storage_info,
51+
static unique_ptr<TransactionManager> PostgresCreateTransactionManager(optional_ptr<StorageExtensionInfo> storage_info,
5452
AttachedDatabase &db, Catalog &catalog) {
5553
auto &postgres_catalog = catalog.Cast<PostgresCatalog>();
5654
return make_uniq<PostgresTransactionManager>(db, postgres_catalog);

0 commit comments

Comments
 (0)