Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::CatalogSearchPath Class Reference

The schema search path, in order by which entries are searched if no schema entry is provided. More...

Collaboration diagram for duckdb::CatalogSearchPath:

Public Member Functions

DUCKDB_API CatalogSearchPath (ClientContext &client_p)
 
DUCKDB_API CatalogSearchPath (ClientContext &client_p, vector< CatalogSearchEntry > entries)
 
 CatalogSearchPath (const CatalogSearchPath &other)=delete
 
DUCKDB_API void Set (CatalogSearchEntry new_value, CatalogSetPathType set_type)
 
DUCKDB_API void Set (vector< CatalogSearchEntry > new_paths, CatalogSetPathType set_type)
 
DUCKDB_API void Reset ()
 
DUCKDB_API vector< CatalogSearchEntryGet () const
 
const vector< CatalogSearchEntry > & GetSetPaths () const
 
DUCKDB_API const CatalogSearchEntryGetDefault () const
 
DUCKDB_API string GetDefaultSchema (const string &catalog) const
 FIXME: this method is deprecated.
 
DUCKDB_API string GetDefaultSchema (ClientContext &context, const string &catalog) const
 
DUCKDB_API string GetDefaultCatalog (const string &schema) const
 
DUCKDB_API vector< string > GetSchemasForCatalog (const string &catalog) const
 
DUCKDB_API vector< string > GetCatalogsForSchema (const string &schema) const
 
DUCKDB_API bool SchemaInSearchPath (ClientContext &context, const string &catalog_name, const string &schema_name) const
 

Private Member Functions

void SetPathsInternal (vector< CatalogSearchEntry > new_paths)
 Set paths without checking if they exist.
 
string GetSetName (CatalogSetPathType set_type)
 

Private Attributes

ClientContextcontext
 
vector< CatalogSearchEntrypaths
 
vector< CatalogSearchEntryset_paths
 Only the paths that were explicitly set (minus the always included paths)
 

Detailed Description

The schema search path, in order by which entries are searched if no schema entry is provided.

Constructor & Destructor Documentation

◆ CatalogSearchPath() [1/2]

duckdb::CatalogSearchPath::CatalogSearchPath ( ClientContext client_p)
explicit
22409 : CatalogSearchPath(context_p, {}) {
22410}

◆ CatalogSearchPath() [2/2]

duckdb::CatalogSearchPath::CatalogSearchPath ( ClientContext client_p,
vector< CatalogSearchEntry entries 
)
22405 : context(context_p) {
22406 SetPathsInternal(std::move(entries));
22407}
void SetPathsInternal(vector< CatalogSearchEntry > new_paths)
Set paths without checking if they exist.
Definition duckdb.cpp:22559

Member Function Documentation

◆ Set() [1/2]

void duckdb::CatalogSearchPath::Set ( CatalogSearchEntry  new_value,
CatalogSetPathType  set_type 
)
22470 {
22471 vector<CatalogSearchEntry> new_paths {std::move(new_value)};
22472 Set(std::move(new_paths), set_type);
22473}

◆ Set() [2/2]

void duckdb::CatalogSearchPath::Set ( vector< CatalogSearchEntry new_paths,
CatalogSetPathType  set_type 
)
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 // we are setting a schema - update the catalog and schema
22442 if (path.catalog.empty()) {
22443 path.catalog = GetDefault().catalog;
22444 }
22445 continue;
22446 }
22447 // only schema supplied - check if this is a catalog instead
22448 if (path.catalog.empty()) {
22449 auto catalog = Catalog::GetCatalogEntry(context, path.schema);
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 }
22467 SetPathsInternal(std::move(new_paths));
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

◆ Reset()

void duckdb::CatalogSearchPath::Reset ( )
22412 {
22413 vector<CatalogSearchEntry> empty;
22414 SetPathsInternal(empty);
22415}

◆ Get()

vector< CatalogSearchEntry > duckdb::CatalogSearchPath::Get ( ) const
22475 {
22476 vector<CatalogSearchEntry> res;
22477 for (auto &path : paths) {
22478 if (path.schema.empty()) {
22479 continue;
22480 }
22481 res.emplace_back(path);
22482 }
22483 return res;
22484}

◆ GetSetPaths()

const vector< CatalogSearchEntry > & duckdb::CatalogSearchPath::GetSetPaths ( ) const
inline
64 {
65 return set_paths;
66 }
vector< CatalogSearchEntry > set_paths
Only the paths that were explicitly set (minus the always included paths)
Definition duckdb.cpp:88

◆ GetDefault()

const CatalogSearchEntry & duckdb::CatalogSearchPath::GetDefault ( ) const
22553 {
22554 D_ASSERT(paths.size() >= 2);
22555 D_ASSERT(!paths[1].schema.empty());
22556 return paths[1];
22557}

◆ GetDefaultSchema() [1/2]

string duckdb::CatalogSearchPath::GetDefaultSchema ( const string &  catalog) const

FIXME: this method is deprecated.

22486 {
22487 for (auto &path : paths) {
22488 if (path.catalog == TEMP_CATALOG) {
22489 continue;
22490 }
22491 if (StringUtil::CIEquals(path.catalog, catalog)) {
22492 return path.schema;
22493 }
22494 }
22495 return DEFAULT_SCHEMA;
22496}
static DUCKDB_API bool CIEquals(const string &l1, const string &l2)
Case insensitive equals.
Here is the call graph for this function:

◆ GetDefaultSchema() [2/2]

string duckdb::CatalogSearchPath::GetDefaultSchema ( ClientContext context,
const string &  catalog 
) const
22498 {
22499 for (auto &path : paths) {
22500 if (path.catalog == TEMP_CATALOG) {
22501 continue;
22502 }
22503 if (StringUtil::CIEquals(path.catalog, catalog)) {
22504 return path.schema;
22505 }
22506 }
22507 auto catalog_entry = Catalog::GetCatalogEntry(context, catalog);
22508 if (catalog_entry) {
22509 return catalog_entry->GetDefaultSchema();
22510 }
22511 return DEFAULT_SCHEMA;
22512}

◆ GetDefaultCatalog()

string duckdb::CatalogSearchPath::GetDefaultCatalog ( const string &  schema) const
22514 {
22515 if (DefaultSchemaGenerator::IsDefaultSchema(schema)) {
22516 return SYSTEM_CATALOG;
22517 }
22518 for (auto &path : paths) {
22519 if (path.catalog == TEMP_CATALOG) {
22520 continue;
22521 }
22522 if (StringUtil::CIEquals(path.schema, schema)) {
22523 return path.catalog;
22524 }
22525 }
22526 return INVALID_CATALOG;
22527}

◆ GetSchemasForCatalog()

vector< string > duckdb::CatalogSearchPath::GetSchemasForCatalog ( const string &  catalog) const
22543 {
22544 vector<string> schemas;
22545 for (auto &path : paths) {
22546 if (!path.schema.empty() && StringUtil::CIEquals(path.catalog, catalog)) {
22547 schemas.push_back(path.schema);
22548 }
22549 }
22550 return schemas;
22551}

◆ GetCatalogsForSchema()

vector< string > duckdb::CatalogSearchPath::GetCatalogsForSchema ( const string &  schema) const
22529 {
22530 vector<string> catalogs;
22531 if (DefaultSchemaGenerator::IsDefaultSchema(schema)) {
22532 catalogs.push_back(SYSTEM_CATALOG);
22533 } else {
22534 for (auto &path : paths) {
22535 if (StringUtil::CIEquals(path.schema, schema) || path.schema.empty()) {
22536 catalogs.push_back(path.catalog);
22537 }
22538 }
22539 }
22540 return catalogs;
22541}

◆ SchemaInSearchPath()

bool duckdb::CatalogSearchPath::SchemaInSearchPath ( ClientContext context,
const string &  catalog_name,
const string &  schema_name 
) const
22574 {
22575 for (auto &path : paths) {
22576 if (!StringUtil::CIEquals(path.schema, schema_name)) {
22577 continue;
22578 }
22579 if (StringUtil::CIEquals(path.catalog, catalog_name)) {
22580 return true;
22581 }
22582 if (IsInvalidCatalog(path.catalog) &&
22583 StringUtil::CIEquals(catalog_name, DatabaseManager::GetDefaultDatabase(context))) {
22584 return true;
22585 }
22586 }
22587 return false;
22588}

◆ SetPathsInternal()

void duckdb::CatalogSearchPath::SetPathsInternal ( vector< CatalogSearchEntry new_paths)
private

Set paths without checking if they exist.

22559 {
22560 this->set_paths = std::move(new_paths);
22561
22562 paths.clear();
22563 paths.reserve(set_paths.size() + 4);
22564 paths.emplace_back(TEMP_CATALOG, DEFAULT_SCHEMA);
22565 for (auto &path : set_paths) {
22566 paths.push_back(path);
22567 }
22568 paths.emplace_back(INVALID_CATALOG, DEFAULT_SCHEMA);
22569 paths.emplace_back(SYSTEM_CATALOG, DEFAULT_SCHEMA);
22570 paths.emplace_back(SYSTEM_CATALOG, "pg_catalog");
22571}

◆ GetSetName()

string duckdb::CatalogSearchPath::GetSetName ( CatalogSetPathType  set_type)
private
22417 {
22418 switch (set_type) {
22419 case CatalogSetPathType::SET_SCHEMA:
22420 return "SET schema";
22421 case CatalogSetPathType::SET_SCHEMAS:
22422 return "SET search_path";
22423 default:
22424 throw InternalException("Unrecognized CatalogSetPathType");
22425 }
22426}

The documentation for this class was generated from the following file: