Changeset: 1975b7093121 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1975b7093121
Modified Files:
        sql/backends/monet5/rel_bin.c
        sql/include/sql_catalog.h
        sql/server/rel_dump.c
        sql/server/rel_exp.c
        sql/server/rel_optimizer.c
        sql/server/rel_schema.c
        sql/server/rel_select.c
        sql/server/sql_parser.y
        sql/storage/sql_catalog.c
        sql/storage/store.c
        sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
        sql/test/BugTracker-2015/Tests/crash_in_reduce_groupby.Bug-3818.test
        sql/test/BugTracker-2015/Tests/large_join.Bug-3809.test
        
sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.test
        
sql/test/BugTracker-2016/Tests/memory-consumption-query-PLAN-25joins.Bug-3972.test
        
sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.test
        
sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-1join-query.test
        
sql/test/FeatureRequests/Tests/foreign_key_outer_join_dead_code_elimination-plan-2join-query.test
        sql/test/SQLancer/Tests/sqlancer17.test
        sql/test/Tests/keys.test
        sql/test/analytics/Tests/analytics00.test
        sql/test/astro/Tests/astro.test
        sql/test/miscellaneous/Tests/All
        sql/test/miscellaneous/Tests/simple_plans.test
        sql/test/miscellaneous/Tests/simple_selects.test
        sql/test/miscellaneous/Tests/unique_keys.test
        tools/monetdbe/monetdbe.c
Branch: antipush
Log Message:

Merged with default and approved


diffs (truncated from 6412 to 300 lines):

diff --git a/ctest/tools/monetdbe/example1.c b/ctest/tools/monetdbe/example1.c
--- a/ctest/tools/monetdbe/example1.c
+++ b/ctest/tools/monetdbe/example1.c
@@ -36,7 +36,7 @@ main(void)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol;
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example2.c b/ctest/tools/monetdbe/example2.c
--- a/ctest/tools/monetdbe/example2.c
+++ b/ctest/tools/monetdbe/example2.c
@@ -43,7 +43,7 @@ main(void)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_bool: {
                                        monetdbe_column_bool * col = 
(monetdbe_column_bool *) rcol;
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example_append.c 
b/ctest/tools/monetdbe/example_append.c
--- a/ctest/tools/monetdbe/example_append.c
+++ b/ctest/tools/monetdbe/example_append.c
@@ -44,7 +44,7 @@ main(void)
                for (size_t c = 0; c < result->ncols; c++) {
                        if ((err = monetdbe_result_fetch(result, rcol+c, c)) != 
NULL)
                                error(err)
-                       switch (rcol[c]->type.type) {
+                       switch (rcol[c]->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol[c];
                                        if (col->data[r] == col->null_value) {
@@ -129,7 +129,7 @@ main(void)
                for (size_t c = 0; c < result->ncols; c++) {
                        if ((err = monetdbe_result_fetch(result, rcol+c, c)) != 
NULL)
                                error(err)
-                       switch (rcol[c]->type.type) {
+                       switch (rcol[c]->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol[c];
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example_append_raw.c 
b/ctest/tools/monetdbe/example_append_raw.c
--- a/ctest/tools/monetdbe/example_append_raw.c
+++ b/ctest/tools/monetdbe/example_append_raw.c
@@ -38,11 +38,11 @@ main(void)
        int32_t i1 = 42;
        int32_t i2 = *(int32_t*)monetdbe_null(mdbe, monetdbe_int32_t);
        int32_t ints[2] = { i1, i2 };
-       monetdbe_column col0 = { .type.type = monetdbe_int32_t, .data = &ints, 
.count = 2 };
+       monetdbe_column col0 = { .type = monetdbe_int32_t, .data = &ints, 
.count = 2 };
 
        // str
        char* dstr[2] = { "Hello", "World" };
-       monetdbe_column col1 = { .type.type = monetdbe_str, .data = &dstr, 
.count = 2 };
+       monetdbe_column col1 = { .type = monetdbe_str, .data = &dstr, .count = 
2 };
 
        // timestamp
        monetdbe_data_date dt = { .day = 2, .month = 3, .year = 2020 };
@@ -50,25 +50,25 @@ main(void)
        monetdbe_data_timestamp t1 = { .date = dt, .time = tm };
        monetdbe_data_timestamp t2 = 
*(monetdbe_data_timestamp*)monetdbe_null(mdbe, monetdbe_timestamp);
        monetdbe_data_timestamp tss[2] = { t1, t2 };
-       monetdbe_column col2 = { .type.type = monetdbe_timestamp, .data = &tss, 
.count = 2 };
+       monetdbe_column col2 = { .type = monetdbe_timestamp, .data = &tss, 
.count = 2 };
 
        // date
        monetdbe_data_date d1 = dt;
        monetdbe_data_date d2 = *(monetdbe_data_date*)monetdbe_null(mdbe, 
monetdbe_date);
        monetdbe_data_date dts[2] = { d1, d2 };
-       monetdbe_column col3 = { .type.type = monetdbe_date, .data = &dts, 
.count = 2 };
+       monetdbe_column col3 = { .type = monetdbe_date, .data = &dts, .count = 
2 };
 
        // time
        monetdbe_data_time tm1 = tm;
        monetdbe_data_time tm2 = *(monetdbe_data_time*)monetdbe_null(mdbe, 
monetdbe_time);
        monetdbe_data_time tms[2] = { tm1, tm2 };
-       monetdbe_column col4 = { .type.type = monetdbe_time, .data = &tms, 
.count = 2 };
+       monetdbe_column col4 = { .type = monetdbe_time, .data = &tms, .count = 
2 };
 
        // blob
        monetdbe_data_blob b1 = { .size = 1, .data = "33" };
        monetdbe_data_blob b2 = *(monetdbe_data_blob*)monetdbe_null(mdbe, 
monetdbe_blob);
        monetdbe_data_blob bs[2] = { b1, b2 };
-       monetdbe_column col5 = { .type.type = monetdbe_blob, .data = &bs, 
.count = 2 };
+       monetdbe_column col5 = { .type = monetdbe_blob, .data = &bs, .count = 2 
};
 
        monetdbe_column* dcol[6] = { &col0, &col1, &col2, &col3, &col4, &col5 };
        if ((err = monetdbe_append(mdbe, "sys", "test", (monetdbe_column**) 
&dcol, 6)) != NULL)
@@ -76,7 +76,7 @@ main(void)
 
        // str with wrong utf8
        char* dstr2[2] = { "\xc3\x28", "\xe2\x28\xa1" };
-       monetdbe_column col12 = { .type.type = monetdbe_str, .data = &dstr2, 
.count = 2 };
+       monetdbe_column col12 = { .type = monetdbe_str, .data = &dstr2, .count 
= 2 };
        monetdbe_column* dcol2[6] = { &col0, &col12, &col2, &col3, &col4, &col5 
};
        if ((err = monetdbe_append(mdbe, "sys", "test", (monetdbe_column**) 
&dcol2, 6)) == NULL)
                error("Invalid UTF-8 string expected")
@@ -89,7 +89,7 @@ main(void)
                for (size_t c = 0; c < result->ncols; c++) {
                        if ((err = monetdbe_result_fetch(result, rcol+c, c)) != 
NULL)
                                error(err)
-                       switch (rcol[c]->type.type) {
+                       switch (rcol[c]->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol[c];
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example_blob.c 
b/ctest/tools/monetdbe/example_blob.c
--- a/ctest/tools/monetdbe/example_blob.c
+++ b/ctest/tools/monetdbe/example_blob.c
@@ -38,7 +38,7 @@ main(void)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_blob: {
                                        monetdbe_column_blob * col = 
(monetdbe_column_blob *) rcol;
                                        if (!col->data[r].data) {
diff --git a/ctest/tools/monetdbe/example_connections.c 
b/ctest/tools/monetdbe/example_connections.c
--- a/ctest/tools/monetdbe/example_connections.c
+++ b/ctest/tools/monetdbe/example_connections.c
@@ -38,7 +38,7 @@ main(void)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol;
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example_decimals.c 
b/ctest/tools/monetdbe/example_decimals.c
--- a/ctest/tools/monetdbe/example_decimals.c
+++ b/ctest/tools/monetdbe/example_decimals.c
@@ -36,7 +36,7 @@ main(void)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_bool: {
                                        monetdbe_column_bool * col = 
(monetdbe_column_bool *) rcol;
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example_proxy.c 
b/ctest/tools/monetdbe/example_proxy.c
--- a/ctest/tools/monetdbe/example_proxy.c
+++ b/ctest/tools/monetdbe/example_proxy.c
@@ -38,7 +38,7 @@ main(int argc, char** argv)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol;
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/example_temporal.c 
b/ctest/tools/monetdbe/example_temporal.c
--- a/ctest/tools/monetdbe/example_temporal.c
+++ b/ctest/tools/monetdbe/example_temporal.c
@@ -39,7 +39,7 @@ main(void)
                        monetdbe_column* rcol;
                        if ((err = monetdbe_result_fetch(result, &rcol, c)) != 
NULL)
                                error(err)
-                       switch (rcol->type.type) {
+                       switch (rcol->type) {
                                case monetdbe_int32_t: {
                                        monetdbe_column_int32_t * col = 
(monetdbe_column_int32_t *) rcol;
                                        if (col->data[r] == col->null_value) {
diff --git a/ctest/tools/monetdbe/test_helper_template.h 
b/ctest/tools/monetdbe/test_helper_template.h
--- a/ctest/tools/monetdbe/test_helper_template.h
+++ b/ctest/tools/monetdbe/test_helper_template.h
@@ -29,7 +29,7 @@ bool CHECK_COLUMN_FUNC (
 
     const monetdbe_types expected_type = TPE_ENUM;
 
-    if (rcol->type.type != expected_type) {
+    if (rcol->type != expected_type) {
         printf("Actual column and expected column differ in type.\n");
         return false;
     }
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
@@ -1209,8 +1209,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                break;
        case e_atom: {
                if (e->l) {                     /* literals */
-                       atom *a = e->l;
-                       s = stmt_atom(be, atom_dup(sql->sa, a));
+                       s = stmt_atom(be, e->l);
                } else if (e->r) {              /* parameters and declared 
variables */
                        sql_var_name *vname = (sql_var_name*) e->r;
                        assert(vname->name);
diff --git a/sql/backends/monet5/rel_predicates.c 
b/sql/backends/monet5/rel_predicates.c
--- a/sql/backends/monet5/rel_predicates.c
+++ b/sql/backends/monet5/rel_predicates.c
@@ -59,7 +59,7 @@ rel_find_predicates(visitor *v, sql_rel 
                                } else if (isNew(c)) {
                                        continue;
                                } else {
-                                       atom *e1 = r && r->l ? atom_dup(NULL, 
r->l) : NULL, *e2 = r2 && r2->l ? atom_dup(NULL, r2->l) : NULL;
+                                       atom *e1 = r && r->l ? atom_copy(NULL, 
r->l) : NULL, *e2 = r2 && r2->l ? atom_copy(NULL, r2->l) : NULL;
 
                                        if ((r && r->l && !e1) || (r2 && r2->l 
&& !e2)) {
                                                if (e1) {
diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -3016,7 +3016,7 @@ stmt_exception(backend *be, stmt *cond, 
 /* The type setting is not propagated to statements such as st_bat and 
st_append,
        because they are not considered projections */
 static void
-tail_set_type(stmt *st, sql_subtype *t)
+tail_set_type(mvc *m, stmt *st, sql_subtype *t)
 {
        for (;;) {
                switch (st->type) {
@@ -3048,7 +3048,7 @@ tail_set_type(stmt *st, sql_subtype *t)
                        return;
                }
                case st_atom:
-                       atom_set_type(st->op4.aval, t);
+                       st->op4.aval = atom_set_type(m->sa, st->op4.aval, t);
                        return;
                case st_convert:
                case st_temp:
@@ -3089,7 +3089,7 @@ stmt_convert(backend *be, stmt *v, stmt 
                /* trivial string cases */
                (EC_VARCHAR(f->type->eclass) && EC_VARCHAR(t->type->eclass) && 
(t->digits == 0 || (f->digits > 0 && t->digits >= f->digits))))) {
                /* set output type. Despite the MAL code already being 
generated, the output type may still be checked */
-               tail_set_type(v, t);
+               tail_set_type(be->mvc, v, t);
                return v;
        }
 
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
@@ -862,7 +862,7 @@ typedef struct atom {
 
 /* duplicate atom */
 extern ValPtr SA_VALcopy(sql_allocator *sa, ValPtr d, const ValRecord *s);
-extern atom *atom_dup(sql_allocator *sa, atom *a);
+extern atom *atom_copy(sql_allocator *sa, atom *a);
 
 typedef struct pl {
        sql_column *c;
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -95,6 +95,20 @@ dump_escape_ident(sql_allocator *sa, con
        return res;
 }
 
+static char *
+dump_sql_subtype(sql_allocator *sa, sql_subtype *t)
+{
+       char buf[BUFSIZ];
+
+       if (t->digits && t->scale)
+               snprintf(buf, BUFSIZ, "%s(%u,%u)", t->type->base.name, 
t->digits, t->scale);
+       else if (t->digits)
+               snprintf(buf, BUFSIZ, "%s(%u)", t->type->base.name, t->digits);
+       else
+               snprintf(buf, BUFSIZ, "%s", t->type->base.name);
+       return sa_strdup(sa, buf);
+}
+
 static void exps_print(mvc *sql, stream *fout, list *exps, int depth, list 
*refs, int alias, int brackets);
 
 static void
@@ -118,7 +132,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
                } else if (e->flag & PSM_VAR) {
                        // todo output table def (from e->f)
                        const char *rname = exp_relname(e);
-                       char *type_str = e->f ? NULL : 
sql_subtype_string(sql->ta, exp_subtype(e));
+                       char *type_str = e->f ? NULL : 
dump_sql_subtype(sql->ta, exp_subtype(e));
                        int level = GET_PSM_LEVEL(e->flag);
                        mnstr_printf(fout, "declare ");
                        if (rname)
@@ -154,7 +168,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
                break;
        }
        case e_convert: {
-               char *to_type = sql_subtype_string(sql->ta, exp_subtype(e));
+               char *to_type = dump_sql_subtype(sql->ta, exp_subtype(e));
                mnstr_printf(fout, "%s[", to_type);
                exp_print(sql, fout, e->l, depth, refs, 0, 0);
                mnstr_printf(fout, "]");
@@ -170,7 +184,7 @@ exp_print(mvc *sql, stream *fout, sql_ex
                                        isReplicaTable(t)?"replica 
table":"table",
                                        dump_escape_ident(sql->ta, 
t->base.name));
                        } else {
-                               char *t = sql_subtype_string(sql->ta, 
atom_type(a));
+                               char *t = dump_sql_subtype(sql->ta, 
atom_type(a));
                                if (a->isnull)
                                        mnstr_printf(fout, "%s \"NULL\"", t);
                                else {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to