Changeset: 4129073aff31 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4129073aff31 Modified Files: sql/backends/monet5/sql.c sql/backends/monet5/sql_statistics.c sql/backends/monet5/sql_upgrades.c sql/include/sql_catalog.h sql/server/sql_mvc.c sql/storage/sql_catalog.c sql/storage/store.c Branch: nospare Log Message:
use objectset for schemas diffs (truncated from 619 to 300 lines): 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 @@ -4354,7 +4354,7 @@ sql_storage(Client cntxt, MalBlkPtr mb, mvc *m = NULL; str msg; sql_trans *tr; - node *nsch, *ncol; + node *ncol; int w; bit bitval; bat *rsch = getArgReference_bat(stk, pci, 0); @@ -4377,6 +4377,7 @@ sql_storage(Client cntxt, MalBlkPtr mb, str sname = 0; str tname = 0; str cname = 0; + struct os_iter *si = NULL; if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; @@ -4416,9 +4417,9 @@ sql_storage(Client cntxt, MalBlkPtr mb, cname = *getArgReference_str(stk, pci, pci->retc + 2); /* check for limited storage tables */ - for (nsch = tr->cat->schemas.set->h; nsch; nsch = nsch->next) { - sql_base *b = nsch->data; - sql_schema *s = (sql_schema *) nsch->data; + si = os_iterator(tr->cat->schemas, tr, NULL); + for (sql_base *b = oi_next(si); b; b = oi_next(si)) { + sql_schema *s = (sql_schema *) b; if( sname && strcmp(b->name, sname) ) continue; if (isalpha((unsigned char) b->name[0])) diff --git a/sql/backends/monet5/sql_statistics.c b/sql/backends/monet5/sql_statistics.c --- a/sql/backends/monet5/sql_statistics.c +++ b/sql/backends/monet5/sql_statistics.c @@ -78,7 +78,7 @@ sql_analyze(Client cntxt, MalBlkPtr mb, mvc *m = NULL; str msg = getSQLContext(cntxt, mb, &m, NULL); sql_trans *tr = m->session->tr; - node *nsch, *ncol; + node *ncol; char *maxval = NULL, *minval = NULL; size_t minlen = 0, maxlen = 0; str sch = 0, tbl = 0, col = 0; @@ -123,8 +123,9 @@ sql_analyze(Client cntxt, MalBlkPtr mb, TRC_DEBUG(SQL_PARSER, "analyze %s.%s.%s sample " LLFMT "%s\n", (sch ? sch : ""), (tbl ? tbl : " "), (col ? col : " "), samplesize, (minmax)?"MinMax":""); /* Do all the validations before doing any analyze */ - for (nsch = tr->cat->schemas.set->h; nsch; nsch = nsch->next) { - sql_schema *s = (sql_schema *) nsch->data; + struct os_iter *si = os_iterator(tr->cat->schemas, tr, NULL); + for(sql_base *b = oi_next(si); b; b = oi_next(si)) { + sql_schema *s = (sql_schema *)b; if (!isalpha((unsigned char) s->base.name[0])) continue; @@ -165,9 +166,9 @@ sql_analyze(Client cntxt, MalBlkPtr mb, throw(SQL, "analyze", SQLSTATE(38000) "Column '%s' does not exist", col); sqlstore *store = tr->store; - for (nsch = tr->cat->schemas.set->h; nsch; nsch = nsch->next) { - sql_base *b = nsch->data; - sql_schema *s = (sql_schema *) nsch->data; + si = os_iterator(tr->cat->schemas, tr, NULL); + for(sql_base *b = oi_next(si); b; b = oi_next(si)) { + sql_schema *s = (sql_schema *)b; if (!isalpha((unsigned char) b->name[0])) continue; 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 @@ -1031,6 +1031,7 @@ sql_update_nov2019_missing_dependencies( sql_allocator *old_sa = sql->sa; bool first = true; sql_trans *tr = sql->session->tr; + struct os_iter *si = NULL; if (buf == NULL) throw(SQL, __func__, SQLSTATE(HY013) MAL_MALLOC_FAIL); @@ -1043,8 +1044,9 @@ sql_update_nov2019_missing_dependencies( pos += snprintf(buf + pos, bufsize - pos, "insert into sys.dependencies select c1, c2, c3 from (values"); ppos = pos; /* later check if found updatable database objects */ - for (node *n = sql->session->tr->cat->schemas.set->h; n; n = n->next) { - sql_schema *s = (sql_schema*) n->data; + si = os_iterator(sql->session->tr->cat->schemas, sql->session->tr, NULL); + for (sql_base *b = oi_next(si); b; oi_next(si)) { + sql_schema *s = (sql_schema*)b; struct os_iter *oi = os_iterator(s->funcs, sql->session->tr, NULL); for (sql_base *b = oi_next(oi); b; oi_next(oi)) { 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 @@ -288,7 +288,7 @@ typedef struct sql_schema { } sql_schema; typedef struct sql_catalog { - changeset schemas; + struct objectset *schemas; } sql_catalog; typedef struct sql_trans { @@ -775,7 +775,6 @@ extern sql_sequence *find_sql_sequence(s extern sql_schema *find_sql_schema(sql_trans *t, const char *sname); extern sql_schema *find_sql_schema_id(sql_trans *t, sqlid id); -extern node *find_sql_schema_node(sql_trans *t, sqlid id); extern sql_type *find_sql_type(sql_trans *tr, sql_schema * s, const char *tname); extern sql_type *sql_trans_bind_type(sql_trans *tr, sql_schema *s, const char *name); diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c --- a/sql/server/sql_mvc.c +++ b/sql/server/sql_mvc.c @@ -357,8 +357,10 @@ mvc_init(sql_allocator *pa, int debug, s } //as the sql_parser is not yet initialized in the storage, we determine the sql type of the sql_parts here - for (node *n = m->session->tr->cat->schemas.set->h; n; n = n->next) { - sql_schema *ss = (sql_schema*) n->data; + + struct os_iter *si = os_iterator(m->session->tr->cat->schemas, m->session->tr, NULL); + for(sql_base *b = oi_next(si); b; b = oi_next(si)) { + sql_schema *ss = (sql_schema*)b; struct os_iter *oi = os_iterator(ss->tables, m->session->tr, NULL); for(sql_base *b = oi_next(oi); b; b = oi_next(oi)) { sql_table *tt = (sql_table*)b; 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 @@ -49,7 +49,7 @@ static void * for (; he; he = he->chain) { sql_base *b = he->value; - if (b->name && strcmp(b->name, name) == 0 && !b->deleted) { + if (b->name && strcmp(b->name, name) == 0) { MT_lock_unset(&l->ht_lock); return b; } @@ -117,21 +117,6 @@ tr_version_of_parent(sql_trans *tr, ulng } static void * -tr_find_base(sql_trans *tr, sql_base *b) -{ - while(b && b->ts != tr->tid && (tr->parent && !tr_version_of_parent(tr, b->ts)) && b->ts > tr->ts) - b = b->older; - return b; -} - -static void * -tr_find_name(sql_trans *tr, changeset * cs, const char *name) -{ - sql_base *b = _list_find_name(cs->set, name); - return tr_find_base(tr, b); -} - -static void * _cs_find_name(changeset * cs, const char *name) { return _list_find_name(cs->set, name); @@ -218,13 +203,12 @@ find_sql_key(sql_table *t, const char *k sql_key * sql_trans_find_key(sql_trans *tr, sqlid id) { - if (tr->cat->schemas.set) { - for (node *n = tr->cat->schemas.set->h; n; n = n->next) { - sql_schema *s = n->data; - sql_base *b = os_find_id(s->keys, tr, id); - if (b) - return (sql_key*)b; - } + struct os_iter *oi = os_iterator(tr->cat->schemas, tr, NULL); + for (sql_base *b = oi_next(oi); b; b = oi_next(oi)) { + sql_schema *s = (sql_schema*)b; + sql_base *bk = os_find_id(s->keys, tr, id); + if (bk) + return (sql_key*)bk; } return NULL; } @@ -238,13 +222,12 @@ find_sql_idx(sql_table *t, const char *i sql_idx * sql_trans_find_idx(sql_trans *tr, sqlid id) { - if (tr->cat->schemas.set) { - for (node *n = tr->cat->schemas.set->h; n; n = n->next) { - sql_schema *s = n->data; - sql_base *b = os_find_id(s->idxs, tr, id); - if (b) - return (sql_idx*)b; - } + struct os_iter *oi = os_iterator(tr->cat->schemas, tr, NULL); + for (sql_base *b = oi_next(oi); b; b = oi_next(oi)) { + sql_schema *s = (sql_schema*)b; + sql_base *bi = os_find_id(s->idxs, tr, id); + if (bi) + return (sql_idx*)bi; } return NULL; } @@ -255,6 +238,14 @@ find_sql_column(sql_table *t, const char return _cs_find_name(&t->columns, cname); } +static void * +tr_find_base(sql_trans *tr, sql_base *b) +{ + while(b && b->ts != tr->tid && (tr->parent && !tr_version_of_parent(tr, b->ts)) && b->ts > tr->ts) + b = b->older; + return b; +} + sql_part * find_sql_part_id(sql_trans *tr, sql_table *t, sqlid id) { @@ -280,18 +271,14 @@ find_sql_table_id(sql_trans *tr, sql_sch sql_table * sql_trans_find_table(sql_trans *tr, sqlid id) { - node *n; - sql_table *t = NULL; - - if (tr->cat->schemas.set) { - for (n = tr->cat->schemas.set->h; n && !t; n = n->next) { - sql_schema *s = n->data; - sql_base *m = os_find_id(s->tables, tr, id); - if (m) - t = (sql_table*)m; - } + struct os_iter *oi = os_iterator(tr->cat->schemas, tr, NULL); + for (sql_base *b = oi_next(oi); b; b = oi_next(oi)) { + sql_schema *s = (sql_schema*)b; + sql_base *bt = os_find_id(s->tables, tr, id); + if (bt) + return (sql_table*)bt; } - return t; + return NULL; } sql_sequence * @@ -305,7 +292,7 @@ find_sql_schema(sql_trans *tr, const cha { if (tr->tmp && strcmp(sname, "tmp")==0) return tr->tmp; - return tr_find_name(tr, &tr->cat->schemas, sname); + return (sql_schema*)os_find_name(tr->cat->schemas, tr, sname); } sql_schema * @@ -313,17 +300,7 @@ find_sql_schema_id(sql_trans *tr, sqlid { if (tr->tmp && tr->tmp->base.id == id) return tr->tmp; - node *n = cs_find_id(&tr->cat->schemas, id); - - if (n) - return n->data; - return NULL; -} - -node * -find_sql_schema_node(sql_trans *tr, sqlid id) -{ - return cs_find_id(&tr->cat->schemas, id); + return (sql_schema*)os_find_id(tr->cat->schemas, tr, id); } sql_type * @@ -335,18 +312,16 @@ find_sql_type(sql_trans *tr, sql_schema sql_type * sql_trans_bind_type(sql_trans *tr, sql_schema *c, const char *name) { - sql_type *t = NULL; - - if (tr->cat->schemas.set) - for (node *n = tr->cat->schemas.set->h; n && !t; n = n->next) { - sql_schema *s = n->data; - - t = find_sql_type(tr, s, name); - } - - if (!t && c) - t = find_sql_type(tr, c, name); - return t; + struct os_iter *oi = os_iterator(tr->cat->schemas, tr, NULL); + for (sql_base *b = oi_next(oi); b; b = oi_next(oi)) { + sql_schema *s = (sql_schema*)b; + sql_type *t = find_sql_type(tr, s, name); + if (t) + return t; + } + if (c) + return find_sql_type(tr, c, name); + return NULL; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list