Changeset: a769f303bcfd for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a769f303bcfd
Modified Files:
clients/Tests/exports.stable.out
monetdb5/mal/Tests/dynamicload.malC
monetdb5/mal/Tests/dynamicload.stable.err
monetdb5/mal/mal.h
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_linker.c
monetdb5/mal/mal_linker.h
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_scenario.c
monetdb5/mal/mal_session.c
monetdb5/optimizer/opt_pipes.c
Branch: default
Log Message:
Remove old loader stuff
Remnants of the old static loader
and simplify getAddress call.
diffs (truncated from 403 to 300 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
@@ -2074,7 +2074,7 @@ str fstrcmp_impl(dbl *ret, str *string1,
void garbageCollector(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int flag);
void garbageElement(Client cntxt, ValPtr v);
str generatorRef;
-MALfcn getAddress(stream *out, str filename, str modnme, str fcnname, int
silent);
+MALfcn getAddress(stream *out, str filename, str fcnname, int silent);
str getArgDefault(MalBlkPtr mb, InstrPtr p, int idx);
ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k);
int getAtomIndex(str nme, int len, int deftpe);
@@ -2137,7 +2137,6 @@ str ilikesubselectRef;
str ilikethetasubselectRef;
str ilikeuselectRef;
void initHeartbeat(void);
-void initLibraries(void);
void initNamespace(void);
void initParser(void);
void initProfiler(void);
@@ -2165,7 +2164,6 @@ int isFragmentGroup2(InstrPtr q);
int isIdentifier(str s);
int isInvariant(MalBlkPtr mb, int pcf, int pcl, int varid);
int isLikeOp(InstrPtr q);
-int isLoaded(str modulename);
int isLoopBarrier(MalBlkPtr mb, int pc);
int isMapOp(InstrPtr q);
int isMatJoinOp(InstrPtr q);
@@ -2176,7 +2174,6 @@ int isNotUsedIn(InstrPtr p, int start, i
int isOptimizerEnabled(MalBlkPtr mb, str opt);
int isOptimizerPipe(str name);
int isOrderby(InstrPtr q);
-int isPreloaded(str nme);
int isProcedure(MalBlkPtr mb, InstrPtr p);
int isSample(InstrPtr q);
int isSideEffectFree(MalBlkPtr mb);
@@ -2528,7 +2525,6 @@ int tzone_fromstr(const char *buf, int *
tzone tzone_local;
int tzone_tostr(str *buf, int *len, const tzone *z);
str unescape_str(str *retval, str s);
-void unloadLibraries(void);
str unlockRef;
str unpackRef;
str unpinRef;
diff --git a/monetdb5/mal/Tests/dynamicload.malC
b/monetdb5/mal/Tests/dynamicload.malC
--- a/monetdb5/mal/Tests/dynamicload.malC
+++ b/monetdb5/mal/Tests/dynamicload.malC
@@ -1,7 +1,7 @@
# examples of non-bindable instructions
#load unknown library
-library UNKNOWlib;
+include UNKNOWlib;
command wrong()
address UNKOWNaddress
diff --git a/monetdb5/mal/Tests/dynamicload.stable.err
b/monetdb5/mal/Tests/dynamicload.stable.err
--- a/monetdb5/mal/Tests/dynamicload.stable.err
+++ b/monetdb5/mal/Tests/dynamicload.stable.err
@@ -84,7 +84,7 @@ MAPI = (monetdb) /var/tmp/mtest-30911/.
QUERY = # examples of non-bindable instructions
#load unknown library
- library UNKNOWlib;
+ include UNKNOWlib;
command wrong()
address UNKOWNaddress
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -149,7 +149,7 @@ typedef struct VARRECORD {
int declared; /* pc index when it was first
assigned */
int updated; /* pc index when it was first
updated */
int eolife; /* pc index when it
should be garbage collected */
- int depth; /* scope block depth */
+ int depth; /* scope block depth,
set to -1 if not used */
int worker; /* thread id of last
worker producing it */
str stc; /* rendering
schema.table.column */
BUN rowcnt; /* estimated row count*/
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
@@ -1289,7 +1289,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(f, "bat", "bat", "BKCinfo", 0);
+ fcn = getAddress(f, "bat", "BKCinfo", 0);
if (fcn) {
(*fcn)(&ret,&ret2, &bid);
b[0] = BATdescriptor(ret);
@@ -1323,7 +1323,7 @@ printBatProperties(stream *f, VarPtr n,
BUN p;
/* at this level we don't know bat kernel primitives */
- fcn = getAddress(f, "bat", "bat", "BKCinfo", 0);
+ fcn = getAddress(f, "bat", "BKCinfo", 0);
if (fcn) {
BAT *b[2];
str res;
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
@@ -8,7 +8,7 @@
/*
* (author) M. Kersten
- * For documentation see website
+ * An include file name is also used as library name
*/
#include "monetdb_config.h"
#include "mal_module.h"
@@ -32,11 +32,10 @@
#define close _close
#endif
-static int noDlopen;
-#define MAXMODULES 512
+#define MAXMODULES 128
typedef struct{
- str filename;
+ str modname;
str fullname;
void **handle;
} FileRecord;
@@ -47,27 +46,20 @@ static int lastfile = 0;
/* Search for occurrence of the function in the library identified by the
filename. */
MALfcn
-getAddress(stream *out, str filename, str modnme, str fcnname, int silent)
+getAddress(stream *out, str modname, str fcnname, int silent)
{
void *dl;
MALfcn adr;
static int idx=0;
+
static int prev= -1;
- (void) modnme;
+ /* First try the last module loaded */
if( prev >= 0){
adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname);
if( adr != NULL)
return adr; /* found it */
}
- if( prev >= 0 && filename &&
- filesLoaded[prev].filename &&
- strcmp(filename, filesLoaded[prev].filename) == 0) {
-
- adr = (MALfcn) dlsym(filesLoaded[prev].handle, fcnname);
- if( adr != NULL)
- return adr; /* found it */
- }
/*
* Search for occurrence of the function in any library already loaded.
* This deals with the case that files are linked together to reduce
@@ -97,12 +89,12 @@ getAddress(stream *out, str filename, st
if (!silent)
showException(out, MAL, "MAL.getAddress",
"address of '%s.%s' not
found",
- (modnme?modnme:"<unknown>"),
fcnname);
+
(modname?modname:"<unknown>"), fcnname);
return NULL;
}
adr = (MALfcn) dlsym(dl, fcnname);
- filesLoaded[lastfile].filename = GDKstrdup("libmonetdb5");
+ filesLoaded[lastfile].modname = GDKstrdup("libmonetdb5");
filesLoaded[lastfile].fullname = "libmonetdb5";
filesLoaded[lastfile].handle = dl;
lastfile ++;
@@ -111,7 +103,7 @@ getAddress(stream *out, str filename, st
if (!silent)
showException(out, MAL,"MAL.getAddress", "address of '%s.%s'
not found",
- (modnme?modnme:"<unknown>"), fcnname);
+ (modname?modname:"<unknown>"), fcnname);
return NULL;
}
/*
@@ -131,19 +123,6 @@ getAddress(stream *out, str filename, st
* already loaded.
*/
-int
-isLoaded(str modulename)
-{
- int idx;
-
- for (idx = 0; idx < lastfile; idx++)
- if (filesLoaded[idx].filename &&
- strcmp(filesLoaded[idx].filename, modulename) == 0) {
- return 1;
- }
- return 0;
-}
-
str
loadLibrary(str filename, int flag)
{
@@ -161,8 +140,8 @@ loadLibrary(str filename, int flag)
#endif
for (idx = 0; idx < lastfile; idx++)
- if (filesLoaded[idx].filename &&
- strcmp(filesLoaded[idx].filename, filename) == 0)
+ if (filesLoaded[idx].modname &&
+ strcmp(filesLoaded[idx].modname, filename) == 0)
/* already loaded */
return MAL_SUCCEED;
@@ -232,7 +211,7 @@ loadLibrary(str filename, int flag)
dlclose(handle);
showException(GDKout, MAL,"loadModule", "internal error, too
many modules loaded");
} else {
- filesLoaded[lastfile].filename = GDKstrdup(filename);
+ filesLoaded[lastfile].modname = GDKstrdup(filename);
filesLoaded[lastfile].fullname = GDKstrdup(handle ? nme : "");
filesLoaded[lastfile].handle = handle ? handle :
filesLoaded[0].handle;
lastfile ++;
@@ -256,58 +235,14 @@ mal_linker_reset(void)
for (i = 0; i < lastfile; i++){
if (filesLoaded[i].fullname) {
/* dlclose(filesLoaded[i].handle);*/
- if (filesLoaded[i].filename)
GDKfree(filesLoaded[i].filename);
+ if (filesLoaded[i].modname)
GDKfree(filesLoaded[i].modname);
}
- filesLoaded[i].filename = NULL;
+ filesLoaded[i].modname = NULL;
filesLoaded[i].fullname = NULL;
}
lastfile = 0;
MT_lock_unset(&mal_contextLock);
}
-/*
- * To speedup restart and to simplify debugging, the MonetDB server can
- * be statically linked with some (or all) of the modules libraries.
- * A complicating factor is then to avoid users to initiate another load
- * of the module file, because it would lead to a @code{dlopen()} error.
- *
- * The partial way out of this dilema is to administer somewhere
- * the statically bound modules, or to enforce that each module
- * comes with a known routine for which we can search.
- * In the current version we use the former approach.
- *
- * The routine below turns off dynamic loading while parsing the
- * command signature files.
- */
-static str preloaded[] = {
- "kernel/bat",
- 0
-};
-
-int
-isPreloaded(str nme)
-{
- int i;
-
- for (i = 0; preloaded[i]; i++)
- if (strcmp(preloaded[i], nme) == 0)
- return 1;
- return 0;
-}
-
-void
-initLibraries(void)
-{
- int i;
- str msg;
-
- noDlopen = TRUE;
- if(noDlopen == FALSE)
- for(i=0;preloaded[i];i++) {
- msg = loadLibrary(preloaded[i],FALSE);
- if ( msg )
- mnstr_printf(GDKerr,"#%s\n",msg);
- }
-}
/*
* Handling of Module Library Search Path
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
@@ -23,12 +23,8 @@
/* #define DEBUG_MAL_LINKER */
#define MONET64 1
-mal_export MALfcn getAddress(stream *out, str filename, str modnme, str
fcnname,int silent);
+mal_export MALfcn getAddress(stream *out, str filename, str fcnname,int
silent);
mal_export char *MSP_locate_sqlscript(const char *mod_name, bit recurse);
mal_export str loadLibrary(str modulename, int flag);
-mal_export void unloadLibraries(void);
-mal_export void initLibraries(void);
-mal_export int isPreloaded(str nme);
-mal_export int isLoaded(str modulename);
mal_export char *locate_file(const char *basename, const char *ext, bit
recurse);
#endif /* _MAL_LINKER_H */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list