Changeset: b9c7a2e08cba for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b9c7a2e08cba
Modified Files:
        clients/R/MonetDB.R/NEWS
        clients/R/MonetDB.R/R/dbi.R
        clients/R/MonetDB.R/R/mapi.R
Branch: embedded
Log Message:

R client fixes


diffs (114 lines):

diff --git a/clients/R/MonetDB.R/NEWS b/clients/R/MonetDB.R/NEWS
--- a/clients/R/MonetDB.R/NEWS
+++ b/clients/R/MonetDB.R/NEWS
@@ -12,7 +12,6 @@ 1.0.0
 - Added lower.case.names argument to monet.read.csv() in case users want to 
avoid quoting (a bit)
 - Fix for dbConnect() that should be more robust to invalid connections
 - Cleaned up quoting behavior in dbListTables(), dbRemoveTable() etc.
-- Initial support for running MonetDB in embedded mode (MonetDBLite)
 - Now re-establishing connection if interrupt (CMD-C or ESC) occurs
 - Fixed a bug in monetdb.read.csv for multiple CSV files without headers
 - dplyr src_monetdb now has a con parameter to pass an existing DBI connection
@@ -21,6 +20,9 @@ 1.0.0
 - Added transactions to monetdb.read.csv so no empty tables are left over
 - Fixed != comparisions in dplyr (Thanks, David)
 - New "mclient" function to get a shell-like DB interface
+- Support for running MonetDB in embedded mode (MonetDBLite)
+- Support for monetdblite:/some/path URLs in dbConnect()
+- Fixed an off-by-one error in type conversion (Thanks, Kirill)
 
 0.9.7
 - Fixed crash on Windows (Sorry, everyone)
diff --git a/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R
--- a/clients/R/MonetDB.R/R/dbi.R
+++ b/clients/R/MonetDB.R/R/dbi.R
@@ -46,7 +46,7 @@ setMethod("dbConnect", "MonetDBDriver", 
                                                      password="monetdb", 
host="localhost", port=50000L, timeout=86400L, wait=FALSE, language="sql", 
embedded=FALSE,
                                                      ..., url="") {
   
-  if (substring(url, 1, 10) == "monetdb://") {
+  if (substring(url, 1, 10) == "monetdb://" || substring(url, 1, 12) == 
"monetdblite:") {
     dbname <- url
   }
   timeout <- as.integer(timeout)
@@ -81,12 +81,16 @@ setMethod("dbConnect", "MonetDBDriver", 
   }
   # this is important, otherwise we'll trip an assertion
   port <- as.integer(port)
-
   # validate port number
   if (length(port) != 1 || port < 1 || port > 65535) {
     stop("Illegal port number ",port)
   }
 
+  # support monetdblite:/db/dir urls to fool sqlsurvey
+  if (substring(dbname, 1, 12) == "monetdblite:") {
+    embedded <- substring(dbname, 13, nchar(dbname))
+  }
+
   if (embedded != FALSE) {
     if (!require("MonetDBLite", character.only=T)) {
       stop("MonetDBLite package required for embedded mode")
@@ -95,7 +99,9 @@ setMethod("dbConnect", "MonetDBDriver", 
     connenv <- new.env(parent=emptyenv())
     connenv$conn <- MonetDBLite::monetdb_embedded_connect()
     connenv$open <- TRUE
-    return(new("MonetDBEmbeddedConnection", connenv=connenv))
+    conn <- new("MonetDBEmbeddedConnection", connenv=connenv)
+    attr(conn, "dbPreExists") <- TRUE
+    return(conn)
   }
   
   if (getOption("monetdb.debug.mapi", F)) message("II: Connecting to MonetDB 
on host ", host, " at "
@@ -138,6 +144,7 @@ setMethod("dbConnect", "MonetDBDriver", 
     message("MonetDB: Switching to single-threaded query execution.")
     dbSendQuery(conn, "set optimizer='sequential_pipe'")
   }
+  attr(conn, "dbPreExists") <- TRUE
   conn
 }, 
 valueClass="MonetDBConnection")
@@ -352,7 +359,6 @@ setMethod("dbSendQuery", signature(conn=
     env$conn <- conn
     env$query <- statement
     env$info <- resp
-
   }
   if (resp$type == MSG_MESSAGE) {
     env$success = FALSE
@@ -575,7 +581,7 @@ setClass("MonetDBEmbeddedResult", repres
 .CT_RAW <- 5L
 
 # type mapping matrix
-monetTypes <- rep(c("integer", "numeric", "character", "character", "logical", 
"raw"), c(6, 5, 4, 6, 1, 1))
+monetTypes <- rep(c("integer", "numeric", "character", "character", "logical", 
"raw"), c(5, 6, 4, 6, 1, 1))
 names(monetTypes) <- c(c("WRD", "TINYINT", "SMALLINT", "INT", 
"MONTH_INTERVAL"), # month_interval is the diff between date cols, int
   c("BIGINT", "HUGEINT", "REAL", "DOUBLE", "DECIMAL", "SEC_INTERVAL"),  # 
sec_interval is the difference between timestamps, float
   c("CHAR", "VARCHAR", "CLOB", "STR"), 
@@ -606,9 +612,13 @@ setMethod("dbFetch", signature(res="Mone
   if (!dbIsValid(res)) {
     stop("Cannot fetch results from closed response.")
   }
-  
+ 
   # okay, so we arrive here with the tuples from the first result in 
res@env$data as a list
   info <- res@env$info
+  # apparently, one should be able to fetch results sets from ddl ops
+  if (info$type == Q_UPDATE) { 
+    return(data.frame())
+  }
   if (res@env$delivered < 0) {
     res@env$delivered <- 0
   }
diff --git a/clients/R/MonetDB.R/R/mapi.R b/clients/R/MonetDB.R/R/mapi.R
--- a/clients/R/MonetDB.R/R/mapi.R
+++ b/clients/R/MonetDB.R/R/mapi.R
@@ -224,7 +224,7 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
       
       env$type <- Q_UPDATE
       env$id           <- header$id
-      
+      env$rows  <- 0
       return(env)                      
     }
     
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to