Changeset: d0507a2686e6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d0507a2686e6 Modified Files: clients/Tests/exports.stable.out gdk/gdk_batop.c monetdb5/mal/mal_client.c monetdb5/mal/mal_client.h monetdb5/mal/mal_errors.h monetdb5/mal/mal_interpreter.c monetdb5/modules/mal/clients.c monetdb5/modules/mal/clients.mal monetdb5/modules/mal/mat.c sql/backends/monet5/sql.mx sql/scripts/22_clients.sql sql/test/Tests/systemfunctions.stable.out sql/test/Tests/systemfunctions_nogeom.stable.out Branch: mutation Log Message:
merge with default diffs (295 lines): 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 @@ -1546,6 +1546,7 @@ str MATHunary_ISNAN(bit *res, dbl *a); str MATdummy(int *ret, str *grp); str MAThasMoreElements(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); str MATinfo(int *ret, str *grp, str *elm); +str MATmergepack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); str MATnewIterator(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); str MATpack(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); str MATpack2(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); @@ -3131,7 +3132,7 @@ str topn_maxRef; str topn_minRef; int toriginProp; void trimMalBlk(MalBlkPtr mb); -void trimMalVariables(MalBlkPtr mb); +void trimMalVariables(MalBlkPtr mb, MalStkPtr stk); void trimMalVariables_(MalBlkPtr mb, bit *used, MalStkPtr glb); int tubProp; str tuniqueRef; diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -2242,10 +2242,10 @@ BATmergecand(BAT *a, BAT *b) assert(b->htype == TYPE_void); assert(ATOMtype(a->htype) == TYPE_oid); assert(ATOMtype(b->htype) == TYPE_oid); - assert(a->tsorted); - assert(b->tsorted); - assert(a->tkey); - assert(b->tkey); + assert(BATcount(a) <= 1 || a->tsorted); + assert(BATcount(b) <= 1 || b->tsorted); + assert(BATcount(a) <= 1 || a->tkey); + assert(BATcount(b) <= 1 || b->tkey); assert(a->T->nonil); assert(b->T->nonil); 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 @@ -227,6 +227,7 @@ MCinitClientRecord(Client c, oid user, b c->father = NULL; c->login = c->lastcmd = time(0); + c->session = GDKusec(); c->qtimeout = 0; c->stimeout = 0; c->stage = 0; 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 @@ -94,8 +94,9 @@ typedef struct CLIENT { time_t login; time_t lastcmd; /* set when input is received */ - lng qtimeout; /* query abort after x milliseconds */ - lng stimeout; /* session abort after x milliseconds */ + lng session; /* usec since start of server */ + lng qtimeout; /* query abort after x usec*/ + lng stimeout; /* session abort after x usec */ /* * Communication channels for the interconnect are stored here. * It is perfectly legal to have a client without input stream. diff --git a/monetdb5/mal/mal_errors.h b/monetdb5/mal/mal_errors.h --- a/monetdb5/mal/mal_errors.h +++ b/monetdb5/mal/mal_errors.h @@ -100,6 +100,7 @@ #define RUNTIME_OBJECT_UNDEFINED "Object not found" #define RUNTIME_UNKNOWN_INSTRUCTION "Instruction type not supported" #define RUNTIME_QRY_TIMEOUT "Query aborted due to timeout" +#define RUNTIME_SESSION_TIMEOUT "Query aborted due to session timeout" #define OPERATION_FAILED "operation failed" #define BOX_CLOSED "Box is not open" 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 @@ -381,7 +381,7 @@ str runMAL(Client cntxt, MalBlkPtr mb, M garbageCollector(cntxt, mb, stk, env != stk); if (stk && stk != env) GDKfree(stk); - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout) + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout) throw(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); return ret; } @@ -473,7 +473,7 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS throw(MAL, "mal.interpreter", RUNTIME_UNKNOWN_INSTRUCTION); } MT_sema_up(&mal_parallelism,"callMAL"); - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout) + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout) throw(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); return ret; } @@ -519,6 +519,8 @@ str runMALsequence(Client cntxt, MalBlkP runtimeProfileInit(cntxt, mb, stk); runtimeProfileBegin(cntxt, mb, stk, 0, &runtimeProfileFunction, 1); mb->starttime = GDKusec(); + if (cntxt->stimeout && cntxt->session && GDKusec()- cntxt->session > cntxt->stimeout) + throw(MAL, "mal.interpreter", RUNTIME_SESSION_TIMEOUT); } stkpc = startpc; exceptionVar = -1; @@ -711,7 +713,7 @@ str runMALsequence(Client cntxt, MalBlkP runtimeProfileFinish(cntxt, mb); if (pcicaller && garbageControl(getInstrPtr(mb, 0))) garbageCollector(cntxt, mb, stk, TRUE); - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout){ + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout){ ret= createException(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); break; } @@ -726,7 +728,7 @@ str runMALsequence(Client cntxt, MalBlkP w= instruction2str(mb, 0, pci, FALSE); ret = createScriptException(mb, stkpc, MAL, NULL, "unkown operation:%s",w); GDKfree(w); - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout){ + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout){ ret= createException(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); break; } @@ -862,7 +864,7 @@ str runMALsequence(Client cntxt, MalBlkP if (exceptionVar == -1) { runtimeProfileExit(cntxt, mb, stk, pci, &runtimeProfile); runtimeProfileFinish(cntxt, mb); - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout) + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout) ret= createException(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); stkpc = mb->stop; continue; @@ -909,7 +911,7 @@ str runMALsequence(Client cntxt, MalBlkP } } if (stkpc == mb->stop) { - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout){ + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout){ ret= createException(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); stkpc = mb->stop; } @@ -1132,7 +1134,7 @@ str runMALsequence(Client cntxt, MalBlkP default: stkpc++; } - if (cntxt->qtimeout && GDKms() > cntxt->qtimeout){ + if (cntxt->qtimeout && GDKusec()- mb->starttime > cntxt->qtimeout){ ret= createException(MAL, "mal.interpreter", RUNTIME_QRY_TIMEOUT); stkpc= mb->stop; } 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 @@ -359,14 +359,18 @@ CLTsuspend(Client cntxt, MalBlkPtr mb, M return MCsuspendClient(*id); } +//set time out based on seconds str CLTsetTimeout(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { - lng qto= *(lng *) getArgReference(stk,pci,1); - lng sto= *(lng *) getArgReference(stk,pci,2); + lng qto,sto; (void) mb; - cntxt->qtimeout = qto; - cntxt->stimeout = sto; + qto= *(lng *) getArgReference(stk,pci,1); + cntxt->qtimeout = qto * 1000 * 1000; + if ( pci->argc == 3){ + sto= *(lng *) getArgReference(stk,pci,2); + cntxt->stimeout = sto * 1000 * 1000; + } return MAL_SUCCEED; } str diff --git a/monetdb5/modules/mal/clients.mal b/monetdb5/modules/mal/clients.mal --- a/monetdb5/modules/mal/clients.mal +++ b/monetdb5/modules/mal/clients.mal @@ -71,9 +71,13 @@ command wakeup(id:int):void address CLTwakeup comment "Wakeup a client process"; +pattern settimeout(n:lng):void +address CLTsettimeout +comment "Abort a query after n seconds."; + pattern setTimeout(q:lng,s:lng):void address CLTsetTimeout -comment "Abort a query after q milliseconds (q=0 means run undisturbed). +comment "Abort a query after q seconds (q=0 means run undisturbed). The session timeout aborts the connection after spending too many seconds on query processing."; diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c --- a/monetdb5/modules/mal/mat.c +++ b/monetdb5/modules/mal/mat.c @@ -461,7 +461,7 @@ MATmergepack(Client cntxt, MalBlkPtr mb, bn = BATnew(TYPE_void, TYPE_oid, cap); if (bn == NULL) throw(MAL, "mat.pack", MAL_MALLOC_FAIL); - + BATsettrivprop(bn); for (i = 1; i < p->argc; i++) { b = BATdescriptor(stk->stk[getArg(p,i)].val.ival); if( b ){ @@ -473,7 +473,6 @@ MATmergepack(Client cntxt, MalBlkPtr mb, } assert(!bn->H->nil || !bn->H->nonil); assert(!bn->T->nil || !bn->T->nonil); - BATsettrivprop(bn); BBPkeepref(*ret = bn->batCacheid); return MAL_SUCCEED; } diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx --- a/sql/backends/monet5/sql.mx +++ b/sql/backends/monet5/sql.mx @@ -477,7 +477,15 @@ comment "return table of users with sql pattern password(user:str) :str address db_password_wrap -comment "return password hash of user"; +comment "Return password hash of user"; + +pattern settimeout(s:lng):void +address CLTsetTimeout +comment "Abort query after s seconds"; + +pattern settimeout(s:lng,t:lng):void +address CLTsetTimeout +comment "Abort query after s and session after t seconds"; pattern dump_cache()(query:bat[:oid,:str],count:bat[:oid,:int]) address dump_cache diff --git a/sql/scripts/22_clients.sql b/sql/scripts/22_clients.sql --- a/sql/scripts/22_clients.sql +++ b/sql/scripts/22_clients.sql @@ -14,6 +14,12 @@ -- Copyright August 2008-2013 MonetDB B.V. -- All Rights Reserved. -create function password_hash (username string) +create function sys.password_hash (username string) returns string external name sql.password; + +-- control the query time out +create procedure sys.settimeout("query" bigint) + external name sql.settimeout; +create procedure sys.settimeout("query" bigint, "session" bigint) + external name sql.settimeout; diff --git a/sql/test/Tests/systemfunctions.stable.out b/sql/test/Tests/systemfunctions.stable.out --- a/sql/test/Tests/systemfunctions.stable.out +++ b/sql/test/Tests/systemfunctions.stable.out @@ -349,7 +349,7 @@ Ready. [ "sys", "overlaps", 0, "boolean", "create function overlaps(a geometry, b geometry) returns boolean external name geom.\"Overlaps\";" ] [ "sys", "overlaps", 1, "geometry", "" ] [ "sys", "overlaps", 2, "geometry", "" ] -[ "sys", "password_hash", 0, "clob", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\ncreate function password_hash (username string) \n\treturns string \n\texternal name sql.password;" ] +[ "sys", "password_hash", 0, "clob", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\ncreate function sys.password_hash (username string) \n\treturns string \n\texternal name sql.password;" ] [ "sys", "password_hash", 1, "clob", "" ] [ "sys", "pause", 0, "int", "-- operations to manipulate the state of havoc queries\ncreate procedure sys.pause(tag int)\nexternal name sql.sysmon_pause;" ] [ "sys", "pause", 0, "bigint", "create procedure sys.pause(tag bigint)\nexternal name sql.sysmon_pause;" ] @@ -386,6 +386,9 @@ Ready. [ "sys", "setmasklen", 0, "inet", "create function \"setmasklen\" (p inet, mask int) returns inet\n\texternal name inet.\"setmasklen\";" ] [ "sys", "setmasklen", 1, "inet", "" ] [ "sys", "setmasklen", 2, "int", "" ] +[ "sys", "settimeout", 0, "bigint", "-- control the query time out \ncreate procedure sys.settimeout(\"query\" bigint)\n\texternal name sql.settimeout;" ] +[ "sys", "settimeout", 0, "bigint", "create procedure sys.settimeout(\"query\" bigint, \"session\" bigint)\n\texternal name sql.settimeout;" ] +[ "sys", "settimeout", 1, "bigint", "" ] [ "sys", "shrink", 0, "clob", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\n-- Vacuum a relational table should be done with care.\n-- For, the oid's are used in join-indices.\n\n-- Vacuum of tables may improve IO performance and disk footprint.\n-- The foreign key constraints should be dropped before\n-- and re-established after the cluste r operation.\n\ncreate procedure shrink(sys string, tab string)\n\texternal name sql.shrink;" ] [ "sys", "shrink", 1, "clob", "" ] [ "sys", "srid", 0, "int", "create function srid(g geometry) returns integer external name geom.\"SRID\";" ] diff --git a/sql/test/Tests/systemfunctions_nogeom.stable.out b/sql/test/Tests/systemfunctions_nogeom.stable.out --- a/sql/test/Tests/systemfunctions_nogeom.stable.out +++ b/sql/test/Tests/systemfunctions_nogeom.stable.out @@ -256,7 +256,7 @@ Ready. [ "sys", "newurl", 3, "clob", "" ] [ "sys", "optimizer_stats", 0, "table", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\n-- show the optimizer statistics maintained by the SQL frontend\ncreate function sys.optimizer_stats () \n\treturns table (rewrite string, count int) \n\texternal name sql.dump_opt_stats;" ] [ "sys", "optimizers", 0, "table", "-- MONETDB KERNEL SECTION\n-- optimizer pipe catalog\ncreate function sys.optimizers () \n\treturns table (name string, def string, status string)\n\texternal name sql.optimizers;" ] -[ "sys", "password_hash", 0, "clob", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\ncreate function password_hash (username string) \n\treturns string \n\texternal name sql.password;" ] +[ "sys", "password_hash", 0, "clob", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\ncreate function sys.password_hash (username string) \n\treturns string \n\texternal name sql.password;" ] [ "sys", "password_hash", 1, "clob", "" ] [ "sys", "pause", 0, "int", "-- operations to manipulate the state of havoc queries\ncreate procedure sys.pause(tag int)\nexternal name sql.sysmon_pause;" ] [ "sys", "pause", 0, "bigint", "create procedure sys.pause(tag bigint)\nexternal name sql.sysmon_pause;" ] @@ -277,6 +277,9 @@ Ready. [ "sys", "setmasklen", 0, "inet", "create function \"setmasklen\" (p inet, mask int) returns inet\n\texternal name inet.\"setmasklen\";" ] [ "sys", "setmasklen", 1, "inet", "" ] [ "sys", "setmasklen", 2, "int", "" ] +[ "sys", "settimeout", 0, "bigint", "-- control the query time out \ncreate procedure sys.settimeout(\"query\" bigint)\n\texternal name sql.settimeout;" ] +[ "sys", "settimeout", 0, "bigint", "create procedure sys.settimeout(\"query\" bigint, \"session\" bigint)\n\texternal name sql.settimeout;" ] +[ "sys", "settimeout", 1, "bigint", "" ] [ "sys", "shrink", 0, "clob", "-- The contents of this file are subject to the MonetDB Public License\n-- Version 1.1 (the \"License\"); you may not use this file except in\n-- compliance with the License. You may obtain a copy of the License at\n-- http://www.monetdb.org/Legal/MonetDBLicense\n--\n-- Software distributed under the License is distributed on an \"AS IS\"\n-- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\n-- License for the specific language governing rights and limitations\n-- under the License.\n--\n-- The Original Code is the MonetDB Database System.\n--\n-- The Initial Developer of the Original Code is CWI.\n-- Copyright August 2008-2013 MonetDB B.V.\n-- All Rights Reserved.\n\n-- Vacuum a relational table should be done with care.\n-- For, the oid's are used in join-indices.\n\n-- Vacuum of tables may improve IO performance and disk footprint.\n-- The foreign key constraints should be dropped before\n-- and re-established after the cluste r operation.\n\ncreate procedure shrink(sys string, tab string)\n\texternal name sql.shrink;" ] [ "sys", "shrink", 1, "clob", "" ] [ "sys", "stddev_pop", 0, "double", "create aggregate stddev_pop(val tinyint) returns double\n\texternal name \"aggr\".\"stdevp\";" ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list