Changeset: 740bbc2f8918 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/740bbc2f8918
Modified Files:
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_result.c
Branch: directappend
Log Message:

Append to the actual table, not to a dummy table


diffs (67 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2908,7 +2908,6 @@ mvc_import_table_wrap(Client cntxt, MalB
                besteffort -= 100;
                append_directly = true;
        }
-       (void)append_directly;
        char *fixed_widths = *getArgReference_str(stk, pci, pci->retc + 9);
        int onclient = *getArgReference_int(stk, pci, pci->retc + 10);
        bool escape = *getArgReference_int(stk, pci, pci->retc + 11);
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -715,7 +715,6 @@ directappend_init(struct directappend *s
        *state = (struct directappend) { 0 };
        backend *be;
        mvc *mvc;
-       sql_schema *s;
 
        msg = checkSQLContext(cntxt);
        if (msg != MAL_SUCCEED)
@@ -723,20 +722,6 @@ directappend_init(struct directappend *s
        be = cntxt->sqlcontext;
        mvc = be->mvc;
        state->mvc = mvc;
-
-       // temporary: append to table banana2 instead
-       s = t->s;
-       char *tname;
-       tname = "banana2";  // <<=============================================
-       if (NULL == (t = mvc_bind_table(mvc, s, tname))) {
-               msg = createException(SQL, "sql.append_from", SQLSTATE(3F000) 
"Table missing: %s.%s", s->base.name, tname);
-               goto bailout;
-       }
-       if (!isTable(t)) {
-               msg = createException(SQL, "sql.append_from", SQLSTATE(42000) 
"%s '%s' is not persistent", TABLE_TYPE_DESCRIPTION(t->type, t->properties), 
t->base.name);
-               goto bailout;
-       }
-
        state->t = t;
 
        state->all_offsets = COLnew(0, TYPE_oid, 0, TRANSIENT);
@@ -1040,13 +1025,21 @@ mvc_import_table(Client cntxt, BAT ***ba
                                        break;
                        }
 
-                       *bats = (BAT**) GDKzalloc(sizeof(BAT *) * as.nr_attrs);
+                       size_t nreturns = loadops ? 1 : as.nr_attrs;
+                       *bats = (BAT**) GDKzalloc(sizeof(BAT *) * nreturns);
                        if ( *bats == NULL) {
                                TABLETdestroy_format(&as);
                                directappend_destroy(our_loadops.state);
                                throw(IO, "sql.copy_from", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                        }
-                       msg = TABLETcollect(*bats,&as);
+                       if (loadops) {
+                               BAT *oids_bat = directappend_state.all_offsets;
+                               directappend_state.all_offsets = NULL; // or 
we'd try to reclaim it later
+                               BBPfix(oids_bat->batCacheid);
+                               (*bats)[0] = oids_bat;
+                       } else {
+                               msg = TABLETcollect(*bats,&as);
+                       }
 
                } while (false);
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to