Changeset: 6b3a30c6bbd9 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6b3a30c6bbd9 Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_cat.c sql/backends/monet5/sql_upgrades.c sql/include/sql_catalog.h sql/server/rel_schema.c sql/storage/store.c Branch: default Log Message:
triggers -> objlist diffs (228 lines): diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c --- a/sql/backends/monet5/rel_bin.c +++ b/sql/backends/monet5/rel_bin.c @@ -4015,10 +4015,10 @@ sql_insert_triggers(backend *be, sql_tab node *n; int res = 1; - if (!t->triggers.set) + if (!ol_length(t->triggers)) return res; - for (n = t->triggers.set->h; n; n = n->next) { + for (n = ol_first_node(t->triggers); n; n = n->next) { sql_trigger *trigger = n->data; if (!stack_push_frame(sql, "%OLD-NEW")) @@ -4979,10 +4979,10 @@ sql_update_triggers(backend *be, sql_tab node *n; int res = 1; - if (!t->triggers.set) + if (!ol_length(t->triggers)) return res; - for (n = t->triggers.set->h; n; n = n->next) { + for (n = ol_first_node(t->triggers); n; n = n->next) { sql_trigger *trigger = n->data; if (!stack_push_frame(sql, "%OLD-NEW")) @@ -5262,10 +5262,10 @@ sql_delete_triggers(backend *be, sql_tab node *n; int res = 1; - if (!t->triggers.set) + if (!ol_length(t->triggers)) return res; - for (n = t->triggers.set->h; n; n = n->next) { + for (n = ol_first_node(t->triggers); n; n = n->next) { sql_trigger *trigger = n->data; if (!stack_push_frame(sql, "%OLD-NEW")) @@ -5400,7 +5400,7 @@ sql_delete(backend *be, sql_table *t, st } /* project all columns */ - if (list_length(t->triggers.set) || partition_find_part(sql->session->tr, t, NULL)) { + if (ol_length(t->triggers) || partition_find_part(sql->session->tr, t, NULL)) { int nr = 0; deleted_cols = table_update_stmts(sql, t, &nr); int i = 0; @@ -5622,7 +5622,7 @@ sql_truncate(backend *be, sql_table *t, v = stmt_tid(be, next, 0); /* project all columns */ - if (list_length(t->triggers.set) || partition_find_part(sql->session->tr, t, NULL)) { + if (ol_length(t->triggers) || partition_find_part(sql->session->tr, t, NULL)) { int nr = 0; deleted_cols = table_update_stmts(sql, t, &nr); int i = 0; diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -422,8 +422,8 @@ create_table_or_view(mvc *sql, char* sna } } } - if (t->triggers.set) { - for (n = t->triggers.set->h; n; n = n->next) { + if (t->triggers) { + for (n = ol_first_node(t->triggers); n; n = n->next) { sql_trigger *tr = n->data; if (mvc_copy_trigger(sql, nt, tr)) { sql->sa = osa; diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c --- a/sql/backends/monet5/sql_cat.c +++ b/sql/backends/monet5/sql_cat.c @@ -1733,7 +1733,7 @@ SQLrename_table(Client cntxt, MalBlkPtr throw(SQL, "sql.rename_table", SQLSTATE(42000) "ALTER TABLE: not possible to change schema of a view"); if (isDeclaredTable(t)) throw(SQL, "sql.rename_table", SQLSTATE(42000) "ALTER TABLE: not possible to change schema of a declared table"); - if (mvc_check_dependency(sql, t->base.id, TABLE_DEPENDENCY, NULL) || cs_size(&t->members) || !list_empty(t->triggers.set)) + if (mvc_check_dependency(sql, t->base.id, TABLE_DEPENDENCY, NULL) || cs_size(&t->members) || ol_length(t->triggers)) throw(SQL, "sql.rename_table", SQLSTATE(2BM37) "ALTER TABLE: unable to set schema of table '%s' (there are database objects which depend on it)", otable_name); if (!(s = mvc_bind_schema(sql, nschema_name))) throw(SQL, "sql.rename_table", SQLSTATE(42S02) "ALTER TABLE: no such schema '%s'", nschema_name); diff --git a/sql/backends/monet5/sql_upgrades.c b/sql/backends/monet5/sql_upgrades.c --- a/sql/backends/monet5/sql_upgrades.c +++ b/sql/backends/monet5/sql_upgrades.c @@ -908,8 +908,8 @@ sql_update_nov2019_missing_dependencies( } } } - if (t->triggers.set) - for (node *mm = t->triggers.set->h; mm; mm = mm->next) { + if (t->triggers) + for (node *mm = ol_first_node(t->triggers); mm; mm = mm->next) { sql_trigger *tr = (sql_trigger*) mm->data; char *relt; sql_rel *r = NULL; 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 @@ -711,7 +711,7 @@ typedef struct sql_table { objlist *columns; objlist *idxs; objlist *keys; - changeset triggers; + objlist *triggers; changeset members; /* member tables of merge/replica tables */ int drop_action; /* only needed for alter drop table */ diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c --- a/sql/server/rel_schema.c +++ b/sql/server/rel_schema.c @@ -2305,7 +2305,7 @@ rel_set_table_schema(sql_query *query, c return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: not possible to change a temporary table schema"); if (isView(ot)) return sql_error(sql, 02, SQLSTATE(42000) "ALTER TABLE: not possible to change schema of a view"); - if (mvc_check_dependency(sql, ot->base.id, TABLE_DEPENDENCY, NULL) || cs_size(&ot->members) || !list_empty(ot->triggers.set)) + if (mvc_check_dependency(sql, ot->base.id, TABLE_DEPENDENCY, NULL) || cs_size(&ot->members) || ol_length(ot->triggers)) return sql_error(sql, 02, SQLSTATE(2BM37) "ALTER TABLE: unable to set schema of table '%s' (there are database objects which depend on it)", tname); if (!(ns = mvc_bind_schema(sql, new_schema))) return sql_error(sql, ERR_NOTFOUND, SQLSTATE(42S02) "ALTER TABLE: no such schema '%s'", new_schema); diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -215,7 +215,7 @@ table_destroy(sqlstore *store, sql_table cs_destroy(&t->members, store); ol_destroy(t->idxs, store); ol_destroy(t->keys, store); - cs_destroy(&t->triggers, store); + ol_destroy(t->triggers, store); ol_destroy(t->columns, store); if (isPartitionedByExpressionTable(t)) { if (t->part.pexp->cols) @@ -677,7 +677,7 @@ load_table(sql_trans *tr, sql_schema *s, t->columns = ol_new(tr->sa, (destroy_fptr) &column_destroy); t->idxs = ol_new(tr->sa, (destroy_fptr) &idx_destroy); t->keys = ol_new(tr->sa, (destroy_fptr) &key_destroy); - cs_new(&t->triggers, tr->sa, (fdestroy) &trigger_destroy); + t->triggers = ol_new(tr->sa, (destroy_fptr) &trigger_destroy); if (isMergeTable(t) || isReplicaTable(t)) cs_new(&t->members, tr->sa, (fdestroy) &part_destroy); @@ -761,7 +761,7 @@ load_table(sql_trans *tr, sql_schema *s, for (rid = store->table_api.rids_next(rs); !is_oid_nil(rid); rid = store->table_api.rids_next(rs)) { sql_trigger *k = load_trigger(tr, t, rid); - cs_add(&t->triggers, k, 0); + ol_add(t->triggers, &k->base); if (os_add(s->triggers, tr, k->base.name, dup_base(&k->base))) { trigger_destroy(store, k); table_destroy(store, t); @@ -1367,7 +1367,7 @@ create_sql_table_with_id(sql_allocator * t->columns = ol_new(sa, (destroy_fptr) &column_destroy); t->idxs = ol_new(sa, (destroy_fptr) &idx_destroy); t->keys = ol_new(sa, (destroy_fptr) &key_destroy); - cs_new(&t->triggers, sa, (fdestroy) &trigger_destroy); + t->triggers = ol_new(sa, (destroy_fptr) &trigger_destroy); if (isMergeTable(t) || isReplicaTable(t)) cs_new(&t->members, sa, (fdestroy) &part_destroy); t->pkey = NULL; @@ -2755,7 +2755,7 @@ table_dup(sql_trans *tr, sql_table *ot, t->columns = ol_new(sa, (destroy_fptr) &column_destroy); t->idxs = ol_new(sa, (destroy_fptr) &idx_destroy); t->keys = ol_new(sa, (destroy_fptr) &key_destroy); - cs_new(&t->triggers, sa, (fdestroy) &trigger_destroy); + t->triggers = ol_new(sa, (destroy_fptr) &trigger_destroy); if (ot->members.set) cs_new(&t->members, sa, (fdestroy) &part_destroy); @@ -2796,9 +2796,11 @@ table_dup(sql_trans *tr, sql_table *ot, sql_key *k = key_dup(tr, n->data, t); ol_add(t->keys, &k->base); } - if (ot->triggers.set) - for (n = ot->triggers.set->h; n; n = n->next) - cs_add(&t->triggers, trigger_dup(tr, n->data, t), 0); + if (ot->triggers) + for (n = ol_first_node(ot->triggers); n; n = n->next) { + sql_trigger *k = trigger_dup(tr, n->data, t); + ol_add(t->triggers, &k->base); + } if (ot->members.set) for (n = ot->members.set->h; n; n = n->next) cs_add(&t->members, part_dup(tr, n->data, t), 0); @@ -2956,7 +2958,7 @@ sql_trans_copy_trigger( sql_trans *tr, s return NULL; sql_trans_create_dependency(tr, ic->c->base.id, nt->base.id, TRIGGER_DEPENDENCY); } - cs_add(&t->triggers, nt, TR_NEW); + ol_add(t->triggers, &nt->base); if (os_add(t->s->triggers, tr, nt->base.name, dup_base(&nt->base))) { trigger_destroy(store, nt); return NULL; @@ -3784,8 +3786,8 @@ sys_drop_triggers(sql_trans *tr, sql_tab { node *n; - if (cs_size(&t->triggers)) - for (n = t->triggers.set->h; n; n = n->next) { + if (ol_length(t->triggers)) + for (n = ol_first_node(t->triggers); n; n = n->next) { sql_trigger *i = n->data; if (sys_drop_trigger(tr, i)) @@ -5793,7 +5795,7 @@ sql_trans_create_trigger(sql_trans *tr, nt->condition = SA_STRDUP(tr->sa, condition); nt->statement = SA_STRDUP(tr->sa, statement); - cs_add(&t->triggers, nt, TR_NEW); + ol_add(t->triggers, &nt->base); if (os_add(t->s->triggers, tr, nt->base.name, dup_base(&nt->base))) { trigger_destroy(store, nt); return NULL; @@ -5851,9 +5853,9 @@ sql_trans_drop_trigger(sql_trans *tr, sq if (sys_drop_trigger(tr, i)) return -1; - node *n = cs_find_name(&i->t->triggers, i->base.name); + node *n = ol_find_name(i->t->triggers, i->base.name); if (n) - cs_del(&i->t->triggers, store, n, i->base.flags); + ol_del(i->t->triggers, store, n); if (drop_action == DROP_CASCADE_START && tr->dropped) { list_destroy(tr->dropped); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list