Changeset: 2fe0b22cc3fb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2fe0b22cc3fb
Modified Files:
clients/R/MonetDB.R/R/dbi.R
Branch: Jul2015
Log Message:
Encode strings (i.e. call encodeString on them) that are given to SQL as file
names.
This will double backslashes so that COPY INTO works on Windows.
diffs (29 lines):
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
@@ -336,7 +336,7 @@ setMethod("dbWriteTable", "MonetDBConnec
tmp <- tempfile(fileext = ".csv")
write.table(value, tmp, sep = ",", quote = TRUE, row.names = FALSE,
col.names = FALSE,na="")
dbSendQuery(conn, paste0("COPY ",format(nrow(value), scientific=FALSE),"
RECORDS INTO ", qname,
- " FROM '", tmp, "' USING DELIMITERS ',','\\n','\"' NULL AS ''"))
+ " FROM '", encodeString(tmp), "' USING DELIMITERS ',','\\n','\"' NULL AS
''"))
file.remove(tmp)
} else {
vins <- paste("(", paste(rep("?", length(value)), collapse=', '), ")",
sep='')
@@ -651,14 +651,14 @@ monet.read.csv <- monetdb.read.csv <- fu
if(header){
for(i in seq_along(files)) {
- thefile <- normalizePath(files[i])
+ thefile <- encodeString(normalizePath(files[i]))
dbSendUpdate(conn, paste("COPY OFFSET 2 INTO",
tablename, "FROM", paste("'", thefile, "'", sep=""), delimspec, "NULL
as", paste("'",
na.strings[1], "'", sep=""), if(locked) "LOCKED"))
}
} else {
for(i in seq_along(files)) {
- thefile <- normalizePath(files[i])
+ thefile <- encodeString(normalizePath(files[i]))
dbSendUpdate(conn, paste0("COPY INTO ", tablename, " FROM ", paste("'",
thefile, "'", sep=""),
delimspec, "NULL as ", paste("'", na.strings[1], "'", sep=""),
if(locked) " LOCKED "))
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list