Changeset: a8196995d3b1 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8196995d3b1 Modified Files: clients/mapiclient/mnc.c clients/mapilib/mapi.c common/stream/stream.c monetdb5/extras/jaql/jaql.h monetdb5/extras/jaql/jaql.mal monetdb5/extras/jaql/jaqlgencode.c monetdb5/extras/jaql/json.c monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out monetdb5/mal/mal_instruction.mx monetdb5/mal/mal_listing.c monetdb5/modules/mal/Tests/inspect05.stable.out monetdb5/modules/mal/remote.c monetdb5/optimizer/opt_centipede.mx monetdb5/optimizer/opt_octopus.mx monetdb5/optimizer/opt_pipes.c sql/backends/monet5/sql_result.mx sql/server/rel_dump.c sql/server/sql_datetime.c sql/server/sql_statement.c sql/server/sql_statement.h testing/Mtest.py.in Branch: DVframework Log Message:
merge with default. diffs (truncated from 3432 to 300 lines): diff --git a/clients/mapiclient/mnc.c b/clients/mapiclient/mnc.c --- a/clients/mapiclient/mnc.c +++ b/clients/mapiclient/mnc.c @@ -99,7 +99,7 @@ main(int argc, char **argv) stream *in = NULL; stream *out = NULL; char buf[8096]; - size_t len; + ssize_t len; fd_set fds; char seeneof = 0; char seenflush = 0; @@ -271,8 +271,11 @@ main(int argc, char **argv) select((int)s + 1, &fds, NULL, NULL, NULL); if (FD_ISSET(s, &fds)) { - if ((len = mnstr_read(in, buf, 1, sizeof(buf))) != 0) { - if (!write(1, buf, len)) + if ((len = mnstr_read(in, buf, 1, sizeof(buf))) > 0) { + /* on Windows: unsigned int, + * elsewhere: size_t, but then + * unsigned int shouldn't harm */ + if (!write(1, buf, (unsigned int) len)) exit(2); seenflush = 0; } else { @@ -285,8 +288,8 @@ main(int argc, char **argv) } } if (FD_ISSET(0, &fds)) { - if ((len = read(0, buf, sizeof(buf))) != 0) { - mnstr_write(out, buf, len, 1); + if ((len = read(0, buf, sizeof(buf))) > 0) { + mnstr_write(out, buf, (size_t) len, 1); seeneof = 0; } else if (len == 0) { /* EOF */ diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c --- a/clients/mapilib/mapi.c +++ b/clients/mapilib/mapi.c @@ -2554,7 +2554,7 @@ mapi_start_talking(Mapi mid) * commas, and only allow full matches */ if (strstr(hashes, *algs) != NULL) { char *pwh = mcrypt_hashPassword(*algs, p, chal); - int len; + size_t len; if (pwh == NULL) continue; len = strlen(pwh) + 11 /* {RIPEMD160} */ + 1; diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -1460,8 +1460,9 @@ socket_update_timeout(stream *s) tv.tv_sec = s->timeout; tv.tv_usec = 0; - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, (socklen_t) sizeof(tv)); - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, (socklen_t) sizeof(tv)); + /* cast to char * for Windows, no harm on "normal" systems */ + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, (socklen_t) sizeof(tv)); + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *) &tv, (socklen_t) sizeof(tv)); } static stream * diff --git a/monetdb5/extras/jaql/jaql.h b/monetdb5/extras/jaql/jaql.h --- a/monetdb5/extras/jaql/jaql.h +++ b/monetdb5/extras/jaql/jaql.h @@ -53,6 +53,8 @@ typedef struct _jc { void *scanner; char explain; jvar *vars; + int j1, j2, j3, j4, j5, j6 ,j7; + char ro1:1, ro2:2, ro3:3, ro4:4, ro5:5, ro6:6, ro7:7; int vtop; } jc; diff --git a/monetdb5/extras/jaql/jaql.mal b/monetdb5/extras/jaql/jaql.mal --- a/monetdb5/extras/jaql/jaql.mal +++ b/monetdb5/extras/jaql/jaql.mal @@ -41,6 +41,22 @@ command exportResult(o:streams, kind:bat address JAQLexportResult comment "Writes the given JSON fragment to the MAPI stream" +# select wrappers that preserve order +function select(b:bat[:oid,:any_1], v:any_1):bat[:oid,:any_1]; + j := algebra.markT(b, 0@0); + a := algebra.markH(b, 0@0); + q := algebra.select(a, v); + l := algebra.leftjoin(j, q); + return l; +end select +function uselect(b:bat[:oid,:any_1], v:any_1):bat[:oid,:void]; + l := algebra.markT(b, 0@0); + r := algebra.markH(b, 0@0); + e := algebra.uselect(r, v); + s := algebra.leftjoin(l, e); + return s; +end uselect + # scenario functions and init call command prelude() address JAQLprelude; diff --git a/monetdb5/extras/jaql/jaqlgencode.c b/monetdb5/extras/jaql/jaqlgencode.c --- a/monetdb5/extras/jaql/jaqlgencode.c +++ b/monetdb5/extras/jaql/jaqlgencode.c @@ -50,11 +50,37 @@ typedef struct _jgvar { #define MAXJAQLARG 23 -static int dumpvariabletransformation(jc *j, Client cntxt, MalBlkPtr mb, tree *t, int elems, int *j1, int *j2, int *j3, int *j4, int *j5, int *j6, int *j7); +static int dumpvariabletransformation(jc *j, Client cntxt, MalBlkPtr mb, tree *t, int elems); static int dumpnextid(MalBlkPtr mb, int j1); static int matchfuncsig(jc *j, Client cntxt, tree *t, int *coltpos, enum treetype (*coltypes)[MAXJAQLARG], int (*dynaarg)[MAXJAQLARG][7]); static void conditionalcall(int *ret, MalBlkPtr mb, tree *t, enum treetype coltypes[MAXJAQLARG], int dynaarg[MAXJAQLARG][7], int coltpos, InstrPtr q); +/* dumps a algebra.copy for the Xth JSON BAT, if necessary, and sets the + * ro bit appropriately afterwards */ +static inline void +dumpbatwritable(jc *j, MalBlkPtr mb, char X) +{ + int *jX = NULL; + InstrPtr q; + + switch (X) { + case 1: if (!j->ro1) return; jX = &j->j1; j->ro1 = 0; break; + case 2: if (!j->ro2) return; jX = &j->j2; j->ro2 = 0; break; + case 3: if (!j->ro3) return; jX = &j->j3; j->ro3 = 0; break; + case 4: if (!j->ro4) return; jX = &j->j4; j->ro4 = 0; break; + case 5: if (!j->ro5) return; jX = &j->j5; j->ro5 = 0; break; + case 6: if (!j->ro6) return; jX = &j->j6; j->ro6 = 0; break; + case 7: if (!j->ro7) return; jX = &j->j7; j->ro7 = 0; break; + } + q = newInstruction(mb, ASSIGNsymbol); + setModuleId(q, algebraRef); + setFunctionId(q, copyRef); + /* put inplace, because we sometimes use this inside barriers */ + q = pushReturn(mb, q, *jX); + q = pushArgument(mb, q, *jX); + pushInstruction(mb, q); +} + /* returns a bat with subset from kind bat (:oid,:bte) which are * referenced by the first array of the JSON structure (oid 0@0 of kind * bat, pointing to array, so all oids from array bat that have head oid @@ -63,7 +89,7 @@ static int dumpwalkvar(MalBlkPtr mb, int j1, int j5) { InstrPtr q; - int a; + int a, b; q = newInstruction(mb, ASSIGNsymbol); setModuleId(q, algebraRef); @@ -74,10 +100,9 @@ dumpwalkvar(MalBlkPtr mb, int j1, int j5 a = getArg(q, 0); pushInstruction(mb, q); q = newInstruction(mb, ASSIGNsymbol); - setModuleId(q, algebraRef); - setFunctionId(q, semijoinRef); + setModuleId(q, batRef); + setFunctionId(q, mirrorRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); - q = pushArgument(mb, q, j5); q = pushArgument(mb, q, a); a = getArg(q, 0); pushInstruction(mb, q); @@ -85,6 +110,14 @@ dumpwalkvar(MalBlkPtr mb, int j1, int j5 setModuleId(q, batRef); setFunctionId(q, reverseRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, j5); + b = getArg(q, 0); + pushInstruction(mb, q); + q = newInstruction(mb, ASSIGNsymbol); + setModuleId(q, algebraRef); + setFunctionId(q, leftjoinRef); + q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, b); q = pushArgument(mb, q, a); a = getArg(q, 0); pushInstruction(mb, q); @@ -109,7 +142,7 @@ dumparrrefvar(MalBlkPtr mb, tree *t, int /* array indirection, entries must be arrays */ q = newInstruction(mb, ASSIGNsymbol); - setModuleId(q, algebraRef); + setModuleId(q, putName("jaql", 4)); setFunctionId(q, uselectRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); q = pushArgument(mb, q, elems); @@ -129,10 +162,9 @@ dumparrrefvar(MalBlkPtr mb, tree *t, int } else if (t->nval == -1 && t->tval1 != NULL) { /* all array members of which objects will be dereferenced */ q = newInstruction(mb, ASSIGNsymbol); - setModuleId(q, algebraRef); - setFunctionId(q, semijoinRef); + setModuleId(q, batRef); + setFunctionId(q, mirrorRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); - q = pushArgument(mb, q, j5); q = pushArgument(mb, q, a); a = getArg(q, 0); pushInstruction(mb, q); @@ -140,16 +172,23 @@ dumparrrefvar(MalBlkPtr mb, tree *t, int setModuleId(q, batRef); setFunctionId(q, reverseRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, j5); + b = getArg(q, 0); + pushInstruction(mb, q); + q = newInstruction(mb, ASSIGNsymbol); + setModuleId(q, algebraRef); + setFunctionId(q, leftjoinRef); + q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, b); q = pushArgument(mb, q, a); b = getArg(q, 0); pushInstruction(mb, q); } else { /* xth array member */ q = newInstruction(mb, ASSIGNsymbol); - setModuleId(q, algebraRef); - setFunctionId(q, semijoinRef); + setModuleId(q, batRef); + setFunctionId(q, mirrorRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); - q = pushArgument(mb, q, j5); q = pushArgument(mb, q, a); a = getArg(q, 0); pushInstruction(mb, q); @@ -157,10 +196,25 @@ dumparrrefvar(MalBlkPtr mb, tree *t, int setModuleId(q, batRef); setFunctionId(q, reverseRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, j5); + c = getArg(q, 0); + pushInstruction(mb, q); + q = newInstruction(mb, ASSIGNsymbol); + setModuleId(q, algebraRef); + setFunctionId(q, leftjoinRef); + q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, c); q = pushArgument(mb, q, a); b = getArg(q, 0); pushInstruction(mb, q); q = newInstruction(mb, ASSIGNsymbol); + setModuleId(q, batRef); + setFunctionId(q, reverseRef); + q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); + q = pushArgument(mb, q, b); + a = getArg(q, 0); + pushInstruction(mb, q); + q = newInstruction(mb, ASSIGNsymbol); setModuleId(q, algebraRef); setFunctionId(q, markHRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); @@ -196,12 +250,11 @@ dumparrrefvar(MalBlkPtr mb, tree *t, int pushInstruction(mb, q); q = newInstruction(mb, ASSIGNsymbol); - setModuleId(q, algebraRef); + setModuleId(q, putName("jaql", 4)); setFunctionId(q, selectRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); q = pushArgument(mb, q, b); q = pushOid(mb, q, (oid)t->nval); - q = pushOid(mb, q, (oid)t->nval); b = getArg(q, 0); pushInstruction(mb, q); q = newInstruction(mb, ASSIGNsymbol); @@ -244,7 +297,7 @@ dumparrrefvar(MalBlkPtr mb, tree *t, int * in the tail, the oid of the corresponding element from elems * (typically array bat, head oid 0@0) */ static int -dumprefvar(MalBlkPtr mb, tree *t, int elems, int *j1, int *j5, int *j6, int *j7) +dumprefvar(jc *j, MalBlkPtr mb, tree *t, int elems) { InstrPtr q; int a = 0, b = 0, c = 0; @@ -267,7 +320,7 @@ dumprefvar(MalBlkPtr mb, tree *t, int el a = elems; for (t = t->tval1; t != NULL; t = t->tval1) { if (t->type == j_arr_idx) { - c = dumparrrefvar(mb, t, a, *j5); + c = dumparrrefvar(mb, t, a, j->j5); q = newInstruction(mb, ASSIGNsymbol); setModuleId(q, algebraRef); setFunctionId(q, joinRef); @@ -281,7 +334,7 @@ dumprefvar(MalBlkPtr mb, tree *t, int el setModuleId(q, algebraRef); setFunctionId(q, semijoinRef); q = pushReturn(mb, q, newTmpVariable(mb, TYPE_any)); - q = pushArgument(mb, q, *j1); + q = pushArgument(mb, q, j->j1); q = pushArgument(mb, q, b); a = getArg(q, 0); pushInstruction(mb, q); @@ -289,7 +342,7 @@ dumprefvar(MalBlkPtr mb, tree *t, int el encapsulate = 1; } else { _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list