add a new ctdb_ltdb function to delete a record in a normal database
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 6 Dec 2010 05:06:20 +0000 (16:06 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 7 Dec 2010 04:32:17 +0000 (15:32 +1100)
common/ctdb_ltdb.c
include/ctdb_private.h

index c9693e83ee4e3671b4f8b7d75ae6ddeb852ac934..200cca41dc1c119fd866770607af463b8981f1a4 100644 (file)
@@ -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;
+}
index 0df5ca5a9725511a39ac966f83acf65bf6c5c3b4..ec41270de678a34fcb7fa889a3bb458d0833b32e 100644 (file)
@@ -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);