Changeset: cdeb75203287 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cdeb75203287
Modified Files:
        gdk/gdk_bbp.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/mal/batExtensions.c
        monetdb5/modules/mal/mat.c
Branch: default
Log Message:

Call BATsetaccess to set bat read-only in BBPkeepref.
This means that in a few places we should avoid calling BBPkeepref,
mostly in functions where we change a bat (as opposed to returning a
new one).


diffs (193 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2398,6 +2398,7 @@ BBPkeepref(bat i)
                BAT *b;
 
                if ((b = BBPdescriptor(i)) != NULL) {
+                       BATsetaccess(b, BAT_READ);
                        BATsettrivprop(b);
                        if (GDKdebug & (CHECKMASK | PROPMASK))
                                BATassertProps(b);
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -75,7 +75,9 @@ BKCnewBAT(bat *res, const int *tt, const
        if (bn == NULL)
                throw(MAL, "bat.new", GDK_EXCEPTION);
        *res = bn->batCacheid;
-       BBPkeepref(*res);
+       BATsettrivprop(bn);
+       BBPretain(bn->batCacheid);
+       BBPunfix(bn->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -138,13 +140,14 @@ BKCdelete(bat *r, const bat *bid, const 
 
        if ((b = BATdescriptor(*bid)) == NULL)
                throw(MAL, "bat.delete", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
-       if ((b = setaccess(b, BAT_WRITE)) == NULL)
-               throw(MAL, "bat.delete", OPERATION_FAILED);
        if (BUNdelete(b, *h) != GDK_SUCCEED) {
                BBPunfix(b->batCacheid);
                throw(MAL, "bat.delete", GDK_EXCEPTION);
        }
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -166,7 +169,10 @@ BKCdelete_multi(bat *r, const bat *bid, 
                BBPunfix(b->batCacheid);
                throw(MAL, "bat.delete", GDK_EXCEPTION);
        }
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -183,7 +189,10 @@ BKCdelete_all(bat *r, const bat *bid)
        }
        if( !b->batTransient)
                BATmsync(b);
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -216,7 +225,10 @@ BKCappend_cand_force_wrap(bat *r, const 
        }
        if( !b->batTransient)
                BATmsync(b);
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -257,7 +269,10 @@ BKCappend_val_force_wrap(bat *r, const b
                BBPunfix(b->batCacheid);
                throw(MAL, "bat.append", GDK_EXCEPTION);
        }
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -278,7 +293,10 @@ BKCbun_inplace(bat *r, const bat *bid, c
                BBPunfix(b->batCacheid);
                throw(MAL, "bat.inplace", GDK_EXCEPTION);
        }
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -293,7 +311,10 @@ BKCbun_inplace_force(bat *r, const bat *
                BBPunfix(b->batCacheid);
                throw(MAL, "bat.inplace", GDK_EXCEPTION);
        }
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -320,7 +341,10 @@ BKCbat_inplace_force(bat *r, const bat *
                BBPunfix(u->batCacheid);
                throw(MAL, "bat.inplace", GDK_EXCEPTION);
        }
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        BBPunfix(p->batCacheid);
        BBPunfix(u->batCacheid);
        return MAL_SUCCEED;
@@ -508,7 +532,10 @@ BKCsetAccess(bat *res, const bat *bid, c
        }
        if ((b = setaccess(b, m)) == NULL)
                throw(MAL, "bat.setAccess", OPERATION_FAILED);
-       BBPkeepref(*res = b->batCacheid);
+       *res = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -79,7 +79,10 @@ CMDBATdup(Client cntxt, MalBlkPtr mb, Ma
        BBPunfix(i->batCacheid);
        if (b == 0)
                throw(MAL,"bat.new", SQLSTATE(HY013) MAL_MALLOC_FAIL);
-       BBPkeepref(*ret = b->batCacheid);
+       *ret = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
@@ -262,7 +265,10 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt
                }
        }
 
-       BBPkeepref(*r = b->batCacheid);
+       *r = b->batCacheid;
+       BATsettrivprop(b);
+       BBPretain(b->batCacheid);
+       BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
 
diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -153,7 +153,10 @@ MATpackIncrement(Client cntxt, MalBlkPtr
                        throw(MAL, "mat.pack", GDK_EXCEPTION);
                }
                bn->unused = (pieces-1); /* misuse "unused" field */
-               BBPkeepref(*ret = bn->batCacheid);
+               *ret = bn->batCacheid;
+               BATsettrivprop(bn);
+               BBPretain(bn->batCacheid);
+               BBPunfix(bn->batCacheid);
                if (b != ob)
                        BBPunfix(ob->batCacheid);
                if (b)
@@ -189,7 +192,10 @@ MATpackIncrement(Client cntxt, MalBlkPtr
                        BBPkeepref(*ret = b->batCacheid);
                        throw(MAL, "mat.pack", "INTERNAL ERROR" " b->tnil or  
b->tnonil fails ");
                }
-               BBPkeepref(*ret = b->batCacheid);
+               *ret = b->batCacheid;
+               BATsettrivprop(b);
+               BBPretain(b->batCacheid);
+               BBPunfix(b->batCacheid);
        }
        return MAL_SUCCEED;
 }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to