MonetDB: Jul2021 - Don't kill already dead server; kill inherite...

2022-06-15 Thread Sjoerd Mullender
Changeset: d61dcc675506 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d61dcc675506
Modified Files:
tools/merovingian/daemon/forkmserver.c
Branch: Jul2021
Log Message:

Don't kill already dead server; kill inherited server.
If the pid in the internal admin is -1, we already received notification
(SIGCHILD) that the process died, so silently return.
If the internal pid is 0 and the pid from looking at the file system is
greater than 0, presumably the server is running but was not started by
us.  In this case, attempt to terminate it anyway.

Also, if the kill system call fails, also report why it failed.


diffs (43 lines):

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
@@ -57,6 +57,12 @@ terminateProcess(char *dbname, pid_t pid
return false;
}
 
+   if (pid == -1) {
+   /* it's already dead */
+   msab_freeStatus(&stats);
+   return true;
+   }
+
if (stats->pid != pid) {
Mfprintf(stderr,
"strange, trying to kill process %lld to stop database 
'%s' "
@@ -65,8 +71,13 @@ terminateProcess(char *dbname, pid_t pid
dbname,
(long long int)pid
);
-   msab_freeStatus(&stats);
-   return false;
+   if (stats->pid >= 1 && pid < 1) {
+   /* assume the server was started by a previous 
merovingian */
+   pid = stats->pid;
+   } else {
+   msab_freeStatus(&stats);
+   return false;
+   }
}
assert(stats->pid == pid);
 
@@ -114,8 +125,8 @@ terminateProcess(char *dbname, pid_t pid
 "TERM signal\n", (long long int)pid, dbname);
if (kill(pid, SIGTERM) < 0) {
/* barf */
-   Mfprintf(stderr, "cannot send TERM signal to process (database 
'%s')\n",
-dbname);
+   Mfprintf(stderr, "cannot send TERM signal to process (database 
'%s'): %s\n",
+dbname, strerror(errno));
msab_freeStatus(&stats);
return false;
}
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jul2021 - Close files. Mostly in case of (rare) error,...

2022-06-15 Thread Sjoerd Mullender
Changeset: 97d4194885f5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/97d4194885f5
Modified Files:
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/handlers.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/multiplex-funnel.c
tools/merovingian/daemon/proxy.c
tools/merovingian/utils/control.c
tools/merovingian/utils/database.c
Branch: Jul2021
Log Message:

Close files.  Mostly in case of (rare) error, but also when reinitializing log 
file.


diffs (186 lines):

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
@@ -399,10 +399,13 @@ forkMserver(const char *database, sabdb*
freeConfFile(ckv);
free(ckv);
pthread_mutex_unlock(&dp->fork_lock);
+   close(pfdo[1]);
+   close(pfde[1]);
return newErr("Failed to open file descriptor\n");
}
if(!(f2 = fdopen(pfde[1], "a"))) {
fclose(f1);
+   close(pfde[1]);
msab_freeStatus(stats);
freeConfFile(ckv);
free(ckv);
@@ -443,6 +446,10 @@ forkMserver(const char *database, sabdb*
freeConfFile(ckv);
free(ckv);
pthread_mutex_unlock(&dp->fork_lock);
+   close(pfdo[0]);
+   close(pfdo[1]);
+   close(pfde[0]);
+   close(pfde[1]);
return(newErr("cannot start database '%s': no .vaultkey found "
  "(did you create the database with 
`monetdb create %s`?)",
  database, database));
@@ -454,6 +461,10 @@ forkMserver(const char *database, sabdb*
freeConfFile(ckv);
free(ckv);
pthread_mutex_unlock(&dp->fork_lock);
+   close(pfdo[0]);
+   close(pfdo[1]);
+   close(pfde[0]);
+   close(pfde[1]);
return(er);
}
 
@@ -696,15 +707,15 @@ forkMserver(const char *database, sabdb*
int dup_err;
close(pfdo[0]);
dup_err = dup2(pfdo[1], 1);
+   if(dup_err == -1)
+   perror("dup2");
close(pfdo[1]);
 
close(pfde[0]);
+   dup_err = dup2(pfde[1], 2);
if(dup_err == -1)
perror("dup2");
-   dup_err = dup2(pfde[1], 2);
close(pfde[1]);
-   if(dup_err == -1)
-   perror("dup2");
 
write_error = write(1, "arguments:", 10);
for (c = 0; argv[c] != NULL; c++) {
diff --git a/tools/merovingian/daemon/handlers.c 
b/tools/merovingian/daemon/handlers.c
--- a/tools/merovingian/daemon/handlers.c
+++ b/tools/merovingian/daemon/handlers.c
@@ -251,10 +251,20 @@ void reinitialize(void)
mytime, (long long int)_mero_topdp->next->pid);
fflush(_mero_logfile);
_mero_topdp->out = _mero_topdp->err = t;
-   _mero_logfile = fdopen(t, "a");
-   Mfprintf(_mero_logfile, "%s BEG merovingian[%lld]: "
-   "reopening logfile\n",
-   mytime, (long long int)_mero_topdp->next->pid);
+   FILE *f = _mero_logfile;
+   if ((_mero_logfile = fdopen(t, "a")) == NULL) {
+   /* revert to old log so that we have something */
+   Mfprintf(f, "%s ERR merovingian[%lld]: "
+"failed to reopen logfile",
+mytime, (long long 
int)_mero_topdp->next->pid);
+   _mero_topdp->out = _mero_topdp->err = fileno(f);
+   _mero_logfile = f;
+   } else {
+   fclose(f);
+   Mfprintf(_mero_logfile, "%s BEG merovingian[%lld]: "
+"reopening logfile\n",
+mytime, (long long 
int)_mero_topdp->next->pid);
+   }
}
 
/* logger go ahead! */
diff --git a/tools/merovingian/daemon/merovingian.c 
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -519,6 +519,8 @@ main(int argc, char *argv[])
/* oops, forking went wrong! */
Mfprintf(stderr, "unable to fork into 
background: %s\n",
strerror(errno));
+   close(pfd[0]);
+   

MonetDB: Jul2021 - Changed error message for "impossible state".

2022-06-15 Thread Sjoerd Mullender
Changeset: eeb6a93397fb for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eeb6a93397fb
Modified Files:
tools/merovingian/daemon/forkmserver.c
Branch: Jul2021
Log Message:

Changed error message for "impossible state".


diffs (29 lines):

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
@@ -348,14 +348,22 @@ forkMserver(const char *database, sabdb*
break;
default:
/* this also includes SABdbStarting, which we shouldn't ever
-* see due to the global starting lock */
+* see due to the global starting lock
+*
+* if SABdbStarting: a process (presumably mserver5) has locked
+* the database (i.e. the .gdk_lock file), but the server is not
+* ready to accept connections (i.e. there is no .started
+* file) */
state = (*stats)->state;
msab_freeStatus(stats);
freeConfFile(ckv);
free(ckv);
pthread_mutex_unlock(&dp->fork_lock);
-   return(newErr("unknown or impossible state: %d",
- (int)state));
+   if (state == SABdbStarting)
+   return(newErr("unexpected state: database is locked but 
not yet started"));
+   else
+   return(newErr("unknown or impossible state: %d",
+ (int)state));
}
 
/* create the pipes (filedescriptors) now, such that we and the
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - F_LOCK and friends is defined in unistd.h and...

2022-06-15 Thread Sjoerd Mullender
Changeset: d20e413d3282 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d20e413d3282
Modified Files:
common/utils/mutils.h
Branch: default
Log Message:

F_LOCK and friends is defined in unistd.h and/or fcntl.h.


diffs (23 lines):

diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -35,15 +35,15 @@
 #define MONETDB_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | 
S_IWOTH)
 #define MONETDB_DIRMODE(MONETDB_MODE | S_IXUSR | S_IXGRP | 
S_IXOTH)
 
+#ifdef NATIVE_WIN32
+
+#include 
+
 #define F_TEST 3   /* test a region for other processes locks.  */
 #define F_TLOCK2   /* test and lock a region for exclusive 
use */
 #define F_ULOCK0   /* unlock a previously locked region */
 #define F_LOCK 1   /* lock a region for exclusive use */
 
-#ifdef NATIVE_WIN32
-
-#include 
-
 struct DIR;
 
 typedef struct DIR DIR;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jul2021 - Sleep briefly on transient errors in accept().

2022-06-15 Thread Sjoerd Mullender
Changeset: e799ff5b1923 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e799ff5b1923
Modified Files:
tools/merovingian/daemon/client.c
tools/merovingian/daemon/controlrunner.c
Branch: Jul2021
Log Message:

Sleep briefly on transient errors in accept().


diffs (40 lines):

diff --git a/tools/merovingian/daemon/client.c 
b/tools/merovingian/daemon/client.c
--- a/tools/merovingian/daemon/client.c
+++ b/tools/merovingian/daemon/client.c
@@ -528,6 +528,7 @@ acceptConnections(int socks[3])
case ENOBUFS:
case ENOMEM:
/* transient failures */
+   sleep_ms(500);  /* wait a little, maybe it goes 
away */
break;
case ECONNABORTED:
/* connection aborted before we began */
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
@@ -1259,9 +1259,24 @@ controlRunner(void *d)
free(p);
if (_mero_keep_listening == 0)
break;
-   if (errno != EINTR) {
+   switch (errno) {
+   case EMFILE:
+   case ENFILE:
+   case ENOBUFS:
+   case ENOMEM:
+   /* transient failure, wait a little and 
continue */
Mfprintf(_mero_ctlerr, "error during accept: 
%s",
strerror(errno));
+   sleep_ms(500);
+   break;
+   case EINTR:
+   /* interrupted */
+   break;
+   default:
+   /* anything else */
+   Mfprintf(_mero_ctlerr, "error during accept: 
%s",
+   strerror(errno));
+   break;
}
continue;
}
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: default - Remove dead code.

2022-06-15 Thread Sjoerd Mullender
Changeset: b6a788ee6227 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b6a788ee6227
Modified Files:
tools/merovingian/client/monetdb.c
Branch: default
Log Message:

Remove dead code.


diffs (13 lines):

diff --git a/tools/merovingian/client/monetdb.c 
b/tools/merovingian/client/monetdb.c
--- a/tools/merovingian/client/monetdb.c
+++ b/tools/merovingian/client/monetdb.c
@@ -820,8 +820,7 @@ command_status(int argc, char *argv[])
prev = NULL;
while (stats != NULL) {
if (stats->locked == curLock &&
-   (curLock ||
-(!curLock && stats->state == curMode)))
+   (curLock || stats->state == curMode))
{
sabdb *next = stats->next;
stats->next = neworig;
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: geo-update - Merging with default due to problem with f...

2022-06-15 Thread stefanos mavros
Changeset: 9ad933bcfdc3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9ad933bcfdc3
Modified Files:
.hgtags
Branch: geo-update
Log Message:

Merging with default due to problem with filter functions


diffs (truncated from 95650 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -768,3 +768,4 @@ 2e54857a91306cc6304825c5596f65d00595db6b
 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_13
 1252291e5c0ddc91ccb16d612d04e34e6a7d3bc3 Jun2020_SP2_release
 59de1ee118d4eccc072c0cf3938f90635a7db311 Jan2022_15
+59de1ee118d4eccc072c0cf3938f90635a7db311 Jan2022_SP3_release
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,7 +70,6 @@ if(NOT HAVE_SYS_SOCKET_H)
 set(CMAKE_EXTRA_INCLUDE_FILES "winsock.h")
   endif()
 endif()
-set(CMAKE_REQUIRED_INCLUDES "/usr/include")
 
 monetdb_configure_sizes()
 
diff --git a/clients/ChangeLog.Jan2022 b/clients/ChangeLog.Jan2022
--- a/clients/ChangeLog.Jan2022
+++ b/clients/ChangeLog.Jan2022
@@ -1,3 +1,9 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Tue May 31 2022 Sjoerd Mullender 
+- Fixed a bug where when the semicolon at the end of a COPY INTO query
+  that reads from STDIN is at exactly a 10240 byte boundary in a file,
+  the data isn't read as input for the COPY INTO but instead as a new
+  SQL query.
+
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
@@ -190,6 +190,7 @@ gdk_return BATsemijoin(BAT **r1p, BAT **
 BAT *BATsetaccess(BAT *b, restrict_t mode) 
__attribute__((__warn_unused_result__));
 void BATsetcapacity(BAT *b, BUN cnt);
 void BATsetcount(BAT *b, BUN cnt);
+gdk_return BATsetstrimps(BAT *b);
 BAT *BATslice(BAT *b, BUN low, BUN high);
 gdk_return BATsort(BAT **sorted, BAT **order, BAT **groups, BAT *b, BAT *o, 
BAT *g, bool reverse, bool nilslast, bool stable) 
__attribute__((__warn_unused_result__));
 gdk_return BATstr_group_concat(ValPtr res, BAT *b, BAT *s, BAT *sep, bool 
skip_nils, bool nil_if_empty, const char *restrict separator);
@@ -200,7 +201,6 @@ gdk_return BATsum(void *res, int tp, BAT
 gdk_return BATthetajoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT 
*sr, int op, bool nil_matches, BUN estimate) 
__attribute__((__warn_unused_result__));
 BAT *BATthetaselect(BAT *b, BAT *s, const void *val, const char *op);
 void BATtseqbase(BAT *b, oid o);
-void BATundo(BAT *b);
 BAT *BATunique(BAT *b, BAT *s);
 BAT *BATunmask(BAT *b);
 gdk_return BATupdate(BAT *b, BAT *p, BAT *n, bool force) 
__attribute__((__warn_unused_result__));
@@ -401,7 +401,7 @@ BUN SORTfndfirst(BAT *b, const void *v);
 BUN SORTfndlast(BAT *b, const void *v);
 gdk_return STRMPcreate(BAT *b, BAT *s);
 void STRMPdestroy(BAT *b);
-BAT *STRMPfilter(BAT *b, BAT *s, const char *q);
+BAT *STRMPfilter(BAT *b, BAT *s, const char *q, const bool keep_nils);
 MT_Id THRcreate(void (*f)(void *), void *arg, enum MT_thr_detach d, const char 
*name);
 void *THRdata[THREADDATA];
 void THRdel(Thread t);
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2575,29 +2575,32 @@ dump_database(Mapi mid, stream *toConsol
"SELECT s.name, t.name, "
   "a.name, "
   "sum(p.privileges), "
-  "g.name, p.grantable "
+  "g.name, go.opt "
"FROM sys.schemas s, sys.tables t, "
 "sys.auths a, sys.privileges p, "
-"sys.auths g "
+"sys.auths g, "
+"(VALUES (0, ''), (1, ' WITH GRANT OPTION')) AS go (id, 
opt) "
"WHERE p.obj_id = t.id "
  "AND p.auth_id = a.id "
  "AND t.schema_id = s.id "
  "AND t.system = FALSE "
  "AND p.grantor = g.id "
-   "GROUP BY s.name, t.name, a.name, g.name, p.grantable "
-   "ORDER BY s.name, t.name, a.name, g.name, p.grantable";
+ "AND p.grantable = go.id "
+   "GROUP BY s.name, t.name, a.name, g.name, go.opt "
+   "ORDER BY s.name, t.name, a.name, g.name, go.opt";
const char *column_grants =
"SELECT s.name, t.name, "
   "c.name, a.name, "
   "pc.privilege_code_name, "
-  "g.name, p.grantable "
+  "g.name, go.opt "
"FROM sys.schemas s, "
 "sys.tables t, "
 "sys.columns c, "
 "sys.auths a, "
 "sys.privileges p, "
 "sys.auths g, "
-"sys.privilege_codes pc "
+"sys.privilege_codes pc, "
+"(VALUES (0, ''), (1, ' WITH GRANT OPTION')) AS go (id, 
opt) "
"WHERE p.obj_id = c.id "
 

MonetDB: geo-update - Fix non-existing bounding box on polygon f...

2022-06-15 Thread Bernardo Mota
Changeset: 6ca55805d7cd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6ca55805d7cd
Modified Files:
geom/monetdb5/geod.c
geom/monetdb5/geom.c
Branch: geo-update
Log Message:

Fix non-existing bounding box on polygon for distancegeographic, makeline 
temporary fix


diffs (161 lines):

diff --git a/geom/monetdb5/geod.c b/geom/monetdb5/geod.c
--- a/geom/monetdb5/geod.c
+++ b/geom/monetdb5/geod.c
@@ -174,6 +174,8 @@ geoLinesFromGeom(GEOSGeom geom)
return geo;
 }
 
+static BoundingBox * boundingBoxLines(GeoLines lines);
+
 /* Converts the a GEOSGeom Line into GeoPolygon (with exterior ring and 
zero-to-multiple interior rings)
Argument must be a Polygon geometry. */
 static GeoPolygon
@@ -192,8 +194,8 @@ geoPolygonFromGeom(GEOSGeom geom)
//Get interior rings GeoLines
for (int i = 0; i < geo.interiorRingsCount; i++)
geo.interiorRings[i] = 
geoLinesFromGeom((GEOSGeom)GEOSGetInteriorRingN(geom, i));
-   //TODO Calculate Boundind Box on initializion?
-   geo.bbox = NULL;
+   // If the geometry doesn't have BoundingBoxe, calculate it
+   geo.bbox = boundingBoxLines(geo.exteriorRing);
return geo;
 }
 
@@ -722,18 +724,12 @@ geoDistanceSingle(GEOSGeom aGeom, GEOSGe
/* Line/LinearRing and Polygon */
GeoLines a = geoLinesFromGeom(aGeom);
GeoPolygon b = geoPolygonFromGeom(bGeom);
-   // If the geometry doesn't have BoundingBoxe, calculate it
-   if (b.bbox == NULL)
-   b.bbox = boundingBoxLines(b.exteriorRing);
distance = geoDistanceLinePolygon(a, b);
freeGeoLines(a);
freeGeoPolygon(b);
} else if (dimA == 2 && dimB == 1) {
/* Polygon and Line/LinearRing */
GeoPolygon a = geoPolygonFromGeom(aGeom);
-   // If the geometry doesn't have BoundingBoxe, calculate it
-   if (a.bbox == NULL)
-   a.bbox = boundingBoxLines(a.exteriorRing);
GeoLines b = geoLinesFromGeom(bGeom);
distance = geoDistanceLinePolygon(b, a);
freeGeoPolygon(a);
@@ -742,11 +738,6 @@ geoDistanceSingle(GEOSGeom aGeom, GEOSGe
/* Polygon and Polygon */
GeoPolygon a = geoPolygonFromGeom(aGeom);
GeoPolygon b = geoPolygonFromGeom(bGeom);
-   // If the geometries don't have BoundingBoxes, calculate them
-   if (a.bbox == NULL)
-   a.bbox = boundingBoxLines(a.exteriorRing);
-   if (b.bbox == NULL)
-   b.bbox = boundingBoxLines(b.exteriorRing);
distance = geoDistancePolygonPolygon(a, b);
freeGeoPolygon(a);
freeGeoPolygon(b);
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -3384,14 +3384,12 @@ wkbMakeLineAggr(wkb **outWKB, bat *bid)
return err;
 }
 
-static str
+/*static str
 wkbMakeLineAggrArray(wkb **outWKB, wkb **inWKB_array, int size) {
str msg = MAL_SUCCEED;
int i;
wkb *aWKB, *bWKB;
 
-   /* TODO: what should be returned if the input is less than
-* two rows? --sjoerd */
if (size == 0) {
if ((*outWKB = wkbNULLcopy()) == NULL)
throw(MAL, "aggr.MakeLine", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
@@ -3420,6 +3418,70 @@ wkbMakeLineAggrArray(wkb **outWKB, wkb *
GDKfree(aWKB);
}
return msg;
+}*/
+
+static str
+wkbExtractPointToCoordSeq(GEOSCoordSeq *outCoordSeq, wkb *inWKB, int index) {
+   double x,y;
+   str msg = MAL_SUCCEED;
+   GEOSGeom inGeometry;
+   const GEOSCoordSequence *inCoordSeq = NULL;
+
+   inGeometry = wkb2geos(inWKB);
+   if (!inGeometry) {
+   throw(MAL, "geom.MakeLine", SQLSTATE(38000) "Geos operation 
wkb2geos failed");
+   }
+   inCoordSeq = GEOSGeom_getCoordSeq(inGeometry);
+   GEOSCoordSeq_getX(inCoordSeq, 0, &x);
+   GEOSCoordSeq_getY(inCoordSeq, 0, &y);
+   if (!GEOSCoordSeq_setX(*outCoordSeq, index, x) ||
+   !GEOSCoordSeq_setY(*outCoordSeq, index, y)) {
+   throw(MAL, "geom.MakeLine", SQLSTATE(38000) "Geos operation 
GEOSCoordSeq_set[XY] failed");
+   }
+   return msg;
+}
+
+static str
+wkbMakeLineAggrArray2(wkb **outWKB, wkb **inWKB_array, int size) {
+   str msg = MAL_SUCCEED;
+   int i;
+   wkb *aWKB, *bWKB;
+   GEOSGeom outGeometry;
+   GEOSCoordSeq outCoordSeq = NULL;
+
+   /* TODO: what should be returned if the input is less than
+* two rows? --sjoerd */
+   if (size == 0) {
+   if ((*outWKB = wkbNULLcopy()) == NULL)
+   throw(MAL, "aggr.MakeLine", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
+   return MAL_SUCCEED;
+   }
+   aWKB = inWKB_array[0];
+   if (size == 1

MonetDB: perf-imdb-air - This branch is to help reproduce perfor...

2022-06-15 Thread Aris Koning
Changeset: 6692da25d986 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6692da25d986
Branch: perf-imdb-air
Log Message:

This branch is to help reproduce performance degradation that workbench started 
to  demonstrate around 16 of May on default for imdb and airtraffic.

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


MonetDB: perf-imdb-air - One extra dummy commit.

2022-06-15 Thread Aris Koning
Changeset: 30088309fe21 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/30088309fe21
Added Files:
foo
Branch: perf-imdb-air
Log Message:

One extra dummy commit.


diffs (6 lines):

diff --git a/foo b/foo
new file mode 100644
--- /dev/null
+++ b/foo
@@ -0,0 +1,1 @@
+bar
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jan2022 - Split off test that only works with older R v...

2022-06-15 Thread Sjoerd Mullender
Changeset: 01aef0406052 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/01aef0406052
Added Files:
sql/backends/monet5/Tests/rapi09a.test
Modified Files:
sql/backends/monet5/Tests/All
sql/backends/monet5/Tests/rapi09.test
testing/Mtest.py.in
Branch: Jan2022
Log Message:

Split off test that only works with older R versions.


diffs (78 lines):

diff --git a/sql/backends/monet5/Tests/All b/sql/backends/monet5/Tests/All
--- a/sql/backends/monet5/Tests/All
+++ b/sql/backends/monet5/Tests/All
@@ -9,6 +9,7 @@ HAVE_LIBR&NOT_WIN32?rapi06
 HAVE_LIBR&NOT_WIN32?rapi07
 #HAVE_LIBR&NOT_WIN32?rapi08
 HAVE_LIBR&NOT_WIN32?rapi09
+HAVE_LIBR&NOT_WIN32&R_VERSION<4.2.0?rapi09a
 HAVE_LIBR&NOT_WIN32?rapi10
 HAVE_LIBR&NOT_WIN32?rapi12
 HAVE_LIBR&NOT_WIN32?rapi13
diff --git a/sql/backends/monet5/Tests/rapi09.test 
b/sql/backends/monet5/Tests/rapi09.test
--- a/sql/backends/monet5/Tests/rapi09.test
+++ b/sql/backends/monet5/Tests/rapi09.test
@@ -63,18 +63,6 @@ SELECT * FROM suicide2()
 statement ok
 ROLLBACK
 
-statement ok
-START TRANSACTION
-
-statement ok
-CREATE FUNCTION suicide3() RETURNS TABLE (i integer) LANGUAGE R 
{.Internal(quit("no", 0,F))}
-
-statement error
-SELECT * FROM suicide3()
-
-statement ok
-ROLLBACK
-
 query I rowsort
 SELECT 1
 
diff --git a/sql/backends/monet5/Tests/rapi09a.test 
b/sql/backends/monet5/Tests/rapi09a.test
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/rapi09a.test
@@ -0,0 +1,17 @@
+statement ok
+START TRANSACTION
+
+statement ok
+CREATE FUNCTION suicide3() RETURNS TABLE (i integer) LANGUAGE R 
{.Internal(quit("no", 0,F))}
+
+statement error
+SELECT * FROM suicide3()
+
+statement ok
+ROLLBACK
+
+query I rowsort
+SELECT 1
+
+1
+
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2027,6 +2027,19 @@ def RunTest(env, TST, COND, oktests, len
 break
 if reason is not None:
 break
+elif cond.startswith('R_VERSION<'):
+rversion = os.path.join('@LIBR_INCLUDE_DIRS@', 'Rversion.h')
+if os.path.exists(rversion):
+with openutf8(rversion, 'r') as f:
+res = re.search('#define R_VERSION (?P\d+)', 
f.read())
+if res is not None:
+r_version = res.group('rversion')
+req_version = cond[10:].split('.')
+req_version = int(req_version[0]) * 65536 + 
int(req_version[1]) * 256 + int(req_version[2])
+if int(r_version) >= req_version:
+reason = "R version too high"
+elem = SkipTest(env, TST, EXT, reason, length)
+break
 elif cond not in CONDITIONALS:
 reason = "as conditional '%s' is unknown." % cond
 elem = SkipTest(env, TST, EXT, reason, length)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: Jan2022 - Reverse R version test and add negation to th...

2022-06-15 Thread Sjoerd Mullender
Changeset: 626ee3024b3c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/626ee3024b3c
Modified Files:
sql/backends/monet5/Tests/All
testing/Mtest.py.in
Branch: Jan2022
Log Message:

Reverse R version test and add negation to the mix.
This way, the test is the same as the one for GEOS.


diffs (47 lines):

diff --git a/sql/backends/monet5/Tests/All b/sql/backends/monet5/Tests/All
--- a/sql/backends/monet5/Tests/All
+++ b/sql/backends/monet5/Tests/All
@@ -9,7 +9,7 @@ HAVE_LIBR&NOT_WIN32?rapi06
 HAVE_LIBR&NOT_WIN32?rapi07
 #HAVE_LIBR&NOT_WIN32?rapi08
 HAVE_LIBR&NOT_WIN32?rapi09
-HAVE_LIBR&NOT_WIN32&R_VERSION<4.2.0?rapi09a
+HAVE_LIBR&NOT_WIN32&!R_VERSION>=4.2.0?rapi09a
 HAVE_LIBR&NOT_WIN32?rapi10
 HAVE_LIBR&NOT_WIN32?rapi12
 HAVE_LIBR&NOT_WIN32?rapi13
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2027,19 +2027,25 @@ def RunTest(env, TST, COND, oktests, len
 break
 if reason is not None:
 break
-elif cond.startswith('R_VERSION<'):
+elif cond.startswith('R_VERSION>='):
 rversion = os.path.join('@LIBR_INCLUDE_DIRS@', 'Rversion.h')
 if os.path.exists(rversion):
 with openutf8(rversion, 'r') as f:
 res = re.search('#define R_VERSION (?P\d+)', 
f.read())
 if res is not None:
 r_version = res.group('rversion')
-req_version = cond[10:].split('.')
+req_version = cond[11:].split('.')
 req_version = int(req_version[0]) * 65536 + 
int(req_version[1]) * 256 + int(req_version[2])
-if int(r_version) >= req_version:
-reason = "R version too high"
-elem = SkipTest(env, TST, EXT, reason, length)
-break
+if not negate:
+if int(r_version) < req_version:
+reason = "R version too low"
+elem = SkipTest(env, TST, EXT, reason, 
length)
+break
+else:
+if int(r_version) >= req_version:
+reason = "R version too high"
+elem = SkipTest(env, TST, EXT, reason, 
length)
+break
 elif cond not in CONDITIONALS:
 reason = "as conditional '%s' is unknown." % cond
 elem = SkipTest(env, TST, EXT, reason, length)
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: imdbairperf - Rename branch.

2022-06-15 Thread Aris Koning
Changeset: 68c912f015b0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/68c912f015b0
Branch: imdbairperf
Log Message:

Rename branch.

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


MonetDB: imdbairperf - Another dummy commit.

2022-06-15 Thread Aris Koning
Changeset: c2399b99a375 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c2399b99a375
Modified Files:
foo
Branch: imdbairperf
Log Message:

Another dummy commit.


diffs (6 lines):

diff --git a/foo b/foo
--- a/foo
+++ b/foo
@@ -1,1 +1,2 @@
 bar
+stuff
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: perf-imdb-air - Renamed branch to imdbairperf.

2022-06-15 Thread Aris Koning
Changeset: bdd5372c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bdd5372c
Branch: perf-imdb-air
Log Message:

Renamed branch to imdbairperf.

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


MonetDB: userprofile - add password column to users tbl

2022-06-15 Thread svetlin
Changeset: 8e4c0ac61102 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8e4c0ac61102
Modified Files:
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_authorize.h
monetdb5/mal/mal_session.c
sql/backends/monet5/sql_user.c
Branch: userprofile
Log Message:

add password column to users tbl


diffs (215 lines):

diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -87,7 +87,7 @@ AUTHfindUser(const char *username)
 }
 
 /**
- * Requires the current client to be the admin user thread.  If not the case,
+ * Requires the current client to be the admin user thread. If not the case,
  * this function returns an InvalidCredentialsException.
  */
 static str
@@ -432,7 +432,7 @@ AUTHcheckCredentials(
str pwd = NULL;
str hash = NULL;
BUN p;
-   BATiter passi;
+   // BATiter passi;
 
if (cntxt)
rethrow("checkCredentials", tmp, AUTHrequireAdminOrUser(cntxt, 
username));
@@ -456,13 +456,17 @@ AUTHcheckCredentials(
throw(INVCRED, "checkCredentials", INVCRED_INVALID_USER " 
'%s'", username);
}
 
+   // WIP load password from users tbl
+   if (authCallbackCntx.get_user_password && cntxt)
+   tmp = authCallbackCntx.get_user_password(cntxt, username);
+
/* find the corresponding password to the user */
-   passi = bat_iterator(pass);
-   tmp = (str)BUNtvar(passi, p);
-   assert (tmp != NULL);
+   // passi = bat_iterator(pass);
+   // tmp = (str)BUNtvar(passi, p);
+   // assert (tmp != NULL);
/* decypher the password (we lose the original tmp here) */
tmp = AUTHdecypherValue(&pwd, tmp);
-   bat_iterator_end(&passi);
+   // bat_iterator_end(&passi);
if (tmp)
return tmp;
 
@@ -1271,3 +1275,10 @@ AUTHRegisterGetPasswordHandler(get_user_
authCallbackCntx.get_user_password = callback;
return MAL_SUCCEED;
 }
+
+
+str
+AUTHGeneratePasswordHash(str *res, const char *value)
+{
+   return AUTHcypherValue(res, value);
+}
diff --git a/monetdb5/mal/mal_authorize.h b/monetdb5/mal/mal_authorize.h
--- a/monetdb5/mal/mal_authorize.h
+++ b/monetdb5/mal/mal_authorize.h
@@ -46,12 +46,13 @@ mal_export str AUTHdeleteRemoteTableCred
  */
 mal_export str AUTHunlockVault(const char *password);
 
-typedef str (*get_user_password_handler)(void *mvc, str user);
+typedef str (*get_user_password_handler)(Client c, const char *user);
 
 typedef struct AUTHCallbackCntx {
get_user_password_handler get_user_password;
 } AUTHCallbackCntx;
 
 mal_export str AUTHRegisterGetPasswordHandler(get_user_password_handler 
callback);
+mal_export str AUTHGeneratePasswordHash(str *res, const char *value);
 
 #endif /* _MAL_AUTHORIZE_H */
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -279,10 +279,14 @@ MSscheduleClient(str command, str challe
sabdb *stats = NULL;
 
if (!GDKembedded()) {
+   c = MCinitClient(MAL_ADMIN, NULL, NULL);
+   Scenario scenario = findScenario(lang);
+   scenario->initClientCmd(c);
/* access control: verify the credentials supplied by 
the user,
* no need to check for database stuff, because that is 
done per
* database itself (one gets a redirect) */
-   err = AUTHcheckCredentials(&uid, NULL, user, passwd, 
challenge, algo);
+   err = AUTHcheckCredentials(&uid, c, user, passwd, 
challenge, algo);
+   scenario->exitClientCmd(c);
if (err != MAL_SUCCEED) {
mnstr_printf(fout, "!%s\n", err);
exit_streams(fin, fout);
diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c
--- a/sql/backends/monet5/sql_user.c
+++ b/sql/backends/monet5/sql_user.c
@@ -34,26 +34,30 @@ getUsersTbl(mvc *m)
 
 
 static oid
-getUserOIDByName(mvc *m, str user)
+getUserOIDByName(mvc *m, const char *user)
 {
sql_trans *tr = m->session->tr;
sqlstore *store = m->session->tr->store;
sql_table *users = getUsersTbl(m);
-   return store->table_api.column_find_row(tr, find_sql_column(users, 
"name"), user, NULL);
+   sql_column *users_name = find_sql_column(users, "name");
+   return store->table_api.column_find_row(tr, users_name, user, NULL);
 }
 
 
 static str
-getPasswordHash(ptr _mvc, str user)
+getPasswordHash(Client c, const char *user)
 {
-   mvc *m = (mvc *) _mvc;
+   str res;
+   mvc *m = ((backend *) c->sqlcontext)->mvc;
sql_trans *tr = m->session->tr;
sqlstore *store = m->session->tr->store;
sql_table *users = getUsersTbl(m);
+   sql_trans_begin(m->session);

MonetDB: userprofile - merge default

2022-06-15 Thread svetlin
Changeset: 0f5ff89ffa74 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0f5ff89ffa74
Branch: userprofile
Log Message:

merge default


diffs (truncated from 444 to 300 lines):

diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog
--- a/clients/odbc/ChangeLog
+++ b/clients/odbc/ChangeLog
@@ -1,6 +1,12 @@
 # ChangeLog file for odbc
 # This file is updated with Maddlog
 
+* Thu Jun  9 2022 Martin van Dinther 
+- For SQLForeignKeys() corrected the output of columns UPDATE_RULE and
+  DELETE_RULE. These columns used to always return 3 (= SQL_NO_ACTION)
+  but now they will report the action codes as specified in the FOREIGN KEY
+  CONSTRAINT construction.
+
 * Thu Jun  2 2022 Martin van Dinther 
 - Fixed issue in function SQLProcedureColumns(). When the argument ColumnName
   was not empty it generated an invalid SQL query which failed with error:
diff --git a/clients/odbc/driver/SQLForeignKeys.c 
b/clients/odbc/driver/SQLForeignKeys.c
--- a/clients/odbc/driver/SQLForeignKeys.c
+++ b/clients/odbc/driver/SQLForeignKeys.c
@@ -139,9 +139,9 @@ MNDBForeignKeys(ODBCStmt *stmt,
}
}
 
-   /* first create a string buffer (1200 extra bytes is plenty:
-  we actually need just over 1000) */
-   querylen = 1200 + (2 * strlen(stmt->Dbc->dbname)) +
+   /* first create a string buffer (1300 extra bytes is plenty:
+  we actually need just over 1100) */
+   querylen = 1300 + (2 * strlen(stmt->Dbc->dbname)) +
(psch ? strlen(psch) : 0) + (ptab ? strlen(ptab) : 0) +
(fsch ? strlen(fsch) : 0) + (ftab ? strlen(ftab) : 0);
query = malloc(querylen);
@@ -167,35 +167,44 @@ MNDBForeignKeys(ODBCStmt *stmt,
 
pos += snprintf(query + pos, querylen - pos,
"select '%s' as \"PKTABLE_CAT\", "
-  "pks.name as \"PKTABLE_SCHEM\", "
-  "pkt.name as \"PKTABLE_NAME\", "
-  "pkkc.name as \"PKCOLUMN_NAME\", "
-  "'%s' as \"FKTABLE_CAT\", "
-  "fks.name as \"FKTABLE_SCHEM\", "
-  "fkt.name as \"FKTABLE_NAME\", "
-  "fkkc.name as \"FKCOLUMN_NAME\", "
-  "cast(fkkc.nr + 1 as smallint) as \"KEY_SEQ\", "
-  "cast(%d as smallint) as \"UPDATE_RULE\", "
-  "cast(%d as smallint) as \"DELETE_RULE\", "
-  "fkk.name as \"FK_NAME\", "
-  "pkk.name as \"PK_NAME\", "
-  "cast(%d as smallint) as \"DEFERRABILITY\" "
-   "from sys.schemas fks, sys.tables fkt, "
-"sys.objects fkkc, sys.keys as fkk, "
-"sys.schemas pks, sys.tables pkt, "
-"sys.objects pkkc, sys.keys as pkk "
-   "where fkt.id = fkk.table_id and "
- "pkt.id = pkk.table_id and "
+   "pks.name as \"PKTABLE_SCHEM\", "
+   "pkt.name as \"PKTABLE_NAME\", "
+   "pkkc.name as \"PKCOLUMN_NAME\", "
+   "'%s' as \"FKTABLE_CAT\", "
+   "fks.name as \"FKTABLE_SCHEM\", "
+   "fkt.name as \"FKTABLE_NAME\", "
+   "fkkc.name as \"FKCOLUMN_NAME\", "
+   "cast(fkkc.nr + 1 as smallint) as \"KEY_SEQ\", "
+   /* logic for "action" value interpretation pulled from 
clients/mapiclient/dump.c dump_foreign_keys() */
+   /* for "action" code values meaning see table: 
sys.fkey_actions */
+   "cast(CASE ((fkk.\"action\" >> 8) & 255)"
+   " WHEN 0 THEN %d WHEN 1 THEN %d WHEN 2 THEN %d"
+   " WHEN 3 THEN %d WHEN 4 THEN %d ELSE %d END"
+   " AS smallint) as \"UPDATE_RULE\", "
+   "cast(CASE (fkk.\"action\" & 255)"
+   " WHEN 0 THEN %d WHEN 1 THEN %d WHEN 2 THEN %d"
+   " WHEN 3 THEN %d WHEN 4 THEN %d ELSE %d END"
+   " AS smallint) as \"DELETE_RULE\", "
+   "fkk.name as \"FK_NAME\", "
+   "pkk.name as \"PK_NAME\", "
+   "cast(%d as smallint) as \"DEFERRABILITY\" "
+   "from sys.keys as fkk, sys.objects fkkc, sys.tables fkt, 
sys.schemas fks, "
+"sys.keys as pkk, sys.objects pkkc, sys.tables pkt, 
sys.schemas pks "
+   "where fkk.rkey > 0 and "   /* exclude invalid rkey 
references, such as -1 first */
+ "fkk.rkey = pkk.id and "
  "fkk.id = fkkc.id and "
  "pkk.id = pkkc.id and "
+ "fkkc.nr = pkkc.nr and "
+ "fkt.id = fkk.table_id and "
+ "pkt.id = pkk.table_id and "
  "fks.id = fkt.schema_id and "
- "pks.id = pkt.schema_id and "
-