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

fixed bug in handling schema_changes, ie now we always reset schema's fully on
schema_changes.


diffs (126 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3205,8 +3205,6 @@ static void
        tr->schema_updates = 0;
        tr->dropped = NULL;
        tr->status = 0;
-       if (otr != gtrans)
-               tr->schema_updates = otr->schema_updates;
 
        tr->schema_number = store_schema_number();
        tr->parent = otr;
@@ -3959,7 +3957,7 @@ rollforward_trans(sql_trans *tr, int mod
 
        if (mode == R_APPLY && tr->parent && tr->wtime > tr->parent->wtime) {
                tr->parent->wtime = tr->wtime;
-               tr->parent->schema_updates = tr->schema_updates;
+               tr->parent->schema_updates += tr->schema_updates;
        }
 
        if (tr->moved_tables) {
@@ -4121,8 +4119,9 @@ reset_changeset(sql_trans *tr, changeset
 static int
 reset_idx(sql_trans *tr, sql_idx *fi, sql_idx *pfi)
 {
+       (void)tr;
        /* did we access the idx or is the global changed after we started */
-       if (fi->base.rtime || fi->base.wtime || tr->stime < pfi->base.wtime) {
+       if (fi->base.rtime || fi->base.wtime || fi->base.stime < 
pfi->base.wtime) {
                if (isTable(fi->t)) 
                        store_funcs.destroy_idx(NULL, fi);
        }
@@ -4133,7 +4132,7 @@ static int
 reset_column(sql_trans *tr, sql_column *fc, sql_column *pfc)
 {
        /* did we access the column or is the global changed after we started */
-       if (fc->base.rtime || fc->base.wtime || tr->stime < pfc->base.wtime) {
+       if (fc->base.rtime || fc->base.wtime || fc->base.stime < 
pfc->base.wtime) {
 
                if (isTable(fc->t)) 
                        store_funcs.destroy_col(NULL, fc);
@@ -4177,7 +4176,7 @@ reset_seq(sql_trans *tr, sql_sequence *f
 static int
 reset_part(sql_trans *tr, sql_part *ft, sql_part *pft)
 {
-       if (ft->base.rtime || ft->base.wtime || tr->stime < pft->base.wtime) {
+       if (ft->base.rtime || ft->base.wtime || ft->base.stime < 
pft->base.wtime) {
 
                if (pft->t) {
                        sql_table *mt = pft->t;
@@ -4215,7 +4214,7 @@ reset_table(sql_trans *tr, sql_table *ft
                return LOG_OK;
 
        /* did we access the table or did the global change */
-       if (ft->base.rtime || ft->base.wtime || tr->stime < pft->base.wtime) {
+       if (ft->base.rtime || ft->base.wtime || ft->base.stime < 
pft->base.wtime) {
                int ok = LOG_OK;
 
                if (isTable(ft) && !isTempTable(ft)) 
@@ -4290,26 +4289,22 @@ reset_schema(sql_trans *tr, sql_schema *
                return ok;
        }
 
-       /* did we access the schema or is the global changed after we started */
-       if (fs->base.rtime || fs->base.wtime || tr->stime < pfs->base.wtime) {
-
-               /* apply possible renaming -> transaction rollbacks or when it 
starts, inherit from the previous transaction */
-               if ((tr->status == 1 && isRenamed(fs)) || isRenamed(pfs)) {
-                       list_hash_delete(tr->schemas.set, fs, NULL);
-                       fs->base.name = sa_strdup(tr->parent->sa, 
pfs->base.name);
-                       if (!list_hash_add(tr->schemas.set, fs, NULL))
-                               ok = LOG_ERR;
-               }
-
-               if (ok == LOG_OK)
-                       ok = reset_changeset(tr, &fs->types, &pfs->types, 
&fs->base, (resetf) NULL, (dupfunc) &type_dup);
-               if (ok == LOG_OK)
-                       ok = reset_changeset(tr, &fs->funcs, &pfs->funcs, 
&fs->base, (resetf) NULL, (dupfunc) &func_dup);
-               if (ok == LOG_OK)
-                       ok = reset_changeset(tr, &fs->seqs, &pfs->seqs, 
&fs->base, (resetf) &reset_seq, (dupfunc) &seq_dup);
-               if (ok == LOG_OK)
-                       ok = reset_changeset(tr, &fs->tables, &pfs->tables, 
&fs->base, (resetf) &reset_table, (dupfunc) &table_dup);
-       }
+       /* apply possible renaming -> transaction rollbacks or when it starts, 
inherit from the previous transaction */
+       if ((tr->status == 1 && isRenamed(fs)) || isRenamed(pfs)) {
+               list_hash_delete(tr->schemas.set, fs, NULL);
+               fs->base.name = sa_strdup(tr->parent->sa, pfs->base.name);
+               if (!list_hash_add(tr->schemas.set, fs, NULL))
+                       ok = LOG_ERR;
+       }
+
+       if (ok == LOG_OK)
+               ok = reset_changeset(tr, &fs->types, &pfs->types, &fs->base, 
(resetf) NULL, (dupfunc) &type_dup);
+       if (ok == LOG_OK)
+               ok = reset_changeset(tr, &fs->funcs, &pfs->funcs, &fs->base, 
(resetf) NULL, (dupfunc) &func_dup);
+       if (ok == LOG_OK)
+               ok = reset_changeset(tr, &fs->seqs, &pfs->seqs, &fs->base, 
(resetf) &reset_seq, (dupfunc) &seq_dup);
+       if (ok == LOG_OK)
+               ok = reset_changeset(tr, &fs->tables, &pfs->tables, &fs->base, 
(resetf) &reset_table, (dupfunc) &table_dup);
        return ok;
 }
 
@@ -4464,7 +4459,6 @@ sql_trans_commit(sql_trans *tr)
                prev_oid = store_oid;
                if (ok == LOG_OK)
                        ok = logger_funcs.log_tend();
-               tr->schema_number = store_schema_number();
        }
        if (ok == LOG_OK) {
                /* It is save to rollforward the changes now. In case 
@@ -5304,6 +5298,7 @@ sql_trans_add_table(sql_trans *tr, sql_t
        cs_add(&mt->members, p, TR_NEW);
        mt->s->base.wtime = mt->base.wtime = pt->s->base.wtime = pt->base.wtime 
= p->base.wtime = tr->wtime = tr->wstime;
        table_funcs.table_insert(tr, sysobj, &mt->base.id, p->base.name, 
&p->base.id);
+       tr->schema_updates ++;
        return mt;
 }
 
@@ -5611,6 +5606,7 @@ sql_trans_del_table(sql_trans *tr, sql_t
 
        if (drop_action == DROP_CASCADE)
                sql_trans_drop_table(tr, mt->s, pt->base.id, drop_action);
+       tr->schema_updates ++;
        return mt;
 }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to