Changeset: f11781d4cff2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f11781d4cff2
Modified Files:
        sql/storage/bat/bat_storage.c
Branch: unlock
Log Message:

protect access of the deleted table against heap-extends


diffs (53 lines):

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
@@ -43,6 +43,18 @@ timestamp_dbat( storage *d, int ts)
        return d;
 }
 
+static void
+lock_table(sqlid id)
+{
+       MT_lock_set(&table_locks[id&(NR_TABLE_LOCKS-1)]);
+}
+
+static void
+unlock_table(sqlid id)
+{
+       MT_lock_unset(&table_locks[id&(NR_TABLE_LOCKS-1)]);
+}
+
 static size_t
 count_inserts( segment *s, sql_trans *tr)
 {
@@ -227,7 +239,10 @@ count_del(sql_trans *tr, sql_table *t, i
                return d->cs.ucnt;
        if (access == 1)
                return count_inserts(d->segs->head, tr);
-       return count_deletes(d);
+       lock_table(t->base.id);
+       size_t cnt = count_deletes(d);
+       unlock_table(t->base.id);
+       return cnt;
 }
 
 static BAT *
@@ -936,18 +951,6 @@ table_claim_space(sql_trans *tr, sql_tab
        return LOG_OK;
 }
 
-static void
-lock_table(sqlid id)
-{
-       MT_lock_set(&table_locks[id&(NR_TABLE_LOCKS-1)]);
-}
-
-static void
-unlock_table(sqlid id)
-{
-       MT_lock_unset(&table_locks[id&(NR_TABLE_LOCKS-1)]);
-}
-
 static BAT *
 mask_bat(size_t cnt, msk val)
 {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to