Skip to content

Commit c541acb

Browse files
committed
when an entry is missing, throw exception immediately if default catalog is detached
1 parent 57af6b7 commit c541acb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/catalog/catalog.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,11 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, Cat
769769

770770
if (if_not_found == OnEntryNotFound::RETURN_NULL) {
771771
return {nullptr, nullptr, ErrorData()};
772+
}
773+
// Check if the default database is actually attached. CreateMissingEntryException will throw binder exception otherwise.
774+
if (!GetCatalogEntry(context, GetDefaultCatalog(retriever))) {
775+
auto except = CatalogException("%s with name %s does not exist!", CatalogTypeToString(type), name);
776+
return {nullptr, nullptr, ErrorData(except)};
772777
} else {
773778
auto except = CreateMissingEntryException(retriever, name, type, schemas, error_context);
774779
return {nullptr, nullptr, ErrorData(except)};
@@ -805,6 +810,11 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, vec
805810

806811
if (if_not_found == OnEntryNotFound::RETURN_NULL) {
807812
return {nullptr, nullptr, ErrorData()};
813+
}
814+
// Check if the default database is actually attached. CreateMissingEntryException will throw binder exception otherwise.
815+
if (!GetCatalogEntry(context, GetDefaultCatalog(retriever))) {
816+
auto except = CatalogException("%s with name %s does not exist!", CatalogTypeToString(type), name);
817+
return {nullptr, nullptr, ErrorData(except)};
808818
} else {
809819
auto except = CreateMissingEntryException(retriever, name, type, schemas, error_context);
810820
return {nullptr, nullptr, ErrorData(except)};

0 commit comments

Comments
 (0)