Skip to content

Commit e53141c

Browse files
committed
WIP: bump to main
1 parent 98482ce commit e53141c

14 files changed

+100
-103
lines changed

duckdb

Submodule duckdb updated 1763 files

src/include/storage/postgres_catalog.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ class PostgresCatalog : public Catalog {
4040

4141
void ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) override;
4242

43-
optional_ptr<SchemaCatalogEntry> GetSchema(CatalogTransaction transaction, const string &schema_name,
44-
OnEntryNotFound if_not_found,
45-
QueryErrorContext error_context = QueryErrorContext()) override;
46-
47-
unique_ptr<PhysicalOperator> PlanInsert(ClientContext &context, LogicalInsert &op,
48-
unique_ptr<PhysicalOperator> plan) override;
49-
unique_ptr<PhysicalOperator> PlanCreateTableAs(ClientContext &context, LogicalCreateTable &op,
50-
unique_ptr<PhysicalOperator> plan) override;
51-
unique_ptr<PhysicalOperator> PlanDelete(ClientContext &context, LogicalDelete &op,
52-
unique_ptr<PhysicalOperator> plan) override;
53-
unique_ptr<PhysicalOperator> PlanUpdate(ClientContext &context, LogicalUpdate &op,
54-
unique_ptr<PhysicalOperator> plan) override;
43+
optional_ptr<SchemaCatalogEntry> LookupSchema(CatalogTransaction transaction, const EntryLookupInfo &schema_lookup,
44+
OnEntryNotFound if_not_found) override;
45+
46+
PhysicalOperator &PlanCreateTableAs(ClientContext &context, PhysicalPlanGenerator &planner, LogicalCreateTable &op,
47+
PhysicalOperator &plan) override;
48+
PhysicalOperator &PlanInsert(ClientContext &context, PhysicalPlanGenerator &planner, LogicalInsert &op,
49+
optional_ptr<PhysicalOperator> plan) override;
50+
PhysicalOperator &PlanDelete(ClientContext &context, PhysicalPlanGenerator &planner, LogicalDelete &op,
51+
PhysicalOperator &plan) override;
52+
PhysicalOperator &PlanUpdate(ClientContext &context, PhysicalPlanGenerator &planner, LogicalUpdate &op,
53+
PhysicalOperator &plan) override;
54+
5555
unique_ptr<LogicalOperator> BindCreateIndex(Binder &binder, CreateStatement &stmt, TableCatalogEntry &table,
5656
unique_ptr<LogicalOperator> plan) override;
5757

src/include/storage/postgres_schema_entry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PostgresSchemaEntry : public SchemaCatalogEntry {
4242
void Scan(ClientContext &context, CatalogType type, const std::function<void(CatalogEntry &)> &callback) override;
4343
void Scan(CatalogType type, const std::function<void(CatalogEntry &)> &callback) override;
4444
void DropEntry(ClientContext &context, DropInfo &info) override;
45-
optional_ptr<CatalogEntry> GetEntry(CatalogTransaction transaction, CatalogType type, const string &name) override;
45+
optional_ptr<CatalogEntry> LookupEntry(CatalogTransaction transaction, const EntryLookupInfo &lookup_info) override;
4646

4747
static bool SchemaIsInternal(const string &name);
4848

src/storage/postgres_catalog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ void PostgresCatalog::ScanSchemas(ClientContext &context, std::function<void(Sch
138138
schemas.Scan(context, [&](CatalogEntry &schema) { callback(schema.Cast<PostgresSchemaEntry>()); });
139139
}
140140

141-
optional_ptr<SchemaCatalogEntry> PostgresCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
142-
OnEntryNotFound if_not_found,
143-
QueryErrorContext error_context) {
141+
optional_ptr<SchemaCatalogEntry> PostgresCatalog::LookupSchema(CatalogTransaction transaction, const EntryLookupInfo &schema_lookup,
142+
OnEntryNotFound if_not_found) {
143+
auto schema_name = schema_lookup.GetEntryName();
144144
if (schema_name == DEFAULT_SCHEMA) {
145-
return GetSchema(transaction, default_schema, if_not_found, error_context);
145+
schema_name = default_schema;
146146
}
147147
auto &postgres_transaction = PostgresTransaction::Get(transaction.GetContext(), *this);
148148
if (schema_name == "pg_temp") {
149-
return GetSchema(transaction, postgres_transaction.GetTemporarySchema(), if_not_found, error_context);
149+
schema_name = postgres_transaction.GetTemporarySchema();
150150
}
151151
auto entry = schemas.GetEntry(transaction.GetContext(), schema_name);
152152
if (!entry && if_not_found != OnEntryNotFound::RETURN_NULL) {

src/storage/postgres_delete.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,16 @@ InsertionOrderPreservingMap<string> PostgresDelete::ParamsToString() const {
119119
//===--------------------------------------------------------------------===//
120120
// Plan
121121
//===--------------------------------------------------------------------===//
122-
unique_ptr<PhysicalOperator> PostgresCatalog::PlanDelete(ClientContext &context, LogicalDelete &op,
123-
unique_ptr<PhysicalOperator> plan) {
122+
PhysicalOperator &PostgresCatalog::PlanDelete(ClientContext &context, PhysicalPlanGenerator &planner, LogicalDelete &op, PhysicalOperator &plan) {
124123
if (op.return_chunk) {
125124
throw BinderException("RETURNING clause not yet supported for deletion of a Postgres table");
126125
}
127126
auto &bound_ref = op.expressions[0]->Cast<BoundReferenceExpression>();
128-
PostgresCatalog::MaterializePostgresScans(*plan);
127+
PostgresCatalog::MaterializePostgresScans(plan);
129128

130-
auto insert = make_uniq<PostgresDelete>(op, op.table, bound_ref.index);
131-
insert->children.push_back(std::move(plan));
132-
return std::move(insert);
129+
auto &delete_op = planner.Make<PostgresDelete>(op, op.table, bound_ref.index);
130+
delete_op.children.push_back(plan);
131+
return delete_op;
133132
}
134133

135134
} // namespace duckdb

src/storage/postgres_index.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class LogicalPostgresCreateIndex : public LogicalExtensionOperator {
5656
unique_ptr<CreateIndexInfo> info;
5757
TableCatalogEntry &table;
5858

59-
unique_ptr<PhysicalOperator> CreatePlan(ClientContext &context, PhysicalPlanGenerator &generator) override {
60-
return make_uniq<PostgresCreateIndex>(std::move(info), table);
59+
PhysicalOperator &CreatePlan(ClientContext &context, PhysicalPlanGenerator &planner) override {
60+
return planner.Make<PostgresCreateIndex>(std::move(info), table);
6161
}
6262

6363
void Serialize(Serializer &serializer) const override {

src/storage/postgres_insert.cpp

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -153,41 +153,41 @@ InsertionOrderPreservingMap<string> PostgresInsert::ParamsToString() const {
153153
//===--------------------------------------------------------------------===//
154154
// Plan
155155
//===--------------------------------------------------------------------===//
156-
unique_ptr<PhysicalOperator> AddCastToPostgresTypes(ClientContext &context, unique_ptr<PhysicalOperator> plan) {
156+
PhysicalOperator &AddCastToPostgresTypes(ClientContext &context, PhysicalPlanGenerator &planner, PhysicalOperator &plan) {
157157
// check if we need to cast anything
158158
bool require_cast = false;
159-
auto &child_types = plan->GetTypes();
159+
auto &child_types = plan.GetTypes();
160160
for (auto &type : child_types) {
161161
auto postgres_type = PostgresUtils::ToPostgresType(type);
162162
if (postgres_type != type) {
163163
require_cast = true;
164164
break;
165165
}
166166
}
167-
if (require_cast) {
168-
vector<LogicalType> postgres_types;
169-
vector<unique_ptr<Expression>> select_list;
170-
for (idx_t i = 0; i < child_types.size(); i++) {
171-
auto &type = child_types[i];
172-
unique_ptr<Expression> expr;
173-
expr = make_uniq<BoundReferenceExpression>(type, i);
174-
175-
auto postgres_type = PostgresUtils::ToPostgresType(type);
176-
if (postgres_type != type) {
177-
// add a cast
178-
expr = BoundCastExpression::AddCastToType(context, std::move(expr), postgres_type);
179-
}
180-
postgres_types.push_back(std::move(postgres_type));
181-
select_list.push_back(std::move(expr));
182-
}
183-
// we need to cast: add casts
184-
auto proj = make_uniq<PhysicalProjection>(std::move(postgres_types), std::move(select_list),
185-
plan->estimated_cardinality);
186-
proj->children.push_back(std::move(plan));
187-
plan = std::move(proj);
188-
}
189-
190-
return plan;
167+
if (!require_cast) {
168+
return plan;
169+
}
170+
171+
vector<LogicalType> postgres_types;
172+
vector<unique_ptr<Expression>> select_list;
173+
for (idx_t i = 0; i < child_types.size(); i++) {
174+
auto &type = child_types[i];
175+
unique_ptr<Expression> expr;
176+
expr = make_uniq<BoundReferenceExpression>(type, i);
177+
178+
auto postgres_type = PostgresUtils::ToPostgresType(type);
179+
if (postgres_type != type) {
180+
// add a cast
181+
expr = BoundCastExpression::AddCastToType(context, std::move(expr), postgres_type);
182+
}
183+
postgres_types.push_back(std::move(postgres_type));
184+
select_list.push_back(std::move(expr));
185+
}
186+
187+
// we need to cast: add casts
188+
auto &proj = planner.Make<PhysicalProjection>(std::move(postgres_types), std::move(select_list), plan.estimated_cardinality);
189+
proj.children.push_back(plan);
190+
return proj;
191191
}
192192

193193
bool PostgresCatalog::IsPostgresScan(const string &name) {
@@ -206,36 +206,34 @@ void PostgresCatalog::MaterializePostgresScans(PhysicalOperator &op) {
206206
}
207207
}
208208
for (auto &child : op.children) {
209-
MaterializePostgresScans(*child);
209+
MaterializePostgresScans(child);
210210
}
211211
}
212212

213-
unique_ptr<PhysicalOperator> PostgresCatalog::PlanInsert(ClientContext &context, LogicalInsert &op,
214-
unique_ptr<PhysicalOperator> plan) {
213+
PhysicalOperator &PostgresCatalog::PlanInsert(ClientContext &context, PhysicalPlanGenerator &planner, LogicalInsert &op, optional_ptr<PhysicalOperator> plan) {
215214
if (op.return_chunk) {
216215
throw BinderException("RETURNING clause not yet supported for insertion into Postgres table");
217216
}
218217
if (op.action_type != OnConflictAction::THROW) {
219218
throw BinderException("ON CONFLICT clause not yet supported for insertion into Postgres table");
220219
}
221-
MaterializePostgresScans(*plan);
222220

223-
plan = AddCastToPostgresTypes(context, std::move(plan));
221+
D_ASSERT(plan);
222+
MaterializePostgresScans(*plan);
223+
auto &inner_plan = AddCastToPostgresTypes(context, planner, *plan);
224224

225-
auto insert = make_uniq<PostgresInsert>(op, op.table, op.column_index_map);
226-
insert->children.push_back(std::move(plan));
227-
return std::move(insert);
225+
auto &insert = planner.Make<PostgresInsert>(op, op.table, op.column_index_map);
226+
insert.children.push_back(inner_plan);
227+
return insert;
228228
}
229229

230-
unique_ptr<PhysicalOperator> PostgresCatalog::PlanCreateTableAs(ClientContext &context, LogicalCreateTable &op,
231-
unique_ptr<PhysicalOperator> plan) {
232-
plan = AddCastToPostgresTypes(context, std::move(plan));
233-
234-
MaterializePostgresScans(*plan);
230+
PhysicalOperator &PostgresCatalog::PlanCreateTableAs(ClientContext &context, PhysicalPlanGenerator &planner, LogicalCreateTable &op, PhysicalOperator &plan) {
231+
auto &inner_plan = AddCastToPostgresTypes(context, planner, plan);
232+
MaterializePostgresScans(inner_plan);
235233

236-
auto insert = make_uniq<PostgresInsert>(op, op.schema, std::move(op.info));
237-
insert->children.push_back(std::move(plan));
238-
return std::move(insert);
234+
auto &insert = planner.Make<PostgresInsert>(op, op.schema, std::move(op.info));
235+
insert.children.push_back(inner_plan);
236+
return insert;
239237
}
240238

241239
} // namespace duckdb

src/storage/postgres_schema_entry.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ void PostgresSchemaEntry::DropEntry(ClientContext &context, DropInfo &info) {
183183
GetCatalogSet(info.type).DropEntry(context, info);
184184
}
185185

186-
optional_ptr<CatalogEntry> PostgresSchemaEntry::GetEntry(CatalogTransaction transaction, CatalogType type,
187-
const string &name) {
188-
if (!CatalogTypeIsSupported(type)) {
186+
optional_ptr<CatalogEntry> PostgresSchemaEntry::LookupEntry(CatalogTransaction transaction, const EntryLookupInfo &lookup_info) {
187+
auto catalog_type = lookup_info.GetCatalogType();
188+
if (!CatalogTypeIsSupported(catalog_type)) {
189189
return nullptr;
190190
}
191-
return GetCatalogSet(type).GetEntry(transaction.GetContext(), name);
191+
return GetCatalogSet(catalog_type).GetEntry(transaction.GetContext(), lookup_info.GetEntryName());
192192
}
193193

194194
PostgresCatalogSet &PostgresSchemaEntry::GetCatalogSet(CatalogType type) {

src/storage/postgres_update.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ InsertionOrderPreservingMap<string> PostgresUpdate::ParamsToString() const {
180180
//===--------------------------------------------------------------------===//
181181
// Plan
182182
//===--------------------------------------------------------------------===//
183-
unique_ptr<PhysicalOperator> PostgresCatalog::PlanUpdate(ClientContext &context, LogicalUpdate &op,
184-
unique_ptr<PhysicalOperator> plan) {
183+
PhysicalOperator &PostgresCatalog::PlanUpdate(ClientContext &context, PhysicalPlanGenerator &planner, LogicalUpdate &op, PhysicalOperator &plan) {
185184
if (op.return_chunk) {
186185
throw BinderException("RETURNING clause not yet supported for updates of a Postgres table");
187186
}
@@ -190,10 +189,11 @@ unique_ptr<PhysicalOperator> PostgresCatalog::PlanUpdate(ClientContext &context,
190189
throw BinderException("SET DEFAULT is not yet supported for updates of a Postgres table");
191190
}
192191
}
193-
PostgresCatalog::MaterializePostgresScans(*plan);
194-
auto insert = make_uniq<PostgresUpdate>(op, op.table, std::move(op.columns));
195-
insert->children.push_back(std::move(plan));
196-
return std::move(insert);
192+
193+
PostgresCatalog::MaterializePostgresScans(plan);
194+
auto &update = planner.Make<PostgresUpdate>(op, op.table, std::move(op.columns));
195+
update.children.push_back(plan);
196+
return update;
197197
}
198198

199199
} // namespace duckdb

test/sql/scanner/daterange_array.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ loop i 0 2
2020
query II
2121
SELECT * from daterange_array;
2222
----
23-
1108 [["2010-01-01 14:30:00","2010-01-01 15:30:00")]
23+
1108 ['["2010-01-01 14:30:00","2010-01-01 15:30:00")']
2424

2525
statement ok
2626
USE memory

0 commit comments

Comments
 (0)