Changeset: 60a887373d88 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60a887373d88
Modified Files:
        clients/R/Tests/dbi.stable.err
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        monetdb5/mal/mal.h
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_runtime.h
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/clients.h
        monetdb5/modules/mal/clients.mal
        monetdb5/modules/mal/mdb.c
        monetdb5/modules/mal/sysmon.c
Branch: Nov2019
Log Message:

Turned the tag into a lng. Removed unused code and rely on the sysmon code 
where necessary.
Sharpen the access control to user information at the MAL level.


diffs (truncated from 592 to 300 lines):

diff --git a/clients/R/Tests/dbi.stable.err b/clients/R/Tests/dbi.stable.err
--- a/clients/R/Tests/dbi.stable.err
+++ b/clients/R/Tests/dbi.stable.err
@@ -30,6 +30,8 @@ stderr of test 'dbi` in directory 'clien
 # 12:27:25 >  "R" "--vanilla" "--slave" "--args" "31728"
 # 12:27:25 >  
 
+Warning message:
+S3 methods ‘[.fun_list’, ‘[.grouped_df’, ‘all.equal.tbl_df’, 
‘anti_join.data.frame’, ‘anti_join.tbl_df’, ‘arrange.data.frame’, 
‘arrange.default’, ‘arrange.grouped_df’, ‘arrange.tbl_df’, 
‘arrange_.data.frame’, ‘arrange_.tbl_df’, ‘as.data.frame.grouped_df’, 
‘as.data.frame.rowwise_df’, ‘as.data.frame.tbl_cube’, ‘as.table.tbl_cube’, 
‘as.tbl.data.frame’, ‘as.tbl.tbl’, ‘as.tbl_cube.array’, 
‘as.tbl_cube.data.frame’, ‘as.tbl_cube.matrix’, ‘as.tbl_cube.table’, 
‘as_tibble.grouped_df’, ‘as_tibble.tbl_cube’, ‘auto_copy.tbl_cube’, 
‘auto_copy.tbl_df’, ‘cbind.grouped_df’, ‘collapse.data.frame’, 
‘collect.data.frame’, ‘common_by.NULL’, ‘common_by.character’, 
‘common_by.default’, ‘common_by.list’, ‘compute.data.frame’, 
‘copy_to.DBIConnection’, ‘copy_to.src_local’, ‘default_missing.data.frame’, 
‘default_missing.default’, ‘dim.tbl_cube’, ‘distinct.data.f [... truncated] 
 Identifier(s) "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", 
"Species" contain uppercase or reserved SQL characters and need(s) to be quoted 
in queries.
 Warning message:
 'MonetDBLite::isIdCurrent' is deprecated.
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
@@ -10732,17 +10732,14 @@ stdout of test 'MAL-signatures` in direc
 [ "clients",   "changePassword",       "pattern 
clients.changePassword(old:str, new:str):void ",       "CLTchangePassword;",   
"Change the password for the current user"      ]
 [ "clients",   "changeUsername",       "pattern 
clients.changeUsername(old:str, new:str):void ",       "CLTchangeUsername;",   
"Change the username of the user into the new string"   ]
 [ "clients",   "checkPermission",      "pattern 
clients.checkPermission(usr:str, pw:str):void ",       "CLTcheckPermission;",  
"Check permission for a user, requires hashed password (backendsum)"    ]
-[ "clients",   "getActions",   "command clients.getActions():bat[:int] ",      
"CLTActions;",  "Pseudo bat of client's command counts."        ]
 [ "clients",   "getId",        "pattern clients.getId():int ", 
"CLTgetClientId;",      "Return a number that uniquely represents the current 
client."  ]
 [ "clients",   "getInfo",      "pattern clients.getInfo() (X_0:bat[:str], 
X_1:bat[:str]) ",    "CLTInfo;",     "Pseudo bat with client attributes."    ]
-[ "clients",   "getLastCommand",       "command 
clients.getLastCommand():bat[:str] ",  "CLTLastCommand;",      "Pseudo bat of 
client's last command time."     ]
 [ "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",   "getUsers",     "command clients.getUsers():bat[:str] ",        
"CLTusers;",    "Pseudo bat of users id and name."      ]
 [ "clients",   "md5sum",       "command clients.md5sum(pw:str):str ",  
"CLTmd5sum;",   "Return hex string representation of the MD5 hash of the given 
string"  ]
 [ "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."       ]
@@ -12061,6 +12058,7 @@ stdout of test 'MAL-signatures` in direc
 [ "wlc",       "drop_user",    "pattern wlc.drop_user(sname:str, 
action:int):void ",   "WLCgeneric;",  "Catalog operation drop_user"   ]
 [ "wlc",       "drop_user",    "pattern wlc.drop_user(sname:str, auth:str, 
action:int):void ", "WLCgeneric;",  "Catalog operation drop_user"   ]
 [ "wlc",       "drop_view",    "pattern wlc.drop_view(sname:str, name:str, 
action:int, ifexists:int):void ",   "WLCgeneric;",  "Catalog operation 
drop_view"   ]
+[ "wlc",       "flush",        "pattern wlc.flush():void ",    "WLCflush;",    
"Flush current log buffer"      ]
 [ "wlc",       "getmasterbeat",        "pattern 
wlc.getmasterbeat(duration:int):str ", "WLCgetmasterbeat;",    "Maximal delay 
for transaction log flushing"    ]
 [ "wlc",       "getmasterclock",       "pattern wlc.getmasterclock():str ",    
"WLCgetmasterclock;",   "Timestamp of last update transaction"  ]
 [ "wlc",       "getmastertick",        "pattern wlc.getmastertick():lng ",     
"WLCgetmastertick;",    "Transaction identifier of the last committed 
transaction"      ]
@@ -12135,19 +12133,19 @@ stdout of test 'MAL-signatures` in direc
 [ "wlr",       "rename_schema",        "pattern wlr.rename_schema(sname:str, 
newnme:str):void ",       "WLRgeneric;",  "Catalog operation rename_schema"     
  ]
 [ "wlr",       "rename_table", "pattern wlr.rename_table(osname:str, 
nsname:str, otname:str, ntname:str):void ",       "WLRgeneric;",  "Catalog 
operation rename_table"        ]
 [ "wlr",       "rename_user",  "pattern wlr.rename_user(sname:str, newnme:str, 
action:int):void ",     "WLRgeneric;",  "Catalog operation rename_user" ]
-[ "wlr",       "replicate",    "pattern wlr.replicate():void ",        
"WLRreplicate;",        "Roll the snapshot forward to an up-to-date clone"      
]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str):void ",      
"WLRreplicate;",        "Roll the snapshot forward to an up-to-date clone"      
]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:bte):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:int):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:lng):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:sht):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, 
ts:timestamp):void ",        "WLRreplicate;",        "Roll the snapshot forward 
to the time TS"      ]
+[ "wlr",       "replicate",    "pattern wlr.replicate():void ",        
"WLRreplicate;",        "Continue to keep the replica in sink"  ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:bte):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:int):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:lng):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:sht):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
 [ "wlr",       "replicate",    "pattern wlr.replicate(ts:timestamp):void ",    
"WLRreplicate;",        "Roll the snapshot forward to an up-to-date clone"      
]
+[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str):void ",      
"WLRstartreplicate;",   "Initialize the replicator thread"      ]
 [ "wlr",       "revoke",       "pattern wlr.revoke(sname:str, tbl:str, 
grantee:str, privs:int, cname:str, grant:int, grantor:int):void ",      
"WLRgeneric;",  "Catalog operation revoke"      ]
 [ "wlr",       "revoke_function",      "pattern wlr.revoke_function(sname:str, 
fcnid:int, grantee:str, privs:int, grant:int, grantor:int):void ",      
"WLRgeneric;",  "Catalog operation revoke_function"     ]
 [ "wlr",       "revoke_roles", "pattern wlr.revoke_roles(sname:str, auth:str, 
grantor:int, admin:int):void ",  "WLRgeneric;",  "Catalog operation 
revoke_roles"        ]
 [ "wlr",       "rollback",     "pattern wlr.rollback():void ", "WLRrollback;", 
"Mark the end of the work unit" ]
 [ "wlr",       "setreplicabeat",       "pattern 
wlr.setreplicabeat(dur:int):void ",    "WLRsetreplicabeat;",   "Threshold (in 
seconds) for re-running queries" ]
+[ "wlr",       "stopreplicate",        "pattern wlr.stopreplicate():void ",    
"WLRstopreplicate;",    "Stop the replicator thread"    ]
 [ "wlr",       "transaction",  "unsafe pattern wlr.transaction():void ",       
"WLRgeneric;",  "Start an autocommit transaction"       ]
 [ "wlr",       "transaction",  "pattern wlr.transaction(tid:lng, started:str, 
user:str):void ",        "WLRtransaction;",      "Mark the beginning of the 
work unit which can be a compound transaction"       ]
 [ "wlr",       "transaction_begin",    "pattern 
wlr.transaction_begin(chain:int, name:str):void ",     "WLRgeneric;",  "A 
transaction statement (type can be commit,release,rollback or start)"        ]
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
@@ -15120,17 +15120,14 @@ stdout of test 'MAL-signatures` in direc
 [ "clients",   "changePassword",       "pattern 
clients.changePassword(old:str, new:str):void ",       "CLTchangePassword;",   
"Change the password for the current user"      ]
 [ "clients",   "changeUsername",       "pattern 
clients.changeUsername(old:str, new:str):void ",       "CLTchangeUsername;",   
"Change the username of the user into the new string"   ]
 [ "clients",   "checkPermission",      "pattern 
clients.checkPermission(usr:str, pw:str):void ",       "CLTcheckPermission;",  
"Check permission for a user, requires hashed password (backendsum)"    ]
-[ "clients",   "getActions",   "command clients.getActions():bat[:int] ",      
"CLTActions;",  "Pseudo bat of client's command counts."        ]
 [ "clients",   "getId",        "pattern clients.getId():int ", 
"CLTgetClientId;",      "Return a number that uniquely represents the current 
client."  ]
 [ "clients",   "getInfo",      "pattern clients.getInfo() (X_0:bat[:str], 
X_1:bat[:str]) ",    "CLTInfo;",     "Pseudo bat with client attributes."    ]
-[ "clients",   "getLastCommand",       "command 
clients.getLastCommand():bat[:str] ",  "CLTLastCommand;",      "Pseudo bat of 
client's last command time."     ]
 [ "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",   "getUsers",     "command clients.getUsers():bat[:str] ",        
"CLTusers;",    "Pseudo bat of users id and name."      ]
 [ "clients",   "md5sum",       "command clients.md5sum(pw:str):str ",  
"CLTmd5sum;",   "Return hex string representation of the MD5 hash of the given 
string"  ]
 [ "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."       ]
@@ -16481,6 +16478,7 @@ stdout of test 'MAL-signatures` in direc
 [ "wlc",       "drop_user",    "pattern wlc.drop_user(sname:str, 
action:int):void ",   "WLCgeneric;",  "Catalog operation drop_user"   ]
 [ "wlc",       "drop_user",    "pattern wlc.drop_user(sname:str, auth:str, 
action:int):void ", "WLCgeneric;",  "Catalog operation drop_user"   ]
 [ "wlc",       "drop_view",    "pattern wlc.drop_view(sname:str, name:str, 
action:int, ifexists:int):void ",   "WLCgeneric;",  "Catalog operation 
drop_view"   ]
+[ "wlc",       "flush",        "pattern wlc.flush():void ",    "WLCflush;",    
"Flush current log buffer"      ]
 [ "wlc",       "getmasterbeat",        "pattern 
wlc.getmasterbeat(duration:int):str ", "WLCgetmasterbeat;",    "Maximal delay 
for transaction log flushing"    ]
 [ "wlc",       "getmasterclock",       "pattern wlc.getmasterclock():str ",    
"WLCgetmasterclock;",   "Timestamp of last update transaction"  ]
 [ "wlc",       "getmastertick",        "pattern wlc.getmastertick():lng ",     
"WLCgetmastertick;",    "Transaction identifier of the last committed 
transaction"      ]
@@ -16555,19 +16553,19 @@ stdout of test 'MAL-signatures` in direc
 [ "wlr",       "rename_schema",        "pattern wlr.rename_schema(sname:str, 
newnme:str):void ",       "WLRgeneric;",  "Catalog operation rename_schema"     
  ]
 [ "wlr",       "rename_table", "pattern wlr.rename_table(osname:str, 
nsname:str, otname:str, ntname:str):void ",       "WLRgeneric;",  "Catalog 
operation rename_table"        ]
 [ "wlr",       "rename_user",  "pattern wlr.rename_user(sname:str, newnme:str, 
action:int):void ",     "WLRgeneric;",  "Catalog operation rename_user" ]
-[ "wlr",       "replicate",    "pattern wlr.replicate():void ",        
"WLRreplicate;",        "Roll the snapshot forward to an up-to-date clone"      
]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str):void ",      
"WLRreplicate;",        "Roll the snapshot forward to an up-to-date clone"      
]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:bte):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:int):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:lng):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, id:sht):void 
",      "WLRreplicate;",        "Roll the snapshot forward to a specific 
transaction id"        ]
-[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str, 
ts:timestamp):void ",        "WLRreplicate;",        "Roll the snapshot forward 
to the time TS"      ]
+[ "wlr",       "replicate",    "pattern wlr.replicate():void ",        
"WLRreplicate;",        "Continue to keep the replica in sink"  ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:bte):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:int):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:lng):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
+[ "wlr",       "replicate",    "pattern wlr.replicate(id:sht):void ",  
"WLRreplicate;",        "Roll the snapshot forward to a specific transaction 
id"        ]
 [ "wlr",       "replicate",    "pattern wlr.replicate(ts:timestamp):void ",    
"WLRreplicate;",        "Roll the snapshot forward to an up-to-date clone"      
]
+[ "wlr",       "replicate",    "pattern wlr.replicate(dbname:str):void ",      
"WLRstartreplicate;",   "Initialize the replicator thread"      ]
 [ "wlr",       "revoke",       "pattern wlr.revoke(sname:str, tbl:str, 
grantee:str, privs:int, cname:str, grant:int, grantor:int):void ",      
"WLRgeneric;",  "Catalog operation revoke"      ]
 [ "wlr",       "revoke_function",      "pattern wlr.revoke_function(sname:str, 
fcnid:int, grantee:str, privs:int, grant:int, grantor:int):void ",      
"WLRgeneric;",  "Catalog operation revoke_function"     ]
 [ "wlr",       "revoke_roles", "pattern wlr.revoke_roles(sname:str, auth:str, 
grantor:int, admin:int):void ",  "WLRgeneric;",  "Catalog operation 
revoke_roles"        ]
 [ "wlr",       "rollback",     "pattern wlr.rollback():void ", "WLRrollback;", 
"Mark the end of the work unit" ]
 [ "wlr",       "setreplicabeat",       "pattern 
wlr.setreplicabeat(dur:int):void ",    "WLRsetreplicabeat;",   "Threshold (in 
seconds) for re-running queries" ]
+[ "wlr",       "stopreplicate",        "pattern wlr.stopreplicate():void ",    
"WLRstopreplicate;",    "Stop the replicator thread"    ]
 [ "wlr",       "transaction",  "unsafe pattern wlr.transaction():void ",       
"WLRgeneric;",  "Start an autocommit transaction"       ]
 [ "wlr",       "transaction",  "pattern wlr.transaction(tid:lng, started:str, 
user:str):void ",        "WLRtransaction;",      "Mark the beginning of the 
work unit which can be a compound transaction"       ]
 [ "wlr",       "transaction_begin",    "pattern 
wlr.transaction_begin(chain:int, name:str):void ",     "WLRgeneric;",  "A 
transaction statement (type can be commit,release,rollback or start)"        ]
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -175,7 +175,7 @@ typedef struct {
 typedef struct MALBLK {
        char binding[IDLENGTH]; /* related C-function */
        str help;                               /* supportive commentary */
-       oid tag;                                /* unique block tag */
+       lng tag;                                /* unique block tag */
        struct MALBLK *alternative;
        int vtop;                               /* next free slot */
        int vsize;                              /* size of variable arena */
@@ -229,7 +229,7 @@ typedef struct MALSTK {
        char cmd;               /* debugger and runtime communication */
        char status;            /* srunning 'R' suspended 'S', quiting 'Q' */
        int pcup;               /* saved pc upon a recursive all */
-       int tag;                /* unique invocation call tag */
+       lng tag;                /* unique invocation call tag */
        struct MALSTK *up;      /* stack trace list */
        struct MALBLK *blk;     /* associated definition */
        ValRecord stk[FLEXIBLE_ARRAY_MEMBER];
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -560,6 +560,8 @@ str runMALsequence(Client cntxt, MalBlkP
                        lastcheck = runtimeProfile.ticks;
                }
 
+               /* Long running queries are traced in the logger. Use at least 
a couple of minutes
+                * to avoid a larg log*/
                if (qptimeout > 0) {
                        lng t = GDKusec();
                        ATOMIC_BASE_TYPE lp = ATOMIC_GET(&cntxt->lastprint);
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -165,14 +165,14 @@ renderProfilerEvent(MalBlkPtr mb, MalStk
 
        logadd("\"function\":\"%s.%s\",%s", getModuleId(getInstrPtr(mb, 0)), 
getFunctionId(getInstrPtr(mb, 0)), prettify);
        logadd("\"pc\":%d,%s", mb?getPC(mb,pci):0, prettify);
-       logadd("\"tag\":%d,%s", stk?stk->tag:0, prettify);
+       logadd("\"tag\":"LLFMT",%s", stk?stk->tag:0, prettify);
        logadd("\"module\":\"%s\",%s", pci->modname ? pci->modname : "", 
prettify);
        if (pci->modname && strcmp(pci->modname, "user") == 0) {
-               int caller_tag = 0;
+               lng caller_tag = 0;
                if(stk && stk->up) {
                        caller_tag = stk->up->tag;
                }
-               logadd("\"caller\":%d,%s", caller_tag, prettify);
+               logadd("\"caller\":"LLFMT",%s", caller_tag, prettify);
        }
        logadd("\"instruction\":\"%s\",%s", pci->fcnname ? pci->fcnname : "", 
prettify);
        if (!GDKinmemory()) {
@@ -904,7 +904,7 @@ cachedProfilerEvent(MalBlkPtr mb, MalStk
                return;
 
        /* update the Trace tables */
-       snprintf(buf, BUFSIZ, "%s.%s[%d]%d",
+       snprintf(buf, BUFSIZ, "%s.%s[%d]"LLFMT,
        getModuleId(getInstrPtr(mb, 0)),
        getFunctionId(getInstrPtr(mb, 0)), getPC(mb, pci), stk->tag);
 
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
@@ -7,8 +7,11 @@
  */
 
 /* Author(s) M.L. Kersten
- * The MAL Runtime Profiler
+ * The MAL Runtime Profiler and system queue
  * This little helper module is used to perform instruction based profiling.
+ * We should actually keep a little list of recently executed queries to 
inspection.
+ * [TODO] It should be moved into the Client record for speed (>500 client 
connections)
+ * Long term archival is left to the SQL history management structure
  */
 
 #include "monetdb_config.h"
@@ -26,7 +29,16 @@
 // Keep a queue of running queries
 QueryQueue QRYqueue;
 int qtop;
-static int qsize, qtag= 1;
+static lng qsize, qtag= 1;
+
+#define QRYreset(I)\
+               if (QRYqueue[I].query) GDKfree(QRYqueue[I].query);\
+               QRYqueue[I].cntxt = 0; \
+               QRYqueue[I].tag = 0; \
+               QRYqueue[I].query = 0; \
+               QRYqueue[I].status =0; \
+               QRYqueue[I].stk =0; \
+               QRYqueue[I].mb =0; \
 
 void
 mal_runtime_reset(void)
@@ -63,9 +75,9 @@ runtimeProfileInit(Client cntxt, MalBlkP
        MT_lock_set(&mal_delayLock);
        tmp = QRYqueue;
        if ( QRYqueue == 0)
-               QRYqueue = (QueryQueue) GDKzalloc( sizeof (struct QRYQUEUE) * 
(qsize= 256));
+               QRYqueue = (QueryQueue) GDKzalloc( sizeof (struct QRYQUEUE) * 
(qsize= 1024));
        else if ( qtop +1 == qsize )
-               QRYqueue = (QueryQueue) GDKrealloc( QRYqueue, sizeof (struct 
QRYQUEUE) * (qsize +=256));
+               QRYqueue = (QueryQueue) GDKrealloc( QRYqueue, sizeof (struct 
QRYQUEUE) * (qsize += 256));
        if ( QRYqueue == NULL){
                addMalException(mb,"runtimeProfileInit" MAL_MALLOC_FAIL);
                GDKfree(tmp);                   /* may be NULL, but doesn't 
harm */
@@ -99,6 +111,8 @@ runtimeProfileInit(Client cntxt, MalBlkP
        MT_lock_unset(&mal_delayLock);
 }
 
+/* We should keep a short list of previously executed queries/client for 
inspection */
+
 void
 runtimeProfileFinish(Client cntxt, MalBlkPtr mb, MalStkPtr stk)
 {
@@ -120,16 +134,8 @@ runtimeProfileFinish(Client cntxt, MalBl
                }
                QRYqueue[i].mb->calls++;
                QRYqueue[i].mb->runtime += (lng) ((lng)(time(0) - 
QRYqueue[i].start) * 1000.0/QRYqueue[i].mb->calls);
-
-               // reset entry
-               if (QRYqueue[i].query)
-                       GDKfree(QRYqueue[i].query);
-               QRYqueue[i].cntxt = 0;
-               QRYqueue[i].tag = 0;
-               QRYqueue[i].query = 0;
-               QRYqueue[i].status =0;
-               QRYqueue[i].stk =0;
-               QRYqueue[i].mb =0;
+               QRYqueue[i].status = "finished";
+               QRYreset(i)
        }
 
        qtop = j;
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
@@ -28,7 +28,7 @@ typedef struct QRYQUEUE{
        Client cntxt;
        MalBlkPtr mb;
        MalStkPtr stk;
-       int tag;
+       lng tag;
        str query;
        str status;
        time_t start;
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
@@ -10,10 +10,8 @@
  * author Martin Kersten, Fabian Groffen
  * Client Management
  * Each online client is represented with an entry in the clients table.
- * The client may inspect his record at run-time and partially change its
- * properties.
- * The administrator sees all client records and has the right to
- * adjust global properties.
+ * The client may inspect his record at run-time and partially change its 
properties.
+ * The administrator sees all client records and has the right to adjust 
global properties.
  */
 
 
@@ -202,91 +200,18 @@ CLTLogin(bat *nme, bat *ret)
 }
 
 str
-CLTLastCommand(bat *ret)
-{
-       BAT *b = COLnew(0, TYPE_str, 12, TRANSIENT);
-       int i;
-       char s[26];
-
-       if (b == 0)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to