Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4381
Modified Files:
Makefile.ag monetdb.c
Removed Files:
monetdb_set.c
Log Message:
merge back set code into main monetdb.c, it only consists of wrapping code now,
all logic is in separate files called both by monetdb (when without
merovingian) and merovingian
U Makefile.ag
Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/Makefile.ag,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Makefile.ag 7 Sep 2009 09:21:56 -0000 1.8
+++ Makefile.ag 9 Sep 2009 20:13:57 -0000 1.9
@@ -38,7 +38,6 @@
monetdb_lock.c \
monetdb_merocom.c \
monetdb_release.c \
- monetdb_set.c \
monetdb_status.c
EXTRA_DIST = $(man_MANS) \
U monetdb.c
Index: monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- monetdb.c 9 Sep 2009 13:28:55 -0000 1.41
+++ monetdb.c 9 Sep 2009 20:13:57 -0000 1.42
@@ -183,7 +183,162 @@
#include "monetdb_status.c"
#include "monetdb_discover.c"
#include "monetdb_merocom.c"
-#include "monetdb_set.c"
+
+typedef enum {
+ SET = 0,
+ INHERIT
+} meroset;
+
+static void
+command_set(int argc, char *argv[], meroset type)
+{
+ char *p, *value = NULL;
+ char property[24] = "";
+ err e;
+ int i;
+ int state = 0;
+ sabdb *stats;
+ confkeyval *props = getDefaultProps();
+
+ if (argc >= 1 && argc <= 2) {
+ /* print help message for this command */
+ command_help(2, &argv[-1]);
+ exit(1);
+ } else if (argc == 0) {
+ exit(2);
+ }
+
+ /* time to collect some option flags */
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] == '-') {
+ for (p = argv[i] + 1; *p != '\0'; p++) {
+ switch (*p) {
+ case '-':
+ if (p[1] == '\0') {
+ i = argc;
+ break;
+ }
+ default:
+ fprintf(stderr, "%s: unknown
option: -%c\n",
+ argv[0], *p);
+ command_help(2, &argv[-1]);
+ exit(1);
+ break;
+ }
+ }
+ /* make this option no longer available, for easy use
+ * lateron */
+ argv[i] = NULL;
+ } else if (property[0] == '\0') {
+ /* first non-option is property, rest is database */
+ p = argv[i];
+ if (type == SET) {
+ if ((p = strchr(argv[i], '=')) == NULL) {
+ fprintf(stderr, "set: need
property=value\n");
+ command_help(2, &argv[-1]);
+ exit(1);
+ }
+ *p = '\0';
+ snprintf(property, sizeof(property), "%s",
argv[i]);
+ *p++ = '=';
+ value = p;
+ p = argv[i];
+ } else {
+ snprintf(property, sizeof(property), "%s",
argv[i]);
+ }
+ argv[i] = NULL;
+ }
+ }
+
+ if (property[0] == '\0') {
+ fprintf(stderr, "%s: need a property argument\n", argv[0]);
+ command_help(2, &argv[-1]);
+ exit(1);
+ }
+
+ /* handle rename separately due to single argument constraint */
+ if (strcmp(property, "name") == 0) {
+ if (type == INHERIT) {
+ fprintf(stderr, "inherit: cannot default to a database
name\n");
+ exit(1);
+ }
+
+ if (argc > 3) {
+ fprintf(stderr, "%s: cannot rename multiple databases
to "
+ "the same name\n", argv[0]);
+ exit(1);
+ }
+
+ if (mero_running == 0) {
+ if ((e = db_rename(stats->dbname, value)) != NULL) {
+ fprintf(stderr, "set: %s\n", e);
+ free(e);
+ exit(1);
+ }
+ } else {
+ char *res;
+ char *out;
+
+ out = control_send(&res, mero_control, -1, argv[2], p);
+ if (out != NULL || strcmp(res, "OK") != 0) {
+ res = out == NULL ? res : out;
+ fprintf(stderr, "%s: %s\n", argv[0], res);
+ state |= 1;
+ }
+ free(res);
+ }
+
+ GDKfree(props);
+ exit(state);
+ }
+
+ for (i = 1; i < argc; i++) {
+ if (argv[i] == NULL)
+ continue;
+
+ if (mero_running == 0) {
+ if ((e = SABAOTHgetStatus(&stats, argv[i])) !=
MAL_SUCCEED) {
+ fprintf(stderr, "%s: internal error: %s\n",
argv[0], e);
+ GDKfree(e);
+ exit(2);
+ }
+
+ if (stats == NULL) {
+ fprintf(stderr, "%s: no such database: %s\n",
+ argv[0], argv[i]);
+ state |= 1;
+ continue;
+ }
+
+ if ((e = setProp(stats->path, property, value)) !=
NULL) {
+ fprintf(stderr, "%s: %s\n", argv[0], e);
+ free(e);
+ state |= 1;
+ }
+
+ SABAOTHfreeStatus(&stats);
+ } else {
+ char *res;
+ char *out;
+
+ if (type == INHERIT) {
+ strncat(property, "=", sizeof(property));
+ p = property;
+ }
+ out = control_send(&res, mero_control, 0, argv[i], p);
+ if (out != NULL || strcmp(res, "OK") != 0) {
+ res = out == NULL ? res : out;
+ fprintf(stderr, "%s: %s\n", argv[0], res);
+ state |= 1;
+ }
+ free(res);
+ }
+ }
+
+ GDKfree(props);
+ exit(state);
+}
+
#include "monetdb_get.c"
static void
--- monetdb_set.c DELETED ---
------------------------------------------------------------------------------
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