1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-02 08:58:33 +03:00

added a TDB_MODIFY flag to tdb_store() that says "if the record

doesn't exist then fail the store"
(This used to be commit 6aec1457f8772cf81b88a0a00cc2ad7c16cd0d87)
This commit is contained in:
Andrew Tridgell 2004-03-28 01:38:42 +00:00
parent 2fe43ec90f
commit ad15f42b6d
2 changed files with 7 additions and 0 deletions

View File

@ -1479,6 +1479,12 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
/* first try in-place update, on modify or replace. */
if (tdb_update_hash(tdb, key, hash, dbuf) == 0)
goto out;
if (tdb->ecode == TDB_ERR_NOEXIST &&
flag == TDB_MODIFY) {
/* if the record doesn't exist and we are in TDB_MODIFY mode then
we should fail the store */
goto fail;
}
}
/* reset the error code potentially set by the tdb_update() */
tdb->ecode = TDB_SUCCESS;

View File

@ -29,6 +29,7 @@ extern "C" {
/* flags to tdb_store() */
#define TDB_REPLACE 1
#define TDB_INSERT 2
#define TDB_MODIFY 3
/* flags for tdb_open() */
#define TDB_DEFAULT 0 /* just a readability place holder */