Changeset: 9d75acab2037 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d75acab2037
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/modules/kernel/alarm.c
monetdb5/modules/kernel/alarm.mal
monetdb5/modules/mal/clients.c
monetdb5/modules/mal/sysmon.c
sql/backends/monet5/sql_upgrades.c
sql/scripts/22_clients.sql
sql/scripts/25_debug.sql
sql/scripts/26_sysmon.sql
sql/test/Users/Tests/sessioncontrol.stable.err
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:
Merged with linear-hashing
diffs (truncated from 1008 to 300 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -565,9 +565,9 @@ stdout of test 'MAL-signatures` in direc
[ "aggr", "variancep", "command aggr.variancep(b:bat[:any_2]):dbl ",
"ALGvariancep;", "Gives the variance of all tail values" ]
[ "alarm", "ctime", "unsafe command alarm.ctime():str ",
"ALARMctime;", "Return the current time as a C-time string." ]
[ "alarm", "epoch", "unsafe command alarm.epoch():int ",
"ALARMepoch;", "Return time since Jan 1, 1970 in seconds." ]
-[ "alarm", "sleep", "unsafe pattern
alarm.sleep(msecs:bat[:int]):bat[:int] ", "ALARMsleep;", "Sleep a few
milliseconds and return the slept value" ]
-[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:int):int ",
"ALARMsleep;", "Sleep a few milliseconds and return the slept value" ]
-[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:int):void ",
"ALARMsleep;", "Sleep a few milliseconds" ]
+[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:any_1):any_1
", "ALARMsleep;", "Sleep a few milliseconds and return the slept value"
]
+[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:any_1):void
", "ALARMsleep;", "Sleep a few milliseconds" ]
+[ "alarm", "sleep", "unsafe pattern
alarm.sleep(msecs:bat[:any_1]):bat[:any_1] ", "ALARMsleep;", "Sleep a few
milliseconds and return the slept value" ]
[ "alarm", "time", "unsafe command alarm.time():int ", "ALARMtime;",
"Return time since program start in milliseconds." ]
[ "alarm", "usec", "unsafe command alarm.usec():lng ", "ALARMusec;",
"Return time since Jan 1, 1970 in microseconds." ]
[ "algebra", "antijoin", "function algebra.antijoin(l:bat[:any_1],
r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng)
(X_0:bat[:oid], X_1:bat[:oid]);", "", "" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -674,9 +674,9 @@ stdout of test 'MAL-signatures` in direc
[ "aggr", "variancep", "command aggr.variancep(b:bat[:any_2]):dbl ",
"ALGvariancep;", "Gives the variance of all tail values" ]
[ "alarm", "ctime", "unsafe command alarm.ctime():str ",
"ALARMctime;", "Return the current time as a C-time string." ]
[ "alarm", "epoch", "unsafe command alarm.epoch():int ",
"ALARMepoch;", "Return time since Jan 1, 1970 in seconds." ]
-[ "alarm", "sleep", "unsafe pattern
alarm.sleep(msecs:bat[:int]):bat[:int] ", "ALARMsleep;", "Sleep a few
milliseconds and return the slept value" ]
-[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:int):int ",
"ALARMsleep;", "Sleep a few milliseconds and return the slept value" ]
-[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:int):void ",
"ALARMsleep;", "Sleep a few milliseconds" ]
+[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:any_1):any_1
", "ALARMsleep;", "Sleep a few milliseconds and return the slept value"
]
+[ "alarm", "sleep", "unsafe pattern alarm.sleep(msecs:any_1):void
", "ALARMsleep;", "Sleep a few milliseconds" ]
+[ "alarm", "sleep", "unsafe pattern
alarm.sleep(msecs:bat[:any_1]):bat[:any_1] ", "ALARMsleep;", "Sleep a few
milliseconds and return the slept value" ]
[ "alarm", "time", "unsafe command alarm.time():int ", "ALARMtime;",
"Return time since program start in milliseconds." ]
[ "alarm", "usec", "unsafe command alarm.usec():lng ", "ALARMusec;",
"Return time since Jan 1, 1970 in microseconds." ]
[ "algebra", "antijoin", "function algebra.antijoin(l:bat[:any_1],
r:bat[:any_1], sl:bat[:oid], sr:bat[:oid], nil_matches:bit, estimate:lng)
(X_0:bat[:oid], X_1:bat[:oid]);", "", "" ]
diff --git a/monetdb5/modules/kernel/alarm.c b/monetdb5/modules/kernel/alarm.c
--- a/monetdb5/modules/kernel/alarm.c
+++ b/monetdb5/modules/kernel/alarm.c
@@ -39,57 +39,95 @@ ALARMusec(lng *ret)
return MAL_SUCCEED;
}
+#define SLEEP_SINGLE(TPE) \
+ do { \
+ TPE *res = (TPE*) getArgReference(stk, pci, 0), *msecs = (TPE*)
getArgReference(stk,pci,1); \
+ if (is_##TPE##_nil(*msecs)) \
+ throw(MAL, "alarm.sleepr", "NULL values not allowed for
sleeping time"); \
+ if (*msecs < 0) \
+ throw(MAL, "alarm.sleepr", "Cannot sleep for a negative
time"); \
+ MT_sleep_ms((unsigned int) *msecs); \
+ *res = *msecs; \
+ } while (0)
+
+#define SLEEP_MULTI(TPE) \
+ do { \
+ for (i = 0; i < j ; i++) { \
+ if (is_##TPE##_nil(bb[i])) { \
+ BBPreclaim(r); \
+ BBPunfix(b->batCacheid); \
+ throw(MAL, "alarm.sleepr", "NULL values not
allowed for sleeping time"); \
+ } \
+ if (bb[i] < 0) { \
+ BBPreclaim(r); \
+ BBPunfix(b->batCacheid); \
+ throw(MAL, "alarm.sleepr", "Cannot sleep for a
negative time"); \
+ } \
+ } \
+ for (i = 0; i < j ; i++) { \
+ MT_sleep_ms((unsigned int) bb[i]); \
+ rb[i] = bb[i]; \
+ } \
+ } while (0)
+
str
ALARMsleep(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- BAT *r, *b;
- int *restrict rb, *restrict bb;
+ BAT *r = NULL, *b = NULL;
+ int *restrict rb, *restrict bb, tpe;
BUN i, j;
(void) cntxt;
if (getArgType(mb, pci, 0) != TYPE_void && isaBatType(getArgType(mb,
pci, 1))) {
bat *res = getArgReference_bat(stk, pci, 0);
bat *bid = getArgReference_bat(stk, pci, 1);
-
+ tpe = getArgType(mb, pci, 1);
+
if (!(b = BATdescriptor(*bid)))
throw(MAL, "alarm.sleepr", SQLSTATE(HY005) "Cannot
access column descriptor");
j = BATcount(b);
bb = Tloc(b, 0);
- for (i = 0; i < j ; i++) {
- if (is_int_nil(bb[i])) {
- BBPunfix(b->batCacheid);
- throw(MAL, "alarm.sleepr", "NULL values not
allowed for the sleeping time");
- } else if (bb[i]) {
- BBPunfix(b->batCacheid);
- throw(MAL, "alarm.sleepr", "Cannot sleep for a
negative time");
- }
- }
- r = COLnew(0, TYPE_int, j, TRANSIENT);
- if (r == NULL) {
+ if (!(r = COLnew(0, tpe, j, TRANSIENT))) {
BBPunfix(b->batCacheid);
throw(MAL, "alarm.sleepr", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
}
+ rb = Tloc(r, 0);
- rb = Tloc(r, 0);
- for (i = 0; i < j ; i++) {
- MT_sleep_ms(bb[i]);
- rb[i] = bb[i];
+ switch (tpe) {
+ case TYPE_bte:
+ SLEEP_MULTI(bte);
+ break;
+ case TYPE_sht:
+ SLEEP_MULTI(sht);
+ break;
+ case TYPE_int:
+ SLEEP_MULTI(int);
+ break;
+ default: {
+ BBPreclaim(r);
+ BBPunfix(b->batCacheid);
+ throw(MAL, "alarm.sleepr", SQLSTATE(42000)
"Sleep function not available for type %s", ATOMname(tpe));
+ }
}
BBPunfix(b->batCacheid);
BBPkeepref(*res = r->batCacheid);
} else {
- int *res = (int*) getArgReference(stk, pci, 0), *msecs = (int*)
getArgReference(stk,pci,1);
-
- if (is_int_nil(*msecs))
- throw(MAL, "alarm.sleepr", "NULL values not allowed for
the sleeping time");
- else if (*msecs < 0)
- throw(MAL, "alarm.sleepr", "Cannot sleep for a negative
time");
-
- MT_sleep_ms(*msecs);
- *res = *msecs;
+ switch (getArgType(mb, pci, 1)) {
+ case TYPE_bte:
+ SLEEP_SINGLE(bte);
+ break;
+ case TYPE_sht:
+ SLEEP_SINGLE(sht);
+ break;
+ case TYPE_int:
+ SLEEP_SINGLE(int);
+ break;
+ default:
+ throw(MAL, "alarm.sleepr", SQLSTATE(42000)
"Sleep function not available for type %s", ATOMname(getArgType(mb, pci, 1)));
+ }
}
return MAL_SUCCEED;
}
diff --git a/monetdb5/modules/kernel/alarm.mal
b/monetdb5/modules/kernel/alarm.mal
--- a/monetdb5/modules/kernel/alarm.mal
+++ b/monetdb5/modules/kernel/alarm.mal
@@ -6,15 +6,15 @@
module alarm;
-unsafe pattern alarm.sleep(msecs:int) :void
+unsafe pattern alarm.sleep(msecs:any_1) :void
address ALARMsleep
comment "Sleep a few milliseconds";
-unsafe pattern alarm.sleep(msecs:int) :int
+unsafe pattern alarm.sleep(msecs:any_1) :any_1
address ALARMsleep
comment "Sleep a few milliseconds and return the slept value";
-unsafe pattern alarm.sleep(msecs:bat[:int]) :bat[:int]
+unsafe pattern alarm.sleep(msecs:bat[:any_1]) :bat[:any_1]
address ALARMsleep
comment "Sleep a few milliseconds and return the slept value";
diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c
--- a/monetdb5/modules/mal/clients.c
+++ b/monetdb5/modules/mal/clients.c
@@ -267,8 +267,10 @@ CLTsetworkerlimit(Client cntxt, MalBlkPt
if( idx < 0 || idx > MAL_MAXCLIENTS)
throw(MAL,"clients.setworkerlimit","Illegal session id");
+ if( is_int_nil(limit))
+ throw(MAL, "clients.setworkerlimit","The number of workers
cannot be NULL");
if( limit < 0)
- throw(MAL, "clients.setworkerlimit", "At least one worker
needed");
+ throw(MAL, "clients.setworkerlimit","The number of workers
cannot be negative");
if (mal_clients[idx].mode == FREECLIENT)
throw(MAL,"clients.setworkerlimit","Session not active
anymore");
if (cntxt->user == mal_clients[idx].user || cntxt->user == MAL_ADMIN){
@@ -295,6 +297,10 @@ CLTsetmemorylimit(Client cntxt, MalBlkPt
throw(MAL,"clients.setmemorylimit","Illegal session id");
if (mal_clients[idx].mode == FREECLIENT)
throw(MAL,"clients.setmemorylimit","Session not active
anymore");
+ if( is_int_nil(limit))
+ throw(MAL, "clients.setmemorylimit", "The memmory limit cannot
be NULL");
+ if( limit < 0)
+ throw(MAL, "clients.setmemorylimit", "The memmory limit cannot
be negative");
if (cntxt->user == mal_clients[idx].user || cntxt->user == MAL_ADMIN){
mal_clients[idx].memorylimit = limit;
}
@@ -366,7 +372,9 @@ CLTsetSessionTimeout(Client cntxt, MalBl
throw(MAL,"clients.setsession","Illegal session id %d", idx);
if (mal_clients[idx].mode == FREECLIENT)
throw(MAL,"clients.setsession","Session not active anymore");
- sto = *getArgReference_lng(stk,pci,1);
+ sto = *getArgReference_lng(stk,pci,1);
+ if (is_lng_nil(sto))
+ throw(MAL,"clients.setsession","Session timeout cannot be
NULL");
if (sto < 0)
throw(MAL,"clients.setsession","Session timeout should be >=
0");
mal_clients[idx].sessiontimeout = sto * 1000000;
@@ -386,10 +394,14 @@ CLTsetTimeout(Client cntxt, MalBlkPtr mb
if (mal_clients[idx].mode == FREECLIENT)
throw(MAL,"clients.settimeout","Session not active anymore");
qto = *getArgReference_lng(stk,pci,1);
+ if (is_lng_nil(qto))
+ throw(MAL,"clients.settimeout","Query timeout cannot be NULL");
if (qto < 0)
throw(MAL,"clients.settimeout","Query timeout should be >= 0");
if (pci->argc == 3) {
sto = *getArgReference_lng(stk,pci,2);
+ if (is_lng_nil(sto))
+ throw(MAL,"clients.settimeout","Session timeout cannot
be NULL");
if( sto < 0)
throw(MAL,"clients.settimeout","Session timeout should
be >= 0");
mal_clients[idx].sessiontimeout = sto * 1000000;
@@ -424,8 +436,10 @@ CLTqueryTimeout(Client cntxt, MalBlkPtr
idx = cntxt->idx;
qto= *getArgReference_int(stk,pci,1);
}
+ if (is_int_nil(qto))
+ throw(MAL,"clients.queryTimeout","Query timeout cannot be
NULL");
if( qto < 0)
- throw(MAL,"clients.queryTimeout","Query time-out should be >=
0");
+ throw(MAL,"clients.queryTimeout","Query timeout should be >=
0");
mal_clients[idx].querytimeout = (lng) qto * 1000000;
return MAL_SUCCEED;
}
@@ -456,8 +470,10 @@ CLTsessionTimeout(Client cntxt, MalBlkPt
idx = cntxt->idx;
sto = *getArgReference_int(stk,pci,1);
}
+ if (is_lng_nil(sto))
+ throw(MAL,"clients.sessionTimeout","Session timeout cannot be
NULL");
if( sto < 0)
- throw(MAL,"clients.sessionTimeout","Session time-out should be
>= 0");
+ throw(MAL,"clients.sessionTimeout","Session timeout should be
>= 0");
if( idx < 0 || idx > MAL_MAXCLIENTS)
throw(MAL,"clients.sessionTimeout","Illegal session id %d",
idx);
if (mal_clients[idx].mode == FREECLIENT)
@@ -749,10 +765,12 @@ CLTshutdown(Client cntxt, MalBlkPtr mb,
if (cntxt->user != MAL_ADMIN)
throw(MAL,"mal.shutdown", "Administrator rights required");
+ if (is_int_nil(delay))
+ throw(MAL,"mal.shutdown", "Delay cannot be NULL");
if (delay < 0)
throw(MAL,"mal.shutdown", "Delay cannot be negative");
if (is_bit_nil(force))
- throw(MAL,"mal.shutdown", "Force cannot be null");
+ throw(MAL,"mal.shutdown", "Force cannot be NULL");
MCstopClients(cntxt);
do{
if ( (leftover = MCactiveClients()-1) )
@@ -837,11 +855,14 @@ CLTsessions(Client cntxt, MalBlkPtr mb,
timeout = (int)(c->querytimeout / 1000000);
if (BUNappend(querytimeout, &timeout, false) !=
GDK_SUCCEED)
goto bailout;
- ret = timestamp_fromtime(c->idle);
- if (is_timestamp_nil(ret)) {
- msg = createException(SQL, "sql.sessions",
SQLSTATE(22003) "Failed to convert user logged time");
- goto bailout;
- }
+ if( c->idle){
+ ret = timestamp_fromtime(c->idle);
+ if (is_timestamp_nil(ret)) {
+ msg = createException(SQL,
"sql.sessions", SQLSTATE(22003) "Failed to convert user logged time");
+ goto bailout;
+ }
+ } else
+ ret = timestamp_nil;
if (BUNappend(idle, &ret, false) != GDK_SUCCEED)
goto bailout;
if (BUNappend(opt, &c->optimizer, false) != GDK_SUCCEED)
diff --git a/monetdb5/modules/mal/sysmon.c b/monetdb5/modules/mal/sysmon.c
--- a/monetdb5/modules/mal/sysmon.c
+++ b/monetdb5/modules/mal/sysmon.c
@@ -129,7 +129,9 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb,
str
SYSMONpause(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
-{ lng i, tag = 0;
+{
+ bool set = false;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list