From 7a912ca89134415c6c978acf3ef48e9f438b9fc9 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 10 Jan 2024 06:59:54 -0500 Subject: [PATCH] LibSQL: Reset the highest written block during the zeroth block init Otherwise, when changing the SQL heap version, the value from the now- stale heap file will continue to be used. --- Userland/Libraries/LibSQL/Heap.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibSQL/Heap.cpp b/Userland/Libraries/LibSQL/Heap.cpp index 6796b75b866..f2650d059bd 100644 --- a/Userland/Libraries/LibSQL/Heap.cpp +++ b/Userland/Libraries/LibSQL/Heap.cpp @@ -49,6 +49,7 @@ ErrorOr Heap::open() } else { file_size = stat_buffer.st_size; } + if (file_size > 0) { m_next_block = file_size / Block::SIZE; m_highest_block_written = m_next_block - 1; @@ -357,6 +358,7 @@ ErrorOr Heap::initialize_zero_block() m_tables_root = 0; m_table_columns_root = 0; m_next_block = 1; + m_highest_block_written = 0; for (auto& user : m_user_values) user = 0u; return update_zero_block();