Changeset: 209ee0af3379 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/209ee0af3379
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/include/sql_catalog.h
Branch: dict
Log Message:
merged with default
diffs (truncated from 6635 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
@@ -3058,7 +3058,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) {
@@ -3090,7 +3090,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:
@@ -3131,7 +3131,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;
}
@@ -3452,6 +3452,8 @@ stmt_func(backend *be, stmt *ops, const
if ((p = find_prop(rel->p, PROP_REMOTE)))
rel->p = prop_remove(rel->p, p);
+ /* sql_processrelation may split projections, so make sure the topmost
relation only contains references */
+ rel = rel_project(be->mvc->sa, rel, rel_projections(be->mvc, rel, NULL,
1, 1));
if (!(rel = sql_processrelation(be->mvc, rel, 1, 1)))
return NULL;
if (p) {
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, "]");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list