Changeset: 7f1071b5b208 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7f1071b5b208
Modified Files:
monetdb5/modules/kernel/aggr_be_minmax.mx
monetdb5/modules/kernel/aggr_bge_minmax.mx
monetdb5/modules/kernel/aggr_ri.mx
sql/server/rel_optimizer.c
sql/server/sql_parser.y
Branch: Oct2012
Log Message:
Merge with Oct
diffs (212 lines):
diff --git a/monetdb5/modules/kernel/aggr_be_minmax.mx
b/monetdb5/modules/kernel/aggr_be_minmax.mx
--- a/monetdb5/modules/kernel/aggr_be_minmax.mx
+++ b/monetdb5/modules/kernel/aggr_be_minmax.mx
@@ -238,7 +238,7 @@ All Rights Reserved.
static int
aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BAT *e)
{
- BAT *bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
+ BAT *bn;
BATiter bni, bi = bat_iterator(b);
int (*cmp)(const void *, const void *);
ptr nil;
@@ -254,6 +254,13 @@ aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BA
oid bhsb;
int b_use = USE_TAIL;
+ /* workaround for bug 3152: if type is str do not create a view and
+ because an assert will be triggered if the vheap is extended */
+ if (BATttype(b) == TYPE_str) {
+ bn = BATnew(TYPE_oid, BATttype(b), BATcount(e));
+ } else {
+ bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
+ }
if( bn == NULL) {
GDKerror("aggrX3_@1_@3_@4_@5(): BATnew() failed");
return GDK_FAIL;
@@ -261,9 +268,14 @@ aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BA
ALGODEBUG fprintf(stderr, "#aggrX3_@1_@3_@4_@5[@2,@6](b=%s,e=%s);\n",
BATgetId(b),BATgetId(e));
- /* init: prepare the result bat;
- * trick: by using "tail-type" void, we only write the head column,
here */
- @:init_result(void)@
+ /* do not do "the trick" if str */
+ if (BATttype(b) == TYPE_str) {
+ @:init_result(str)@
+ } else {
+ /* init: prepare the result bat;
+ * trick: by using "tail-type" void, we only write the head
column, here */
+ @:init_result(void)@
+ }
bni = bat_iterator(bn);
cmp = BATatoms[bn->ttype].atomCmp;
nil = ATOMnilptr(bn->ttype);
diff --git a/monetdb5/modules/kernel/aggr_bge_minmax.mx
b/monetdb5/modules/kernel/aggr_bge_minmax.mx
--- a/monetdb5/modules/kernel/aggr_bge_minmax.mx
+++ b/monetdb5/modules/kernel/aggr_bge_minmax.mx
@@ -326,15 +326,26 @@ aggrX3_@13_@3_@4_@5(BAT **ret, BAT *b, B
return rtrn;
}
- bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
+ /* workaround for bug 3152: if type is str do not create a view and
+ because an assert will be triggered if the vheap is extended */
+ if (BATttype(b) == TYPE_str) {
+ bn = BATnew(TYPE_oid, BATttype(b), BATcount(e));
+ } else {
+ bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
+ }
if( bn == NULL) {
GDKerror("aggrX3_@13_@3_@4_@5(): BATnew() failed");
return GDK_FAIL;
}
- /* init: prepare the result bat;
- * trick: by using "tail-type" void, we only write the head column,
here */
- @:init_result(void)@
+ /* do not do "the trick" if str */
+ if (BATttype(b) == TYPE_str) {
+ @:init_result(str)@
+ } else {
+ /* init: prepare the result bat;
+ * trick: by using "tail-type" void, we only write the head
column, here */
+ @:init_result(void)@
+ }
bni = bat_iterator(bn);
cmp = BATatoms[bn->ttype].atomCmp;
nil = ATOMnilptr(bn->ttype);
diff --git a/monetdb5/modules/kernel/aggr_ri.mx
b/monetdb5/modules/kernel/aggr_ri.mx
--- a/monetdb5/modules/kernel/aggr_ri.mx
+++ b/monetdb5/modules/kernel/aggr_ri.mx
@@ -57,7 +57,7 @@ All Rights Reserved.
BATaccessEnd(e,USE_HEAD,MMAP_SEQUENTIAL);
}
}
-#if TYPE_@1 != TYPE_void
+#if (TYPE_@1 != TYPE_void) && (TYPE_@1 != TYPE_str)
{
/* set all sums/avgs/counts to zero; for prod, zero is 1 */
BUN _i = 0;
@@ -69,6 +69,21 @@ All Rights Reserved.
}
#endif
BATsetcount(bn, _cnt);
+#if TYPE_@1 == TYPE_str
+{
+ /* copy head values */
+ BUN _i = 0;
+ oid *bnh = (oid*)Hloc(bn,BUNfirst(bn));
+ oid *eh = (oid*)Hloc(e,BUNfirst(e));
+ (void) bm; /* silence compiler */
+ BATaccessBegin(bn,USE_HEAD,MMAP_SEQUENTIAL);
+ BATaccessBegin(e,USE_HEAD,MMAP_SEQUENTIAL);
+ for (_i = 0; _i < _cnt; _i++)
+ bnh[_i] = eh[_i];
+ BATaccessEnd(bn,USE_HEAD,MMAP_SEQUENTIAL);
+ BATaccessEnd(e,USE_HEAD,MMAP_SEQUENTIAL);
+}
+#else
if (!bn->batDirty)
bn->batDirty = TRUE;
bm = VIEWcreate(e,bn);
@@ -76,4 +91,5 @@ All Rights Reserved.
bn = bm;
bm = 0;
ALIGNsetH(bn, e);
+#endif
}
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -1600,27 +1600,21 @@ rel_push_count_down(int *changes, mvc *s
*/
static list *
-sum_limit_offset(sql_allocator *sa, list *exps )
+sum_limit_offset(mvc *sql, list *exps )
{
- list *nexps = new_exp_list(sa);
- wrd l = 0;
+ list *nexps = new_exp_list(sql->sa);
node *n;
+ sql_subtype *wrd = sql_bind_localtype("wrd");
+ sql_subfunc *add;
/* if the expression list only consists of a limit expression,
* we copy it */
if (list_length(exps) == 1 && exps->h->data)
return append(nexps, exps->h->data);
- for (n = exps->h; n; n = n->next ) {
- sql_exp *e = n->data;
-
- if (e) {
- atom *a = e->l;
-
- assert(e->type == e_atom);
- l += a->data.val.wval;
- }
- }
- return append(nexps, exp_atom_wrd(sa, l));
+ for (n = exps->h; n; n = n->next )
+ nexps = append(nexps, n->data);
+ add = sql_bind_func_result(sql->sa, sql->session->schema, "sql_add",
wrd, wrd, wrd);
+ return append(nexps, exp_op(sql->sa, exps, add));
}
static int
@@ -1715,11 +1709,11 @@ rel_push_topn_down(int *changes, mvc *sq
ul = rel_project(sql->sa, ul, NULL);
ul->exps = exps_copy(sql->sa, r->exps);
ul->r = exps_copy(sql->sa, r->r);
- ul = rel_topn(sql->sa, ul, sum_limit_offset(sql->sa,
rel->exps));
+ ul = rel_topn(sql->sa, ul, sum_limit_offset(sql,
rel->exps));
ur = rel_project(sql->sa, ur, NULL);
ur->exps = exps_copy(sql->sa, r->exps);
ur->r = exps_copy(sql->sa, r->r);
- ur = rel_topn(sql->sa, ur, sum_limit_offset(sql->sa,
rel->exps));
+ ur = rel_topn(sql->sa, ur, sum_limit_offset(sql,
rel->exps));
u = rel_setop(sql->sa, ul, ur, op_union);
u->exps = exps_copy(sql->sa, r->exps);
/* zap names */
@@ -1743,14 +1737,14 @@ rel_push_topn_down(int *changes, mvc *sq
}
}
if (r && r != rel && r->op == op_project && !(rel_is_ref(r)) &&
!r->r && r->l) {
- r = rel_topn(sql->sa, r, sum_limit_offset(sql->sa,
rel->exps));
+ r = rel_topn(sql->sa, r, sum_limit_offset(sql,
rel->exps));
}
/* push topn under crossproduct */
if (r && !r->exps && r->op == op_join && !(rel_is_ref(r)) &&
((sql_rel *)r->l)->op != op_topn && ((sql_rel *)r->r)->op
!= op_topn) {
- r->l = rel_topn(sql->sa, r->l,
sum_limit_offset(sql->sa, rel->exps));
- r->r = rel_topn(sql->sa, r->r,
sum_limit_offset(sql->sa, rel->exps));
+ r->l = rel_topn(sql->sa, r->l, sum_limit_offset(sql,
rel->exps));
+ r->r = rel_topn(sql->sa, r->r, sum_limit_offset(sql,
rel->exps));
(*changes)++;
return rel;
}
@@ -1763,8 +1757,8 @@ rel_push_topn_down(int *changes, mvc *sq
rp->op == op_join && rp->exps && rp->exps->h &&
((prop*)((sql_exp*)rp->exps->h->data)->p)->kind == PROP_FETCH &&
((sql_rel *)rp->l)->op != op_topn && ((sql_rel *)rp->r)->op
!= op_topn) {
/* TODO check if order by columns are independend of
join conditions */
- r->l = rel_topn(sql->sa, r->l,
sum_limit_offset(sql->sa, rel->exps));
- r->r = rel_topn(sql->sa, r->r,
sum_limit_offset(sql->sa, rel->exps));
+ r->l = rel_topn(sql->sa, r->l, sum_limit_offset(sql,
rel->exps));
+ r->r = rel_topn(sql->sa, r->r, sum_limit_offset(sql,
rel->exps));
(*changes)++;
return rel;
}
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -2813,6 +2813,8 @@ with_list_element:
;
sql:
+ select_statement_single_row
+|
select_no_parens_orderby
;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list