Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8768

Modified Files:
        mal_parser.mx 
Log Message:
Recognize tuples being received over the primary communication channel.
Flush them to a temporary file, and replace the batch by a string
assignment to the predefined variable 'tuples'

This code will help to ship BATs to a remote site, by simply
printing them on the channel.


Index: mal_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_parser.mx,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- mal_parser.mx       11 Jan 2008 10:41:32 -0000      1.210
+++ mal_parser.mx       20 Jan 2008 03:53:51 -0000      1.211
@@ -93,6 +93,7 @@
 #include "mal_instruction.h"    /* for pushEndInstruction(), 
findVariableLength() */
 #include "mal_namespace.h"
 #include "mal_utils.h"
+#include "mal_builder.h"
 
 #define FATALINPUT MAXERRORS+1
 #define NL(X) ((X)=='\n' || (X)=='\r')
@@ -1676,6 +1677,47 @@
        skipToEnd(cntxt);
        pushInstruction(curBlk,curInstr);
 }
+
[EMAIL PROTECTED]
+A piggybacked way to ship tuples is to mimick
+a copycommand through the language interface.
+All tuples are stored in a temporary file 
+whose name can be picked up immediately afterwards.
+The code should be made thread safe, by storing
+the file name in the client record.
[EMAIL PROTECTED]
+static void
+parseTuple(Client cntxt) {
+       InstrPtr curInstr;
+       MalBlkPtr curBlk;
+       Symbol curPrg;
+       FILE *f= 0;
+       char  buf[MAXPATHLEN]="monetXXXXX",*fname= buf;
+       int c;
+
+       fname= tmpnam(fname);
+       if(fname == 0)
+               showException(SYNTAX, "no temp file", "");
+       else 
+               f= fopen(fname,"w");
+       while( (c=currChar(cntxt)) == '[' && c){
+               do {
+                       if (f && c) fputc(c, f);
+                       nextChar(cntxt);
+               } while( (c=currChar(cntxt)) != '\n' && c);
+               if (f && c) fputc(c, f);
+               nextChar(cntxt);
+       }
+       curPrg = cntxt->curprg;
+       curBlk = curPrg->def;
+       curInstr = newAssignment(curBlk);
+       c = newVariable(curBlk,GDKstrdup("tuples"),TYPE_any);
+       getArg(curInstr,0)= c;
+       pushStr(curBlk,curInstr,fname);
+       if( f)
+               (void) fclose(f);
+}
+
 #define BRKONERR if( curPrg->def->errors>=MAXERRORS) return 
curPrg->def->errors;
 int parseMAL(Client cntxt, Symbol curPrg){
        int cntrl=0;
@@ -1693,6 +1735,10 @@
                case ';': case '\t': case ' ': 
                        nextChar(cntxt);
                        continue;
+               case '[':
+               /* parse a tuple value. stops at end of line */
+                       parseTuple(cntxt);
+                       break;
                case '#': 
                { /* keep the full line comments unless it is a MX #line */
                        char start[256], *e=start, c; 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to