Changeset: 97901335c72d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=97901335c72d Modified Files: sql/backends/monet5/sql.c sql/server/sql_mvc.c sql/server/sql_partition.c sql/server/sql_partition.h sql/storage/store.c Branch: nospare Log Message:
more leak fixing.. diffs (173 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 @@ -381,8 +381,9 @@ create_table_or_view(mvc *sql, char* sna if (isPartitionedByExpressionTable(t)) { char *err = NULL; + _DELETE(nt->part.pexp->exp); nt->part.pexp->exp = SA_STRDUP(sql->session->tr->sa, t->part.pexp->exp); - err = bootstrap_partition_expression(sql, sql->session->tr->sa, nt, 1); + err = bootstrap_partition_expression(sql, nt, 1); sa_reset(sql->ta); if (err) { sql->sa = osa; 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 @@ -1240,7 +1240,7 @@ mvc_create_table(mvc *m, sql_schema *s, t->s = s; } else { t = sql_trans_create_table(m->session->tr, s, name, NULL, tt, system, persistence, commit_action, sz, properties); - if(t && isPartitionedByExpressionTable(t) && (err = bootstrap_partition_expression(m, m->session->tr->sa, t, 1))) { + if(t && isPartitionedByExpressionTable(t) && (err = bootstrap_partition_expression(m, t, 1))) { (void) sql_error(m, 02, "%s", err); return NULL; } diff --git a/sql/server/sql_partition.c b/sql/server/sql_partition.c --- a/sql/server/sql_partition.c +++ b/sql/server/sql_partition.c @@ -231,7 +231,7 @@ exp_find_table_columns(mvc *sql, sql_exp } str -bootstrap_partition_expression(mvc *sql, sql_allocator *rsa, sql_table *mt, int instantiate) +bootstrap_partition_expression(mvc *sql, sql_table *mt, int instantiate) { sql_exp *exp; char *query, *msg = NULL; @@ -255,8 +255,7 @@ bootstrap_partition_expression(mvc *sql, throw(SQL,"sql.partition", SQLSTATE(42000) "Incorrect expression '%s'", query); } - if (!mt->part.pexp->cols) - mt->part.pexp->cols = SA_LIST(rsa, (fdestroy) NULL); + assert(mt->part.pexp->cols); exp_find_table_columns(sql, exp, mt, mt->part.pexp->cols); mt->part.pexp->type = *exp_subtype(exp); @@ -309,7 +308,7 @@ initialize_sql_parts(mvc *sql, sql_table int localtype; sql_trans *tr = sql->session->tr; - if (isPartitionedByExpressionTable(mt) && (res = bootstrap_partition_expression(sql, tr->sa, mt, 0)) != NULL) + if (isPartitionedByExpressionTable(mt) && (res = bootstrap_partition_expression(sql, mt, 0)) != NULL) return res; find_partition_type(&found, mt); diff --git a/sql/server/sql_partition.h b/sql/server/sql_partition.h --- a/sql/server/sql_partition.h +++ b/sql/server/sql_partition.h @@ -13,7 +13,7 @@ #include "sql_catalog.h" extern str sql_partition_validate_key(mvc *sql, sql_table *nt, sql_key *k, const char* op); -extern str bootstrap_partition_expression(mvc* sql, sql_allocator *rsa, sql_table *mt, int instantiate); +extern str bootstrap_partition_expression(mvc* sql, sql_table *mt, int instantiate); extern void find_partition_type(sql_subtype *tpe, sql_table *mt); extern str initialize_sql_parts(mvc* sql, sql_table *mt); diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -205,6 +205,13 @@ column_destroy(sqlstore *store, sql_colu } static void +int_destroy(sqlstore *store, int *v) +{ + (void)store; + _DELETE(v); +} + +static void table_destroy(sqlstore *store, sql_table *t) { assert(t->base.refcnt > 0); @@ -219,7 +226,9 @@ table_destroy(sqlstore *store, sql_table cs_destroy(&t->triggers, store); cs_destroy(&t->columns, store); if (isPartitionedByExpressionTable(t)) { - list_destroy(t->part.pexp->cols); + if (t->part.pexp->cols) + list_destroy2(t->part.pexp->cols, store); + _DELETE(t->part.pexp->exp); _DELETE(t->part.pexp); } _DELETE(t->query); @@ -670,12 +679,6 @@ dup_base(sql_base *b) } static sql_table * -dup_table(sql_table *t) -{ - return (sql_table*)dup_base(&t->base); -} - -static sql_table * load_table(sql_trans *tr, sql_schema *s, sqlid tid, subrids *nrs) { sqlstore *store = tr->store; @@ -762,8 +765,7 @@ load_table(sql_trans *tr, sql_schema *s, t->part.pexp = SA_ZNEW(tr->sa, sql_expression); t->part.pexp->exp = exp; t->part.pexp->type = *sql_bind_localtype("void"); /* initialized at initialize_sql_parts */ - /* ??? what kind of objects do we keep */ - t->part.pexp->cols = SA_LIST(tr->sa, (fdestroy) NULL); + t->part.pexp->cols = SA_LIST(tr->sa, (fdestroy) &int_destroy); } for (rid = store->table_api.subrids_next(nrs); !is_oid_nil(rid); rid = store->table_api.subrids_next(nrs)) { sql_column* next = load_column(tr, t, rid); @@ -1600,7 +1602,7 @@ dup_sql_table(sql_allocator *sa, sql_tab nt->part.pexp = SA_ZNEW(sa, sql_expression); nt->part.pexp->exp = SA_STRDUP(sa, t->part.pexp->exp); nt->part.pexp->type = t->part.pexp->type; /* No dup_sql_type call needed */ - nt->part.pexp->cols = SA_LIST(sa, (fdestroy) NULL); + nt->part.pexp->cols = SA_LIST(sa, (fdestroy) &int_destroy); for (n = t->part.pexp->cols->h; n; n = n->next) { int *nid = SA_NEW(sa, int); *nid = *(int *) n->data; @@ -3036,7 +3038,7 @@ table_dup(sql_trans *tr, sql_table *ot, t->part.pexp = SA_ZNEW(sa, sql_expression); t->part.pexp->exp = SA_STRDUP(sa, ot->part.pexp->exp); t->part.pexp->type = ot->part.pexp->type; - t->part.pexp->cols = SA_LIST(sa, (fdestroy) NULL); + t->part.pexp->cols = SA_LIST(sa, (fdestroy) &int_destroy); for (n = ot->part.pexp->cols->h; n; n = n->next) { int *nid = SA_NEW(sa, int); *nid = *(int *) n->data; @@ -3395,7 +3397,7 @@ sql_trans_rollback(sql_trans *tr) node *next = n->next; sql_table *tt = n->data; if (!isNew(tt)) - list_prepend(tr->localtmps.set, dup_table(tt)); + list_prepend(tr->localtmps.set, dup_base(&tt->base)); n = next; } } @@ -4513,7 +4515,7 @@ sql_trans_drop_schema(sql_trans *tr, sql return 0; } - sql_table * +sql_table * sql_trans_add_table(sql_trans *tr, sql_table *mt, sql_table *pt) { sqlstore *store = tr->store; @@ -4525,6 +4527,8 @@ sql_trans_add_table(sql_trans *tr, sql_t sql_trans_create_dependency(tr, pt->base.id, mt->base.id, TABLE_DEPENDENCY); assert(isMergeTable(mt) || isReplicaTable(mt)); mt = new_table(tr, mt); + if (!mt->members.set) + cs_new(&mt->members, tr->sa, (fdestroy) &part_destroy); p->t = mt; p->member = pt->base.id; /* TODO parts should have a unique name - id ? */ @@ -4857,6 +4861,7 @@ sql_trans_create_table(sql_trans *tr, sq if (isPartitionedByExpressionTable(t)) { t->part.pexp = SA_ZNEW(tr->sa, sql_expression); t->part.pexp->type = *sql_bind_localtype("void"); /* leave it non-initialized, at the backend the copy of this table will get the type */ + t->part.pexp->cols = SA_LIST(tr->sa, (fdestroy) &int_destroy); } ca = t->commit_action; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list