Skip to content

Commit

Permalink
fix optional_idx issue
Browse files Browse the repository at this point in the history
  • Loading branch information
samansmink committed Dec 20, 2024
1 parent 1ed221c commit 23f4e9c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/storage/delta_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,24 @@ bool DeltaCatalog::UseCachedSnapshot() {

optional_idx DeltaCatalog::GetCatalogVersion(ClientContext &context) {
auto &delta_transaction = DeltaTransaction::Get(context, *this);
idx_t version = DConstants::INVALID_INDEX;

// Option 1: snapshot is cached table-wide
auto cached_snapshot = main_schema->GetCachedTable();
if (cached_snapshot) {
return cached_snapshot->snapshot->GetVersion();
version = cached_snapshot->snapshot->GetVersion();
}

// Option 2: snapshot is cached in transaction
if (delta_transaction.table_entry) {
return delta_transaction.table_entry->snapshot->GetVersion();
version = delta_transaction.table_entry->snapshot->GetVersion();
}

return {};
if (version != DConstants::INVALID_INDEX) {
return version;
}

return optional_idx::Invalid();
}

DatabaseSize DeltaCatalog::GetDatabaseSize(ClientContext &context) {
Expand Down

0 comments on commit 23f4e9c

Please sign in to comment.