From 7e1e0fd2f8c9f4d4cd686ea93d6b2df4c7aeb729 Mon Sep 17 00:00:00 2001 From: Alex Gaetano Padula Date: Thu, 12 Feb 2026 11:48:22 -0500 Subject: [PATCH 1/2] checkpoint api feature support to align with tdb v8.3.2+ --- src/tidesdb.lua | 12 ++++- tests/test_tidesdb.lua | 53 +++++++++++++++++++ ...5.0-1.rockspec => tidesdb-0.5.1-1.rockspec | 4 +- 3 files changed, 66 insertions(+), 3 deletions(-) rename tidesdb-0.5.0-1.rockspec => tidesdb-0.5.1-1.rockspec (95%) diff --git a/src/tidesdb.lua b/src/tidesdb.lua index f7450ea..a625a4a 100644 --- a/src/tidesdb.lua +++ b/src/tidesdb.lua @@ -159,6 +159,7 @@ ffi.cdef[[ // Backup operations int tidesdb_backup(void* db, const char* dir); + int tidesdb_checkpoint(void* db, const char* checkpoint_dir); // Configuration operations int tidesdb_cf_config_load_from_ini(const char* ini_file, const char* section_name, tidesdb_column_family_config_t* config); @@ -970,6 +971,15 @@ function TidesDB:backup(dir) check_result(result, "failed to create backup") end +function TidesDB:checkpoint(dir) + if self._closed then + error(TidesDBError.new("Database is closed")) + end + + local result = lib.tidesdb_checkpoint(self._db, dir) + check_result(result, "failed to create checkpoint") +end + function TidesDB:register_comparator(name, fn, ctx_str, ctx) if self._closed then error(TidesDBError.new("Database is closed")) @@ -1032,6 +1042,6 @@ function tidesdb.save_config_to_ini(ini_file, section_name, config) end -- Version -tidesdb._VERSION = "0.5.0" +tidesdb._VERSION = "0.5.1" return tidesdb diff --git a/tests/test_tidesdb.lua b/tests/test_tidesdb.lua index abb8a15..a367730 100644 --- a/tests/test_tidesdb.lua +++ b/tests/test_tidesdb.lua @@ -376,6 +376,59 @@ function tests.test_backup() print("PASS: test_backup") end +function tests.test_checkpoint() + local path = "./test_db_checkpoint" + local checkpoint_path = "./test_db_checkpoint_snap" + cleanup_db(path) + cleanup_db(checkpoint_path) + + local db = tidesdb.TidesDB.open(path) + db:create_column_family("test_cf") + local cf = db:get_column_family("test_cf") + + -- Insert data + local txn = db:begin_txn() + txn:put(cf, "key1", "value1") + txn:put(cf, "key2", "value2") + txn:commit() + txn:free() + + -- Create checkpoint + db:checkpoint(checkpoint_path) + + db:close() + + -- Open checkpoint and verify data + local cp_db = tidesdb.TidesDB.open(checkpoint_path) + local cp_cf = cp_db:get_column_family("test_cf") + local read_txn = cp_db:begin_txn() + local v1 = read_txn:get(cp_cf, "key1") + local v2 = read_txn:get(cp_cf, "key2") + assert_eq(v1, "value1", "checkpoint should contain key1") + assert_eq(v2, "value2", "checkpoint should contain key2") + read_txn:free() + + -- Verify checkpoint to existing non-empty dir fails + cp_db:close() + + local db2 = tidesdb.TidesDB.open(path) + db2:create_column_family("test_cf") + local cf2 = db2:get_column_family("test_cf") + local txn2 = db2:begin_txn() + txn2:put(cf2, "key1", "value1") + txn2:commit() + txn2:free() + + local err = assert_error(function() + db2:checkpoint(checkpoint_path) + end, "checkpoint to non-empty dir should fail") + + db2:close() + cleanup_db(path) + cleanup_db(checkpoint_path) + print("PASS: test_checkpoint") +end + function tests.test_update_runtime_config() local path = "./test_db_runtime_config" cleanup_db(path) diff --git a/tidesdb-0.5.0-1.rockspec b/tidesdb-0.5.1-1.rockspec similarity index 95% rename from tidesdb-0.5.0-1.rockspec rename to tidesdb-0.5.1-1.rockspec index 22fa743..47cf30d 100644 --- a/tidesdb-0.5.0-1.rockspec +++ b/tidesdb-0.5.1-1.rockspec @@ -1,8 +1,8 @@ package = "tidesdb" -version = "0.5.0-1" +version = "0.5.1-1" source = { url = "git://github.com/tidesdb/tidesdb-lua.git", - tag = "v0.5.0" + tag = "v0.5.1" } description = { summary = "Official Lua bindings for TidesDB - A high-performance embedded key-value storage engine", From b18983e5e22259493220cc2997425ec18c66a9d5 Mon Sep 17 00:00:00 2001 From: Alex Gaetano Padula Date: Thu, 12 Feb 2026 11:57:24 -0500 Subject: [PATCH 2/2] minor test correction --- tests/test_tidesdb.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_tidesdb.lua b/tests/test_tidesdb.lua index a367730..8880885 100644 --- a/tests/test_tidesdb.lua +++ b/tests/test_tidesdb.lua @@ -412,12 +412,7 @@ function tests.test_checkpoint() cp_db:close() local db2 = tidesdb.TidesDB.open(path) - db2:create_column_family("test_cf") local cf2 = db2:get_column_family("test_cf") - local txn2 = db2:begin_txn() - txn2:put(cf2, "key1", "value1") - txn2:commit() - txn2:free() local err = assert_error(function() db2:checkpoint(checkpoint_path)