@@ -328,6 +328,9 @@ struct CatalogLookup {
328
328
CatalogLookup (Catalog &catalog, CatalogType catalog_type, string schema_p, string name_p)
329
329
: catalog(catalog), schema(std::move(schema_p)), name(std::move(name_p)), lookup_info(catalog_type, name) {
330
330
}
331
+ CatalogLookup (Catalog &catalog, string schema_p, const EntryLookupInfo &lookup_p)
332
+ : catalog(catalog), schema(std::move(schema_p)), name(lookup_p.GetEntryName()), lookup_info(lookup_p, name) {
333
+ }
331
334
332
335
Catalog &catalog;
333
336
string schema;
@@ -757,11 +760,14 @@ CatalogException Catalog::CreateMissingEntryException(CatalogEntryRetriever &ret
757
760
did_you_mean = StringUtil::Join (suggestions, " or " );
758
761
}
759
762
760
- return CatalogException::MissingEntry (type, entry_name, did_you_mean, lookup_info. GetErrorContext () );
763
+ return CatalogException::MissingEntry (lookup_info, did_you_mean);
761
764
}
762
765
763
766
CatalogEntryLookup Catalog::TryLookupEntryInternal (CatalogTransaction transaction, const string &schema,
764
767
const EntryLookupInfo &lookup_info) {
768
+ if (lookup_info.GetAtClause () && !SupportsTimeTravel ()) {
769
+ return {nullptr , nullptr , ErrorData (BinderException (" Catalog type does not support time travel" ))};
770
+ }
765
771
auto schema_lookup = EntryLookupInfo::SchemaLookup (lookup_info, schema);
766
772
auto schema_entry = LookupSchema (transaction, schema_lookup, OnEntryNotFound::RETURN_NULL);
767
773
if (!schema_entry) {
@@ -833,6 +839,8 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, con
833
839
const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found) {
834
840
auto &context = retriever.GetContext ();
835
841
reference_set_t <SchemaCatalogEntry> schemas;
842
+ bool all_errors = true ;
843
+ ErrorData error_data;
836
844
for (auto &lookup : lookups) {
837
845
auto transaction = lookup.catalog .GetCatalogTransaction (context);
838
846
auto result = lookup.catalog .TryLookupEntryInternal (transaction, lookup.schema , lookup.lookup_info );
@@ -842,6 +850,14 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, con
842
850
if (result.schema ) {
843
851
schemas.insert (*result.schema );
844
852
}
853
+ if (!result.error .HasError ()) {
854
+ all_errors = false ;
855
+ } else {
856
+ error_data = std::move (result.error );
857
+ }
858
+ }
859
+ if (all_errors && error_data.HasError ()) {
860
+ error_data.Throw ();
845
861
}
846
862
847
863
if (if_not_found == OnEntryNotFound::RETURN_NULL) {
@@ -916,11 +932,9 @@ CatalogEntryLookup Catalog::TryLookupEntry(CatalogEntryRetriever &retriever, con
916
932
D_ASSERT (catalog_entry);
917
933
auto lookup_behavior = catalog_entry->CatalogTypeLookupRule (lookup_info.GetCatalogType ());
918
934
if (lookup_behavior == CatalogLookupBehavior::STANDARD) {
919
- lookups.emplace_back (*catalog_entry, lookup_info.GetCatalogType (), entry.schema ,
920
- lookup_info.GetEntryName ());
935
+ lookups.emplace_back (*catalog_entry, entry.schema , lookup_info);
921
936
} else if (lookup_behavior == CatalogLookupBehavior::LOWER_PRIORITY) {
922
- final_lookups.emplace_back (*catalog_entry, lookup_info.GetCatalogType (), entry.schema ,
923
- lookup_info.GetEntryName ());
937
+ final_lookups.emplace_back (*catalog_entry, entry.schema , lookup_info);
924
938
}
925
939
}
926
940
@@ -955,6 +969,12 @@ CatalogEntry &Catalog::GetEntry(ClientContext &context, CatalogType catalog_type
955
969
return GetEntry (context, catalog_name, schema_name, lookup_info);
956
970
}
957
971
972
+ optional_ptr<CatalogEntry> Catalog::GetEntry (ClientContext &context, CatalogType catalog_type, const string &schema,
973
+ const string &name, OnEntryNotFound if_not_found) {
974
+ EntryLookupInfo lookup_info (catalog_type, name);
975
+ return GetEntry (context, schema, lookup_info, if_not_found);
976
+ }
977
+
958
978
CatalogEntry &Catalog::GetEntry (ClientContext &context, CatalogType catalog_type, const string &schema_name,
959
979
const string &name) {
960
980
EntryLookupInfo lookup_info (catalog_type, name);
0 commit comments