Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv19789/src/backends/monet5
Modified Files:
sql_gencode.mx
Log Message:
propagated changes of Thursday Oct 08 2009
from the Nov2009 branch to the development trunk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/08 - sjoerd: src/backends/monet5/sql_gencode.mx,1.336.2.1
propagated changes of Thursday Oct 08 2009
from the Aug2009 branch to the Nov2009 branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/08 - mr-meltdown: src/backends/monet5/sql_gencode.mx,1.332.2.2
it makes little to no sense to first allocate some space on the stack and
then strdup it, can allocate it on the heap immediately too, this helps
reducing the stack space in use, as indicated by Solaris which still runs out
of it (but a little bit later now) for the huge_expression_and_column_name test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/08 - mr-meltdown: src/backends/monet5/sql_gencode.mx,1.332.2.3
fix guaranteed segfault, don't try to dereference s if you just found out
that s is NULL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/08 - mr-meltdown: src/backends/monet5/sql_gencode.mx,1.332.2.4
avoid crash when we run out of stack space, this is not a good solution,
but it works good enough for now
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: sql_gencode.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_gencode.mx,v
retrieving revision 1.336
retrieving revision 1.337
diff -u -d -r1.336 -r1.337
--- sql_gencode.mx 23 Sep 2009 07:25:30 -0000 1.336
+++ sql_gencode.mx 8 Oct 2009 11:20:46 -0000 1.337
@@ -423,6 +423,13 @@
InstrPtr q = NULL;
node *n;
+ if (THRhighwater()) {
+ /* FIXME: this needs a proper solution, but at least this avoids
+ * crashing, which is just a wee bit better */
+ showException(SQL, "sql", "too many nested operators");
+ return(0);
+ }
+
if (s) {
if (s->nr > 0)
return s->nr; /* stmt already handled */
@@ -448,37 +455,34 @@
setVarType(mb, getArg(q, 0), tt);
setVarUDFtype(mb,getArg(q,0));
} else if ((s->flag & VAR_DECLARE) == 0) {
- char *buf;
+ char *buf = GDKmalloc(SMALLBUFSIZ);
- buf = alloca(SMALLBUFSIZ);
(void) snprintf(buf, SMALLBUFSIZ,
"A%s", s->op1.sval);
q = newAssignment(mb);
- q = pushArgumentId(mb, q, _strdup(buf));
+ q = pushArgumentId(mb, q, buf);
} else {
int tt = tail_type(s)->type->localtype;
- char *buf;
+ char *buf = GDKmalloc(SMALLBUFSIZ);
if (tt == TYPE_bat) {
/* declared table */
s->nr = dump_table(mb,
tail_type(s)->comp_type);
break;
}
- buf = alloca(SMALLBUFSIZ);
(void) snprintf(buf, SMALLBUFSIZ,
"A%s", s->op1.sval);
q = newInstruction(mb,ASSIGNsymbol);
q->argc = q->retc = 0;
- q = pushArgumentId(mb, q, _strdup(buf));
+ q = pushArgumentId(mb, q, buf);
q = pushNil(mb, q, tt);
pushInstruction(mb, q);
q->retc++;
}
} else {
- char *buf;
+ char *buf = GDKmalloc(SMALLBUFSIZ);
- buf = alloca(SMALLBUFSIZ);
(void) snprintf(buf, SMALLBUFSIZ, "A%d",
s->flag);
q = newAssignment(mb);
- q = pushArgumentId(mb, q, _strdup(buf));
+ q = pushArgumentId(mb, q, buf);
}
s->nr = getDestVar(q);
} break;
@@ -1057,14 +1061,13 @@
break;
}
case st_group:{
- char *nme;
+ char *nme = GDKmalloc(SMALLBUFSIZ);
int ext, grp, o1 = _dumpstmt(sql, mb, s->op1.stval);
- nme = alloca(SMALLBUFSIZ);
q = newStmt2(mb, groupRef, newRef);
ext = getDestVar(q);
- snprintf( nme, SMALLBUFSIZ, "grp%d", getDestVar(q));
- q = pushReturn(mb, q, newVariable(mb, _strdup(nme),
TYPE_any));
+ snprintf(nme, SMALLBUFSIZ, "grp%d", getDestVar(q));
+ q = pushReturn(mb, q, newVariable(mb, nme, TYPE_any));
grp = getArg(q, 1);
q = pushArgument(mb, q, o1);
@@ -1072,16 +1075,16 @@
q = pushArgument(mb, q, grp);
s->nr = getDestVar(q);
- snprintf( nme, SMALLBUFSIZ, "ext%d", s->nr);
- renameVariable(mb, ext, _strdup(nme));
+ nme = GDKmalloc(SMALLBUFSIZ);
+ snprintf(nme, SMALLBUFSIZ, "ext%d", s->nr);
+ renameVariable(mb, ext, nme);
} break;
case st_group_ext:{
- char *ext;
+ char ext[SMALLBUFSIZ];
int e = -1, g = _dumpstmt(sql, mb, s->op1.stval);
- ext = alloca(SMALLBUFSIZ);
- snprintf( ext, SMALLBUFSIZ, "ext%d", g);
+ snprintf(ext, SMALLBUFSIZ, "ext%d", g);
e = findVariable(mb, ext);
assert(e >= 0);
@@ -1090,20 +1093,19 @@
s->nr = getDestVar(q);
} break;
case st_derive:{
- char *nme, *buf;
+ char *nme = GDKmalloc(SMALLBUFSIZ);
+ char *buf = GDKmalloc(SMALLBUFSIZ);
int ext, grp;
int g = _dumpstmt(sql, mb, s->op1.stval);
int l = _dumpstmt(sql, mb, s->op2.stval);
- nme = alloca(SMALLBUFSIZ);
- buf = alloca(SMALLBUFSIZ);
q = newStmt2(mb, groupRef, deriveRef);
ext = getDestVar(q);
- snprintf( nme, SMALLBUFSIZ, "grp%d", getDestVar(q));
- q = pushReturn(mb, q, newVariable(mb, _strdup(nme),
TYPE_any));
+ snprintf(nme, SMALLBUFSIZ, "grp%d", getDestVar(q));
+ q = pushReturn(mb, q, newVariable(mb, nme, TYPE_any));
grp = getArg(q, 1);
(void) snprintf(buf, SMALLBUFSIZ, "ext%d", g);
- q = pushArgumentId(mb, q, _strdup(buf));
+ q = pushArgumentId(mb, q, buf);
q = pushArgument(mb, q, g);
q = pushArgument(mb, q, l);
@@ -1111,26 +1113,25 @@
q = pushArgument(mb, q, grp);
s->nr = getDestVar(q);
- snprintf( nme, SMALLBUFSIZ, "ext%d", s->nr);
- renameVariable(mb, ext, _strdup(nme));
+ nme = GDKmalloc(SMALLBUFSIZ);
+ snprintf(nme, SMALLBUFSIZ, "ext%d", s->nr);
+ renameVariable(mb, ext, nme);
} break;
case st_unique:{
int l = _dumpstmt(sql, mb, s->op1.stval);
if (s->op2.stval) {
- char *nme, *buf;
+ char *nme = GDKmalloc(SMALLBUFSIZ);
+ char *buf = GDKmalloc(SMALLBUFSIZ);
int e, g = _dumpstmt(sql, mb, s->op2.stval);
- nme = alloca(SMALLBUFSIZ);
- buf = alloca(SMALLBUFSIZ);
-
q = newStmt2(mb, groupRef, deriveRef);
e = getDestVar(q);
- snprintf( nme, SMALLBUFSIZ, "grp%d",
getDestVar(q));
- q = pushReturn(mb, q, newVariable(mb,
_strdup(nme), TYPE_any));
+ snprintf(nme, SMALLBUFSIZ, "grp%d",
getDestVar(q));
+ q = pushReturn(mb, q, newVariable(mb, nme,
TYPE_any));
(void) snprintf(buf, SMALLBUFSIZ, "ext%d", g);
- q = pushArgumentId(mb, q, _strdup(buf));
+ q = pushArgumentId(mb, q, buf);
q = pushArgument(mb, q, g);
q = pushArgument(mb, q, l);
@@ -1757,7 +1758,8 @@
if (s->op2.stval)
r = _dumpstmt(sql,mb, s->op2.stval);
if (!VAR_GLOBAL(s->flag)) { /* globals */
- char *buf, *vn =
atom2string(s->op1.stval->op1.aval);
+ char *buf = GDKmalloc(SMALLBUFSIZ);
+ char *vn = atom2string(s->op1.stval->op1.aval);
if (!s->op2.stval) {
/* drop declared table */
@@ -1765,11 +1767,10 @@
_DELETE(vn);
break;
}
- buf = alloca(SMALLBUFSIZ);
(void) snprintf(buf, SMALLBUFSIZ, "A%s", vn);
q = newInstruction(mb,ASSIGNsymbol);
q->argc = q->retc = 0;
- q = pushArgumentId(mb, q, _strdup(buf));
+ q = pushArgumentId(mb, q, buf);
_DELETE(vn);
pushInstruction(mb, q);
q->retc++;
@@ -1791,8 +1792,11 @@
}
+
+ return s->nr;
}
- return s->nr;
+
+ return(0);
}
@-
The kernel uses two calls to procedures defined in SQL.
@@ -2064,7 +2068,7 @@
if (f->ops) {
int argc = 0;
node *n;
- char *buf = alloca(SMALLBUFSIZ);
+ char *buf = GDKmalloc(SMALLBUFSIZ);
for (n = f->ops->h; n; n = n->next, argc++) {
sql_arg *a = n->data;
@@ -2075,7 +2079,7 @@
(void) snprintf(buf, SMALLBUFSIZ, "A%s",
a->name);
else
(void) snprintf(buf, SMALLBUFSIZ, "A%d", argc);
- varid = newVariable(curBlk, _strdup(buf), type);
+ varid = newVariable(curBlk, buf, type);
curInstr = pushArgument(curBlk, curInstr, varid);
setVarType(curBlk, varid, type);
setVarUDFtype(curBlk,varid);
------------------------------------------------------------------------------
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