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

Modified Files:
        merovingian_controlrunner.c monetdb.c monetdb_set.c 
Log Message:
allow merovingian to do renames, make monetdb default to that, let merovingian 
update the discovery upon rename

U merovingian_controlrunner.c
Index: merovingian_controlrunner.c
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/backends/monet5/merovingian/merovingian_controlrunner.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- merovingian_controlrunner.c 9 Sep 2009 12:17:21 -0000       1.9
+++ merovingian_controlrunner.c 9 Sep 2009 13:28:55 -0000       1.10
@@ -328,6 +328,56 @@
                                        SABAOTHfreeStatus(&topdb);
                                        freeConfFile(props);
                                        GDKfree(props);
+                               } else if (strncmp(p, "name=", strlen("name=")) 
== 0) {
+                                       char *e;
+                                       confkeyval *kv, *props = 
getDefaultProps();
+
+                                       p += strlen("name=");
+                                       e = db_rename(q, p);
+                                       if (e != NULL) {
+                                               Mfprintf(_mero_ctlerr, "%s\n", 
e);
+                                               len = snprintf(buf2, 
sizeof(buf2), "%s\n", e);
+                                               send(msgsock, buf2, len, 0);
+                                               free(e);
+                                       } else {
+                                               if ((e = 
SABAOTHgetStatus(&stats, p)) != MAL_SUCCEED) {
+                                                       Mfprintf(_mero_ctlerr, 
"share: SABAOTHgetStatus: "
+                                                                       "%s\n", 
e);
+                                                       freeErr(e);
+                                                       /* should not fail, 
since the rename was
+                                                        * already successful */
+                                               } else {
+                                                       kv = 
findConfKey(_mero_props, "shared");
+                                                       if (strcmp(kv->val, 
"no") != 0) {
+                                                               
readProps(props, stats->path);
+                                                               kv = 
findConfKey(props, "shared");
+                                                               if 
(stats->locked != 1 && 
+                                                                               
(kv->val == NULL ||
+                                                                               
 strcmp(kv->val, "no") != 0))
+                                                               {
+                                                                       
snprintf(buf2, sizeof(buf2),
+                                                                               
        "LEAV %s mapi:monetdb://%s:%hu/",
+                                                                               
        q, _mero_hostname, _mero_port);
+                                                                       
broadcast(buf2);
+                                                                       
snprintf(buf2, sizeof(buf2),
+                                                                               
        "ANNC %s%s%s mapi:monetdb://%s:%hu/ %d",
+                                                                               
        stats->dbname,
+                                                                               
        kv->val == NULL ? "" : "/",
+                                                                               
        kv->val == NULL ? "" : kv->val,
+                                                                               
        _mero_hostname,
+                                                                               
        _mero_port,
+                                                                               
        _mero_discoveryttl + 60);
+                                                                       
broadcast(buf2);
+                                                               }
+                                                               
freeConfFile(props);
+                                                       }
+                                                       
SABAOTHfreeStatus(&stats);
+                                               }
+                                               Mfprintf(_mero_ctlout, "renamed 
database '%s' "
+                                                               "to '%s'\n", q, 
p);
+                                               len = snprintf(buf2, 
sizeof(buf2), "OK\n");
+                                               send(msgsock, buf2, len, 0);
+                                       }
                                } else if (strcmp(q, "anelosimus") == 0 &&
                                                strcmp(p, "eximius") == 0)
                                {

U monetdb.c
Index: monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- monetdb.c   9 Sep 2009 11:47:37 -0000       1.40
+++ monetdb.c   9 Sep 2009 13:28:55 -0000       1.41
@@ -314,7 +314,6 @@
                                ret = out;
                }
 
-
                if (ret == NULL) {
                        printf("successfully destroyed database '%s'\n", 
argv[i]);
                } else {

U monetdb_set.c
Index: monetdb_set.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb_set.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- monetdb_set.c       9 Sep 2009 12:55:34 -0000       1.7
+++ monetdb_set.c       9 Sep 2009 13:28:55 -0000       1.8
@@ -118,6 +118,10 @@
 
        for (stats = orig; stats != NULL; stats = stats->next) {
                if (strcmp(property, "name") == 0) {
+                       char name[4069];
+                       char *res;
+                       char *out;
+
                        /* special virtual case */
                        if (type == INHERIT) {
                                fprintf(stderr, "inherit: cannot default to a 
database name\n");
@@ -128,11 +132,22 @@
                        if (value[0] == '\0')
                                continue;
 
-                       if ((e = db_rename(stats->dbname, value)) != NULL) {
-                               fprintf(stderr, "set: %s\n", e);
-                               free(e);
-                               state |= 1;
-                               continue;
+                       if (mero_running == 0) {
+                               if ((e = db_rename(stats->dbname, value)) != 
NULL) {
+                                       fprintf(stderr, "set: %s\n", e);
+                                       free(e);
+                                       state |= 1;
+                                       continue;
+                               }
+                       } else {
+                               snprintf(name, sizeof(name), "name=%s", value);
+                               out = control_send(&res, mero_control, -1, 
stats->dbname, name);
+                               if (out != NULL || strcmp(res, "OK") != 0) {
+                                       res = out == NULL ? res : out;
+                                       fprintf(stderr, "%s: %s\n", argv[0], 
res);
+                                       state |= 1;
+                               }
+                               free(res);
                        }
                } else if (strcmp(property, "shared") == 0) {
                        char share[4069];


------------------------------------------------------------------------------
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