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::StorageOptions Struct Reference
Collaboration diagram for duckdb::StorageOptions:

Public Member Functions

void SetEncryptionVersion (string &storage_version_user_provided)
void Initialize (unordered_map< string, Value > &options)

Public Attributes

optional_idx block_alloc_size
 The allocation size of blocks for this attached database file (if any).
optional_idx row_group_size
 The row group size for this attached database (if any).
optional_idx storage_version
 Target storage version (if any).
optional_idx block_header_size
 Block header size (only used for encryption).
CompressInMemory compress_in_memory = CompressInMemory::AUTOMATIC
bool encryption = false
 Whether the database is encrypted.
EncryptionTypes::CipherType encryption_cipher = EncryptionTypes::INVALID
 Encryption algorithm.
shared_ptr< string > user_key
EncryptionTypes::EncryptionVersion encryption_version = EncryptionTypes::NONE
 encryption version (set default to 1)

Member Function Documentation

◆ SetEncryptionVersion()

void duckdb::StorageOptions::SetEncryptionVersion ( string & storage_version_user_provided)
426209 {
426210 // storage version < v1.4.0
426211 if (!storage_version.IsValid() ||
426212 storage_version.GetIndex() < SerializationCompatibility::FromString("v1.4.0").serialization_version) {
426213 if (!storage_version_user_provided.empty()) {
426214 throw InvalidInputException("Explicit provided STORAGE_VERSION (\"%s\") and ENCRYPTION_KEY (storage >= "
426215 "v1.4.0) are not compatible",
426216 storage_version_user_provided);
426217 }
426218 }
426219
426220 auto target_encryption_version = encryption_version;
426221
426222 if (target_encryption_version == EncryptionTypes::NONE) {
426223 target_encryption_version = EncryptionTypes::V0_1;
426224 }
426225
426226 switch (target_encryption_version) {
426227 case EncryptionTypes::V0_1:
426228 // storage version not explicitly set
426229 if (!storage_version.IsValid() && storage_version_user_provided.empty()) {
426230 storage_version = SerializationCompatibility::FromString("v1.5.0").serialization_version;
426231 break;
426232 }
426233 // storage version set, but v1.4.0 =< storage < v1.5.0
426234 if (storage_version.GetIndex() < SerializationCompatibility::FromString("v1.5.0").serialization_version) {
426235 if (!storage_version_user_provided.empty()) {
426236 if (encryption_version == target_encryption_version) {
426237 // encryption version is explicitly given, but not compatible with < v1.5.0
426238 throw InvalidInputException("Explicit provided STORAGE_VERSION (\"%s\") is not compatible with "
426239 "'debug_encryption_version = v1' (storage >= "
426240 "v1.5.0)",
426241 storage_version_user_provided);
426242 }
426243 } else {
426244 // encryption version needs to be lowered, because storage version < v1.5.0
426245 target_encryption_version = EncryptionTypes::V0_0;
426246 break;
426247 }
426248 }
426249
426250 break;
426251
426252 case EncryptionTypes::V0_0:
426253 // we set this to V0 to V1.5.0 if no explicit storage version provided
426254 if (!storage_version.IsValid() && storage_version_user_provided.empty()) {
426255 storage_version = SerializationCompatibility::FromString("v1.5.0").serialization_version;
426256 break;
426257 }
426258 // if storage version is provided, we do nothing
426259 break;
426260 default:
426261 throw InvalidConfigurationException("Encryption version is not set");
426262 }
426263
426264 encryption_version = target_encryption_version;
426265}
EncryptionTypes::EncryptionVersion encryption_version
encryption version (set default to 1)
Definition duckdb.cpp:11062
optional_idx storage_version
Target storage version (if any).
Definition duckdb.cpp:11048

◆ Initialize()

void duckdb::StorageOptions::Initialize ( unordered_map< string, Value > & options)
426267 {
426268 string storage_version_user_provided = "";
426269 for (auto &entry : options) {
426270 if (entry.first == "block_size") {
426271 // Extract the block allocation size. This is NOT the actual memory available on a block (block_size),
426272 // even though the corresponding option we expose to the user is called "block_size".
426273 block_alloc_size = entry.second.GetValue<uint64_t>();
426274 } else if (entry.first == "encryption_key") {
426275 // check the type of the key
426276 auto type = entry.second.type();
426277 if (type.id() != LogicalTypeId::VARCHAR) {
426278 throw BinderException("\"%s\" is not a valid key. A key must be of type VARCHAR",
426279 entry.second.ToString());
426280 } else if (entry.second.GetValue<string>().empty()) {
426281 throw BinderException("Not a valid key. A key cannot be empty");
426282 }
426283 user_key = make_shared_ptr<string>(StringValue::Get(entry.second.DefaultCastAs(LogicalType::BLOB)));
426284 block_header_size = DEFAULT_ENCRYPTION_BLOCK_HEADER_SIZE;
426285 encryption = true;
426286 } else if (entry.first == "encryption_cipher") {
426287 auto parsed_cipher = EncryptionTypes::StringToCipher(entry.second.ToString());
426288 if (parsed_cipher != EncryptionTypes::CipherType::GCM &&
426289 parsed_cipher != EncryptionTypes::CipherType::CTR) {
426290 throw BinderException("\"%s\" is not a valid cipher. Try 'GCM' or 'CTR'.", entry.second.ToString());
426291 }
426292 encryption_cipher = parsed_cipher;
426293 } else if (entry.first == "row_group_size") {
426294 row_group_size = entry.second.GetValue<uint64_t>();
426295 } else if (entry.first == "storage_version") {
426296 storage_version_user_provided = entry.second.ToString();
426298 SerializationCompatibility::FromString(storage_version_user_provided).serialization_version;
426299 } else if (entry.first == "compress") {
426300 if (entry.second.DefaultCastAs(LogicalType::BOOLEAN).GetValue<bool>()) {
426301 compress_in_memory = CompressInMemory::COMPRESS;
426302 } else {
426303 compress_in_memory = CompressInMemory::DO_NOT_COMPRESS;
426304 }
426305 } else if (entry.first == "debug_encryption_version") {
426306 encryption_version = EncryptionTypes::StringToVersion(entry.second.ToString());
426307 } else {
426308 throw BinderException("Unrecognized option for attach \"%s\"", entry.first);
426309 }
426310 }
426311 // erase encryption settings
426312 options.erase("encryption_key");
426313 options.erase("encryption_cipher");
426314 if (encryption) {
426315 SetEncryptionVersion(storage_version_user_provided);
426316 }
426317}
::uint64_t uint64_t
shared_ptr< string > user_key
Definition duckdb.cpp:11060
optional_idx block_header_size
Block header size (only used for encryption).
Definition duckdb.cpp:11050
bool encryption
Whether the database is encrypted.
Definition duckdb.cpp:11055
optional_idx row_group_size
The row group size for this attached database (if any).
Definition duckdb.cpp:11046
EncryptionTypes::CipherType encryption_cipher
Encryption algorithm.
Definition duckdb.cpp:11057
optional_idx block_alloc_size
The allocation size of blocks for this attached database file (if any).
Definition duckdb.cpp:11044

Member Data Documentation

◆ user_key

shared_ptr<string> duckdb::StorageOptions::user_key

encryption key FIXME: change to a unique_ptr in the future


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