client: refuse attach with CLEAR_IF_FIRST for persistent DBs
[obnox/ctdb.git] / client / ctdb_client.c
index 334d830707d3a3ad79e899e2f320d1537c9eff33..e128d9b2f2e608091f5866cbb8f1ed16b8edb9af 100644 (file)
@@ -1918,6 +1918,14 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
        TDB_DATA data;
        int ret;
        int32_t res;
+       bool clear_if_first = (tdb_flags & TDB_CLEAR_IF_FIRST);
+
+       if (persistent == clear_if_first) {
+               DEBUG(DEBUG_ERR, ("DB Attach to %s: %s\n", name, persistent
+                                 ? "CLEAR_IF_FIRST is not allowed for persistent databases"
+                                 : "non-persistent databases need CLEAR_IF_FIRST"));
+               return NULL;
+       }
 
        ctdb_db = ctdb_db_handle(ctdb, name);
        if (ctdb_db) {