Changeset: 5f03d2c79994 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f03d2c79994 Modified Files: sql/include/sql_catalog.h sql/storage/bat/bat_storage.c sql/storage/sql_catalog.c sql/storage/store.c Branch: nospare Log Message:
only log when we have something too write to the wal. make sure objects are marked existing, during commit. cleanup some more. diffs (137 lines): diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h --- a/sql/include/sql_catalog.h +++ b/sql/include/sql_catalog.h @@ -305,6 +305,7 @@ typedef struct sql_trans { sql_store store; /* keep link into the global store */ list *changes; /* list of changes */ + int logchanges; /* count number of changes to be applied too the wal */ int active; /* is active transaction */ int status; /* status of the last query */ 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 @@ -1628,7 +1628,7 @@ commit_create_col_( sql_trans *tr, sql_c assert(delta->next == NULL); ok = tr_merge_delta(tr, delta); - c->t->base.flags = 0; + c->base.flags = 0; } return ok; } @@ -1745,7 +1745,7 @@ commit_create_idx_( sql_trans *tr, sql_i assert(delta->next == NULL); ok = tr_merge_delta(tr, delta); - i->t->base.flags = 0; + i->base.flags = 0; } return ok; } @@ -1902,6 +1902,7 @@ commit_create_del( sql_trans *tr, sql_ch ok = commit_create_idx_(tr, i, commit_ts, oldest); } } + t->base.flags = 0; } } return ok; diff --git a/sql/storage/sql_catalog.c b/sql/storage/sql_catalog.c --- a/sql/storage/sql_catalog.c +++ b/sql/storage/sql_catalog.c @@ -80,6 +80,8 @@ trans_add(sql_trans *tr, sql_base *b, vo change->commit = commit; change->log = log; tr->changes = sa_list_append(tr->sa, tr->changes, change); + if (log) + tr->logchanges++; } int diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -3236,6 +3236,7 @@ sql_trans_rollback(sql_trans *tr) list_destroy(nl); list_destroy(tr->changes); tr->changes = NULL; + tr->logchanges = 0; } } @@ -3325,60 +3326,38 @@ sql_trans_commit(sql_trans *tr) ulng oldest = store_oldest(store, commit_ts); /* write phase */ - /* first drop temp tables with commit action CA_DROP */ + /* first drop local temp tables with commit action CA_DROP */ if (cs_size(&tr->localtmps)) { for(node *n=tr->localtmps.set->h; n; ) { node *next = n->next; sql_table *tt = n->data; - if (tt->commit_action == CA_DROP) { + if (tt->commit_action == CA_DROP) (void) sql_trans_drop_table_id(tr, tt->s, tt->base.id, DROP_RESTRICT); - /* - } else if (tt->commit_action != CA_PRESERVE || tt->commit_action == CA_DELETE) { - sql_trans_clear_table(tr, tt); - */ - } n = next; } tr->localtmps.nelm = NULL; } - /* - if (tr->tmp) { - struct os_iter oi; - os_iterator(&oi, tr->tmp->tables, tr, NULL); - for (sql_base *b = oi_next(&oi); b; b = oi_next(&oi)) { - sql_table *tt = (sql_table*)b; - - if (tt->commit_action == CA_DROP) { - (void) sql_trans_drop_table_id(tr, tt->s, tt->base.id, DROP_RESTRICT); - } else if (tt->commit_action != CA_PRESERVE || tt->commit_action == CA_DELETE) { - sql_trans_clear_table(tr, tt); - } - b->flags = 0; - } - } - */ TRC_DEBUG(SQL_STORE, "Forwarding changes (%ld, %ld) -> %ld\n", tr->tid, tr->ts, commit_ts); if (tr->changes) { - /* log changes */ - /* TODO this block should only be done if there is something to log */ - if (!tr->parent && tr->active) /* only active transactions need loging (not savepoints and during reload) */ + /* log changes should only be done if there is something to log */ + if (tr->logchanges > 0) { ok = store->logger_api.log_tstart(store); - /* log */ - for(node *n=tr->changes->h; n && ok == LOG_OK; n = n->next) { - sql_change *c = n->data; - - if (c->log && ok == LOG_OK) - ok = c->log(tr, c); - } - //saved_id = store->logger_api.log_save_id(store); - if (!tr->parent && tr->active) { + /* log */ + for(node *n=tr->changes->h; n && ok == LOG_OK; n = n->next) { + sql_change *c = n->data; + + if (c->log && ok == LOG_OK) + ok = c->log(tr, c); + } + //saved_id = store->logger_api.log_save_id(store); if (ok == LOG_OK && store->prev_oid != store->obj_id) ok = store->logger_api.log_sequence(store, OBJ_SID, store->obj_id); store->prev_oid = store->obj_id; if (ok == LOG_OK) ok = store->logger_api.log_tend(store); } + tr->logchanges = 0; /* apply committed changes */ for(node *n=tr->changes->h; n && ok == LOG_OK; n = n->next) { sql_change *c = n->data; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list