Skip to content

Commit 1f643ee

Browse files
committed
Fix #272: no longer treat main schema as a special schema (requires upstream DuckDB fixes)
1 parent ef6c95e commit 1f643ee

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

Diff for: src/include/storage/postgres_catalog.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class PostgresCatalog : public Catalog {
3131
string GetCatalogType() override {
3232
return "postgres";
3333
}
34+
string GetDefaultSchema() const override {
35+
return default_schema.empty() ? "public" : default_schema;
36+
}
3437

3538
optional_ptr<CatalogEntry> CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) override;
3639

Diff for: src/storage/postgres_catalog.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ void PostgresCatalog::ScanSchemas(ClientContext &context, std::function<void(Sch
6666
optional_ptr<SchemaCatalogEntry> PostgresCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
6767
OnEntryNotFound if_not_found,
6868
QueryErrorContext error_context) {
69-
if (schema_name == DEFAULT_SCHEMA) {
70-
return GetSchema(transaction, default_schema, if_not_found, error_context);
71-
}
7269
auto &postgres_transaction = PostgresTransaction::Get(transaction.GetContext(), *this);
7370
if (schema_name == "pg_temp") {
7471
return GetSchema(transaction, postgres_transaction.GetTemporarySchema(), if_not_found, error_context);

Diff for: test/other.sql

+4
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,7 @@ INSERT INTO varchars_fixed_len VALUES ('hello'), ('world'), ('maxlength1'), ('he
164164
create table tbl_with_constraints(pk int primary key, c1 int not null, c2 int, c3 int not null);
165165
create table tbl_with_more_constraints(pk1 int, pk2 int, fk1 int references tbl_with_constraints(pk), primary key (pk1, pk2));
166166
create table tbl_with_unique_constraints(pk int unique, c1 int not null, c2 int, c3 int not null, unique(c2, c3));
167+
168+
create schema main;
169+
create table main.main_tbl(i int);
170+
insert into main.main_tbl values (42), (NULL);

Diff for: test/sql/storage/attach_main_schema.test

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# name: test/sql/storage/attach_main_schema.test
2+
# description: Test usage of the main schema in Postgres
3+
# group: [storage]
4+
5+
require postgres_scanner
6+
7+
require-env POSTGRES_TEST_DATABASE_AVAILABLE
8+
9+
statement ok
10+
PRAGMA enable_verification
11+
12+
statement ok
13+
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)
14+
15+
query I
16+
SELECT * FROM s.main.main_tbl
17+
----
18+
42
19+
NULL
20+
21+
statement ok
22+
USE s
23+
24+
query I
25+
SELECT * FROM main.main_tbl
26+
----
27+
42
28+
NULL

0 commit comments

Comments
 (0)