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

fixed bug with foreign key misalignment, ie leading to BATproject errors


diffs (142 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
@@ -775,7 +775,7 @@ dup_idx(sql_trans *tr, sql_idx *i, sql_i
 {
        int ok = LOG_OK;
 
-       if (!isTable(i->t) || !idx_has_column(i->type))
+       if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type))
                return ok;
        if (i->data) {
                int type = (oid_index(ni->type))?TYPE_oid:TYPE_lng;
@@ -892,9 +892,9 @@ append_col(sql_trans *tr, sql_column *c,
 static int
 append_idx(sql_trans *tr, sql_idx * i, void *ib, int tpe)
 {
+       int ok = LOG_OK;
        BAT *b = ib;
        sql_delta *bat;
-       int ok = LOG_OK;
 
        if (tpe == TYPE_bat && !BATcount(b)) 
                return ok;
@@ -908,8 +908,8 @@ append_idx(sql_trans *tr, sql_idx * i, v
                else {
                        i->data = bat;
                        obat = timestamp_delta(oi->data, i->base.stime);
-                       ok = dup_bat(tr, i->t, obat, bat, type, isNew(i), 
isNew(i));
-                       if(ok != LOG_ERR)
+                       ok = dup_bat(tr, i->t, obat, bat, type, isNew(oi), 
isNew(i));
+                       if(ok == LOG_OK)
                                i->base.allocated = 1;
                }
        }
@@ -1053,7 +1053,7 @@ delete_tab(sql_trans *tr, sql_table * t,
                        sql_idx *i = n->data;
                        sql_delta *bat;
 
-                       if (!isTable(i->t) || !idx_has_column(i->type)) 
+                       if (!isTable(i->t) || (hash_index(i->type) && 
list_length(i->columns) <= 1) || !idx_has_column(i->type)) 
                                continue;
                        if (!i->data) {
                                sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1136,7 +1136,7 @@ count_idx(sql_trans *tr, sql_idx *i, int
 {
        sql_delta *b;
 
-       if (!isTable(i->t) || !idx_has_column(i->type)) 
+       if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type)) 
                return 0;
        if (!i->data) {
                sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1189,7 +1189,7 @@ count_idx_upd(sql_trans *tr, sql_idx *i)
 {
        sql_delta *b;
 
-       if (!isTable(i->t) || !idx_has_column(i->type)) 
+       if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type)) 
                return 0;
        if (!i->data) {
                sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1220,7 +1220,7 @@ count_upd(sql_trans *tr, sql_table *t)
        for( n = t->idxs.set->h; n; n = n->next) {
                sql_idx *i = n->data;
 
-               if (!isTable(i->t) || !idx_has_column(i->type)) 
+               if (!isTable(i->t) || (hash_index(i->type) && 
list_length(i->columns) <= 1) || !idx_has_column(i->type)) 
                        continue;
                if (count_idx_upd(tr, i))
                        return 1;
@@ -2055,7 +2055,7 @@ clear_col(sql_trans *tr, sql_column *c)
 static BUN
 clear_idx(sql_trans *tr, sql_idx *i)
 {
-       if (!isTable(i->t) || !idx_has_column(i->type))
+       if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type))
                return 0;
        if (!i->data || !i->base.allocated) {
                int type = (oid_index(i->type))?TYPE_oid:TYPE_lng;
@@ -2064,7 +2064,7 @@ clear_idx(sql_trans *tr, sql_idx *i)
                if(!bat)
                        return 0;
                obat = timestamp_delta(oi->data, i->base.stime);
-               if(dup_bat(tr, i->t, obat, bat, type, isNew(i), isNew(i)))
+               if(dup_bat(tr, i->t, obat, bat, type, isNew(oi), isNew(i)))
                        return 0;
                i->base.allocated = 1;
        }
@@ -2087,7 +2087,8 @@ clear_dbat(sql_trans *tr, sql_dbat *bat)
        }
        if (bat->dbid) {
                BAT *b = temp_descriptor(bat->dbid);
-               if(b && !isEbat(b)) {
+
+               if (b && !isEbat(b)) {
                        sz += BATcount(b);
                        bat_clear(b);
                        BATcommit(b);
@@ -2269,7 +2270,7 @@ gtr_update_table(sql_trans *tr, sql_tabl
                        sql_idx *ci = n->data;
 
                        /* some indices have no bats */
-                       if (!isTable(ci->t) || !idx_has_column(ci->type)) 
+                       if (!isTable(ci->t) || (hash_index(ci->type) && 
list_length(ci->columns) <= 1) || !idx_has_column(ci->type)) 
                                continue;
                        if (!ci->base.wtime || ci->base.wtime <= 
ci->base.allocated) 
                                continue;
@@ -2823,7 +2824,7 @@ update_table(sql_trans *tr, sql_table *f
                        sql_idx *oi = m->data;
 
                        /* some indices have no bats */
-                       if (!oi->data) {
+                       if (!oi->data || (hash_index(oi->type) && 
list_length(oi->columns) <= 1) || !idx_has_column(oi->type)) {
                                ci->data = NULL;
                                ci->base.allocated = 0;
                                continue;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3232,6 +3232,22 @@ trans_init(sql_trans *tr, backend_stack 
                                                        assert(0);
                                                }
                                        }
+                                       if (pt->idxs.set)
+                                       for (i = pt->idxs.set->h, j = 
t->idxs.set->h; i && j; i = i->next, j = j->next ) { 
+                                               sql_idx *pc = i->data; /* 
parent transactions column */
+                                               sql_idx *c = j->data; 
+
+                                               if (pc->base.id == c->base.id) {
+                                                       c->base.rtime = 
c->base.wtime = 0;
+                                                       c->base.stime = 
pc->base.wtime;
+                                                       if (!istmp && 
!c->base.allocated)
+                                                               c->data = NULL;
+                                                       assert (istmp || 
!c->base.allocated);
+                                               } else {
+                                                       /* for now assert */
+                                                       assert(0);
+                                               }
+                                       }
                                } else {
                                        /* for now assert */
                                        assert(0);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to