Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv23422/src/backends/monet5

Modified Files:
        sql.mx sql_gencode.mx 
Log Message:
Finished the implementation of the SQL side of binary file import
(attach).
The implementation  reuses the st_import statement type and  uses the
separator (or lack thereof) to distinguish between  binary and CSV.
It binary, op4 is a list of files instead of a single file (i.e. a
list instead of stmt).

Niels, there is a question in sql_gencode.mx for you (look  for XXX).


U sql_gencode.mx
Index: sql_gencode.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_gencode.mx,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -d -r1.309 -r1.310
--- sql_gencode.mx      14 Jan 2009 12:27:24 -0000      1.309
+++ sql_gencode.mx      26 Jan 2009 16:09:42 -0000      1.310
@@ -1391,12 +1391,11 @@
                        break;
                case st_atom: {
                        atom *a = s->op1.aval;
+                       q = newStmt1(mb, calcRef, 
atom_type(a)->type->base.name);
                        if (atom_null(a)) {
-                               q = newStmt1(mb, calcRef, 
atom_type(a)->type->base.name);
                                q = pushNil(mb, q, 
atom_type(a)->type->localtype);
                        } else {
                                int k;
-                               q = newStmt1(mb, calcRef, 
atom_type(a)->type->base.name);
                                k = constantAtom(sql, mb, a);
                                q = pushArgument(mb, q, k);
                        }
@@ -1505,10 +1504,26 @@
                        char *rsep = n->next->data;
                        char *ssep = n->next->next->data;
                        char *ns = n->next->next->next->data;
+/* XXX shouldn't these be lng?  see stmt_import() in sql_statement.mx */
                        int nr_rec = *(int*)(n->next->next->next->next->data);
                        int offset = 
*(int*)(n->next->next->next->next->next->data);
 
-                       if (s->op4.stval) {
+                       if (sep == NULL) {
+                               /* COPY INTO from binary files */
+                               int *fn;
+                               int i;
+                               node *f;
+
+                               fn = (int *) alloca(sizeof(int) * 
s->op4.lval->cnt);
+                               for (f = s->op4.lval->h, i = 0; f; f = f->next, 
i++)
+                                       fn[i] = _dumpstmt(sql, mb, (stmt *) 
f->data);
+                               q = newStmt1(mb, sqlRef, "importTable");
+                               q = pushStr(mb, q, sname);
+                               q = pushStr(mb, q, tname);
+                               for (i = 0; i < s->op4.lval->cnt; i++)
+                                       q = pushArgument(mb, q, fn[i]);
+                               s->nr = getDestVar(q);
+                       } else if (s->op4.stval) {
                                int file = _dumpstmt(sql, mb, s->op4.stval);
                                int codeset;
                                int bs;

U sql.mx
Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.317
retrieving revision 1.318
diff -u -d -r1.317 -r1.318
--- sql.mx      22 Jan 2009 21:58:06 -0000      1.317
+++ sql.mx      26 Jan 2009 16:09:42 -0000      1.318
@@ -2278,7 +2278,14 @@
        b = BATnew(TYPE_str, TYPE_bat, pci->argc-3);
        for (i = 3, n = t->columns.set->h; i<pci->argc && n; i++, n = n->next) {
                sql_column *col = n->data;
-               BAT *c = BATattach(col->type.type->localtype, 
*(str*)getArgReference(stk, pci, i));
+               BAT *c;
+
+               c = BATattach(col->type.type->localtype, 
*(str*)getArgReference(stk, pci, i));
+               if (c == NULL) {
+                       BBPunfix(b->batCacheid);
+                       throw(SQL, "sql", "failed to attach file %s",
+                             *(str*)getArgReference(stk, pci, i));
+               }
 
                BATsetaccess(c, BAT_READ);
                BATpropcheck(c, BATPROPS_ALL);


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to