[PATCH 12/14] pytdb: Add support for tdb_repack()
Kirill Smelkov
kirr at landau.phys.spbu.ru
Sun Sep 19 03:53:30 MDT 2010
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 e61391c..98a7b2b 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -414,6 +414,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_dump_all(PyTdbObject *self)
{
tdb_dump_all(self->ctx);
@@ -489,6 +496,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." },
{ "dump_all", (PyCFunction)obj_dump_all, METH_NOARGS, "S.dump_all() -> None" },
{ "printfreelist", (PyCFunction)obj_printfreelist, METH_NOARGS,
"S.print_freelist -> None" },
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index acc9d66..eeefd66 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -166,6 +166,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_dump(self):
self.tdb["foo"] = "1"
self.tdb["bar"] = "2"
--
1.7.3.rc2
More information about the samba-technical
mailing list