Changeset: 9ac59b1a1597 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9ac59b1a1597
Added Files:
        sql/backends/monet5/sql_session.c
        sql/backends/monet5/sql_session.h
        sql/backends/monet5/sql_session.mal
        sql/test/Users/Tests/sessioncontrol.sql
Removed Files:
        sql/test/BugTracker-2016/Tests/set-negative-querytimeout.Bug-6070.sql
        
sql/test/BugTracker-2016/Tests/set-negative-querytimeout.Bug-6070.stable.err
        
sql/test/BugTracker-2016/Tests/set-negative-querytimeout.Bug-6070.stable.out
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_client.h
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_runtime.h
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/clients.mal
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_optimizer.c
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/22_clients.sql
        sql/test/BugTracker-2016/Tests/All
        sql/test/Users/Tests/All
        
sql/test/sys-schema/Tests/check_ForeignKey_referential_integrity.stable.out
        sql/test/sys-schema/Tests/systemfunctions.stable.out
        sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: sessions
Log Message:

Major revamp. See the documentation. Test included in 
sql/tests/Users/sessioncontrol


diffs (truncated from 1135 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
@@ -10750,34 +10750,40 @@ stdout of test 'MAL-signatures` in direc
 [ "clients",   "getLogins",    "command clients.getLogins() (user:bat[:oid], 
start:bat[:str]) ",       "CLTLogin;",    "Pseudo bat of client id and login 
time."       ]
 [ "clients",   "getPasswordHash",      "pattern 
clients.getPasswordHash(user:str):str ",       "CLTgetPasswordHash;",  "Return 
the password hash of the given user"    ]
 [ "clients",   "getScenario",  "pattern clients.getScenario():str ",   
"CLTgetScenario;",      "Retrieve current scenario name."       ]
-[ "clients",   "getTimeout",   "pattern clients.getTimeout() (q:lng, s:lng) ", 
"CLTgetTimeout;",       "A query is aborted after q milliseconds (q=0 means run 
undisturbed).\nThe session timeout aborts the connection after spending 
too\nmany seconds on query processing." ]
 [ "clients",   "getUsername",  "pattern clients.getUsername():str ",   
"CLTgetUsername;",      "Return the username of the currently logged in user"   
]
 [ "clients",   "getUsers",     "pattern clients.getUsers() (X_0:bat[:oid], 
X_1:bat[:str]) ",   "CLTgetUsers;", "return a BAT with user id and one with 
name available in the system"   ]
+[ "clients",   "getprofile",   "pattern clients.getprofile() (opt:str, q:int, 
s:int, w:int, m:int) ",  "CLTgetProfile;",       "Retrieve the profile settings 
for a client"    ]
 [ "clients",   "md5sum",       "command clients.md5sum(pw:str):str ",  
"CLTmd5sum;",   "Return hex string representation of the MD5 hash of the given 
string"  ]
-[ "clients",   "querytimeout", "pattern clients.querytimeout(sid:bte, 
n:lng):void ",   "CLTqueryTimeout;",     ""      ]
-[ "clients",   "querytimeout", "pattern clients.querytimeout(sid:int, 
n:lng):void ",   "CLTqueryTimeout;",     ""      ]
-[ "clients",   "querytimeout", "pattern clients.querytimeout(sid:sht, 
n:lng):void ",   "CLTqueryTimeout;",     ""      ]
 [ "clients",   "quit", "pattern clients.quit():void ", "CLTquit;",     
"Terminate the client session." ]
 [ "clients",   "quit", "pattern clients.quit(idx:int):void ",  "CLTquit;",     
"Terminate the session for a single client using a soft error.\nIt is the 
privilige of the console user."       ]
 [ "clients",   "removeUser",   "pattern clients.removeUser(nme:str):void ",    
"CLTremoveUser;",       "Remove the given user from the system" ]
 [ "clients",   "ripemd160sum", "command clients.ripemd160sum(pw:str):str ",    
"CLTripemd160sum;",     "Return hex string representation of the RIPEMD160 hash 
of the given string"    ]
-[ "clients",   "sessiontimeout",       "pattern 
clients.sessiontimeout(sid:bte, n:lng):void ", "CLTsessionTimeout;",   "Set the 
session timeout for a particulat session id"   ]
-[ "clients",   "sessiontimeout",       "pattern 
clients.sessiontimeout(sid:int, n:lng):void ", "CLTsessionTimeout;",   "Set the 
session timeout for a particulat session id"   ]
-[ "clients",   "sessiontimeout",       "pattern 
clients.sessiontimeout(sid:sht, n:lng):void ", "CLTsessionTimeout;",   "Set the 
session timeout for a particulat session id"   ]
 [ "clients",   "setListing",   "pattern clients.setListing(flag:int):int ",    
"CLTsetListing;",       "Turn on/off echo of MAL instructions:\n\t1 - echo 
input,\n\t2 - show mal instruction,\n\t4 - show details of type resolutoin, 
\n\t8 - show binding information."       ]
 [ "clients",   "setPassword",  "pattern clients.setPassword(user:str, 
pass:str):void ",        "CLTsetPassword;",      "Set the password for the 
given user"   ]
 [ "clients",   "setScenario",  "pattern clients.setScenario(msg:str):str ",    
"CLTsetScenario;",      "Switch to other scenario handler, return previous 
one."        ]
+[ "clients",   "setmemorylimit",       "pattern 
clients.setmemorylimit(n:int):void ",  "CLTsetmemorylimit;",   ""      ]
+[ "clients",   "setmemorylimit",       "pattern 
clients.setmemorylimit(sid:sht, n:int):void ", "CLTsetmemorylimit;",   "Limit 
the memory claim in MB per query"        ]
+[ "clients",   "setoptimizer", "pattern clients.setoptimizer(opt:str):void ",  
"CLTsetoptimizer;",     ""      ]
+[ "clients",   "setoptimizer", "pattern clients.setoptimizer(sid:int, 
opt:str):void ", "CLTsetoptimizer;",     "Set the session optimizer"     ]
 [ "clients",   "setprinttimeout",      "command 
clients.setprinttimeout(n:int):void ", "CLTsetPrintTimeout;",  "Print running 
query every so many seconds."    ]
-[ "clients",   "setsession",   "pattern clients.setsession(n:lng):void ",      
"CLTsetSessionTimeout;",        "Abort a session after  n seconds."     ]
-[ "clients",   "settimeout",   "pattern clients.settimeout(n:lng):void ",      
"CLTsetTimeout;",       "Abort a query after q seconds (q=0 means run 
undisturbed).\nThe session timeout aborts the connection after spending 
too\nmany seconds on query processing."   ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(n:int):void ", "CLTqueryTimeout;",     ""      ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(sid:bte, n:int):void ",        "CLTqueryTimeout;",     
""      ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(sid:int, n:int):void ",        "CLTqueryTimeout;",     
"A query is aborted after q seconds (q=0 means run undisturbed)."       ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(sid:sht, n:int):void ",        "CLTqueryTimeout;",     
""      ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(n:int):void ",       "CLTsessionTimeout;",   ""      ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(sid:bte, n:int):void ",      "CLTsessionTimeout;",   
""      ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(sid:int, n:int):void ",      "CLTsessionTimeout;",   
"Set the session timeout for a particulat session id"   ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(sid:sht, n:int):void ",      "CLTsessionTimeout;",   
""      ]
+[ "clients",   "setworkerlimit",       "pattern 
clients.setworkerlimit(n:int):void ",  "CLTsetworkerlimit;",   ""      ]
+[ "clients",   "setworkerlimit",       "pattern 
clients.setworkerlimit(sid:int, n:int):void ", "CLTsetworkerlimit;",   "Limit 
the number of worker threads per query"  ]
 [ "clients",   "sha1sum",      "command clients.sha1sum(pw:str):str ", 
"CLTsha1sum;",  "Return hex string representation of the SHA-1 hash of the 
given string"        ]
 [ "clients",   "sha2sum",      "command clients.sha2sum(pw:str, bits:int):str 
",       "CLTsha2sum;",  "Return hex string representation of the SHA-2 hash 
with bits of the given string"      ]
 [ "clients",   "shutdown",     "pattern clients.shutdown(delay:int):str ",     
"CLTshutdown;", ""      ]
 [ "clients",   "shutdown",     "pattern clients.shutdown(delay:int, 
forced:bit):str ", "CLTshutdown;", "Close all other client connections. Return 
if it succeeds.\nIf forced is set then always stop the system the hard way" ]
 [ "clients",   "stop", "pattern clients.stop(id:int):void ",   "CLTstop;",     
"Stop the query execution at the next eligble statement."       ]
-[ "clients",   "stopsession",  "pattern clients.stopsession(sid:bte):void ",   
"CLTstopSession;",      "Stop a particular session"     ]
+[ "clients",   "stopsession",  "pattern clients.stopsession(sid:bte):void ",   
"CLTstopSession;",      ""      ]
 [ "clients",   "stopsession",  "pattern clients.stopsession(sid:int):void ",   
"CLTstopSession;",      "Stop a particular session"     ]
-[ "clients",   "stopsession",  "pattern clients.stopsession(sid:sht):void ",   
"CLTstopSession;",      "Stop a particular session"     ]
+[ "clients",   "stopsession",  "pattern clients.stopsession(sid:sht):void ",   
"CLTstopSession;",      ""      ]
 [ "clients",   "suspend",      "pattern clients.suspend(id:int):void ",        
"CLTsuspend;",  "Put a client process to sleep for some time.\nIt will simple 
sleep for a second at a time, until\nthe awake bit has been set in its 
descriptor"        ]
 [ "clients",   "wakeup",       "command clients.wakeup(id:int):void ", 
"CLTwakeup;",   "Wakeup a client process"       ]
 [ "color",     "#fromstr",     "command color.#fromstr():void ",       
"color_fromstr;",       ""      ]
@@ -11762,7 +11768,7 @@ stdout of test 'MAL-signatures` in direc
 [ "sql",       "round",        "command sql.round(v:sht, d:int, s:int, 
r:bte):sht ",   "sht_round_wrap;",      "round off the decimal v(d,s) to r 
digits behind the dot (if r < 0, before the dot)"    ]
 [ "sql",       "row_number",   "pattern sql.row_number(b:any_1, p:bit, 
o:bit):int ",   "SQLrow_number;",       "return the row_numer-ed groups"        
]
 [ "sql",       "rt_credentials",       "pattern 
sql.rt_credentials(tablename:str) (uri:bat[:str], username:bat[:str], 
hash:bat[:str]) ",       "sql_rt_credentials_wrap;",     "Return the remote 
table credentials for the given table"       ]
-[ "sql",       "sessions",     "pattern sql.sessions() (id:bat[:int], 
user:bat[:str], start:bat[:timestamp], stimeout:bat[:lng], 
lastcmd:bat[:timestamp], qtimeout:bat[:lng], idle:bat[:int]) ",       
"sql_sessions_wrap;",   "SQL export table of active sessions, their timeouts 
and idle status"   ]
+[ "sql",       "sessions",     "pattern sql.sessions() (id:bat[:int], 
user:bat[:str], start:bat[:timestamp], idle:bat[:timestamp], 
optmizer:bat[:str], stimeout:bat[:int], qtimeout:bat[:int], wlimit:bat[:int], 
mlimit:bat[:int]) ",  "sql_sessions_wrap;",   "SQL export table of active 
sessions, their timeouts and idle status"   ]
 [ "sql",       "setVariable",  "pattern sql.setVariable(mvc:int, varname:str, 
value:any_1):int ",      "setVariable;", "Set the value of a session variable"  
 ]
 [ "sql",       "shrink",       "pattern sql.shrink(sch:str, tbl:str):void ",   
"SQLshrink;",   "Consolidate the deletion table over all columns using 
shrinking"       ]
 [ "sql",       "shutdown",     "pattern sql.shutdown(delay:bte):str ", 
"SQLshutdown_wrap;",    ""      ]
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
@@ -15138,34 +15138,40 @@ stdout of test 'MAL-signatures` in direc
 [ "clients",   "getLogins",    "command clients.getLogins() (user:bat[:oid], 
start:bat[:str]) ",       "CLTLogin;",    "Pseudo bat of client id and login 
time."       ]
 [ "clients",   "getPasswordHash",      "pattern 
clients.getPasswordHash(user:str):str ",       "CLTgetPasswordHash;",  "Return 
the password hash of the given user"    ]
 [ "clients",   "getScenario",  "pattern clients.getScenario():str ",   
"CLTgetScenario;",      "Retrieve current scenario name."       ]
-[ "clients",   "getTimeout",   "pattern clients.getTimeout() (q:lng, s:lng) ", 
"CLTgetTimeout;",       "A query is aborted after q milliseconds (q=0 means run 
undisturbed).\nThe session timeout aborts the connection after spending 
too\nmany seconds on query processing." ]
 [ "clients",   "getUsername",  "pattern clients.getUsername():str ",   
"CLTgetUsername;",      "Return the username of the currently logged in user"   
]
 [ "clients",   "getUsers",     "pattern clients.getUsers() (X_0:bat[:oid], 
X_1:bat[:str]) ",   "CLTgetUsers;", "return a BAT with user id and one with 
name available in the system"   ]
+[ "clients",   "getprofile",   "pattern clients.getprofile() (opt:str, q:int, 
s:int, w:int, m:int) ",  "CLTgetProfile;",       "Retrieve the profile settings 
for a client"    ]
 [ "clients",   "md5sum",       "command clients.md5sum(pw:str):str ",  
"CLTmd5sum;",   "Return hex string representation of the MD5 hash of the given 
string"  ]
-[ "clients",   "querytimeout", "pattern clients.querytimeout(sid:bte, 
n:lng):void ",   "CLTqueryTimeout;",     ""      ]
-[ "clients",   "querytimeout", "pattern clients.querytimeout(sid:int, 
n:lng):void ",   "CLTqueryTimeout;",     ""      ]
-[ "clients",   "querytimeout", "pattern clients.querytimeout(sid:sht, 
n:lng):void ",   "CLTqueryTimeout;",     ""      ]
 [ "clients",   "quit", "pattern clients.quit():void ", "CLTquit;",     
"Terminate the client session." ]
 [ "clients",   "quit", "pattern clients.quit(idx:int):void ",  "CLTquit;",     
"Terminate the session for a single client using a soft error.\nIt is the 
privilige of the console user."       ]
 [ "clients",   "removeUser",   "pattern clients.removeUser(nme:str):void ",    
"CLTremoveUser;",       "Remove the given user from the system" ]
 [ "clients",   "ripemd160sum", "command clients.ripemd160sum(pw:str):str ",    
"CLTripemd160sum;",     "Return hex string representation of the RIPEMD160 hash 
of the given string"    ]
-[ "clients",   "sessiontimeout",       "pattern 
clients.sessiontimeout(sid:bte, n:lng):void ", "CLTsessionTimeout;",   "Set the 
session timeout for a particulat session id"   ]
-[ "clients",   "sessiontimeout",       "pattern 
clients.sessiontimeout(sid:int, n:lng):void ", "CLTsessionTimeout;",   "Set the 
session timeout for a particulat session id"   ]
-[ "clients",   "sessiontimeout",       "pattern 
clients.sessiontimeout(sid:sht, n:lng):void ", "CLTsessionTimeout;",   "Set the 
session timeout for a particulat session id"   ]
 [ "clients",   "setListing",   "pattern clients.setListing(flag:int):int ",    
"CLTsetListing;",       "Turn on/off echo of MAL instructions:\n\t1 - echo 
input,\n\t2 - show mal instruction,\n\t4 - show details of type resolutoin, 
\n\t8 - show binding information."       ]
 [ "clients",   "setPassword",  "pattern clients.setPassword(user:str, 
pass:str):void ",        "CLTsetPassword;",      "Set the password for the 
given user"   ]
 [ "clients",   "setScenario",  "pattern clients.setScenario(msg:str):str ",    
"CLTsetScenario;",      "Switch to other scenario handler, return previous 
one."        ]
+[ "clients",   "setmemorylimit",       "pattern 
clients.setmemorylimit(n:int):void ",  "CLTsetmemorylimit;",   ""      ]
+[ "clients",   "setmemorylimit",       "pattern 
clients.setmemorylimit(sid:sht, n:int):void ", "CLTsetmemorylimit;",   "Limit 
the memory claim in MB per query"        ]
+[ "clients",   "setoptimizer", "pattern clients.setoptimizer(opt:str):void ",  
"CLTsetoptimizer;",     ""      ]
+[ "clients",   "setoptimizer", "pattern clients.setoptimizer(sid:int, 
opt:str):void ", "CLTsetoptimizer;",     "Set the session optimizer"     ]
 [ "clients",   "setprinttimeout",      "command 
clients.setprinttimeout(n:int):void ", "CLTsetPrintTimeout;",  "Print running 
query every so many seconds."    ]
-[ "clients",   "setsession",   "pattern clients.setsession(n:lng):void ",      
"CLTsetSessionTimeout;",        "Abort a session after  n seconds."     ]
-[ "clients",   "settimeout",   "pattern clients.settimeout(n:lng):void ",      
"CLTsetTimeout;",       "Abort a query after q seconds (q=0 means run 
undisturbed).\nThe session timeout aborts the connection after spending 
too\nmany seconds on query processing."   ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(n:int):void ", "CLTqueryTimeout;",     ""      ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(sid:bte, n:int):void ",        "CLTqueryTimeout;",     
""      ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(sid:int, n:int):void ",        "CLTqueryTimeout;",     
"A query is aborted after q seconds (q=0 means run undisturbed)."       ]
+[ "clients",   "setquerytimeout",      "pattern 
clients.setquerytimeout(sid:sht, n:int):void ",        "CLTqueryTimeout;",     
""      ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(n:int):void ",       "CLTsessionTimeout;",   ""      ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(sid:bte, n:int):void ",      "CLTsessionTimeout;",   
""      ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(sid:int, n:int):void ",      "CLTsessionTimeout;",   
"Set the session timeout for a particulat session id"   ]
+[ "clients",   "setsessiontimeout",    "pattern 
clients.setsessiontimeout(sid:sht, n:int):void ",      "CLTsessionTimeout;",   
""      ]
+[ "clients",   "setworkerlimit",       "pattern 
clients.setworkerlimit(n:int):void ",  "CLTsetworkerlimit;",   ""      ]
+[ "clients",   "setworkerlimit",       "pattern 
clients.setworkerlimit(sid:int, n:int):void ", "CLTsetworkerlimit;",   "Limit 
the number of worker threads per query"  ]
 [ "clients",   "sha1sum",      "command clients.sha1sum(pw:str):str ", 
"CLTsha1sum;",  "Return hex string representation of the SHA-1 hash of the 
given string"        ]
 [ "clients",   "sha2sum",      "command clients.sha2sum(pw:str, bits:int):str 
",       "CLTsha2sum;",  "Return hex string representation of the SHA-2 hash 
with bits of the given string"      ]
 [ "clients",   "shutdown",     "pattern clients.shutdown(delay:int):str ",     
"CLTshutdown;", ""      ]
 [ "clients",   "shutdown",     "pattern clients.shutdown(delay:int, 
forced:bit):str ", "CLTshutdown;", "Close all other client connections. Return 
if it succeeds.\nIf forced is set then always stop the system the hard way" ]
 [ "clients",   "stop", "pattern clients.stop(id:int):void ",   "CLTstop;",     
"Stop the query execution at the next eligble statement."       ]
-[ "clients",   "stopsession",  "pattern clients.stopsession(sid:bte):void ",   
"CLTstopSession;",      "Stop a particular session"     ]
+[ "clients",   "stopsession",  "pattern clients.stopsession(sid:bte):void ",   
"CLTstopSession;",      ""      ]
 [ "clients",   "stopsession",  "pattern clients.stopsession(sid:int):void ",   
"CLTstopSession;",      "Stop a particular session"     ]
-[ "clients",   "stopsession",  "pattern clients.stopsession(sid:sht):void ",   
"CLTstopSession;",      "Stop a particular session"     ]
+[ "clients",   "stopsession",  "pattern clients.stopsession(sid:sht):void ",   
"CLTstopSession;",      ""      ]
 [ "clients",   "suspend",      "pattern clients.suspend(id:int):void ",        
"CLTsuspend;",  "Put a client process to sleep for some time.\nIt will simple 
sleep for a second at a time, until\nthe awake bit has been set in its 
descriptor"        ]
 [ "clients",   "wakeup",       "command clients.wakeup(id:int):void ", 
"CLTwakeup;",   "Wakeup a client process"       ]
 [ "color",     "#fromstr",     "command color.#fromstr():void ",       
"color_fromstr;",       ""      ]
@@ -16174,7 +16180,7 @@ stdout of test 'MAL-signatures` in direc
 [ "sql",       "round",        "command sql.round(v:sht, d:int, s:int, 
r:bte):sht ",   "sht_round_wrap;",      "round off the decimal v(d,s) to r 
digits behind the dot (if r < 0, before the dot)"    ]
 [ "sql",       "row_number",   "pattern sql.row_number(b:any_1, p:bit, 
o:bit):int ",   "SQLrow_number;",       "return the row_numer-ed groups"        
]
 [ "sql",       "rt_credentials",       "pattern 
sql.rt_credentials(tablename:str) (uri:bat[:str], username:bat[:str], 
hash:bat[:str]) ",       "sql_rt_credentials_wrap;",     "Return the remote 
table credentials for the given table"       ]
-[ "sql",       "sessions",     "pattern sql.sessions() (id:bat[:int], 
user:bat[:str], start:bat[:timestamp], stimeout:bat[:lng], 
lastcmd:bat[:timestamp], qtimeout:bat[:lng], idle:bat[:int]) ",       
"sql_sessions_wrap;",   "SQL export table of active sessions, their timeouts 
and idle status"   ]
+[ "sql",       "sessions",     "pattern sql.sessions() (id:bat[:int], 
user:bat[:str], start:bat[:timestamp], idle:bat[:timestamp], 
optmizer:bat[:str], stimeout:bat[:int], qtimeout:bat[:int], wlimit:bat[:int], 
mlimit:bat[:int]) ",  "sql_sessions_wrap;",   "SQL export table of active 
sessions, their timeouts and idle status"   ]
 [ "sql",       "setVariable",  "pattern sql.setVariable(mvc:int, varname:str, 
value:any_1):int ",      "setVariable;", "Set the value of a session variable"  
 ]
 [ "sql",       "shrink",       "pattern sql.shrink(sch:str, tbl:str):void ",   
"SQLshrink;",   "Consolidate the deletion table over all columns using 
shrinking"       ]
 [ "sql",       "shutdown",     "pattern sql.shutdown(delay:bte):str ", 
"SQLshutdown_wrap;",    ""      ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -924,8 +924,8 @@ str CLTchangeUsername(Client cntxt, MalB
 str CLTcheckPermission(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 str CLTgetClientId(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTgetPasswordHash(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+str CLTgetProfile(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTgetScenario(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str CLTgetTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTgetUsername(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTgetUsers(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTmd5sum(str *ret, str *pw);
@@ -939,8 +939,9 @@ str CLTsetListing(Client cntxt, MalBlkPt
 str CLTsetPassword(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTsetPrintTimeout(void *ret, int *secs);
 str CLTsetScenario(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-str CLTsetSessionTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-str CLTsetTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str CLTsetmemorylimit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str CLTsetoptimizer(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+str CLTsetworkerlimit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str CLTsha1sum(str *ret, str *pw);
 str CLTsha2sum(str *ret, str *pw, int *bits);
 str CLTshutdown(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c
--- a/monetdb5/mal/mal_client.c
+++ b/monetdb5/mal/mal_client.c
@@ -249,8 +249,6 @@ MCinitClientRecord(Client c, oid user, b
        c->memorylimit = 0;
        c->querytimeout = 0;
        c->sessiontimeout = 0;
-       c->workers = 0;
-       c->memoryclaim = 0;
        c->itrace = 0;
        c->errbuf = 0;
 
@@ -374,8 +372,6 @@ MCforkClient(Client father)
                son->memorylimit = father->memorylimit;
                son->querytimeout = father->querytimeout;
                son->sessiontimeout = father->sessiontimeout;
-               son->workers = father->workers;
-               son->memoryclaim = father->memoryclaim;
 
                if (son->prompt)
                        GDKfree(son->prompt);
@@ -445,8 +441,6 @@ MCfreeClient(Client c)
        c->memorylimit = 0;
        c->querytimeout = 0;
        c->sessiontimeout = 0;
-       c->workers = 0;
-       c->memoryclaim = 0;
        c->user = oid_nil;
        if( c->username){
                GDKfree(c->username);
diff --git a/monetdb5/mal/mal_client.h b/monetdb5/mal/mal_client.h
--- a/monetdb5/mal/mal_client.h
+++ b/monetdb5/mal/mal_client.h
@@ -79,8 +79,6 @@ typedef struct CLIENT {
         * For program debugging and performance trace we keep the actual 
resource claims.
         */
        time_t  lastcmd;                /* set when query is received */
-       int             workers;                /* Actual number of concurrent 
workers */
-       lng             memoryclaim;    /* Actual memory claim highwater mark */
 
        /* The user can request a TRACE SQL statement, calling for collecting 
the events locally */
        BAT *profticks;                         
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -141,8 +141,8 @@ runtimeProfileFinish(Client cntxt, MalBl
        QRYqueue[qtop].query = NULL; /* sentinel for SYSMONqueue() */
        cntxt->idle = time(0);
        cntxt->lastcmd = 0;
-       cntxt->workers = 0;
-       cntxt->memoryclaim = 0;
+       QRYqueue[qtop].workers = 0;
+       QRYqueue[qtop].memoryclaim = 0;
        MT_lock_unset(&mal_delayLock);
 }
 
@@ -192,7 +192,7 @@ runtimeProfileBegin(Client cntxt, MalBlk
                workingset[tid].mb = mb;
                workingset[tid].stk = stk;
                workingset[tid].pci = pci;
-               cntxt->workers ++;
+               QRYqueue[qtop].workers ++;
                MT_lock_unset(&mal_delayLock);
        }
        /* always collect the MAL instruction execution time */
@@ -215,7 +215,7 @@ runtimeProfileExit(Client cntxt, MalBlkP
                workingset[tid].mb = 0;
                workingset[tid].stk = 0;
                workingset[tid].pci = 0;
-               cntxt->workers --;
+               QRYqueue[qtop].workers --;
                MT_lock_unset(&mal_delayLock);
        }
 
diff --git a/monetdb5/mal/mal_runtime.h b/monetdb5/mal/mal_runtime.h
--- a/monetdb5/mal/mal_runtime.h
+++ b/monetdb5/mal/mal_runtime.h
@@ -32,6 +32,8 @@ typedef struct QRYQUEUE{
        str query;
        str status;
        time_t start;
+       int             workers;                /* Actual number of concurrent 
workers */
+       lng             memoryclaim;    /* Actual memory claim highwater mark */
        lng runtime;
 } *QueryQueue;
 mal_export lng qtop;
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
@@ -242,8 +242,8 @@ CLTsetoptimizer(Client cntxt, MalBlkPtr 
 
     (void) mb;
        if( pci->argc == 3){
-       idx = *getArgReference_sht(stk,pci,1);
-       opt = *getArgReference_str(stk,pci,2);
+               idx = *getArgReference_int(stk,pci,1);
+               opt = *getArgReference_str(stk,pci,2);
        } else {
                idx = cntxt->idx;
                opt = *getArgReference_str(stk,pci,1);
@@ -266,7 +266,7 @@ CLTsetworkerlimit(Client cntxt, MalBlkPt
 
     (void) mb;
        if(pci->argc == 3){
-               idx = *getArgReference_sht(stk,pci,1);
+               idx = *getArgReference_int(stk,pci,1);
                limit = *getArgReference_int(stk,pci,2);
        } else {
                idx = cntxt->idx;
@@ -275,6 +275,8 @@ CLTsetworkerlimit(Client cntxt, MalBlkPt
 
        if( idx < 0 || idx > MAL_MAXCLIENTS)
                throw(MAL,"setworkerlimit","Illegal session id");
+       if( limit < 0)
+               throw(MAL, "setworkerlimit", "At least one worker needed");
        if (mal_clients[idx].mode == FREECLIENT)
                throw(MAL,"setworkerlimit","Session not active anymore ");
     if (cntxt->user == mal_clients[idx].user || cntxt->user == MAL_ADMIN){
@@ -301,6 +303,8 @@ CLTsetmemorylimit(Client cntxt, MalBlkPt
                throw(MAL,"setmemorylimit","Illegal session id");
        if (mal_clients[idx].mode == FREECLIENT)
                throw(MAL,"setmemorylimit","Session not active anymore ");
+       if( limit < 100)
+               throw(MAL, "setmemorylimit", "At least 100 MB needed");
     if (cntxt->user == mal_clients[idx].user || cntxt->user == MAL_ADMIN){
         mal_clients[idx].memorylimit = limit; 
        }
@@ -357,7 +361,7 @@ CLTwakeup(void *ret, int *id)
     return MCawakeClient(*id);
 }
 
-/* set session time out based in seconds */
+/* set session time out based in seconds, converted into microseconds */
 str
 CLTqueryTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
@@ -377,16 +381,16 @@ CLTqueryTimeout(Client cntxt, MalBlkPtr 
                        idx = *getArgReference_int(stk,pci,1);
                        break;
                default:
-                       throw(MAL,"sessionTimeout","Unexpected index type");
+                       throw(MAL,"querytimeout","Unexpected index type");
                }
-               qto=  *getArgReference_lng(stk,pci,2);
+               qto=  *getArgReference_int(stk,pci,2);
        } else {
                idx = cntxt->idx;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to