Changeset: 1aca47696041 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1aca47696041 Added Files: sql/test/BugTracker-2015/Tests/nil_cast.Bug-3787.sql sql/test/BugTracker-2015/Tests/nil_cast.Bug-3787.stable.err sql/test/BugTracker-2015/Tests/nil_cast.Bug-3787.stable.out sql/test/BugTracker-2015/Tests/useless_casts.Bug-3756.stable.out.single 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/R/MonetDB.R/NAMESPACE 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/stethoscope.c clients/mapiclient/tachograph.c clients/mapiclient/tomograph.c clients/mapilib/mapi.rc clients/odbc/driver/driver.rc clients/odbc/winsetup/setup.rc clients/python2/setup.py clients/python3/setup.py configure.ag debian/changelog debian/control debian/libmonetdb-client-odbc.postinst debian/monetdb5-sql.install gdk/ChangeLog gdk/gdk.h gdk/gdk_calc.c gdk/gdk_group.c gdk/gdk_join.c gdk/gdk_logger.c gdk/gdk_private.h gdk/gdk_select.c gdk/gdk_setop.c gdk/gdk_system_private.h gdk/gdk_unique.c gdk/libbat.rc java/ChangeLog-Archive java/Makefile.ag java/build.properties java/pom.xml java/release.txt libversions monetdb5/ChangeLog monetdb5/modules/kernel/algebra.c monetdb5/modules/kernel/algebra.h monetdb5/modules/kernel/algebra.mal monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_prelude.h monetdb5/tests/mapi/Tests/All monetdb5/tools/libmonetdb5.rc sql/ChangeLog-Archive sql/ChangeLog.Jul2015 sql/backends/monet5/Tests/rapi13.stable.out sql/backends/monet5/generator/Tests/generator03.stable.out sql/backends/monet5/rel_bin.c sql/backends/monet5/sql_result.c sql/backends/monet5/sql_scenario.c sql/backends/monet5/sql_statement.c 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/server/rel_optimizer.c sql/server/rel_select.c sql/storage/bat/bat_utils.c sql/storage/bat/bat_utils.h sql/test/BugDay_2005-10-06_2.9.3/Tests/cast_to_interval.SF-1019079.stable.out sql/test/BugDay_2005-10-06_2.9.3/Tests/error_in_sql_parser.SF-1019122.stable.out sql/test/BugDay_2005-10-06_2.9.3/Tests/set_types.SF-932360.stable.out sql/test/BugDay_2005-11-09_2.9.3/Tests/date_functions.SF-967145.stable.out sql/test/BugDay_2005-11-09_2.9.3/Tests/interval_on_time_stamp.SF-1080488.stable.out sql/test/BugDay_2005-12-19_2.9.3/Tests/cast_interval.SF.1280682.stable.out sql/test/BugDay_2005-12-19_2.9.3/Tests/interval_times_int.SF-1281996.stable.out sql/test/BugTracker-2011/Tests/default-interval.Bug-2877.stable.out sql/test/BugTracker-2011/Tests/time_precision.Bug-2873.stable.out sql/test/BugTracker-2012/Tests/incorrect_cast_from_double_to_int.Bug-2579.stable.out sql/test/BugTracker-2012/Tests/now_results_in_illegal_argument.Bug-2978.stable.out sql/test/BugTracker-2012/Tests/timestamp-diff.Bug-3190.stable.out sql/test/BugTracker-2014/Tests/current_timestamp.Bug-3427.stable.out sql/test/BugTracker-2014/Tests/nil_2dec_lng.Bug-3592.stable.out sql/test/BugTracker-2014/Tests/nil_2dec_lng.Bug-3592.stable.out.single sql/test/BugTracker-2015/Tests/All sql/test/BugTracker-2015/Tests/div_zero.Bug-3742.stable.out sql/test/BugTracker-2015/Tests/sum_interval.Bug-3785.stable.out sql/test/BugTracker/Tests/cast_interval2time.SF-1488247.stable.out sql/test/Tests/timezone.stable.out sql/test/VOC/Tests/median.Bug-3096.stable.out sql/test/bugs/Tests/default_with_cast.SF-1334486.stable.out sql/test/bugs/Tests/interval_convert_bugs-sf-1274077-1274085.stable.out sql/test/bugs/Tests/interval_parse_bug-sf-1263967.stable.out 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/pg_regress/Tests/alter_table.stable.out sql/test/pg_regress/Tests/date.stable.out sql/test/pg_regress/Tests/horology.stable.out sql/test/pg_regress/Tests/interval.stable.out sql/test/pg_regress/Tests/interval.stable.out.int128 sql/test/pg_regress/Tests/reltime.stable.out sql/test/pg_regress/Tests/time.stable.out sql/test/pg_regress/Tests/timestamp.stable.out sql/test/pg_regress/Tests/timestamptz.stable.out sql/test/pg_regress/Tests/timetz.stable.out sql/test/snodgrass/Tests/cast_select.stable.out sql/test/snodgrass/Tests/interval_parsing.stable.out sql/test/testdb-upgrade-chain/Tests/package.py sql/test/testdb/Tests/testdb-package.py vertoo.data Branch: DataVaults Log Message:
Merge with default branch Resolve conflicts in rel_optimizer.c diffs (truncated from 5106 to 300 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -600,3 +600,9 @@ a1a48562a4651b1beb3168290777cbeb91f474d8 71a9c48c90348eab78069f2ecc616e3f73bbba95 Jul2015_root 77c8f3354e948ccd094ab3e53631b9fe272da8ea Jul2015_1 77c8f3354e948ccd094ab3e53631b9fe272da8ea Jul2015_release +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 @@ -659,6 +659,7 @@ fi %exclude %{_libdir}/monetdb5/sql*.mal %if %{bits} == 64 %exclude %{_libdir}/monetdb5/*_hge.mal +%exclude %{_libdir}/monetdb5/autoload/*_hge.mal %endif %{_libdir}/monetdb5/*.mal %if %{?with_geos:1}%{!?with_geos:0} @@ -995,6 +996,32 @@ 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 +- BZ#3440: Sequence type errors +- BZ#3449: mserver crash on start - Freebsd 10 amd64 +- BZ#3496: autocompletion table names does not work correctly +- BZ#3758: "COPY INTO ..." doesn't work, if executing from 2 processes + concurrently. +- BZ#3763: JDBC PreparedStatement for a table with 14 Foreign Keys + crashing the Database +- BZ#3783: Behavioural change in Jul2015 for 'timestamp minus timestamp' +- BZ#3784: Assertion failed: (bn->batCapacity >= cnt), function + BAT_scanselect, file gdk_select.c, line 1008. +- BZ#3785: sum(interval) causes overflow in conversion to bte +- BZ#3786: ResultSet.close() never sends Xclose to free resources +- BZ#3787: "b and g must be aligned" from complex group/union query +- BZ#3791: HEAPextend: failed to extend to 2420077101056 + +* Tue Aug 18 2015 Sjoerd Mullender <sjo...@acm.org> - 11.21.3-20150818 +- sql: Differences between time, timestamp, and date values now return properly + typed interval types (second or month intervals) instead of integers. + * Fri Aug 07 2015 Sjoerd Mullender <sjo...@acm.org> - 11.21.1-20150807 - Rebuilt. - BZ#3364: Cannot set role back to a user's default role @@ -1063,7 +1090,7 @@ rm -f %{buildroot}%{_bindir}/Maddlog - java: Improved JDBC driver to not throw NullPointerException anymore when calling isNullable() or getPrecision() or getScale() or getColumnDisplaySize() or getSchemaName() or getTableName() or - getColumnClassName() on a ResultSet object. + getColumnClassName() on a ResultSetMetaData object. * Tue Jul 28 2015 Sjoerd Mullender <sjo...@acm.org> - 11.21.1-20150807 - sql: Added support for 128-bit integers (called HUGEINT) on platforms that diff --git a/clients/R/MonetDB.R/NAMESPACE b/clients/R/MonetDB.R/NAMESPACE --- a/clients/R/MonetDB.R/NAMESPACE +++ b/clients/R/MonetDB.R/NAMESPACE @@ -1,4 +1,4 @@ -import(DBI,digest,methods,codetools) +import(DBI,digest,methods,codetools,utils) # export only driver constructor, everything else is DBI stuff.. export(MonetDB,MonetR,MonetDBR,MonetDB.R) 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,6 +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 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,17 +280,15 @@ 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]) @@ -315,7 +310,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 +361,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 +618,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, ...){ + 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 +628,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,8 +637,22 @@ 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") } - - if (create) dbWriteTable(conn, tablename, headers[[1]][FALSE, ]) + tablename <- quoteIfNeeded(conn, tablename) + if (create){ + 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, "'") @@ -659,6 +670,6 @@ monet.read.csv <- monetdb.read.csv <- fu 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 @@ -9,16 +9,16 @@ Instruct MonetDB to read a CSV file, optionally also create the table for it. } \usage{ - monetdb.read.csv (conn, files, tablename, nrows, header=TRUE, + monetdb.read.csv (conn, files, tablename, nrows=NA, header=TRUE, locked=FALSE, na.strings="", nrow.check=500, delim=",", - newline = "\\\\n", quote = "\"", create=TRUE, ...) + 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.} @@ -30,6 +30,8 @@ \item{newline}{Newline in CSV file, usually \\n for UNIX-like systems and \\r\\r on Windows.} \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{ @@ -47,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))) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list