Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4564

Modified Files:
        database.c database.h monetdb.c 
Log Message:
change interface to no longer need the dbfarm, now that we can just
retrieve it from Sabaoth


U database.c
Index: database.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/database.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- database.c  20 Aug 2009 12:04:56 -0000      1.3
+++ database.c  20 Aug 2009 16:11:59 -0000      1.4
@@ -36,10 +36,11 @@
        'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
        '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};
 
-char* db_create(char *dbfarm, char* dbname) {
+char* db_create(char* dbname) {
        sabdb *stats;
        char* e;
        size_t c;
+       char* dbfarm;
        char buf[8096];
        char path[8096];
        FILE *f;
@@ -79,14 +80,23 @@
                return(strdup(buf));
        }
 
+       if ((e = SABAOTHgetDBfarm(&dbfarm)) != MAL_SUCCEED) {
+               snprintf(buf, sizeof(buf), "internal error: %s", e);
+               GDKfree(e);
+               return(strdup(buf));
+       }
+
        /* create the directory */
        c = snprintf(path, sizeof(path), "%s/%s", dbfarm, dbname);
-       if (c >= sizeof(path))
+       if (c >= sizeof(path)) {
+               GDKfree(dbfarm);
                return(strdup("path/dbname combination too long, "
                                "path would get truncated"));
+       }
        if (mkdir(path, 0755) == -1) {
                snprintf(buf, sizeof(buf), "unable to create %s: %s",
                                dbname, strerror(errno));
+               GDKfree(dbfarm);
                return(strdup(buf));
        }
 
@@ -98,6 +108,7 @@
                /* try to cleanup */
                snprintf(path, sizeof(path), "%s/%s", dbfarm, dbname);
                rmdir(path);
+               GDKfree(dbfarm);
                return(strdup("path/dbname combination too long, "
                                "filenames inside would get truncated"));
        }
@@ -116,6 +127,7 @@
        if (fwrite("bla:", 1, 4, f) < 4) {
                snprintf(buf, sizeof(buf), "cannot write lock file: %s",
                                strerror(errno));
+               GDKfree(dbfarm);
                return(strdup(buf));
        }
        fclose(f);
@@ -131,6 +143,7 @@
        if (fwrite(buf, 1, 48, f) < 48) {
                snprintf(buf, sizeof(buf), "cannot write vaultkey: %s",
                                strerror(errno));
+               GDKfree(dbfarm);
                return(strdup(buf));
        }
        fclose(f);
@@ -140,6 +153,7 @@
        snprintf(path, sizeof(path), "%s/%s/.uplog", dbfarm, dbname);
        fclose(fopen(path, "w"));
 
+       GDKfree(dbfarm);
        return(NULL);
 }
 

U monetdb.c
Index: monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- monetdb.c   20 Aug 2009 12:04:56 -0000      1.32
+++ monetdb.c   20 Aug 2009 16:12:02 -0000      1.33
@@ -217,7 +217,7 @@
                if (argv[i] == NULL)
                        continue;
 
-               ret = db_create(dbfarm, argv[i]);
+               ret = db_create(argv[i]);
 
                if (ret == NULL) {
                        printf("successfully created database '%s' "

U database.h
Index: database.h
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/database.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- database.h  20 Aug 2009 12:04:56 -0000      1.3
+++ database.h  20 Aug 2009 16:12:02 -0000      1.4
@@ -20,7 +20,7 @@
 #ifndef _SEEN_DATABASE_H
 #define _SEEN_DATABASE_H 1
 
-char* db_create(char *dbfarm, char* dbname);
+char* db_create(char* dbname);
 char* db_destroy(char* dbname);
 
 #endif


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to