Changeset: ff7eed7b63cd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ff7eed7b63cd
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
monetdb5/modules/mal/clients.c
Branch: default
Log Message:
Cleanup some interfaces and checks.
The session id is always an INTEGER, so get rid of the BTE and SHT
variants; don't ignore administrator-only argument if not administrator,
throw an error instead.
diffs (truncated from 457 to 300 lines):
diff --git a/clients/Tests/MAL-signatures-hge.test
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -43895,11 +43895,6 @@ CLTsetPrintTimeout;
Print running query every so many seconds.
clients
setquerytimeout
-unsafe pattern clients.setquerytimeout(X_0:bte, X_1:int):void
-CLTqueryTimeout;
-(empty)
-clients
-setquerytimeout
unsafe pattern clients.setquerytimeout(X_0:int):void
CLTqueryTimeout;
(empty)
@@ -43909,22 +43904,12 @@ unsafe pattern clients.setquerytimeout(X
CLTqueryTimeout;
A query is aborted after q seconds (q=0 means run undisturbed).
clients
-setquerytimeout
-unsafe pattern clients.setquerytimeout(X_0:sht, X_1:int):void
-CLTqueryTimeout;
-(empty)
-clients
setsession
unsafe pattern clients.setsession(X_0:lng):void
CLTsetSessionTimeout;
Abort a session after n seconds.
clients
setsessiontimeout
-unsafe pattern clients.setsessiontimeout(X_0:bte, X_1:int):void
-CLTsessionTimeout;
-(empty)
-clients
-setsessiontimeout
unsafe pattern clients.setsessiontimeout(X_0:int):void
CLTsessionTimeout;
(empty)
@@ -43934,11 +43919,6 @@ unsafe pattern clients.setsessiontimeout
CLTsessionTimeout;
Set the session timeout for a particulat session id
clients
-setsessiontimeout
-unsafe pattern clients.setsessiontimeout(X_0:sht, X_1:int):void
-CLTsessionTimeout;
-(empty)
-clients
settimeout
unsafe pattern clients.settimeout(X_0:lng):void
CLTsetTimeout;
@@ -43970,12 +43950,12 @@ CLTsha2sum;
Return hex string representation of the SHA-2 hash with bits of the given
string
clients
shutdown
-unsafe pattern clients.shutdown(X_0:int):str
+unsafe pattern clients.shutdown(X_0:bte):str
CLTshutdown;
(empty)
clients
shutdown
-unsafe pattern clients.shutdown(X_0:int, X_1:bit):str
+unsafe pattern clients.shutdown(X_0:bte, X_1:bit):str
CLTshutdown;
Close all other client connections. Return if it succeeds.@If forced is set
then always stop the system the hard way
clients
@@ -43985,20 +43965,10 @@ CLTstop;
Stop the query execution at the next eligble statement.
clients
stopsession
-unsafe pattern clients.stopsession(X_0:bte):void
-CLTstopSession;
-(empty)
-clients
-stopsession
unsafe pattern clients.stopsession(X_0:int):void
CLTstopSession;
Stop a particular session
clients
-stopsession
-unsafe pattern clients.stopsession(X_0:sht):void
-CLTstopSession;
-(empty)
-clients
suspend
unsafe pattern clients.suspend(X_0:int):void
CLTsuspend;
diff --git a/clients/Tests/MAL-signatures.test
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -32390,11 +32390,6 @@ CLTsetPrintTimeout;
Print running query every so many seconds.
clients
setquerytimeout
-unsafe pattern clients.setquerytimeout(X_0:bte, X_1:int):void
-CLTqueryTimeout;
-(empty)
-clients
-setquerytimeout
unsafe pattern clients.setquerytimeout(X_0:int):void
CLTqueryTimeout;
(empty)
@@ -32404,22 +32399,12 @@ unsafe pattern clients.setquerytimeout(X
CLTqueryTimeout;
A query is aborted after q seconds (q=0 means run undisturbed).
clients
-setquerytimeout
-unsafe pattern clients.setquerytimeout(X_0:sht, X_1:int):void
-CLTqueryTimeout;
-(empty)
-clients
setsession
unsafe pattern clients.setsession(X_0:lng):void
CLTsetSessionTimeout;
Abort a session after n seconds.
clients
setsessiontimeout
-unsafe pattern clients.setsessiontimeout(X_0:bte, X_1:int):void
-CLTsessionTimeout;
-(empty)
-clients
-setsessiontimeout
unsafe pattern clients.setsessiontimeout(X_0:int):void
CLTsessionTimeout;
(empty)
@@ -32429,11 +32414,6 @@ unsafe pattern clients.setsessiontimeout
CLTsessionTimeout;
Set the session timeout for a particulat session id
clients
-setsessiontimeout
-unsafe pattern clients.setsessiontimeout(X_0:sht, X_1:int):void
-CLTsessionTimeout;
-(empty)
-clients
settimeout
unsafe pattern clients.settimeout(X_0:lng):void
CLTsetTimeout;
@@ -32465,12 +32445,12 @@ CLTsha2sum;
Return hex string representation of the SHA-2 hash with bits of the given
string
clients
shutdown
-unsafe pattern clients.shutdown(X_0:int):str
+unsafe pattern clients.shutdown(X_0:bte):str
CLTshutdown;
(empty)
clients
shutdown
-unsafe pattern clients.shutdown(X_0:int, X_1:bit):str
+unsafe pattern clients.shutdown(X_0:bte, X_1:bit):str
CLTshutdown;
Close all other client connections. Return if it succeeds.@If forced is set
then always stop the system the hard way
clients
@@ -32480,20 +32460,10 @@ CLTstop;
Stop the query execution at the next eligble statement.
clients
stopsession
-unsafe pattern clients.stopsession(X_0:bte):void
-CLTstopSession;
-(empty)
-clients
-stopsession
unsafe pattern clients.stopsession(X_0:int):void
CLTstopSession;
Stop a particular session
clients
-stopsession
-unsafe pattern clients.stopsession(X_0:sht):void
-CLTstopSession;
-(empty)
-clients
suspend
unsafe pattern clients.suspend(X_0:int):void
CLTsuspend;
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
@@ -192,8 +192,12 @@ CLTquit(Client cntxt, MalBlkPtr mb, MalS
int idx = cntxt->idx;
(void) mb; /* fool compiler */
- if ( pci->argc == 2 && cntxt->user == MAL_ADMIN)
- idx = *getArgReference_int(stk,pci,1);
+ if (pci->argc == 2) {
+ if (cntxt->user == MAL_ADMIN)
+ idx = *getArgReference_int(stk,pci,1);
+ else
+ throw(MAL, "clients.quit", SQLSTATE(42000)
"Administrator rights required");
+ }
if ( idx < 0 || idx > MAL_MAXCLIENTS)
throw(MAL,"clients.quit", "Illegal session id");
@@ -208,7 +212,7 @@ CLTquit(Client cntxt, MalBlkPtr mb, MalS
return msg;
}
-/* Stopping a client in a softmanner by setting the time out marker */
+/* Stopping a client in a soft manner by setting the time out marker */
static str
CLTstop(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
@@ -216,8 +220,10 @@ CLTstop(Client cntxt, MalBlkPtr mb, MalS
str msg = MAL_SUCCEED;
(void) mb;
- if (cntxt->user == MAL_ADMIN)
- idx = *getArgReference_int(stk,pci,1);
+ if (cntxt->user != MAL_ADMIN)
+ throw(MAL, "clients.stop", SQLSTATE(42000) "Administrator
rights required");
+
+ idx = *getArgReference_int(stk,pci,1);
if ( idx < 0 || idx > MAL_MAXCLIENTS)
throw(MAL,"clients.stop","Illegal session id");
@@ -239,9 +245,13 @@ CLTsetoptimizer(Client cntxt, MalBlkPtr
str opt, msg = MAL_SUCCEED;
(void) mb;
- if( pci->argc == 3 && cntxt->user == MAL_ADMIN){
- idx = *getArgReference_int(stk,pci,1);
- opt = *getArgReference_str(stk,pci,2);
+ if (pci->argc == 3) {
+ if (cntxt->user == MAL_ADMIN){
+ idx = *getArgReference_int(stk,pci,1);
+ opt = *getArgReference_str(stk,pci,2);
+ } else {
+ throw(MAL, "clients.setoptimizer", SQLSTATE(42000)
"Administrator rights required");
+ }
} else {
opt = *getArgReference_str(stk,pci,1);
}
@@ -271,9 +281,13 @@ CLTsetworkerlimit(Client cntxt, MalBlkPt
int idx = cntxt->idx, limit;
(void) mb;
- if (pci->argc == 3 && cntxt->user == MAL_ADMIN){
- idx = *getArgReference_int(stk,pci,1);
- limit = *getArgReference_int(stk,pci,2);
+ if (pci->argc == 3) {
+ if (cntxt->user == MAL_ADMIN) {
+ idx = *getArgReference_int(stk,pci,1);
+ limit = *getArgReference_int(stk,pci,2);
+ } else {
+ throw(MAL, "clients.setworkerlimit", SQLSTATE(42000)
"Administrator rights required");
+ }
} else {
limit = *getArgReference_int(stk,pci,1);
}
@@ -301,9 +315,13 @@ CLTsetmemorylimit(Client cntxt, MalBlkPt
int idx = cntxt->idx, limit;
(void) mb;
- if (pci->argc == 3 && cntxt->user == MAL_ADMIN){
- idx = *getArgReference_sht(stk,pci,1);
- limit = *getArgReference_int(stk,pci,2);
+ if (pci->argc == 3) {
+ if (cntxt->user == MAL_ADMIN) {
+ idx = *getArgReference_sht(stk,pci,1);
+ limit = *getArgReference_int(stk,pci,2);
+ } else {
+ throw(MAL, "clients.setmemorylimit", SQLSTATE(42000)
"Administrator rights required");
+ }
} else {
limit = *getArgReference_int(stk,pci,1);
}
@@ -331,22 +349,12 @@ CLTstopSession(Client cntxt, MalBlkPtr m
{
str msg = MAL_SUCCEED;
int idx = cntxt->idx;
+ (void) mb;
- if (cntxt->user == MAL_ADMIN) {
- switch( getArgType(mb,pci,1)){
- case TYPE_bte:
- idx = *getArgReference_bte(stk,pci,1);
- break;
- case TYPE_sht:
- idx = *getArgReference_sht(stk,pci,1);
- break;
- case TYPE_int:
- idx = *getArgReference_int(stk,pci,1);
- break;
- default:
- throw(MAL,"clients.stopSession","Unexpected index
type");
- }
+ if (cntxt->user != MAL_ADMIN) {
+ throw(MAL, "clients.stopsession", SQLSTATE(42000)
"Administrator rights required");
}
+ idx = *getArgReference_int(stk,pci,1);
if( idx < 0 || idx > MAL_MAXCLIENTS)
throw(MAL,"clients.stopSession","Illegal session id");
@@ -369,8 +377,10 @@ CLTsuspend(Client cntxt, MalBlkPtr mb, M
str msg = MAL_SUCCEED;
int idx = cntxt->idx;
- if (cntxt->user == MAL_ADMIN)
- idx = *getArgReference_int(stk,pci,1);
+ if (cntxt->user != MAL_ADMIN)
+ throw(MAL, "clients.suspend", SQLSTATE(42000) "Administrator
rights required");
+
+ idx = *getArgReference_int(stk,pci,1);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]