@@ -769,6 +769,11 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, Cat
769
769
770
770
if (if_not_found == OnEntryNotFound::RETURN_NULL) {
771
771
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)};
772
777
} else {
773
778
auto except = CreateMissingEntryException (retriever, name, type, schemas, error_context);
774
779
return {nullptr , nullptr , ErrorData (except)};
@@ -805,6 +810,11 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, vec
805
810
806
811
if (if_not_found == OnEntryNotFound::RETURN_NULL) {
807
812
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)};
808
818
} else {
809
819
auto except = CreateMissingEntryException (retriever, name, type, schemas, error_context);
810
820
return {nullptr , nullptr , ErrorData (except)};
0 commit comments