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::DuckSchemaEntry Class Reference

A schema in the catalog. More...

Inheritance diagram for duckdb::DuckSchemaEntry:
Collaboration diagram for duckdb::DuckSchemaEntry:

Public Member Functions

 DuckSchemaEntry (Catalog &catalog, CreateSchemaInfo &info)
 
optional_ptr< CatalogEntryAddEntry (CatalogTransaction transaction, unique_ptr< StandardEntry > entry, OnCreateConflict on_conflict)
 
optional_ptr< CatalogEntryAddEntryInternal (CatalogTransaction transaction, unique_ptr< StandardEntry > entry, OnCreateConflict on_conflict, LogicalDependencyList dependencies)
 
optional_ptr< CatalogEntryCreateTable (CatalogTransaction transaction, BoundCreateTableInfo &info) override
 Creates a table with the given name in the schema.
 
optional_ptr< CatalogEntryCreateFunction (CatalogTransaction transaction, CreateFunctionInfo &info) override
 Create a scalar or aggregate function within the given schema.
 
optional_ptr< CatalogEntryCreateIndex (CatalogTransaction transaction, CreateIndexInfo &info, TableCatalogEntry &table) override
 Creates an index with the given name in the schema.
 
optional_ptr< CatalogEntryCreateView (CatalogTransaction transaction, CreateViewInfo &info) override
 Creates a view with the given name in the schema.
 
optional_ptr< CatalogEntryCreateSequence (CatalogTransaction transaction, CreateSequenceInfo &info) override
 Creates a sequence with the given name in the schema.
 
optional_ptr< CatalogEntryCreateTableFunction (CatalogTransaction transaction, CreateTableFunctionInfo &info) override
 Create a table function within the given schema.
 
optional_ptr< CatalogEntryCreateCopyFunction (CatalogTransaction transaction, CreateCopyFunctionInfo &info) override
 Create a copy function within the given schema.
 
optional_ptr< CatalogEntryCreatePragmaFunction (CatalogTransaction transaction, CreatePragmaFunctionInfo &info) override
 Create a pragma function within the given schema.
 
optional_ptr< CatalogEntryCreateCollation (CatalogTransaction transaction, CreateCollationInfo &info) override
 Create a collation within the given schema.
 
optional_ptr< CatalogEntryCreateCoordinateSystem (CatalogTransaction transaction, CreateCoordinateSystemInfo &info) override
 Create a coordiante system within the given schema.
 
optional_ptr< CatalogEntryCreateType (CatalogTransaction transaction, CreateTypeInfo &info) override
 Create a enum within the given schema.
 
void Alter (CatalogTransaction transaction, AlterInfo &info) override
 Alters a catalog entry.
 
void Scan (ClientContext &context, CatalogType type, const std::function< void(CatalogEntry &)> &callback) override
 Scan the specified catalog set, invoking the callback method for every entry.
 
void Scan (CatalogType type, const std::function< void(CatalogEntry &)> &callback) override
 Scan the specified catalog set, invoking the callback method for every committed entry.
 
void DropEntry (ClientContext &context, DropInfo &info) override
 Drops an entry from the schema.
 
optional_ptr< CatalogEntryLookupEntry (CatalogTransaction transaction, const EntryLookupInfo &lookup_info) override
 Lookup an entry in the schema.
 
CatalogSet::EntryLookup LookupEntryDetailed (CatalogTransaction transaction, const EntryLookupInfo &lookup_info) override
 
SimilarCatalogEntry GetSimilarEntry (CatalogTransaction transaction, const EntryLookupInfo &lookup_info) override
 
unique_ptr< CatalogEntryCopy (ClientContext &context) const override
 
void Verify (Catalog &catalog) override
 
CatalogSetGetCatalogSet (CatalogType type)
 Get the catalog set for the specified type.
 
- Public Member Functions inherited from duckdb::SchemaCatalogEntry
 SchemaCatalogEntry (Catalog &catalog, CreateSchemaInfo &info)
 
unique_ptr< CreateInfoGetInfo () const override
 
string ToSQL () const override
 Convert the catalog entry to a SQL string that can be used to re-construct the catalog entry.
 
optional_ptr< CatalogEntryCreateIndex (ClientContext &context, CreateIndexInfo &info, TableCatalogEntry &table)
 
DUCKDB_API optional_ptr< CatalogEntryGetEntry (CatalogTransaction transaction, CatalogType type, const string &name)
 
CatalogTransaction GetCatalogTransaction (ClientContext &context)
 
- Public Member Functions inherited from duckdb::InCatalogEntry
 InCatalogEntry (CatalogType type, Catalog &catalog, string name)
 
CatalogParentCatalog () override
 
const CatalogParentCatalog () const override
 
void Verify (Catalog &catalog) override
 
- Public Member Functions inherited from duckdb::CatalogEntry
 CatalogEntry (CatalogType type, Catalog &catalog, string name)
 
 CatalogEntry (CatalogType type, string name, idx_t oid)
 
virtual unique_ptr< CatalogEntryAlterEntry (ClientContext &context, AlterInfo &info)
 
virtual unique_ptr< CatalogEntryAlterEntry (CatalogTransaction transaction, AlterInfo &info)
 
virtual void UndoAlter (ClientContext &context, AlterInfo &info)
 
virtual void Rollback (CatalogEntry &prev_entry)
 
virtual void OnDrop ()
 
virtual void SetAsRoot ()
 Sets the CatalogEntry as the new root entry (i.e. the newest entry)
 
virtual SchemaCatalogEntryParentSchema ()
 
virtual const SchemaCatalogEntryParentSchema () const
 
void Serialize (Serializer &serializer) const
 
void SetChild (unique_ptr< CatalogEntry > child)
 
unique_ptr< CatalogEntryTakeChild ()
 
bool HasChild () const
 
bool HasParent () const
 
CatalogEntryChild ()
 
CatalogEntryParent ()
 
const CatalogEntryParent () const
 
template<class TARGET >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 

Private Member Functions

void OnDropEntry (CatalogTransaction transaction, CatalogEntry &entry)
 

Private Attributes

CatalogSet tables
 The catalog set holding the tables.
 
CatalogSet indexes
 The catalog set holding the indexes.
 
CatalogSet table_functions
 The catalog set holding the table functions.
 
CatalogSet copy_functions
 The catalog set holding the copy functions.
 
CatalogSet pragma_functions
 The catalog set holding the pragma functions.
 
CatalogSet functions
 The catalog set holding the scalar and aggregate functions.
 
CatalogSet sequences
 The catalog set holding the sequences.
 
CatalogSet collations
 The catalog set holding the collations.
 
CatalogSet types
 The catalog set holding the types.
 
CatalogSet coordinate_systems
 The catalog set holding the coordinate systems.
 

Additional Inherited Members

- Static Public Member Functions inherited from duckdb::CatalogEntry
static unique_ptr< CreateInfoDeserialize (Deserializer &deserializer)
 
- Public Attributes inherited from duckdb::InCatalogEntry
Catalogcatalog
 The catalog the entry belongs to.
 
- Public Attributes inherited from duckdb::CatalogEntry
idx_t oid
 The oid of the entry.
 
CatalogType type
 The type of this catalog entry.
 
optional_ptr< CatalogSetset
 Reference to the catalog set this entry is stored in.
 
string name
 The name of the entry.
 
bool deleted
 Whether or not the object is deleted.
 
bool temporary
 Whether or not the object is temporary and should not be added to the WAL.
 
bool internal
 Whether or not the entry is an internal entry (cannot be deleted, not dumped, etc)
 
atomic< transaction_ttimestamp
 Timestamp at which the catalog entry was created.
 
Value comment
 (optional) comment on this entry
 
InsertionOrderPreservingMap< string > tags
 (optional) extra data associated with this entry
 
- Static Public Attributes inherited from duckdb::SchemaCatalogEntry
static constexpr const CatalogType Type = CatalogType::SCHEMA_ENTRY
 
static constexpr const charName = "schema"
 

Detailed Description

A schema in the catalog.

Constructor & Destructor Documentation

◆ DuckSchemaEntry()

duckdb::DuckSchemaEntry::DuckSchemaEntry ( Catalog catalog,
CreateSchemaInfo info 
)
10187 : SchemaCatalogEntry(catalog, info),
10188 tables(catalog, catalog.IsSystemCatalog() ? make_uniq<DefaultViewGenerator>(catalog, *this) : nullptr),
10191 catalog.IsSystemCatalog() ? make_uniq<DefaultTableFunctionGenerator>(catalog, *this) : nullptr),
10193 functions(catalog, catalog.IsSystemCatalog() ? make_uniq<DefaultFunctionGenerator>(catalog, *this) : nullptr),
10194 sequences(catalog), collations(catalog), types(catalog, make_uniq<DefaultTypeGenerator>(catalog, *this)),
10196 catalog, catalog.IsSystemCatalog() ? make_uniq<DefaultCoordinateSystemGenerator>(catalog, *this) : nullptr) {
10197}
CatalogSet table_functions
The catalog set holding the table functions.
Definition duckdb.cpp:9419
CatalogSet tables
The catalog set holding the tables.
Definition duckdb.cpp:9415
CatalogSet functions
The catalog set holding the scalar and aggregate functions.
Definition duckdb.cpp:9425
CatalogSet types
The catalog set holding the types.
Definition duckdb.cpp:9431
CatalogSet coordinate_systems
The catalog set holding the coordinate systems.
Definition duckdb.cpp:9433
CatalogSet pragma_functions
The catalog set holding the pragma functions.
Definition duckdb.cpp:9423
CatalogSet collations
The catalog set holding the collations.
Definition duckdb.cpp:9429
CatalogSet sequences
The catalog set holding the sequences.
Definition duckdb.cpp:9427
CatalogSet indexes
The catalog set holding the indexes.
Definition duckdb.cpp:9417
CatalogSet copy_functions
The catalog set holding the copy functions.
Definition duckdb.cpp:9421
Catalog & catalog
The catalog the entry belongs to.
Definition duckdb.hpp:6387

Member Function Documentation

◆ AddEntry()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::AddEntry ( CatalogTransaction  transaction,
unique_ptr< StandardEntry entry,
OnCreateConflict  on_conflict 
)
10338 {
10339 LogicalDependencyList dependencies = entry->dependencies;
10340 return AddEntryInternal(transaction, std::move(entry), on_conflict, dependencies);
10341}

◆ AddEntryInternal()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::AddEntryInternal ( CatalogTransaction  transaction,
unique_ptr< StandardEntry entry,
OnCreateConflict  on_conflict,
LogicalDependencyList  dependencies 
)
10211 {
10212 auto entry_name = entry->name;
10213 auto entry_type = entry->type;
10214 auto result = entry.get();
10215
10216 if (transaction.context) {
10217 auto &meta = MetaTransaction::Get(transaction.GetContext());
10218 auto modified_database = meta.ModifiedDatabase();
10219 auto &db = ParentCatalog().GetAttached();
10220 if (!db.IsTemporary() && !db.IsSystem()) {
10221 if (!modified_database || !RefersToSameObject(*modified_database, ParentCatalog().GetAttached())) {
10222 throw InternalException(
10223 "DuckSchemaEntry::AddEntryInternal called but this database is not marked as modified");
10224 }
10225 }
10226 }
10227 // first find the set for this entry
10228 auto &set = GetCatalogSet(entry_type);
10229 dependencies.AddDependency(*this);
10230 if (on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT) {
10231 auto old_entry = set.GetEntry(transaction, entry_name);
10232 if (old_entry) {
10233 return nullptr;
10234 }
10235 }
10236
10237 if (on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT) {
10238 // CREATE OR REPLACE: first try to drop the entry
10239 auto old_entry = set.GetEntry(transaction, entry_name);
10240 if (old_entry) {
10241 if (dependencies.Contains(*old_entry)) {
10242 throw CatalogException("CREATE OR REPLACE is not allowed to depend on itself");
10243 }
10244 if (old_entry->type != entry_type) {
10245 throw CatalogException("Existing object %s is of type %s, trying to replace with type %s", entry_name,
10246 CatalogTypeToString(old_entry->type), CatalogTypeToString(entry_type));
10247 }
10248 OnDropEntry(transaction, *old_entry);
10249 (void)set.DropEntry(transaction, entry_name, false, entry->internal);
10250 }
10251 }
10252 // now try to add the entry
10253 if (!set.CreateEntry(transaction, entry_name, std::move(entry), dependencies)) {
10254 // entry already exists!
10255 if (on_conflict == OnCreateConflict::ERROR_ON_CONFLICT) {
10256 auto existing_entry = set.GetEntry(transaction, entry_name);
10257 auto existing_type = existing_entry ? existing_entry->type : entry_type;
10258 throw CatalogException::EntryAlreadyExists(existing_type, entry_name);
10259 } else {
10260 return nullptr;
10261 }
10262 }
10263 return result;
10264}
optional_ptr< CatalogSet > set
Reference to the catalog set this entry is stored in.
Definition duckdb.hpp:6309
CatalogSet & GetCatalogSet(CatalogType type)
Get the catalog set for the specified type.
Definition duckdb.cpp:10496
cv::GOpaque< T > meta(G g, const std::string &tag)
db
bool RefersToSameObject(const reference< T > &a, const reference< T > &b)
Returns whether or not two reference wrappers refer to the same object.
Definition duckdb.hpp:2191

◆ CreateTable()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateTable ( CatalogTransaction  transaction,
BoundCreateTableInfo info 
)
overridevirtual

Creates a table with the given name in the schema.

Implements duckdb::SchemaCatalogEntry.

10266 {
10267 auto table = make_uniq<DuckTableEntry>(catalog, *this, info);
10268
10269 // add a foreign key constraint in main key table if there is a foreign key constraint
10270 vector<unique_ptr<AlterForeignKeyInfo>> fk_arrays;
10271 FindForeignKeyInformation(*table, AlterForeignKeyType::AFT_ADD, fk_arrays);
10272 for (idx_t i = 0; i < fk_arrays.size(); i++) {
10273 // alter primary key table
10274 auto &fk_info = *fk_arrays[i];
10275 Alter(transaction, fk_info);
10276
10277 // make a dependency between this table and referenced table
10278 auto &set = GetCatalogSet(CatalogType::TABLE_ENTRY);
10279 info.dependencies.AddDependency(*set.GetEntry(transaction, fk_info.name));
10280 }
10281 for (auto &dep : info.dependencies.Set()) {
10282 table->dependencies.AddDependency(dep);
10283 }
10284
10285 auto entry = AddEntryInternal(transaction, std::move(table), info.Base().on_conflict, info.dependencies);
10286 if (!entry) {
10287 return nullptr;
10288 }
10289
10290 return entry;
10291}
void Alter(CatalogTransaction transaction, AlterInfo &info) override
Alters a catalog entry.
Definition duckdb.cpp:10408
Here is the call graph for this function:

◆ CreateFunction()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateFunction ( CatalogTransaction  transaction,
CreateFunctionInfo info 
)
overridevirtual

Create a scalar or aggregate function within the given schema.

Implements duckdb::SchemaCatalogEntry.

10293 {
10294 if (info.on_conflict == OnCreateConflict::ALTER_ON_CONFLICT) {
10295 // check if the original entry exists
10296 auto &catalog_set = GetCatalogSet(info.type);
10297 auto current_entry = catalog_set.GetEntry(transaction, info.name);
10298 if (current_entry) {
10299 // the current entry exists - alter it instead
10300 auto alter_info = info.GetAlterInfo();
10301 Alter(transaction, *alter_info);
10302 return nullptr;
10303 }
10304 }
10305 unique_ptr<StandardEntry> function;
10306 switch (info.type) {
10307 case CatalogType::SCALAR_FUNCTION_ENTRY:
10308 function = make_uniq_base<StandardEntry, ScalarFunctionCatalogEntry>(catalog, *this,
10309 info.Cast<CreateScalarFunctionInfo>());
10310 break;
10311 case CatalogType::TABLE_FUNCTION_ENTRY:
10312 function = make_uniq_base<StandardEntry, TableFunctionCatalogEntry>(catalog, *this,
10313 info.Cast<CreateTableFunctionInfo>());
10314 break;
10315 case CatalogType::MACRO_ENTRY:
10316 // create a macro function
10317 function = make_uniq_base<StandardEntry, ScalarMacroCatalogEntry>(catalog, *this, info.Cast<CreateMacroInfo>());
10318 break;
10319
10320 case CatalogType::TABLE_MACRO_ENTRY:
10321 // create a macro table function
10322 function = make_uniq_base<StandardEntry, TableMacroCatalogEntry>(catalog, *this, info.Cast<CreateMacroInfo>());
10323 break;
10324 case CatalogType::AGGREGATE_FUNCTION_ENTRY:
10325 D_ASSERT(info.type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
10326 // create an aggregate function
10327 function = make_uniq_base<StandardEntry, AggregateFunctionCatalogEntry>(
10328 catalog, *this, info.Cast<CreateAggregateFunctionInfo>());
10329 break;
10330 default:
10331 throw InternalException("Unknown function type \"%s\"", CatalogTypeToString(info.type));
10332 }
10333 function->internal = info.internal;
10334 return AddEntry(transaction, std::move(function), info.on_conflict);
10335}
Here is the call graph for this function:

◆ CreateIndex()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateIndex ( CatalogTransaction  transaction,
CreateIndexInfo info,
TableCatalogEntry table 
)
overridevirtual

Creates an index with the given name in the schema.

Implements duckdb::SchemaCatalogEntry.

10359 {
10360 info.dependencies.AddDependency(table);
10361
10362 // currently, we can not alter PK/FK/UNIQUE constraints
10363 // concurrency-safe name checks against other INDEX catalog entries happens in the catalog
10364 if (info.on_conflict != OnCreateConflict::IGNORE_ON_CONFLICT &&
10365 !table.GetStorage().IndexNameIsUnique(info.index_name)) {
10366 throw CatalogException("An index with the name " + info.index_name + " already exists!");
10367 }
10368
10369 auto index = make_uniq<DuckIndexEntry>(catalog, *this, info, table);
10370 auto dependencies = index->dependencies;
10371 return AddEntryInternal(transaction, std::move(index), info.on_conflict, dependencies);
10372}
index
Here is the call graph for this function:

◆ CreateView()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateView ( CatalogTransaction  transaction,
CreateViewInfo info 
)
overridevirtual

Creates a view with the given name in the schema.

Implements duckdb::SchemaCatalogEntry.

10353 {
10354 auto view = make_uniq<ViewCatalogEntry>(catalog, *this, info);
10355 return AddEntry(transaction, std::move(view), info.on_conflict);
10356}

◆ CreateSequence()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateSequence ( CatalogTransaction  transaction,
CreateSequenceInfo info 
)
overridevirtual

Creates a sequence with the given name in the schema.

Implements duckdb::SchemaCatalogEntry.

10343 {
10344 auto sequence = make_uniq<SequenceCatalogEntry>(catalog, *this, info);
10345 return AddEntry(transaction, std::move(sequence), info.on_conflict);
10346}

◆ CreateTableFunction()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateTableFunction ( CatalogTransaction  transaction,
CreateTableFunctionInfo info 
)
overridevirtual

Create a table function within the given schema.

Implements duckdb::SchemaCatalogEntry.

10388 {
10389 auto table_function = make_uniq<TableFunctionCatalogEntry>(catalog, *this, info);
10390 table_function->internal = info.internal;
10391 return AddEntry(transaction, std::move(table_function), info.on_conflict);
10392}

◆ CreateCopyFunction()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateCopyFunction ( CatalogTransaction  transaction,
CreateCopyFunctionInfo info 
)
overridevirtual

Create a copy function within the given schema.

Implements duckdb::SchemaCatalogEntry.

10395 {
10396 auto copy_function = make_uniq<CopyFunctionCatalogEntry>(catalog, *this, info);
10397 copy_function->internal = info.internal;
10398 return AddEntry(transaction, std::move(copy_function), info.on_conflict);
10399}

◆ CreatePragmaFunction()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreatePragmaFunction ( CatalogTransaction  transaction,
CreatePragmaFunctionInfo info 
)
overridevirtual

Create a pragma function within the given schema.

Implements duckdb::SchemaCatalogEntry.

10402 {
10403 auto pragma_function = make_uniq<PragmaFunctionCatalogEntry>(catalog, *this, info);
10404 pragma_function->internal = info.internal;
10405 return AddEntry(transaction, std::move(pragma_function), info.on_conflict);
10406}

◆ CreateCollation()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateCollation ( CatalogTransaction  transaction,
CreateCollationInfo info 
)
overridevirtual

Create a collation within the given schema.

Implements duckdb::SchemaCatalogEntry.

10374 {
10375 auto collation = make_uniq<CollateCatalogEntry>(catalog, *this, info);
10376 collation->internal = info.internal;
10377 return AddEntry(transaction, std::move(collation), info.on_conflict);
10378}

◆ CreateCoordinateSystem()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateCoordinateSystem ( CatalogTransaction  transaction,
CreateCoordinateSystemInfo info 
)
overridevirtual

Create a coordiante system within the given schema.

Reimplemented from duckdb::SchemaCatalogEntry.

10381 {
10382 auto coordinate_system = make_uniq<CoordinateSystemCatalogEntry>(catalog, *this, info);
10383 coordinate_system->internal = info.internal;
10384 return AddEntry(transaction, std::move(coordinate_system), info.on_conflict);
10385}

◆ CreateType()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::CreateType ( CatalogTransaction  transaction,
CreateTypeInfo info 
)
overridevirtual

Create a enum within the given schema.

Implements duckdb::SchemaCatalogEntry.

10348 {
10349 auto type_entry = make_uniq<TypeCatalogEntry>(catalog, *this, info);
10350 return AddEntry(transaction, std::move(type_entry), info.on_conflict);
10351}

◆ Alter()

void duckdb::DuckSchemaEntry::Alter ( CatalogTransaction  transaction,
AlterInfo info 
)
overridevirtual

Alters a catalog entry.

Implements duckdb::SchemaCatalogEntry.

10408 {
10409 CatalogType type = info.GetCatalogType();
10410
10411 auto &set = GetCatalogSet(type);
10412 if (info.type == AlterType::CHANGE_OWNERSHIP) {
10413 if (!set.AlterOwnership(transaction, info.Cast<ChangeOwnershipInfo>())) {
10414 throw CatalogException("Couldn't change ownership!");
10415 }
10416 } else {
10417 string name = info.name;
10418 if (!set.AlterEntry(transaction, name, info)) {
10419 throw CatalogException::MissingEntry(type, name, string());
10420 }
10421 }
10422}
string name
The name of the entry.
Definition duckdb.hpp:6311
CatalogType type
The type of this catalog entry.
Definition duckdb.hpp:6307
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Scan() [1/2]

void duckdb::DuckSchemaEntry::Scan ( ClientContext context,
CatalogType  type,
const std::function< void(CatalogEntry &)> &  callback 
)
overridevirtual

Scan the specified catalog set, invoking the callback method for every entry.

Implements duckdb::SchemaCatalogEntry.

10425 {
10426 auto &set = GetCatalogSet(type);
10427 set.Scan(GetCatalogTransaction(context), callback);
10428}
Here is the call graph for this function:

◆ Scan() [2/2]

void duckdb::DuckSchemaEntry::Scan ( CatalogType  type,
const std::function< void(CatalogEntry &)> &  callback 
)
overridevirtual

Scan the specified catalog set, invoking the callback method for every committed entry.

Implements duckdb::SchemaCatalogEntry.

10430 {
10431 auto &set = GetCatalogSet(type);
10432 set.Scan(callback);
10433}
Here is the call graph for this function:

◆ DropEntry()

void duckdb::DuckSchemaEntry::DropEntry ( ClientContext context,
DropInfo info 
)
overridevirtual

Drops an entry from the schema.

Implements duckdb::SchemaCatalogEntry.

10435 {
10436 auto &set = GetCatalogSet(info.type);
10437
10438 // first find the entry
10439 auto transaction = GetCatalogTransaction(context);
10440 auto existing_entry = set.GetEntry(transaction, info.name);
10441 if (!existing_entry) {
10442 throw InternalException("Failed to drop entry \"%s\" - entry could not be found", info.name);
10443 }
10444 if (existing_entry->type != info.type) {
10445 throw CatalogException("Existing object %s is of type %s, trying to drop type %s", info.name,
10446 CatalogTypeToString(existing_entry->type), CatalogTypeToString(info.type));
10447 }
10448
10449 vector<unique_ptr<AlterForeignKeyInfo>> fk_arrays;
10450 if (existing_entry->type == CatalogType::TABLE_ENTRY) {
10451 // if there is a foreign key constraint, get that information
10452 auto &table_entry = existing_entry->Cast<TableCatalogEntry>();
10453 FindForeignKeyInformation(table_entry, AlterForeignKeyType::AFT_DELETE, fk_arrays);
10454 }
10455
10456 OnDropEntry(transaction, *existing_entry);
10457 if (!set.DropEntry(transaction, info.name, info.cascade, info.allow_drop_internal)) {
10458 throw InternalException("Could not drop element because of an internal error");
10459 }
10460
10461 // remove the foreign key constraint in main key table if main key table's name is valid
10462 for (idx_t i = 0; i < fk_arrays.size(); i++) {
10463 // alter primary key table
10464 Alter(transaction, *fk_arrays[i]);
10465 }
10466}
Here is the call graph for this function:

◆ LookupEntry()

optional_ptr< CatalogEntry > duckdb::DuckSchemaEntry::LookupEntry ( CatalogTransaction  transaction,
const EntryLookupInfo lookup_info 
)
overridevirtual

Lookup an entry in the schema.

Implements duckdb::SchemaCatalogEntry.

10482 {
10483 return GetCatalogSet(lookup_info.GetCatalogType()).GetEntry(transaction, lookup_info.GetEntryName());
10484}
Here is the call graph for this function:

◆ LookupEntryDetailed()

CatalogSet::EntryLookup duckdb::DuckSchemaEntry::LookupEntryDetailed ( CatalogTransaction  transaction,
const EntryLookupInfo lookup_info 
)
overridevirtual

This should not be used, it's only implemented to not put the burden of implementing it on every derived class of SchemaCatalogEntry

Reimplemented from duckdb::SchemaCatalogEntry.

10487 {
10488 return GetCatalogSet(lookup_info.GetCatalogType()).GetEntryDetailed(transaction, lookup_info.GetEntryName());
10489}
DUCKDB_API EntryLookup GetEntryDetailed(CatalogTransaction transaction, const string &name)
Returns the entry with the specified name.
Definition duckdb.cpp:23455
Here is the call graph for this function:

◆ GetSimilarEntry()

SimilarCatalogEntry duckdb::DuckSchemaEntry::GetSimilarEntry ( CatalogTransaction  transaction,
const EntryLookupInfo lookup_info 
)
overridevirtual

Reimplemented from duckdb::SchemaCatalogEntry.

10492 {
10493 return GetCatalogSet(lookup_info.GetCatalogType()).SimilarEntry(transaction, lookup_info.GetEntryName());
10494}
SimilarCatalogEntry SimilarEntry(CatalogTransaction transaction, const string &name)
Definition duckdb.cpp:23404

◆ Copy()

unique_ptr< CatalogEntry > duckdb::DuckSchemaEntry::Copy ( ClientContext context) const
overridevirtual

Reimplemented from duckdb::CatalogEntry.

10199 {
10200 auto info_copy = GetInfo();
10201 auto &cast_info = info_copy->Cast<CreateSchemaInfo>();
10202
10203 auto result = make_uniq<DuckSchemaEntry>(catalog, cast_info);
10204
10205 return std::move(result);
10206}

◆ Verify()

void duckdb::DuckSchemaEntry::Verify ( Catalog catalog)
overridevirtual

Reimplemented from duckdb::CatalogEntry.

10527 {
10528 InCatalogEntry::Verify(catalog);
10529
10530 tables.Verify(catalog);
10531 indexes.Verify(catalog);
10532 table_functions.Verify(catalog);
10533 copy_functions.Verify(catalog);
10534 pragma_functions.Verify(catalog);
10535 functions.Verify(catalog);
10536 sequences.Verify(catalog);
10537 collations.Verify(catalog);
10538 types.Verify(catalog);
10539}

◆ GetCatalogSet()

CatalogSet & duckdb::DuckSchemaEntry::GetCatalogSet ( CatalogType  type)

Get the catalog set for the specified type.

10496 {
10497 switch (type) {
10498 case CatalogType::VIEW_ENTRY:
10499 case CatalogType::TABLE_ENTRY:
10500 return tables;
10501 case CatalogType::INDEX_ENTRY:
10502 return indexes;
10503 case CatalogType::TABLE_FUNCTION_ENTRY:
10504 case CatalogType::TABLE_MACRO_ENTRY:
10505 return table_functions;
10506 case CatalogType::COPY_FUNCTION_ENTRY:
10507 return copy_functions;
10508 case CatalogType::PRAGMA_FUNCTION_ENTRY:
10509 return pragma_functions;
10510 case CatalogType::AGGREGATE_FUNCTION_ENTRY:
10511 case CatalogType::SCALAR_FUNCTION_ENTRY:
10512 case CatalogType::MACRO_ENTRY:
10513 return functions;
10514 case CatalogType::SEQUENCE_ENTRY:
10515 return sequences;
10516 case CatalogType::COLLATION_ENTRY:
10517 return collations;
10518 case CatalogType::COORDINATE_SYSTEM_ENTRY:
10519 return coordinate_systems;
10520 case CatalogType::TYPE_ENTRY:
10521 return types;
10522 default:
10523 throw InternalException({{"catalog_type", CatalogTypeToString(type)}}, "Unsupported catalog type in schema");
10524 }
10525}
Here is the caller graph for this function:

◆ OnDropEntry()

void duckdb::DuckSchemaEntry::OnDropEntry ( CatalogTransaction  transaction,
CatalogEntry entry 
)
private
10468 {
10469 if (!transaction.transaction) {
10470 return;
10471 }
10472 if (entry.type != CatalogType::TABLE_ENTRY) {
10473 return;
10474 }
10475 // if we have transaction local insertions for this table - clear them
10476 auto &table_entry = entry.Cast<TableCatalogEntry>();
10477 auto &local_storage = LocalStorage::Get(transaction.transaction->Cast<DuckTransaction>());
10478 local_storage.DropTable(table_entry.GetStorage());
10479}

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