Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22749/src/mal
Modified Files:
Tag: GDK-2
mal_builder.mx mal_client.mx mal_instruction.mx mal_module.mx
mal_parser.mx mal_sabaoth.mx mal_scenario.mx mal_session.mx
Log Message:
propagated changes of Tuesday Aug 28 2007 - Monday Sep 03 2007
from the development trunk to the GDK-2 branch
Index: mal_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_parser.mx,v
retrieving revision 1.200.2.2
retrieving revision 1.200.2.3
diff -u -d -r1.200.2.2 -r1.200.2.3
--- mal_parser.mx 21 Aug 2007 13:23:50 -0000 1.200.2.2
+++ mal_parser.mx 3 Sep 2007 13:08:11 -0000 1.200.2.3
@@ -1048,8 +1048,8 @@
} else
if( keyphrase1(cntxt,"(")){ /* deal with compound return */
int retc= curInstr->argc, i1,i2=0;
- int maxarg;
- int *newarg;
+ int max;
+ short *newarg;
/* parse multi-target result */
/* skipSpace(cntxt);*/
ch= currChar(cntxt);
@@ -1067,16 +1067,16 @@
ch = currChar(cntxt);
}
/* re-arrange the parameters, results first*/
- maxarg= curInstr->maxarg;
- newarg= (int*)GDKmalloc(maxarg*sizeof(int));
+ max= curInstr->maxarg;
+ newarg= (short*)GDKmalloc(max*sizeof(short));
for(i1= retc; i1<curInstr->argc; i1++)
newarg[i2++]= curInstr->argv[i1];
curInstr->retc= curInstr->argc-retc;
for(i1= 1; i1<retc; i1++)
newarg[i2++]= curInstr->argv[i1];
curInstr->argc= i2;
- for(; i2<maxarg; i2++) newarg[i2]= 0;
- for(i1=0; i1<maxarg; i1++)
+ for(; i2<max; i2++) newarg[i2]= 0;
+ for(i1=0; i1<max; i1++)
curInstr->argv[i1] = newarg[i1];
GDKfree(newarg);
if (currChar(cntxt) != ')') {
@@ -1840,17 +1840,19 @@
}
*s++= '\n';
*s = 0;
- showException(SYNTAX, "parseError", buf);
- /* produce the position marker*/
- s= buf;
- i = position(cntxt) -1;
- for(; i > 0; i--) {
- *s++ = ((l && *(l+1) && *l++ != '\t'))?' ':'\t';
+ if( s != buf+1 && strlen(buf)<1024){
+ showException(SYNTAX, "parseError", buf);
+ /* produce the position marker*/
+ s= buf;
+ i = position(cntxt) -1;
+ for(; i > 0; i--) {
+ *s++ = ((l && *(l+1) && *l++ != '\t'))?' ':'\t';
+ }
+ *s++ = '^';
+ *s = 0;
}
- *s++ = '^';
- *s = 0;
- if( msg && strlen(msg)+strlen(buf) < 1020)
+ if( msg && strlen(msg))
snprintf(s,1020,"%s", msg);
skipToEnd(cntxt);
showException(SYNTAX, "parseError", buf);
Index: mal_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_scenario.mx,v
retrieving revision 1.110
retrieving revision 1.110.2.1
diff -u -d -r1.110 -r1.110.2.1
--- mal_scenario.mx 1 Jul 2007 22:03:09 -0000 1.110
+++ mal_scenario.mx 3 Sep 2007 13:08:14 -0000 1.110.2.1
@@ -550,6 +550,7 @@
@-
@{
@= runPhase
+ c->stage= @1;
if(msg== MAL_SUCCEED && c->[EMAIL PROTECTED] && ((msg= (str)
(*c->[EMAIL PROTECTED])(c)) || c->mode <= FINISHING)){
/* error occurred */
#ifdef MAL_SCENARIO_DEBUG
@@ -579,6 +580,7 @@
while (c->mode > FINISHING) {
msg = MAL_SUCCEED;
@:runPhase(MAL_SCENARIO_READER)@
+ c->lastcmd= time(0);
@:runPhase(MAL_SCENARIO_PARSER)@
@:runPhase(MAL_SCENARIO_OPTIMIZE)@
@:runPhase(MAL_SCENARIO_SCHEDULER)@
Index: mal_session.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_session.mx,v
retrieving revision 1.137.4.2
retrieving revision 1.137.4.3
diff -u -d -r1.137.4.2 -r1.137.4.3
--- mal_session.mx 28 Aug 2007 13:15:06 -0000 1.137.4.2
+++ mal_session.mx 3 Sep 2007 13:08:15 -0000 1.137.4.3
@@ -305,13 +305,13 @@
return;
}
- if (stats->state == SABdbMaintenance) {
+ if (stats->locked == 1) {
if (uid == 0) {
stream_printf(fout, "#server is running in "
"maintenance mode\n");
} else {
stream_printf(fout, "!server is running in "
- "maintenance mode\n");
+ "maintenance mode, please try
again later\n");
stream_flush(fout);
SABAOTHfreeStatus(&stats);
GDKfree(command);
Index: mal_client.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_client.mx,v
retrieving revision 1.154.2.1
retrieving revision 1.154.2.2
diff -u -d -r1.154.2.1 -r1.154.2.2
--- mal_client.mx 28 Aug 2007 13:14:57 -0000 1.154.2.1
+++ mal_client.mx 3 Sep 2007 13:08:07 -0000 1.154.2.2
@@ -130,6 +130,7 @@
str srcFile; /* NULL for stdin, or file name */
void *state[7], *oldstate[7];
MALfcn phase[7], oldphase[7];
+ sht stage; /* keep track of the phase being ran */
char itrace; /* trace execution using interactive mdb */
/* if set to 'S' it will put
the process to sleep */
short debugOptimizer,debugScheduler;
@@ -155,8 +156,8 @@
Future releases may support a re-connect facility. [TODO]
@h
time_t login;
- time_t logout;
- time_t delay;
+ time_t lastcmd; /* set when input is received */
+ time_t delay; /* not yet used */
@-
Communication channels for the interconnect are stored here.
It is perfectly legal to have a client without input stream.
@@ -430,9 +431,10 @@
c->glb = 0;
c->father = NULL;
- c->login = time(0); c->delay= TIMEOUT;
- c->logout= c->login+c->delay;
+ c->login = c->lastcmd= time(0);
+ c->delay= TIMEOUT;
c->mode = AWAITING;
+ c->stage = 0;
c->itrace = 0;
c->debugOptimizer = c->debugScheduler= 0;
c->timer = 0;
@@ -584,7 +586,7 @@
c->errbuf=0;
}
c->father = 0;
- c->login = c->delay = c->logout = 0;
+ c->login = c->delay = c->lastcmd = 0;
@-
The threads may not be removed, but should become dormant
@c
Index: mal_module.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_module.mx,v
retrieving revision 1.50.2.4
retrieving revision 1.50.2.5
diff -u -d -r1.50.2.4 -r1.50.2.5
--- mal_module.mx 28 Aug 2007 13:14:59 -0000 1.50.2.4
+++ mal_module.mx 3 Sep 2007 13:08:10 -0000 1.50.2.5
@@ -784,16 +784,17 @@
size_t len;
len= strlen(s);
for(i=0; msg[i]; i++)
- if( strncmp(s, msg[i], MAX(len,strlen(msg[i]))) == 0)
+ if( strncmp(s, msg[i], MAX(len,strlen(msg[i]))) == 0 &&
+ strlen(s) == strlen(msg[i]) )
return 1;
return 0;
}
-char **getHelp(Module m, str pat, int completion)
+char **getHelp(Module m, str inputpat, int completion)
{
- str modnme, fcnnme = 0;
+ str pat, modnme, fcnnme = 0;
Module m1;
Symbol s;
- int len1 = 0,len2 = 0,fnd=0,f;
+ int len1 = 0,len2 = 0,fnd=0;
char *t, **msg, buf[BUFSIZ];
int top=0, i,j,k, sig = 0, doc = 0;
@@ -803,9 +804,10 @@
msg= (char **) GDKmalloc( 1000 * sizeof(str));
msg[top]=0;
- if (!pat)
+ if (!inputpat)
return msg;
+ pat= GDKstrdup(inputpat);
t= strchr(pat,'\n');
if( t) *t=0;
@@ -823,18 +825,22 @@
*fcnnme++ = 0;
if( strchr(modnme,'*'))
modnme="*";
- if( strchr(fcnnme,'*'))
+ if( strchr(fcnnme,'*') || *fcnnme==0)
fcnnme="*";
} else {
modnme="*";
fcnnme=pat;
- if( strchr(fcnnme,'*'))
+ if( strchr(fcnnme,'*') || *fcnnme==0)
fcnnme="*";
}
- if( fcnnme){
+ if( fcnnme && *fcnnme){
len2 = strlen(fcnnme);
+ } else {
+ GDKfree(pat);
+ return msg;
}
+
len1 = strlen(modnme);
/* display module information if there is no function */
@@ -846,17 +852,24 @@
if( strncmp(modnme,m->name,len1) ==0 ||
*modnme=='*'){
msg[top++] = GDKstrdup(m->name);
msg[top] =0;
- if( top == 999) return msg;
+ if( top == 999) {
+ GDKfree(pat);
+ return msg;
+ }
}
m= m->sibling;
}
}
+ GDKfree(pat);
return msg;
}
/* display module.function */
m1 = findModule(m,modnme);
- if( m1 == 0 && *modnme != '*') return msg;
+ if( m1 == 0 && *modnme != '*') {
+ GDKfree(pat);
+ return msg;
+ }
if( m1 ) m = m1;
#ifdef MAL_SCOPE_DEBUG
@@ -891,18 +904,17 @@
v= strstr(buf,"address");
if( v) *v=0;
- if( tstDuplicate(msg,buf+1) ) fnd++;
-
- for(f=0;f<top;f++)
- if( msg[f] && strcmp(buf+1, msg[f]) ==
0 ) fnd++;
+ if( tstDuplicate(msg,buf+1) &&
s->def->help==0 ) fnd++;
if(fnd) continue;
msg[top++]= GDKstrdup(buf+1);
- if( top >=998) return msg;
+ if( top >=998) {
+ GDKfree(pat);
+ return msg;
+ }
if(v){
*v='a';
msg[top++]= GDKstrdup(v);
- if( top >=998) return msg;
}
if( s->def->help) {
@@ -926,12 +938,16 @@
if( fnd == 0 && buf[1]){
msg[top++] = GDKstrdup(buf+1);
msg[top] = 0;
- if( top >=998) return msg;
+ }
+ if( top >=998) {
+ GDKfree(pat);
+ return msg;
}
}
m= m->sibling;
}
}
+ GDKfree(pat);
return msg;
}
@-
Index: mal_instruction.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_instruction.mx,v
retrieving revision 1.282.2.2
retrieving revision 1.282.2.3
diff -u -d -r1.282.2.2 -r1.282.2.3
--- mal_instruction.mx 21 Aug 2007 13:23:49 -0000 1.282.2.2
+++ mal_instruction.mx 3 Sep 2007 13:08:08 -0000 1.282.2.3
@@ -302,7 +302,7 @@
#endif
#define DEBUG_MAL_INSTR
-#define MAXARG 4
+#define MAXARG 4 /* BEWARE the code depends on this knowledge */
#define STMT_INCREMENT 32
#define STMT_MAXIMUM 1<<16
#define MAXVARS 32
@@ -366,7 +366,7 @@
str modname; /* module context */
str fcnname; /* function name */
short argc, retc, maxarg; /* total and result argument count */
- short argv[1]; /* at least one entry */
+ short argv[MAXARG]; /* at least a few entries */
} *InstrPtr, InstrRecord;
@-
@@ -897,7 +897,6 @@
newInstruction(MalBlkPtr mb, int kind)
{
InstrPtr p = NULL;
- int space;
if (mb && mb->stop <mb->ssize) {
p = mb->stmt[mb->stop];
@@ -907,8 +906,7 @@
mb->stmt[mb->stop] = NULL;
}
if (p == NULL) {
- space = (MAXARG - 1) * sizeof(int) + sizeof(InstrRecord);
- p = GDKmalloc(space);
+ p = GDKmalloc(sizeof(InstrRecord));
p->maxarg = MAXARG;
}
p->typechk = TYPE_UNKNOWN;
@@ -954,7 +952,7 @@
copyInstruction(InstrPtr p)
{
InstrPtr new;
- new = (InstrPtr) GDKmalloc(sizeof(InstrRecord) + sizeof(int) *
p->maxarg - 1);
+ new = (InstrPtr) GDKmalloc(sizeof(InstrRecord) + sizeof(short) *
(p->maxarg - MAXARG));
oldmoveInstruction(new, p);
return new;
}
@@ -971,7 +969,7 @@
clrInstruction(InstrPtr p)
{
clrFunction(p);
- memset((char *) p, 0, sizeof(InstrRecord) + (p->argc - 1) *
sizeof(int));
+ memset((char *) p, 0, sizeof(InstrRecord) + (p->maxarg - MAXARG) *
sizeof(int));
}
void
@@ -990,7 +988,7 @@
{
int space;
- space = sizeof(InstrRecord) + sizeof(int) * p->argc;
+ space = sizeof(InstrRecord) + sizeof(short) * (p->maxarg-MAXARG);
memcpy((char *) new, (char *) p, space);
setFunctionId(new, getFunctionId(p));
setModuleId(new, getModuleId(p));
@@ -1830,13 +1828,26 @@
p->argv[p->argc++] = varid;
if (p->argc == p->maxarg) {
InstrPtr pn;
- int pc = 0;
- int space = (p->maxarg - 1) * sizeof(int) + sizeof(InstrRecord);
- pn = GDKmalloc(space + MAXARG * sizeof(int));
+ int pc = 0,pclimit;
+ int space = (p->maxarg - MAXARG) * sizeof(short) +
sizeof(InstrRecord);
+ pn = GDKmalloc(space + MAXARG * sizeof(short));
memcpy((char *) pn, (char *) p, space);
- pn->maxarg = p->maxarg + MAXARG;
- /* most likely the last instruction is affected */
- for(pc= mb->stop-1; pc >= 0; pc--)
+ pn->maxarg += MAXARG;
+ /* instructions are either created in isolation or
+ are stored on the program instruction stack already.
+ In the latter case, we may have to adjust their reference.
+ It does not make sense to locate it on the complete stack,
+ because this would jeopardise long MAL program.
+
+ The alternative to this hack is to change the code in many
places
+ and educate the programmer to not forget updating the
stmtblock
+ after pushing the arguments. In sql_gencode this alone would
be
+ >100 places and in the optimizers > 30. In almost all cases
+ the instructions have few parameters.
+ */
+ pclimit= mb->stop-8;
+ pclimit= pclimit<0? 0: pclimit;
+ for(pc= mb->stop-1; pc >= pclimit; pc--)
if( mb->stmt[pc]== p){
mb->stmt[pc] = pn;
break;
Index: mal_sabaoth.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_sabaoth.mx,v
retrieving revision 1.27.2.2
retrieving revision 1.27.2.3
diff -u -d -r1.27.2.2 -r1.27.2.3
--- mal_sabaoth.mx 28 Aug 2007 13:15:04 -0000 1.27.2.2
+++ mal_sabaoth.mx 3 Sep 2007 13:08:11 -0000 1.27.2.3
@@ -105,13 +105,12 @@
assert(dbfarm != NULL);
if (_sabaoth_internal_dbfarm != NULL)
- free(_sabaoth_internal_dbfarm);
+ GDKfree(_sabaoth_internal_dbfarm);
if (_sabaoth_internal_dbname != NULL)
- free(_sabaoth_internal_dbname);
+ GDKfree(_sabaoth_internal_dbname);
len = strlen(dbfarm);
- _sabaoth_internal_dbfarm = malloc(sizeof(char) * (len + 1));
- memcpy(_sabaoth_internal_dbfarm, dbfarm, len + 1);
+ _sabaoth_internal_dbfarm = GDKstrdup(dbfarm);
/* remove trailing slashes, newlines and spaces */
len--;
while (len > 0 && (
@@ -126,9 +125,7 @@
if (dbname == NULL) {
_sabaoth_internal_dbname = NULL;
} else {
- len = strlen(dbname);
- _sabaoth_internal_dbname = malloc(sizeof(char) * (len + 1));
- memcpy(_sabaoth_internal_dbname, dbname, len + 1);
+ _sabaoth_internal_dbname = GDKstrdup(dbname);
}
}
@@ -273,7 +270,7 @@
/* emit a warning if we are in maintenance mode */
rethrow("sabaoth.getMyStatus", tmp,
SABAOTHgetMyStatus(&stats));
- if (stats->state == SABdbMaintenance)
+ if (stats->locked == 1)
fprintf(stderr, "#warning: database is running in "
"maintenance mode\n");
SABAOTHfreeStatus(&stats);
@@ -415,13 +412,13 @@
SABdbIllegal = 0,
SABdbRunning,
SABdbCrashed,
- SABdbInactive,
- SABdbMaintenance
+ SABdbInactive
} SABdbState;
typedef struct Ssabdb {
- str dbname; /* database name as string */
- /* str path; */
+ str dbname; /* database name */
+ str path; /* full path to database */
+ int locked; /* whether this database is under maintenance
*/
SABdbState state; /* current database state */
sablist* scens; /* scenarios available for this database */
sablist* conns; /* connections available for this database */
@@ -479,14 +476,16 @@
continue;
if (sdb == NULL) {
- top = sdb = malloc(sizeof(sabdb));
+ top = sdb = GDKmalloc(sizeof(sabdb));
} else {
- sdb = sdb->next = malloc(sizeof(sabdb));
+ sdb = sdb->next = GDKmalloc(sizeof(sabdb));
}
sdb->next = NULL;
/* store the database name */
- sdb->dbname = strdup(e->d_name);
+ snprintf(buf, PATHLENGTH, "%s/%s", path, e->d_name);
+ sdb->path = GDKstrdup(buf);
+ sdb->dbname = sdb->path + strlen(sdb->path) - strlen(e->d_name);
/* add scenarios that are supported */
sdb->scens = NULL;
@@ -497,13 +496,13 @@
if (*data != '\0' && data[strlen(data) - 1] ==
'\n')
data[strlen(data) - 1] = '\0';
if (sdb->scens == NULL) {
- sdb->scens = malloc(sizeof(sablist));
- sdb->scens->val = strdup(data);
+ sdb->scens = GDKmalloc(sizeof(sablist));
+ sdb->scens->val = GDKstrdup(data);
sdb->scens->next = NULL;
np = sdb->scens;
} else {
- np = np->next = malloc(sizeof(sablist));
- np->val = strdup(data);
+ np = np->next =
GDKmalloc(sizeof(sablist));
+ np->val = GDKstrdup(data);
np->next = NULL;
}
}
@@ -519,13 +518,13 @@
if (*data != '\0' && data[strlen(data) - 1] ==
'\n')
data[strlen(data) - 1] = '\0';
if (sdb->conns == NULL) {
- sdb->conns = malloc(sizeof(sablist));
- sdb->conns->val = strdup(data);
+ sdb->conns = GDKmalloc(sizeof(sablist));
+ sdb->conns->val = GDKstrdup(data);
sdb->conns->next = NULL;
np = sdb->conns;
} else {
- np = np->next = malloc(sizeof(sablist));
- np->val = strdup(data);
+ np = np->next =
GDKmalloc(sizeof(sablist));
+ np->val = GDKstrdup(data);
np->next = NULL;
}
}
@@ -538,12 +537,15 @@
* running
* - to distinguish between a crash and proper shutdown, consult
* the uplog
- * the existance of the maintenance file overrules any check and
- * puts the server in maintenance mode
*/
snprintf(buf, PATHLENGTH, "%s/%s/%s", path, e->d_name,
".gdk_lock");
- fd = MT_lockf(buf, F_TLOCK, 4, 1);
- if (fd == -2) {
+ if (_sabaoth_internal_dbname != NULL &&
+ strcmp(_sabaoth_internal_dbname, e->d_name) ==
0)
+ {
+ /* if we are the mserver that is running this database,
+ * don't touch the lock! */
+ sdb->state = SABdbRunning;
+ } else if ((fd = MT_lockf(buf, F_TLOCK, 4, 1)) == -2) {
/* Locking failed; this can be because the lockfile
couldn't
* be created. Probably there is no Mserver running for
* that case also.
@@ -557,8 +559,6 @@
log[PATHLENGTH] = '\0';
/* locking succeed, check for a crash in the uplog */
- close(fd);
-
snprintf(log, PATHLENGTH, "%s/%s/%s", path, e->d_name,
UPLOGFILE);
if ((f = fopen(log, "r")) != NULL) {
(void)fseek(f, -1, SEEK_END);
@@ -575,15 +575,17 @@
/* no uplog file? assume no crash */
sdb->state = SABdbInactive;
}
- fd = MT_lockf(buf, F_ULOCK, 4, 1);
- if (fd >= 0)
- close(fd);
+
+ /* release the lock */
+ close(fd);
}
snprintf(buf, PATHLENGTH, "%s/%s/%s", path, e->d_name,
MAINTENANCEFILE);
f = fopen(buf, "r");
if (f != NULL) {
fclose(f);
- sdb->state = SABdbMaintenance;
+ sdb->locked = 1;
+ } else {
+ sdb->locked = 0;
}
}
(void) closedir(d);
@@ -607,25 +609,26 @@
p = *ret;
while (p != NULL) {
- if (p->dbname != NULL) free(p->dbname);
+ if (p->path != NULL)
+ GDKfree(p->path);
r = p->scens;
while (r != NULL) {
if (r->val != NULL)
- free(r->val);
+ GDKfree(r->val);
s = r->next;
- free(r);
+ GDKfree(r);
r = s;
}
r = p->conns;
while (r != NULL) {
if (r->val != NULL)
- free(r->val);
+ GDKfree(r->val);
s = r->next;
- free(r);
+ GDKfree(r);
r = s;
}
q = p->next;
- free(p);
+ GDKfree(p);
p = q;
}
Index: mal_builder.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_builder.mx,v
retrieving revision 1.23.4.2
retrieving revision 1.23.4.3
diff -u -d -r1.23.4.2 -r1.23.4.3
--- mal_builder.mx 28 Aug 2007 13:14:57 -0000 1.23.4.2
+++ mal_builder.mx 3 Sep 2007 13:08:06 -0000 1.23.4.3
@@ -330,10 +330,13 @@
}
InstrPtr
-pushValue(MalBlkPtr mb, InstrPtr q, ValPtr cst)
+pushValue(MalBlkPtr mb, InstrPtr q, ValPtr vr)
{
int _t;
- _t = defConstant(mb,cst->vtype,cst);
+ ValRecord cst;
+ VALcopy(&cst, vr);
+
+ _t = defConstant(mb,cst.vtype,&cst);
return pushArgument(mb, q, _t);
}
@}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins