Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv1931
Modified Files:
database.c database.h monetdb_release.c
Log Message:
move monetdb release code to database.c:db_release
U database.c
Index: database.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/database.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- database.c 10 Sep 2009 08:04:00 -0000 1.7
+++ database.c 10 Sep 2009 08:20:33 -0000 1.8
@@ -364,3 +364,41 @@
return(NULL);
}
+
+char *db_release(char *dbname) {
+ char *e;
+ sabdb *stats;
+ char path[8096];
+ char buf[8096];
+
+ /* the argument is the database to take under maintenance, see
+ * what Sabaoth can tell us about it */
+ if ((e = SABAOTHgetStatus(&stats, dbname)) != MAL_SUCCEED) {
+ snprintf(buf, sizeof(buf), "internal error: %s", e);
+ GDKfree(e);
+ return(strdup(buf));
+ }
+
+ if (stats == NULL) {
+ snprintf(buf, sizeof(buf), "no such database: %s", dbname);
+ return(strdup(buf));
+ }
+
+ if (stats->locked != 1) {
+ SABAOTHfreeStatus(&stats);
+ snprintf(buf, sizeof(buf), "database '%s' is not "
+ "under maintenance", dbname);
+ return(strdup(buf));
+ }
+
+ /* get this database out of maintenance mode */
+ snprintf(path, sizeof(path), "%s/.maintenance", stats->path);
+ SABAOTHfreeStatus(&stats);
+ if (unlink(path) != 0) {
+ snprintf(buf, sizeof(buf), "could not remove '%s' for '%s': %s",
+ path, dbname, strerror(errno));
+ return(strdup(buf));
+ }
+
+ return(NULL);
+}
U monetdb_release.c
Index: monetdb_release.c
===================================================================
RCS file:
/cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb_release.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- monetdb_release.c 19 Aug 2009 13:41:08 -0000 1.1
+++ monetdb_release.c 10 Sep 2009 08:20:33 -0000 1.2
@@ -32,46 +32,15 @@
/* do for each listed database */
for (i = 1; i < argc; i++) {
- sabdb *stats;
- err e;
- char *dbname = argv[i];
-
- /* the argument is the database to take under maintenance, see
- * what Sabaoth can tell us about it */
- if ((e = SABAOTHgetStatus(&stats, dbname)) != MAL_SUCCEED) {
- fprintf(stderr, "release: internal error: %s\n", e);
- GDKfree(e);
- exit(2);
- }
-
- if (stats != NULL) {
- char path[8096];
-
- if (stats->locked != 1) {
- fprintf(stderr, "release: database '%s' is not "
- "under maintenance\n", dbname);
- SABAOTHfreeStatus(&stats);
- hadwork = 1;
- state |= 1;
- continue;
- }
+ char *e;
- /* put this database in maintenance mode */
- snprintf(path, 8095, "%s/.maintenance", stats->path);
- if (unlink(path) != 0) {
- fprintf(stderr, "failed to take database '%s'
out of "
- " maintenance mode: %s\n",
dbname, strerror(errno));
- SABAOTHfreeStatus(&stats);
- hadwork = 1;
- state |= 1;
- continue;
- }
- printf("database '%s' has been taken out of maintenance
mode\n",
- dbname);
- SABAOTHfreeStatus(&stats);
- } else {
- fprintf(stderr, "release: no such database: %s\n",
dbname);
+ if ((e = db_release(argv[i])) != NULL) {
+ fprintf(stderr, "release: %s\n", e);
+ free(e);
state |= 1;
+ } else {
+ printf("database '%s' has been taken out of maintenance
mode\n",
+ argv[i]);
}
hadwork = 1;
}
U database.h
Index: database.h
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/database.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- database.h 10 Sep 2009 08:04:00 -0000 1.7
+++ database.h 10 Sep 2009 08:20:33 -0000 1.8
@@ -25,5 +25,6 @@
char* db_destroy(char* dbname);
char* db_rename(char *olddb, char *newdb);
char* db_lock(char *dbname);
+char *db_release(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