Print error strings when transactions fail in ldb tools
[kai/samba.git] / source4 / lib / ldb / tools / ldbmodify.c
index 40affe5f431e5163cb6cc576e3dc758bcf5194c5..0288e4e6885bb197155d37bbbbc32bef16df4f10 100644 (file)
@@ -18,8 +18,7 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -90,9 +89,12 @@ int main(int argc, const char **argv)
        int i, ret=LDB_SUCCESS;
        struct ldb_cmdline *options;
 
-       ldb_global_init();
+       ldb = ldb_init(NULL, NULL);
 
-       ldb = ldb_init(NULL);
+       if (ldb_transaction_start(ldb) != 0) {
+               printf("Failed to start transaction: %s\n", ldb_errstring(ldb));
+               exit(1);
+       }
 
        options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -111,6 +113,11 @@ int main(int argc, const char **argv)
                }
        }
 
+       if (count != 0 && ldb_transaction_commit(ldb) != 0) {
+               printf("Failed to commit transaction: %s\n", ldb_errstring(ldb));
+               exit(1);
+       }
+
        talloc_free(ldb);
 
        printf("Modified %d records with %d failures\n", count, failures);