MonetDB: default - Simplify code: test only once.

2018-10-09 Thread Sjoerd Mullender
Changeset: d95ad5191235 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d95ad5191235
Modified Files:
gdk/gdk_logger.c
Branch: default
Log Message:

Simplify code: test only once.


diffs (65 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -339,8 +339,7 @@ static gdk_return
 log_write_id(logger *l, char tpe, oid id)
 {
lng lid = id;
-   if (lid < 0 || lid > 100)
-   assert(0);
+   assert(lid >= 0 && lid <= 100);
if (mnstr_writeChr(l->log, tpe) &&
mnstr_writeLng(l->log, id))
return GDK_SUCCEED;
@@ -422,8 +421,9 @@ log_read_updates(logger *lg, trans *tr, 
 
for (i = 0; i < tr->nr; i++) {
if (tr->changes[i].type == LOG_CREATE &&
-  ((!tpe && strcmp(tr->changes[i].name, name) == 0)  ||
-  (tpe && tr->changes[i].tpe == tpe && 
tr->changes[i].cid == id))) {
+   (tpe == 0
+? strcmp(tr->changes[i].name, name) == 0
+: tr->changes[i].tpe == tpe && tr->changes[i].cid 
== id)) {
ht = tr->changes[i].ht;
if (ht < 0) {
ht = TYPE_void;
@@ -2797,8 +2797,7 @@ log_bat_transient(logger *lg, const char
}
 
if (log_write_format(lg, ) != GDK_SUCCEED ||
-   (tpe && log_write_id(lg, tpe, id) != GDK_SUCCEED) ||
-   (!tpe && log_write_string(lg, name) != GDK_SUCCEED)) {
+   (tpe ? log_write_id(lg, tpe, id) : log_write_string(lg, name)) != 
GDK_SUCCEED) {
fprintf(stderr, "!ERROR: log_bat_transient: write failed\n");
return GDK_FAIL;
}
@@ -2833,8 +2832,7 @@ log_delta(logger *lg, BAT *uid, BAT *uva
 
l.flag = (tpe)?LOG_UPDATE_ID:LOG_UPDATE;
if (log_write_format(lg, ) != GDK_SUCCEED ||
-   (tpe && log_write_id(lg, tpe, id) != GDK_SUCCEED) ||
-   (!tpe && log_write_string(lg, name) != GDK_SUCCEED))
+   (tpe ? log_write_id(lg, tpe, id) : log_write_string(lg, 
name)) != GDK_SUCCEED)
return GDK_FAIL;
 
for (p = 0; p < BUNlast(uid) && ok == GDK_SUCCEED; p++) {
@@ -2876,8 +2874,7 @@ log_bat(logger *lg, BAT *b, const char *
 
l.flag = tpe?LOG_INSERT_ID:LOG_INSERT;
if (log_write_format(lg, ) != GDK_SUCCEED ||
-   (tpe && log_write_id(lg, tpe, id) != GDK_SUCCEED) ||
-   (!tpe && log_write_string(lg, name) != GDK_SUCCEED))
+   (tpe ? log_write_id(lg, tpe, id) : log_write_string(lg, 
name)) != GDK_SUCCEED)
return GDK_FAIL;
 
if (b->ttype > TYPE_void &&
@@ -2919,8 +2916,7 @@ log_bat_clear(logger *lg, const char *na
 
l.flag = (tpe)?LOG_CLEAR_ID:LOG_CLEAR;
if (log_write_format(lg, ) != GDK_SUCCEED ||
-   (tpe && log_write_id(lg, tpe, id) != GDK_SUCCEED) ||
-   (!tpe && log_write_string(lg, name) != GDK_SUCCEED))
+   (tpe ? log_write_id(lg, tpe, id) : log_write_string(lg, name)) != 
GDK_SUCCEED)
return GDK_FAIL;
 
if (lg->debug & 1)
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Simplify code.

2018-09-11 Thread Sjoerd Mullender
Changeset: 84870491b10a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=84870491b10a
Modified Files:
monetdb5/modules/mal/projectionpath.c
Branch: default
Log Message:

Simplify code.


diffs (54 lines):

diff --git a/monetdb5/modules/mal/projectionpath.c 
b/monetdb5/modules/mal/projectionpath.c
--- a/monetdb5/modules/mal/projectionpath.c
+++ b/monetdb5/modules/mal/projectionpath.c
@@ -12,11 +12,10 @@
 str
 ALGprojectionpath(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-   int i, top = 0;
-   bat *bid;
+   int i;
+   bat bid;
bat *r = getArgReference_bat(stk, pci, 0);
BAT *b, **joins = (BAT**)GDKzalloc(pci->argc * sizeof(BAT*)); 
-   int error = 0;
 
(void) mb;
(void) cntxt;
@@ -25,27 +24,20 @@ ALGprojectionpath(Client cntxt, MalBlkPt
if ( joins == NULL)
throw(MAL, "algebra.projectionpath", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
for (i = pci->retc; i < pci->argc; i++) {
-   bid = getArgReference_bat(stk, pci, i);
-   b = BATdescriptor(*bid);
-   if (b == NULL) {
-   error = 1;
-   } else {
-   if (i + 1 < pci->argc && ATOMtype(b->ttype) != 
TYPE_oid) {
-   error = 1;
-   }
-   else joins[top++] = b;
-   }
-   if (error) {
-   while (top-- > 0)
-   BBPunfix(joins[top]->batCacheid);
+   bid = *getArgReference_bat(stk, pci, i);
+   b = BATdescriptor(bid);
+   if (b == NULL || (i + 1 < pci->argc && ATOMtype(b->ttype) != 
TYPE_oid)) {
+   while (--i >= pci->retc)
+   BBPunfix(joins[i - pci->retc]->batCacheid);
GDKfree(joins);
throw(MAL, "algebra.projectionpath", "%s", b ? 
SEMANTIC_TYPE_MISMATCH : INTERNAL_BAT_ACCESS);
}
+   joins[i - pci->retc] = b;
}
-   joins[top] = NULL;
+   joins[pci->argc - pci->retc] = NULL;
b = BATprojectchain(joins);
-   while (top-- > 0)
-   BBPunfix(joins[top]->batCacheid);
+   for (i = pci->retc; i < pci->argc; i++)
+   BBPunfix(joins[i - pci->retc]->batCacheid);
GDKfree(joins);
if ( b)
BBPkeepref( *r = b->batCacheid);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Simplify code.

2017-11-07 Thread Sjoerd Mullender
Changeset: 31a3d252b036 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=31a3d252b036
Modified Files:
geom/monetdb5/geom.c
Branch: default
Log Message:

Simplify code.


diffs (14 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2095,9 +2095,7 @@ geom_epilogue(void *ret)
 static int
 mbr_isnil(const mbr *m)
 {
-   if (m == NULL || is_flt_nil(m->xmin) || is_flt_nil(m->ymin) || 
is_flt_nil(m->xmax) || is_flt_nil(m->ymax))
-   return 1;
-   return 0;
+   return (m == NULL || is_flt_nil(m->xmin) || is_flt_nil(m->ymin) || 
is_flt_nil(m->xmax) || is_flt_nil(m->ymax));
 }
 
 /* returns the size of variable-sized atom wkb */
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Simplify code, and only use constant strings ...

2017-09-18 Thread Sjoerd Mullender
Changeset: 976a4b688e4f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=976a4b688e4f
Modified Files:
clients/mapiclient/tomograph.c
Branch: default
Log Message:

Simplify code, and only use constant strings as fprintf formats.


diffs (70 lines):

diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -953,49 +953,23 @@ showio(void)
 static void
 fprintf_time(FILE *f, lng time)
 {
-   int TME = TME_DD|TME_HH|TME_MM|TME_SS|TME_MS|TME_US;
-   int tail = 0;
-   const char *fmt = NULL;
-
-   if (TME & TME_DD && (tail || time >= US_DD)) {
-   fmt = LLFMT"%s";
-   fprintf(f, fmt, time / US_DD, " d ");
-   time %= US_DD;
-   TME &= TME_HH;
-   tail = 1;
-   }
-   if (TME & TME_HH && (tail || time >= US_HH)) {
-   fmt = tail ? "%02d%s" : "%d%s";
-   fprintf(f, fmt, (int) (time / US_HH), " h ");
-   time %= US_HH;
-   TME &= TME_MM;
-   tail = 1;
-   }
-   if (TME & TME_MM && (tail || time >= US_MM)) {
-   fmt = tail ? "%02d%s" : "%d%s";
-   fprintf(f, fmt, (int) (time / US_MM), " m ");
-   time %= US_MM;
-   TME &= TME_SS;
-   tail = 1;
-   }
-   if (TME & TME_SS && (tail || time >= US_SS)) {
-   fmt = tail ? "%02d%s" : "%d%s";
-   fprintf(f, fmt, (int) (time / US_SS), (TME & TME_MS) ? "." : " 
s ");
-   time %= US_SS;
-   TME &= TME_MS;
-   tail = 1;
-   }
-   if (TME & TME_MS && (tail || time >= US_MS)) {
-   fmt = tail ? "%03d%s" : "%d%s";
-   fprintf(f, fmt, (int) (time / US_MS), (TME & TME_US) ? "." : " 
s ");
-   time %= US_MS;
-   TME &= TME_US;
-   tail = 1;
-   }
-   if (TME & TME_US) {
-   fmt = tail ? "%03d%s" : "%d%s";
-   fprintf(f, fmt, (int) time, tail ? " ms " : " us ");
-   }
+   if (time >= US_DD)
+   fprintf(f, LLFMT " d %02d h ", time / US_DD,
+   (int) ((time % US_DD) / US_HH));
+   else if (time >= US_HH)
+   fprintf(f, "%d h %02d m ", (int) (time / US_HH),
+   (int) ((time % US_HH) / US_MM));
+   else if (time >= US_MM)
+   fprintf(f, "%d m %02d s ", (int) (time / US_MM),
+   (int) ((time % US_MM) / US_SS));
+   else if (time >= US_SS)
+   fprintf(f, "%d.%03d s ", (int) (time / US_SS),
+   (int) ((time % US_SS) / US_MS));
+   else if (time >= US_MS)
+   fprintf(f, "%d.%03d ms ", (int) (time / US_MS),
+   (int) ((time % US_MS)));
+   else
+   fprintf(f, "%d us ", (int) time);
 }
 
 /* produce a legenda image for the color map */
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Simplify code for debugging

2017-03-01 Thread Martin Kersten
Changeset: 7401c070465b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7401c070465b
Modified Files:
monetdb5/mal/mal.h
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_function.c
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_instruction.h
Branch: default
Log Message:

Simplify code for debugging


diffs (138 lines):

diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -146,7 +146,14 @@ typedef struct SYMDEF {
 typedef struct VARRECORD {
char id[IDLENGTH];  /* use the space for the full 
name */
malType type;   /* internal type signature */
-   short flags;/* see below, reserve 
some space */
+unsigned short constant:1,
+typevar:1,
+fixedtype:1,
+udftype:1,
+cleanup:1,
+initialized:1,
+used:1,
+disabled:1;
short depth;/* scope block depth, set to -1 
if not used */
short worker;   /* thread id of last worker 
producing it */
ValRecord value;
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -1228,7 +1228,7 @@ printStackElm(stream *f, MalBlkPtr mb, V
if (strcmp(nmeOnStk, nme) && strncmp(nmeOnStk, "BAT", 3))
mnstr_printf(f, "!%s ", nmeOnStk);
mnstr_printf(f, " %s", (isVarConstant(mb, index) ? " constant" : ""));
-   /* mnstr_printf(f, " %s", (isVarUsed(mb,index) ? "": " not used" ));*/
+   mnstr_printf(f, " %s", (isVarUsed(mb,index) ? "": " not used" ));
mnstr_printf(f, " %s", (isVarTypedef(mb, index) ? " type variable" : 
""));
GDKfree(nme);
mnstr_printf(f, "\n");
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -629,6 +629,10 @@ setVariableScope(MalBlkPtr mb)
dflow= -1;
else depth--;
}
+   if( blockReturn(p)){
+   for (k = 0; k < p->argc; k++)
+   setVarEolife(mb,getArg(p,k),pc);
+   }
}
for (k = 0; k < mb->vtop; k++)
if( getVarEolife(mb,k) == 0)
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -768,7 +768,13 @@ clearVariable(MalBlkPtr mb, int varid)
if (isVarConstant(mb, varid) || isVarDisabled(mb, varid))
VALclear(>value);
v->type = 0;
-   v->flags = 0;
+   v->constant= 0;
+   v->typevar= 0;  
+   v->fixedtype= 0;
+   v->udftype= 0;
+   v->cleanup= 0;
+   v->initialized= 0;
+   v->used= 0;
v->rowcnt = 0;
v->eolife = 0;
v->stc = 0;
diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h
--- a/monetdb5/mal/mal_instruction.h
+++ b/monetdb5/mal/mal_instruction.h
@@ -51,38 +51,39 @@
 #define getVarGDKType(M,I) getGDKType((M)->var[I].type)
 #define setVarType(M,I,V)   (M)->var[I].type = V
 
-#define clrVarFixed(M,I)   ((M)->var[I].flags &= ~VAR_FIXTYPE)
-#define setVarFixed(M,I)   ((M)->var[I].flags |= VAR_FIXTYPE)
-#define isVarFixed(M,I)((M)->var[I].flags & VAR_FIXTYPE)
+#define clrVarFixed(M,I)   ((M)->var[I].fixedtype = 0)
+#define setVarFixed(M,I)   ((M)->var[I].fixedtype =1)
+#define isVarFixed(M,I)((M)->var[I].fixedtype)
 
-#define clrVarCleanup(M,I) ((M)->var[I].flags &= ~VAR_CLEANUP)
-#define setVarCleanup(M,I) ((M)->var[I].flags |= VAR_CLEANUP)
-#define isVarCleanup(M,I)  ((M)->var[I].flags & VAR_CLEANUP)
+#define clrVarCleanup(M,I) ((M)->var[I].cleanup = 0)
+#define setVarCleanup(M,I) ((M)->var[I].cleanup = 1)
+#define isVarCleanup(M,I)  ((M)->var[I].cleanup )
+
 #define isTmpVar(M,I)  (*getVarName(M,I) == REFMARKER && 
*(getVarName(M,I)+1) == TMPMARKER)
 
-#define clrVarUsed(M,I)((M)->var[I].flags &= ~VAR_USED)
-#define setVarUsed(M,I)((M)->var[I].flags |= VAR_USED)
-#define isVarUsed(M,I) ((M)->var[I].flags & VAR_USED)
+#define clrVarUsed(M,I)((M)->var[I].used = 0)
+#define setVarUsed(M,I)((M)->var[I].used = 1)
+#define isVarUsed(M,I) ((M)->var[I].used)
 
-#define clrVarDisabled(M,I)((M)->var[I].flags &= ~VAR_DISABLED)
-#define setVarDisabled(M,I)((M)->var[I].flags |= VAR_DISABLED)
-#define isVarDisabled(M,I) ((M)->var[I].flags & VAR_DISABLED)
+#define clrVarDisabled(M,I)((M)->var[I].disabled= 0 )

MonetDB: default - Simplify code.

2016-09-21 Thread Sjoerd Mullender
Changeset: e6e32756ad31 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e6e32756ad31
Modified Files:
monetdb5/modules/kernel/bat5.c
Branch: default
Log Message:

Simplify code.


diffs (38 lines):

diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -216,27 +216,18 @@ BKCmirror(bat *ret, const bat *bid)
 {
BAT *b, *bn;
 
+   *ret = 0;
if ((b = BATdescriptor(*bid)) == NULL) {
throw(MAL, "bat.mirror", RUNTIME_OBJECT_MISSING);
}
bn = BATdense(b->hseqbase, b->hseqbase, BATcount(b));
-   if (bn != NULL) {
-   if (b->batRestricted == BAT_WRITE) {
-   BAT *bn1;
-   bn1 = COLcopy(bn, bn->ttype, FALSE, TRANSIENT);
-   BBPreclaim(bn);
-   bn = bn1;
-   }
-   if (bn != NULL) {
-   *ret = bn->batCacheid;
-   BBPkeepref(*ret);
-   BBPunfix(b->batCacheid);
-   return MAL_SUCCEED;
-   }
+   BBPunfix(b->batCacheid);
+   if (bn == NULL) {
+   throw(MAL, "bat.mirror", GDK_EXCEPTION);
}
-   *ret = 0;
-   BBPunfix(b->batCacheid);
-   throw(MAL, "bat.mirror", GDK_EXCEPTION);
+   *ret = bn->batCacheid;
+   BBPkeepref(*ret);
+   return MAL_SUCCEED;
 }
 
 char *
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Simplify code.

2015-05-13 Thread Sjoerd Mullender
Changeset: cd4fcb470704 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cd4fcb470704
Modified Files:
clients/mapiclient/tomograph.c
Branch: default
Log Message:

Simplify code.


diffs (41 lines):

diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -1722,12 +1722,16 @@ main(int argc, char **argv)
}
 
fprintf(stderr,-- Stop capturing with cntrl-c or after %d 
pages\n,atlas);
-   if (cache)
+   if (cache) {
+   snprintf(cachebuf,BUFSIZ,%s%c,cache, DIR_SEP);
 #ifdef NATIVE_WIN32
-   snprintf(cachebuf,BUFSIZ,%s\\,cache);
-#else
-   snprintf(cachebuf,BUFSIZ,%s/,cache);
+#define mkdir(d,m) _mkdir(d)
 #endif
+   if( mkdir(cache,0755)  0  errno != EEXIST) {
+   fprintf(stderr,Failed to create cache '%s'\n,cache);
+   exit(-1);
+   }
+   }
initcolors();
resetTomograph();
 
@@ -1758,16 +1762,6 @@ main(int argc, char **argv)
close(0);
 
/* reprocess an existing profiler trace, possibly producing the trace 
split   */
-   if (cache) {
-#ifdef NATIVE_WIN32
-   if( _mkdir(cache)  0  errno != EEXIST){
-#else
-   if( mkdir(cache,0755)   0  errno != EEXIST) {
-#endif
-   fprintf(stderr,Failed to create cache '%s'\n,cache);
-   exit(-1);
-   }
-   }
snprintf(buf,BUFSIZ,%s%s_%s_%02d.trace, cachebuf, basefilename, 
DBNAME, atlaspage);
if (inputfile==0 || strcmp(buf, inputfile) ){
// avoid overwriting yourself
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Simplify code and deal with speed

2012-08-23 Thread Martin Kersten
Changeset: d6e1922722b6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d6e1922722b6
Modified Files:
sql/backends/monet5/datacell/Tests/emili.sql
Branch: default
Log Message:

Simplify code and deal with speed
When there are many events arriving within a cycle,
we triggered primary key violations.
The current code is a simplified version


diffs (88 lines):

diff --git a/sql/backends/monet5/datacell/Tests/emili.sql 
b/sql/backends/monet5/datacell/Tests/emili.sql
--- a/sql/backends/monet5/datacell/Tests/emili.sql
+++ b/sql/backends/monet5/datacell/Tests/emili.sql
@@ -46,18 +46,19 @@ CALL datacell.receptor('datacell.observa
 CREATE PROCEDURE datacell.enrich()
 BEGIN
DECLARE cnt INTEGER;
-   SET cnt = (SELECT count(distinct I.ip) FROM datacell.area A, 
datacell.istream I WHERE A.location = substring(I.location,0,3) ) ;
+
INSERT INTO datacell.sensors(ip, location, kind,value) 
SELECT ip, substring(location,0,3), kind, value FROM 
datacell.istream;
-   IF cnt = 0
-   THEN
-   INSERT INTO datacell.area SELECT ip, substring(location,0,3) 
FROM datacell.istream;
-   END IF;
-   SET cnt = (SELECT count(distinct I.ip) FROM datacell.states A, 
datacell.istream I WHERE A.location = substring(I.location,0,3) ) ;
-   IF cnt = 0
-   THEN
-   INSERT INTO datacell.states SELECT substring(location,0,3), 
now(), 'normal' FROM datacell.istream;
-   END IF;
+
+   INSERT INTO datacell.area 
+   SELECT DISTINCT I.ip, substring(I.location,0,3) 
+   FROM datacell.istream I 
+   WHERE I.ip NOT IN (SELECT ip FROM datacell.area);
+
+   INSERT INTO datacell.states 
+   SELECT DISTINCT substring(location,0,3), now(), 'normal' 
+   FROM datacell.istream
+   WHERE substring(location,0,3) NOT IN (SELECT location FROM 
datacell.states);
 END;
 CALL datacell.query('datacell.enrich');
 
@@ -97,40 +98,26 @@ call datacell.query('datacell.splitter')
 -- unconfirmed fire detection based 
 CREATE PROCEDURE datacell.firewarning()
 BEGIN
-   DECLARE cnt INTEGER;
-
-   SET cnt = ( SELECT count(*)
-   FROM datacell.states S, datacell.area A, datacell.hotsensors1 H
-   WHERE S.status ='normal' AND A.ip = H.ip and S.location = 
A.location);
-
-   IF cnt =1 
-   THEN
-   UPDATE datacell.states
-   SET status = 'unconfirmed', time = now()
-   WHERE location IN (SELECT A.location
-   FROM datacell.states S, datacell.area A, 
datacell.hotsensors1 H
-   WHERE S.status ='normal' AND A.ip = H.ip and 
S.location = A.location));
-   END IF;
+   UPDATE datacell.states
+   SET status = 'unconfirmed', time = now()
+   WHERE location IN (SELECT A.location
+   FROM datacell.states S, datacell.area A, 
datacell.hotsensors1 H
+   WHERE S.status ='normal' AND A.ip = H.ip and S.location 
= A.location));
 END;
 CALL datacell.query('datacell.firewarning');
 
 -- autoconfirm the fire warning 
 CREATE PROCEDURE datacell.firespotted()
 BEGIN
-   DECLARE cnt INTEGER;
-
-   SET cnt = ( SELECT count(*)
-   FROM datacell.area A, datacell.states S,  datacell.area B, 
datacell.hotsensors2 H
-   WHERE S.status ='unconfirmed' AND A.ip  H.ip AND B.ip = H.ip 
AND A.ip  B.ip AND S.location = A.location);
-
-   IF cnt =1 
-   THEN
-   UPDATE datacell.states
-   SET status = 'confirmed', time = now()
-   WHERE location IN (SELECT A.location
-   FROM datacell.states S, datacell.area A, 
datacell.hotsensors1 H
-   WHERE S.status ='unconfirmed' AND A.ip = H.ip 
and S.location = A.location));
-   END IF;
+   UPDATE datacell.states
+   SET status = 'confirmed', time = now()
+   WHERE location IN (SELECT A.location
+   FROM datacell.states S, datacell.area A, datacell.area 
B, datacell.hotsensors1 H
+   WHERE S.status ='unconfirmed' 
+   AND A.ip = H.ip 
+   AND A.ip  B.ip 
+   AND S.location = A.location
+   AND S.location = B.location));
 END;
 CALL datacell.query('datacell.firespotted');
 
___
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list