MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-06-22 Thread Sjoerd Mullender
Changeset: 64db91f17817 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/64db91f17817
Modified Files:
monetdb5/mal/mal_profiler.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (298 lines):

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
@@ -31,17 +31,18 @@
 
 #include 
 
-static str myname = 0; // avoid tracing the profiler module
+static const char *myname = 0; // avoid tracing the profiler module
 
 /* The JSON rendering can be either using '\n' separators between
  * each key:value pair or as a single line.
  * The current stethoscope implementation requires the first option and
- * also the term rendering  to be set to ''
+ * also the term rendering to be set to ''
  */
 
 /* When the MAL block contains a BARRIER block we may end up with tons
  * of profiler events. To avoid this, we stop emitting the events
- * when we reached the HIGHWATERMARK. Leaving a message in the log. */
+ * when we reached the HIGHWATERMARK. Leaving a message in the log.
+ */
 #define HIGHWATERMARK 5
 
 
@@ -60,18 +61,17 @@ static struct rusage prevUsage;
 #define LOGLEN 8192
 
 // The heart beat events should be sent to all outstanding channels.
-static void logjsonInternal(char *logbuffer)
+static void logjsonInternal(char *logbuffer, bool flush)
 {
size_t len;
len = strlen(logbuffer);
 
-   MT_lock_set(_profileLock);
if (maleventstream) {
-   // upon request the log record is sent over the profile stream
+   // upon request the log record is sent over the profile stream
(void) mnstr_write(maleventstream, logbuffer, 1, len);
-   (void) mnstr_flush(maleventstream, MNSTR_FLUSH_DATA);
+   if (flush)
+   (void) mnstr_flush(maleventstream, MNSTR_FLUSH_DATA);
}
-   MT_lock_unset(_profileLock);
 }
 
 /*
@@ -141,7 +141,7 @@ logadd(struct logbuf *logbuf, const char
/* includes first time when logbuffer == NULL and 
logcap = 0 */
char *alloc_buff;
if (logbuf->loglen > 0)
-   logjsonInternal(logbuf->logbuffer);
+   logjsonInternal(logbuf->logbuffer, false);
logbuf->logcap = (size_t) tmp_len + (size_t) tmp_len/2;
if (logbuf->logcap < LOGLEN)
logbuf->logcap = LOGLEN;
@@ -156,7 +156,7 @@ logadd(struct logbuf *logbuf, const char
logbuf->logbuffer = alloc_buff;
lognew(logbuf);
} else {
-   logjsonInternal(logbuf->logbuffer);
+   logjsonInternal(logbuf->logbuffer, false);
lognew(logbuf);
}
}
@@ -170,20 +170,20 @@ logadd(struct logbuf *logbuf, const char
 
 /* JSON rendering method of performance data.
  * The eventparser may assume this layout for ease of parsing
-EXAMPLE:
-{
-"event":6,
-"thread":3,
-"function":"user.s3_1",
-"pc":1,
-"tag":10397,
-"state":"start",
-"usec":0,
-}
-"stmt":"X_41=0@0:void := querylog.define(\"select count(*) from 
tables;\":str,\"default_pipe\":str,30:int);",
+ EXAMPLE:
+ {
+ "event":6,
+ "thread":3,
+ "function":"user.s3_1",
+ "pc":1,
+ "tag":10397,
+ "state":"start",
+ "usec":0,
+ }
+ "stmt":"X_41=0@0:void := querylog.define(\"select count(*) from 
tables;\":str,\"default_pipe\":str,30:int);",
 */
 static void
-renderProfilerEvent(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, 
int start)
+prepareProfilerEvent(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, 
int start)
 {
struct logbuf logbuf;
str c;
@@ -202,9 +202,9 @@ renderProfilerEvent(Client cntxt, MalBlk
return;
}
 
-/* The stream of events can be complete read by the DBA,
- * all other users can only see events assigned to their account
- */
+   /* The stream of events can be complete read by the DBA,
+* all other users can only see events assigned to their account
+*/
if(malprofileruser!= MAL_ADMIN && malprofileruser != cntxt->user)
return;
 
@@ -303,7 +303,7 @@ renderProfilerEvent(Client cntxt, MalBlk
c =getVarName(mb, getArg(pci,j));
if(getVarSTC(mb,getArg(pci,j))){
InstrPtr stc = getInstrPtr(mb, 
getVarSTC(mb,getArg(pci,j)));
-   if (stc &&
+   if (stc && getModuleId(stc) &&
strcmp(getModuleId(stc),"sql") ==0 &&
strncmp(getFunctionId(stc),"bind",4)==0 
&&
!logadd(, 
",\"alias\":\"%s.%s.%s\"",
@@ -317,13 +317,16 @@ renderProfilerEvent(Client cntxt, MalBlk

MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-24 Thread Sjoerd Mullender
Changeset: c1fc0f734a0d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c1fc0f734a0d
Modified Files:
sql/benchmarks/tpcds/Tests/40.stable.out
sql/benchmarks/tpcds/Tests/40.stable.out.int128
sql/test/pg_regress/Tests/polygon.stable.out
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (158 lines):

diff --git a/geom/sql/conformance/Tests/T48.stable.out 
b/geom/sql/conformance/Tests/T48.stable.out
--- a/geom/sql/conformance/Tests/T48.stable.out
+++ b/geom/sql/conformance/Tests/T48.stable.out
@@ -29,7 +29,7 @@ stdout of test 'T48` in directory 'geom/
 % %1 # name
 % clob # type
 % 45 # length
-[ "POLYGON ((62 48, 84 48, 84 42, 56 34, 62 48))"  ]
+[ "POLYGON ((84 48, 84 42, 56 34, 62 48, 84 48))"  ]
 
 # 15:15:54 >  
 # 15:15:54 >  "Done."
diff --git a/geom/sql/conformance/Tests/T49.stable.out 
b/geom/sql/conformance/Tests/T49.stable.out
--- a/geom/sql/conformance/Tests/T49.stable.out
+++ b/geom/sql/conformance/Tests/T49.stable.out
@@ -29,7 +29,7 @@ stdout of test 'T49` in directory 'geom/
 % %1 # name
 % clob # type
 % 43 # length
-[ "POLYGON ((52 18, 66 23, 73 9, 48 6, 52 18))"]
+[ "POLYGON ((66 23, 73 9, 48 6, 52 18, 66 23))"]
 
 # 15:15:54 >  
 # 15:15:54 >  "Done."
diff --git a/geom/sql/functions/Tests/ST_NumPoints.stable.err 
b/geom/sql/functions/Tests/ST_NumPoints.stable.err
--- a/geom/sql/functions/Tests/ST_NumPoints.stable.err
+++ b/geom/sql/functions/Tests/ST_NumPoints.stable.err
@@ -31,7 +31,7 @@ stderr of test 'ST_NumPoints` in directo
 
 MAPI  = (monetdb) /var/tmp/mtest-8056/.s.monetdb.39838
 QUERY = SELECT ST_NumPoints(ST_GeomFromText('polygon((77.29 29.07,77.42 
29.26,77.27 29.31,77.29 29.07))'));
-ERROR = !Geometry "POLYGON ((77.290001 29.07, 77.42 29.26, 77.27 
29.31, 77.290001 29.07))" not a LineString
+ERROR = !Geometry "POLYGON ((77.29 29.07, 77.42 29.26, 77.27 29.31, 77.29 
29.07))" not a LineString
 CODE  = 38000
 MAPI  = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685
 QUERY = select st_numPoints(st_mpointFromText('multipoint(1 2 3, 4 5 6, 7 8 9, 
10 11 12)'));
diff --git a/geom/sql/functions/Tests/ST_NumPoints.stable.out 
b/geom/sql/functions/Tests/ST_NumPoints.stable.out
--- a/geom/sql/functions/Tests/ST_NumPoints.stable.out
+++ b/geom/sql/functions/Tests/ST_NumPoints.stable.out
@@ -25,8 +25,8 @@ stdout of test 'ST_NumPoints` in directo
 # 09:53:35 >  
 
 #SELECT ST_NumPoints(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 
29.31,77.29 29.07)'));
-% . # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
 % int # type
 % 1 # length
 [ 4]
diff --git a/geom/sql/pg_regression/Tests/dump.stable.out 
b/geom/sql/pg_regression/Tests/dump.stable.out
--- a/geom/sql/pg_regression/Tests/dump.stable.out
+++ b/geom/sql/pg_regression/Tests/dump.stable.out
@@ -98,14 +98,14 @@ stdout of test 'dump` in directory 'geom
 % %4,  id, polygonwkb # name
 % char,clob,   geometry # type
 % 3,   3,  0 # length
-[ "t11",   "1","GEOMETRYCOLLECTION EMPTY"  ]
+[ "t11",   "1","GEOMETRYCOLLECTION (GEOMETRYCOLLECTION EMPTY, 
LINESTRING EMPTY, POLYGON EMPTY, MULTIPOINT EMPTY, MULTILINESTRING EMPTY, 
MULTIPOLYGON EMPTY, GEOMETRYCOLLECTION (GEOMETRYCOLLECTION EMPTY))"]
 [ "t11",   "1","GEOMETRYCOLLECTION EMPTY"  ]
 [ "t11",   "2","LINESTRING EMPTY"  ]
 [ "t11",   "3","POLYGON EMPTY" ]
 [ "t11",   "4","MULTIPOINT EMPTY"  ]
 [ "t11",   "5","MULTILINESTRING EMPTY" ]
 [ "t11",   "6","MULTIPOLYGON EMPTY"]
-[ "t11",   "7","GEOMETRYCOLLECTION EMPTY"  ]
+[ "t11",   "7","GEOMETRYCOLLECTION (GEOMETRYCOLLECTION EMPTY)" ]
 [ "t11",   "7,1",  "GEOMETRYCOLLECTION EMPTY"  ]
 
 # 12:29:09 >  
diff --git a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_10.stable.err 
b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_10.stable.err
--- a/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_10.stable.err
+++ b/sql/backends/monet5/UDF/pyapi3/Tests/pyapi3_10.stable.err
@@ -38,7 +38,7 @@ ERROR = !Could not parse Python code
 !  1. def pyfun(i,j,_columns,_column_types,_conn):
 !> 2. return(i*j 
 !  3. 
-!unexpected EOF while parsing (, line 2)
+!'(' was never closed (, line 2)
 CODE  = PY000
 MAPI  = (monetdb) /var/tmp/mtest-13372/.s.monetdb.36607
 QUERY = SELECT AVG(pyapi10_indentation_error(i,j)) FROM 
pyapi10_random_table_nulls(5000);
diff --git 
a/sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.out 
b/sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.out
--- a/sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.out
+++ b/sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.out
@@ -51,10 +51,10 @@ stdout of test 'python-microseconds.Bug-
 # 17:15:02 >  
 
 [(datetime.datetime(2014, 4, 24, 17, 12, 12, 415000),)]
-[(datetime.datetime(2014, 4, 24, 19, 12, 12, 415000),)]
+[(datetime.datetime(2014, 4, 24, 21, 12, 12, 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-16 Thread Sjoerd Mullender
Changeset: ceaa337f8fef for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ceaa337f8fef
Modified Files:
clients/mapiclient/mclient.c
clients/mapilib/mapi.c
gdk/gdk.h
gdk/gdk_aggr.c
monetdb5/extras/rapi/rapi.c
sql/backends/monet5/sql.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (135 lines):

diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1011,15 +1011,15 @@ static ATOMIC_FLAG mapi_initialized = AT
return (e); \
}   \
} while (0)
-#define REALLOC(p, c)  \
-   do {\
-   if (p) {\
-   void *tmp = (p);\
-   (p) = realloc((p), (c) * sizeof(*(p))); \
-   if ((p) == NULL)\
-   free(tmp);  \
-   } else  \
-   (p) = malloc((c) * sizeof(*(p)));   \
+#define REALLOC(p, c)  \
+   do {\
+   if (p) {\
+   void *tmp = realloc((p), (c) * sizeof(*(p)));   \
+   if (tmp == NULL)\
+   free(p);\
+   (p) = tmp;  \
+   } else  \
+   (p) = malloc((c) * sizeof(*(p)));   \
} while (0)
 
 /*
@@ -3351,11 +3351,11 @@ mapi_prepare(Mapi mid, const char *cmd)
do {\
/* note: k==strlen(hdl->query) */   \
if (k+len >= lim) { \
-   char *q = hdl->query;   \
lim = k + len + MAPIBLKSIZE;\
-   hdl->query = realloc(hdl->query, lim);  \
-   if (hdl->query == NULL) {   \
-   free(q);\
+   char *q = realloc(hdl->query, lim); \
+   if (q == NULL) {\
+   free(hdl->query);   \
+   hdl->query = NULL;  \
return; \
}   \
}   \
@@ -3491,11 +3491,11 @@ mapi_param_store(MapiHdl hdl)
val = mapi_quote(buf, 1);
/* note: k==strlen(hdl->query) */
if (k + strlen(val) + 3 >= lim) {
-   char *q = hdl->query;
lim = k + strlen(val) + 3 + MAPIBLKSIZE;
-   hdl->query = realloc(hdl->query, lim);
-   if (hdl->query == NULL) {
-   free(q);
+   char *q = realloc(hdl->query, lim);
+   if (q == NULL) {
+   free(hdl->query);
+   hdl->query = NULL;
free(val);
return;
}
@@ -3508,11 +3508,11 @@ mapi_param_store(MapiHdl hdl)
val = mapi_quote((char *) src, 
hdl->params[i].sizeptr ? *hdl->params[i].sizeptr : -1);
/* note: k==strlen(hdl->query) */
if (k + strlen(val) + 3 >= lim) {
-   char *q = hdl->query;
lim = k + strlen(val) + 3 + MAPIBLKSIZE;
-   hdl->query = realloc(hdl->query, lim);
-   if (hdl->query == NULL) {
-   free(q);
+   char *q = realloc(hdl->query, lim);
+   if (q == NULL) {
+   free(hdl->query);
+   hdl->query = NULL;
   

MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-13 Thread Sjoerd Mullender
Changeset: 89f904bae064 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/89f904bae064
Modified Files:
.hgtags
gdk/gdk_utils.h
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (39 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -803,3 +803,4 @@ 6b71a8cc3498561815ac88d6c652922359efd13a
 5cb19dc0880d1fb4799cd0f8019d1c2b430c503e Oct2020_17
 5cb19dc0880d1fb4799cd0f8019d1c2b430c503e Oct2020_SP5_release
 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_13
+1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_SP2_release
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -162,9 +162,11 @@ gdk_export int GDKms(void);
({  \
void *_ptr = (p);   \
size_t _size = (s); \
+   char _buf[12];  \
+   snprintf(_buf, sizeof(_buf), "%p", _ptr);   \
void *_res = GDKrealloc(_ptr, _size);   \
-   TRC_DEBUG(ALLOC, "GDKrealloc(%p,%zu) -> %p\n",  \
- _ptr, _size, _res);   \
+   TRC_DEBUG(ALLOC, "GDKrealloc(%s,%zu) -> %p\n",  \
+ _buf, _size, _res);   \
_res;   \
 })
 #define GDKfree(p) \
@@ -233,9 +235,11 @@ gdk_export int GDKms(void);
({  \
void *_ptr = (p);   \
size_t _size = (s); \
+   char _buf[12];  \
+   snprintf(_buf, sizeof(_buf), "%p", _ptr);   \
void *_res = realloc(_ptr, _size);  \
-   TRC_DEBUG(ALLOC, "realloc(%p,%zu) -> %p\n", \
- _ptr, _size, _res);   \
+   TRC_DEBUG(ALLOC, "realloc(%s,%zu) -> %p\n", \
+ _buf, _size, _res);   \
_res;   \
 })
 #define free(p)\
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch, not changing any f...

2022-05-09 Thread Sjoerd Mullender
Changeset: a89f2e58bb4d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a89f2e58bb4d
Removed Files:
NT/monetdb_config.h.in
NT/rules.msc
configure.ag
Modified Files:
.bumpversion.cfg
MonetDB.spec
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
Branch: Oct2020
Log Message:

Merge with Jun2020 branch, not changing any files..

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-09 Thread Sjoerd Mullender
Changeset: bdfe5a875eb4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bdfe5a875eb4
Modified Files:
.hgtags
MonetDB.spec
debian/changelog
gdk/ChangeLog-Archive
sql/ChangeLog-Archive
tools/merovingian/ChangeLog-Archive
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (8 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -802,3 +802,4 @@ 6b71a8cc3498561815ac88d6c652922359efd13a
 6b71a8cc3498561815ac88d6c652922359efd13a Oct2020_SP4_release
 5cb19dc0880d1fb4799cd0f8019d1c2b430c503e Oct2020_17
 5cb19dc0880d1fb4799cd0f8019d1c2b430c503e Oct2020_SP5_release
+1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_13
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch, not changing any f...

2022-05-09 Thread Sjoerd Mullender
Changeset: 339fd7875270 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/339fd7875270
Removed Files:
NT/monetdb_config.h.in
NT/rules.msc
configure.ag
Modified Files:
.bumpversion.cfg
MonetDB.spec
clients/mapilib/mapi.rc
clients/odbc/driver/driver.rc
clients/odbc/winsetup/setup.rc
gdk/libbat.rc
monetdb5/tools/libmonetdb5.rc
Branch: Oct2020
Log Message:

Merge with Jun2020 branch, not changing any files.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-09 Thread Sjoerd Mullender
Changeset: 9c8372259853 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9c8372259853
Modified Files:
debian/control
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-09 Thread Sjoerd Mullender
Changeset: 958f46f1bc99 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/958f46f1bc99
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-05-04 Thread Sjoerd Mullender
Changeset: c711c0f0b560 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c711c0f0b560
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_logger.c
gdk/gdk_logger.h
sql/storage/bat/bat_logger.c
sql/storage/store.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (12 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2472,7 +2472,7 @@ logger_destroy(logger *lg)
BAT *b = lg->catalog_bid;
 
if (lg->changes &&
-   (logger_restart(lg) != GDK_SUCCEED ||
+   (logger_flush(lg, lg->tid+1) != GDK_SUCCEED ||
 logger_cleanup(lg) != GDK_SUCCEED))
TRC_CRITICAL(GDK, "logger_cleanup failed\n");
 
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-04-25 Thread Sjoerd Mullender
Changeset: 42963de663cb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/42963de663cb
Modified Files:
gdk/gdk_logger.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (25 lines):

diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1179,6 +1179,12 @@ logger_readlog(logger *lg, char *filenam
char tpe;
oid id;
 
+   if (l.flag == 0) {
+   /* end of useful content */
+   assert(l.tid == 0);
+   assert(l.nr == 0);
+   break;
+   }
t1 = time(NULL);
if (t1 - t0 > 10) {
lng fpos;
@@ -1317,8 +1323,6 @@ logger_readlog(logger *lg, char *filenam
else
err = log_read_clear(lg, tr, name, tpe, id);
break;
-   case 0:
-   break;
default:
err = LOG_ERR;
}
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-04-14 Thread Sjoerd Mullender
Changeset: f2b8f82764bb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f2b8f82764bb
Modified Files:
gdk/gdk_align.c
gdk/gdk_batop.c
gdk/gdk_logger.c
gdk/gdk_private.h
gdk/gdk_storage.c
gdk/gdk_string.c
gdk/gdk_utils.c
monetdb5/modules/atoms/str.c
sql/backends/monet5/sql.c
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (44 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -2438,6 +2438,14 @@ mvc_result_set_wrap( Client cntxt, MalBl
b = BATdescriptor(bid);
if ( b == NULL)
throw(MAL,"sql.resultset", SQLSTATE(HY005) "Cannot access 
column descriptor");
+   if (isVIEW(b)) {
+   BAT *bn = COLcopy(b, b->ttype, true, TRANSIENT);
+   BBPunfix(b->batCacheid);
+   if (bn == NULL)
+   throw(MAL, "sql.resultset", GDK_EXCEPTION);
+   b = bn;
+   assert(!isVIEW(b));
+   }
res = *res_id = mvc_result_table(be, mb->tag, pci->argc - (pci->retc + 
5), Q_TABLE, b);
if (res < 0)
msg = createException(SQL, "sql.resultSet", SQLSTATE(45000) 
"Result table construction failed");
@@ -2463,12 +2471,21 @@ mvc_result_set_wrap( Client cntxt, MalBl
colname = BUNtvar(iteratr,o);
tpename = BUNtvar(itertpe,o);
b = BATdescriptor(bid);
-   if ( b == NULL)
+   if ( b == NULL) {
msg= 
createException(MAL,"sql.resultset",SQLSTATE(HY005) "Cannot access column 
descriptor ");
-   else if (mvc_result_column(be, tblname, colname, tpename, 
*digits++, *scaledigits++, b))
+   break;
+   }
+   if (isVIEW(b)) {
+   BAT *bn = COLcopy(b, b->ttype, true, TRANSIENT);
+   BBPunfix(b->batCacheid);
+   if (bn == NULL)
+   throw(MAL, "sql.resultset", GDK_EXCEPTION);
+   b = bn;
+   assert(!isVIEW(b));
+   }
+   if (mvc_result_column(be, tblname, colname, tpename, *digits++, 
*scaledigits++, b))
msg = createException(SQL, "sql.resultset", 
SQLSTATE(42000) "Cannot access column descriptor %s.%s",tblname,colname);
-   if( b)
-   BBPunfix(bid);
+   BBPunfix(b->batCacheid);
}
/* now send it to the channel cntxt->fdout */
if (mvc_export_result(cntxt->sqlcontext, cntxt->fdout, res, true, 
mb->starttime, mb->optimize))
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2022-04-13 Thread Sjoerd Mullender
Changeset: 703d46938bc0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/703d46938bc0
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.

___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-09-02 Thread Sjoerd Mullender
Changeset: 18b7db92b8ed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/18b7db92b8ed
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.

___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-06-28 Thread Sjoerd Mullender
Changeset: bc6eb7167efe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bc6eb7167efe
Modified Files:
gdk/gdk_logger.c
monetdb5/modules/mal/tablet.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (54 lines):

diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -1235,12 +1235,13 @@ SQLproducer(void *p)
bool blocked[MAXBUFFERS] = { false };
bool ateof[MAXBUFFERS] = { false };
BUN cnt = 0, bufcnt[MAXBUFFERS] = { 0 };
-   char *end, *e, *s = NULL, *base;
+   char *end = NULL, *e = NULL, *s = NULL, *base;
const char *rsep = task->rsep;
size_t rseplen = strlen(rsep), partial = 0;
char quote = task->quote;
dfa_t rdfa;
lng rowno = 0;
+   int more = 0;
 
MT_sema_down(>producer);
if (task->id < 0) {
@@ -1447,6 +1448,7 @@ SQLproducer(void *p)
task->cur = cur;
task->ateof = ateof[cur];
task->cnt = bufcnt[cur];
+   more = !ateof[cur] || (e && e < end && task->top[cur] 
== task->limit);
 /* TRC_DEBUG(MAL_SERVER, "SQL producer got buffer '%d' 
filled with '%d' records\n", cur, task->top[cur]);*/
 
MT_sema_up(>consumer);
@@ -1464,7 +1466,7 @@ SQLproducer(void *p)
 /* TRC_DEBUG(MAL_SERVER, "Continue producer buffer: %d\n", cur);*/
 
/* we ran out of input? */
-   if (task->ateof) {
+   if (task->ateof && !more) {
 /* TRC_DEBUG(MAL_SERVER, "Producer encountered eof\n");*/
GDKfree(rdfa);
return;
@@ -1528,7 +1530,7 @@ SQLload_file(Client cntxt, Tablet *as, b
BUN i, attr;
READERtask task;
READERtask ptask[MAXWORKERS];
-   int threads = (maxrow< 0 || maxrow > (1 << 16)) ? (GDKnr_threads < 
MAXWORKERS && GDKnr_threads > 1 ? GDKnr_threads - 1 : MAXWORKERS - 1) : 1;
+   int threads = (maxrow< 0 || maxrow > (1 << 16)) && GDKnr_threads > 1 ? 
(GDKnr_threads < MAXWORKERS ? GDKnr_threads - 1 : MAXWORKERS - 1) : 1;
lng lio = 0, tio, t1 = 0, total = 0, iototal = 0;
char name[MT_NAME_LEN];
 
@@ -1836,6 +1838,9 @@ SQLload_file(Client cntxt, Tablet *as, b
task.maxrow = cnt;
task.state = ENDOFCOPY;
}
+   if (task.ateof && task.top[task.cur] < task.limit && cnt != 
task.maxrow)
+   break;
+   task.top[task.cur] = 0;
MT_sema_up();
}
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch, doing things total...

2021-06-07 Thread Sjoerd Mullender
Changeset: 814b56984a10 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/814b56984a10
Modified Files:
cmake/monetdb-functions.cmake
Branch: Oct2020
Log Message:

Merge with Jun2020 branch, doing things totally differently for cmake.


diffs (20 lines):

diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake
--- a/cmake/monetdb-functions.cmake
+++ b/cmake/monetdb-functions.cmake
@@ -8,7 +8,15 @@
 
 function(monetdb_hg_revision)
   # Get the current version control revision
-  if(EXISTS "${CMAKE_SOURCE_DIR}/.hg")
+  if(EXISTS "${CMAKE_SOURCE_DIR}/.hg_archival.txt")
+execute_process(COMMAND "sed" "-n" "s/^node: 
\\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\\).*/\\1/p"
 ".hg_archival.txt" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE 
HG_RETURN_CODE
+  OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES)
+  set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE)
+else()
+  message(FATAL_ERROR "Failed to find mercurial ID")
+endif()
+  elseif(EXISTS "${CMAKE_SOURCE_DIR}/.hg")
 find_package(Hg)
 if(HG_FOUND)
   message("hg found: ${HG_EXECUTABLE}")
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-04-19 Thread Sjoerd Mullender
Changeset: e39b28036e7c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e39b28036e7c
Modified Files:
gdk/gdk_atoms.h
sql/server/sql_scan.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (33 lines):

diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -396,7 +396,7 @@ strEQ(const char *l, const char *r)
 static inline bool __attribute__((__pure__))
 strNil(const char *s)
 {
-   return s == NULL || *s == '\200';
+   return s == NULL || (s[0] == '\200' && s[1] == '\0');
 }
 
 static inline size_t __attribute__((__pure__))
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -30,7 +30,7 @@
 char *
 query_cleaned(sql_allocator *sa, const char *query)
 {
-   char *q, *r, *c;
+   char *q, *r, *c = NULL;
int lines = 0;
int quote = 0;  /* inside quotes ('..', "..", {..}) */
bool bs = false;/* seen a backslash in a quoted string 
*/
@@ -42,8 +42,6 @@ query_cleaned(sql_allocator *sa, const c
if(!r)
return NULL;
 
-   (void) c;
-
for (q = r; *query; query++) {
if (incomment1) {
if (*query == '/' && query[-1] == '*') {
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-04-18 Thread Sjoerd Mullender
Changeset: 13d1e98e03f4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/13d1e98e03f4
Modified Files:
gdk/gdk_string.c
sql/server/sql_scan.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (159 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -108,11 +108,14 @@ strCleanHash(Heap *h, bool rebuild)
 * started. */
memset(newhash, 0, sizeof(newhash));
pos = GDK_STRHASHSIZE;
-   while (pos < h->free &&
-  pos + (pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1))) < 
GDK_ELIMLIMIT) {
+   while (pos < h->free) {
+   pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
if (pad < sizeof(stridx_t))
pad += GDK_VARALIGN;
-   pos += pad + extralen;
+   pos += pad;
+   if (pos >= GDK_ELIMLIMIT)
+   break;
+   pos += extralen;
s = h->base + pos;
if (h->hashash)
strhash = ((const BUN *) s)[-1];
@@ -276,9 +279,11 @@ strPut(Heap *h, var_t *dst, const char *
pad = 0;
}
 
+   pad += extralen;
+
/* check heap for space (limited to a certain maximum after
 * which nils are inserted) */
-   if (h->free + pad + len + extralen >= h->size) {
+   if (h->free + pad + len >= h->size) {
size_t newsize = MAX(h->size, 4096);
 
/* double the heap size until we have enough space */
@@ -287,11 +292,11 @@ strPut(Heap *h, var_t *dst, const char *
newsize <<= 1;
else
newsize += 4 * 1024 * 1024;
-   } while (newsize <= h->free + pad + len + extralen);
+   } while (newsize <= h->free + pad + len);
 
assert(newsize);
 
-   if (h->free + pad + len + extralen >= (size_t) VAR_MAX) {
+   if (h->free + pad + len >= (size_t) VAR_MAX) {
GDKerror("string heaps gets larger than %zuGiB.\n", 
(size_t) VAR_MAX >> 30);
return 0;
}
@@ -299,19 +304,16 @@ strPut(Heap *h, var_t *dst, const char *
if (HEAPextend(h, newsize, true) != GDK_SUCCEED) {
return 0;
}
-#ifndef NDEBUG
-   /* fill should solve initialization problems within
-* valgrind */
-   memset(h->base + h->free, 0, h->size - h->free);
-#endif
 
/* make bucket point into the new heap */
bucket = ((stridx_t *) h->base) + off;
}
 
/* insert string */
-   pos = h->free + pad + extralen;
+   pos = h->free + pad;
*dst = (var_t) pos;
+   if (pad > 0)
+   memset(h->base + h->free, 0, pad);
memcpy(h->base + pos, v, len);
if (h->hashash) {
((BUN *) (h->base + pos))[-1] = strhash;
@@ -319,7 +321,7 @@ strPut(Heap *h, var_t *dst, const char *
((BUN *) (h->base + pos))[-2] = (BUN) len;
 #endif
}
-   h->free += pad + len + extralen;
+   h->free += pad + len;
h->dirty = true;
 
/* maintain hash table */
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -24,30 +24,50 @@
 #include 
 #include "sql_keyword.h"
 
+/**
+ * Removes all comments before the query. In query comments are kept.
+ */
 char *
 query_cleaned(sql_allocator *sa, const char *query)
 {
-   char *q, *r;
+   char *q, *r, *c;
+   int lines = 0;
int quote = 0;  /* inside quotes ('..', "..", {..}) */
bool bs = false;/* seen a backslash in a quoted string 
*/
bool incomment1 = false;/* inside traditional C style comment */
bool incomment2 = false;/* inside comment starting with --  */
+   bool inline_comment = false;
+
r = SA_NEW_ARRAY(sa, char, strlen(query) + 1);
if(!r)
return NULL;
 
+   (void) c;
+
for (q = r; *query; query++) {
if (incomment1) {
if (*query == '/' && query[-1] == '*') {
incomment1 = false;
+   if (c == r && lines > 0) {
+   q = r; // reset to beginning
+   lines = 0;
+   continue;
+   }
}
+   if (*query == '\n') lines++;
+   *q++ = *query;
} else if (incomment2) {
if (*query == '\n') {
incomment2 = false;
+   inline_comment = false;
/* add newline only if comment 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-04-14 Thread Sjoerd Mullender
Changeset: 0dd353ec7b4b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0dd353ec7b4b
Modified Files:
gdk/gdk_string.c
monetdb5/mal/mal_interpreter.c
tools/merovingian/daemon/argvcmds.c
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/monetdbd.1.in
tools/merovingian/utils/utils.c
tools/merovingian/utils/utils.h
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (224 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -108,8 +108,8 @@ strCleanHash(Heap *h, bool rebuild)
 * started. */
memset(newhash, 0, sizeof(newhash));
pos = GDK_STRHASHSIZE;
-   while (pos < h->free && pos < GDK_ELIMLIMIT) {
-   pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
+   while (pos < h->free &&
+  pos + (pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1))) < 
GDK_ELIMLIMIT) {
if (pad < sizeof(stridx_t))
pad += GDK_VARALIGN;
pos += pad + extralen;
@@ -219,7 +219,6 @@ checkUTF8(const char *v)
 var_t
 strPut(Heap *h, var_t *dst, const char *v)
 {
-   size_t elimbase = GDK_ELIMBASE(h->free);
size_t pad;
size_t pos, len = strLen(v);
const size_t extralen = h->hashash ? EXTRALEN : 0;
@@ -265,19 +264,16 @@ strPut(Heap *h, var_t *dst, const char *
}
 
pad = GDK_VARALIGN - (h->free & (GDK_VARALIGN - 1));
-   if (elimbase == 0) {/* i.e. h->free < GDK_ELIMLIMIT */
+   if (GDK_ELIMBASE(h->free + pad) == 0) { /* i.e. h->free+pad < 
GDK_ELIMLIMIT */
if (pad < sizeof(stridx_t)) {
/* make room for hash link */
pad += GDK_VARALIGN;
}
-   } else if (extralen == 0) { /* i.e., h->hashash == FALSE */
-   /* no VARSHIFT and no string hash value stored => no
-* padding/alignment needed */
+   } else if (GDK_ELIMBASE(h->free) != 0) {
+   /* no extra padding needed when no hash links needed
+* (but only when padding doesn't cross duplicate
+* elimination boundary) */
pad = 0;
-   } else {
-   /* pad to align on VARALIGN for VARSHIFT and/or string
-* hash value */
-   pad &= (GDK_VARALIGN - 1);
}
 
/* check heap for space (limited to a certain maximum after
@@ -328,7 +324,7 @@ strPut(Heap *h, var_t *dst, const char *
 
/* maintain hash table */
pos -= extralen;
-   if (elimbase == 0) {/* small string heap: link the next pointer */
+   if (GDK_ELIMBASE(pos) == 0) {   /* small string heap: link the next 
pointer */
/* the stridx_t next pointer directly precedes the
 * string and optional (depending on hashash) hash
 * value */
diff --git a/tools/merovingian/daemon/argvcmds.c 
b/tools/merovingian/daemon/argvcmds.c
--- a/tools/merovingian/daemon/argvcmds.c
+++ b/tools/merovingian/daemon/argvcmds.c
@@ -509,19 +509,26 @@ command_stop(confkeyval *ckv, int argc, 
return(1);
}
 
-   /* wait up to 30 seconds for monetdbd to actually stop */
-   for (i = 0; i < 60; i++) {
-   tv.tv_sec = 0;
-   tv.tv_usec = 50;
-   select(0, NULL, NULL, NULL, );
-   if (kill(daemon, 0) == -1) {
-   /* daemon has died */
-   return(0);
+   int exittimeout = getConfNum(ckv, "exittimeout");
+   if (exittimeout != 0) {
+   if (exittimeout > 0) {
+   /* wait a tad longer for monetdbd to die than for the
+* mserver processes */
+   exittimeout += 5;
}
-   }
+   for (i = 0; exittimeout < 0 || i < exittimeout * 2; i++) {
+   tv.tv_sec = 0;
+   tv.tv_usec = 50;
+   select(0, NULL, NULL, NULL, );
+   if (kill(daemon, 0) == -1) {
+   /* daemon has died */
+   return(0);
+   }
+   }
 
-   /* done waiting, use harsher measures */
-   kill(daemon, SIGKILL);
+   /* done waiting, use harsher measures */
+   kill(daemon, SIGKILL);
+   }
 
return(0);
 }
diff --git a/tools/merovingian/daemon/forkmserver.c 
b/tools/merovingian/daemon/forkmserver.c
--- a/tools/merovingian/daemon/forkmserver.c
+++ b/tools/merovingian/daemon/forkmserver.c
@@ -120,7 +120,8 @@ terminateProcess(char *dbname, pid_t pid
return false;
}
kv = findConfKey(_mero_props, "exittimeout");
-   for (i = 0; i < atoi(kv->val) * 2; i++) {
+   int exittimeout = atoi(kv->val);
+   for (i 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-03-19 Thread Sjoerd Mullender
Changeset: 4cc759c56763 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4cc759c56763
Modified Files:
gdk/gdk_aggr.c
sql/server/rel_optimizer.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (109 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3683,7 +3683,8 @@ static BAT *
 doBATgroupquantile(BAT *b, BAT *g, BAT *e, BAT *s, int tp, double quantile,
   bool skip_nils, bool abort_on_error, bool average)
 {
-   bool freeb = false, freeg = false;
+   BAT *origb = b;
+   BAT *origg = g;
oid min, max;
BUN ngrp;
BUN nils = 0;
@@ -3750,12 +3751,10 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
b = BATproject(s, b);
if (b == NULL)
return NULL;
-   freeb = true;
if (g) {
g = BATproject(s, g);
if (g == NULL)
goto bunins_failed;
-   freeg = true;
}
}
 
@@ -3775,27 +3774,25 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
else
bn = COLcopy(b, tp, false, TRANSIENT);
BAThseqbase(bn, g->tseqbase); /* deals with NULL */
-   if (freeb)
+   if (b != origb)
BBPunfix(b->batCacheid);
-   if (freeg)
+   if (g != origg)
BBPunfix(g->batCacheid);
return bn;
}
if (BATsort(, , NULL, g, NULL, NULL, false, false, false) 
!= GDK_SUCCEED)
goto bunins_failed;
-   if (freeg)
+   if (g != origg)
BBPunfix(g->batCacheid);
g = t1;
-   freeg = true;
 
if (BATsort(, NULL, NULL, b, t2, g, false, false, false) != 
GDK_SUCCEED) {
BBPunfix(t2->batCacheid);
goto bunins_failed;
}
-   if (freeb)
+   if (b != origb)
BBPunfix(b->batCacheid);
b = t1;
-   freeb = true;
BBPunfix(t2->batCacheid);
 
if (average)
@@ -3969,7 +3966,7 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
goto bunins_failed;
}
 
-   if (freeb)
+   if (b != origb)
BBPunfix(b->batCacheid);
 
bn->tkey = BATcount(bn) <= 1;
@@ -3981,15 +3978,15 @@ doBATgroupquantile(BAT *b, BAT *g, BAT *
  "e=" ALGOOPTBATFMT ",s=" ALGOOPTBATFMT
  ",quantile=%g,average=%s -> " ALGOOPTBATFMT
  "; start " OIDFMT ", count " BUNFMT " (" LLFMT " usec)\n",
- ALGOBATPAR(b), ALGOOPTBATPAR(g), ALGOOPTBATPAR(e),
+ ALGOBATPAR(origb), ALGOOPTBATPAR(origg), ALGOOPTBATPAR(e),
  ALGOOPTBATPAR(s), quantile, average ? "true" : "false",
  ALGOOPTBATPAR(bn), ci.seq, ncand, GDKusec() - t0);
return bn;
 
   bunins_failed:
-   if (freeb)
+   if (b && b != origb)
BBPunfix(b->batCacheid);
-   if (freeg)
+   if (g && g != origg)
BBPunfix(g->batCacheid);
if (bn)
BBPunfix(bn->batCacheid);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -889,8 +889,8 @@ order_joins(visitor *v, list *rels, list
/* complex expressions may touch multiple base tables
 * Should be pushed up to extra selection.
 * */
-   if (cje->type != e_cmp || is_complex_exp(cje->flag) || 
!find_prop(cje->p, PROP_HASHCOL) /*||
-  (cje->type == e_cmp && cje->f == NULL)*/) {
+   if (cje->type != e_cmp || is_complex_exp(cje->flag) || 
!find_prop(cje->p, PROP_HASHCOL) ||
+  (cje->type == e_cmp && cje->f == NULL)) {
l = find_one_rel(rels, cje->l);
r = find_one_rel(rels, cje->r);
}
@@ -1677,7 +1677,7 @@ rel_push_count_down(visitor *v, sql_rel 
 }
 
 static bool
-check_projection_on_foreignside(sql_rel *r, list *pexps, int fk_left) 
+check_projection_on_foreignside(sql_rel *r, list *pexps, int fk_left)
 {
/* projection columns from the foreign side */
if (list_empty(pexps))
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-03-09 Thread Sjoerd Mullender
Changeset: fa144eae9942 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fa144eae9942
Modified Files:
gdk/gdk_bbp.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (12 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2447,7 +2447,7 @@ decref(bat i, bool logical, bool release
 * if they have been made cold or are not dirty */
if (BBP_refs(i) > 0 ||
(BBP_lrefs(i) > 0 &&
-(b == NULL || BATdirtydata(b) || !(BBP_status(i) & BBPPERSISTENT) 
|| GDKinmemory( {
+(b == NULL || BATdirty(b) || !(BBP_status(i) & BBPPERSISTENT) || 
GDKinmemory( {
/* bat cannot be swapped out */
} else if (b ? b->batSharecnt == 0 : (BBP_status(i) & BBPTMP)) {
/* bat will be unloaded now. set the UNLOADING bit
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2021-03-05 Thread Sjoerd Mullender
Changeset: 1fcd0d34c7e3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1fcd0d34c7e3
Modified Files:
gdk/gdk_join.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (12 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -2569,7 +2569,7 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B
  r->thash ? " ignoring existing hash" : "",
  swapped ? " (swapped)" : "");
if (snprintf(ext, sizeof(ext), "thshjn%x",
-(unsigned) rci->s->batCacheid) >= (int) 
sizeof(ext))
+(unsigned) THRgettid()) >= (int) sizeof(ext))
goto bailout;
if ((hsh = BAThash_impl(r, rci, ext)) == NULL) {
goto bailout;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-12-18 Thread Sjoerd Mullender
Changeset: 20d5ae056058 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=20d5ae056058
Modified Files:
gdk/gdk_join.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (truncated from 453 to 300 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -2500,7 +2500,8 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B
 struct canditer *restrict lci, struct canditer *restrict rci,
 bool nil_matches, bool nil_on_miss, bool semi, bool only_misses,
 bool not_in, bool max_one,
-BUN estimate, lng t0, bool swapped, bool hash, bool phash,
+BUN estimate, lng t0, bool swapped,
+bool hash, bool phash, bool hash_cand,
 const char *reason)
 {
oid lo, ro;
@@ -2519,7 +2520,6 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B
const char *v = (const char *) 
bool lskipped = false;  /* whether we skipped values in l */
Hash *restrict hsh = NULL;
-   bool hash_cand = false;
 
assert(!BATtvoid(r));
assert(ATOMtype(l->ttype) == ATOMtype(r->ttype));
@@ -2555,7 +2555,24 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B
 
rl = rci->seq - r->hseqbase;
rh = canditer_last(rci) + 1 - r->hseqbase;
-   if (phash) {
+   if (hash_cand) {
+   /* we need to create a hash on r specific for the
+* candidate list */
+   char ext[32];
+   assert(rci->s);
+   MT_thread_setalgorithm(swapped ? "hashjoin using candidate hash 
(swapped)" : "hashjoin using candidate hash");
+   TRC_DEBUG(ALGO, ALGOBATFMT ": creating "
+ "hash for candidate list " ALGOBATFMT "%s%s\n",
+ ALGOBATPAR(r), ALGOBATPAR(rci->s),
+ r->thash ? " ignoring existing hash" : "",
+ swapped ? " (swapped)" : "");
+   if (snprintf(ext, sizeof(ext), "thshjn%x",
+(unsigned) rci->s->batCacheid) >= (int) 
sizeof(ext))
+   goto bailout;
+   if ((hsh = BAThash_impl(r, rci, ext)) == NULL) {
+   goto bailout;
+   }
+   } else if (phash) {
/* there is a hash on the parent which we should use */
MT_thread_setalgorithm(swapped ? "hashjoin using parent hash 
(swapped)" : "hashjoin using parent hash");
BAT *b = BBPdescriptor(VIEWtparent(r));
@@ -2577,24 +2594,6 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B
  "existing hash%s\n",
  ALGOBATPAR(r),
  swapped ? " (swapped)" : "");
-   } else if (rci->tpe != cand_dense || rci->ncand != BATcount(r)) {
-   /* we need to create a hash on r specific for the
-* candidate list */
-   char ext[32];
-   assert(rci->s);
-   MT_thread_setalgorithm(swapped ? "hashjoin using candidate hash 
(swapped)" : "hashjoin using candidate hash");
-   TRC_DEBUG(ALGO, ALGOBATFMT ": creating "
- "hash for candidate list " ALGOBATFMT "%s%s\n",
- ALGOBATPAR(r), ALGOBATPAR(rci->s),
- r->thash ? " ignoring existing hash" : "",
- swapped ? " (swapped)" : "");
-   if (snprintf(ext, sizeof(ext), "thshjn%x",
-(unsigned) rci->s->batCacheid) >= (int) 
sizeof(ext))
-   goto bailout;
-   if ((hsh = BAThash_impl(r, rci, ext)) == NULL) {
-   goto bailout;
-   }
-   hash_cand = true;
} else {
/* we need to create a hash on r */
MT_thread_setalgorithm(swapped ? "hashjoin using new hash 
(swapped)" : "hashjoin using new hash");
@@ -3071,6 +3070,79 @@ guess_uniques(BAT *b, struct canditer *c
return B;
 }
 
+/* estimate the cost of doing a hashjoin with a hash on r; return value
+ * is the estimated cost, the last three arguments receive some extra
+ * information */
+static double
+joincost(BAT *r, struct canditer *lci, struct canditer *rci,
+bool *hash, bool *phash, bool *cand)
+{
+   bool rhash = BATcheckhash(r);
+   bool prhash = false;
+   bool rcand = false;
+   double rcost = 1;
+   bat parent;
+   BAT *b;
+
+   if (rci->noids > 0) {
+   /* if we need to do binary search on candidate
+* list, take that into account */
+   rcost += log2((double) rci->noids);
+   }
+   rcost *= lci->ncand;
+   if (rhash) {
+   /* average chain length */
+   rcost *= (double) BATcount(r) / r->thash->nheads;
+   } else if ((parent = VIEWtparent(r)) != 0 &&
+  (b = BBPdescriptor(parent)) != NULL &&
+  BATcheckhash(b)) {
+   rhash = 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-12-15 Thread Sjoerd Mullender
Changeset: eba191c0b714 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eba191c0b714
Modified Files:
gdk/gdk_batop.c
gdk/gdk_project.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (121 lines):

diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -141,7 +141,7 @@ VIEWcreate(oid seq, BAT *b)
GDKfree(bn);
return NULL;
}
-   TRC_DEBUG(ALGO, "VIEWcreate(" ALGOBATFMT ")=" ALGOBATFMT "\n",
+   TRC_DEBUG(ALGO, ALGOBATFMT " -> " ALGOBATFMT "\n",
  ALGOBATPAR(b), ALGOBATPAR(bn));
return bn;
 }
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -842,7 +842,7 @@ COLcopy(BAT *b, int tt, bool writable, r
}
if (!writable)
bn->batRestricted = BAT_READ;
-   TRC_DEBUG(ALGO, "COLcopy(" ALGOBATFMT ")=" ALGOBATFMT "\n",
+   TRC_DEBUG(ALGO, ALGOBATFMT " -> " ALGOBATFMT "\n",
  ALGOBATPAR(b), ALGOBATPAR(bn));
return bn;
   bunins_failed:
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1767,11 +1767,11 @@ BATsort(BAT **sorted, BAT **order, BAT *
}
*groups = gn;
}
-   TRC_DEBUG(ALGO, "BATsort(b=" ALGOBATFMT ",o="
+   TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",o="
  ALGOOPTBATFMT ",g=" ALGOOPTBATFMT
  ",reverse=%d,nilslast=%d,stable=%d) = ("
  ALGOOPTBATFMT "," ALGOOPTBATFMT ","
- ALGOOPTBATFMT ") -- trivial (" LLFMT
+ ALGOOPTBATFMT " -- trivial (" LLFMT
  " usec)\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(o),
  ALGOOPTBATPAR(g), reverse, nilslast, stable,
@@ -1854,11 +1854,11 @@ BATsort(BAT **sorted, BAT **order, BAT *
BBPunfix(on->batCacheid);
on = NULL;
}
-   TRC_DEBUG(ALGO, "BATsort(b=" ALGOBATFMT ",o="
+   TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",o="
  ALGOOPTBATFMT ",g=" ALGOOPTBATFMT
  ",reverse=%d,nilslast=%d,stable=%d) = ("
  ALGOOPTBATFMT "," ALGOOPTBATFMT ","
- ALGOOPTBATFMT ") -- orderidx (" LLFMT
+ ALGOOPTBATFMT " -- orderidx (" LLFMT
  " usec)\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(o),
  ALGOOPTBATPAR(g), reverse, nilslast, stable,
@@ -1956,12 +1956,12 @@ BATsort(BAT **sorted, BAT **order, BAT *
goto error;
*groups = gn;
}
-   TRC_DEBUG(ALGO, "BATsort(b=" ALGOBATFMT
+   TRC_DEBUG(ALGO, "b=" ALGOBATFMT
  ",o=" ALGOOPTBATFMT ",g=" ALGOBATFMT
  ",reverse=%d,nilslast=%d,stable=%d"
  ") = (" ALGOOPTBATFMT ","
  ALGOOPTBATFMT "," ALGOOPTBATFMT
- ") -- key group (" LLFMT " usec)\n",
+ " -- key group (" LLFMT " usec)\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(o),
  ALGOBATPAR(g), reverse, nilslast,
  stable, ALGOOPTBATPAR(bn),
@@ -2078,10 +2078,10 @@ BATsort(BAT **sorted, BAT **order, BAT *
bn = NULL;
}
 
-   TRC_DEBUG(ALGO, "BATsort(b=" ALGOBATFMT ",o=" ALGOOPTBATFMT
+   TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",o=" ALGOOPTBATFMT
  ",g=" ALGOOPTBATFMT ",reverse=%d,nilslast=%d,"
  "stable=%d) = (" ALGOOPTBATFMT "," ALGOOPTBATFMT ","
- ALGOOPTBATFMT ") -- %ssort (" LLFMT " usec)\n",
+ ALGOOPTBATFMT " -- %ssort (" LLFMT " usec)\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(o), ALGOOPTBATPAR(g),
  reverse, nilslast, stable, ALGOOPTBATPAR(bn),
  ALGOOPTBATPAR(gn), ALGOOPTBATPAR(on),
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -265,8 +265,8 @@ BAT *virtualize(BAT *bn)
BATcount(b),\
b->hseqbase,\
ATOMname(b->ttype), \
-   !b->batTransient ? "P" : isVIEW(b) ? "V" : "T", \
-   BATtdense(b) ? "D" : b->ttype == TYPE_void && b->tvheap ? "X" :"", \
+   !b->batTransient ? "P" : b->theap.parentid ? "V" : b->tvheap && 
b->tvheap->parentid != b->batCacheid ? "v" : "T", \
+   BATtdense(b) ? "D" : b->ttype == 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-12-10 Thread Sjoerd Mullender
Changeset: fa2910be8514 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fa2910be8514
Modified Files:
gdk/gdk_project.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (42 lines):

diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -375,10 +375,10 @@ project_str(BAT *restrict l, struct cand
v += off;
switch (bn->twidth) {
case 1:
-   ((uint8_t *) bn->theap.base)[lo] = v - 
GDK_VAROFFSET;
+   ((uint8_t *) bn->theap.base)[lo] = (uint8_t) (v 
- GDK_VAROFFSET);
break;
case 2:
-   ((uint16_t *) bn->theap.base)[lo] = v - 
GDK_VAROFFSET;
+   ((uint16_t *) bn->theap.base)[lo] = (uint16_t) 
(v - GDK_VAROFFSET);
break;
case 4:
((uint32_t *) bn->theap.base)[lo] = (uint32_t) 
v;
@@ -422,10 +422,10 @@ project_str(BAT *restrict l, struct cand
v += off;
switch (bn->twidth) {
case 1:
-   ((uint8_t *) bn->theap.base)[lo] = v - 
GDK_VAROFFSET;
+   ((uint8_t *) bn->theap.base)[lo] = (uint8_t) (v 
- GDK_VAROFFSET);
break;
case 2:
-   ((uint16_t *) bn->theap.base)[lo] = v - 
GDK_VAROFFSET;
+   ((uint16_t *) bn->theap.base)[lo] = (uint16_t) 
(v - GDK_VAROFFSET);
break;
case 4:
((uint32_t *) bn->theap.base)[lo] = (uint32_t) 
v;
@@ -470,10 +470,10 @@ project_str(BAT *restrict l, struct cand
v += off;
switch (bn->twidth) {
case 1:
-   ((uint8_t *) bn->theap.base)[lo] = v - 
GDK_VAROFFSET;
+   ((uint8_t *) bn->theap.base)[lo] = (uint8_t) (v 
- GDK_VAROFFSET);
break;
case 2:
-   ((uint16_t *) bn->theap.base)[lo] = v - 
GDK_VAROFFSET;
+   ((uint16_t *) bn->theap.base)[lo] = (uint16_t) 
(v - GDK_VAROFFSET);
break;
case 4:
((uint32_t *) bn->theap.base)[lo] = (uint32_t) 
v;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-12-10 Thread Sjoerd Mullender
Changeset: 0697f14bf095 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0697f14bf095
Modified Files:
gdk/gdk_project.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (33 lines):

diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -346,7 +346,8 @@ project_str(BAT *restrict l, struct cand
oid o = canditer_next(ci);
if (o < r1seq || o >= r2end) {
GDKerror("does not match always\n");
-   return GDK_FAIL;
+   BBPreclaim(bn);
+   return NULL;
}
if (o < r1end) {
r = r1;
@@ -392,7 +393,8 @@ project_str(BAT *restrict l, struct cand
oid o = l->tseqbase + lo;
if (o < r1seq || o >= r2end) {
GDKerror("does not match always\n");
-   return GDK_FAIL;
+   BBPreclaim(bn);
+   return NULL;
}
if (o < r1end) {
r = r1;
@@ -439,7 +441,8 @@ project_str(BAT *restrict l, struct cand
oid o = ot[lo];
if (o < r1seq || o >= r2end) {
GDKerror("does not match always\n");
-   return GDK_FAIL;
+   BBPreclaim(bn);
+   return NULL;
}
if (o < r1end) {
r = r1;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-12-09 Thread Sjoerd Mullender
Changeset: 5d72c236661b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5d72c236661b
Modified Files:
sql/backends/monet5/sql_execute.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (11 lines):

diff --git a/sql/backends/monet5/sql_execute.c 
b/sql/backends/monet5/sql_execute.c
--- a/sql/backends/monet5/sql_execute.c
+++ b/sql/backends/monet5/sql_execute.c
@@ -206,6 +206,7 @@ SQLrun(Client c, mvc *m)
*m->errstr=0;
return msg;
}
+   TRC_INFO(SQL_EXECUTION, "Executing: %s", c->query);
MT_thread_setworking(c->query);
// locate and inline the query template instruction
mb = copyMalBlk(c->curprg->def);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-11-25 Thread Sjoerd Mullender
Changeset: 347220845608 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=347220845608
Modified Files:
tools/merovingian/daemon/controlrunner.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.

___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-11-18 Thread Sjoerd Mullender
Changeset: cd671140ae07 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cd671140ae07
Modified Files:
gdk/gdk_join.c
sql/backends/monet5/sql_result.c
sql/backends/monet5/sql_round_impl.h
sql/backends/monet5/vaults/shp/shp.c
sql/server/rel_optimizer.c
sql/server/sql_decimal.c
sql/server/sql_decimal.h
sql/server/sql_parser.y
sql/test/BugTracker-2009/Tests/prepare_decimal_bug.SF-2831994.stable.out
sql/test/Tests/decimal2.stable.out
sql/test/emptydb-upgrade-chain-hge/Tests/All
sql/test/emptydb-upgrade-chain/Tests/All
sql/test/emptydb-upgrade-hge/Tests/All
sql/test/emptydb-upgrade/Tests/All
sql/test/mergetables/Tests/mergequery.stable.out
sql/test/pg_regress/Tests/numeric.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/All
sql/test/testdb-upgrade-chain/Tests/All
sql/test/testdb-upgrade-hge/Tests/All
sql/test/testdb-upgrade/Tests/All
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (truncated from 425 to 300 lines):

diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -370,8 +370,10 @@ VIEWreset(BAT *b)
b->batCapacity = cnt;
 
/* insert all of v in b, and quit */
-   if (BATappend2(b, v, NULL, false, false) != GDK_SUCCEED)
+   if (BATappend2(b, v, NULL, false, false) != GDK_SUCCEED) {
+   GDKerror("appending view failed");
goto bailout;
+   }
BBPreclaim(v);
}
return GDK_SUCCEED;
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -2831,6 +2831,233 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B
return GDK_FAIL;
 }
 
+/* population count: count number of 1 bits in a value */
+static inline uint32_t __attribute__((__const__))
+pop(uint32_t x)
+{
+#if defined(__GNUC__)
+   return (uint32_t) __builtin_popcount(x);
+#elif defined(_MSC_VER)
+   return (uint32_t) __popcnt((unsigned int) (x));
+#else
+   /* divide and conquer implementation (the two versions are
+* essentially equivalent, but the first version is written a
+* bit smarter) */
+#if 1
+   x -= (x >> 1) & ~0U/3 /* 0x */; /* 3-1=2; 2-1=1; 1-0=1; 0-0=0 */
+   x = (x & ~0U/5) + ((x >> 2) & ~0U/5) /* 0x */;
+   x = (x + (x >> 4)) & ~0UL/0x11 /* 0x0F0F0F0F */;
+   x = (x + (x >> 8)) & ~0UL/0x101 /* 0x00FF00FF */;
+   x = (x + (x >> 16)) & 0x /* ~0UL/0x10001 */;
+#else
+   x = (x & 0x) + ((x >>  1) & 0x);
+   x = (x & 0x) + ((x >>  2) & 0x);
+   x = (x & 0x0F0F0F0F) + ((x >>  4) & 0x0F0F0F0F);
+   x = (x & 0x00FF00FF) + ((x >>  8) & 0x00FF00FF);
+   x = (x & 0x) + ((x >> 16) & 0x);
+#endif
+   return x;
+#endif
+}
+
+/* Count the number of unique values for the first half and the complete
+ * set (the sample s of b) and return the two values in *cnt1 and
+ * *cnt2. In case of error, both values are 0. */
+static void
+count_unique(BAT *b, BAT *s, BUN *cnt1, BUN *cnt2)
+{
+   struct canditer ci;
+   BUN half;
+   BUN cnt = 0;
+   const void *v;
+   const char *bvals;
+   const char *bvars;
+   oid bval;
+   int bwidth;
+   oid i, o;
+   const char *nme;
+   BUN hb;
+   BATiter bi;
+   int (*cmp)(const void *, const void *);
+   const char *algomsg = "";
+   lng t0 = 0;
+
+   TRC_DEBUG_IF(ALGO) t0 = GDKusec();
+   canditer_init(, b, s);
+   half = ci.ncand / 2;
+
+   if (b->tkey || ci.ncand <= 1 || BATtdense(b)) {
+   /* trivial: already unique */
+   *cnt1 = half;
+   *cnt2 = ci.ncand;
+   return;
+   }
+
+   if ((BATordered(b) && BATordered_rev(b)) ||
+   (b->ttype == TYPE_void && is_oid_nil(b->tseqbase))) {
+   /* trivial: all values are the same */
+   *cnt1 = *cnt2 = 1;
+   return;
+   }
+
+   assert(b->ttype != TYPE_void);
+
+   bvals = Tloc(b, 0);
+   if (b->tvarsized && b->ttype)
+   bvars = b->tvheap->base;
+   else
+   bvars = NULL;
+   bwidth = Tsize(b);
+   cmp = ATOMcompare(b->ttype);
+   bi = bat_iterator(b);
+
+   *cnt1 = *cnt2 = 0;
+
+   if (BATordered(b) || BATordered_rev(b)) {
+   const void *prev = NULL;
+   algomsg = "sorted";
+   for (i = 0; i < ci.ncand; i++) {
+   if (i == half)
+   *cnt1 = cnt;
+   o = canditer_next();
+   v = VALUE(b, o - b->hseqbase);
+   if (prev == NULL || (*cmp)(v, prev) != 0) {
+   cnt++;
+   }
+   prev = v;
+ 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-10-26 Thread Sjoerd Mullender
Changeset: e6889f4f0308 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e6889f4f0308
Modified Files:
sql/storage/bat/bat_storage.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (157 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -326,6 +326,7 @@ delta_update_bat( sql_delta *bat, BAT *t
}
if (BATappend(ui, tids, o, true) != GDK_SUCCEED ||
BATappend(uv, updates, o, true) != GDK_SUCCEED) {
+   bat_destroy(o);
bat_destroy(ui);
bat_destroy(uv);
return LOG_ERR;
@@ -550,6 +551,7 @@ dup_delta(sql_trans *tr, sql_delta *obat
return LOG_ERR;
bat_set_access(b, BAT_READ);
bat->ibid = temp_create(b);
+   bat_destroy(b);
}
} else { /* old column */
bat->ibid = ebat_copy(bat->ibid, bat->ibase, 0);
@@ -714,8 +716,7 @@ delta_append_bat( sql_delta *bat, BAT *i
if (isVIEW(i) && b->batCacheid == VIEWtparent(i)) {
BAT *ic = COLcopy(i, i->ttype, true, TRANSIENT);
if (ic == NULL || BATappend(b, ic, NULL, true) != 
GDK_SUCCEED) {
-   if(ic)
-   bat_destroy(ic);
+   bat_destroy(ic);
bat_destroy(b);
return LOG_ERR;
}
@@ -1338,8 +1339,10 @@ log_create_delta(sql_delta *bat, char tp
bat->uvbid = e_bat(b->ttype);
if (bat->uibid == BID_NIL || bat->uvbid == BID_NIL)
res = LOG_ERR;
-   if (GDKinmemory())
+   if (GDKinmemory()) {
+   bat_destroy(b);
return res;
+   }
 
ok = logger_add_bat(bat_logger, b, bat->name, tpe, id);
if (ok == GDK_SUCCEED)
@@ -1975,8 +1978,7 @@ clear_delta(sql_trans *tr, sql_delta *ba
bat_clear(b);
BATcommit(b);
}
-   if (b)
-   bat_destroy(b);
+   bat_destroy(b);
}
if (bat->bid) {
b = temp_descriptor(bat->bid);
@@ -2000,8 +2002,7 @@ clear_delta(sql_trans *tr, sql_delta *ba
bat_clear(b);
BATcommit(b);
}
-   if (b)
-   bat_destroy(b);
+   bat_destroy(b);
}
if (bat->uvbid) {
b = temp_descriptor(bat->uvbid);
@@ -2009,8 +2010,7 @@ clear_delta(sql_trans *tr, sql_delta *ba
bat_clear(b);
BATcommit(b);
}
-   if (b)
-   bat_destroy(b);
+   bat_destroy(b);
}
bat->cleared = 1;
bat->ibase = 0;
@@ -2688,9 +2688,8 @@ static int
 update_table(sql_trans *tr, sql_table *ft, sql_table *tt)
 {
sql_trans *oldest = oldest_active_transaction();
-   sql_table *ot = NULL;
int ok = LOG_OK;
-   node *n, *m, *o = NULL;
+   node *n, *m;
 
if (ATOMIC_GET(_nr_active) == 1 || ft->base.allocated) {
if (ATOMIC_GET(_nr_active) > 1 && ft->data) { /* move 
delta */
@@ -2709,9 +2708,7 @@ update_table(sql_trans *tr, sql_table *f
}
while (b && b->wtime >= oldest->stime)
b = b->next;
-   /* find table t->base.stime */
-   ot = tr_find_table(oldest, tt);
-   if (b && ot && b->wtime < ot->base.stime) {
+   if (b && b->next) {
/* anything older can go */
delayed_destroy_dbat(b->next);
b->next = NULL;
@@ -2736,9 +2733,7 @@ update_table(sql_trans *tr, sql_table *f
ft->data = NULL;
}
}
-   if (ot)
-   o = ot->columns.set->h;
-   for (n = ft->columns.set->h, m = tt->columns.set->h; ok == LOG_OK && n 
&& m; n = n->next, m = m->next, o=(o?o->next:NULL)) {
+   for (n = ft->columns.set->h, m = tt->columns.set->h; ok == LOG_OK && n 
&& m; n = n->next, m = m->next) {
sql_column *cc = n->data; // TODO: either stick to to/from 
terminology or old/current terminology
sql_column *oc = m->data;
 
@@ -2746,7 +2741,6 @@ update_table(sql_trans *tr, sql_table *f
assert(!cc->base.wtime || oc->base.wtime < 
cc->base.wtime || (oc->base.wtime == cc->base.wtime && oc->base.allocated /* 
alter */));
if 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-10-23 Thread Sjoerd Mullender
Changeset: 62cca5b7349e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=62cca5b7349e
Modified Files:
sql/backends/monet5/sql_scenario.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (19 lines):

diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -260,6 +260,7 @@ SQLprepareClient(Client c, int login)
}
if (m->session->tr)
reset_functions(m->session->tr);
+   MT_lock_unset(_contextLock);
if (login) {
str schema = monet5_user_set_def_schema(m, c->user);
if (!schema) {
@@ -270,6 +271,7 @@ SQLprepareClient(Client c, int login)
}
 
 bailout:
+   MT_lock_set(_contextLock);
/* expect SQL text first */
if (be)
be->language = 'S';
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-10-22 Thread Sjoerd Mullender
Changeset: 60843e29a4ed for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60843e29a4ed
Modified Files:
tools/mserver/mserver5.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (19 lines):

diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -487,7 +487,6 @@ main(int argc, char **av)
if (!(setlen = mo_system_config(, setlen)))
usage(prog, -1);
 
-   GDKsetdebug(debug | grpdebug);  /* add the algorithm tracers */
if (debug)
mo_print_options(set, setlen);
 
@@ -541,6 +540,7 @@ main(int argc, char **av)
fprintf(stderr, "%s\n", GDKerrbuf);
exit(1);
}
+   GDKsetdebug(debug | grpdebug);  /* add the algorithm tracers */
mo_free_options(set, setlen);
 
if (GDKsetenv("monet_version", GDKversion()) != GDK_SUCCEED ||
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-10-21 Thread Sjoerd Mullender
Changeset: e50e785e0e9b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e50e785e0e9b
Modified Files:
gdk/gdk_bbp.c
monetdb5/optimizer/opt_mergetable.c
sql/storage/bat/bat_storage.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (140 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3616,6 +3616,10 @@ BBPdiskscan(const char *parent, size_t b
/* older versions used .thash which we
 * can simply ignore */
delete = true;
+   } else if (strncmp(p + 1, "thsh", 4) == 0) {
+   /* temporary hash files which we can
+* simply ignore */
+   delete = true;
} else if (strncmp(p + 1, "timprints", 9) == 0) {
BAT *b = getdesc(bid);
delete = b == NULL;
diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -59,15 +59,6 @@ is_a_mat(int idx, matlist_t *ml)
 }
 
 static int
-was_a_mat(int idx, matlist_t *ml){
-   int i;
-   for(i =0; itop; i++)
-   if (ml->v[i].mv == idx)
-   return i;
-   return -1;
-}
-
-static int
 nr_of_mats(InstrPtr p, matlist_t *ml)
 {
int j,cnt=0;
@@ -82,7 +73,7 @@ nr_of_bats(MalBlkPtr mb, InstrPtr p)
 {
int j,cnt=0;
for(j=p->retc; jargc; j++)
-   if (isaBatType(getArgType(mb,p,j)))
+   if (isaBatType(getArgType(mb,p,j)) && !isVarConstant(mb, 
getArg(p,j)))
cnt++;
return cnt;
 }
@@ -92,7 +83,7 @@ nr_of_nilbats(MalBlkPtr mb, InstrPtr p)
 {
int j,cnt=0;
for(j=p->retc; jargc; j++)
-   if (getArgType(mb,p,j) == TYPE_bat)
+   if (getArgType(mb,p,j) == TYPE_bat || 
(isaBatType(getArgType(mb, p, j)) && isVarConstant(mb, getArg(p,j)) && 
getVarConstant(mb, getArg(p,j)).val.bval == bat_nil))
cnt++;
return cnt;
 }
@@ -1954,7 +1945,7 @@ OPTmergetableImplementation(Client cntxt
InstrPtr *old;
matlist_t ml;
int oldtop, fm, fn, fo, fe, i, k, m, n, o, e, slimit, bailout = 0;
-   int size=0, match, actions=0, distinct_topn = 0, /*topn_res = 0,*/ 
groupdone = 0, *vars;
+   int size=0, match, actions=0, distinct_topn = 0, /*topn_res = 0,*/ 
groupdone = 0, *vars, maxvars;
char buf[256], *group_input;
lng usec = GDKusec();
str msg = MAL_SUCCEED;
@@ -1965,6 +1956,7 @@ OPTmergetableImplementation(Client cntxt
oldtop= mb->stop;
 
vars = (int*) GDKmalloc(sizeof(int)* mb->vtop);
+   maxvars = mb->vtop;
group_input = (char*) GDKzalloc(sizeof(char)* mb->vtop);
if (vars == NULL || group_input == NULL){
if (vars)
@@ -2036,7 +2028,6 @@ OPTmergetableImplementation(Client cntxt
/* not idea how to detect this yet */
//distinct_topn = 1;
}
-   GDKfree(vars);
GDKfree(group_input);
 
ml.horigin = 0;
@@ -2367,11 +2358,10 @@ OPTmergetableImplementation(Client cntxt
}
 
/* select on insert, should use last tid only */
-   if (/* DISABLES CODE */ (0))
if (match == 1 && fm == 2 && isSelect(p) && p->retc == 1 &&
   (m=is_a_mat(getArg(p,fm), )) >= 0 &&
   !ml.v[m].packed && /* not packed yet */
-  was_a_mat(getArg(p,fm-1), ) < 0){ /* not previously 
packed */
+  (getArg(p,fm-1) > maxvars || 
getModuleId(old[vars[getArg(p,fm-1)]]) == sqlRef)){
if((r = copyInstruction(p)) == NULL) {
msg = 
createException(MAL,"optimizer.mergetable",SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto cleanup;
@@ -2488,6 +2478,7 @@ OPTmergetableImplementation(Client cntxt
freeInstruction(ml.v[i].mi);
}
 cleanup:
+   if (vars) GDKfree(vars);
if (ml.v) GDKfree(ml.v);
if (ml.horigin) GDKfree(ml.horigin);
if (ml.torigin) GDKfree(ml.torigin);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -905,6 +905,7 @@ delta_delete_bat( sql_dbat *bat, BAT *i 
return LOG_ERR;
 
if (isEbat(b)) {
+   assert(ATOMtype(b->ttype) == TYPE_oid);
temp_destroy(bat->dbid);
bat->dbid = temp_copy(b->batCacheid, FALSE);
if (bat->dbid == BID_NIL)
@@ -935,6 +936,7 @@ delta_delete_val( sql_dbat *bat, oid rid
 
if (isEbat(b)) {
temp_destroy(bat->dbid);
+   

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-10-13 Thread Sjoerd Mullender
Changeset: 0e29b912d97a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0e29b912d97a
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (136 lines):

diff --git a/monetdb5/mal/mal_exception.c b/monetdb5/mal/mal_exception.c
--- a/monetdb5/mal/mal_exception.c
+++ b/monetdb5/mal/mal_exception.c
@@ -61,22 +61,39 @@ dupError(const char *err)
 static str __attribute__((__format__(__printf__, 3, 0), __returns_nonnull__))
 createExceptionInternal(enum malexception type, const char *fcn, const char 
*format, va_list ap)
 {
-   char local[GDKMAXERRLEN];
+   size_t msglen;
int len;
+   char *msg;
+   va_list ap2;
 #ifndef NDEBUG
// if there is an error we allow memory allocation once again
GDKsetmallocsuccesscount(-1);
 #endif
-   len = snprintf(local, GDKMAXERRLEN, "%s:%s:", exceptionNames[type], 
fcn);
-   len = vsnprintf(local + len, GDKMAXERRLEN - len, format, ap);
-   if (len < 0)
+   va_copy(ap2, ap);   /* we need to use it twice */
+   msglen = strlen(exceptionNames[type]) + strlen(fcn) + 2;
+   len = vsnprintf(NULL, 0, format, ap); /* count necessary length */
+   if (len < 0) {
TRC_CRITICAL(MAL_SERVER, "called with bad arguments");
-   char *q = local;
-   for (char *p = strchr(q, '\n'); p; q = p + 1, p = strchr(q, '\n'))
-   TRC_ERROR(MAL_SERVER, "%.*s\n", (int) (p - q), q);
-   if (*q)
-   TRC_ERROR(MAL_SERVER, "%s\n", q);
-   return dupError(local);
+   len = 0;
+   }
+   msg = GDKmalloc(msglen + len + 1);
+   if (msg != NULL) {
+   /* the calls below succeed: the arguments have already been 
checked */
+   (void) strconcat_len(msg, msglen + 1,
+exceptionNames[type], 
":", fcn, ":", NULL);
+   if (len > 0)
+   (void) vsnprintf(msg + msglen, len + 1, format, ap2);
+   va_end(ap2);
+   char *q = msg;
+   for (char *p = strchr(msg, '\n'); p; q = p + 1, p = strchr(q, 
'\n'))
+   TRC_ERROR(MAL_SERVER, "%.*s\n", (int) (p - q), q);
+   if (*q)
+   TRC_ERROR(MAL_SERVER, "%s\n", q);
+   } else {
+   msg = M5OutOfMemory;
+   }
+   va_end(ap2);
+   return msg;
 }
 
 /**
@@ -145,38 +162,52 @@ freeException(str msg)
 static str __attribute__((__format__(__printf__, 5, 0), __returns_nonnull__))
 createMalExceptionInternal(MalBlkPtr mb, int pc, enum malexception type, char 
*prev, const char *format, va_list ap)
 {
-   char buf[GDKMAXERRLEN];
-   size_t i;
-   str s, fcn;
+   bool addnl = false;
+   const char *s = mb ? getModName(mb) : "unknown";
+   const char *fcn = mb ? getFcnName(mb) : "unknown";
+   size_t msglen;
 
-   s = mb ? getModName(mb) : "unknown";
-   fcn = mb ? getFcnName(mb) : "unknown";
-   i = 0;
-
-   if (prev){
-   if( *prev){
-   i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "%s", 
prev);
-   if( buf[i-1] != '\n')
-   buf[i++]= '\n';
+   if (prev) {
+   msglen = strlen(prev);
+   if (msglen > 0 && prev[msglen - 1] != '\n') {
+   addnl = true;
+   msglen++;
}
-   i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "!%s:%s.%s[%d]:",
-   exceptionNames[type], s, fcn, pc);
-   freeException(prev);
-   } else if( type == SYNTAX)
-   i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "%s:",
-   exceptionNames[type]);
-   else
-   i += snprintf(buf + i, GDKMAXERRLEN - 1 - i, "%s:%s.%s[%d]:",
-   exceptionNames[type], s, fcn, pc);
-   i += vsnprintf(buf + i, GDKMAXERRLEN - 1 - i, format, ap);
-   if( buf[i-1] != '\n')
-   buf[i++]= '\n';
-   buf[i] = '\0';
-
-   s = GDKstrdup(buf);
-   if (s == NULL)  /* make sure we always return 
something */
-   s = M5OutOfMemory;
-   return s;
+   msglen += snprintf(NULL, 0, "!%s:%s.%s[%d]:",
+  exceptionNames[type], s, 
fcn, pc);
+   } else if (type == SYNTAX) {
+   msglen = strlen(exceptionNames[type]) + 1;
+   } else {
+   msglen = snprintf(NULL, 0, "%s:%s.%s[%d]:",
+ exceptionNames[type], s, fcn, 
pc);
+   }
+   va_list ap2;
+   va_copy(ap2, ap);
+   int len = vsnprintf(NULL, 0, format, ap);
+   if (len < 0)
+   len = 0;
+   char *msg = GDKmalloc(msglen + len + 1);
+   if (msg != NULL) {
+   /* the calls below succeed: the arguments have already been 

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-10-05 Thread Sjoerd Mullender
Changeset: 70eacab62cb9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=70eacab62cb9
Modified Files:
tools/merovingian/daemon/controlrunner.c
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/merovingian.h
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (196 lines):

diff --git a/tools/merovingian/daemon/controlrunner.c 
b/tools/merovingian/daemon/controlrunner.c
--- a/tools/merovingian/daemon/controlrunner.c
+++ b/tools/merovingian/daemon/controlrunner.c
@@ -351,6 +351,7 @@ static void ctl_handle_client(
{
mtype mtype = 0;
pid_t pid = 0;
+   bool terminated = false;
 
// First look for something started by ourself.
pthread_mutex_lock(&_mero_topdp_lock);
@@ -408,18 +409,27 @@ static void ctl_handle_client(
/* then kill it */
if (dp)

pthread_mutex_lock(>fork_lock);
-   terminateProcess(q, pid, mtype);
+   terminated = terminateProcess(q, pid, 
mtype);
if (dp)

pthread_mutex_unlock(>fork_lock);
Mfprintf(_mero_ctlout, "%s: stopped "
"database '%s'\n", 
origin, q);
} else {
-   kill(pid, SIGKILL);
+   terminated = kill(pid, SIGKILL) == 0;
Mfprintf(_mero_ctlout, "%s: killed "
"database '%s'\n", 
origin, q);
}
-   len = snprintf(buf2, sizeof(buf2), "OK\n");
-   send_client("=");
+   if (terminated) {
+   len = snprintf(buf2, sizeof(buf2), 
"OK\n");
+   send_client("=");
+   } else {
+   Mfprintf(_mero_ctlerr, "%s: received 
stop signal for "
+   "non running database: 
%s\n", origin, q);
+   len = snprintf(buf2, sizeof(buf2),
+   "database is not 
running: %s\n", q);
+   send_client("!");
+   break;
+   }
} else if (strcmp(p, "create") == 0 ||
strncmp(p, "create password=", 
strlen("create password=")) == 0) {
err e;
diff --git a/tools/merovingian/daemon/forkmserver.c 
b/tools/merovingian/daemon/forkmserver.c
--- a/tools/merovingian/daemon/forkmserver.c
+++ b/tools/merovingian/daemon/forkmserver.c
@@ -35,7 +35,7 @@
  * shut down gracefully within a given time-out.  If that fails, it
  * sends the deadly SIGKILL signal to the mserver process and returns.
  */
-void
+bool
 terminateProcess(char *dbname, pid_t pid, mtype type)
 {
sabdb *stats;
@@ -48,13 +48,13 @@ terminateProcess(char *dbname, pid_t pid
Mfprintf(stderr, "cannot terminate process %lld: %s\n",
 (long long int)pid, er);
free(er);
-   return;
+   return false;
}
 
if (stats == NULL) {
Mfprintf(stderr, "strange, process %lld serves database '%s' "
 "which does not exist\n", (long long int)pid, 
dbname);
-   return;
+   return false;
}
 
if (stats->pid != pid) {
@@ -65,7 +65,7 @@ terminateProcess(char *dbname, pid_t pid
dbname,
(long long int)pid
);
-   return;
+   return false;
}
assert(stats->pid == pid);
 
@@ -78,13 +78,13 @@ terminateProcess(char *dbname, pid_t pid
 "(pid %lld) has crashed\n",
 dbname, (long long int)pid);
msab_freeStatus();
-   return;
+   return false;
case SABdbInactive:
Mfprintf(stdout, "database '%s' appears to have shut down 
already\n",
 dbname);
fflush(stdout);
msab_freeStatus();
-   return;
+   return false;
case SABdbStarting:

MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-09-15 Thread Sjoerd Mullender
Changeset: 0336545c4361 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0336545c4361
Modified Files:
testing/Mtest.py.in
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (12 lines):

diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -3205,7 +3205,7 @@ def DoIt(env, SERVER, CALL, TST, EXT, Te
 break
 elif CALL == "sqltest":
 import MonetDBtesting.sqllogictest as sqllogictest
-sql = sqllogictest.SQLLogic(ClntErr)
+sql = sqllogictest.SQLLogic(out=ClntErr)
 try:
 sql.connect(hostname='localhost',
 port=int(env['MAPIPORT']),
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-09-15 Thread Sjoerd Mullender
Changeset: 75f88045fee4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=75f88045fee4
Modified Files:
cmake/monetdb-defines.cmake
monetdb_config.h.in
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (22 lines):

diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -294,6 +294,7 @@ macro(monetdb_configure_sizes)
   check_type_size(short SIZEOF_SHORT LANGUAGE C)
   check_type_size(int SIZEOF_INT LANGUAGE C)
   check_type_size(long SIZEOF_LONG LANGUAGE C)
+  check_type_size("long int" SIZEOF_LONG_INT LANGUAGE C)
   check_type_size(double SIZEOF_DOUBLE LANGUAGE C)
   check_type_size(wchar_t SIZEOF_WCHAR_T LANGUAGE C)
   check_type_size(socklen_t HAVE_SOCKLEN_T LANGUAGE C)
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -283,6 +283,7 @@
 #cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@
 #cmakedefine SIZEOF_INT @SIZEOF_INT@
 #cmakedefine SIZEOF_LONG @SIZEOF_LONG@
+#cmakedefine SIZEOF_LONG_INT @SIZEOF_LONG_INT@
 #cmakedefine SIZEOF_DOUBLE @SIZEOF_DOUBLE@
 #cmakedefine SIZEOF_WCHAR_T @SIZEOF_WCHAR_T@
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Merge with Jun2020 branch.

2020-09-10 Thread Sjoerd Mullender
Changeset: e8ea5102a673 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e8ea5102a673
Modified Files:
gdk/gdk.h
gdk/gdk_bbp.c
Branch: Oct2020
Log Message:

Merge with Jun2020 branch.


diffs (154 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1070,6 +1070,9 @@ gdk_export restrict_t BATgetaccess(BAT *
 (b)->batDirtydesc ||   \
 (b)->theap.dirty ||\
 ((b)->tvheap != NULL && (b)->tvheap->dirty))
+#define BATdirtydata(b)(!(b)->batCopiedtodisk ||   
\
+(b)->theap.dirty ||\
+((b)->tvheap != NULL && (b)->tvheap->dirty))
 
 #define BATcapacity(b) (b)->batCapacity
 /*
@@ -1191,8 +1194,9 @@ static inline void
 BATsettrivprop(BAT *b)
 {
assert(!is_oid_nil(b->hseqbase));
-   b->batDirtydesc = true; /* likely already set */
assert(is_oid_nil(b->tseqbase) || ATOMtype(b->ttype) == TYPE_oid);
+   if (!b->batDirtydesc)
+   return;
if (b->ttype == TYPE_void) {
if (is_oid_nil(b->tseqbase)) {
b->tnonil = b->batCount == 0;
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -435,6 +435,7 @@ VIEWdestroy(BAT *b)
HASHdestroy(b);
IMPSdestroy(b);
OIDXdestroy(b);
+   PROPdestroy(b);
VIEWunlink(b);
 
if (b->ttype && !b->theap.parentid) {
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -550,7 +550,6 @@ BATfree(BAT *b)
if (b->tident && !default_ident(b->tident))
GDKfree(b->tident);
b->tident = BATstring_t;
-   PROPdestroy(b);
HASHfree(b);
IMPSfree(b);
OIDXfree(b);
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1412,6 +1412,7 @@ BBPexit(void)
}
VIEWdestroy(b);
} else {
+   PROPdestroy(b);
BATfree(b);
}
}
@@ -1714,15 +1715,14 @@ BBPdump(void)
if (b == NULL)
continue;
fprintf(stderr,
-   "# %d[%s]: nme='%s' refs=%d lrefs=%d "
-   "status=%u count=" BUNFMT,
+   "# %d: " ALGOBATFMT " "
+   "refs=%d lrefs=%d "
+   "status=%u",
i,
-   ATOMname(b->ttype),
-   BBP_logical(i) ? BBP_logical(i) : "",
+   ALGOBATPAR(b),
BBP_refs(i),
BBP_lrefs(i),
-   BBP_status(i),
-   b->batCount);
+   BBP_status(i));
if (b->batSharecnt > 0)
fprintf(stderr, " shares=%d", b->batSharecnt);
if (b->batDirtydesc)
@@ -1731,9 +1731,10 @@ BBPdump(void)
fprintf(stderr, " Theap -> %d", b->theap.parentid);
} else {
fprintf(stderr,
-   " Theap=[%zu,%zu]%s",
+   " Theap=[%zu,%zu,f=%d]%s",
HEAPmemsize(>theap),
HEAPvmsize(>theap),
+   b->theap.farmid,
b->theap.dirty ? "(Dirty)" : "");
if (BBP_logical(i) && BBP_logical(i)[0] == '.') {
cmem += HEAPmemsize(>theap);
@@ -1752,9 +1753,10 @@ BBPdump(void)
b->tvheap->parentid);
} else {
fprintf(stderr,
-   " Tvheap=[%zu,%zu]%s",
+   " Tvheap=[%zu,%zu,f=%d]%s",
HEAPmemsize(b->tvheap),
HEAPvmsize(b->tvheap),
+   b->tvheap->farmid,
b->tvheap->dirty ? "(Dirty)" : "");
if (BBP_logical(i) && BBP_logical(i)[0] == '.') 
{
cmem += HEAPmemsize(b->tvheap);
@@ -1768,7 +1770,9 @@ BBPdump(void)
if (b->thash && b->thash != (Hash *) 1) {
size_t m = HEAPmemsize(>thash->heaplink) + 
HEAPmemsize(>thash->heapbckt);
size_t v = HEAPvmsize(>thash->heaplink) + 
HEAPvmsize(>thash->heapbckt);
-