Skip to content

Commit 2f77f6d

Browse files
authored
Merge pull request #290 from Mytherin/mainschema
Fix #272: no longer treat main schema as a special schema
2 parents 96df45d + 0a15573 commit 2f77f6d

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

src/include/storage/postgres_catalog.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class PostgresCatalog : public Catalog {
3333
string GetCatalogType() override {
3434
return "postgres";
3535
}
36+
string GetDefaultSchema() const override {
37+
return default_schema.empty() ? "public" : default_schema;
38+
}
3639

3740
static string GetConnectionString(ClientContext &context, const string &attach_path, string secret_name);
3841

src/storage/postgres_catalog.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ void PostgresCatalog::ScanSchemas(ClientContext &context, std::function<void(Sch
141141
optional_ptr<SchemaCatalogEntry> PostgresCatalog::LookupSchema(CatalogTransaction transaction, const EntryLookupInfo &schema_lookup,
142142
OnEntryNotFound if_not_found) {
143143
auto schema_name = schema_lookup.GetEntryName();
144-
if (schema_name == DEFAULT_SCHEMA) {
145-
schema_name = default_schema;
146-
}
147144
auto &postgres_transaction = PostgresTransaction::Get(transaction.GetContext(), *this);
148145
if (schema_name == "pg_temp") {
149146
schema_name = postgres_transaction.GetTemporarySchema();

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);
+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)