Changeset: 52854648b40d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=52854648b40d
Modified Files:
        monetdb5/extras/jaql/jaqlgencode.c
Branch: Oct2012
Log Message:

functions: handle j->startoid correctly

Make sure we use j->startoid when we give input to "internal" functions,
or clean up the document instead, if we call "real" (external)
functions.

Similar, when we get output from the functions, we should reset
j->startoid, since we will always get something "clean".


diffs (131 lines):

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
@@ -6611,6 +6611,46 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                        /* treat pipe as first input */
                                        switch (coltypes[i]) {
                                                case j_json_arr:
+                                                       /* make sure we give 
"clean" input to a
+                                                        * function */
+                                                       if (j->startoid != 0) {
+                                                               a = 
dumpwalkvar(mb, j->j1, j->j5, j->startoid);
+                                                               q = 
newInstruction(mb, ASSIGNsymbol);
+                                                               setModuleId(q, 
batRef);
+                                                               
setFunctionId(q, mirrorRef);
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushArgument(mb, q, a);
+                                                               a = getArg(q, 
0);
+                                                               
pushInstruction(mb, q);
+                                                               q = 
newInstruction(mb, ASSIGNsymbol);
+                                                               setModuleId(q, 
putName("json", 4));
+                                                               
setFunctionId(q, putName("extract", 7));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushReturn(mb, q, newTmpVariable(mb, TYPE_any));
+                                                               q = 
pushArgument(mb, q, j->j1);
+                                                               q = 
pushArgument(mb, q, j->j2);
+                                                               q = 
pushArgument(mb, q, j->j3);
+                                                               q = 
pushArgument(mb, q, j->j4);
+                                                               q = 
pushArgument(mb, q, j->j5);
+                                                               q = 
pushArgument(mb, q, j->j6);
+                                                               q = 
pushArgument(mb, q, j->j7);
+                                                               q = 
pushArgument(mb, q, a);
+                                                               q = pushOid(mb, 
q, 0);
+                                                               j->j1 = 
getArg(q, 0);
+                                                               j->j2 = 
getArg(q, 1);
+                                                               j->j3 = 
getArg(q, 2);
+                                                               j->j4 = 
getArg(q, 3);
+                                                               j->j5 = 
getArg(q, 4);
+                                                               j->j6 = 
getArg(q, 5);
+                                                               j->j7 = 
getArg(q, 6);
+                                                               
pushInstruction(mb, q);
+                                                               j->startoid = 0;
+                                                       }
                                                        dynaarg[i][0] = j->j1;
                                                        dynaarg[i][1] = j->j2;
                                                        dynaarg[i][2] = j->j3;
@@ -6636,7 +6676,11 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                        q = pushArgument(mb, q, 
j->j5);
                                                        q = pushArgument(mb, q, 
j->j6);
                                                        q = pushArgument(mb, q, 
j->j7);
-                                                       q = pushOid(mb, q, 
(oid)0);
+                                                       if (j->startoid == 0) {
+                                                               q = pushOid(mb, 
q, (oid)0);
+                                                       } else {
+                                                               q = 
pushArgument(mb, q, j->startoid);
+                                                       }
                                                        a = getArg(q, 0);
                                                        dynaarg[i][0] = a;
                                                        pushInstruction(mb, q);
@@ -6672,7 +6716,11 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                                q = 
pushArgument(mb, q, j->j5);
                                                                q = 
pushArgument(mb, q, j->j6);
                                                                q = 
pushArgument(mb, q, j->j7);
-                                                               q = pushOid(mb, 
q, (oid)0);
+                                                               if (j->startoid 
== 0) {
+                                                                       q = 
pushOid(mb, q, (oid)0);
+                                                               } else {
+                                                                       q = 
pushArgument(mb, q, j->startoid);
+                                                               }
                                                                q = pushStr(mb, 
q, "");
                                                                dynaarg[i][1] = 
getArg(q, 0);
                                                                
pushInstruction(mb, q);
@@ -6713,7 +6761,11 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                                q = 
pushArgument(mb, q, j->j5);
                                                                q = 
pushArgument(mb, q, j->j6);
                                                                q = 
pushArgument(mb, q, j->j7);
-                                                               q = pushOid(mb, 
q, (oid)0);
+                                                               if (j->startoid 
== 0) {
+                                                                       q = 
pushOid(mb, q, (oid)0);
+                                                               } else {
+                                                                       q = 
pushArgument(mb, q, j->startoid);
+                                                               }
                                                                q = pushDbl(mb, 
q, 0.0);
                                                                dynaarg[i][2] = 
getArg(q, 0);
                                                                
pushInstruction(mb, q);
@@ -6754,7 +6806,11 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                                q = 
pushArgument(mb, q, j->j5);
                                                                q = 
pushArgument(mb, q, j->j6);
                                                                q = 
pushArgument(mb, q, j->j7);
-                                                               q = pushOid(mb, 
q, (oid)0);
+                                                               if (j->startoid 
== 0) {
+                                                                       q = 
pushOid(mb, q, (oid)0);
+                                                               } else {
+                                                                       q = 
pushArgument(mb, q, j->startoid);
+                                                               }
                                                                q = pushLng(mb, 
q, 0);
                                                                dynaarg[i][3] = 
getArg(q, 0);
                                                                
pushInstruction(mb, q);
@@ -6818,7 +6874,11 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                                        setModuleId(q, 
algebraRef);
                                                        setFunctionId(q, 
projectRef);
                                                        q = pushReturn(mb, q, 
newTmpVariable(mb, TYPE_any));
-                                                       q = pushOid(mb, q, 0);
+                                                       if (j->startoid == 0) {
+                                                               q = pushOid(mb, 
q, (oid)0);
+                                                       } else {
+                                                               q = 
pushArgument(mb, q, j->startoid);
+                                                       }
                                                        q = pushArgument(mb, q, 
a);
                                                        a = getArg(q, 0);
                                                        pushInstruction(mb, q);
@@ -7096,6 +7156,7 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                        j->j5 = getArg(q, 4);
                                        j->j6 = getArg(q, 5);
                                        j->j7 = getArg(q, 6);
+                                       j->startoid = 0; /* external output 
should be "clean" */
                                        for (i = 0; i < coltpos; i++) {
                                                switch (coltypes[i]) {
                                                        case j_json:
@@ -7149,6 +7210,7 @@ dumptree(jc *j, Client cntxt, MalBlkPtr 
                                        j->j5 = getArg(r, 4);
                                        j->j6 = getArg(r, 5);
                                        j->j7 = getArg(r, 6);
+                                       j->startoid = 0;  /* wrap returns 
"clean" document */
                                        pushInstruction(mb, r);
                                }
                        } break;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to