Changeset: aa8cc0a76801 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aa8cc0a76801
Modified Files:
        gdk/gdk_bat.c
        monetdb5/mal/mal.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_interpreter.h
        monetdb5/mal/mal_private.h
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_runtime.h
        monetdb5/mal/mal_scenario.c
        monetdb5/mal/mal_session.c
        monetdb5/mal/mal_session.h
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/optimizer.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_cat.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_optimizer.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_statement.c
        sql/backends/monet5/sql_transaction.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/sql_user.c
        sql/server/rel_schema.c
Branch: port-monetdblite
Log Message:

More features check backported from MonetDBLite.

- mal_profiler, mal_debugger, mal_factory, mal_runtime are not used.
- querylog, postfix and wlc optimizer pipes are not used.


diffs (truncated from 1224 to 300 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -242,6 +242,12 @@ BATdense(oid hseq, oid tseq, BUN cnt)
        return bn;
 }
 
+#if defined(HAVE_EMBEDDED) && defined(HAVE_EMBEDDED_JAVA)
+extern int TYPE_date;
+extern int TYPE_daytime;
+extern int TYPE_timestamp;
+#endif
+
 BAT *
 BATattach(int tt, const char *heapfile, int role)
 {
@@ -249,6 +255,10 @@ BATattach(int tt, const char *heapfile, 
        char *p;
        size_t m;
        FILE *f;
+#if defined(HAVE_EMBEDDED) && defined(HAVE_EMBEDDED_JAVA)
+       //The JVM is always Big-Endian, so the integer values must be swapped 
if so
+       int swapendianess = MT_check_endianness() != HOST_BIG_ENDIAN;
+#endif
 
        ERRORcheck(tt <= 0 , "BATattach: bad tail type (<=0)\n", NULL);
        ERRORcheck(ATOMvarsized(tt) && ATOMstorage(tt) != TYPE_str, "BATattach: 
bad tail type (varsized and not str)\n", NULL);
@@ -359,6 +369,41 @@ BATattach(int tt, const char *heapfile, 
                p = Tloc(bn, 0);
                n = (lng) st.st_size;
                while (n > 0 && (m = fread(p, 1, (size_t) MIN(1024*1024, n), 
f)) > 0) {
+#if defined(HAVE_EMBEDDED) && defined(HAVE_EMBEDDED_JAVA)
+                       if (swapendianess) {
+                               BUN j = 0, end = 0;
+                               int stype = ATOMstorage(tt);
+                               if (stype == TYPE_sht) {
+                                       sht *bufptr = (sht*) p;
+                                       for (j = 0; j < end; j++) {
+                                               bufptr[j] = 
short_int_SWAP(bufptr[j]);
+                                       }
+                               } else if (stype == TYPE_int || stype == 
TYPE_flt || stype == TYPE_date || stype == TYPE_daytime
+                                                  || stype == TYPE_timestamp) {
+                                       int *bufptr = (int*) p;
+                                       end = m / atomsize;
+                                       if (stype == TYPE_timestamp)
+                                               end <<= 2; /* 4 times entries 
(alignment -> 4 bytes + date -> 1 byte + daytime -> 1 byte) */
+                                       /* the alignment field is not properly 
swapped, but we never use it anyway */
+                                       for (j = 0; j < end; j++) {
+                                               bufptr[j] = 
normal_int_SWAP(bufptr[j]);
+                                       }
+                               } else if (stype == TYPE_dbl || stype == 
TYPE_lng) {
+                                       lng *bufptr = (lng*) p;
+                                       for (j = 0, end = m / atomsize; j < 
end; j++) {
+                                               bufptr[j] = 
long_long_SWAP(bufptr[j]);
+                                       }
+                               }
+#ifdef HAVE_HGE
+                               else if (stype == TYPE_hge) {
+                                       hge *bufptr = (hge*) p;
+                                       for (j = 0, end = m / atomsize; j < 
end; j++) {
+                                               bufptr[j] = 
huge_int_SWAP(bufptr[j]);
+                                       }
+                               }
+#endif
+                       }
+#endif
                        p += m;
                        n -= m;
                }
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -181,10 +181,10 @@ void mserver_reset(int exit)
        }
 
        mal_client_reset();
-       mal_runtime_reset();
        opt_pipes_reset();
 
 #ifndef HAVE_EMBEDDED
+       mal_runtime_reset();
        mal_linker_reset();
        mal_resource_reset();
        mal_module_reset();
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -42,13 +42,15 @@
 /* (author) M.L. Kersten */
 #include "monetdb_config.h"
 #include "mal_client.h"
-#include "mal_readline.h"
 #include "mal_import.h"
 #include "mal_parser.h"
 #include "mal_namespace.h"
 #include "mal_private.h"
 #include "mal_runtime.h"
+#ifndef HAVE_EMBEDDED
+#include "mal_profiler.h"
 #include "mal_authorize.h"
+#endif
 
 int MAL_MAXCLIENTS = 0;
 ClientRec *mal_clients;
@@ -57,8 +59,10 @@ void
 mal_client_reset(void)
 {
        MAL_MAXCLIENTS = 0;
-       if (mal_clients)
+       if (mal_clients) {
                GDKfree(mal_clients);
+               mal_clients = NULL;
+       }
 }
 
 void
@@ -135,6 +139,10 @@ MCnewClient(void)
 {
        Client c;
        MT_lock_set(&mal_contextLock);
+       if (!mal_clients) {
+               MT_lock_unset(&mal_contextLock);
+               return NULL;
+       }
        if (mal_clients[CONSOLE].user && mal_clients[CONSOLE].mode == 
FINISHCLIENT) {
                /*system shutdown in progress */
                MT_lock_unset(&mal_contextLock);
@@ -182,8 +190,10 @@ MCexitClient(Client c)
 #ifdef MAL_CLIENT_DEBUG
        mnstr_printf(GDKerr,"# Exit client %d\n", c->idx);
 #endif
+#ifndef HAVE_EMBEDDED
        finishSessionProfiler(c);
        MPresetProfiler(c->fdout);
+#endif
        if (c->father == NULL) { /* normal client */
                if (c->fdout && c->fdout != GDKstdout) {
                        close_stream(c->fdout);
@@ -298,7 +308,9 @@ MCinitClientThread(Client c)
        cname[11] = '\0';
        t = THRnew(cname);
        if (t == 0) {
+#ifndef HAVE_EMBEDDED
                MPresetProfiler(c->fdout);
+#endif
                return -1;
        }
        /*
@@ -313,7 +325,9 @@ MCinitClientThread(Client c)
        if (c->errbuf == NULL) {
                char *n = GDKzalloc(GDKMAXERRLEN);
                if ( n == NULL){
+#ifndef HAVE_EMBEDDED
                        MPresetProfiler(c->fdout);
+#endif
                        return -1;
                }
                GDKsetbuf(n);
@@ -400,10 +414,6 @@ freeClient(Client c)
        c->prompt = NULL;
        c->promptlength = -1;
        if (c->errbuf) {
-/* no client threads in embedded mode */
-#ifndef HAVE_EMBEDDED
-               GDKsetbuf(0);
-#endif
                if (c->father == NULL)
                        GDKfree(c->errbuf);
                c->errbuf = 0;
@@ -468,9 +478,13 @@ MCshutdowninprogress(void){
 void
 MCstopClients(Client cntxt)
 {
-       Client c = mal_clients;
-
+       Client c;
        MT_lock_set(&mal_contextLock);
+       c = mal_clients;
+       if (!c) {
+               MT_lock_unset(&mal_contextLock);
+               return;
+       }
        for(c= mal_clients +1;  c < mal_clients+MAL_MAXCLIENTS; c++)
        if( cntxt != c){
                if ( c->mode == RUNCLIENT)
@@ -640,13 +654,22 @@ MCvalid(Client tc)
 str
 PROFinitClient(Client c){
        (void) c;
+#ifndef HAVE_EMBEDDED
        return startProfiler();
+#else
+       return MAL_SUCCEED;
+#endif
+
 }
 
 str
 PROFexitClient(Client c){
        (void) c;
+#ifndef HAVE_EMBEDDED
        return stopProfiler();
+#else
+       return MAL_SUCCEED;
+#endif
 }
 
 
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -13,7 +13,6 @@
 /*#define MAL_CLIENT_DEBUG */
 
 #include "mal_resolve.h"
-#include "mal_profiler.h"
 
 #define SCENARIO_PROPERTIES 8
 
diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -29,7 +29,7 @@
 #include "mal_dataflow.h"
 #include "mal_private.h"
 #include "mal_runtime.h"
-#include "mal_resource.h"
+#include "mal_interpreter.h"
 
 #define DFLOWpending 0         /* runnable */
 #define DFLOWrunning 1         /* currently in progress */
@@ -479,8 +479,10 @@ DFLOWworker(void *T)
                        MT_lock_set(&todo->l);
                        last = todo->last;
                        MT_lock_unset(&todo->l);
+#ifndef HAVE_EMBEDDED
                        if (last == 0)
                                profilerHeartbeatEvent("wait");
+#endif
                }
        }
        GDKfree(GDKerrbuf);
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
@@ -70,7 +70,6 @@ malOpenSource(str file)
        return fd;
 }
 
-#ifndef HAVE_EMBEDDED
 /*
  * The malLoadScript routine merely reads the contents of a file into
  * the input buffer of the client. It is typically used in situations
@@ -106,7 +105,6 @@ malLoadScript(str name, bstream **fdin)
        }
        return MAL_SUCCEED;
 }
-#endif
 
 /*
  * Beware that we have to isolate the execution of the source file
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -15,10 +15,11 @@
 #include "mal_interpreter.h"
 #include "mal_resource.h"
 #include "mal_listing.h"
-#include "mal_debugger.h"   /* for mdbStep() */
 #include "mal_type.h"
 #include "mal_private.h"
-  
+#ifndef HAVE_EMBEDDED
+#include "mal_debugger.h"   /* for mdbStep() */
+#endif
 
 /*
  * The struct alignment leads to 40% gain in simple instructions when set.
@@ -441,10 +442,12 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS
                stk->cmd = debug;
                ret = runMALsequence(cntxt, mb, 1, 0, stk, 0, 0);
                break;
+#ifndef HAVE_EMBEDDED
        case FACTORYsymbol:
        case FACcall:
                ret = callFactory(cntxt, mb, argv, debug);
                break;
+#endif
        case PATcall:
        case CMDcall:
        default:
@@ -476,11 +479,14 @@ str runMALsequence(Client cntxt, MalBlkP
        ValPtr backup;
        int garbages[16], *garbage;
        int stkpc = 0;
+
+#ifndef HAVE_EMBEDDED
        RuntimeProfileRecord runtimeProfile, runtimeProfileFunction;
        lng lastcheck = 0;
        int     startedProfileQueue = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to