Changeset: fdb5b3950889 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fdb5b3950889
Added Files:
        sql/test/copy/Tests/incorrect_columns.sql
        sql/test/copy/Tests/incorrect_columns.stable.err
        sql/test/copy/Tests/incorrect_columns.stable.out
Removed Files:
        monetdb5/tests/mapi/Tests/smack01-slow.MAL.bat
        monetdb5/tests/mapi/Tests/smack01-slow.MAL.sh
        monetdb5/tests/mapi/Tests/smack01-slow.stable.err
        monetdb5/tests/mapi/Tests/smack01-slow.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/ChangeLog.Jul2015
        clients/R/MonetDB.R/NEWS
        clients/R/MonetDB.R/R/dbi.R
        clients/R/MonetDB.R/man/monetdb.read.csv.Rd
        clients/R/Tests/dbi.R
        clients/R/Tests/dbi.stable.err
        clients/R/Tests/dbi.stable.out
        clients/R/Tests/dplyr-flights.stable.err
        clients/R/Tests/dplyr.stable.err
        clients/R/build-for-cran.sh
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        clients/mapiclient/mclient.1
        clients/mapiclient/mclient.c
        clients/mapilib/mapi.c
        clients/mapilib/mapi.h
        clients/mapilib/mapi.rc
        clients/odbc/driver/SQLDriverConnect.c
        clients/odbc/driver/driver.rc
        clients/odbc/winsetup/setup.rc
        clients/python2/setup.py
        clients/python3/setup.py
        configure.ag
        debian/changelog
        gdk/gdk_calc.c
        gdk/gdk_heap.c
        gdk/gdk_join.c
        gdk/gdk_logger.c
        gdk/libbat.rc
        libversions
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_resource.c
        monetdb5/mal/mal_utils.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/str.h
        monetdb5/modules/atoms/str.mal
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/algebra.h
        monetdb5/modules/kernel/algebra.mal
        monetdb5/modules/mal/tablet.c
        monetdb5/tests/mapi/Tests/All
        monetdb5/tools/libmonetdb5.rc
        sql/backends/monet5/sql_result.c
        sql/benchmarks/nobench/Tests/nobench.sql
        sql/benchmarks/nobench/Tests/nobench.stable.err
        sql/benchmarks/nobench/Tests/nobench.stable.out
        sql/benchmarks/tpch/LOCKED/Tests/01-22.stable.out
        sql/benchmarks/tpch/LOCKED/Tests/14.stable.out
        sql/benchmarks/tpch/Tests/08-explain.stable.out
        sql/benchmarks/tpch/Tests/17-explain.stable.out
        sql/benchmarks/tpch/Tests/20-explain.stable.out
        sql/benchmarks/tpch/Tests/20-explain.stable.out.32bit
        sql/test/Users/Tests/dropManyUsers.Bug-3764.stable.out
        sql/test/copy/Tests/All
        sql/test/copy/Tests/key_copy.sql
        sql/test/copy/Tests/key_copy.stable.err
        sql/test/leaks/Tests/check0.stable.out.int128
        sql/test/leaks/Tests/check1.stable.out.int128
        sql/test/leaks/Tests/check2.stable.out.int128
        sql/test/leaks/Tests/check3.stable.out.int128
        sql/test/leaks/Tests/check4.stable.out.int128
        sql/test/leaks/Tests/check5.stable.out.int128
        sql/test/leaks/Tests/drop3.stable.out.int128
        sql/test/leaks/Tests/select1.stable.out.int128
        sql/test/leaks/Tests/select2.stable.out.int128
        sql/test/leaks/Tests/temp1.stable.out.int128
        sql/test/leaks/Tests/temp2.stable.out.int128
        sql/test/leaks/Tests/temp3.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/package.py
        sql/test/testdb/Tests/testdb-package.py
        vertoo.data
Branch: leftmart
Log Message:

Sync with default


diffs (truncated from 3237 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -602,3 +602,6 @@ 77c8f3354e948ccd094ab3e53631b9fe272da8ea
 30be7bd4aec0b5daf3d2f3a26a1043c04b88bb6d Jul2015_3
 77c8f3354e948ccd094ab3e53631b9fe272da8ea Jul2015_release
 30be7bd4aec0b5daf3d2f3a26a1043c04b88bb6d Jul2015_release
+c7c0a76e663e34bcddae683b385c8e5a919ffd84 Jul2015_5
+30be7bd4aec0b5daf3d2f3a26a1043c04b88bb6d Jul2015_release
+c7c0a76e663e34bcddae683b385c8e5a919ffd84 Jul2015_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -996,6 +996,10 @@ rm -f %{buildroot}%{_bindir}/Maddlog
 %postun -p /sbin/ldconfig
 
 %changelog
+* Mon Aug 24 2015 Sjoerd Mullender <sjo...@acm.org> - 11.21.5-20150824
+- Rebuilt.
+- BZ#3730: SAMPLE function not sampling randomly
+
 * Tue Aug 18 2015 Sjoerd Mullender <sjo...@acm.org> - 11.21.3-20150818
 - Rebuilt.
 - BZ#3361: constants as MAL function parameters prevent intermediate reuse
diff --git a/clients/ChangeLog.Jul2015 b/clients/ChangeLog.Jul2015
--- a/clients/ChangeLog.Jul2015
+++ b/clients/ChangeLog.Jul2015
@@ -1,3 +1,7 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Sun Aug 30 2015 Sjoerd Mullender <sjo...@acm.org>
+- In the SQL formatter of mclient (the default) we now properly align
+  East Asian wide characters.
+
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
@@ -8,7 +8,10 @@ 1.0.0
 - 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)
 - Fix for dbConnect(), it ignored the url parameter somehow, which broke some 
sqlsurvey (Thanks, Anthony)
-- Added lower.case.names= to monet.read.csv() in case users want to avoid 
quoting
+- Added col.names argument to monet.read.csv()
+- 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.
 
 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
@@ -103,7 +103,7 @@ setMethod("dbConnect", "MonetDBDriver", 
         break
       }, error = function(e) {
         if ("connection" %in% class(socket)) {
-          close(socket)
+          tryCatch(close(socket), error=function(e){}) 
         }
         message("Server not ready(", e$message, "), retrying (ESC or CTRL+C to 
abort)")
         Sys.sleep(1)
@@ -153,18 +153,14 @@ setMethod("dbDisconnect", "MonetDBConnec
   return(invisible(TRUE))
 })
 
-setMethod("dbListTables", "MonetDBConnection", def=function(conn, ..., 
sys_tables=F, schema_names=F, quote=F) {
+setMethod("dbListTables", "MonetDBConnection", def=function(conn, ..., 
sys_tables=F, schema_names=F) {
   q <- "select schemas.name as sn, tables.name as tn from sys.tables join 
sys.schemas on tables.schema_id=schemas.id"
   if (!sys_tables) q <- paste0(q, " where tables.system=false")
   df <- dbGetQuery(conn, q)
-  if (quote) {
-    df$tn <- paste0("\"", df$tn, "\"")
-  }
+    df$tn <- quoteIfNeeded(conn, df$tn, warn=F)
   res <- df$tn
   if (schema_names) {
-    if (quote) {
-      df$sn <- paste0("\"", df$sn, "\"")
-    }
+    df$sn <- quoteIfNeeded(conn, df$sn, warn=F)
     res <- paste0(df$sn, ".", df$tn)
   }
   return(as.character(res))
@@ -203,9 +199,9 @@ setMethod("dbListFields", "MonetDBConnec
 })
 
 setMethod("dbExistsTable", "MonetDBConnection", def=function(conn, name, ...) {
-  # TODO: this is evil... 
-  return(tolower(gsub("(^\"|\"$)","",as.character(name))) %in% 
-    tolower(dbListTables(conn, sys_tables=T)))
+  name <- quoteIfNeeded(conn, name)
+  return(as.character(name) %in% 
+    dbListTables(conn, sys_tables=T))
 })
 
 setMethod("dbGetException", "MonetDBConnection", def=function(conn, ...) {
@@ -213,6 +209,7 @@ setMethod("dbGetException", "MonetDBConn
 })
 
 setMethod("dbReadTable", "MonetDBConnection", def=function(conn, name, ...) {
+  name <- quoteIfNeeded(conn, name)
   if (!dbExistsTable(conn, name))
     stop(paste0("Unknown table: ", name));
   dbGetQuery(conn, paste0("SELECT * FROM ", name))
@@ -283,20 +280,20 @@ setMethod("dbSendQuery", signature(conn=
   invisible(new("MonetDBResult", env=env))
   })
 
-
-
 # quoting
-quoteIfNeeded <- function(conn, x, ...) {
-  chars <- !grepl("^[a-z][a-z0-9_]*$", x, perl=T) & !grepl("^\"[^\"]*\"$", x, 
perl=T)
-  if (any(chars)) {
-    message("Identifier(s) ", paste(x[chars], collapse=", "), " contain 
uppercase or reserved SQL characters and need(s) to be quoted in queries.")
+quoteIfNeeded <- function(conn, x, warn=T, ...) {
+  chars <- !grepl("^[a-z_][a-z0-9_]*$", x, perl=T) & !grepl("^\"[^\"]*\"$", x, 
perl=T)
+  if (any(chars) && warn) {
+    message("Identifier(s) ", paste("\"", x[chars],"\"", collapse=", ", 
sep=""), " contain uppercase or reserved SQL characters and need(s) to be 
quoted in queries.")
   }
   reserved <- toupper(x) %in% .SQL92Keywords
-  if (any(reserved)) {
-    message("Identifier(s) ", paste(x[reserved], collapse=", "), " are 
reserved SQL keywords and need(s) to be quoted in queries.")
+  if (any(reserved) && warn) {
+    message("Identifier(s) ", paste("\"", x[reserved],"\"", collapse=", ", 
sep=""), " are reserved SQL keywords and need(s) to be quoted in queries.")
   }
   qts <- reserved | chars
-  x[qts] <- dbQuoteIdentifier(conn, x[qts])
+  if (any(qts)) {
+    x[qts] <- dbQuoteIdentifier(conn, x[qts])
+  }
   x
 }
 
@@ -315,7 +312,7 @@ setMethod("dbWriteTable", "MonetDBConnec
     if (!is.data.frame(value)) value <- as.data.frame(value)
   }
   if (overwrite && append) {
-    stop("Setting both overwrite and append to true makes no sense.")
+    stop("Setting both overwrite and append to TRUE makes no sense.")
   }
 
   qname <- quoteIfNeeded(conn, name)
@@ -366,8 +363,9 @@ setMethod("dbDataType", signature(dbObj=
 
 
 setMethod("dbRemoveTable", "MonetDBConnection", def=function(conn, name, ...) {
+  name <- quoteIfNeeded(conn, name)
   if (dbExistsTable(conn, name)) {
-    dbSendUpdate(conn, paste("DROP TABLE", tolower(name)))
+    dbSendUpdate(conn, paste("DROP TABLE", name))
     return(invisible(TRUE))
   }
   return(invisible(FALSE))
@@ -622,7 +620,8 @@ setMethod("dbGetInfo", "MonetDBResult", 
 # adapted from RMonetDB, no java-specific things in here...
 monet.read.csv <- monetdb.read.csv <- function(conn, files, tablename, 
nrows=NA, header=TRUE, 
                                                locked=FALSE, na.strings="", 
nrow.check=500, 
-                                               delim=",", newline="\\n", 
quote="\"", create=TRUE, lower.case.names=FALSE, ...){
+                                               delim=",", newline="\\n", 
quote="\"", create=TRUE, 
+                                               col.names=NULL, 
lower.case.names=FALSE, ...){
   
   if (length(na.strings)>1) stop("na.strings must be of length 1")
   headers <- lapply(files, utils::read.csv, sep=delim, na.strings=na.strings, 
quote=quote, nrows=nrow.check, 
@@ -631,7 +630,7 @@ monet.read.csv <- monetdb.read.csv <- fu
   if (!missing(nrows)) {
     warning("monetdb.read.csv(): nrows parameter is not neccessary any more 
and deprecated.")
   }
-  
+
   if (length(files)>1){
     nn <- sapply(headers, ncol)
     if (!all(nn==nn[1])) stop("Files have different numbers of columns")
@@ -640,29 +639,31 @@ monet.read.csv <- monetdb.read.csv <- fu
     types <- sapply(headers, function(df) sapply(df, dbDataType, dbObj=conn))
     if(!all(types==types[, 1])) stop("Files have different variable types")
   } 
-  
+  tablename <- quoteIfNeeded(conn, tablename)
   if (create){
-    if(lower.case.names) names(headers[[1]]) <- tolower(names( headers[[1]]))
+    if(lower.case.names) names(headers[[1]]) <- tolower(names(headers[[1]]))
+    if(!is.null(col.names)) {
+      if (lower.case.names) {
+        warning("Ignoring lower.case.names parameter as overriding col.names 
are supplied.")
+      }
+      col.names <- as.character(col.names)
+      if (length(unique(col.names)) != length(names(headers[[1]]))) {
+        stop("You supplied ", length(unique(col.names)), " unique column 
names, but file has ", 
+          length(names(headers[[1]])), " columns.")
+      }
+      names(headers[[1]]) <- quoteIfNeeded(conn, col.names)
+    }
     dbWriteTable(conn, tablename, headers[[1]][FALSE, ])
-
   }
   
   delimspec <- paste0("USING DELIMITERS '", delim, "','", newline, "','", 
quote, "'")
   
-  if(header){
-    for(i in seq_along(files)) {
-      thefile <- 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])
-      dbSendUpdate(conn, paste0("COPY INTO ", tablename, " FROM ", paste("'", 
thefile, "'", sep=""), 
-        delimspec, "NULL as ", paste("'", na.strings[1], "'", sep=""), 
if(locked) " LOCKED "))
-    }
+  for(i in seq_along(files)) {
+    thefile <- normalizePath(files[i])
+    dbSendUpdate(conn, paste("COPY", if(header) "OFFSET 2", "INTO", 
+      tablename, "FROM", paste("'", thefile, "'", sep=""), delimspec, "NULL 
as", paste("'", 
+      na.strings[1], "'", sep=""), if(locked) "LOCKED"))
   }
-  dbGetQuery(conn, paste("select count(*) from", tablename))
+  dbGetQuery(conn, paste("SELECT COUNT(*) FROM", tablename))[[1]]
 }
 
diff --git a/clients/R/MonetDB.R/man/monetdb.read.csv.Rd 
b/clients/R/MonetDB.R/man/monetdb.read.csv.Rd
--- a/clients/R/MonetDB.R/man/monetdb.read.csv.Rd
+++ b/clients/R/MonetDB.R/man/monetdb.read.csv.Rd
@@ -11,14 +11,14 @@
 \usage{
    monetdb.read.csv (conn, files, tablename, nrows=NA, header=TRUE, 
   locked=FALSE, na.strings="", nrow.check=500, delim=",",
-  newline = "\\\\n", quote = "\"", create=TRUE, lower.case.names=FALSE, ...)
+  newline = "\\\\n", quote = "\"", create=TRUE, col.names=NULL, 
lower.case.names=FALSE, ...)
 }
 \arguments{
   \item{conn}{A MonetDB.R database connection. Created using 
\code{\link[DBI]{dbConnect}} with the 
   \code{\link[MonetDB.R]{MonetDB.R}} database driver.}
    \item{files}{A single string or a vector of strings containing the absolute 
file names of the CSV files to be imported.}
    \item{tablename}{Name of the database table the CSV files should be 
imported in. Created if necessary.}
-   \item{nrows}{Total number of rows to import. Can be an upper bound.}
+   \item{nrows}{Total number of rows to import (deprecated).}
    \item{header}{Whether or not the CSV files contain a header line.}
    \item{locked}{Whether or not to disable transactions for import. 
    Setting this to TRUE can greatly improve the import performance.}
@@ -31,6 +31,7 @@
    \item{quote}{Quote character(s) in CSV file.}
   \item{create}{Create table before importing?}
   \item{lower.case.names}{Convert all column names to lowercase in the 
database?}
+  \item{col.names}{Optional column names in case the ones from CSV file should 
not be used}
  }
  
 \value{
@@ -48,6 +49,6 @@ data(iris)
 file <- tempfile()
 write.table(iris, file, sep=",")
 # create table and import CSV
-monetdb.read.csv(conn, file, "iris", 150)
+monetdb.read.csv(conn, file, "iris")
 }}
 \keyword{interface}
diff --git a/clients/R/Tests/dbi.R b/clients/R/Tests/dbi.R
--- a/clients/R/Tests/dbi.R
+++ b/clients/R/Tests/dbi.R
@@ -92,13 +92,23 @@ stopifnot(identical(dbExistsTable(con,tn
 # test csv import
 file <- tempfile()
 write.table(iris,file,sep=",")
+tname2 <- "Need to quote this table name"
 monetdb.read.csv(con,file,tname)
+monetdb.read.csv(con,file,tname2)
+###
+dbListTables(con)
+
 unlink(file)
 stopifnot(identical(dbExistsTable(con,tname),TRUE))
+stopifnot(identical(dbExistsTable(con,tname2),TRUE))
 iris3 <- dbReadTable(con,tname)
+iris4 <- dbReadTable(con,tname2)
 stopifnot(identical(dim(iris),dim(iris3)))
+stopifnot(identical(dim(iris),dim(iris4)))
 stopifnot(identical(dbListFields(con,tname),names(iris)))
+stopifnot(identical(dbListFields(con,tname2),names(iris)))
 dbRemoveTable(con,tname)
+dbRemoveTable(con,tname2)
 stopifnot(identical(dbExistsTable(con,tname),FALSE))
 
 # test dbWriteTable
diff --git a/clients/R/Tests/dbi.stable.err b/clients/R/Tests/dbi.stable.err
--- a/clients/R/Tests/dbi.stable.err
+++ b/clients/R/Tests/dbi.stable.err
@@ -30,12 +30,18 @@ stderr of test 'dbi` in directory 'clien
 # 12:27:25 >  "R" "--vanilla" "--slave" "--args" "31728"
 # 12:27:25 >  
 
-Identifier(s) Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species 
contain uppercase or reserved SQL characters and need(s) to be quoted in 
queries.
-Identifier(s) Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species 
contain uppercase or reserved SQL characters and need(s) to be quoted in 
queries.
-Identifier(s) some.dot contain uppercase or reserved SQL characters and 
need(s) to be quoted in queries.
-Identifier(s) year, month, day are reserved SQL keywords and need(s) to be 
quoted in queries.
-Identifier(s) sch.wide, comp.imp, yr.rnd, acs.k3, acs.46, acs.core, pct.resp, 
not.hsg, some.col, col.grad, grad.sch, avg.ed, api.stu contain uppercase or 
reserved SQL characters and need(s) to be quoted in queries.
-Identifier(s) full are reserved SQL keywords and need(s) to be quoted in 
queries.
+Identifier(s) "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", 
"Species" contain uppercase or reserved SQL characters and need(s) to be quoted 
in queries.
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to