Changeset: 3a931695b48a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3a931695b48a
Modified Files:
sql/server/rel_optimize_others.c
sql/server/rel_optimize_proj.c
sql/server/rel_optimize_sel.c
sql/server/rel_unnest.c
Branch: default
Log Message:
merged with Dec2025
diffs (truncated from 841 to 300 lines):
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -1136,37 +1136,29 @@ BATstr_group_concat(allocator *ma, ValPt
{
struct canditer ci;
gdk_return r = GDK_SUCCEED;
- char *nseparator = (char *)separator;
+ const char *nseparator = separator;
assert((nseparator && !sep) || (!nseparator && sep)); /* only one of
them must be set */
*res = (ValRecord) {.vtype = TYPE_str};
canditer_init(&ci, b, s);
- allocator *ta = MT_thread_getallocator();
- allocator_state ta_state = ma_open(ta);
-
+ BATiter bi = bat_iterator(sep);
if (sep && BATcount(sep) == 1) { /* Only one element in sep */
- BATiter bi = bat_iterator(sep);
- nseparator = ma_strdup(ta, BUNtvar(bi, 0));
- bat_iterator_end(&bi);
- if (!nseparator) {
- ma_close(&ta_state);
- return GDK_FAIL;
- }
+ nseparator = BUNtvar(bi, 0);
sep = NULL;
}
if (ci.ncand == 0 || (nseparator && strNil(nseparator))) {
- if (VALinit(ta, res, TYPE_str, nil_if_empty ? str_nil : "") ==
NULL)
+ if (VALinit(ma, res, TYPE_str, nil_if_empty ? str_nil : "") ==
NULL)
r = GDK_FAIL;
- ma_close(&ta_state);
+ bat_iterator_end(&bi);
return r;
}
r = concat_strings(ma, NULL, res, b, b->hseqbase, 1, &ci, NULL, 0, 0,
skip_nils, sep, nseparator, NULL);
- ma_close(&ta_state);
+ bat_iterator_end(&bi);
return r;
}
@@ -1180,7 +1172,7 @@ BATgroupstr_group_concat(BAT *b, BAT *g,
struct canditer ci;
const char *err;
gdk_return res;
- char *nseparator = (char *)separator;
+ const char *nseparator = separator;
assert((nseparator && !sep) || (!nseparator && sep)); /* only one of
them must be set */
(void) skip_nils;
@@ -1195,17 +1187,9 @@ BATgroupstr_group_concat(BAT *b, BAT *g,
return NULL;
}
- allocator *ma = MT_thread_getallocator();
- allocator_state ma_state = ma_open(ma);
-
+ BATiter bi = bat_iterator(sep);
if (sep && BATcount(sep) == 1) { /* Only one element in sep */
- BATiter bi = bat_iterator(sep);
- nseparator = ma_strdup(ma, BUNtvar(bi, 0));
- bat_iterator_end(&bi);
- if (!nseparator) {
- ma_close(&ma_state);
- return NULL;
- }
+ nseparator = BUNtvar(bi, 0);
sep = NULL;
}
@@ -1232,7 +1216,7 @@ BATgroupstr_group_concat(BAT *b, BAT *g,
bn = NULL;
done:
- ma_close(&ma_state);
+ bat_iterator_end(&bi);
return bn;
}
@@ -1241,23 +1225,20 @@ done:
for (oid m = START; m < END; m++) { \
const char *sb = BUNtvar(bi, m); \
\
- if (separator) { \
- if (!strNil(sb)) { \
+ if (!strNil(sb)) { \
+ if (separator) { \
next_group_length += strlen(sb); \
if (!empty) \
next_group_length +=
separator_length; \
- empty = false; \
- } \
- } else { /* sep case */ \
- assert(sep != NULL); \
- const char *sl = BUNtvar(sepi, m); \
+ } else { /* sep case */ \
+ assert(sep != NULL); \
+ const char *sl = BUNtvar(sepi, m); \
\
- if (!strNil(sb)) { \
next_group_length += strlen(sb); \
if (!empty && !strNil(sl)) \
next_group_length +=
strlen(sl); \
- empty = false; \
} \
+ empty = false; \
} \
} \
if (empty) { \
@@ -1289,38 +1270,32 @@ done:
for (oid m = START; m < END; m++) { \
const char *sb = BUNtvar(bi, m); \
\
+ if (strNil(sb)) \
+ continue; \
if (separator) { \
- if (strNil(sb)) \
- continue; \
if (!empty) { \
memcpy(single_str + offset,
separator, separator_length); \
offset += separator_length; \
} \
- next_length = strlen(sb); \
- memcpy(single_str + offset, sb,
next_length); \
- offset += next_length; \
- empty = false; \
} else { /* sep case */ \
assert(sep != NULL); \
const char *sl = BUNtvar(sepi, m); \
\
- if (strNil(sb)) \
- continue; \
if (!empty && !strNil(sl)) { \
next_length = strlen(sl); \
memcpy(single_str + offset, sl,
next_length); \
offset += next_length; \
} \
- next_length = strlen(sb); \
- memcpy(single_str + offset, sb,
next_length); \
- offset += next_length; \
- empty = false; \
} \
+ next_length = strlen(sb); \
+ memcpy(single_str + offset, sb, next_length); \
+ offset += next_length; \
+ empty = false; \
} \
\
single_str[offset] = '\0'; \
} \
-} while (0)
+ } while (0)
#define ANALYTICAL_STR_GROUP_CONCAT_UNBOUNDED_TILL_CURRENT_ROW \
do { \
diff --git a/sql/include/sql_relation.h b/sql/include/sql_relation.h
--- a/sql/include/sql_relation.h
+++ b/sql/include/sql_relation.h
@@ -314,7 +314,7 @@ typedef struct relation {
* Used by rewriters at rel_unnest, rel_optimizer and rel_distribute so
a relation is not modified twice
* The list is kept at rel_optimizer_private.h Please update it
accordingly
*/
- uint8_t used;
+ uint16_t used;
int opt;
void *p; /* properties for the optimizer, distribution */
} sql_rel;
diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c
--- a/sql/server/rel_optimize_others.c
+++ b/sql/server/rel_optimize_others.c
@@ -706,7 +706,7 @@ rel_mark_used(mvc *sql, sql_rel *rel, in
}
}
-static sql_rel *rel_dce_sub(mvc *sql, sql_rel *rel);
+static sql_rel *rel_dce_sub(visitor *v, sql_rel *rel);
static sql_rel *
rel_remove_unused(mvc *sql, sql_rel *rel)
@@ -903,7 +903,7 @@ rel_dce_refs(mvc *sql, sql_rel *rel, lis
}
static sql_rel *
-rel_dce_down(mvc *sql, sql_rel *rel, int skip_proj)
+rel_dce_down(visitor *v, sql_rel *rel, int skip_proj)
{
if (!rel)
return rel;
@@ -916,9 +916,9 @@ rel_dce_down(mvc *sql, sql_rel *rel, int
case op_table:
if (skip_proj && rel->l && rel->op == op_table && rel->flag !=
TRIGGER_WRAPPER)
- rel->l = rel_dce_down(sql, rel->l, 0);
+ rel->l = rel_dce_down(v, rel->l, 0);
if (!skip_proj)
- rel_dce_sub(sql, rel);
+ rel_dce_sub(v, rel);
/* fall through */
case op_truncate:
@@ -926,16 +926,16 @@ rel_dce_down(mvc *sql, sql_rel *rel, int
case op_insert:
rel_used(rel->r);
- rel_dce_sub(sql, rel->r);
+ rel_dce_sub(v, rel->r);
return rel;
case op_update:
case op_delete:
if (skip_proj && rel->r)
- rel->r = rel_dce_down(sql, rel->r, 0);
+ rel->r = rel_dce_down(v, rel->r, 0);
if (!skip_proj)
- rel_dce_sub(sql, rel);
+ rel_dce_sub(v, rel);
return rel;
case op_topn:
@@ -944,34 +944,34 @@ rel_dce_down(mvc *sql, sql_rel *rel, int
case op_groupby:
if (skip_proj && rel->l)
- rel->l = rel_dce_down(sql, rel->l, is_topn(rel->op) ||
is_sample(rel->op));
+ rel->l = rel_dce_down(v, rel->l, is_topn(rel->op) ||
is_sample(rel->op));
if (!skip_proj)
- rel_dce_sub(sql, rel);
+ rel_dce_sub(v, rel);
return rel;
case op_inter:
case op_except:
if (skip_proj) {
if (rel->l)
- rel->l = rel_dce_down(sql, rel->l, 0);
+ rel->l = rel_dce_down(v, rel->l, 0);
if (rel->r)
- rel->r = rel_dce_down(sql, rel->r, 0);
+ rel->r = rel_dce_down(v, rel->r, 0);
}
if (!skip_proj)
- rel_dce_sub(sql, rel);
+ rel_dce_sub(v, rel);
return rel;
case op_munion:
if (skip_proj) {
for (node *n = ((list*)rel->l)->h; n; n = n->next)
- n->data = rel_dce_down(sql, n->data, 0);
+ n->data = rel_dce_down(v, n->data, 0);
}
if (!skip_proj)
- rel_dce_sub(sql, rel);
+ rel_dce_sub(v, rel);
return rel;
case op_select:
if (rel->l)
- rel->l = rel_dce_down(sql, rel->l, 0);
+ rel->l = rel_dce_down(v, rel->l, 0);
return rel;
case op_join:
@@ -981,22 +981,22 @@ rel_dce_down(mvc *sql, sql_rel *rel, int
case op_semi:
case op_anti:
if (rel->l)
- rel->l = rel_dce_down(sql, rel->l, 0);
+ rel->l = rel_dce_down(v, rel->l, 0);
if (rel->r)
- rel->r = rel_dce_down(sql, rel->r, 0);
+ rel->r = rel_dce_down(v, rel->r, 0);
if (!skip_proj && !list_empty(rel->attr))
- rel_dce_sub(sql, rel);
+ rel_dce_sub(v, rel);
return rel;
case op_ddl:
if (rel->flag == ddl_output || rel->flag == ddl_create_seq ||
rel->flag == ddl_alter_seq || rel->flag == ddl_alter_table || rel->flag ==
ddl_create_table || rel->flag == ddl_create_view) {
if (rel->l)
- rel->l = rel_dce_down(sql, rel->l, 0);
+ rel->l = rel_dce_down(v, rel->l, 0);
} else if (rel->flag == ddl_list || rel->flag == ddl_exception)
{
if (rel->l)
- rel->l = rel_dce_down(sql, rel->l, 0);
+ rel->l = rel_dce_down(v, rel->l, 0);
if (rel->r)
- rel->r = rel_dce_down(sql, rel->r, 0);
+ rel->r = rel_dce_down(v, rel->r, 0);
}
return rel;
}
@@ -1010,44 +1010,51 @@ rel_dce_down(mvc *sql, sql_rel *rel, int
*/
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]