Changeset: ba770c4dfa90 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ba770c4dfa90
Modified Files:
        sql/backends/monet5/sql.c
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

In some cases we need to convert a view to a copy earlier.


diffs (49 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
@@ -1830,8 +1830,17 @@ mvc_append_wrap(Client cntxt, MalBlkPtr 
        }
        if (ATOMextern(tpe) && !ATOMvarsized(tpe))
                ins = *(ptr *) ins;
-       if ( tpe == TYPE_bat)
+       if ( tpe == TYPE_bat) {
                b =  (BAT*) ins;
+               if (VIEWtparent(b) || VIEWvtparent(b)) {
+                       /* note, b == (BAT*)ins */
+                       b = COLcopy(b, b->ttype, true, TRANSIENT);
+                       BBPreclaim(ins);
+                       ins = b;
+                       if (b == NULL)
+                               throw(SQL, "sql.append", GDK_EXCEPTION);
+               }
+       }
        s = mvc_bind_schema(m, sname);
        if (s == NULL) {
                bat_destroy(pos);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -73,12 +73,9 @@ transfer_to_systrans(BAT *b)
        MT_lock_set(&b->theaplock);
        if (VIEWtparent(b) || VIEWvtparent(b)) {
                MT_lock_unset(&b->theaplock);
-               BAT *bn = COLcopy(b, b->ttype, true, TRANSIENT);
+               BAT *bn = COLcopy(b, b->ttype, true, SYSTRANS);
                BBPreclaim(b);
-               b = bn;
-               if (b == NULL)
-                       return NULL;
-               MT_lock_set(&b->theaplock);
+               return bn;
        }
        if (b->theap->farmid == TRANSIENT ||
                (b->tvheap && b->tvheap->farmid == TRANSIENT)) {
@@ -2158,7 +2155,7 @@ delta_append_bat(sql_trans *tr, sql_delt
                bat_set_access(i, BAT_READ);
                if (bat->cs.bid)
                        temp_destroy(bat->cs.bid);
-               transfer_to_systrans(i);
+               i = transfer_to_systrans(i);
                bat->cs.bid = temp_create(i);
        } else if (!offsets && offset == b->hseqbase+BATcount(b)) {
                if (BATappend(b, oi, NULL, true) != GDK_SUCCEED)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to