From 4c185a6077322ba64231d23dda25a6b6d44d0b12 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 10 May 2007 10:42:13 +0000 Subject: r22775: For the cluster code I've developed a wrapper around tdb to put different database backends in place dynamically. The main abstractions are db_context and db_record, it should be mainly self-describing, see include/dbwrap.h. You open the db just as you would open a tdb, this time with db_open(). If you want to fetch a record, just do the db->fetch() call, if you want to do operations on it, you need to get it with fetch_locked(). I added dbwrap_file.c (not heavily tested lately) as an example for what can be done with that abstraction, uses a file per key. So if anybody is willing to shape that up, we might have a chance on reiserfs again.... :-) This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and sessionid.tdb. It should work fine for the others as well, I just did not yet get around to convert them. If nobody loudly screams NO, then I will import the code that uses this soon. Volker (This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe) --- source3/lib/dbwrap.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 source3/lib/dbwrap.c (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c new file mode 100644 index 0000000000..9f74a9eb48 --- /dev/null +++ b/source3/lib/dbwrap.c @@ -0,0 +1,61 @@ +/* + Unix SMB/CIFS implementation. + Database interface wrapper + Copyright (C) Jim McDonough 2006 + + Major code contributions from Aleksey Fedoseev (fedoseev@ru.ibm.com) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + * Fall back using fetch_locked if no genuine fetch operation is provided + */ + +static int dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *data) +{ + struct db_record *rec; + + if (!(rec = db->fetch_locked(db, mem_ctx, key))) { + return -1; + } + + data->dsize = rec->value.dsize; + data->dptr = talloc_move(mem_ctx, &rec->value.dptr); + TALLOC_FREE(rec); + return 0; +} + +struct db_context *db_open(TALLOC_CTX *mem_ctx, + const char *name, + int hash_size, int tdb_flags, + int open_flags, mode_t mode) +{ + struct db_context *result = NULL; + + if (result == NULL) { + result = db_open_tdb(mem_ctx, name, hash_size, + tdb_flags, open_flags, mode); + } + + if ((result != NULL) && (result->fetch == NULL)) { + result->fetch = dbwrap_fallback_fetch; + } + + return result; +} -- cgit From de565785f5e1f097bd75f57331425c4185185f80 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 10 Jun 2007 17:02:09 +0000 Subject: r23410: Merge the core of the cluster code. I'm 100% certain I've forgotten to merge something, but the main code should be in. It's mainly in dbwrap_ctdb.c, ctdbd_conn.c and messages_ctdbd.c. There should be no changes to the non-cluster case, it does survive make test on my laptop. It survives some very basic tests with ctdbd enables, I did not do the full test suite for clusters yet. Phew... Volker (This used to be commit 15553d6327a3aecdd2b0b94a3656d04bf4106323) --- source3/lib/dbwrap.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 9f74a9eb48..c06cd4bb16 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -48,6 +48,32 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, { struct db_context *result = NULL; +#ifdef CLUSTER_SUPPORT + + if (lp_clustering()) { + const char *partname; + /* ctdb only wants the file part of the name */ + partname = strrchr(name, '/'); + if (partname) { + partname++; + } else { + partname = name; + } + /* allow ctdb for individual databases to be disabled */ + if (lp_parm_bool(-1, "ctdb", partname, True)) { + result = db_open_ctdb(mem_ctx, partname, hash_size, + tdb_flags, open_flags, mode); + if (result == NULL) { + DEBUG(0,("failed to attach to ctdb %s\n", + partname)); + smb_panic("failed to attach to a ctdb " + "database"); + } + } + } + +#endif + if (result == NULL) { result = db_open_tdb(mem_ctx, name, hash_size, tdb_flags, open_flags, mode); -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/lib/dbwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index c06cd4bb16..cf7699f679 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/lib/dbwrap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index cf7699f679..3abd0e2ba5 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 94a354493aef434510183146a548c4ef08009014 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 24 Nov 2007 19:56:16 +0100 Subject: Add dbwrap bystring service routines (This used to be commit 1e214b536b0628db299d701839e62a4ac52727c9) --- source3/lib/dbwrap.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 3abd0e2ba5..4e16d18682 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -84,3 +84,45 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, return result; } + +NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) +{ + struct db_record *rec; + NTSTATUS status; + + rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key)); + if (rec == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = rec->delete_rec(rec); + TALLOC_FREE(rec); + return status; +} + +NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, + TDB_DATA data, int flags) +{ + struct db_record *rec; + NTSTATUS status; + + rec = db->fetch_locked(db, talloc_tos(), string_term_tdb_data(key)); + if (rec == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = rec->store(rec, data, flags); + TALLOC_FREE(rec); + return status; +} + +TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key) +{ + TDB_DATA result; + + if (db->fetch(db, mem_ctx, string_term_tdb_data(key), &result) == -1) { + return make_tdb_data(NULL, 0); + } + + return result; +} -- cgit From 68694369fc96354452979b07425f3f48c4f73bbe Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 16 Jan 2008 12:09:48 +0300 Subject: Merge CTDB-related fixes from samba-ctdb 3.0 branch (http://samba.org/~tridge/3_0-ctdb) Signed-off-by: Alexander Bokovoy (This used to be commit 0c8e23afbbb2d081fc23908bafcad04650bfacea) --- source3/lib/dbwrap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 4e16d18682..001424a6c0 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -20,7 +20,9 @@ */ #include "includes.h" - +#ifdef CLUSTER_SUPPORT +#include "ctdb_private.h" +#endif /* * Fall back using fetch_locked if no genuine fetch operation is provided */ @@ -46,10 +48,16 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, int open_flags, mode_t mode) { struct db_context *result = NULL; +#ifdef CLUSTER_SUPPORT + const char *sockname = lp_ctdbd_socket(); +#endif #ifdef CLUSTER_SUPPORT + if(!sockname || !*sockname) { + sockname = CTDB_PATH; + } - if (lp_clustering()) { + if (lp_clustering() && socket_exist(sockname)) { const char *partname; /* ctdb only wants the file part of the name */ partname = strrchr(name, '/'); -- cgit From 474916b70c4bed3accd8592ff82aa2d6f90c8e8d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 27 Mar 2008 16:08:21 +0100 Subject: dbwrap: add db_open_trans() This should be used when transactions are wanted. For now it's just a wrapper of db_open(), but this will change. metze Signed-off-by: Stefan Metzmacher (This used to be commit 74a070b8a24fea1009e557f711b76fc14e8961dc) --- source3/lib/dbwrap.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 001424a6c0..fd924639a9 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -42,6 +42,9 @@ static int dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, return 0; } +/** + * If you need transaction support use db_open_trans() + */ struct db_context *db_open(TALLOC_CTX *mem_ctx, const char *name, int hash_size, int tdb_flags, @@ -93,6 +96,18 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, return result; } +/** + * If you use this you can only modify with a transaction + */ +struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, + const char *name, + int hash_size, int tdb_flags, + int open_flags, mode_t mode) +{ + /* TODO: implement this differently */ + return db_open(mem_ctx, name, hash_size, tdb_flags, open_flags, mode); +} + NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) { struct db_record *rec; -- cgit From 138b58bcec67e4a45cfa28213fc667504755a894 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 26 Mar 2008 10:08:10 +0100 Subject: dbwrap: use db_open_tdb2() in for db_open_trans() if "dbwrap:use_tdb2=yes" For clustered setups you need to disable the ctdb backend for each tdb which should use the tdb2 backend (e.g. ctdb:registry.tdb=no). To disable tdb2 per tdb use something like "tdb2:passdb.tdb=no" metze (This used to be commit 5cea2bf3673c982bafeef4a8bbd3bd2ab73cc0c5) --- source3/lib/dbwrap.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index fd924639a9..d688b83d73 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -104,8 +104,63 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, int hash_size, int tdb_flags, int open_flags, mode_t mode) { - /* TODO: implement this differently */ - return db_open(mem_ctx, name, hash_size, tdb_flags, open_flags, mode); + bool use_tdb2 = lp_parm_bool(-1, "dbwrap", "use_tdb2", false); +#ifdef CLUSTER_SUPPORT + const char *sockname = lp_ctdbd_socket(); +#endif + + if (tdb_flags & TDB_CLEAR_IF_FIRST) { + DEBUG(0,("db_open_trans: called with TDB_CLEAR_IF_FIRST: %s\n", + name)); + smb_panic("db_open_trans: called with TDB_CLEAR_IF_FIRST"); + } + +#ifdef CLUSTER_SUPPORT + if(!sockname || !*sockname) { + sockname = CTDB_PATH; + } + + if (lp_clustering() && socket_exist(sockname)) { + const char *partname; + /* ctdb only wants the file part of the name */ + partname = strrchr(name, '/'); + if (partname) { + partname++; + } else { + partname = name; + } + /* allow ctdb for individual databases to be disabled */ + if (lp_parm_bool(-1, "ctdb", partname, true)) { + result = db_open_ctdb(mem_ctx, partname, hash_size, + tdb_flags, open_flags, mode); + if (result == NULL) { + DEBUG(0,("failed to attach to ctdb %s\n", + partname)); + smb_panic("failed to attach to a ctdb " + "database"); + } + } + } +#endif + + if (use_tdb2) { + const char *partname; + /* tdb2 only wants the file part of the name */ + partname = strrchr(name, '/'); + if (partname) { + partname++; + } else { + partname = name; + } + /* allow ctdb for individual databases to be disabled */ + if (lp_parm_bool(-1, "tdb2", partname, true)) { + return db_open_tdb2(mem_ctx, partname, hash_size, + tdb_flags, open_flags, mode); + } + } + + return db_open_tdb(mem_ctx, name, hash_size, + tdb_flags, open_flags, mode); } NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) -- cgit From 313abd3ac22005800e625a9931e9c403d60b8c79 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 Apr 2008 12:53:11 +0200 Subject: Fix the build of db_open_trans with CLUSTER_SUPPORT enabled Metze, you might want to check this. (This used to be commit 3b4a402bc5c3490000581d43a12388883bcf8150) --- source3/lib/dbwrap.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index d688b83d73..7fe1631bff 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -131,6 +131,7 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, } /* allow ctdb for individual databases to be disabled */ if (lp_parm_bool(-1, "ctdb", partname, true)) { + struct db_context *result = NULL; result = db_open_ctdb(mem_ctx, partname, hash_size, tdb_flags, open_flags, mode); if (result == NULL) { @@ -139,6 +140,7 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, smb_panic("failed to attach to a ctdb " "database"); } + return result; } } #endif -- cgit From 32df537a24f8f24a90dd9f159efc5e2bf527e43f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 14 Jul 2008 10:43:28 +0200 Subject: dbwrap: when clustering = yes, don't fall back to db_open_tdb in db_open Michael (This used to be commit 33188a991f7e2f8dc1b5beed1dde1b7f77403e1a) --- source3/lib/dbwrap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 7fe1631bff..a686ba6b7c 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -60,8 +60,15 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, sockname = CTDB_PATH; } - if (lp_clustering() && socket_exist(sockname)) { + if (lp_clustering()) { const char *partname; + + if (!socket_exist(sockname)) { + DEBUG(1, ("ctdb socket does not exist - is ctdb not " + "running?\n")); + return NULL; + } + /* ctdb only wants the file part of the name */ partname = strrchr(name, '/'); if (partname) { -- cgit From 56681032b288ed924b40ab353c632a1fb153759d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 14 Jul 2008 10:53:06 +0200 Subject: dbwrap: when clustering = yes, don't fall back to db_open_tdb in db_open_trans. Michael (This used to be commit 013d29c70438bfd43bd11cbb13ba707b256f9b18) --- source3/lib/dbwrap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index a686ba6b7c..6dfe0b3766 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -127,8 +127,15 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, sockname = CTDB_PATH; } - if (lp_clustering() && socket_exist(sockname)) { + if (lp_clustering()) { const char *partname; + + if (!socket_exist(sockname)) { + DEBUG(1, ("ctdb socket does not exist - is ctdb not " + "running?\n")); + return NULL; + } + /* ctdb only wants the file part of the name */ partname = strrchr(name, '/'); if (partname) { -- cgit From 5a8b0fe99f302e5d1ff2b47a1fe617ccd3a8b7b7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 15 Jul 2008 15:27:14 +0200 Subject: dbwrap: don't panic in db_open() when attaching to ctdb fails. Michael (This used to be commit b9c008d9bd8b8119007e7ad03a40235998af4f5c) --- source3/lib/dbwrap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 6dfe0b3766..b498c46615 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -83,8 +83,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, if (result == NULL) { DEBUG(0,("failed to attach to ctdb %s\n", partname)); - smb_panic("failed to attach to a ctdb " - "database"); + return NULL; } } } -- cgit From 3899851af02bb5b858ee025504b4c7f12385c0c7 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 15 Jul 2008 15:27:46 +0200 Subject: dbwrap: don't panic in db_open_trans() when attaching to ctdb fails. Michael (This used to be commit 308fc7d5bf5f5ccfc73677b052a4e6ecede25921) --- source3/lib/dbwrap.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index b498c46615..2bff5d9257 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -150,8 +150,6 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, if (result == NULL) { DEBUG(0,("failed to attach to ctdb %s\n", partname)); - smb_panic("failed to attach to a ctdb " - "database"); } return result; } -- cgit From fc6216b2da1087065c26e874058de74ced692fcc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 15 Jul 2008 16:43:26 +0200 Subject: dbwrap: don't panic in db_open_trans() if called with TDB_CLEAR_IF_FIRST. return NULL instead and leave appropriated measures to the caller. Michael (This used to be commit 1002507b56a13420d8178c5397610edd839a7584) --- source3/lib/dbwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index 2bff5d9257..eec15a84bd 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -118,7 +118,7 @@ struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, if (tdb_flags & TDB_CLEAR_IF_FIRST) { DEBUG(0,("db_open_trans: called with TDB_CLEAR_IF_FIRST: %s\n", name)); - smb_panic("db_open_trans: called with TDB_CLEAR_IF_FIRST"); + return NULL; } #ifdef CLUSTER_SUPPORT -- cgit From 89dc729443fad26da346b8ef8d3ce596449ab7f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Aug 2008 17:21:11 +1000 Subject: ensure we give an error code to any routines above that are looking for one (This used to be commit 469ba9b87103aa0053c371e481acc5acf0f98ac1) --- source3/lib/dbwrap.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index eec15a84bd..ff200c35c0 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -83,6 +83,9 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, if (result == NULL) { DEBUG(0,("failed to attach to ctdb %s\n", partname)); + if (errno == 0) { + errno = EIO; + } return NULL; } } -- cgit From 0f41961e4ffaa602a5b19a1e0899bffa491c886f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 7 Aug 2008 16:20:05 +1000 Subject: first cut at adding full transactions for ctdb to samba3 (This used to be commit f91a3e0f7b7737c1d0667cd961ea950e2b93e592) --- source3/lib/dbwrap.c | 76 +--------------------------------------------------- 1 file changed, 1 insertion(+), 75 deletions(-) (limited to 'source3/lib/dbwrap.c') diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c index ff200c35c0..73c2761a1b 100644 --- a/source3/lib/dbwrap.c +++ b/source3/lib/dbwrap.c @@ -43,7 +43,7 @@ static int dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, } /** - * If you need transaction support use db_open_trans() + * open a database */ struct db_context *db_open(TALLOC_CTX *mem_ctx, const char *name, @@ -105,80 +105,6 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, return result; } -/** - * If you use this you can only modify with a transaction - */ -struct db_context *db_open_trans(TALLOC_CTX *mem_ctx, - const char *name, - int hash_size, int tdb_flags, - int open_flags, mode_t mode) -{ - bool use_tdb2 = lp_parm_bool(-1, "dbwrap", "use_tdb2", false); -#ifdef CLUSTER_SUPPORT - const char *sockname = lp_ctdbd_socket(); -#endif - - if (tdb_flags & TDB_CLEAR_IF_FIRST) { - DEBUG(0,("db_open_trans: called with TDB_CLEAR_IF_FIRST: %s\n", - name)); - return NULL; - } - -#ifdef CLUSTER_SUPPORT - if(!sockname || !*sockname) { - sockname = CTDB_PATH; - } - - if (lp_clustering()) { - const char *partname; - - if (!socket_exist(sockname)) { - DEBUG(1, ("ctdb socket does not exist - is ctdb not " - "running?\n")); - return NULL; - } - - /* ctdb only wants the file part of the name */ - partname = strrchr(name, '/'); - if (partname) { - partname++; - } else { - partname = name; - } - /* allow ctdb for individual databases to be disabled */ - if (lp_parm_bool(-1, "ctdb", partname, true)) { - struct db_context *result = NULL; - result = db_open_ctdb(mem_ctx, partname, hash_size, - tdb_flags, open_flags, mode); - if (result == NULL) { - DEBUG(0,("failed to attach to ctdb %s\n", - partname)); - } - return result; - } - } -#endif - - if (use_tdb2) { - const char *partname; - /* tdb2 only wants the file part of the name */ - partname = strrchr(name, '/'); - if (partname) { - partname++; - } else { - partname = name; - } - /* allow ctdb for individual databases to be disabled */ - if (lp_parm_bool(-1, "tdb2", partname, true)) { - return db_open_tdb2(mem_ctx, partname, hash_size, - tdb_flags, open_flags, mode); - } - } - - return db_open_tdb(mem_ctx, name, hash_size, - tdb_flags, open_flags, mode); -} - NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key) { struct db_record *rec; -- cgit