Changeset: 13b2d1aa5eff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/13b2d1aa5eff
Modified Files:
gdk/gdk_batop.c
sql/server/rel_select.c
sql/server/rel_unnest.c
Branch: default
Log Message:
Merge with Dec2025 branch.
diffs (truncated from 741 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1141,7 +1141,7 @@ dump_column_definition(Mapi mid, stream
mnstr_printf(sqlf, " (");
cnt = 1;
}
- } else
+ } else if (strcmp(k_type, "4") != 0)
mnstr_printf(sqlf, ", ");
if (cnt)
dquoted_print(sqlf, c_column, NULL);
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2874,6 +2874,8 @@ BATsort(BAT **sorted, BAT **order, BAT *
}
goto error;
}
+ if (reverse)
+ bn->tseqbase = oid_nil;
bn->tsorted = !reverse && !nilslast;
bn->trevsorted = reverse && nilslast;
if (m != NULL) {
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2423,7 +2423,7 @@ BBPdump(void)
MT_rwlock_rdunlock(&b->thashlock);
}
printf(" role: %s\n",
- b->batRole == PERSISTENT ? "persistent" : "transient");
+ b->batRole == PERSISTENT ? "persistent" : b->batRole ==
SYSTRANS ? "systrans" : "transient");
}
printf("# %d bats: mem=%zu, vm=%zu\n", n, mem, vm);
fflush(stdout);
diff --git a/monetdb5/extras/rapi/Tests/All b/monetdb5/extras/rapi/Tests/All
--- a/monetdb5/extras/rapi/Tests/All
+++ b/monetdb5/extras/rapi/Tests/All
@@ -1,9 +1,9 @@
-HAVE_LIBR&NOT_WIN32?rapi00
-HAVE_LIBR&NOT_WIN32?rapi01
-HAVE_LIBR&HAVE_HGE&NOT_WIN32?rapi02
-HAVE_LIBR&NOT_WIN32?rapi03
-HAVE_LIBR&NOT_WIN32?rapi04
-HAVE_LIBR&NOT_WIN32?rapi05
-HAVE_LIBR&NOT_WIN32?rapi07
-HAVE_LIBR&NOT_WIN32?rapi08
-HAVE_LIBR&NOT_WIN32?rapi10
+HAVE_LIBR?rapi00
+HAVE_LIBR?rapi01
+HAVE_LIBR&HAVE_HGE?rapi02
+HAVE_LIBR?rapi03
+HAVE_LIBR?rapi04
+HAVE_LIBR?rapi05
+HAVE_LIBR?rapi07
+HAVE_LIBR?rapi08
+HAVE_LIBR?rapi10
diff --git a/sql/backends/monet5/Tests/All b/sql/backends/monet5/Tests/All
--- a/sql/backends/monet5/Tests/All
+++ b/sql/backends/monet5/Tests/All
@@ -1,25 +1,24 @@
optimizers
-HAVE_LIBR&NOT_WIN32?rapi00
-HAVE_LIBR&NOT_WIN32?rapi01
-HAVE_LIBR&NOT_WIN32?rapi02
-HAVE_LIBR&NOT_WIN32?rapi03
-HAVE_LIBR&NOT_WIN32?rapi05
-HAVE_LIBR&NOT_WIN32?rapi06
-HAVE_LIBR&NOT_WIN32?rapi07
-#HAVE_LIBR&NOT_WIN32?rapi08
-HAVE_LIBR&NOT_WIN32?rapi09
-HAVE_LIBR&NOT_WIN32&!R_VERSION>=4.2.0?rapi09a
-HAVE_LIBR&NOT_WIN32?rapi10
-HAVE_LIBR&NOT_WIN32?rapi12
-HAVE_LIBR&NOT_WIN32?rapi13
-HAVE_LIBR&NOT_WIN32?rapi14
-HAVE_LIBR&NOT_WIN32?rapi15
-HAVE_LIBR&NOT_WIN32?rapi16
-HAVE_LIBR&NOT_WIN32?rapi17
-HAVE_LIBR&NOT_WIN32?rapi18
-HAVE_LIBR&NOT_WIN32?rapi19
-HAVE_LIBR&NOT_WIN32?rapi20
+HAVE_LIBR?rapi00
+HAVE_LIBR?rapi01
+HAVE_LIBR?rapi02
+HAVE_LIBR?rapi03
+HAVE_LIBR?rapi05
+HAVE_LIBR?rapi06
+HAVE_LIBR?rapi07
+HAVE_LIBR?rapi09
+HAVE_LIBR&!R_VERSION>=4.2.0?rapi09a
+HAVE_LIBR?rapi10
+HAVE_LIBR?rapi12
+HAVE_LIBR?rapi13
+HAVE_LIBR?rapi14
+HAVE_LIBR?rapi15
+HAVE_LIBR?rapi16
+HAVE_LIBR?rapi17
+HAVE_LIBR?rapi18
+HAVE_LIBR?rapi19
+HAVE_LIBR?rapi20
# should this work?
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
@@ -932,9 +932,10 @@ exp2bin_named_placeholders(backend *be,
if (list_empty(args))
return NULL;
- for (node *n = args->h; n; n = n->next, argc++) {
+ for (node *n = args->h, *m = be->mvc->params->h; n && m; n = n->next, m
= m->next, argc++) {
sql_exp *a = n->data;
- sql_subtype *t = exp_subtype(a);
+ sql_arg *p = m->data;
+ sql_subtype *t = &p->type;
stmt *s = exp_bin(be, a, NULL, NULL, NULL, NULL, NULL, NULL, 1,
0, 1);
InstrPtr q = newAssignment(be->mb);
diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -138,7 +138,7 @@ e_cmp
cmp_filter = 6, filters ->l/r
are both lists
- cmp_in = 8, in list handling
->r is a list of values
+ cmp_in = 8, in list handling ->r is
a list of values
cmp_notin = 9, not in list handling ->r is
a list of values
cmp_conjunctive = 10, and handling
-> l is a list
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -4197,9 +4197,10 @@ rel_cast(sql_query *query, sql_rel **rel
if (tpe->type->eclass == EC_DEC) {
sql_subtype *et = exp_subtype(e);
if (e->type == e_atom && !tpe->digits) {
- if (et->type->eclass == EC_NUM || et->type->eclass ==
EC_DEC) {
- tpe->digits = atom_num_digits(e->l);
- tpe = sql_bind_subtype(sql->sa, "decimal",
tpe->digits, et->scale);
+ if (e->l && (et->type->eclass == EC_NUM ||
et->type->eclass == EC_DEC)) {
+ tpe->digits = atom_num_digits(e->l) + 1;
+ tpe->scale = 1;
+ tpe = sql_bind_subtype(sql->sa, "decimal",
tpe->digits, tpe->scale);
} else if (EC_VARCHAR(et->type->eclass)) {
char *s = E_ATOM_STRING(e);
unsigned int min_precision = 0, min_scale = 0;
@@ -4243,8 +4244,10 @@ rel_next_value_for( mvc *sql, symbol *se
sql_subtype t;
sql_subfunc *f;
- if (!sname)
- sname = "sys";
+ if (!sname) {
+ sql_schema *s = cur_schema(sql);
+ sname = s->base.name;
+ }
if (!stack_find_rel_view(sql, seqname)) {
if (!(seq = find_sequence_on_scope(sql, sname, seqname, "NEXT
VALUE FOR")))
return NULL;
@@ -4661,7 +4664,8 @@ rel_order_by(sql_query *query, sql_rel *
assert(is_project(rel->op));
for(node *n = rel->exps->h; n; n = n->next) {
sql_exp *e = n->data;
- append(exps, exp_ref(sql, e));
+ append(exps, e=exp_ref(sql, e));
+ set_ascending(e);
}
return exps;
}
@@ -5996,9 +6000,12 @@ rel_select_exp(sql_query *query, sql_rel
*/
pexps = list_merge(pexps, exps_copy(sql, te), (fdup)NULL);
}
+ int card = inner->card;
if (rel && is_groupby(rel->op) && rel->flag) {
list *gbe = rel->r;
if (!list_empty(gbe)) {
+ inner->card = CARD_AGGR;
+ card = CARD_MULTI;
for (node *n=gbe->h; n; n = n->next) {
sql_exp *e = n->data;
if (rel->flag == 1 && is_atom(e->type) &&
!e->alias.name) {
@@ -6023,6 +6030,7 @@ rel_select_exp(sql_query *query, sql_rel
set_processed(rel);
}
rel = rel_project(sql->sa, rel, pexps);
+ rel->card = card;
rel = rel_having_limits_nodes(query, rel, sn, ek, group_totals);
return rel;
diff --git a/sql/server/rel_unnest.c b/sql/server/rel_unnest.c
--- a/sql/server/rel_unnest.c
+++ b/sql/server/rel_unnest.c
@@ -2385,6 +2385,32 @@ rewrite_empty_project(visitor *v, sql_re
#define is_division(sf) (strcmp(sf->func->base.name, "sql_div") == 0)
#define is_multiplication(sf) (strcmp(sf->func->base.name, "sql_mul") == 0)
+static sql_exp *
+exp_atom_set_type_null(visitor *v, sql_exp *el, sql_subtype *t)
+{
+ if (el->type == e_atom && !el->f && !el->r) {
+ sql_subtype *f = exp_subtype(el);
+ if ((!f || f->type->eclass == EC_ANY) && !el->l) { /*
parameter, set type, or return ERR?? */
+ sql_arg *a = sql_bind_paramnr(v->sql, el->flag);
+ if (!a->type.type || a->type.type->eclass == EC_ANY) {
+ a->type = *t;
+ el->tpe = a->type;
+ v->changes++;
+ return el;
+ }
+ } else if ((!f || f->type->eclass == EC_ANY) && el->l) { /*
NULL? */
+ atom *a = el->l;
+ if (atom_null(a)) {
+ atom_cast_inplace(v->sql->sa, a, t);
+ el->tpe = *t;
+ v->changes++;
+ return el;
+ }
+ }
+ }
+ return NULL;
+}
+
static inline sql_exp *
exp_physical_types(visitor *v, sql_rel *rel, sql_exp *e, int depth)
{
@@ -2571,7 +2597,54 @@ exp_reset_card_and_freevar_set_physical_
}
static sql_exp *
-exp_set_type(mvc *sql, sql_exp *te, sql_exp *e)
+exp_set_type(visitor *v, sql_rel *rel, sql_exp *e, int depth)
+{
+ (void)rel;
+ (void)depth;
+ if (!e)
+ return e;
+
+ if (e->type == e_atom && !e->f && !e->l && !e->r) {
+ sql_subtype *t = exp_subtype(e);
+ if ((!t || t->type->eclass == EC_ANY)) { /* parameter, set
type, or return ERR?? */
+ sql_arg *a = sql_bind_paramnr(v->sql, e->flag);
+ if (!a->type.type)
+ return sql_error(v->sql, 10, SQLSTATE(42000)
"Could not determine type for argument number %d", e->flag+1);
+ e->tpe = a->type;
+ }
+ } else if (e->type == e_cmp && !e->f) {
+ if (e->flag == cmp_in || e->flag == cmp_notin) {
+ sql_subtype *lt = exp_subtype(e->l);
+ e->r = exps_check_type(v->sql, lt, e->r);
+ } else if (e->flag == cmp_equal || e->flag == cmp_notequal) {
+ sql_subtype *lt = exp_subtype(e->l);
+ sql_subtype *rt = exp_subtype(e->r);
+ if (!lt || lt->type->eclass == EC_ANY) {
+ sql_exp *ne = exp_atom_set_type_null(v, e->l,
rt);
+ if (ne)
+ e->l = ne;
+ } else if (!rt || rt->type->eclass == EC_ANY) {
+ sql_exp *ne = exp_atom_set_type_null(v, e->r,
lt);
+ if (ne)
+ e->r = ne;
+ }
+ }
+ } else if (e->type == e_convert && !e->f) {
+ sql_exp *el = e->l;
+ sql_subtype *t = exp_totype(e);
+ if (el->type == e_atom && !el->f && !el->l && !el->r) {
+ el = exp_atom_set_type_null(v, el, t);
+ if (el) {
+ exp_prop_alias(v->sql->sa, el, e);
+ return el;
+ }
+ }
+ }
+ return e;
+}
+
+static sql_exp *
+exp_set_type_as(mvc *sql, sql_exp *te, sql_exp *e)
{
if (te->type == e_convert) {
if (e->type == e_column) {
@@ -2603,7 +2676,7 @@ rel_set_type(visitor *v, sql_rel *rel)
sql_subtype *t = exp_subtype(e);
if (t && !t->type->localtype) {
- n->data = exp_set_type(v->sql,
m->data, e);
+ n->data =
exp_set_type_as(v->sql, m->data, e);
clear_hash = true;
}
}
@@ -2625,7 +2698,7 @@ rel_set_type(visitor *v, sql_rel *rel)
sql_subtype *t = exp_subtype(e);
if (t && !t->type->localtype) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]