Changeset: ada35c3b751a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ada35c3b751a
Modified Files:
monetdb5/modules/mal/mkey.c
monetdb5/optimizer/opt_mergetable.mx
Branch: default
Log Message:
Merged from Aug2011
diffs (167 lines):
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -740,13 +740,17 @@ access_heap(str id, str hp, Heap *h, cha
if (preload > 0) {
size_t alignskip = (page - (((size_t) base) & (page -
1))) & (page - 1);
size_t alignedsz = (size_t) (((sz < alignskip) ? 0 :
((size_t) (sz - alignskip))) & ~(page - 1));
- int ret = posix_madvise(base + alignskip, alignedsz,
adv);
- if (ret)
- THRprintf(GDKerr,
- "#MT_mmap_inform:
posix_madvise(file=%s, base=" PTRFMT ", len=" SZFMT "MB, advice=%s) = %d\n",
- h->filename,
- PTRFMTCAST(base + alignskip),
- alignedsz >> 20, advice, errno);
+ int ret;
+
+ if (alignedsz > 0) {
+ if ((ret = posix_madvise(base + alignskip,
alignedsz, adv)) != 0)
+ THRprintf(GDKerr,
+ "#MT_mmap_inform:
posix_madvise(file=%s, base=" PTRFMT ", len=" SZFMT "MB, advice=%s) = %d, errno
= %d (%s)\n",
+ h->filename,
+ PTRFMTCAST(base + alignskip),
+ alignedsz >> 20, advice, ret,
+ errno, strerror(errno));
+ }
}
}
if (touch && preload > 0 && adv != MMAP_DONTNEED) {
diff --git a/monetdb5/modules/mal/mkey.c b/monetdb5/modules/mal/mkey.c
--- a/monetdb5/modules/mal/mkey.c
+++ b/monetdb5/modules/mal/mkey.c
@@ -232,7 +232,7 @@ MKEYbathash(bat *res, bat *bid )
assert(BAThvoid(b) || BAThrestricted(b));
msg = voidbathash(&dst, b);
- if (!BAThvoid(b)) {
+ if (dst->htype != b->htype) {
BAT *x = VIEWcreate(b, dst);
BBPreleaseref(dst->batCacheid);
dst = x;
diff --git a/monetdb5/optimizer/opt_mergetable.mx
b/monetdb5/optimizer/opt_mergetable.mx
--- a/monetdb5/optimizer/opt_mergetable.mx
+++ b/monetdb5/optimizer/opt_mergetable.mx
@@ -1008,7 +1008,7 @@ aggr_phase2(char *aggr)
{
if (aggr == countRef || aggr == count_no_nilRef)
return sumRef;
- /* min/max/sum/prod are fine */
+ /* min/max/sum/prod and unique are fine */
return aggr;
}
@@ -1417,7 +1417,8 @@ static void
mat_aggr(MalBlkPtr mb, InstrPtr p, mat_t *mat, int m)
{
int tp = getArgType(mb,p,0), k;
- int v = newTmpVariable(mb, newBatType(TYPE_void,tp));
+ int battp = (getModuleId(p)==aggrRef)?newBatType(TYPE_void,tp):tp;
+ int v = newTmpVariable(mb, battp);
InstrPtr r = NULL, s = NULL, q = NULL;
OPTDEBUGmergetable {
@@ -1432,7 +1433,7 @@ mat_aggr(MalBlkPtr mb, InstrPtr p, mat_t
getArg(r,0) = v;
for(k=1; k< mat[m].mi->argc; k++) {
q = newInstruction(mb,ASSIGNsymbol);
- setModuleId(q,aggrRef);
+ setModuleId(q,getModuleId(p));
setFunctionId(q,getFunctionId(p));
getArg(q,0) = newTmpVariable(mb, tp);
q = pushArgument(mb,q,getArg(mat[m].mi,k));
@@ -1442,16 +1443,18 @@ mat_aggr(MalBlkPtr mb, InstrPtr p, mat_t
}
pushInstruction(mb,r);
- s = newInstruction(mb,ASSIGNsymbol);
- setModuleId(s, algebraRef);
- setFunctionId(s, selectNotNilRef);
- getArg(s,0) = newTmpVariable(mb, newBatType(TYPE_void,tp));
- s = pushArgument(mb, s, getArg(r,0));
- pushInstruction(mb, s);
- r = s;
+ if (getModuleId(p) == aggrRef) {
+ s = newInstruction(mb,ASSIGNsymbol);
+ setModuleId(s, algebraRef);
+ setFunctionId(s, selectNotNilRef);
+ getArg(s,0) = newTmpVariable(mb, newBatType(TYPE_void,tp));
+ s = pushArgument(mb, s, getArg(r,0));
+ pushInstruction(mb, s);
+ r = s;
+ }
s = newInstruction(mb,ASSIGNsymbol);
- setModuleId(s,aggrRef);
+ setModuleId(s,getModuleId(p));
setFunctionId(s, aggr_phase2(getFunctionId(p)));
getArg(s,0) = getArg(p,0);
s = pushArgument(mb, s, getArg(r,0));
@@ -2117,14 +2120,17 @@ OPTmergetableImplementation(Client cntxt
* Handle the rewrite v:=aggr.count(b) and sum()
* And the min/max is as easy
*/
- if( getModuleId(p)==aggrRef && p->argc == 2 &&
+ if (match == 1 && p->argc == 2 &&
+ ((getModuleId(p)==aggrRef &&
(getFunctionId(p)== countRef ||
getFunctionId(p)== count_no_nilRef ||
getFunctionId(p)== minRef ||
getFunctionId(p)== maxRef ||
getFunctionId(p)== sumRef ||
- getFunctionId(p) == prodRef) &&
- (m=isMATalias(getArg(p,1), mat, mtop)) >= 0){
+ getFunctionId(p) == prodRef)) ||
+ (getModuleId(p) == algebraRef &&
+ getFunctionId(p) == kuniqueRef)) &&
+ (m=isMATalias(getArg(p,1), mat, mtop)) >= 0) {
mat_aggr(mb, p, mat, m);
actions++;
continue;
diff --git a/sql/test/BugTracker-2011/Tests/All
b/sql/test/BugTracker-2011/Tests/All
--- a/sql/test/BugTracker-2011/Tests/All
+++ b/sql/test/BugTracker-2011/Tests/All
@@ -1,3 +1,4 @@
+operands-not-synced.Bug-2346
mclient-lsql-d.Bug-2861
count-count-distinct.Bug-2808
copy-into-file-error.Bug-2722
diff --git
a/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.err
b/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.err
--- a/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.err
+++ b/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.err
@@ -30,16 +30,6 @@ stderr of test 'operands-not-synced.Bug-
# 13:48:57 > mclient -lsql -ftest -i -e --host=ottar --port=32123
# 13:48:57 >
-MAPI = monetdb@ottar:32123
-QUERY = INSERT INTO applied_credit (directory, allowed, multiplicity)
- SELECT success_credit.directory,
- success_credit.allowed,
- count(applied_credit.directory)
- FROM success_credit
- LEFT OUTER JOIN applied_credit
- ON applied_credit.directory = success_credit.directory
- AND applied_credit.allowed >= success_credit.allowed
- GROUP BY success_credit.directory, success_credit.allowed;
# 13:48:57 >
diff --git
a/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.out
b/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.out
--- a/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.out
+++ b/sql/test/BugTracker-2011/Tests/operands-not-synced.Bug-2346.stable.out
@@ -89,6 +89,16 @@ Over..
#"bar" 341 300 341 300 5
#
[ 2 ]
+#INSERT INTO applied_credit (directory, allowed, multiplicity)
+#SELECT success_credit.directory,
+# success_credit.allowed,
+# count(applied_credit.directory)
+#FROM success_credit
+# LEFT OUTER JOIN applied_credit
+# ON applied_credit.directory = success_credit.directory
+# AND applied_credit.allowed >= success_credit.allowed
+#GROUP BY success_credit.directory, success_credit.allowed;
+[ 2 ]
#ROLLBACK;
# 13:48:57 >
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list