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

R Connector: Fix for empty result set and fix for prompt-only responses


diffs (80 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
@@ -5,6 +5,8 @@ 0.9.8
 - dbWriteTable now quotes table/column names if necessary, and outputs 
warnings if it did
 - New mdbapply function to automatically create and run embedded R functions 
in MonetDB
 - Fixes for dplyr backend
+- Fix for case when query only returns a prompt (CALL ..., Thanks, Roman)
+- Fix for empty result set on dbGetQuery(), no longer returning NULL (Thanks, 
Fabian)
 
 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
@@ -220,8 +220,7 @@ setMethod("dbReadTable", "MonetDBConnect
 
 # This one does all the work in this class
 setMethod("dbSendQuery", signature(conn="MonetDBConnection", 
statement="character"),  
-          def=function(conn, statement, ..., list=NULL, async=FALSE) {
-            
+          def=function(conn, statement, ..., list=NULL, async=FALSE) {   
   if(!is.null(list) || length(list(...))){
     if (length(list(...))) statement <- .bindParameters(statement, list(...))
     if (!is.null(list)) statement <- .bindParameters(statement, list)
@@ -245,11 +244,11 @@ setMethod("dbSendQuery", signature(conn=
     env$data <- resp$tuples
     resp$tuples <- NULL # clean up
     env$info <- resp
-    env$delivered <- 0
+    env$delivered <- -1
     env$query <- statement
     env$open <- TRUE
   }
-  if (resp$type == Q_UPDATE || resp$type == Q_CREATE || resp$type == 
MSG_ASYNC_REPLY) {
+  if (resp$type == Q_UPDATE || resp$type == Q_CREATE || resp$type == 
MSG_ASYNC_REPLY || resp$type == MSG_PROMPT) {
     env$success = TRUE
     env$conn <- conn
     env$query <- statement
@@ -483,6 +482,9 @@ setMethod("dbFetch", signature(res="Mone
   
   # okay, so we arrive here with the tuples from the first result in 
res@env$data as a list
   info <- res@env$info
+  if (res@env$delivered < 0) {
+    res@env$delivered <- 0
+  }
   stopifnot(res@env$delivered <= info$rows, info$index <= info$rows)
   remaining <- info$rows - res@env$delivered
     
@@ -523,7 +525,7 @@ setMethod("dbFetch", signature(res="Mone
   
   # we have delivered everything, return empty df (spec is not clear on this 
one...)
   if (n < 1) {
-    return(data.frame(df))
+    return(data.frame(df, stringsAsFactors=F))
   }
   
   # if our tuple cache in res@env$data does not contain n rows, we fetch from 
server until it does
@@ -576,7 +578,6 @@ setMethod("dbFetch", signature(res="Mone
   class(df) <- "data.frame"
   
   # if (getOption("monetdb.profile", T))  .profiler_clear()
-
   df
 })
 
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
@@ -159,7 +159,9 @@ REPLY_SIZE    <- 100 # Apparently, -1 me
 
 # determines and partially parses the answer from the server in response to a 
query
 .mapiParseResponse <- function(response) {
-  #lines <- .Call("mapiSplitLines", response, PACKAGE="MonetDB.R")
+  if (response == MSG_PROMPT) { # prompt
+    return(list(type = MSG_PROMPT))
+  }
   lines <- strsplit(response, "\n", fixed=TRUE, useBytes=TRUE)[[1]]
   if (length(lines) < 1) {
     stop("Invalid response from server. Try re-connecting.")
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to