22428 {
22429 if (set_type == CatalogSetPathType::SET_SCHEMA && new_paths.size() != 1) {
22430 throw CatalogException("%s can set only 1 schema. This has %d", GetSetName(set_type), new_paths.size());
22431 }
22432 for (auto &path : new_paths) {
22433 if (set_type == CatalogSetPathType::SET_DIRECTLY) {
22434 if (path.catalog.empty() || path.schema.empty()) {
22435 throw InternalException("SET_WITHOUT_VERIFICATION requires a fully qualified set path");
22436 }
22437 continue;
22438 }
22439 auto schema_entry =
Catalog::GetSchema(context, path.catalog, path.schema, OnEntryNotFound::RETURN_NULL);
22440 if (schema_entry) {
22441
22442 if (path.catalog.empty()) {
22443 path.catalog = GetDefault().catalog;
22444 }
22445 continue;
22446 }
22447
22448 if (path.catalog.empty()) {
22450 if (catalog) {
22451 auto schema = catalog->GetSchema(context, catalog->GetDefaultSchema(), OnEntryNotFound::RETURN_NULL);
22452 if (schema) {
22453 path.catalog = std::move(path.schema);
22454 path.schema = schema->name;
22455 continue;
22456 }
22457 }
22458 }
22459 throw CatalogException("%s: No catalog + schema named \"%s\" found.", GetSetName(set_type), path.ToString());
22460 }
22461 if (set_type == CatalogSetPathType::SET_SCHEMA) {
22462 if (new_paths[0].catalog == TEMP_CATALOG || new_paths[0].catalog == SYSTEM_CATALOG) {
22463 throw CatalogException("%s cannot be set to internal schema \"%s\"", GetSetName(set_type),
22464 new_paths[0].catalog);
22465 }
22466 }
22468}
DUCKDB_API SchemaCatalogEntry & GetSchema(ClientContext &context, const EntryLookupInfo &schema_lookup)
Returns the schema object with the specified name, or throws an exception if it does not exist.
Definition duckdb.cpp:7493
static DUCKDB_API optional_ptr< Catalog > GetCatalogEntry(ClientContext &context, const string &catalog_name)
Gets the specified Catalog from the database if it exists.
Definition duckdb.cpp:7198