Changeset: 7c48e26ae36a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7c48e26ae36a
Modified Files:
        common/utils/matomic.h
        monetdb5/mal/mal_debugger.c
        monetdb5/mal/mal_embedded.c
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_linker.h
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_scenario.c
        monetdb5/optimizer/opt_pipes.c
        tools/embedded/monetdb_embedded.c
        tools/embedded/monetdb_embedded.h
        tools/mserver/shutdowntest.c
Branch: mbedded
Log Message:

trying to fix loading...


diffs (truncated from 357 to 300 lines):

diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -134,7 +134,7 @@ typedef volatile atomic_flag ATOMIC_FLAG
  * documentation.
  */
 
-#if SIZEOF_SSIZE_T == 8
+#if SIZEOF_SIZE_T == 8
 
 typedef volatile int64_t ATOMIC_TYPE;
 typedef int64_t ATOMIC_BASE_TYPE;
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -219,7 +219,7 @@ printBatDetails(stream *f, bat bid)
 
        /* at this level we don't know bat kernel primitives */
        mnstr_printf(f, "#Show info for %d\n", bid);
-       fcn = getAddress("BKCinfo");
+       fcn = getAddress(getName("bat"), "BKCinfo");
        if (fcn) {
                (*fcn)(&ret,&ret2, &bid);
                b[0] = BATdescriptor(ret);
@@ -573,7 +573,7 @@ printBatProperties(stream *f, VarPtr n, 
                BUN p;
 
                /* at this level we don't know bat kernel primitives */
-               fcn = getAddress("BKCinfo");
+               fcn = getAddress(getName("bat"), "BKCinfo");
                if (fcn) {
                        BAT *b[2];
                        str res;
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
@@ -78,7 +78,7 @@ malEmbeddedBoot(void)
                MCcloseClient(c);
                return msg;
        }
-       char *modules[2] = { "sql" };
+       char *modules[3] = { "embedded", "sql" };
        if ((msg = malIncludeModules(c, modules, 0, 1)) != MAL_SUCCEED) {
                MCcloseClient(c);
                return msg;
diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -65,7 +65,7 @@ fileexists(const char *path)
 
 /* Search for occurrence of the function in the library identified by the 
filename.  */
 MALfcn
-getAddress(str fcnname)
+getAddress(str modname, str fcnname)
 {
        void *dl;
        MALfcn adr;
@@ -73,7 +73,7 @@ getAddress(str fcnname)
        static int prev= -1;
 
        /* First try the last module loaded */
-       if( prev >= 0){
+       if( prev >= 0 && strcmp(filesLoaded[prev].modname, modname) == 0){ /* 
test if just pointer compare could work */
                adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname);
                if( adr != NULL)
                        return adr; /* found it */
@@ -87,6 +87,7 @@ getAddress(str fcnname)
        for (idx =0; idx < lastfile; idx++)
                if (idx != prev &&              /* skip already searched module 
*/
                        filesLoaded[idx].handle &&
+                       strcmp(filesLoaded[idx].modname, modname) == 0 &&
                        (idx == 0 || filesLoaded[idx].handle != 
filesLoaded[0].handle)) {
                        adr = (MALfcn) dlsym(filesLoaded[idx].handle, fcnname);
                        if (adr != NULL)  {
@@ -95,8 +96,16 @@ getAddress(str fcnname)
                        }
                }
 
-       if (lastfile)
+       if (lastfile) {
+               /* first should be monetdb5 */
+               assert(strcmp(filesLoaded[0].modname, "monetdb5") == 0 || 
strcmp(filesLoaded[0].modname, "embedded") == 0);
+               adr = (MALfcn) dlsym(filesLoaded[0].handle, fcnname);
+               if (adr != NULL)  {
+                       prev = 0;
+                       return adr; /* found it */
+               }
                return NULL;
+       }
        /*
         * Try the program libraries at large or run through all
         * loaded files and try to resolve the functionname again.
@@ -108,7 +117,7 @@ getAddress(str fcnname)
 #else
        dl = dlopen(SO_PREFIX "monetdb5" SO_EXT, RTLD_NOW | RTLD_GLOBAL);
 #endif
-       if (dl == NULL) 
+       if (dl == NULL)
                return NULL;
 
        adr = (MALfcn) dlsym(dl, fcnname);
@@ -153,7 +162,15 @@ loadLibrary(str filename, int flag)
        str s;
        int idx;
        const char *mod_path = GDKgetenv("monet_mod_path");
+       int is_mod;
 
+       is_mod = (strcmp(filename, "monetdb5") != 0 && strcmp(filename, 
"embedded") != 0);
+
+       if (!lastfile && strcmp(filename, "monetdb5") != 0 && strcmp(filename, 
"embedded") != 0) { /* first load reference too local functions */
+               str msg = loadLibrary("monetdb5", flag);
+               if (msg != MAL_SUCCEED)
+                       return msg;
+       }
        /* AIX requires RTLD_MEMBER to load a module that is a member of an
         * archive.  */
 #ifdef RTLD_MEMBER
@@ -179,7 +196,10 @@ loadLibrary(str filename, int flag)
        if (mod_path == NULL) {
                int len;
 
-               len = snprintf(nme, FILENAME_MAX, "%s_%s%s", SO_PREFIX, s, 
SO_EXT);
+               if (is_mod)
+                       len = snprintf(nme, FILENAME_MAX, "%s_%s%s", SO_PREFIX, 
s, SO_EXT);
+               else
+                       len = snprintf(nme, FILENAME_MAX, "%s%s%s", SO_PREFIX, 
s, SO_EXT);
                if (len == -1 || len >= FILENAME_MAX)
                        throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR 
"Library filename path is too large");
 
@@ -202,9 +222,10 @@ loadLibrary(str filename, int flag)
                for (p = mod_path; *p && *p != PATH_SEP; p++)
                        ;
 
-               len = snprintf(nme, FILENAME_MAX, "%.*s%c%s_%s%s",
-                                (int) (p - mod_path),
-                                mod_path, DIR_SEP, SO_PREFIX, s, SO_EXT);
+               if (is_mod)
+                       len = snprintf(nme, FILENAME_MAX, "%.*s%c%s_%s%s", 
(int) (p - mod_path), mod_path, DIR_SEP, SO_PREFIX, s, SO_EXT);
+               else
+                       len = snprintf(nme, FILENAME_MAX, "%.*s%c%s%s%s", (int) 
(p - mod_path), mod_path, DIR_SEP, SO_PREFIX, s, SO_EXT);
                if (len == -1 || len >= FILENAME_MAX)
                        throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR 
"Library filename path is too large");
                handle = dlopen(nme, mode);
@@ -212,9 +233,10 @@ loadLibrary(str filename, int flag)
                        throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " 
failed to open library %s (from within file '%s'): %s", s, nme, dlerror());
                if (handle == NULL && strcmp(SO_EXT, ".so") != /* DISABLES CODE 
*/ (0)) {
                        /* try .so */
-                       len = snprintf(nme, FILENAME_MAX, "%.*s%c%s_%s.so",
-                                        (int) (p - mod_path),
-                                        mod_path, DIR_SEP, SO_PREFIX, s);
+                       if (is_mod)
+                               len = snprintf(nme, FILENAME_MAX, 
"%.*s%c%s_%s.so", (int) (p - mod_path), mod_path, DIR_SEP, SO_PREFIX, s);
+                       else
+                               len = snprintf(nme, FILENAME_MAX, 
"%.*s%c%s%s.so", (int) (p - mod_path), mod_path, DIR_SEP, SO_PREFIX, s);
                        if (len == -1 || len >= FILENAME_MAX)
                                throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR 
"Library filename path is too large");
                        handle = dlopen(nme, mode);
@@ -224,9 +246,10 @@ loadLibrary(str filename, int flag)
 #ifdef __APPLE__
                if (handle == NULL && strcmp(SO_EXT, ".bundle") != 0) {
                        /* try .bundle */
-                       len = snprintf(nme, FILENAME_MAX, "%.*s%c%s_%s.bundle",
-                                        (int) (p - mod_path),
-                                        mod_path, DIR_SEP, SO_PREFIX, s);
+                       if (is_mod)
+                               len = snprintf(nme, FILENAME_MAX, 
"%.*s%c%s_%s.bundle", (int) (p - mod_path), mod_path, DIR_SEP, SO_PREFIX, s);
+                       else
+                               len = snprintf(nme, FILENAME_MAX, 
"%.*s%c%s%s.bundle", (int) (p - mod_path), mod_path, DIR_SEP, SO_PREFIX, s);
                        if (len == -1 || len >= FILENAME_MAX)
                                throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR 
"Library filename path is too large");
                        handle = dlopen(nme, mode);
diff --git a/monetdb5/mal/mal_linker.h b/monetdb5/mal/mal_linker.h
--- a/monetdb5/mal/mal_linker.h
+++ b/monetdb5/mal/mal_linker.h
@@ -20,7 +20,7 @@
 #define RTLD_GLOBAL 4
 #endif
 
-mal_export MALfcn getAddress(str fcnname);
+mal_export MALfcn getAddress(str modname, str fcnname);
 mal_export char *MSP_locate_sqlscript(const char *mod_name, bit recurse);
 mal_export str loadLibrary(str modulename, int flag);
 mal_export char *locate_file(const char *basename, const char *ext, bit 
recurse);
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -1333,7 +1333,7 @@ parseCommandPattern(Client cntxt, int ki
                curBlk->binding[(i< IDLENGTH? i:IDLENGTH-1)] = 0;
                /* avoid a clash with old temporaries */
                advance(cntxt, i);
-               curInstr->fcn = getAddress(curBlk->binding);
+               curInstr->fcn = getAddress(getModuleId(curInstr), 
curBlk->binding);
 
                if (cntxt->usermodule->isAtomModule) {
                        if (curInstr->fcn == NULL) {
@@ -1377,7 +1377,7 @@ parseFunction(Client cntxt, int kind)
                        parseError(cntxt, SQLSTATE(HY013) MAL_MALLOC_FAIL);
                        return 0;
                }
-               curInstr->fcn = getAddress(nme);
+               curInstr->fcn = getAddress(getModuleId(curInstr), nme);
                GDKfree(nme);
                if (curInstr->fcn == NULL) {
                        parseError(cntxt, "<address> not found\n");
diff --git a/monetdb5/mal/mal_scenario.c b/monetdb5/mal/mal_scenario.c
--- a/monetdb5/mal/mal_scenario.c
+++ b/monetdb5/mal/mal_scenario.c
@@ -165,15 +165,18 @@ getFreeScenario(void)
 static str
 initScenario(Client c, Scenario s)
 {
-       str l = s->language;
+       //str l = s->language;
        str msg = MAL_SUCCEED;
 
-       if (s->initSystemCmd)
+       if (s->initSystemCmd || !s->initSystem)
                return(fillScenario(c, s));
        /* prepare for conclicts */
+       assert(0);
+       return msg;
+/*
        MT_lock_set(&mal_contextLock);
        if (s->initSystem && s->initSystemCmd == 0) {
-               s->initSystemCmd = (MALfcn) getAddress(s->initSystem);
+               s->initSystemCmd = (MALfcn) getAddress(NULL, s->initSystem);
                if (s->initSystemCmd) {
                        msg = (*s->initSystemCmd) (c);
                } else {
@@ -188,25 +191,26 @@ initScenario(Client c, Scenario s)
        }
 
        if (s->exitSystem && s->exitSystemCmd == 0)
-               s->exitSystemCmd = (MALfcn) getAddress(s->exitSystem);
+               s->exitSystemCmd = (MALfcn) getAddress(NULL, s->exitSystem);
        if (s->initClient && s->initClientCmd == 0)
-               s->initClientCmd = (MALfcn) getAddress(s->initClient);
+               s->initClientCmd = (MALfcn) getAddress(NULL, s->initClient);
        if (s->exitClient && s->exitClientCmd == 0)
-               s->exitClientCmd = (MALfcn) getAddress(s->exitClient);
+               s->exitClientCmd = (MALfcn) getAddress(NULL, s->exitClient);
        if (s->reader && s->readerCmd == 0)
-               s->readerCmd = (MALfcn) getAddress(s->reader);
+               s->readerCmd = (MALfcn) getAddress(NULL, s->reader);
        if (s->parser && s->parserCmd == 0)
-               s->parserCmd = (MALfcn) getAddress(s->parser);
+               s->parserCmd = (MALfcn) getAddress(NULL, s->parser);
        if (s->optimizer && s->optimizerCmd == 0)
-               s->optimizerCmd = (MALfcn) getAddress(s->optimizer);
+               s->optimizerCmd = (MALfcn) getAddress(NULL, s->optimizer);
        if (s->tactics && s->tacticsCmd == 0)
-               s->tacticsCmd = (MALfcn) getAddress(s->tactics);
+               s->tacticsCmd = (MALfcn) getAddress(NULL, s->tactics);
        if (s->callback && s->callbackCmd == 0)
-               s->callbackCmd = (MALfcn) getAddress(s->callback);
+               s->callbackCmd = (MALfcn) getAddress(NULL, s->callback);
        if (s->engine && s->engineCmd == 0)
-               s->engineCmd = (MALfcn) getAddress(s->engine);
+               s->engineCmd = (MALfcn) getAddress(NULL, s->engine);
        MT_lock_unset(&mal_contextLock);
        return(fillScenario(c, s));
+*/
 }
 
 str
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -32,7 +32,8 @@ static struct PIPELINES {
        char *name;
        char *def;
        char *status;
-       char *prerequisite;
+       //char *prerequisite;
+       char *OLD_prerequisite;
        MalBlkPtr mb;
        char builtin;
 } pipes[MAXOPTPIPES] = {
@@ -370,12 +371,14 @@ getPipeCatalog(bat *nme, bat *def, bat *
        }
 
        for (i = 0; i < MAXOPTPIPES && pipes[i].name; i++) {
+               /*
                if (pipes[i].prerequisite && getAddress(pipes[i].prerequisite) 
== NULL){
                        BBPreclaim(b);
                        BBPreclaim(bn);
                        BBPreclaim(bs);
                        throw(MAL,"getPipeCatalog", SQLSTATE(HY002) 
"#MAL.getAddress address of '%s' not found",pipes[i].name);
                }
+               */
                if (BUNappend(b, pipes[i].name, false) != GDK_SUCCEED ||
                        BUNappend(bn, pipes[i].def, false) != GDK_SUCCEED ||
                        BUNappend(bs, pipes[i].status, false) != GDK_SUCCEED) {
@@ -477,8 +480,10 @@ compileOptimizer(Client cntxt, const cha
                        /* precompile a pipeline as MAL string */
                        for (j = 0; j < MAXOPTPIPES && pipes[j].def; j++) {
                                if (pipes[j].mb == NULL) {
+                                       /*
                                        if (pipes[j].prerequisite && 
getAddress(pipes[j].prerequisite) == NULL)
                                                continue;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to