Changeset: 60229476b63c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60229476b63c Added Files: monetdb5/mal/mal_prelude.c monetdb5/mal/mal_prelude.h Modified Files: README.md monetdb5/mal/CMakeLists.txt monetdb5/mal/mal_import.c monetdb5/mal/mal_import.h monetdb5/mal/mel.h Branch: mbedded Log Message:
merged diffs (truncated from 578 to 300 lines): diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -14,14 +14,20 @@ to build and *install* it from source. I ``` mkdir build cd build -cmake -DCMAKE_INSTALL_PREFIX=/tmp/monetdb ${SOURCE} +cmake -DCMAKE_INSTALL_PREFIX=$PREFIX ${SOURCE} cmake --build . cmake --build . --target install ``` +## Prerequisites +PATH settings ??? +ROle of clients?? How to install + ## Testing For testing, you likely don't want to install in the default location, so you need to add a parameter to the cmake command. -The install directory is passed via the CMAKE\_INSTALL\_PREFIX. + +The MonetDB Mtest.py program is installed in $PREFIX/lib/python3.7/site-packages/. +You have to set or extend the environment variable $PYTHON3PATH to include this location for Mtest. ##Configuration options Evidently there are several options to control as illustrated in $SOURCE/cmake/monetdb-options.cmake @@ -32,7 +38,21 @@ The Debug mode is necessary if you plan This build type also typically leads to a slower execution time, because also all kinds of assertions are being checked. -The relevant properties are also -DASSERT=ON and DSTRICT=ON +Other relevant properties are also -DASSERT=ON and DSTRICT=ON, used in combination with a Debug build, e.g. + + +``` +CONFIGURE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DASSERT=ON -DSTRICT=ON" +mkdir build +cd build +cmake $CONFIGURE_OPTIONS -DCMAKE_INSTALL_PREFIX=$PREFIX ${SOURCE} +cmake --build . +cmake --build . --target install +``` + + +Explain the role of cmake --build . --target mtest +In particular how to call it from anywhere in the tree ## Platform specifics The packages required to built MonetDB from source depends mostly on the operating system environment. diff --git a/monetdb5/mal/CMakeLists.txt b/monetdb5/mal/CMakeLists.txt --- a/monetdb5/mal/CMakeLists.txt +++ b/monetdb5/mal/CMakeLists.txt @@ -50,6 +50,7 @@ target_sources(mal mal_utils.c mal_utils.h mal_embedded.c mal_embedded.h mal_private.h + mal_prelude.c mel.h PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/mal_client.h diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c --- a/monetdb5/mal/mal_import.c +++ b/monetdb5/mal/mal_import.c @@ -33,180 +33,6 @@ #include "mal_authorize.h" #include "mal_private.h" -#define MAX_MAL_MODULES 128 -static int mel_modules = 0; -static str mel_module_name[MAX_MAL_MODULES] = {0}; -static mel_atom *mel_module_atoms[MAX_MAL_MODULES] = {0}; -static mel_func *mel_module_funcs[MAX_MAL_MODULES] = {0}; - -void -mal_module(str name, mel_atom *atoms, mel_func *funcs) -{ - assert (mel_modules < MAX_MAL_MODULES); - mel_module_name[mel_modules] = name; - mel_module_atoms[mel_modules] = atoms; - mel_module_funcs[mel_modules] = funcs; - mel_modules++; -} - -#define MAX_MAL_MODULES 128 -static int mal_modules = 0; -static str mal_module_name[MAX_MAL_MODULES] = {0}; -static unsigned char *mal_module_code[MAX_MAL_MODULES] = {0}; - -static void -initModule(Client c, char *name) -{ - if (!getName(name)) - return; - Module m = getModule(getName(name)); - if (m) { /* run prelude */ - Symbol s = findSymbolInModule(m, getName("prelude")); - - if (s) { - InstrPtr pci = getInstrPtr(s->def, 0); - - if (pci && pci->token == COMMANDsymbol && pci->argc == 1) { - int ret = 0; - - assert(pci->fcn != NULL); - (*pci->fcn)(&ret); - (void)ret; - } else if (pci && pci->token == PATTERNsymbol) { - assert(pci->fcn != NULL); - (*pci->fcn)(c, NULL, NULL, NULL); - } - } - } -} - -void -mal_register(str name, unsigned char *code) -{ - assert (mal_modules < MAX_MAL_MODULES); - mal_module_name[mal_modules] = name; - mal_module_code[mal_modules] = code; - mal_modules++; -} - -static str -addAtom( mel_atom *atoms) -{ - for(; atoms && atoms->name; atoms++) { - int i = ATOMallocate(atoms->name); - if (is_int_nil(i)) - throw(TYPE,"addAtom", SQLSTATE(HY013) MAL_MALLOC_FAIL); - if (atoms->basetype) { - int tpe = ATOMindex(atoms->basetype); - if (tpe < 0) - throw(TYPE,"addAtom", SQLSTATE(HY013) MAL_MALLOC_FAIL); - BATatoms[i] = BATatoms[tpe]; - strcpy_len(BATatoms[i].name, atoms->name, sizeof(BATatoms[i].name)); - BATatoms[i].storage = ATOMstorage(tpe); - } else { /* cannot overload void atoms */ - BATatoms[i].storage = i; - BATatoms[i].linear = false; - } - if (atoms->del) - BATatoms[i].atomDel = (void (*)(Heap *, var_t *))atoms->del; - if (atoms->cmp) { - BATatoms[i].atomCmp = (int (*)(const void *, const void *))atoms->del; - BATatoms[i].linear = true; - } - if (atoms->fromstr) - BATatoms[i].atomFromStr = (ssize_t (*)(const char *, size_t *, ptr *, bool))atoms->fromstr; - if (atoms->tostr) - BATatoms[i].atomToStr = (ssize_t (*)(str *, size_t *, const void *, bool))atoms->tostr; - if (atoms->fix) - BATatoms[i].atomFix = (gdk_return (*)(const void *))atoms->fix; - if (atoms->unfix) - BATatoms[i].atomUnfix = (gdk_return (*)(const void *))atoms->unfix; - if (atoms->heap) { - BATatoms[i].size = sizeof(var_t); - assert_shift_width(ATOMelmshift(ATOMsize(i)), ATOMsize(i)); - BATatoms[i].atomHeap = (void (*)(Heap *, size_t))atoms->heap; - } - if (atoms->hash) - BATatoms[i].atomHash = (BUN (*)(const void *))atoms->hash; - if (atoms->length) - BATatoms[i].atomLen = (size_t (*)(const void *))atoms->length; - if (atoms->null) { - const void *atmnull = ((const void *(*)(void))atoms->null)(); - - BATatoms[i].atomNull = atmnull; - } - if (atoms->nequal) - BATatoms[i].atomCmp = (int (*)(const void *, const void *))atoms->nequal; - if (atoms->put) - BATatoms[i].atomPut = (var_t (*)(Heap *, var_t *, const void *))atoms->put; - if (atoms->storage) - BATatoms[i].storage = (*(int (*)(void))atoms->storage)(); - if (atoms->read) - BATatoms[i].atomRead = (void *(*)(void *, stream *, size_t))atoms->read; - if (atoms->write) - BATatoms[i].atomWrite = (gdk_return (*)(const void *, stream *, size_t))atoms->write; - } - return MAL_SUCCEED; -} - -static str -malIncludeDefault(Client c, int listing, int embedded) -{ - int i; - - for(i = 0; i<mel_modules; i++) { - if (embedded && strcmp(mel_module_name[i], "mal_mapi") == 0) /* skip mapi in the embedded version */ - continue; - if (mel_module_atoms[i]) { - str msg = addAtom(mel_module_atoms[i]); - if (msg) - return msg; - } - /* HERE we need to register the command/pattern's */ - } - for(i = 0; i<mal_modules; i++) { - if (embedded && strcmp(mal_module_name[i], "mal_mapi") == 0) /* skip mapi in the embedded version */ - continue; - str msg = malIncludeString(c, mal_module_name[i], (str)mal_module_code[i], listing); - if (msg) - return msg; - } - /* execute preludes */ - for(i = 0; i<mal_modules; i++) { - if (strcmp(mal_module_name[i], "sql") == 0) /* skip sql should be last to startup */ - continue; - initModule(c, mal_module_name[i]); - } - return MAL_SUCCEED; -} - -str -malIncludeModules(Client c, char *modules[], int listing, int embedded) -{ - int i; - str msg; - - for(i = 0; modules[i]; i++) { - /* load library */ - if ((msg = loadLibrary(modules[i], listing)) != NULL) - return msg; - } - /* only when the libraries are loaded the code is dynamically added, the second call this - * isn't done. So here the mal_modules counter is reset for this - */ - - /* load the mal code for these modules and execute preludes */ - if ((msg = malIncludeDefault(c, listing, embedded)) != NULL) - return msg; - for(int i = 0; modules[i]; i++) { - if (strcmp(modules[i], "sql") == 0) { /* start now */ - initModule(c, modules[i]); - break; - } - } - return MAL_SUCCEED; -} - void slash_2_dir_sep(str fname) { diff --git a/monetdb5/mal/mal_import.h b/monetdb5/mal/mal_import.h --- a/monetdb5/mal/mal_import.h +++ b/monetdb5/mal/mal_import.h @@ -13,12 +13,8 @@ #include "mal_client.h" #include "mal_session.h" #include "mal_utils.h" +#include "mal_prelude.h" -#include "mel.h" -mal_export void mal_module(str name, mel_atom *atoms, mel_func *funcs); - -mal_export void mal_register(str name, unsigned char *code); -mal_export str malIncludeModules(Client c, char *modules[], int listing, int embedded); mal_export str malIncludeString(Client c, const str name, const str mal, int listing); mal_export str malInclude(Client c, str name, int listing); diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c new file mode 100644 --- /dev/null +++ b/monetdb5/mal/mal_prelude.c @@ -0,0 +1,272 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. + */ + +/* Author(s) M.L. Kersten + * This module takes the statically defined modules, atoms, commands and patterns + * and populate the internal structures. + * +*/ + +#include "monetdb_config.h" +#include "mal_import.h" +#include "mal_interpreter.h" /* for showErrors() */ +#include "mal_linker.h" /* for loadModuleLibrary() */ +#include "mal_scenario.h" +#include "mal_parser.h" +#include "mal_authorize.h" +#include "mal_private.h" + +#include "mal_prelude.h" + +#define MAX_MAL_MODULES 128 +static int mel_modules = 0; +static str mel_module_name[MAX_MAL_MODULES] = {0}; +static mel_atom *mel_module_atoms[MAX_MAL_MODULES] = {0}; +static mel_func *mel_module_funcs[MAX_MAL_MODULES] = {0}; + +/* the MAL modules contains text to be parsed */ +static int mal_modules = 0; +static str mal_module_name[MAX_MAL_MODULES] = {0}; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list