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

Base Implementation for catalog set based secret storage. More...

Inheritance diagram for duckdb::CatalogSetSecretStorage:
Collaboration diagram for duckdb::CatalogSetSecretStorage:

Public Member Functions

 CatalogSetSecretStorage (DatabaseInstance &db_instance, const string &name_p, const int64_t offset)
string & GetName () override
 SecretStorage API.
unique_ptr< SecretEntry > StoreSecret (unique_ptr< const BaseSecret > secret, OnCreateConflict on_conflict, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Store a secret.
vector< SecretEntry > AllSecrets (optional_ptr< CatalogTransaction > transaction=nullptr) override
 Get all secrets.
void DropSecretByName (const string &name, OnEntryNotFound on_entry_not_found, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Drop secret by name.
SecretMatch LookupSecret (const string &path, const string &type, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Get best match.
unique_ptr< SecretEntry > GetSecretByName (const string &name, optional_ptr< CatalogTransaction > transaction=nullptr) override
 Get a secret by name.
Public Member Functions inherited from duckdb::SecretStorage
 SecretStorage (const string &name, const int64_t tie_break_offset)
virtual bool IncludeInLookups ()
 Returns include_in_lookups, used to create secret storage.
virtual bool Persistent () const

Protected Member Functions

virtual void WriteSecret (const BaseSecret &secret, OnCreateConflict on_conflict)
 Callback called on Store to allow child classes to implement persistence.
virtual void RemoveSecret (const string &name, OnEntryNotFound on_entry_not_found)
CatalogTransaction GetTransactionOrDefault (optional_ptr< CatalogTransaction > transaction)
 Returns the CatalogTransaction in transaction if not set, return the System transaction.

Protected Attributes

unique_ptr< CatalogSet > secrets
 CatalogSet containing the secrets.
DatabaseInstance & db
 DB instance for accessing the system catalog transaction.
Protected Attributes inherited from duckdb::SecretStorage
string storage_name
 Name of the storage backend (e.g. temporary, file, etc).
const int64_t tie_break_offset
 Offset associated to this storage for tie-breaking secrets between storages.
bool persistent
 Whether entries in this storage will survive duckdb reboots.

Additional Inherited Members

Static Public Attributes inherited from duckdb::SecretStorage
static const int64_t TEMPORARY_STORAGE_OFFSET = 10
 Default storage backend offsets.
static const int64_t LOCAL_FILE_STORAGE_OFFSET = 20
Static Protected Member Functions inherited from duckdb::SecretStorage
static SecretMatch SelectBestMatch (SecretEntry &secret_entry, const string &path, int64_t offset, SecretMatch &current_best)

Detailed Description

Base Implementation for catalog set based secret storage.

Constructor & Destructor Documentation

◆ CatalogSetSecretStorage()

duckdb::CatalogSetSecretStorage::CatalogSetSecretStorage ( DatabaseInstance & db_instance,
const string & name_p,
const int64_t offset )
inline
177729 : SecretStorage(name_p, offset), db(db_instance) {};
DatabaseInstance & db
DB instance for accessing the system catalog transaction.
Definition duckdb.cpp:177757

Member Function Documentation

◆ GetName()

string & duckdb::CatalogSetSecretStorage::GetName ( )
inlineoverridevirtual

SecretStorage API.

Reimplemented from duckdb::SecretStorage.

177733 {
177734 return storage_name;
177735 };
string storage_name
Name of the storage backend (e.g. temporary, file, etc).
Definition duckdb.cpp:177708

◆ StoreSecret()

unique_ptr< SecretEntry > duckdb::CatalogSetSecretStorage::StoreSecret ( unique_ptr< const BaseSecret > secret,
OnCreateConflict on_conflict,
optional_ptr< CatalogTransaction > transaction = nullptr )
overridevirtual

Store a secret.

Implements duckdb::SecretStorage.

300931 {
300932 if (secrets->GetEntry(GetTransactionOrDefault(transaction), secret->GetName())) {
300933 if (on_conflict == OnCreateConflict::ERROR_ON_CONFLICT) {
300934 string persist_string = persistent ? "Persistent" : "Temporary";
300935 string storage_string = persistent ? " in secret storage '" + storage_name + "'" : "";
300936 throw InvalidInputException("%s secret with name '%s' already exists%s!", persist_string, secret->GetName(),
300937 storage_string);
300938 } else if (on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT) {
300939 return nullptr;
300940 } else if (on_conflict == OnCreateConflict::ALTER_ON_CONFLICT) {
300941 throw InternalException("unknown OnCreateConflict found while registering secret");
300942 } else if (on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT) {
300943 secrets->DropEntry(GetTransactionOrDefault(transaction), secret->GetName(), true, true);
300944 }
300945 }
300946
300947 // Call write function
300948 WriteSecret(*secret, on_conflict);
300949
300950 auto secret_name = secret->GetName();
300951 auto secret_entry = make_uniq<SecretCatalogEntry>(std::move(secret), Catalog::GetSystemCatalog(db));
300952 secret_entry->temporary = !persistent;
300953 secret_entry->secret->storage_mode = storage_name;
300954 secret_entry->secret->persist_type = persistent ? SecretPersistType::PERSISTENT : SecretPersistType::TEMPORARY;
300955 LogicalDependencyList l;
300956 secrets->CreateEntry(GetTransactionOrDefault(transaction), secret_name, std::move(secret_entry), l);
300957
300958 auto secret_catalog_entry =
300959 &secrets->GetEntry(GetTransactionOrDefault(transaction), secret_name)->Cast<SecretCatalogEntry>();
300960 return make_uniq<SecretEntry>(*secret_catalog_entry->secret);
300961}
virtual void WriteSecret(const BaseSecret &secret, OnCreateConflict on_conflict)
Callback called on Store to allow child classes to implement persistence.
Definition duckdb.cpp:301042
unique_ptr< CatalogSet > secrets
CatalogSet containing the secrets.
Definition duckdb.cpp:177755
CatalogTransaction GetTransactionOrDefault(optional_ptr< CatalogTransaction > transaction)
Returns the CatalogTransaction in transaction if not set, return the System transaction.
Definition duckdb.cpp:301049
static DUCKDB_API Catalog & GetSystemCatalog(ClientContext &context)
Get the SystemCatalog from the ClientContext.
Definition duckdb.cpp:7173
bool persistent
Whether entries in this storage will survive duckdb reboots.
Definition duckdb.cpp:177712
Here is the call graph for this function:

◆ AllSecrets()

vector< SecretEntry > duckdb::CatalogSetSecretStorage::AllSecrets ( optional_ptr< CatalogTransaction > transaction = nullptr)
overridevirtual

Get all secrets.

Implements duckdb::SecretStorage.

300963 {
300964 vector<SecretEntry> ret_value;
300965 const std::function<void(CatalogEntry &)> callback = [&](CatalogEntry &entry) {
300966 auto &cast_entry = entry.Cast<SecretCatalogEntry>();
300967 ret_value.push_back(*cast_entry.secret);
300968 };
300969 secrets->Scan(GetTransactionOrDefault(transaction), callback);
300970 return ret_value;
300971}
Here is the call graph for this function:

◆ DropSecretByName()

void duckdb::CatalogSetSecretStorage::DropSecretByName ( const string & name,
OnEntryNotFound on_entry_not_found,
optional_ptr< CatalogTransaction > transaction = nullptr )
overridevirtual

Drop secret by name.

Implements duckdb::SecretStorage.

300974 {
300975 auto entry = secrets->GetEntry(GetTransactionOrDefault(transaction), name);
300976 if (!entry && on_entry_not_found == OnEntryNotFound::THROW_EXCEPTION) {
300977 string persist_string = persistent ? "persistent" : "temporary";
300978 string storage_string = persistent ? " in secret storage '" + storage_name + "'" : "";
300979 throw InvalidInputException("Failed to remove non-existent %s secret '%s'%s", persist_string, name,
300980 storage_string);
300981 }
300982
300983 secrets->DropEntry(GetTransactionOrDefault(transaction), name, true, true);
300984 RemoveSecret(name, on_entry_not_found);
300985}
Here is the call graph for this function:

◆ LookupSecret()

SecretMatch duckdb::CatalogSetSecretStorage::LookupSecret ( const string & path,
const string & type,
optional_ptr< CatalogTransaction > transaction = nullptr )
overridevirtual

Get best match.

Implements duckdb::SecretStorage.

300988 {
300989 auto best_match = SecretMatch();
300990
300991 const std::function<void(CatalogEntry &)> callback = [&](CatalogEntry &entry) {
300992 auto &cast_entry = entry.Cast<SecretCatalogEntry>();
300993 if (StringUtil::CIEquals(cast_entry.secret->secret->GetType(), type)) {
300994 best_match = SelectBestMatch(*cast_entry.secret, path, tie_break_offset, best_match);
300995 }
300996 };
300997 secrets->Scan(GetTransactionOrDefault(transaction), callback);
300998
300999 if (best_match.HasMatch()) {
301000 return best_match;
301001 }
301002
301003 return SecretMatch();
301004}
const int64_t tie_break_offset
Offset associated to this storage for tie-breaking secrets between storages.
Definition duckdb.cpp:177710
static SecretMatch SelectBestMatch(SecretEntry &secret_entry, const string &path, int64_t offset, SecretMatch &current_best)
Definition duckdb.cpp:300902
static DUCKDB_API bool CIEquals(const string &l1, const string &l2)
Case insensitive equals.
Definition duckdb.cpp:109696
Here is the call graph for this function:

◆ GetSecretByName()

unique_ptr< SecretEntry > duckdb::CatalogSetSecretStorage::GetSecretByName ( const string & name,
optional_ptr< CatalogTransaction > transaction = nullptr )
overridevirtual

Get a secret by name.

Implements duckdb::SecretStorage.

301007 {
301008 auto res = secrets->GetEntry(GetTransactionOrDefault(transaction), name);
301009
301010 if (res) {
301011 auto &cast_entry = res->Cast<SecretCatalogEntry>();
301012 return make_uniq<SecretEntry>(*cast_entry.secret);
301013 }
301014
301015 return nullptr;
301016}
Here is the call graph for this function:

◆ WriteSecret()

void duckdb::CatalogSetSecretStorage::WriteSecret ( const BaseSecret & secret,
OnCreateConflict on_conflict )
protectedvirtual

Callback called on Store to allow child classes to implement persistence.

Reimplemented in duckdb::LocalFileSecretStorage.

301042 {
301043 // By default, this writes nothing
301044}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveSecret()

void duckdb::CatalogSetSecretStorage::RemoveSecret ( const string & name,
OnEntryNotFound on_entry_not_found )
protectedvirtual

Reimplemented in duckdb::LocalFileSecretStorage.

301045 {
301046 // By default, this writes nothing
301047}

◆ GetTransactionOrDefault()

CatalogTransaction duckdb::CatalogSetSecretStorage::GetTransactionOrDefault ( optional_ptr< CatalogTransaction > transaction)
protected

Returns the CatalogTransaction in transaction if not set, return the System transaction.

301049 {
301050 if (transaction) {
301051 return *transaction;
301052 }
301053 return CatalogTransaction::GetSystemTransaction(db);
301054}
Here is the call graph for this function:
Here is the caller graph for this function:

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