Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6731/src/backends/monet5
Modified Files:
sql.mx sql_gencode.mx sql_optimizer.mx
Log Message:
when we have a topn after a project with order we push a utopn down
(ie we do the utopn on one column before the rest of the order by columns or
any distict is done)
U sql_gencode.mx
Index: sql_gencode.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_gencode.mx,v
retrieving revision 1.338
retrieving revision 1.339
diff -u -d -r1.338 -r1.339
--- sql_gencode.mx 8 Oct 2009 13:35:32 -0000 1.338
+++ sql_gencode.mx 9 Oct 2009 20:50:00 -0000 1.339
@@ -455,21 +455,21 @@
setVarType(mb, getArg(q, 0), tt);
setVarUDFtype(mb,getArg(q,0));
} else if ((s->flag & VAR_DECLARE) == 0) {
- char *buf = GDKmalloc(SMALLBUFSIZ);
+ char *buf = GDKmalloc(MAXIDENTLEN);
- (void) snprintf(buf, SMALLBUFSIZ,
"A%s", s->op1.sval);
+ (void) snprintf(buf, MAXIDENTLEN,
"A%s", s->op1.sval);
q = newAssignment(mb);
q = pushArgumentId(mb, q, buf);
} else {
int tt = tail_type(s)->type->localtype;
- char *buf = GDKmalloc(SMALLBUFSIZ);
+ char *buf = GDKmalloc(MAXIDENTLEN);
if (tt == TYPE_bat) {
/* declared table */
s->nr = dump_table(mb,
tail_type(s)->comp_type);
break;
}
- (void) snprintf(buf, SMALLBUFSIZ,
"A%s", s->op1.sval);
+ (void) snprintf(buf, MAXIDENTLEN,
"A%s", s->op1.sval);
q = newInstruction(mb,ASSIGNsymbol);
q->argc = q->retc = 0;
q = pushArgumentId(mb, q, buf);
@@ -570,6 +570,7 @@
int len = _dumpstmt(sql, mb, s->op3.stval);
/* first insert single value into a bat */
+ assert(s->nrcols);
if (s->nrcols == 0) {
int k;
int ht = TYPE_oid;
@@ -588,11 +589,18 @@
l = k;
}
if (s->flag) {
- int topn = 0;
- char *name = "topn_min";
- if ((s->flag-1) > 0)
- name = "topn_max";
+ int topn = 0, flag = s->flag, utopn = 0;
+ char *name = "utopn_min";
+
+ if (flag >= 3) {
+ utopn = 1;
+ flag -= 2;
+ }
+ if ((flag-1) > 0)
+ name = "utopn_max";
+ if (!utopn)
+ name = name+1;
q = newStmt1(mb, calcRef, "+");
q = pushArgument(mb,q, offset);
q = pushArgument(mb,q, len);
@@ -1758,7 +1766,7 @@
if (s->op2.stval)
r = _dumpstmt(sql,mb, s->op2.stval);
if (!VAR_GLOBAL(s->flag)) { /* globals */
- char *buf = GDKmalloc(SMALLBUFSIZ);
+ char *buf = GDKmalloc(MAXIDENTLEN);
char *vn = atom2string(s->op1.stval->op1.aval);
if (!s->op2.stval) {
@@ -1767,7 +1775,7 @@
_DELETE(vn);
break;
}
- (void) snprintf(buf, SMALLBUFSIZ, "A%s", vn);
+ (void) snprintf(buf, MAXIDENTLEN, "A%s", vn);
q = newInstruction(mb,ASSIGNsymbol);
q->argc = q->retc = 0;
q = pushArgumentId(mb, q, buf);
@@ -2073,12 +2081,12 @@
sql_arg *a = n->data;
int type = a->type.type->localtype;
int varid = 0;
- char *buf = GDKmalloc(SMALLBUFSIZ);
+ char *buf = GDKmalloc(MAXIDENTLEN);
if (a->name)
- (void) snprintf(buf, SMALLBUFSIZ, "A%s",
a->name);
+ (void) snprintf(buf, MAXIDENTLEN, "A%s",
a->name);
else
- (void) snprintf(buf, SMALLBUFSIZ, "A%d", argc);
+ (void) snprintf(buf, MAXIDENTLEN, "A%d", argc);
varid = newVariable(curBlk, buf, type);
curInstr = pushArgument(curBlk, curInstr, varid);
setVarType(curBlk, varid, type);
U sql_optimizer.mx
Index: sql_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_optimizer.mx,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -d -r1.230 -r1.231
--- sql_optimizer.mx 15 Sep 2009 19:44:38 -0000 1.230
+++ sql_optimizer.mx 9 Oct 2009 20:50:00 -0000 1.231
@@ -131,7 +131,7 @@
#define _SQL_OPTIMIZER_H_
#include "sql.h"
-/* #define _SQL_OPTIMIZER_DEBUG */
+//#define _SQL_OPTIMIZER_DEBUG
sql5_export void addQueryToCache(Client c);
sql5_export str SQLoptimizer(Client c);
@@ -573,7 +573,7 @@
mb = c->curprg->def;
chkProgram(c->nspace, mb);
#ifdef _SQL_OPTIMIZER_DEBUG
- printf("ADD QUERY TO CACHE\n");
+ stream_printf(GDKout, "ADD QUERY TO CACHE\n");
printFunction(GDKout,mb,0,LIST_MAL_ALL);
#endif
@-
@@ -635,6 +635,10 @@
SQLgetStatistics(c,(mvc *) c->state[MAL_SCENARIO_OPTIMIZE],mb);
optimizeMALBlock(c,mb);
}
+#ifdef _SQL_OPTIMIZER_DEBUG
+ stream_printf(GDKout, "ADD optimized QUERY TO CACHE\n");
+ printFunction(GDKout,mb,0,LIST_MAL_ALL);
+#endif
}
@-
U sql.mx
Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.358
retrieving revision 1.359
diff -u -d -r1.358 -r1.359
--- sql.mx 21 Sep 2009 14:13:27 -0000 1.358
+++ sql.mx 9 Oct 2009 20:50:00 -0000 1.359
@@ -1369,12 +1369,11 @@
{
mvc *m = NULL;
str msg = getContext(cntxt,mb, &m, NULL);
+ int *ret = (int *) getArgReference(stk, pci, 0);
- (void) cntxt;
- (void) stk;
- (void) pci;
if (msg)
return msg;
+ *ret = 0;
mvc_commit(m, 0, NULL); /* keep the changes */
return MAL_SUCCEED;
}
@@ -1383,12 +1382,11 @@
{
mvc *m=NULL;
str msg = getContext(cntxt,mb, &m, NULL);
+ int *ret = (int *) getArgReference(stk, pci, 0);
- (void) cntxt;
- (void) stk;
- (void) pci;
if (msg)
return msg;
+ *ret = 0;
mvc_rollback(m, 0, NULL); /* keep the changes */
return MAL_SUCCEED;
}
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins