//===----------------------------------------------------------------------===// // DuckDB // // duckdb/catalog/catalog_search_path.hpp // // //===----------------------------------------------------------------------===// #pragma once #include #include "duckdb/common/enums/catalog_type.hpp" #include "duckdb/common/string.hpp" #include "duckdb/common/vector.hpp" #include "duckdb/common/types/value.hpp" namespace duckdb { class ClientContext; struct CatalogSearchEntry { CatalogSearchEntry(string catalog, string schema); string catalog; string schema; public: string ToString() const; static string ListToString(const vector &input); static CatalogSearchEntry Parse(const string &input); static vector ParseList(const string &input); private: static CatalogSearchEntry ParseInternal(const string &input, idx_t &pos); static string WriteOptionallyQuoted(const string &input); }; enum class CatalogSetPathType { SET_SCHEMA, SET_SCHEMAS }; //! The schema search path, in order by which entries are searched if no schema entry is provided class CatalogSearchPath { public: DUCKDB_API explicit CatalogSearchPath(ClientContext &client_p); CatalogSearchPath(const CatalogSearchPath &other) = delete; DUCKDB_API void Set(CatalogSearchEntry new_value, CatalogSetPathType set_type); DUCKDB_API void Set(vector new_paths, CatalogSetPathType set_type); DUCKDB_API void Reset(); DUCKDB_API const vector &Get(); const vector &GetSetPaths() { return set_paths; } DUCKDB_API const CatalogSearchEntry &GetDefault(); DUCKDB_API string GetDefaultSchema(const string &catalog); DUCKDB_API string GetDefaultCatalog(const string &schema); DUCKDB_API vector GetSchemasForCatalog(const string &catalog); DUCKDB_API vector GetCatalogsForSchema(const string &schema); DUCKDB_API bool SchemaInSearchPath(ClientContext &context, const string &catalog_name, const string &schema_name); private: void SetPaths(vector new_paths); string GetSetName(CatalogSetPathType set_type); private: ClientContext &context; vector paths; //! Only the paths that were explicitly set (minus the always included paths) vector set_paths; }; } // namespace duckdb