From 0ff5779b599d91783cb2db8538c2430b186730f6 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Mon, 6 Dec 2010 16:06:20 +1100 Subject: [PATCH] add a new ctdb_ltdb function to delete a record in a normal database --- common/ctdb_ltdb.c | 19 +++++++++++++++++++ include/ctdb_private.h | 1 + 2 files changed, 20 insertions(+) diff --git a/common/ctdb_ltdb.c b/common/ctdb_ltdb.c index c9693e83..200cca41 100644 --- a/common/ctdb_ltdb.c +++ b/common/ctdb_ltdb.c @@ -194,3 +194,22 @@ int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key) } return ret; } + + +/* + delete a record from a normal database +*/ +int ctdb_ltdb_delete(struct ctdb_db_context *ctdb_db, TDB_DATA key) +{ + struct ctdb_context *ctdb = ctdb_db->ctdb; + + if (ctdb_db->persistent != 0) { + DEBUG(DEBUG_ERR,("Trying to delete emty record in persistent database\n")); + return 0; + } + if (tdb_delete(ctdb_db->ltdb->tdb, key) != 0) { + DEBUG(DEBUG_ERR,("Failed to delete empty record.")); + return -1; + } + return 0; +} diff --git a/include/ctdb_private.h b/include/ctdb_private.h index 0df5ca5a..ec41270d 100644 --- a/include/ctdb_private.h +++ b/include/ctdb_private.h @@ -647,6 +647,7 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, TDB_DATA *data); int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, TDB_DATA data); +int ctdb_ltdb_delete(struct ctdb_db_context *ctdb_db, TDB_DATA key); int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA recdata); -- 2.34.1