Changeset: 3433912871c0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3433912871c0
Branch: default
Log Message:

Merge heads.


diffs (256 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1386,7 +1386,7 @@ str mal2str(MalBlkPtr mb, int first, int
 int malAtomSize(int size, const char *name);
 str malBootstrap(char *modules[], int embedded);
 str malCommandCall(MalStkPtr stk, InstrPtr pci);
-str malEmbeddedBoot(int workerlimit, int memorylimit, int querytimeout, int 
sessionlimit);
+str malEmbeddedBoot(int workerlimit, int memorylimit, int querytimeout, int 
sessionlimit, int with_mapi_server);
 void malEmbeddedReset(void);
 _Noreturn void malEmbeddedStop(int status);
 str malExtraModulesBoot(Client c, str extraMalModules[], char *mal_scripts);
diff --git a/ctest/monetdb5/mal/test_malEmbeddedBoot.c 
b/ctest/monetdb5/mal/test_malEmbeddedBoot.c
--- a/ctest/monetdb5/mal/test_malEmbeddedBoot.c
+++ b/ctest/monetdb5/mal/test_malEmbeddedBoot.c
@@ -21,7 +21,7 @@ main(void)
        msg = createException(MAL, "embedded.monetdb_startup", "GDKinit() 
failed");
         return 1;
     }
-    if ((msg = malEmbeddedBoot(0, 0, 0, 0)) != MAL_SUCCEED)
+    if ((msg = malEmbeddedBoot(0, 0, 0, 0, 0)) != MAL_SUCCEED)
         return 1;
     return 0;
 }
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -391,10 +391,7 @@ AUTHinitTables(const char *passwd) {
                        passwd = "monetdb";     /* default password */
                pw = mcrypt_BackendSum(passwd, strlen(passwd));
                if(!pw) {
-                       if (!GDKembedded())
-                               throw(MAL, "initTables", SQLSTATE(42000) "Crypt 
backend hash not found");
-                       else
-                               pw = strdup(passwd);
+                       throw(MAL, "initTables", SQLSTATE(42000) "Crypt backend 
hash not found");
                }
                msg = AUTHaddUser(&uid, NULL, "monetdb", pw);
                free(pw);
@@ -521,11 +518,8 @@ AUTHaddUser(oid *uid, Client cntxt, cons
                throw(MAL, "addUser", "user '%s' already exists", username);
 
        /* we assume the BATs are still aligned */
-       if (!GDKembedded()) {
-               rethrow("addUser", tmp, AUTHcypherValue(&hash, passwd));
-       } else {
-               hash = GDKstrdup("hash");
-       }
+       rethrow("addUser", tmp, AUTHcypherValue(&hash, passwd));
+
        /* needs force, as SQL makes a view over user */
        if (BUNappend(user, username, true) != GDK_SUCCEED ||
                BUNappend(pass, hash, true) != GDK_SUCCEED) {
@@ -537,8 +531,7 @@ AUTHaddUser(oid *uid, Client cntxt, cons
        p = AUTHfindUser(username);
 
        /* make the stuff persistent */
-       if (!GDKembedded())
-               AUTHcommit();
+       AUTHcommit();
 
        *uid = p;
        return(MAL_SUCCEED);
@@ -993,8 +986,6 @@ AUTHverifyPassword(const char *passwd)
 
        return(MAL_SUCCEED);
 #else
-       if (GDKembedded())
-               return(MAL_SUCCEED);
        (void) passwd;
        throw(MAL, "verifyPassword", "Unknown backend hash algorithm: %s",
                  MONETDB5_PASSWDHASH);
diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c
--- a/monetdb5/mal/mal_embedded.c
+++ b/monetdb5/mal/mal_embedded.c
@@ -40,7 +40,7 @@
 static bool embeddedinitialized = false;
 
 str
-malEmbeddedBoot(int workerlimit, int memorylimit, int querytimeout, int 
sessiontimeout)
+malEmbeddedBoot(int workerlimit, int memorylimit, int querytimeout, int 
sessiontimeout, int with_mapi_server)
 {
        Client c;
        str msg = MAL_SUCCEED;
@@ -120,7 +120,7 @@ malEmbeddedBoot(int workerlimit, int mem
                return msg;
        }
        char *modules[3] = { "embedded", "sql" };
-       if ((msg = malIncludeModules(c, modules, 0, 1)) != MAL_SUCCEED) {
+       if ((msg = malIncludeModules(c, modules, 0, !with_mapi_server)) != 
MAL_SUCCEED) {
                MCcloseClient(c);
                return msg;
        }
diff --git a/monetdb5/mal/mal_embedded.h b/monetdb5/mal/mal_embedded.h
--- a/monetdb5/mal/mal_embedded.h
+++ b/monetdb5/mal/mal_embedded.h
@@ -16,7 +16,7 @@
 
 #define MAXMODULES  128
 
-mal_export str malEmbeddedBoot(int workerlimit, int memorylimit, int 
querytimeout, int sessionlimit);
+mal_export str malEmbeddedBoot(int workerlimit, int memorylimit, int 
querytimeout, int sessionlimit, int with_mapi_server);
 mal_export str malExtraModulesBoot(Client c, str extraMalModules[], char* 
mal_scripts);
 mal_export void malEmbeddedReset(void);
 mal_export _Noreturn void malEmbeddedStop(int status);
diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c
--- a/monetdb5/mal/mal_prelude.c
+++ b/monetdb5/mal/mal_prelude.c
@@ -394,7 +394,7 @@ melFunction(bool command, char *mod, cha
 }
 
 static str
-malPrelude(Client c, int listing, int embedded)
+malPrelude(Client c, int listing, int no_mapi_server)
 {
        int i;
        str msg = MAL_SUCCEED;
@@ -420,8 +420,8 @@ malPrelude(Client c, int listing, int em
                        if (msg)
                                return msg;
 
-                       /* skip sql should be last to startup and mapi in the 
embedded version */
-                       if (strcmp(mel_module_name[i], "sql") == 0 || (embedded 
&& strcmp(mel_module_name[i], "mapi") == 0))
+                       /* skip sql should be last to startup and mapi if 
configured without mapi server */
+                       if (strcmp(mel_module_name[i], "sql") == 0 || 
(no_mapi_server && strcmp(mel_module_name[i], "mapi") == 0))
                                continue;
                        if (!mel_module_inits[i]) {
                                msg = initModule(c, mel_module_name[i]);
@@ -433,8 +433,8 @@ malPrelude(Client c, int listing, int em
                        msg = mel_module_inits[i]();
                        if (msg)
                                return msg;
-                       /* skip sql should be last to startup and mapi in the 
embedded version */
-                       if (strcmp(mel_module_name[i], "sql") == 0 || (embedded 
&& strcmp(mel_module_name[i], "mapi") == 0))
+                       /* skip sql should be last to startup and mapi if 
configured without mapi server */
+                       if (strcmp(mel_module_name[i], "sql") == 0 || 
(no_mapi_server && strcmp(mel_module_name[i], "mapi") == 0))
                                continue;
                        msg = initModule(c, mel_module_name[i]);
                        if (msg)
@@ -445,7 +445,7 @@ malPrelude(Client c, int listing, int em
 }
 
 str
-malIncludeModules(Client c, char *modules[], int listing, int embedded)
+malIncludeModules(Client c, char *modules[], int listing, int no_mapi_server)
 {
        int i;
        str msg;
@@ -458,7 +458,7 @@ malIncludeModules(Client c, char *module
                        return msg;
        }
        /* load the mal code for these modules and execute preludes */
-       if ((msg = malPrelude(c, listing, embedded)) != NULL)
+       if ((msg = malPrelude(c, listing, no_mapi_server)) != NULL)
                return msg;
        for(int i = 0; modules[i]; i++) {
                if (strcmp(modules[i], "sql") == 0) { /* start now */
diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -600,7 +600,7 @@ SQLinitClient(Client c)
                MT_lock_unset(&sql_contextLock);
                throw(SQL, "SQLinitClient", SQLSTATE(42000) "Catalogue not 
available");
        }
-       msg = SQLprepareClient(c, !GDKembedded());
+       msg = SQLprepareClient(c, true);
        MT_lock_unset(&sql_contextLock);
        return msg;
 }
diff --git a/tools/monetdbe/monetdbe.c b/tools/monetdbe/monetdbe.c
--- a/tools/monetdbe/monetdbe.c
+++ b/tools/monetdbe/monetdbe.c
@@ -479,10 +479,12 @@ monetdbe_startup(monetdbe_database_inter
        const char* mbedded = "MBEDDED";
        opt *set = NULL;
        int setlen;
+       bool with_mapi_server;
        int workers, memory, querytimeout, sessiontimeout;
        gdk_return gdk_res;
 
        GDKfataljumpenable = 1;
+
        if(setjmp(GDKfataljump) != 0) {
                assert(0);
                mdbe->msg = GDKfatalmsg;
@@ -492,6 +494,8 @@ monetdbe_startup(monetdbe_database_inter
                goto cleanup;
        }
 
+        with_mapi_server = false;
+
        if (monetdbe_embedded_initialized) {
                mdbe->msg = createException(MAL, "monetdbe.monetdbe_startup", 
"MonetDBe is already initialized");
                return;
@@ -517,6 +521,29 @@ monetdbe_startup(monetdbe_database_inter
                goto cleanup;
        }
 
+       if (opts && opts->mapi_server) {
+               /*This monetdbe instance wants to listen to external mapi 
client connections.*/
+               with_mapi_server = true;
+               if (opts->mapi_server->port) {
+                       int psetlen = setlen;
+                       setlen = mo_add_option(&set, setlen, opt_cmdline, 
"mapi_port", opts->mapi_server->port);
+                       if (setlen == psetlen) {
+                               mo_free_options(set, setlen);
+                               mdbe->msg = createException(MAL, 
"monetdbe.monetdbe_startup", MAL_MALLOC_FAIL);
+                               goto cleanup;
+                       }
+               }
+               if (opts->mapi_server->usock) {
+                       int psetlen = setlen;
+                       setlen = mo_add_option(&set, setlen, opt_cmdline, 
"mapi_usock", opts->mapi_server->usock);
+                       if (setlen == psetlen) {
+                               mo_free_options(set, setlen);
+                               mdbe->msg = createException(MAL, 
"monetdbe.monetdbe_startup", MAL_MALLOC_FAIL);
+                               goto cleanup;
+                       }
+               }
+       }
+
        GDKtracer_set_adapter(mbedded); /* set the output of GDKtracer logs */
 
        workers = 0;
@@ -582,7 +609,8 @@ monetdbe_startup(monetdbe_database_inter
                mdbe->msg = createException(MAL, "monetdbe.monetdbe_startup", 
"GDKinit() failed");
                goto cleanup;
        }
-       if ((mdbe->msg = malEmbeddedBoot(workers, memory, querytimeout, 
sessiontimeout)) != MAL_SUCCEED)
+
+       if ((mdbe->msg = malEmbeddedBoot(workers, memory, querytimeout, 
sessiontimeout, with_mapi_server)) != MAL_SUCCEED)
                goto cleanup;
 
        monetdbe_embedded_initialized = true;
diff --git a/tools/monetdbe/monetdbe.h b/tools/monetdbe/monetdbe.h
--- a/tools/monetdbe/monetdbe.h
+++ b/tools/monetdbe/monetdbe.h
@@ -95,11 +95,18 @@ typedef struct {
 } monetdbe_remote;
 
 typedef struct {
+       const char* port;
+       const char* usock;
+} monetdbe_mapi_server;
+
+typedef struct {
        int memorylimit;  // top off the amount of RAM to be used, in MB
        int querytimeout;  // graceful terminate query after a few seconds
        int sessiontimeout;  // graceful terminate the session after a few 
seconds
        int nr_threads;  // maximum number of worker treads, limits level of 
parallelism
        monetdbe_remote* remote;
+       monetdbe_mapi_server* mapi_server;
+
 } monetdbe_options;
 
 #define DEFAULT_STRUCT_DEFINITION(ctype, typename)         \
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to