[PATCH 07/14] pytdb: Add support for tdb_repack()

Kirill Smelkov kirr at landau.phys.spbu.ru
Sat Oct 2 07:43:46 MDT 2010


From: Kirill Smelkov <kirr at mns.spb.ru>

Cc: 597386 at bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr at landau.phys.spbu.ru>
---
 lib/tdb/pytdb.c                |    9 +++++++++
 lib/tdb/python/tests/simple.py |    6 ++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 7ed95a8..0ea6053 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -431,6 +431,13 @@ static PyObject *obj_clear(PyTdbObject *self)
 	Py_RETURN_NONE;
 }
 
+static PyObject *obj_repack(PyTdbObject *self)
+{
+	int ret = tdb_repack(self->ctx);
+	PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
+	Py_RETURN_NONE;
+}
+
 static PyObject *obj_enable_seqnum(PyTdbObject *self)
 {
 	tdb_enable_seqnum(self->ctx);
@@ -500,6 +507,8 @@ static PyMethodDef tdb_object_methods[] = {
 	{ "iterkeys", (PyCFunction)tdb_object_iter, METH_NOARGS, "S.iterkeys() -> iterator" },
 	{ "clear", (PyCFunction)obj_clear, METH_NOARGS, "S.clear() -> None\n"
 		"Wipe the entire database." },
+	{ "repack", (PyCFunction)obj_repack, METH_NOARGS, "S.repack() -> None\n"
+		"Repack the entire database." },
 	{ "enable_seqnum", (PyCFunction)obj_enable_seqnum, METH_NOARGS,
 		"S.enable_seqnum() -> None" },
 	{ "increment_seqnum_nonblock", (PyCFunction)obj_increment_seqnum_nonblock, METH_NOARGS,
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index 576baca..4fe5008 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -183,6 +183,12 @@ class SimpleTdbTests(TestCase):
         self.tdb.clear()
         self.assertEquals(0, len(list(self.tdb)))
 
+    def test_repack(self):
+        self.tdb["foo"] = "abc"
+        self.tdb["bar"] = "def"
+        del self.tdb["foo"]
+        self.tdb.repack()
+
     def test_seqnum(self):
         self.tdb.enable_seqnum()
         seq1 = self.tdb.seqnum
-- 
1.7.3.1.50.g1e633


More information about the samba-technical mailing list