Changeset: 3aa591c5683b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3aa591c5683b
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
gdk/gdk_utils.c
monetdb5/modules/mal/batExtensions.c
monetdb5/modules/mal/manual.c
monetdb5/modules/mal/oltp.c
monetdb5/modules/mal/querylog.c
monetdb5/modules/mal/querylog.h
sql/backends/monet5/sql.c
sql/backends/monet5/sql.h
sql/backends/monet5/sql_rank.mal
sql/common/sql_types.c
sql/server/rel_select.c
sql/test/Tests/systemfunctions.stable.out
sql/test/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:
Merge with Jul2017 branch.
diffs (truncated from 614 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
@@ -94,6 +94,8 @@ Ready.
[ "aggr", "covar", "function aggr.covar(e1:bat[:lng],
e2:bat[:lng]):lng;", "", "" ]
[ "aggr", "covar", "function aggr.covar(e1:bat[:sht],
e2:bat[:sht]):sht;", "", "" ]
[ "aggr", "exist", "command aggr.exist(b:bat[:any_2], h:any_1):bit
", "ALGexist;", "" ]
+[ "aggr", "exist", "command aggr.exist(b:bat[:any_2]):bit ",
"SQLexist;", "" ]
+[ "aggr", "exist", "command aggr.exist(v:any_2):bit ",
"SQLexist_val;", "" ]
[ "aggr", "jsonaggr", "command aggr.jsonaggr(val:bat[:dbl]):str ",
"JSONgroupStr;", "Aggregate the double values to array." ]
[ "aggr", "jsonaggr", "command aggr.jsonaggr(val:bat[:str]):str ",
"JSONgroupStr;", "Aggregate the string values to array." ]
[ "aggr", "max", "command aggr.max(b:bat[:any_1], g:bat[:oid],
e:bat[:any_2]):bat[:any_1] ", "AGGRmax3;", "" ]
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
@@ -102,6 +102,8 @@ Ready.
[ "aggr", "covar", "function aggr.covar(e1:bat[:lng],
e2:bat[:lng]):lng;", "", "" ]
[ "aggr", "covar", "function aggr.covar(e1:bat[:sht],
e2:bat[:sht]):sht;", "", "" ]
[ "aggr", "exist", "command aggr.exist(b:bat[:any_2], h:any_1):bit
", "ALGexist;", "" ]
+[ "aggr", "exist", "command aggr.exist(b:bat[:any_2]):bit ",
"SQLexist;", "" ]
+[ "aggr", "exist", "command aggr.exist(v:any_2):bit ",
"SQLexist_val;", "" ]
[ "aggr", "jsonaggr", "command aggr.jsonaggr(val:bat[:dbl]):str ",
"JSONgroupStr;", "Aggregate the double values to array." ]
[ "aggr", "jsonaggr", "command aggr.jsonaggr(val:bat[:str]):str ",
"JSONgroupStr;", "Aggregate the string values to array." ]
[ "aggr", "max", "command aggr.max(b:bat[:any_1], g:bat[:oid],
e:bat[:any_2]):bat[:any_1] ", "AGGRmax3;", "" ]
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
@@ -1603,8 +1603,8 @@ str PROFexitClient(Client c);
str PROFinitClient(Client c);
str QLOGappend(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
str QLOGcall(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
-void QLOGcalls(BAT **r);
-void QLOGcatalog(BAT **r);
+str QLOGcalls(BAT **r);
+str QLOGcatalog(BAT **r);
str QLOGdefineNaive(void *ret, str *qry, str *opt, int *nr);
str QLOGdisable(void *ret);
str QLOGempty(void *ret);
@@ -2178,7 +2178,7 @@ void initHeartbeat(void);
void initNamespace(void);
void initParser(void);
void initProfiler(void);
-int initQlog(void);
+str initQlog(void);
int initTrace(void);
int inlineMALblock(MalBlkPtr mb, int pc, MalBlkPtr mc);
str inplaceRef;
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -20,8 +20,6 @@
#include "gdk_private.h"
#include "mutils.h"
-static char GDKdbpathStr[PATHLENGTH] = { "dbpath" };
-
BAT *GDKkey = NULL;
BAT *GDKval = NULL;
int GDKdebug = 0;
@@ -87,9 +85,6 @@ GDKenvironment(const char *dbpath)
fprintf(stderr, "!GDKenvironment: directory not an absolute
path: %s.\n", dbpath);
return 0;
}
- strncpy(GDKdbpathStr, dbpath, PATHLENGTH);
- /* make coverity happy: */
- GDKdbpathStr[PATHLENGTH - 1] = 0;
return 1;
}
@@ -437,7 +432,7 @@ GDKinit(opt *set, int setlen)
char *p;
opt *n;
int i, nlen = 0;
- int persistent_farmid, transient_farmid;
+ int farmid;
char buf[16];
/* some sanity checks (should also find if symbols are not defined) */
@@ -496,16 +491,25 @@ GDKinit(opt *set, int setlen)
_set_error_mode(_OUT_TO_STDERR);
#endif
#endif
- /* now try to lock the database */
- /* type and hptype are unused for now */
- persistent_farmid = BBPselectfarm(PERSISTENT, 0, 0);
- GDKlockHome(persistent_farmid);
- transient_farmid = BBPselectfarm(TRANSIENT, 0, 0);
- if (persistent_farmid != transient_farmid) {
- /* Only lock the transient farm if it is different than the
- * persistent one.
- */
- GDKlockHome(transient_farmid);
+ MT_init();
+ BBPdirty(1);
+
+ /* now try to lock the database: go through all farms, and if
+ * we see a new directory, lock it */
+ for (farmid = 0; farmid < MAXFARMS; farmid++) {
+ if (BBPfarms[farmid].dirname != NULL) {
+ int skip = 0;
+ int j;
+ for (j = 0; j < farmid; j++) {
+ if (BBPfarms[j].dirname != NULL &&
+ strcmp(BBPfarms[farmid].dirname,
BBPfarms[j].dirname) == 0) {
+ skip = 1;
+ break;
+ }
+ }
+ if (!skip)
+ GDKlockHome(farmid);
+ }
}
/* Mserver by default takes 80% of all memory as a default */
@@ -689,7 +693,7 @@ GDKreset(int status, int exit)
MT_Id pid = MT_getpid();
Thread t, s;
struct serverthread *st;
- int persistent_farmid, transient_farmid;
+ int farmid;
if( GDKkey){
BBPunfix(GDKkey->batCacheid);
@@ -737,19 +741,28 @@ GDKreset(int status, int exit)
/* we can't clean up after killing threads */
BBPexit();
}
- GDKlog(GET_GDKLOCK(PERSISTENT), GDKLOGOFF);
- persistent_farmid = BBPselectfarm(PERSISTENT, 0, 0);
- transient_farmid = BBPselectfarm(TRANSIENT, 0, 0);
- if (persistent_farmid != transient_farmid) {
- GDKunlockHome(transient_farmid);
+ GDKlog(GET_GDKLOCK(0), GDKLOGOFF);
+
+ for (farmid = 0; farmid < MAXFARMS; farmid++) {
+ if (BBPfarms[farmid].dirname != NULL) {
+ int skip = 0;
+ int j;
+ for (j = 0; j < farmid; j++) {
+ if (BBPfarms[j].dirname != NULL &&
+ strcmp(BBPfarms[farmid].dirname,
BBPfarms[j].dirname) == 0) {
+ skip = 1;
+ break;
+ }
+ }
+ if (!skip)
+ GDKunlockHome(farmid);
+ }
}
- GDKunlockHome(persistent_farmid);
#if !defined(USE_PTHREAD_LOCKS) && !defined(NDEBUG)
TEMDEBUG GDKlockstatistics(1);
#endif
GDKdebug = 0;
- strcpy(GDKdbpathStr,"dbpath");
GDK_mmap_minsize_persistent = MMAP_MINSIZE_PERSISTENT;
GDK_mmap_minsize_transient = MMAP_MINSIZE_TRANSIENT;
GDK_mmap_pagesize = MMAP_PAGESIZE;
@@ -787,7 +800,7 @@ GDKreset(int status, int exit)
void
GDKexit(int status)
{
- if (GET_GDKLOCK(PERSISTENT) == NULL) {
+ if (GET_GDKLOCK(0) == NULL) {
#ifdef HAVE_EMBEDDED
return;
#endif
@@ -829,42 +842,44 @@ GDKlockHome(int farmid)
{
int fd;
struct stat st;
- str gdklockpath = GDKfilepath(farmid, NULL, GDKLOCK, NULL);
- char GDKdirStr[PATHLENGTH];
- FILE *GDKlockFile = BBPfarms[farmid].lock_file;
+ char *gdklockpath;
+ FILE *GDKlockFile;
- assert(GDKlockFile == NULL);
- assert(GDKdbpathStr != NULL);
+ assert(BBPfarms[farmid].dirname != NULL);
+ assert(BBPfarms[farmid].lock_file == NULL);
- snprintf(GDKdirStr, PATHLENGTH, "%s%c", GDKdbpathStr, DIR_SEP);
+ gdklockpath = GDKfilepath(farmid, NULL, GDKLOCK, NULL);
+
/*
* Obtain the global database lock.
*/
- if (stat(GDKdbpathStr, &st) < 0 && GDKcreatedir(GDKdirStr) !=
GDK_SUCCEED) {
- GDKfatal("GDKlockHome: could not create %s\n", GDKdbpathStr);
+ if (stat(BBPfarms[farmid].dirname, &st) < 0 &&
+ GDKcreatedir(gdklockpath) != GDK_SUCCEED) {
+ GDKfatal("GDKlockHome: could not create %s\n",
+ BBPfarms[farmid].dirname);
}
if ((fd = MT_lockf(gdklockpath, F_TLOCK, 4, 1)) < 0) {
- GDKfatal("GDKlockHome: Database lock '%s' denied\n", GDKLOCK);
+ GDKfatal("GDKlockHome: Database lock '%s' denied\n",
+ gdklockpath);
}
- /* now we have the lock on the database */
+
+ /* now we have the lock on the database and are the only
+ * process allowed in this section */
+
if ((GDKlockFile = fdopen(fd, "r+")) == NULL) {
close(fd);
- GDKfatal("GDKlockHome: Could not open %s\n", GDKLOCK);
+ GDKfatal("GDKlockHome: Could not fdopen %s\n", gdklockpath);
}
- /*
- * We have the lock, are the only process currently allowed in
- * this section.
- */
- MT_init();
- BBPdirty(1);
+ BBPfarms[farmid].lock_file = GDKlockFile;
+
/*
* Print the new process list in the global lock file.
*/
fseek(GDKlockFile, 0, SEEK_SET);
if (ftruncate(fileno(GDKlockFile), 0) < 0)
- GDKfatal("GDKlockHome: Could not truncate %s\n", GDKLOCK);
+ GDKfatal("GDKlockHome: Could not truncate %s\n", gdklockpath);
fflush(GDKlockFile);
- GDKlog(GET_GDKLOCK(PERSISTENT), GDKLOGON);
+ GDKlog(GDKlockFile, GDKLOGON);
GDKfree(gdklockpath);
}
@@ -872,12 +887,11 @@ GDKlockHome(int farmid)
static void
GDKunlockHome(int farmid)
{
- FILE *GDKlockFile = BBPfarms[farmid].lock_file;
- if (GDKlockFile) {
- str gdklockpath = GDKfilepath(0, NULL, GDKLOCK, NULL);
+ if (BBPfarms[farmid].lock_file) {
+ char *gdklockpath = GDKfilepath(farmid, NULL, GDKLOCK, NULL);
MT_lockf(gdklockpath, F_ULOCK, 4, 1);
- fclose(GDKlockFile);
- GDKlockFile = 0;
+ fclose(BBPfarms[farmid].lock_file);
+ BBPfarms[farmid].lock_file = NULL;
GDKfree(gdklockpath);
}
}
@@ -1133,7 +1147,7 @@ GDKfatal(const char *format, ...)
MT_exit_thread(1);
/* exit(1); */
} else {
- GDKlog(GET_GDKLOCK(PERSISTENT), "%s", message);
+ GDKlog(GET_GDKLOCK(0), "%s", message);
#ifdef COREDUMP
abort();
#else
diff --git a/monetdb5/modules/mal/batExtensions.c
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -71,7 +71,7 @@ CMDBATsingle(Client cntxt, MalBlkPtr mb,
b = COLnew(0,getArgType(mb,pci,1),0, TRANSIENT);
if( b == 0)
- throw(MAL,"bat.single","Could not create it");
+ throw(MAL,"bat.single",MAL_MALLOC_FAIL);
if (ATOMextern(b->ttype))
u = (ptr) *(str *)u;
if (BUNappend(b, u, FALSE) != GDK_SUCCEED) {
diff --git a/monetdb5/modules/mal/manual.c b/monetdb5/modules/mal/manual.c
--- a/monetdb5/modules/mal/manual.c
+++ b/monetdb5/modules/mal/manual.c
@@ -42,6 +42,7 @@ MANUALcreateOverview(Client cntxt, MalBl
BBPreclaim(sig);
BBPreclaim(adr);
BBPreclaim(com);
+ throw(MAL, "manual.functions", MAL_MALLOC_FAIL);
}
list[top++] = cntxt->nspace;
diff --git a/monetdb5/modules/mal/oltp.c b/monetdb5/modules/mal/oltp.c
--- a/monetdb5/modules/mal/oltp.c
+++ b/monetdb5/modules/mal/oltp.c
@@ -239,6 +239,7 @@ OLTPtable(Client cntxt, MalBlkPtr mb, Ma
if( bu) BBPunfix(bu->batCacheid);
if( bc) BBPunfix(bc->batCacheid);
if( bq) BBPunfix(bq->batCacheid);
+ throw(MAL,"oltp.table",MAL_MALLOC_FAIL);
}
for( i = 0; msg == MAL_SUCCEED && i < MAXOLTPLOCKS; i++)
if (oltp_locks[i].used ){
diff --git a/monetdb5/modules/mal/querylog.c b/monetdb5/modules/mal/querylog.c
--- a/monetdb5/modules/mal/querylog.c
+++ b/monetdb5/modules/mal/querylog.c
@@ -79,14 +79,17 @@ static BAT *QLOG_calls_result = 0;
static BAT *QLOG_calls_cpuload = 0;
static BAT *QLOG_calls_iowait = 0;
-void
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list