Changeset: cc913ce56435 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/cc913ce56435
Branch: default
Log Message:
merge Dec2025
diffs (truncated from 315 to 300 lines):
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -83,19 +83,21 @@ int TYPE_json;
static JSON *JSONparse(allocator *ma, const char *j);
static JSON *
-JSONnewtree(allocator *ma)
+JSONnewtree(allocator *ma, int initsize)
{
JSON *js;
js = ma_zalloc(ma, sizeof(JSON));
if (js == NULL)
return NULL;
+ if (initsize < 8)
+ initsize = 8;
js->ma = ma;
- js->elm = ma_zalloc(ma, sizeof(JSONterm) * 8);
+ js->elm = ma_zalloc(ma, sizeof(JSONterm) * initsize);
if (js->elm == NULL) {
return NULL;
}
- js->size = 8;
+ js->size = initsize;
return js;
}
@@ -1483,7 +1485,7 @@ JSONtoken(JSON *jt, const char *j, const
static JSON *
JSONparse(allocator *ma, const char *j)
{
- JSON *jt = JSONnewtree(ma);
+ JSON *jt = JSONnewtree(ma, (int) (strlen(j) / 10));
if (jt == NULL)
return NULL;
diff --git a/sql/backends/monet5/vaults/odbc/odbc_loader.c
b/sql/backends/monet5/vaults/odbc/odbc_loader.c
--- a/sql/backends/monet5/vaults/odbc/odbc_loader.c
+++ b/sql/backends/monet5/vaults/odbc/odbc_loader.c
@@ -1540,6 +1540,9 @@ odbc_load(void *BE, sql_subfunc *f, char
(void)topn;
InstrPtr q = newStmtArgs(be->mb, "odbc", "loader",
list_length(f->coltypes) + 2);
+ if (q == NULL)
+ return NULL;
+
int col = 0;
list *l = sa_list(be->mvc->sa);
for (node *n = f->coltypes->h, *nn = f->colnames->h; n && nn; col++, n
= n->next, nn = nn->next) {
diff --git a/sql/server/rel_basetable.c b/sql/server/rel_basetable.c
--- a/sql/server/rel_basetable.c
+++ b/sql/server/rel_basetable.c
@@ -533,6 +533,21 @@ rewrite_basetable(mvc *sql, sql_rel *rel
e->alias.label = e->nid;
append(rel->exps, e);
}
+ if (t->pkey) {
+ p = prop_create(sql->sa, PROP_UKEY, rel->p);
+ list *exps = p->value.pval = sa_list(sql->sa);
+ for(node *n = t->pkey->k.columns->h; n; n = n->next) {
+ sql_kc *c = n->data;
+ sql_exp *e = exps_bind_column2(rel->exps,
atname, c->c->base.name, NULL);
+ if (!e) {
+ p = NULL;
+ break;
+ }
+ append(exps, e);
+ }
+ if (p)
+ rel->p = p;
+ }
}
return rel;
}
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
@@ -744,7 +744,7 @@ rel_print_rel(mvc *sql, stream *fout, s
}
if (sql->show_details && decorate && rel->p) {
for (prop *p = rel->p; p; p = p->p) {
- if (p->kind != PROP_COUNT || (ATOMIC_GET(&GDKdebug) &
TESTINGMASK) == 0) {
+ if ((p->kind != PROP_COUNT && p->kind != PROP_UKEY) ||
(ATOMIC_GET(&GDKdebug) & TESTINGMASK) == 0) {
char *pv = propvalue2string(sql->ta, p);
mnstr_printf(fout, " %s %s",
propkind2string(p), pv);
}
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -4026,6 +4026,50 @@ free_exps(allocator *sa, list *exps)
static void
+sql_exp_reset(sql_exp *e)
+{
+ if (!e)
+ return;
+
+ e->l = e->r = e->f = e->p = NULL;
+ e->comment = NULL;
+
+ // Reset basic fields
+ e->type = -1;
+ e->alias.label = 0;
+ e->alias.name = NULL;
+ e->alias.rname = NULL;
+ e->flag = 0;
+ e->tmp = 0;
+ e->nid = 0;
+
+ // Reset bitfields
+ e->card = 0;
+ e->freevar = 0;
+ e->intern = 0;
+ e->selfref = 0;
+ e->anti = 0;
+ e->partitioning = 0;
+ e->ascending = 0;
+ e->nulls_last = 0;
+ e->zero_if_empty = 0;
+ e->distinct = 0;
+ e->semantics = 0;
+ e->any = 0;
+ e->need_no_nil = 0;
+ e->has_no_nil = 0;
+ e->unique = 0;
+ e->base = 0;
+ e->ref = 0;
+ e->used = 0;
+ e->symmetric = 0;
+
+ // Reset subtype
+ memset(&e->tpe, 0, sizeof(e->tpe));
+}
+
+
+static void
_free_exp_internal(allocator *sa, sql_exp *e)
{
if (!e)
@@ -4034,7 +4078,7 @@ static void
// free_props(sa, e->p);
e->p = NULL;
}
- e->type = -1;
+ sql_exp_reset(e);
ma_free(sa, e);
}
@@ -4054,48 +4098,76 @@ free_exp(allocator *sa, sql_exp *e)
case e_cmp:
if (e->flag < cmp_filter) {
// l and r are exp
- if (e->l)
+ if (e->l) {
free_exp(sa, e->l);
- if (e->r)
+ e->l = NULL;
+ }
+ if (e->r) {
free_exp(sa, e->r);
- if (e->f)
+ e->r = NULL;
+ }
+ if (e->f) {
free_exp(sa, e->f);
+ e->f = NULL;
+ }
}
if (e->flag == cmp_filter) {
// l and r are list
- if (e->l)
+ if (e->l) {
free_exps(sa, e->l);
- if (e->r)
+ e->l = NULL;
+ }
+ if (e->r) {
free_exps(sa, e->r);
+ e->r = NULL;
+ }
}
break;
case e_func:
case e_aggr:
- if (e->l)
+ if (e->l) {
free_exps(sa, e->l);
+ e->l = NULL;
+ }
break;
case e_convert:
- if (e->l)
+ if (e->l) {
free_exp(sa, e->l);
+ e->l = NULL;
+ }
break;
case e_psm:
- if ((e->flag & PSM_SET) && e->l)
+ if ((e->flag & PSM_SET) && e->l) {
free_exp(sa, e->l);
- if ((e->flag & PSM_RETURN) && e->l)
+ e->l = NULL;
+ }
+ if ((e->flag & PSM_RETURN) && e->l) {
free_exp(sa, e->l);
+ e->l = NULL;
+ }
if (e->flag & PSM_WHILE) {
- if (e->l)
+ if (e->l) {
free_exp(sa, e->l);
- if (e->r)
+ e->l = NULL;
+ }
+ if (e->r) {
free_exps(sa, e->r);
+ e->r = NULL;
+ }
}
if (e->flag & PSM_IF) {
- if (e->l)
+ if (e->l) {
free_exp(sa, e->l);
- if (e->r)
+ e->l = NULL;
+ }
+ if (e->r) {
free_exps(sa, e->r);
- if (e->f)
+ e->r = NULL;
+ }
+ if (e->f) {
free_exps(sa, e->f);
+ e->f = NULL;
+ }
}
break;
case e_column:
diff --git a/sql/server/rel_prop.c b/sql/server/rel_prop.c
--- a/sql/server/rel_prop.c
+++ b/sql/server/rel_prop.c
@@ -12,6 +12,7 @@
#include "monetdb_config.h"
#include "sql_catalog.h"
+#include "sql_relation.h"
#include "rel_prop.h"
#include "sql_string.h"
@@ -108,6 +109,7 @@ propkind2string( prop *p)
#define PT(TYPE) case PROP_##TYPE : return #TYPE
PT(COUNT);
PT(NUNIQUES);
+ PT(UKEY);
PT(JOINIDX);
PT(HASHIDX);
PT(HASHCOL);
@@ -134,6 +136,18 @@ propvalue2string(allocator *sa, prop *p)
snprintf(buf, sizeof(buf), "%f", p->value.dval);
return ma_strdup(sa, buf);
}
+ case PROP_UKEY: {
+ list *exps = p->value.pval;
+ size_t offset = 0;
+
+ offset += snprintf(buf + offset, BUFSIZ, "[ ");
+ for(node *n = exps->h; n; n = n->next) {
+ sql_exp *e = n->data;
+ offset += snprintf(buf + offset, BUFSIZ, "%s.%s ",
e->alias.rname, e->alias.name);
+ }
+ offset += snprintf(buf + offset, BUFSIZ, "]");
+ return ma_strdup(sa, buf);
+ } break;
case PROP_JOINIDX: {
sql_idx *i = p->value.pval;
diff --git a/sql/server/rel_prop.h b/sql/server/rel_prop.h
--- a/sql/server/rel_prop.h
+++ b/sql/server/rel_prop.h
@@ -21,6 +21,7 @@ typedef enum rel_prop {
PROP_JOINIDX, /* could use join idx */
PROP_HASHIDX, /* is hash idx */
PROP_HASHCOL, /* could use hash idx */
+ PROP_UKEY, /* p = list of exps */
PROP_REMOTE, /* uri for remote execution */
PROP_USED, /* number of times exp is used */
PROP_GROUPINGS /* used by ROLLUP/CUBE/GROUPING SETS, value contains
the list of sets */
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
@@ -82,6 +82,11 @@ is_distinct_set(mvc *sql, sql_rel *rel,
distinct = need_distinct(rel);
if (is_project(rel->op) && rel->l && !distinct)
distinct = is_distinct_set(sql, rel->l, ad);
+ if (is_semi(rel->op))
+ distinct = is_distinct_set(sql, rel->l, ad);
+ prop *p = NULL;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]