Changeset: 6d96c73e2ba5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6d96c73e2ba5
Modified Files:
        sql/common/sql_changeset.c
        sql/common/sql_list.c
        sql/include/sql_catalog.h
        sql/include/sql_list.h
        sql/server/rel_propagate.c
        sql/server/sql_partition.c
        sql/storage/sql_catalog.c
        sql/storage/store.c
Branch: nospare
Log Message:

As the merge table pointer is part of sql_part struct, remove redundant 'tpe' 
component of sql_part


diffs (truncated from 435 to 300 lines):

diff --git a/sql/common/sql_changeset.c b/sql/common/sql_changeset.c
--- a/sql/common/sql_changeset.c
+++ b/sql/common/sql_changeset.c
@@ -42,18 +42,18 @@ cs_add(changeset * cs, void *elm, int fl
 }
 
 void *
-cs_transverse_with_validate(changeset * cs, void *elm, fvalidate cmp)
+cs_transverse_with_validate(changeset * cs, void *elm, void *extra, fvalidate 
cmp)
 {
-       return list_traverse_with_validate(cs->set, elm, cmp);
+       return list_transverse_with_validate(cs->set, elm, extra, cmp);
 }
 
-void*
-cs_add_with_validate(changeset * cs, void *elm, int flags, fvalidate cmp)
+void *
+cs_add_with_validate(changeset * cs, void *elm, void *extra, int flags, 
fvalidate cmp)
 {
        void* res = NULL;
        if (!cs->set)
                cs->set = list_new(cs->sa, cs->destroy);
-       if((res = list_append_with_validate(cs->set, elm, cmp)) != NULL)
+       if((res = list_append_with_validate(cs->set, elm, extra, cmp)) != NULL)
                return res;
        if (newFlagSet(flags) && !cs->nelm)
                cs->nelm = cs->set->t;
diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
+++ b/sql/common/sql_list.c
@@ -177,8 +177,8 @@ list_append(list *l, void *data)
        return list_append_node(l, n);
 }
 
-void*
-list_append_with_validate(list *l, void *data, fvalidate cmp)
+void *
+list_append_with_validate(list *l, void *data, void *extra, fvalidate cmp)
 {
        node *n = node_create(l->sa, data), *m;
        void* err = NULL;
@@ -187,7 +187,7 @@ list_append_with_validate(list *l, void 
                return NULL;
        if (l->cnt) {
                for (m = l->h; m; m = m->next) {
-                       err = cmp(m->data, data);
+                       err = cmp(m->data, data, extra);
                        if(err) {
                                n->data = NULL;
                                node_destroy(l, NULL, n);
@@ -213,7 +213,7 @@ list_append_with_validate(list *l, void 
        return NULL;
 }
 
-void*
+void *
 list_append_sorted(list *l, void *data, void *extra, fcmpvalidate cmp)
 {
        node *n = node_create(l->sa, data), *m, *prev = NULL;
@@ -454,12 +454,12 @@ list_traverse(list *l, traverse_func f, 
 }
 
 void *
-list_traverse_with_validate(list *l, void *data, fvalidate cmp)
+list_transverse_with_validate(list *l, void *data, void *extra, fvalidate cmp)
 {
        void* err = NULL;
 
        for (node *n = l->h; n; n = n->next) {
-               err = cmp(n->data, data);
+               err = cmp(n->data, data, extra);
                if(err)
                        break;
        }
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
@@ -258,11 +258,11 @@ extern void cs_new(changeset * cs, sql_a
 extern changeset* cs_dup(changeset * cs);
 extern void cs_destroy(changeset * cs, void *data);
 extern void cs_add(changeset * cs, void *elm, int flag);
-extern void *cs_add_with_validate(changeset * cs, void *elm, int flag, 
fvalidate cmp);
+extern void *cs_add_with_validate(changeset * cs, void *elm, void *extra, int 
flag, fvalidate cmp);
 extern void cs_add_before(changeset * cs, node *n, void *elm);
 extern void cs_del(changeset * cs, void *gdata, node *elm, int flag);
 extern void cs_move(changeset *from, changeset *to, void *data);
-extern void *cs_transverse_with_validate(changeset * cs, void *elm, fvalidate 
cmp);
+extern void *cs_transverse_with_validate(changeset * cs, void *elm, void 
*extra, fvalidate cmp);
 extern int cs_size(changeset * cs);
 extern node *cs_find_name(changeset * cs, const char *name);
 extern node *cs_find_id(changeset * cs, sqlid id);
@@ -657,7 +657,6 @@ typedef struct sql_part {
        sql_base base;
        struct sql_table *t;    /* the merge table */
        sqlid member;                   /* the member of the merge table */
-       sql_subtype tpe;                /* the column/expression type */
        bit with_nills;                 /* 0 no nills, 1 holds nills, NULL 
holds all values -> range FROM MINVALUE TO MAXVALUE WITH NULL */
        union {
                list *values;       /* partition by values/list */
@@ -775,9 +774,10 @@ extern sql_type *sql_trans_find_type(sql
 extern sql_func *sql_trans_find_func(sql_trans *tr, sqlid id);
 extern sql_trigger *sql_trans_find_trigger(sql_trans *tr, sqlid id);
 
+extern void find_partition_type(sql_subtype *tpe, sql_table *mt);
 extern void *sql_values_list_element_validate_and_insert(void *v1, void *v2, 
void *tpe, int* res);
-extern void *sql_range_part_validate_and_insert(void *v1, void *v2);
-extern void *sql_values_part_validate_and_insert(void *v1, void *v2);
+extern void *sql_range_part_validate_and_insert(void *v1, void *v2, void *tpe);
+extern void *sql_values_part_validate_and_insert(void *v1, void *v2, void 
*tpe);
 
 typedef struct {
        BAT *b;
diff --git a/sql/include/sql_list.h b/sql/include/sql_list.h
--- a/sql/include/sql_list.h
+++ b/sql/include/sql_list.h
@@ -66,15 +66,15 @@ extern int list_check_prop_all(list *l, 
  * */
 typedef int (*fcmp) (void *data, void *key);
 typedef void *(*fcmpvalidate) (void *v1, void *v2, void *extra, int *cmp);
-typedef void *(*fvalidate) (void *v1, void *v2);
+typedef void *(*fvalidate) (void *v1, void *v2, void *extra);
 typedef int (*fcmp2) (void *data, void *v1, void *v2);
 typedef void *(*fdup) (void *data);
 typedef void *(*freduce) (void *v1, void *v2);
 typedef void *(*freduce2) (sql_allocator *sa, void *v1, void *v2);
 typedef void *(*fmap) (void *data, void *clientdata);
 
-extern void *list_traverse_with_validate(list *l, void *data, fvalidate cmp);
-extern void *list_append_with_validate(list *l, void *data, fvalidate cmp);
+extern void *list_transverse_with_validate(list *l, void *data, void *extra, 
fvalidate cmp);
+extern void *list_append_with_validate(list *l, void *data, void *extra, 
fvalidate cmp);
 extern void *list_append_sorted(list *l, void *data, void *extra, fcmpvalidate 
cmp);
 extern node *list_find(list *l, void *key, fcmp cmp);
 extern int  list_position(list *l, void *val);
diff --git a/sql/server/rel_propagate.c b/sql/server/rel_propagate.c
--- a/sql/server/rel_propagate.c
+++ b/sql/server/rel_propagate.c
@@ -276,18 +276,21 @@ propagate_validation_to_upper_tables(sql
                        break;
                sql_part *spt = it;
                if (spt) {
+                       sql_subtype tp;
+                       find_partition_type(&tp, it->t);
+
                        if (isRangePartitionTable(it->t)) {
-                               int tpe = spt->tpe.type->localtype;
+                               int tpe = tp.type->localtype;
                                int (*atomcmp)(const void *, const void *) = 
ATOMcompare(tpe);
                                const void *nil = ATOMnilptr(tpe);
                                sql_exp *e1 = NULL, *e2 = NULL;
                                bool found_all = false, max_equal_min = false;
 
                                if (atomcmp(spt->part.range.minvalue, nil) != 0 
&& atomcmp(spt->part.range.maxvalue, nil) != 0) {
-                                       max_equal_min = 
ATOMcmp(spt->tpe.type->localtype, spt->part.range.maxvalue, 
spt->part.range.minvalue) == 0;
-                                       e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &spt->tpe, spt->part.range.minvalue));
+                                       max_equal_min = ATOMcmp(tpe, 
spt->part.range.maxvalue, spt->part.range.minvalue) == 0;
+                                       e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, spt->part.range.minvalue));
                                        if (!max_equal_min)
-                                               e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &spt->tpe, spt->part.range.maxvalue));
+                                               e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, spt->part.range.maxvalue));
                                } else {
                                        assert(spt->with_nills);
                                        found_all = is_bit_nil(spt->with_nills);
@@ -298,7 +301,7 @@ propagate_validation_to_upper_tables(sql
                                list *exps = new_exp_list(sql->sa);
                                for (node *n = spt->part.values->h ; n ; n = 
n->next) {
                                        sql_part_value *next = 
(sql_part_value*) n->data;
-                                       sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &spt->tpe, next->value));
+                                       sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, next->value));
                                        list_append(exps, e1);
                                }
                                rel = rel_list(sql->sa, rel, 
create_list_partition_anti_rel(query, it->t, pt, spt->with_nills, exps));
@@ -682,7 +685,9 @@ rel_generate_subinserts(sql_query *query
        list *anti_exps = new_exp_list(sql->sa);
        sql_subfunc *cf = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR);
        char buf[BUFSIZ];
+       sql_subtype tp;
 
+       find_partition_type(&tp, t);
        if (isPartitionedByColumnTable(t)) {
                anti_rel = rel_dup(rel->r);
        } else if (isPartitionedByExpressionTable(t)) {
@@ -715,17 +720,17 @@ rel_generate_subinserts(sql_query *query
 
                if (isRangePartitionTable(t)) {
                        sql_exp *range = NULL, *full_range = NULL;
-                       int tpe = pt->tpe.type->localtype;
+                       int tpe = tp.type->localtype;
                        int (*atomcmp)(const void *, const void *) = 
ATOMcompare(tpe);
                        const void *nil = ATOMnilptr(tpe);
 
                        if (atomcmp(pt->part.range.minvalue, nil) != 0 || 
atomcmp(pt->part.range.maxvalue, nil) != 0) {
                                sql_exp *e1, *e2;
-                               bool max_equal_min = 
ATOMcmp(pt->tpe.type->localtype, pt->part.range.maxvalue, 
pt->part.range.minvalue) == 0;
+                               bool max_equal_min = ATOMcmp(tpe, 
pt->part.range.maxvalue, pt->part.range.minvalue) == 0;
 
-                               e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, pt->part.range.minvalue));
+                               e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, pt->part.range.minvalue));
                                if (!max_equal_min) {
-                                       e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, pt->part.range.maxvalue));
+                                       e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, pt->part.range.maxvalue));
                                        range = exp_compare2(sql->sa, le, e1, 
e2, cmp_gte|CMP_BETWEEN);
                                } else {
                                        range = exp_compare(sql->sa, le, e1, 
cmp_equal);
@@ -770,7 +775,7 @@ rel_generate_subinserts(sql_query *query
                                list *exps = new_exp_list(sql->sa);
                                for (node *nn = pt->part.values->h ; nn ; nn = 
nn->next) {
                                        sql_part_value *next = 
(sql_part_value*) nn->data;
-                                       sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, next->value));
+                                       sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, next->value));
                                        list_append(exps, e1);
                                        list_append(anti_exps, exp_copy(sql, 
e1));
                                }
@@ -945,9 +950,11 @@ rel_subtable_insert(sql_query *query, sq
        sql_subfunc *cf = sql_bind_func(sql, "sys", "count", 
sql_bind_localtype("void"), NULL, F_AGGR);
        char buf[BUFSIZ];
        bool found_nils = false, found_all_range_values = false;
+       sql_subtype tp;
 
+       find_partition_type(&tp, upper->t);
        if (isRangePartitionTable(upper->t)) {
-               int tpe = pt->tpe.type->localtype;
+               int tpe = tp.type->localtype;
                int (*atomcmp)(const void *, const void *) = ATOMcompare(tpe);
                const void *nil = ATOMnilptr(tpe);
 
@@ -963,21 +970,21 @@ rel_subtable_insert(sql_query *query, sq
                                        anti_exp = exp_compare(sql->sa, 
anti_nils, exp_atom_bool(sql->sa, 0), cmp_equal);
                                }
                        } else {
-                               sql_exp *e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, pt->part.range.maxvalue));
+                               sql_exp *e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, pt->part.range.maxvalue));
                                anti_exp = exp_compare(sql->sa, exp_copy(sql, 
anti_le), e2, cmp_gte);
                        }
                } else {
                        if (atomcmp(pt->part.range.maxvalue, nil) == 0) {
-                               sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, pt->part.range.minvalue));
+                               sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, pt->part.range.minvalue));
                                anti_exp = exp_compare(sql->sa, exp_copy(sql, 
anti_le), e1, cmp_lt);
                        } else {
-                               sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, pt->part.range.minvalue));
-                               bool max_equal_min = 
ATOMcmp(pt->tpe.type->localtype, pt->part.range.maxvalue, 
pt->part.range.minvalue) == 0;
+                               sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, pt->part.range.minvalue));
+                               bool max_equal_min = ATOMcmp(tpe, 
pt->part.range.maxvalue, pt->part.range.minvalue) == 0;
 
                                if (max_equal_min) {
                                        anti_exp = exp_compare(sql->sa, 
exp_copy(sql, anti_le), e1, cmp_notequal);
                                } else {
-                                       sql_exp *e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, pt->part.range.maxvalue)),
+                                       sql_exp *e2 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, pt->part.range.maxvalue)),
                                                *range1 = exp_compare(sql->sa, 
exp_copy(sql, anti_le), e1, cmp_lt),
                                                *range2 = exp_compare(sql->sa, 
exp_copy(sql, anti_le), e2, cmp_gte);
 
@@ -1000,7 +1007,7 @@ rel_subtable_insert(sql_query *query, sq
                if (list_length(pt->part.values)) { /* if the partition holds 
non-null values */
                        for (node *n = pt->part.values->h ; n ; n = n->next) {
                                sql_part_value *next = (sql_part_value*) 
n->data;
-                               sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &pt->tpe, next->value));
+                               sql_exp *e1 = exp_atom(sql->sa, 
atom_general_ptr(sql->sa, &tp, next->value));
                                list_append(anti_exps, exp_copy(sql, e1));
                        }
                        anti_exp = exp_in(sql->sa, exp_copy(sql, anti_le), 
anti_exps, cmp_notin);
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
@@ -318,12 +318,9 @@ initialize_sql_parts(mvc *sql, sql_table
                for (node *n = mt->members.set->h; n; n = n->next) {
                        sql_part *p = n->data;
 
-                       p->tpe = found;
                        if (isListPartitionTable(mt)) {
                                for (node *m = p->part.values->h; m; m = 
m->next) {
-                                       sql_part_value *v = (sql_part_value*) 
m->data;
-                                   sql_part_value ov = *v;
-
+                                       sql_part_value *v = (sql_part_value*) 
m->data, ov = *v;
                                        ValRecord vvalue;
                                        ptr ok;
 
@@ -357,9 +354,8 @@ initialize_sql_parts(mvc *sql, sql_table
                                if (ok) {
                                        if (strNil((const char *)VALget(&vmin)) 
&&
                                                strNil((const char 
*)VALget(&vmax))) {
-                                               int tpe = found.type->localtype;
-                                               const void *nil_ptr = 
ATOMnilptr(tpe);
-                                               size_t nil_len = ATOMlen(tpe, 
nil_ptr);
+                                               const void *nil_ptr = 
ATOMnilptr(localtype);
+                                               size_t nil_len = 
ATOMlen(localtype, nil_ptr);
 
                                                p->part.range.minvalue = 
SA_NEW_ARRAY(tr->sa, char, nil_len);
                                                p->part.range.maxvalue = 
SA_NEW_ARRAY(tr->sa, char, nil_len);
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
@@ -364,17 +364,16 @@ sql_values_list_element_validate_and_ins
 }
 
 void*
-sql_range_part_validate_and_insert(void *v1, void *v2)
+sql_range_part_validate_and_insert(void *v1, void *v2, void *type)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to