Changeset: 22f55e05b8b4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22f55e05b8b4
Added Files:
        clients/Tests/MAL-signatures_nogeom.malC.src
        clients/Tests/MAL-signatures_nogeom.stable.err
        clients/Tests/MAL-signatures_nogeom.stable.out
        clients/Tests/SQL-dump_nogeom.sql.src
        clients/Tests/SQL-dump_nogeom.stable.err
        clients/Tests/SQL-dump_nogeom.stable.out
        sql/benchmarks/tpch/fileleak/Tests/delete_all_nogeom.SQL.py.src
        sql/benchmarks/tpch/fileleak/Tests/delete_all_nogeom.stable.err
        sql/benchmarks/tpch/fileleak/Tests/delete_all_nogeom.stable.out
        sql/benchmarks/tpch/fileleak/Tests/leaks_nogeom.SQL.py.src
        sql/benchmarks/tpch/fileleak/Tests/leaks_nogeom.stable.err
        sql/benchmarks/tpch/fileleak/Tests/leaks_nogeom.stable.out
Modified Files:
        .hgtags
        MonetDB.spec
        NT/installer32/MonetDB-ODBC-Installer.vdproj
        NT/installer32/MonetDB5-Geom-Module.vdproj
        NT/installer32/MonetDB5-SQL-Installer.vdproj
        NT/installer64/MonetDB-ODBC-Installer.vdproj
        NT/installer64/MonetDB5-Geom-Module.vdproj
        NT/installer64/MonetDB5-SQL-Installer.vdproj
        NT/monetdb_config.h.in
        NT/rules.msc
        clients/R/MonetDB.R/DESCRIPTION
        clients/R/MonetDB.R/R/monetdb.R
        clients/R/MonetDB.R/src/mapi.c
        clients/Tests/All
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.Windows
        clients/Tests/exports.stable.out
        clients/mapilib/mapi.rc
        clients/odbc/driver/driver.rc
        clients/odbc/winsetup/setup.rc
        clients/python2/setup.py
        clients/python3/setup.py
        common/stream/stream.c
        configure.ag
        debian/changelog
        gdk/gdk_select.c
        gdk/libbat.rc
        libversions
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_interpreter.h
        monetdb5/modules/mal/language.mal
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/tablet.c
        monetdb5/optimizer/opt_dataflow.c
        monetdb5/tools/libmonetdb5.rc
        sql/backends/monet5/sql.mx
        sql/benchmarks/tpch/fileleak/Tests/All
        sql/server/rel_select.c
        
sql/test/BugTracker-2012/Tests/predicate_select.Bug-3090_nogeom.stable.out
        sql/test/Tests/systemfunctions_nogeom.stable.out
        sql/test/leaks/Tests/check1_nogeom.stable.out
        sql/test/leaks/Tests/check2_nogeom.stable.out
        sql/test/leaks/Tests/check3_nogeom.stable.out
        sql/test/leaks/Tests/check4_nogeom.stable.out
        sql/test/leaks/Tests/check5_nogeom.stable.out
        sql/test/leaks/Tests/temp2_nogeom.stable.out
        vertoo.data
Branch: int128
Log Message:

Merge with changeset 54740f826e8d, i.e., default after merge with Feb2013-SP4


diffs (truncated from 52552 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -535,3 +535,6 @@ 64caf95db680ce67235697114693cbcf4cc859eb
 3d1afd974f11634c77ded6c090cdbd52be6ab1c1 int128_root
 0ee7e3f578f7ed364682cae20edac923c27dfd86 Feb2013_13
 89679ea95aac8f548c787cd74c35212137f5b56f Feb2013_SP4_release
+e4239a86f8032fd67169ddf4bcea6f37f32a0f8b Feb2013_15
+89679ea95aac8f548c787cd74c35212137f5b56f Feb2013_SP4_release
+11955d7a07f23672650e41dd0c9fbc9e0fc4c1af Feb2013_SP4_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -758,6 +758,9 @@ rm -f $RPM_BUILD_ROOT%{_bindir}/Maddlog
 rm -fr $RPM_BUILD_ROOT
 
 %changelog
+* Wed Sep 25 2013 Sjoerd Mullender <sjo...@acm.org> - 11.15.15-20130925
+- Rebuilt.
+
 * Fri Sep 20 2013 Sjoerd Mullender <sjo...@acm.org> - 11.15.13-20130920
 - Rebuilt.
 
diff --git a/clients/R/MonetDB.R/DESCRIPTION b/clients/R/MonetDB.R/DESCRIPTION
--- a/clients/R/MonetDB.R/DESCRIPTION
+++ b/clients/R/MonetDB.R/DESCRIPTION
@@ -1,10 +1,10 @@
 Package: MonetDB.R
 Version: 0.8.0
-Date: 2013-09-17
+Date: 2013-09-25
 Title: Connect MonetDB to R
-Authors@R: c(person("Hannes Muehleisen", "Developer", role = c("aut", 
"cre"),email = "han...@cwi.nl"),
-       person("Thomas Lumley", "Contributor", role = "ctb"),
-       person("Anthony Damico", "Contributor", role = "ctb"))
+Authors@R: c(person("Hannes Muehleisen", role = c("aut", "cre"),email = 
"han...@cwi.nl"),
+       person("Thomas Lumley", role = "ctb"),
+       person("Anthony Damico", role = "ctb"))
 Depends: DBI (>= 0.2-5), digest (>= 0.6.0), methods, utils, stats
 Description: Allows to pull data from MonetDB into R
 License: MPL (== 1.1)
diff --git a/clients/R/MonetDB.R/R/monetdb.R b/clients/R/MonetDB.R/R/monetdb.R
--- a/clients/R/MonetDB.R/R/monetdb.R
+++ b/clients/R/MonetDB.R/R/monetdb.R
@@ -1,15 +1,19 @@
 require(DBI)
 require(digest)
 
+C_LIBRARY <- "MonetDB.R"
+
 .onLoad <- function(lib, pkg) {
-       library.dynam( "MonetDB.R", pkg, lib )
-       .Call("mapiInit",PACKAGE="MonetDB.R")
+       library.dynam( C_LIBRARY, pkg, lib )
+       .Call("mapiInit",PACKAGE=C_LIBRARY)
 }
 
 # TODO: make these values configurable in the call to dbConnect
 DEBUG_IO      <- FALSE
 DEBUG_QUERY   <- FALSE
 
+
+
 # Make S4 aware of S3 classes
 setOldClass(c("sockconn","connection","monetdb_mapi_conn"))
 
@@ -23,7 +27,7 @@ MonetR <- MonetDB <- MonetDBR <- MonetDB
 
 setMethod("dbGetInfo", "MonetDBDriver", def=function(dbObj, ...)
                        list(name="MonetDBDriver", 
-                                       driver.version="0.7.11",
+                                       driver.version="0.8.0",
                                        DBI.version="0.2-5",
                                        client.version=NA,
                                        max.connections=NA)
@@ -64,17 +68,17 @@ setMethod("dbConnect", "MonetDBDriver", 
                                                                #       
blocking = TRUE, open="r+b",timeout = 5 )
                                                                
                                                                # this goes to 
src/mapi.c
-                                                               socket <- 
socket <<- .Call("mapiConnect",host,port,5,PACKAGE="MonetDB.R")
+                                                               socket <- 
socket <<- .Call("mapiConnect",host,port,5,PACKAGE=C_LIBRARY)
                                                                # authenticate
                                                                
.monetAuthenticate(socket,dbname,user,password)
                                                                # test the 
connection to make sure it works before
                                                                
.mapiWrite(socket,"sSELECT 42;"); .mapiRead(socket)
                                                                #close(socket)
-                                                               
.Call("mapiDisconnect",socket,PACKAGE="MonetDB.R")
+                                                               
.Call("mapiDisconnect",socket,PACKAGE=C_LIBRARY)
                                                                break
                                                        }, error = function(e) {
                                                                if 
("connection" %in% class(socket)) {
-                                                                       
.Call("mapiDisconnect",socket,PACKAGE="MonetDB.R")
+                                                                       
.Call("mapiDisconnect",socket,PACKAGE=C_LIBRARY)
                                                                }
                                                                
cat(paste0("Server not ready(",e$message,"), retrying (ESC or CTRL+C to 
abort)\n"))
                                                                Sys.sleep(1)
@@ -86,7 +90,7 @@ setMethod("dbConnect", "MonetDBDriver", 
                        # make new socket with user-specified timeout
                        #socket <- socket <<- socketConnection(host = host, 
port = port, 
                        #       blocking = TRUE, open="r+b",timeout = timeout) 
-                       socket <- socket <<- 
.Call("mapiConnect",host,port,timeout,PACKAGE="MonetDB.R")
+                       socket <- socket <<- 
.Call("mapiConnect",host,port,timeout,PACKAGE=C_LIBRARY)
                        .monetAuthenticate(socket,dbname,user,password)
                        connenv <- new.env(parent=emptyenv())
                        connenv$lock <- 0
@@ -102,7 +106,7 @@ setMethod("dbConnect", "MonetDBDriver", 
 setClass("MonetDBConnection", 
representation("DBIConnection",socket="externalptr",connenv="environment",fetchSize="integer"))
 
 setMethod("dbDisconnect", "MonetDBConnection", def=function(conn, ...) {
-                       .Call("mapiDisconnect",conn@socket,PACKAGE="MonetDB.R")
+                       .Call("mapiDisconnect",conn@socket,PACKAGE=C_LIBRARY)
                        TRUE
                })
 
@@ -403,7 +407,7 @@ setMethod("fetch", signature(res="MonetD
                        #parts[parts=="NULL"] <- NA
                        
                        # call to a faster C implementation for the hard and 
annoying task of splitting everyting into fields
-                       parts <- .Call("mapiSplit", 
res@env$data[1:n],info$cols, PACKAGE="MonetDB.R")
+                       parts <- .Call("mapiSplit", 
res@env$data[1:n],info$cols, PACKAGE=C_LIBRARY)
                        
                        # convert values column by column
                        for (j in seq.int(info$cols)) { 
@@ -533,16 +537,25 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
        conObj@connenv$lock <- 1
        
        # send payload and read response                
-       .mapiWrite(conObj@socket,msg)
-       resp <- .mapiRead(conObj@socket)
+       #.mapiWrite(conObj@socket,msg)
+       #resp <- .mapiRead(conObj@socket)
+       
+       if (DEBUG_IO)  cat(paste("TX: '",msg,"'\n",sep=""))     
+       resp <- .Call("mapiRequest",conObj@socket,msg,PACKAGE=C_LIBRARY)
+       if (DEBUG_IO) {
+               dstr <- resp
+               if (nchar(dstr) > 300) {
+                       dstr <- 
paste0(substring(dstr,1,200),"...",substring(dstr,nchar(dstr)-100,nchar(dstr))) 
+               } 
+               cat(paste0("RX: '",dstr,"'\n"))
+       }
        
        # get deferred statements from deferred list and execute
        while (length(conObj@connenv$deferred) > 0) {
                # take element, execute, check response for prompt
                dmesg <- conObj@connenv$deferred[[1]]
                conObj@connenv$deferred[[1]] <- NULL
-               .mapiWrite(conObj@socket,dmesg)
-               dresp <- .mapiParseResponse(.mapiRead(conObj@socket))
+               dresp <- 
.mapiParseResponse(.Call("mapiRequest",conObj@socket,dmesg,PACKAGE=C_LIBRARY))
                if (dresp$type == MSG_MESSAGE) {
                        conObj@connenv$lock <- 0
                        warning(paste("II: Failed to execute deferred statement 
'",dmesg,"'. Server said: '",dresp$message,"'\n"))
@@ -556,7 +569,7 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
 
 .mapiCleanup <- function(conObj) {
        if (conObj@connenv$lock > 0) {
-               cat("II: Interrupted query execution. Beware that a 
long-running query in the MonetDB server is NOT affected by this, so please 
consider restarting the server & reopen the connection.\n")
+               if (DEBUG_QUERY) cat("II: Interrupted query execution.\n")
                conObj@connenv$lock <- 0
        }
 }
@@ -564,7 +577,7 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
 .mapiRead <- function(con) {
        if (!identical(class(con)[[1]],"externalptr"))
                stop("I can only be called with a MonetDB connection object as 
parameter.")
-       respstr <- .Call("mapiRead",con,PACKAGE="MonetDB.R")
+       respstr <- .Call("mapiRead",con,PACKAGE=C_LIBRARY)
        if (DEBUG_IO) {
                dstr <- respstr
                if (nchar(dstr) > 300) {
@@ -580,7 +593,7 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
                stop("I can only be called with a MonetDB connection object as 
parameter.")
        
        if (DEBUG_IO)  cat(paste("TX: '",msg,"'\n",sep=""))     
-       .Call("mapiWrite",con,msg,PACKAGE="MonetDB.R")
+       .Call("mapiWrite",con,msg,PACKAGE=C_LIBRARY)
        return (NULL)
 }
 
@@ -625,7 +638,8 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
                        env$lengths     <- .mapiParseTableHeader(lines[5])
                        
                        env$tuples <-lines[6:length(lines)]
-                       
+
+                       stopifnot(length(env$tuples) == header$index)
                        return(env)
                }
                # Continuation of Q_TABLE without headers describing table 
structure
@@ -640,6 +654,8 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
                        env$index       <- header$index
                        env$tuples <- lines[2:length(lines)]
                        
+                       stopifnot(length(env$tuples) == header$rows)
+                       
                        return(env)
                }
                
diff --git a/clients/R/MonetDB.R/src/mapi.c b/clients/R/MonetDB.R/src/mapi.c
--- a/clients/R/MonetDB.R/src/mapi.c
+++ b/clients/R/MonetDB.R/src/mapi.c
@@ -13,6 +13,7 @@
 #endif
 #include <assert.h>
 #include <fcntl.h>
+#include <errno.h>
 
 // R headers
 #include <R.h>
@@ -31,8 +32,9 @@ static SEXP MAPI_type_tag;
 
 #define CHECK_MAPI_SOCK(s) do { \
     if (TYPEOF(s) != EXTPTRSXP || \
-        R_ExternalPtrTag(s) != MAPI_type_tag) \
-        error("bad socket"); \
+        R_ExternalPtrTag(s) != MAPI_type_tag || \
+        EXTPTR_PTR(s) == NULL) \
+        error("Socket has already been closed and cannot be used."); \
 } while (0)
 
 SEXP mapiInit(void) {
@@ -83,9 +85,14 @@ SEXP mapiConnect(SEXP host, SEXP port, S
 #endif
 
        //  send/receive timeouts for socket
+#ifdef __WIN32__
+       int sto;
+       sto = timeoutval * 1000;
+#else
        struct timeval sto;
        sto.tv_sec = timeoutval;
        sto.tv_usec = 0;
+#endif
 
        memset(&hints, 0, sizeof(struct addrinfo));
        hints.ai_family = AF_UNSPEC;
@@ -105,11 +112,11 @@ SEXP mapiConnect(SEXP host, SEXP port, S
                if (sock == -1)
                        continue;
 
-               if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *) &sto,
+               if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *) 
&sto,
                                sizeof(sto)) < 0) {
                        error("setsockopt failed");
                }
-               if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *) &sto,
+               if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *) 
&sto,
                                sizeof(sto)) < 0) {
                        error("setsockopt failed\n");
                }
@@ -149,16 +156,47 @@ SEXP mapiConnect(SEXP host, SEXP port, S
        return connobj;
 }
 
+size_t sockRead(int fd, void *buf, size_t size) {
+       ssize_t retval = -1;
+       do {
+               retval = recv(fd, buf, size, MSG_WAITALL);
+       } while (retval == -1 && errno == EINTR);
+       if (retval == -1) {
+#ifdef __WIN32__
+               errno = WSAGetLastError();
+#endif
+               error("error reading from socket (%d)", errno);
+       } else {
+               return retval;
+       }
+}
+
+size_t sockWrite(int fd, const void *buf, size_t size) {
+       ssize_t retval = -1;
+       do {
+               retval = send(fd, buf, size, 0);
+       } while (retval == -1 && errno == EINTR);
+       if (retval == -1) {
+#ifdef __WIN32__
+               errno = WSAGetLastError();
+#endif
+               error("error writing to socket (%d)", errno);
+       } else {
+               return retval;
+       }
+}
+
 SEXP mapiRead(SEXP conn) {
        CHECK_MAPI_SOCK(conn);
        SOCKET sock = *((SOCKET*) R_ExternalPtrAddr(conn));
 
        SEXP lines;
        char read_buf[BUFSIZE];
-       int n, block_final, block_length;
+       int block_final, block_length;
        short header;
        size_t response_buf_len = ALLOCSIZE;
        size_t response_buf_offset = 0;
+       size_t n = 0;
 
        char* response_buf = malloc(response_buf_len);
        if (response_buf == NULL) {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to