Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #272: no longer treat main schema as a special schema #290

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion duckdb
Submodule duckdb updated 1034 files
3 changes: 3 additions & 0 deletions src/include/storage/postgres_catalog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class PostgresCatalog : public Catalog {
string GetCatalogType() override {
return "postgres";
}
string GetDefaultSchema() const override {
return default_schema.empty() ? "public" : default_schema;
}

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

Expand Down
3 changes: 0 additions & 3 deletions src/storage/postgres_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ void PostgresCatalog::ScanSchemas(ClientContext &context, std::function<void(Sch
optional_ptr<SchemaCatalogEntry> PostgresCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
OnEntryNotFound if_not_found,
QueryErrorContext error_context) {
if (schema_name == DEFAULT_SCHEMA) {
return GetSchema(transaction, default_schema, if_not_found, error_context);
}
auto &postgres_transaction = PostgresTransaction::Get(transaction.GetContext(), *this);
if (schema_name == "pg_temp") {
return GetSchema(transaction, postgres_transaction.GetTemporarySchema(), if_not_found, error_context);
Expand Down
4 changes: 4 additions & 0 deletions test/other.sql
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,7 @@ INSERT INTO varchars_fixed_len VALUES ('hello'), ('world'), ('maxlength1'), ('he
create table tbl_with_constraints(pk int primary key, c1 int not null, c2 int, c3 int not null);
create table tbl_with_more_constraints(pk1 int, pk2 int, fk1 int references tbl_with_constraints(pk), primary key (pk1, pk2));
create table tbl_with_unique_constraints(pk int unique, c1 int not null, c2 int, c3 int not null, unique(c2, c3));

create schema main;
create table main.main_tbl(i int);
insert into main.main_tbl values (42), (NULL);
28 changes: 28 additions & 0 deletions test/sql/storage/attach_main_schema.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# name: test/sql/storage/attach_main_schema.test
# description: Test usage of the main schema in Postgres
# group: [storage]

require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)

query I
SELECT * FROM s.main.main_tbl
----
42
NULL

statement ok
USE s

query I
SELECT * FROM main.main_tbl
----
42
NULL
Loading