Changeset: fe9fdb03fc38 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fe9fdb03fc38
Modified Files:
sql/include/sql_catalog.h
sql/storage/bat/bat_storage.c
sql/storage/objectset.c
sql/storage/store.c
Branch: default
Log Message:
Reapply changeset 427583f8b136
diffs (267 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
@@ -243,7 +243,7 @@ typedef int (*tc_cleanup_fptr) (sql_stor
typedef void (*destroy_fptr)(sql_store store, sql_base *b);
typedef int (*validate_fptr)(struct sql_trans *tr, sql_base *b, int delete);
-extern struct objectset *os_new(sql_allocator *sa, destroy_fptr destroy, bool
temporary, bool unique, bool concurrent, sql_store store);
+extern struct objectset *os_new(sql_allocator *sa, destroy_fptr destroy, bool
temporary, bool unique, bool concurrent, bool nested, sql_store store);
extern struct objectset *os_dup(struct objectset *os);
extern void os_destroy(struct objectset *os, sql_store store);
extern int /*ok, error (name existed) and conflict (added before) */
os_add(struct objectset *os, struct sql_trans *tr, const char *name, sql_base
*b);
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
@@ -3586,6 +3586,8 @@ commit_destroy_del( sql_trans *tr, sql_c
(void)change;
(void)commit_ts;
(void)oldest;
+ if (commit_ts)
+ change->handled = true;
return 0;
}
@@ -4052,6 +4054,8 @@ log_update_col( sql_trans *tr, sql_chang
sql_column *c = (sql_column*)change->obj;
assert(!isTempTable(c->t));
+ if (isDeleted(c->t))
+ change->handled = true;
if (!isDeleted(c->t) && !tr->parent) {/* don't write save point commits
*/
storage *s = ATOMIC_PTR_GET(&c->t->data);
sql_delta *d = ATOMIC_PTR_GET(&c->data);
@@ -4147,7 +4151,7 @@ commit_update_col( sql_trans *tr, sql_ch
ATOMIC_PTR_TYPE* data = &c->data;
int type = c->type.type->localtype;
- if (isDeleted(c->t))
+ if (change->handled || isDeleted(c->t))
return LOG_OK;
return commit_update_delta(tr, change, t, base, data, type, commit_ts,
oldest);
@@ -4159,6 +4163,8 @@ log_update_idx( sql_trans *tr, sql_chang
sql_idx *i = (sql_idx*)change->obj;
assert(!isTempTable(i->t));
+ if (isDeleted(i->t))
+ change->handled = true;
if (!isDeleted(i->t) && !tr->parent) { /* don't write save point
commits */
storage *s = ATOMIC_PTR_GET(&i->t->data);
sql_delta *d = ATOMIC_PTR_GET(&i->data);
@@ -4176,7 +4182,7 @@ commit_update_idx( sql_trans *tr, sql_ch
ATOMIC_PTR_TYPE* data = &i->data;
int type = (oid_index(i->type))?TYPE_oid:TYPE_lng;
- if (isDeleted(i->t))
+ if (change->handled || isDeleted(i->t))
return LOG_OK;
return commit_update_delta(tr, change, t, base, data, type, commit_ts,
oldest);
@@ -4207,6 +4213,8 @@ log_update_del( sql_trans *tr, sql_chang
sql_table *t = (sql_table*)change->obj;
assert(!isTempTable(t));
+ if (isDeleted(t))
+ change->handled = true;
if (!isDeleted(t) && !tr->parent) /* don't write save point commits */
return log_storage(tr, t, ATOMIC_PTR_GET(&t->data));
return LOG_OK;
@@ -4219,7 +4227,7 @@ commit_update_del( sql_trans *tr, sql_ch
sql_table *t = (sql_table*)change->obj;
storage *dbat = ATOMIC_PTR_GET(&t->data);
- if (isDeleted(t))
+ if (change->handled || isDeleted(t))
return ok;
if (t->commit_action == CA_DELETE || t->commit_action == CA_DROP) {
@@ -4280,6 +4288,9 @@ gc_col( sqlstore *store, sql_change *cha
if (!c) /* cleaned earlier */
return 1;
+ if (change->handled || isDeleted(c->t))
+ return 1;
+
/* savepoint commit (did it merge ?) */
if (ATOMIC_PTR_GET(&c->data) != change->data) /* data is freed by
commit */
return 1;
@@ -4328,6 +4339,9 @@ gc_idx( sqlstore *store, sql_change *cha
if (!i) /* cleaned earlier */
return 1;
+ if (change->handled || isDeleted(i->t))
+ return 1;
+
/* savepoint commit (did it merge ?) */
if (ATOMIC_PTR_GET(&i->data) != change->data) /* data is freed by
commit */
return 1;
@@ -4374,6 +4388,8 @@ tc_gc_del( sql_store Store, sql_change *
sqlstore *store = Store;
sql_table *t = (sql_table*)change->obj;
+ if (change->handled || isDeleted(t))
+ return 1;
(void)store;
/* savepoint commit (did it merge ?) */
if (ATOMIC_PTR_GET(&t->data) != change->data) /* data is freed by
commit */
diff --git a/sql/storage/objectset.c b/sql/storage/objectset.c
--- a/sql/storage/objectset.c
+++ b/sql/storage/objectset.c
@@ -64,7 +64,8 @@ typedef struct objectset {
bool
temporary:1,
unique:1, /* names are unique */
- concurrent:1; /* concurrent inserts are allowed */
+ concurrent:1, /* concurrent inserts are allowed */
+ nested:1;
sql_store store;
} objectset;
@@ -537,7 +538,8 @@ try_to_mark_deleted_for_destruction(sqls
}
ov->ts = store_get_timestamp(store)+1;
- ov_destroy_obj_recursive(store, ov);
+ if (!ov->os->nested)
+ ov_destroy_obj_recursive(store, ov);
}
}
@@ -647,7 +649,7 @@ tc_commit_objectversion(sql_trans *tr, s
}
objectset *
-os_new(sql_allocator *sa, destroy_fptr destroy, bool temporary, bool unique,
bool concurrent, sql_store store)
+os_new(sql_allocator *sa, destroy_fptr destroy, bool temporary, bool unique,
bool concurrent, bool nested, sql_store store)
{
assert(!sa);
objectset *os = SA_NEW(sa, objectset);
@@ -658,6 +660,7 @@ os_new(sql_allocator *sa, destroy_fptr d
.temporary = temporary,
.unique = unique,
.concurrent = concurrent,
+ .nested = nested,
.store = store
};
os->destroy = destroy;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1097,14 +1097,14 @@ load_schema(sql_trans *tr, res_table *rt
s->system =
*(bte*)store->table_api.table_fetch_value(rt_schemas, find_sql_column(ss,
"system"));
s->owner =
*(sqlid*)store->table_api.table_fetch_value(rt_schemas, find_sql_column(ss,
"owner"));
- s->tables = os_new(NULL, (destroy_fptr) &table_destroy, false,
true, true, store);
- s->types = os_new(NULL, (destroy_fptr) &type_destroy, false,
true, true, store);
- s->funcs = os_new(NULL, (destroy_fptr) &func_destroy, false,
false, false, store);
- s->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false,
true, true, store);
- s->keys = os_new(NULL, (destroy_fptr) &key_destroy, false,
true, true, store);
- s->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false,
true, true, store);
- s->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy,
false, true, true, store);
- s->parts = os_new(NULL, (destroy_fptr) &part_destroy, false,
false, true, store);
+ s->tables = os_new(NULL, (destroy_fptr) &table_destroy, false,
true, true, false, store);
+ s->types = os_new(NULL, (destroy_fptr) &type_destroy, false,
true, true, false, store);
+ s->funcs = os_new(NULL, (destroy_fptr) &func_destroy, false,
false, false, false, store);
+ s->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false,
true, true, false, store);
+ s->keys = os_new(NULL, (destroy_fptr) &key_destroy, false,
true, true, false, store);
+ s->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false,
true, true, false, store);
+ s->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy,
false, true, true, false, store);
+ s->parts = os_new(NULL, (destroy_fptr) &part_destroy, false,
false, true, false, store);
}
TRC_DEBUG(SQL_STORE, "Load schema: %s %d\n", s->base.name, s->base.id);
@@ -1766,14 +1766,14 @@ bootstrap_create_schema(sql_trans *tr, c
s->auth_id = auth_id;
s->owner = owner;
s->system = TRUE;
- s->tables = os_new(NULL, (destroy_fptr) &table_destroy, false, true,
true, store);
- s->types = os_new(NULL, (destroy_fptr) &type_destroy, false, true,
true, store);
- s->funcs = os_new(NULL, (destroy_fptr) &func_destroy, false, false,
false, store);
- s->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false, true, true,
store);
- s->keys = os_new(NULL, (destroy_fptr) &key_destroy, false, true, true,
store);
- s->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false, true, true,
store);
- s->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy, false,
true, true, store);
- s->parts = os_new(NULL, (destroy_fptr) &part_destroy, false, false,
true, store);
+ s->tables = os_new(NULL, (destroy_fptr) &table_destroy, false, true,
true, false, store);
+ s->types = os_new(NULL, (destroy_fptr) &type_destroy, false, true,
true, false, store);
+ s->funcs = os_new(NULL, (destroy_fptr) &func_destroy, false, false,
false, false, store);
+ s->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false, true, true,
false, store);
+ s->keys = os_new(NULL, (destroy_fptr) &key_destroy, false, true, true,
false, store);
+ s->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false, true, true,
false, store);
+ s->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy, false,
true, true, false, store);
+ s->parts = os_new(NULL, (destroy_fptr) &part_destroy, false, false,
true, false, store);
if (os_add(tr->cat->schemas, tr, s->base.name, &s->base)) {
return NULL;
}
@@ -3762,7 +3762,7 @@ sql_trans_create_(sqlstore *store, sql_t
}
if (!parent) {
- tr->localtmps = os_new(NULL, (destroy_fptr) &table_destroy,
true, true, false, store);
+ tr->localtmps = os_new(NULL, (destroy_fptr) &table_destroy,
true, true, false, false, store);
}
else {
tr->localtmps = os_dup(parent->localtmps);
@@ -3774,8 +3774,8 @@ sql_trans_create_(sqlstore *store, sql_t
tr->cat = store->cat;
if (!tr->cat) {
store->cat = tr->cat = ZNEW(sql_catalog);
- store->cat->schemas = os_new(NULL, (destroy_fptr)
&schema_destroy, false, true, true, store);
- store->cat->objects = os_new(NULL, (destroy_fptr) &key_destroy,
false, false, true, store);
+ store->cat->schemas = os_new(NULL, (destroy_fptr)
&schema_destroy, false, true, true, true, store);
+ store->cat->objects = os_new(NULL, (destroy_fptr) &key_destroy,
false, false, true, false, store);
}
tr->tmp = store->tmp;
TRC_DEBUG(SQL_STORE, "New transaction: %p\n", tr);
@@ -3796,12 +3796,12 @@ schema_dup(sql_trans *tr, sql_schema *s,
sqlstore *store = tr->store;
assert(!isTempSchema(s)); // TODO transaction_layer_revamp: check if
this is really true
- ns->tables = os_new(NULL, (destroy_fptr) &table_destroy, false, true,
true, store);
- ns->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false, true, true,
store);
- ns->keys = os_new(NULL, (destroy_fptr) &key_destroy, false, true, true,
store);
- ns->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false, true, true,
store);
- ns->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy, false,
true, true, store);
- ns->parts = os_new(NULL, (destroy_fptr) &part_destroy, false, false,
true, store);
+ ns->tables = os_new(NULL, (destroy_fptr) &table_destroy, false, true,
true, false, store);
+ ns->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false, true, true,
false, store);
+ ns->keys = os_new(NULL, (destroy_fptr) &key_destroy, false, true, true,
false, store);
+ ns->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false, true, true,
false, store);
+ ns->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy, false,
true, true, false, store);
+ ns->parts = os_new(NULL, (destroy_fptr) &part_destroy, false, false,
true, false, store);
/* table_dup will dup keys, idxs, triggers and parts */
struct os_iter oi;
@@ -5111,14 +5111,14 @@ sql_trans_create_schema(sql_trans *tr, c
s->owner = owner;
s->system = FALSE;
assert(!isTempSchema(s)); // TODO transaction_layer_revamp: check if
this is really true
- s->tables = os_new(NULL, (destroy_fptr) &table_destroy, false, true,
true, store);
- s->types = os_new(NULL, (destroy_fptr) &type_destroy, false, true,
true, store);
- s->funcs = os_new(NULL, (destroy_fptr) &func_destroy, false, false,
false, store);
- s->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false, true, true,
store);
- s->keys = os_new(NULL, (destroy_fptr) &key_destroy, false, true, true,
store);
- s->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false, true, true,
store);
- s->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy, false,
true, true, store);
- s->parts = os_new(NULL, (destroy_fptr) &part_destroy, false, false,
true, store);
+ s->tables = os_new(NULL, (destroy_fptr) &table_destroy, false, true,
true, false, store);
+ s->types = os_new(NULL, (destroy_fptr) &type_destroy, false, true,
true, false, store);
+ s->funcs = os_new(NULL, (destroy_fptr) &func_destroy, false, false,
false, false, store);
+ s->seqs = os_new(NULL, (destroy_fptr) &seq_destroy, false, true, true,
false, store);
+ s->keys = os_new(NULL, (destroy_fptr) &key_destroy, false, true, true,
false, store);
+ s->idxs = os_new(NULL, (destroy_fptr) &idx_destroy, false, true, true,
false, store);
+ s->triggers = os_new(NULL, (destroy_fptr) &trigger_destroy, false,
true, true, false, store);
+ s->parts = os_new(NULL, (destroy_fptr) &part_destroy, false, false,
true, false, store);
s->store = tr->store;
if ((res = store->table_api.table_insert(tr, sysschema, &s->base.id,
&s->base.name, &s->auth_id, &s->owner, &s->system))) {
@@ -5952,7 +5952,7 @@ sql_trans_drop_table(sql_trans *tr, sql_
return res;
t->base.deleted = 1;
-
+
if (gt && (res = os_del(s->tables, tr, gt->base.name,
dup_base(>->base))))
return res;
if (t != gt && (res =os_del(tr->localtmps, tr, t->base.name,
dup_base(&t->base))))
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]