Changeset: 12ae6b3910b9 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=12ae6b3910b9 Modified Files: clients/src/python/COPYRIGHT clients/src/python/Makefile.ag clients/src/python/README.rst clients/src/python/debian/changelog clients/src/python/debian/compat clients/src/python/debian/control clients/src/python/debian/copyright clients/src/python/debian/docs clients/src/python/debian/pycompat clients/src/python/debian/rules clients/src/python/examples/basics.py clients/src/python/examples/perf.py clients/src/python/monetdb/Makefile.ag clients/src/python/monetdb/__init__.py clients/src/python/monetdb/mapi.py clients/src/python/monetdb/mapi2.py clients/src/python/monetdb/mapi3.py clients/src/python/monetdb/mclient.py clients/src/python/monetdb/monetdb_exceptions.py clients/src/python/monetdb/sql/Makefile.ag clients/src/python/monetdb/sql/__init__.py clients/src/python/monetdb/sql/connections.py clients/src/python/monetdb/sql/converters.py clients/src/python/monetdb/sql/cursors.py clients/src/python/monetdb/sql/type_codes.py clients/src/python/setup.py clients/src/python/test/Makefile.ag clients/src/python/test/capabilities.py clients/src/python/test/capabilities_monetdb.py clients/src/python/test/dbapi20.py clients/src/python/test/dbapi20_monetdb.py sql/src/backends/monet5/sql_scenario.mx Branch: default Log Message:
mreged default diffs (truncated from 8849 to 300 lines): diff -r b40c380dc6f5 -r 12ae6b3910b9 .hgignore --- a/.hgignore Thu May 13 22:40:51 2010 +0200 +++ b/.hgignore Thu May 13 22:42:32 2010 +0200 @@ -29,3 +29,4 @@ ^buildtools/burg/ylwrap$ ^buildtools/mel/depcomp$ ^pathfinder/conf/compile$ +\.pyc$ diff -r b40c380dc6f5 -r 12ae6b3910b9 MonetDB5/conf/monetdb5.conf.in --- a/MonetDB5/conf/monetdb5.conf.in Thu May 13 22:40:51 2010 +0200 +++ b/MonetDB5/conf/monetdb5.conf.in Thu May 13 22:42:32 2010 +0200 @@ -231,7 +231,7 @@ datacyclotron_pipe=inline,remap,evaluate,costModel,coercions,emptySet,aliases,datacyclotron,mergetable,deadcode,constants,commonTerms,joinPath,reorder,deadcode,reduce,dataflow,history,replication,multiplex,garbageCollector # The default + derivePath -derive_pipe=inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,derivePath,joinPath,deadcode,reduce,dataflow,history,multiplex,garbageCollector +derive_pipe=inline,remap,evaluate,costModel,coercions,emptySet,aliases,mitosis,mergetable,deadcode,commonTerms,derivePath,joinPath,reorder,deadcode,reduce,dataflow,history,multiplex,garbageCollector # The default + dictionary dictionary_pipe=inline,remap,dictionary,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,dataflow,history,multiplex,garbageCollector diff -r b40c380dc6f5 -r 12ae6b3910b9 MonetDB5/src/mal/mal_function.mx --- a/MonetDB5/src/mal/mal_function.mx Thu May 13 22:40:51 2010 +0200 +++ b/MonetDB5/src/mal/mal_function.mx Thu May 13 22:42:32 2010 +0200 @@ -295,29 +295,29 @@ yieldseen= TRUE; } case RETURNsymbol: - { InstrPtr ps= getInstrPtr(mb,0); - int e; + { + InstrPtr ps = getInstrPtr(mb, 0); + int e; if (p->barrier == RETURNsymbol) - yieldseen = FALSE; /* always end with a return */ - if( ps->retc != p->retc){ - showScriptException(mb,i,SYNTAX, - "invalid return target!"); - mb->errors++; - } else - if(ps->typechk == TYPE_RESOLVED) - for(e=0;e<p->retc; e++){ - if( resolveType(getArgType(mb,ps,e),getArgType(mb,p,e)) <0 ){ - str tpname= getTypeName(getArgType(mb,p,e)); - showScriptException(mb,i,TYPE, - "%s type mismatch at type '%s'", - (p->barrier==RETURNsymbol?"RETURN":"YIELD"), tpname); - GDKfree(tpname); - mb->errors++; - } - } - if(ps->typechk != TYPE_RESOLVED) fixed =0; + yieldseen = FALSE; /* always end with a return */ + if (ps->retc != p->retc) { + showScriptException(mb, i, SYNTAX, + "invalid return target!"); + mb->errors++; + } else if (ps->typechk == TYPE_RESOLVED) + for (e = 0; e < p->retc; e++) { + if (resolveType(getArgType(mb, ps, e), getArgType(mb, p, e)) < 0) { + str tpname = getTypeName(getArgType(mb, p, e)); + showScriptException(mb, i, TYPE, + "%s type mismatch at type '%s'", + (p->barrier == RETURNsymbol ? "RETURN" : "YIELD"), tpname); + GDKfree(tpname); + mb->errors++; + } + } + if (ps->typechk != TYPE_RESOLVED) fixed = 0; } - if (btop==0) + if (btop == 0) retseen = 1; break; case RAISEsymbol: diff -r b40c380dc6f5 -r 12ae6b3910b9 MonetDB5/src/mal/mal_import.mx --- a/MonetDB5/src/mal/mal_import.mx Thu May 13 22:40:51 2010 +0200 +++ b/MonetDB5/src/mal/mal_import.mx Thu May 13 22:42:32 2010 +0200 @@ -34,7 +34,6 @@ #include "mal_utils.h" mal_export void slash_2_dir_sep(str fname); -mal_export stream *openSourceFile(str fname); @- The import context is located. If the module already exists, we should silently skip parsing the file. This is handled at the parser level. @@ -62,23 +61,23 @@ *s = DIR_SEP; } -stream * -openSourceFile(str fname) +static str +malResolveFile(str fname) +{ + char path[PATHLENGTH]; + + snprintf(path, PATHLENGTH, "%s", fname); + slash_2_dir_sep(path); + return MSP_locate_script(path); +} + +static stream * +malOpenSource(str file) { stream *fd = NULL; - char path[PATHLENGTH]; - str fullname; - snprintf(path,PATHLENGTH,"%s",fname); - slash_2_dir_sep(path); - fullname = MSP_locate_script(path); - - if (fullname) { - fd = open_rastream(fullname); - GDKfree(fullname); - } else { - fd = open_rastream(path); - } + if (file) + fd = open_rastream(file); return fd; } @@ -97,14 +96,14 @@ { stream *fd; - fd = openSourceFile(name); + fd = malOpenSource(name); if (stream_errnr(fd) == OPEN_ERROR) { stream_destroy(fd); throw(MAL, "malInclude", "could not open file: %s", name); } *fdin = bstream_create(fd, 128 * BLOCK); - if( bstream_next(*fdin) < 0) - stream_printf(c->fdout,"!WARNING: could not read %s\n",name); + if (bstream_next(*fdin) < 0) + stream_printf(c->fdout, "!WARNING: could not read %s\n", name); return MAL_SUCCEED; } @@ -175,6 +174,8 @@ malInclude(Client c, str name, int listing) { str s= MAL_SUCCEED; + str filename; + str p; bstream *oldfdin = c->fdin; int oldyycur = c->yycur; @@ -189,16 +190,30 @@ Module oldnspace = c->nspace; Symbol oldprg = c->curprg; - c->yycur = 0; c->prompt = GDKstrdup(""); /* do not produce visible prompts */ c->promptlength = 0; c->listing = listing; - c->bak = NULL; c->fdin = NULL; - c->srcFile = name; - if ((s = malLoadScript(c, name, &c->fdin)) == 0) - parseMAL(c,c->curprg); + + if ((filename = malResolveFile(name)) != NULL) { + name = filename; + while ((p = strchr(filename, PATH_SEP)) != NULL) { + *p = '\0'; + c->srcFile = filename; + c->yycur = 0; + c->bak = NULL; + if ((s = malLoadScript(c, filename, &c->fdin)) == 0) + parseMAL(c, c->curprg); + filename = p + 1; + } + c->srcFile = filename; + c->yycur = 0; + c->bak = NULL; + if ((s = malLoadScript(c, filename, &c->fdin)) == 0) + parseMAL(c, c->curprg); + GDKfree(name); + } @:restoreClient()@ return s; @@ -228,25 +243,56 @@ evalFile(Client c, str fname, int listing){ @:restoreState@ stream *fd; + str p; + str filename; str msg= MAL_SUCCEED; - c->yycur = 0; c->prompt = GDKstrdup(""); /* do not produce visible prompts */ c->promptlength = 0; c->listing = listing; - c->bak = NULL; c->fdin = NULL; - c->srcFile= fname; - fd = openSourceFile(fname); + + filename = malResolveFile(fname); + if (filename == NULL) { + stream_printf(c->fdout, "#WARNING: could not open file: %s\n", fname); + @:restoreClient3()@ + @:restoreClient()@ + return msg; + } + + fname = filename; + while ((p = strchr(filename, PATH_SEP)) != NULL) { + *p = '\0'; + fd = malOpenSource(filename); + if (stream_errnr(fd) == OPEN_ERROR) { + stream_destroy(fd); + stream_printf(c->fdout, "#WARNING: could not open file: %s\n", + filename); + } else { + c->srcFile = filename; + c->yycur = 0; + c->bak = NULL; + MSinitClientPrg(c, "user", "main"); /* re-initialize context */ + MCpushClientInput(c, bstream_create(fd, 128 * BLOCK), c->listing, ""); + msg = runScenario(c); + } + filename = p + 1; + } + fd = malOpenSource(filename); if (stream_errnr(fd) == OPEN_ERROR) { stream_destroy(fd); - stream_printf(c->fdout, "#WARNING: could not open file: %s\n", fname); + stream_printf(c->fdout, "#WARNING: could not open file: %s\n", + filename); } else { - MSinitClientPrg(c,"user","main"); /* re-initialize context */ - MCpushClientInput(c, bstream_create(fd, 128 * BLOCK),c->listing,""); + c->srcFile = filename; + c->yycur = 0; + c->bak = NULL; + MSinitClientPrg(c, "user", "main"); /* re-initialize context */ + MCpushClientInput(c, bstream_create(fd, 128 * BLOCK), c->listing, ""); msg = runScenario(c); } + GDKfree(fname); @:restoreClient3()@ @:restoreClient()@ diff -r b40c380dc6f5 -r 12ae6b3910b9 MonetDB5/src/mal/mal_linker.mx --- a/MonetDB5/src/mal/mal_linker.mx Thu May 13 22:40:51 2010 +0200 +++ b/MonetDB5/src/mal/mal_linker.mx Thu May 13 22:42:32 2010 +0200 @@ -59,10 +59,13 @@ #define RTLD_NOW_REPORT_ERROR 8 #endif +#include <sys/types.h> /* opendir */ + /* #define DEBUG_MAL_LINKER */ #define MONET64 1 mal_export MALfcn getAddress(str filename, str modnme, str fcnname,int silent); mal_export char *MSP_locate_script(const char *mod_name); +mal_export char *MSP_locate_sqlscript(const char *mod_name); mal_export char *MSP_locate_file(const char *mod_name); mal_export str loadLibrary(str modulename, int flag); mal_export void unloadLibraries(void); @@ -71,7 +74,7 @@ mal_export int isLoaded(str modulename); #endif @- -The MAL module should be compiled with -rdynamic and -ldl. +The MAL module should be compiled with -rdynamic and -ldl (Linux). This enables loading the routines and finding out the address of a particular routine. The mapping from MAL module.function() identifier to an address is @@ -83,7 +86,7 @@ the current directory. Note, however, that the libraries are reference counted. Although we -do;t close them until end of session it seems prudent to maintain +don't close them until end of session it seems prudent to maintain the consistency of this counter. @c @@ -320,8 +323,14 @@ The plausible locations of the modules can be designated by an environment variable. @c +static int +cmpstr(const void *p1, const void *p2) +{ + return strcmp(*(char* const*)p1, *(char* const*)p2); +} + static char * -locate_file(const char *basename, const char *ext) +locate_file(const char *basename, const char *ext, const bit recurse) { char *mod_path = GDKgetenv("monet_mod_path"); _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list