Changeset: 24ecd74d3d62 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=24ecd74d3d62 Added Files: clients/R/Tests/copy_into_fwf.R clients/R/Tests/copy_into_fwf.reqtests Modified Files: clients/R/Tests/All clients/R/Tests/deps-test.R common/stream/stream.c Branch: fixed-width-format Log Message:
Test case diffs (76 lines): diff --git a/clients/R/Tests/All b/clients/R/Tests/All --- a/clients/R/Tests/All +++ b/clients/R/Tests/All @@ -4,4 +4,5 @@ HAVE_LIBR?deps-test HAVE_LIBR?dbi HAVE_LIBR?dplyr HAVE_LIBR?dplyr-flights +HAVE_LIBR?copy_into_fwf HAVE_LIBR&NOT_WIN32?dbapply diff --git a/clients/R/Tests/copy_into_fwf.R b/clients/R/Tests/copy_into_fwf.R new file mode 100644 --- /dev/null +++ b/clients/R/Tests/copy_into_fwf.R @@ -0,0 +1,34 @@ +if (Sys.getenv("TSTTRGDIR") != "") { + .libPaths(c(.libPaths(), paste0(Sys.getenv("TSTTRGDIR"),"/rlibdir"))) +} +library(DBI, quietly = T) + +args <- commandArgs(trailingOnly = TRUE) +dbport <- 50000 +dbname <- "mTests_clients_R" +if (length(args) > 0) + dbport <- args[[1]] +if (length(args) > 1) + dbname <- args[[2]] + +con <- dbConnect(MonetDBLite::MonetDB(), port = dbport, dbname = dbname, wait = T) +stopifnot(dbIsValid(con)) + +tf <- tempfile() + +gdata::write.fwf(mtcars, tf, colnames = FALSE) + +if (dbExistsTable(con, "mtcars")) dbRemoveTable(con, "mtcars") + +dbBegin(con) +dbSendQuery(con, "CREATE TABLE mtcars (mpg DOUBLE PRECISION, cyl DOUBLE PRECISION, disp DOUBLE PRECISION, hp DOUBLE PRECISION, drat DOUBLE PRECISION, wt DOUBLE PRECISION, qsec DOUBLE PRECISION, vs DOUBLE PRECISION, am DOUBLE PRECISION, gear DOUBLE PRECISION, carb DOUBLE PRECISION)") + +dbSendQuery(con, paste0("COPY INTO mtcars FROM '", tf, "' FWF (4, 2, 6, 4, 5, 6, 6, 2, 2, 2, 2)")) + +print(dbReadTable(con, "mtcars")) + +stopifnot(nrow(dbReadTable(con, "mtcars")) < 1) + +dbRollback(con) + +print("SUCCESS") diff --git a/clients/R/Tests/copy_into_fwf.reqtests b/clients/R/Tests/copy_into_fwf.reqtests new file mode 100644 --- /dev/null +++ b/clients/R/Tests/copy_into_fwf.reqtests @@ -0,0 +1,1 @@ +dbi diff --git a/clients/R/Tests/deps-test.R b/clients/R/Tests/deps-test.R --- a/clients/R/Tests/deps-test.R +++ b/clients/R/Tests/deps-test.R @@ -4,5 +4,5 @@ dd <- capture.output(suppressMessages(su repos <- 'http://cran.rstudio.com/' if(length(np)) install.packages(np, repos=repos, quiet=T) update.packages(repos=repos, ask=F, oldPkgs=lp, quiet=T) - })(c('Rcpp', 'dplyr', 'Lahman', 'nycflights13')) + })(c('Rcpp', 'dplyr', 'Lahman', 'nycflights13', 'gdata')) }))) diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -4791,7 +4791,7 @@ stream_fwf_create (stream *s, size_t num free(fsd); return NULL; } - out_buf_len = fsd->line_len * 2; // TODO: what if this is not enough? + out_buf_len = fsd->line_len * 3; fsd->out_buf = malloc(out_buf_len); if (!fsd->out_buf) { free(fsd->in_buf); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list