Changeset: 70b99da8f9c5 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=70b99da8f9c5 Added Files: sql/storage/objlist.c Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_cat.c sql/backends/monet5/sql_optimizer.c sql/backends/monet5/sql_result.c sql/backends/monet5/sql_statement.c sql/backends/monet5/sql_statistics.c sql/backends/monet5/vaults/fits/fits.c sql/include/sql_catalog.h sql/server/rel_optimizer.c sql/server/rel_partition.c sql/server/rel_planner.c sql/server/rel_propagate.c sql/server/rel_psm.c sql/server/rel_rel.c sql/server/rel_schema.c sql/server/rel_select.c sql/server/rel_updates.c sql/server/sql_mvc.c sql/storage/CMakeLists.txt sql/storage/bat/bat_storage.c sql/storage/bat/bat_table.c sql/storage/sql_catalog.c sql/storage/store.c tools/monetdbe/monetdbe.c Branch: default Log Message:
table->columns is now stored in a objlist. diffs (truncated from 1392 to 300 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 @@ -1657,14 +1657,14 @@ rel2bin_sql_table(backend *be, sql_table node *n; stmt *dels = stmt_tid(be, t, 0); - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data; stmt *sc = stmt_col(be, c, dels, dels->partition); list_append(l, sc); } /* TID column */ - if (t->columns.set->h) { + if (ol_first_node(t->columns)) { /* tid function sql.tid(t) */ const char *rnme = t->base.name; @@ -1925,7 +1925,7 @@ rel2bin_table(backend *be, sql_rel *rel, trigger_input *ti = rel->l; l = sa_list(sql->sa); - for(n = ti->t->columns.set->h; n; n = n->next) { + for(n = ol_first_node(ti->t->columns); n; n = n->next) { sql_column *c = n->data; if (ti->type == 2) { /* updates */ @@ -3996,7 +3996,7 @@ sql_stack_add_inserted( mvc *sql, const ti->updates = updates; ti->type = 1; ti->nn = name; - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data; sql_exp *ne = exp_column(sql->sa, name, c->base.name, &c->type, CARD_MULTI, c->null, 0); @@ -4050,7 +4050,7 @@ sql_insert_check_null(backend *be, sql_t node *m, *n; sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", sql_bind_localtype("void"), NULL, F_AGGR); - for (n = t->columns.set->h, m = inserts->h; n && m; + for (n = ol_first_node(t->columns), m = inserts->h; n && m; n = n->next, m = m->next) { stmt *i = m->data; sql_column *c = n->data; @@ -4076,7 +4076,7 @@ sql_insert_check_null(backend *be, sql_t static stmt ** table_update_stmts(mvc *sql, sql_table *t, int *Len) { - *Len = list_length(t->columns.set); + *Len = ol_length(t->columns); return SA_ZNEW_ARRAY(sql->sa, stmt *, *Len); } @@ -4126,7 +4126,7 @@ rel2bin_insert(backend *be, sql_rel *rel l = sa_list(sql->sa); updates = table_update_stmts(sql, t, &len); - for (n = t->columns.set->h, m = inserts->op4.lval->h; n && m; n = n->next, m = m->next) { + for (n = ol_first_node(t->columns), m = inserts->op4.lval->h; n && m; n = n->next, m = m->next) { sql_column *c = n->data; updates[c->colnr] = m->data; @@ -4192,7 +4192,7 @@ rel2bin_insert(backend *be, sql_rel *rel m = m->next; } - for (n = t->columns.set->h, m = inserts->op4.lval->h; n && m; n = n->next, m = m->next) { + for (n = ol_first_node(t->columns), m = inserts->op4.lval->h; n && m; n = n->next, m = m->next) { stmt *ins = m->data; sql_column *c = n->data; @@ -4905,7 +4905,7 @@ update_idxs_and_check_keys(backend *be, if (!t->idxs.set) return idx_updates; - updcol = first_updated_col(updates, list_length(t->columns.set)); + updcol = first_updated_col(updates, ol_length(t->columns)); for (n = t->idxs.set->h; n; n = n->next) { sql_idx *i = n->data; stmt *is = NULL; @@ -4946,7 +4946,7 @@ sql_stack_add_updated(mvc *sql, const ch ti->type = 2; ti->on = on; ti->nn = nn; - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data; if (updates[c->colnr]) { @@ -5017,7 +5017,7 @@ sql_update_check_null(backend *be, sql_t node *n; sql_subfunc *cnt = sql_bind_func(sql, "sys", "count", sql_bind_localtype("void"), NULL, F_AGGR); - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data; if (updates[c->colnr] && !c->null) { @@ -5044,7 +5044,7 @@ sql_update(backend *be, sql_table *t, st { mvc *sql = be->mvc; list *idx_updates = NULL; - int i, nr_cols = list_length(t->columns.set); + int i, nr_cols = ol_length(t->columns); list *l = sa_list(sql->sa); node *n; @@ -5071,7 +5071,7 @@ sql_update(backend *be, sql_table *t, st return sql_error(sql, 02, SQLSTATE(27000) "UPDATE: triggers failed for table '%s'", t->base.name); /* apply updates */ - for (i = 0, n = t->columns.set->h; i < nr_cols && n; i++, n = n->next) { + for (i = 0, n = ol_first_node(t->columns); i < nr_cols && n; i++, n = n->next) { sql_column *c = n->data; if (updates[i]) @@ -5153,7 +5153,7 @@ rel2bin_update(backend *be, sql_rel *rel sql_update_check_null(be, /*(be->cur_append && t->p) ? t->p :*/ t, updates); /* check keys + get idx */ - updcol = first_updated_col(updates, list_length(t->columns.set)); + updcol = first_updated_col(updates, ol_length(t->columns)); for (m = rel->exps->h; m; m = m->next) { sql_exp *ce = m->data; sql_idx *i = find_sql_idx(t, exp_name(ce)+1); @@ -5243,7 +5243,7 @@ sql_stack_add_deleted(mvc *sql, const ch ti->updates = deleted_cols; ti->type = type; ti->nn = name; - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data; sql_exp *ne = exp_column(sql->sa, name, c->base.name, &c->type, CARD_MULTI, c->null, 0); @@ -5404,7 +5404,7 @@ sql_delete(backend *be, sql_table *t, st int nr = 0; deleted_cols = table_update_stmts(sql, t, &nr); int i = 0; - for (node *n = t->columns.set->h; n; n = n->next, i++) { + for (node *n = ol_first_node(t->columns); n; n = n->next, i++) { sql_column *c = n->data; stmt *s = stmt_col(be, c, v, v->partition); @@ -5525,7 +5525,7 @@ check_for_foreign_key_references(mvc *sq k = fk; /* make sure it is not a self referencing key */ if (k->t != t && !cascade) { - node *n = t->columns.set->h; + node *n = ol_first_node(t->columns); sql_column *c = n->data; size_t n_rows = store->storage_api.count_col(sql->session->tr, c, 0); size_t n_deletes = store->storage_api.count_del(sql->session->tr, c->t, 0); @@ -5595,7 +5595,7 @@ sql_truncate(backend *be, sql_table *t, sche = next->s; if (restart_sequences) { /* restart the sequences if it's the case */ - for (node *n = next->columns.set->h; n; n = n->next) { + for (node *n = ol_first_node(next->columns); n; n = n->next) { col = n->data; if (col->def && !strncmp(col->def, next_value_for, strlen(next_value_for))) { @@ -5626,7 +5626,7 @@ sql_truncate(backend *be, sql_table *t, int nr = 0; deleted_cols = table_update_stmts(sql, t, &nr); int i = 0; - for (node *n = t->columns.set->h; n; n = n->next, i++) { + for (node *n = ol_first_node(t->columns); n; n = n->next, i++) { sql_column *c = n->data; stmt *s = stmt_col(be, c, v, v->partition); 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 @@ -332,7 +332,7 @@ create_table_or_view(mvc *sql, char* sna return sql_message(SQLSTATE(42000) "%s TABLE: '%s' name conflicts", action, t->base.name); /* first check default values */ - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data; if (c->def) { @@ -364,7 +364,7 @@ create_table_or_view(mvc *sql, char* sna } } - for (n = t->columns.set->h; n; n = n->next) { + for (n = ol_first_node(t->columns); n; n = n->next) { sql_column *c = n->data, *copied = mvc_copy_column(sql, nt, c); if (copied == NULL) { @@ -1437,7 +1437,7 @@ mvc_delta_values(Client cntxt, MalBlkPtr throw(SQL, "sql.delta", SQLSTATE(3F000) "No such column '%s' in table '%s'", cname, t->base.name); nrows = 1; } else { - nrows = (BUN) t->columns.set->cnt; + nrows = (BUN) ol_length(t->columns); } } else if (s->tables) { struct os_iter oi; @@ -1445,7 +1445,7 @@ mvc_delta_values(Client cntxt, MalBlkPtr for (sql_base *b = oi_next(&oi); b; b = oi_next(&oi)) { t = (sql_table *)b; if (isTable(t)) - nrows += t->columns.set->cnt; + nrows += (BUN) ol_length(t->columns); } } @@ -1486,7 +1486,7 @@ mvc_delta_values(Client cntxt, MalBlkPtr if ((msg=mvc_insert_delta_values(m, col1, col2, col3, col4, col5, col6, col7, c, cleared, deletes)) != NULL) goto cleanup; } else { - for (n = t->columns.set->h; n ; n = n->next) { + for (n = ol_first_node(t->columns); n ; n = n->next) { c = (sql_column*) n->data; if ((msg=mvc_insert_delta_values(m, col1, col2, col3, col4, col5, col6, col7, c, cleared, deletes)) != NULL) goto cleanup; @@ -1501,7 +1501,7 @@ mvc_delta_values(Client cntxt, MalBlkPtr cleared = 0;//(t->cleared != 0); deletes = (lng) store->storage_api.count_del(m->session->tr, t, 0); - for (node *nn = t->columns.set->h; nn ; nn = nn->next) { + for (node *nn = ol_first_node(t->columns); nn ; nn = nn->next) { c = (sql_column*) nn->data; if ((msg=mvc_insert_delta_values(m, col1, col2, col3, col4, col5, col6, col7, @@ -3658,9 +3658,9 @@ sql_rowid(Client cntxt, MalBlkPtr mb, Ma t = mvc_bind_table(m, s, tname); if (t == NULL) throw(SQL, "sql.rowid", SQLSTATE(42S02) "Table missing %s.%s",sname,tname); - if (!s || !t || !t->columns.set->h) + if (!s || !t || !ol_first_node(t->columns)) throw(SQL, "calc.rowid", SQLSTATE(42S22) "Column missing %s.%s",sname,tname); - c = t->columns.set->h->data; + c = ol_first_node(t->columns)->data; /* HACK, get insert bat */ sqlstore *store = m->session->tr->store; b = store->storage_api.bind_col(m->session->tr, c, RDONLY); @@ -3869,7 +3869,7 @@ SQLdrop_hash(Client cntxt, MalBlkPtr mb, TABLE_TYPE_DESCRIPTION(t->type, t->properties), t->base.name); sqlstore *store = m->session->tr->store; - for (o = t->columns.set->h; o; o = o->next) { + for (o = ol_first_node(t->columns); o; o = o->next) { c = o->data; b = store->storage_api.bind_col(m->session->tr, c, RDONLY); if (b == NULL) @@ -3992,8 +3992,8 @@ sql_storage(Client cntxt, MalBlkPtr mb, if( tname && strcmp(bt->name, tname) ) continue; if (isTable(t)) - if (t->columns.set) - for (ncol = (t)->columns.set->h; ncol; ncol = ncol->next) { + if (ol_first_node(t->columns)) + for (ncol = ol_first_node((t)->columns); ncol; ncol = ncol->next) { sql_base *bc = ncol->data; sql_column *c = (sql_column *) ncol->data; BAT *bn; 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 @@ -62,7 +62,7 @@ table_has_updates(sql_trans *tr, sql_tab int cnt = 0; sqlstore *store = tr->store; - for ( n = t->columns.set->h; !cnt && n; n = n->next) { + for ( n = ol_first_node(t->columns); !cnt && n; n = n->next) { sql_column *c = n->data; size_t upd = store->storage_api.count_col( tr, c, 2/* count updates */); @@ -76,9 +76,9 @@ rel_check_tables(mvc *sql, sql_table *nt { node *n, *m, *nn, *mm; - if (cs_size(&nt->columns) != cs_size(&nnt->columns)) + if (ol_length(nt->columns) != ol_length(nnt->columns)) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table doesn't match %s definition", errtable, errtable); - for (n = nt->columns.set->h, m = nnt->columns.set->h; n && m; n = n->next, m = m->next) { + for (n = ol_first_node(nt->columns), m = ol_first_node(nnt->columns); n && m; n = n->next, m = m->next) { sql_column *nc = n->data; sql_column *mc = m->data; @@ -890,22 +890,20 @@ alter_table(Client cntxt, mvc *sql, char } } - /* check for changes */ - if (t->columns.dset) - for (n = t->columns.dset->h; n; n = n->next) { - /* propagate alter table .. drop column */ - sql_column *c = n->data; - sql_column *nc = mvc_bind_column(sql, nt, c->base.name); - if (mvc_drop_column(sql, nt, nc, c->drop_action)) - throw(SQL,"sql.alter_table", SQLSTATE(HY013) MAL_MALLOC_FAIL); - } - /* check for changes on current cols */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list