Changeset: 9d4cb6781a3a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d4cb6781a3a Modified Files: sql/backends/monet5/rel_bin.c sql/backends/monet5/sql.c sql/backends/monet5/sql_cat.c sql/include/sql_catalog.h sql/server/rel_optimizer.c sql/server/rel_rel.c sql/server/rel_schema.c sql/server/rel_updates.c sql/storage/bat/bat_storage.c sql/storage/sql_catalog.c sql/storage/store.c Branch: default Log Message:
idxs from changeset -> objlist diffs (truncated from 515 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 @@ -1672,8 +1672,8 @@ rel2bin_sql_table(backend *be, sql_table sc = stmt_alias(be, sc, rnme, TID); list_append(l, sc); } - if (t->idxs.set) { - for (n = t->idxs.set->h; n; n = n->next) { + if (t->idxs) { + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; stmt *sc = stmt_idx(be, i, dels, dels->partition); const char *rnme = t->base.name; @@ -4152,9 +4152,9 @@ rel2bin_insert(backend *be, sql_rel *rel } insert = NULL; - if (t->idxs.set) { + if (t->idxs) { idx_m = m; - for (n = t->idxs.set->h; n && m; n = n->next) { + for (n = ol_first_node(t->idxs); n && m; n = n->next) { stmt *is = m->data; sql_idx *i = n->data; @@ -4177,8 +4177,8 @@ rel2bin_insert(backend *be, sql_rel *rel if (t->s) /* only not declared tables, need this */ pos = stmt_claim(be, t, cnt); - if (t->idxs.set) - for (n = t->idxs.set->h, m = idx_m; n && m; n = n->next) { + if (t->idxs) + for (n = ol_first_node(t->idxs), m = idx_m; n && m; n = n->next) { stmt *is = m->data; sql_idx *i = n->data; @@ -4864,10 +4864,10 @@ cascade_updates(backend *be, sql_table * mvc *sql = be->mvc; node *n; - if (!t->idxs.set) + if (!ol_length(t->idxs)) return 0; - for (n = t->idxs.set->h; n; n = n->next) { + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; /* check if update is needed, @@ -4902,11 +4902,11 @@ update_idxs_and_check_keys(backend *be, int updcol; list *idx_updates = sa_list(sql->sa); - if (!t->idxs.set) + if (!ol_length(t->idxs)) return idx_updates; updcol = first_updated_col(updates, ol_length(t->columns)); - for (n = t->idxs.set->h; n; n = n->next) { + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; stmt *is = NULL; 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 @@ -396,8 +396,8 @@ create_table_or_view(mvc *sql, char* sna throw(SQL, "sql.catalog", SQLSTATE(42000) "CREATE TABLE: %s_%s: an internal error occurred", s->base.name, t->base.name); } - if (t->idxs.set) { - for (n = t->idxs.set->h; n; n = n->next) { + if (t->idxs) { + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; if (!mvc_copy_idx(sql, nt, i)) { sql->sa = osa; @@ -4111,8 +4111,8 @@ sql_storage(Client cntxt, MalBlkPtr mb, } if (isTable(t)) - if (t->idxs.set) - for (ncol = (t)->idxs.set->h; ncol; ncol = ncol->next) { + if (t->idxs) + for (ncol = ol_first_node((t)->idxs); ncol; ncol = ncol->next) { sql_base *bc = ncol->data; sql_idx *c = (sql_idx *) ncol->data; if (idx_has_column(c->type)) { 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 @@ -92,10 +92,10 @@ rel_check_tables(mvc *sql, sql_table *nt } } if (isNonPartitionedTable(nt)) { - if (cs_size(&nt->idxs) != cs_size(&nnt->idxs)) + if (ol_length(nt->idxs) != ol_length(nnt->idxs)) throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table index doesn't match %s definition", errtable, errtable); - if (cs_size(&nt->idxs)) - for (n = nt->idxs.set->h, m = nnt->idxs.set->h; n && m; n = n->next, m = m->next) { + if (ol_length(nt->idxs)) + for (n = ol_first_node(nt->idxs), m = ol_first_node(nnt->idxs); n && m; n = n->next, m = m->next) { sql_idx *ni = n->data; sql_idx *mi = m->data; @@ -879,11 +879,13 @@ alter_table(Client cntxt, mvc *sql, char throw(SQL,"sql.alter_table", SQLSTATE(42S02) "ALTER TABLE: no such table '%s'", t->base.name); /* First check if all the changes are allowed */ - if (t->idxs.set) { + if (t->idxs) { /* only one pkey */ if (nt->pkey) { - for (n = t->idxs.nelm; n; n = n->next) { + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; + if (!i->base.new || i->base.deleted) + continue; if (i->key && i->key->type == pkey) throw(SQL,"sql.alter_table", SQLSTATE(40000) "CONSTRAINT PRIMARY KEY: a table can have only one PRIMARY KEY\n"); } @@ -946,19 +948,24 @@ alter_table(Client cntxt, mvc *sql, char if (mvc_copy_column(sql, nt, c) == NULL) throw(SQL,"sql.alter_table", SQLSTATE(40002) "ALTER TABLE: Failed to create column %s.%s", c->t->base.name, c->base.name); } - if (t->idxs.set) { + if (t->idxs) { /* alter drop index */ - if (t->idxs.dset) - for (n = t->idxs.dset->h; n; n = n->next) { + if (t->idxs) + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; + if (i->base.new || !i->base.deleted) + continue; sql_idx *ni = mvc_bind_idx(sql, s, i->base.name); if (mvc_drop_idx(sql, s, ni)) throw(SQL,"sql.alter_table", SQLSTATE(HY013) MAL_MALLOC_FAIL); } /* alter add index */ - for (n = t->idxs.nelm; n; n = n->next) { + for (n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; + if (!i->base.new || i->base.deleted) + continue; + if (i->type == ordered_idx) { sql_kc *ic = i->columns->h->data; BAT *b = mvc_bind(sql, nt->s->base.name, nt->base.name, ic->c->base.name, 0); 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 @@ -709,7 +709,7 @@ typedef struct sql_table { sql_ukey *pkey; objlist *columns; - changeset idxs; + objlist *idxs; changeset keys; changeset triggers; changeset members; /* member tables of merge/replica tables */ diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -87,8 +87,8 @@ name_find_column( sql_rel *rel, const ch return c; } } - if (t->idxs.set) - for (cn = t->idxs.set->h; cn; cn = cn->next) { + if (t->idxs) + for (cn = ol_first_node(t->idxs); cn; cn = cn->next) { sql_idx *i = cn->data; if (strcmp(i->base.name, name+1 /* skip % */) == 0) { *bt = rel; @@ -586,9 +586,9 @@ find_fk_index(mvc *sql, sql_table *l, li { sql_trans *tr = sql->session->tr; - if (l->idxs.set) { + if (l->idxs) { node *in; - for (in = l->idxs.set->h; in; in = in->next){ + for (in = ol_first_node(l->idxs); in; in = in->next){ sql_idx *li = in->data; if (li->type == join_idx) { sql_key *rk = (sql_key*)os_find_id(tr->cat->objects, tr, ((sql_fkey*)li->key)->rkey); @@ -2516,7 +2516,7 @@ is_fk_column_of_pk(mvc *sql, sql_rel *re if (c) { sql_table *t = c->t; - for (node *n = t->idxs.set->h; n; n = n->next) { + for (node *n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *li = n->data; if (li->type == join_idx) { @@ -4464,7 +4464,7 @@ rel_push_groupby_down(visitor *v, sql_re /* * Push select down, pushes the selects through (simple) projections. Also * it cleans up the projections which become useless. - * + * * WARNING - Make sure to call try_remove_empty_select macro before returning so we ensure * possible generated empty selects will get removed without the need to call rel_remove_empty_select optimizer */ @@ -4808,7 +4808,7 @@ rel_push_join_down(visitor *v, sql_rel * * * in some cases the other way is usefull, ie push join down * semijoin. When the join reduces (ie when there are selects on it). - * + * * At the moment, we only flag changes by this optimizer on the first level of optimization */ static inline sql_rel * @@ -8849,9 +8849,9 @@ rel_rename_part(mvc *sql, sql_rel *p, ch } if (n) /* skip TID */ n = n->next; - if (mt->idxs.set) { + if (mt->idxs) { /* also possible index name mismatches */ - for( m = mt->idxs.set->h; n && m; m = m->next) { + for( m = ol_first_node(mt->idxs); n && m; m = m->next) { sql_exp *ne = n->data; sql_idx *i = m->data; char *iname = NULL; diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c --- a/sql/server/rel_rel.c +++ b/sql/server/rel_rel.c @@ -822,8 +822,8 @@ rel_basetable(mvc *sql, sql_table *t, co } append(rel->exps, exp_alias(sa, atname, TID, tname, TID, sql_bind_localtype("oid"), CARD_MULTI, 0, 1)); - if (t->idxs.set) { - for (cn = t->idxs.set->h; cn; cn = cn->next) { + if (t->idxs) { + for (cn = ol_first_node(t->idxs); cn; cn = cn->next) { sql_exp *e; sql_idx *i = cn->data; sql_subtype *t = sql_bind_localtype("lng"); /* hash "lng" */ 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 @@ -1831,6 +1831,7 @@ rel_create_index(mvc *sql, char *iname, /* add index here */ i = mvc_create_idx(sql, nt, iname, itype); + i->base.new = 1; for (n = column_list->h; n; n = n->next) { sql_column *c = mvc_bind_column(sql, nt, n->data.sval); diff --git a/sql/server/rel_updates.c b/sql/server/rel_updates.c --- a/sql/server/rel_updates.c +++ b/sql/server/rel_updates.c @@ -216,11 +216,11 @@ rel_insert_idxs(mvc *sql, sql_table *t, { sql_rel *p = inserts->r; - if (!t->idxs.set) + if (!ol_length(t->idxs)) return inserts; inserts->r = rel_label(sql, inserts->r, 1); - for (node *n = t->idxs.set->h; n; n = n->next) { + for (node *n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; if (hash_index(i->type) || i->type == no_idx) { @@ -807,10 +807,10 @@ rel_update_idxs(mvc *sql, const char *al { sql_rel *p = relup->r; - if (!t->idxs.set) + if (!ol_length(t->idxs)) return relup; - for (node *n = t->idxs.set->h; n; n = n->next) { + for (node *n = ol_first_node(t->idxs); n; n = n->next) { sql_idx *i = n->data; /* check if update is needed, @@ -859,7 +859,7 @@ rel_update(mvc *sql, sql_rel *t, sql_rel sql_column *c = m->data; sql_exp *v = updates[c->colnr]; - if (tab->idxs.set && !v) + if (ol_length(tab->idxs) && !v) v = exp_column(sql->sa, alias, c->base.name, &c->type, CARD_MULTI, c->null, 0); if (v) v = rel_project_add_exp(sql, uprel, v); 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 @@ -2057,8 +2057,8 @@ log_create_del(sql_trans *tr, sql_change ok = log_create_col_(tr, c); } - if (t->idxs.set) { _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list