summaryrefslogtreecommitdiff
path: root/ctdb/lib
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@mns.spb.ru>2010-10-02 17:43:46 +0400
committerRusty Russell <rusty@rustcorp.com.au>2010-10-07 15:18:27 +1030
commit30219892d05cede96bd2a478f582e4c550bba44a (patch)
treee5b21700efdfb860e5e0c1ed5334237ad6a0528e /ctdb/lib
parent8270f9bd4ffe1d9d745f6cf8a471cec8510b32cf (diff)
downloadsamba-30219892d05cede96bd2a478f582e4c550bba44a.tar.gz
pytdb: Add support for tdb_repack()
Cc: 597386@bugs.debian.org Signed-off-by: Kirill Smelkov <kirr@landau.phys.spbu.ru> Signed-off-by: Jelmer Vernooij <jelmer@samba.org> (This used to be ctdb commit ce84abcc6be31554da73920280e6bfc5b63b1464)
Diffstat (limited to 'ctdb/lib')
-rw-r--r--ctdb/lib/tdb/pytdb.c9
-rw-r--r--ctdb/lib/tdb/python/tests/simple.py6
2 files changed, 15 insertions, 0 deletions
diff --git a/ctdb/lib/tdb/pytdb.c b/ctdb/lib/tdb/pytdb.c
index c2ba6613692..402fa5d9d3a 100644
--- a/ctdb/lib/tdb/pytdb.c
+++ b/ctdb/lib/tdb/pytdb.c
@@ -343,6 +343,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);
@@ -393,6 +400,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/ctdb/lib/tdb/python/tests/simple.py b/ctdb/lib/tdb/python/tests/simple.py
index b7eb0b5e5a0..92244e3ad2e 100644
--- a/ctdb/lib/tdb/python/tests/simple.py
+++ b/ctdb/lib/tdb/python/tests/simple.py
@@ -137,6 +137,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