Skip to content

Commit

Permalink
version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored and cran-robot committed Apr 6, 2018
1 parent 89486dd commit cbaefde
Show file tree
Hide file tree
Showing 37 changed files with 744 additions and 361 deletions.
42 changes: 20 additions & 22 deletions DESCRIPTION
@@ -1,46 +1,44 @@
Encoding: UTF-8
Package: RPostgres
Version: 1.0-4
Date: 2017-12-20
Title: 'Rcpp' Interface to 'PostgreSQL'
Version: 1.1.0
Date: 2018-04-04
Authors@R: c(
person("Hadley", "Wickham", role = "aut"),
person("Jeroen", "Ooms", role = "aut"),
person("Kirill", "Müller", role = "cre", email = "krlmlr+r@mailbox.org"),
person("Kirill", "M\u00fcller", role = c("aut", "cre"), email = "krlmlr+r@mailbox.org", comment = c(ORCID = "0000-0002-1416-3412")),
person("RStudio", role = "cph"),
person("R Consortium", role = "cph"),
person("R Consortium", role = "fnd"),
person("Tomoaki", "Nishiyama", role = "ctb",
comment = "Code for encoding vectors into strings derived from RPostgreSQL"),
person("Kungliga Tekniska Högskolan", role = "ctb", comment = "Source code for timegm")
comment = "Code for encoding vectors into strings derived from RPostgreSQL")
)
Description:
Fully 'DBI'-compliant 'Rcpp'-backed interface to 'PostgreSQL' <https://www.postgresql.org/>,
an open-source relational database.
License: GPL-2
URL: https://github.com/r-dbi/RPostgres
BugReports: https://github.com/r-dbi/RPostgres/issues
SystemRequirements: libpq >= 9.0: libpq-dev (deb) or postgresql-devel
(rpm)
License: GPL-2
LazyLoad: true
Depends: R (>= 3.1.0)
Imports: bit64, blob, DBI (>= 0.7), hms, methods, Rcpp (>= 0.11.4.2),
withr
Imports: bit64, blob (>= 1.1.1), DBI (>= 0.8), hms, methods, Rcpp (>=
0.11.4.2), withr
Suggests: DBItest, testthat
LinkingTo: BH, plogr, Rcpp
LinkingTo: BH, plogr (>= 0.2.0), Rcpp
Encoding: UTF-8
LazyLoad: true
RoxygenNote: 6.0.1.9000
SystemRequirements: libpq >= 9.0: libpq-dev (deb) or postgresql-devel
(rpm)
Collate: 'PqDriver.R' 'PqConnection.R' 'PqResult.R' 'RPostgres-pkg.R'
'RcppExports.R' 'default.R' 'quote.R' 'tables.R'
'RcppExports.R' 'default.R' 'export.R' 'quote.R' 'tables.R'
'transactions.R' 'utils.R'
RoxygenNote: 6.0.1
NeedsCompilation: yes
Packaged: 2017-12-20 13:58:34 UTC; muelleki
Packaged: 2018-04-04 18:45:01 UTC; muelleki
Author: Hadley Wickham [aut],
Jeroen Ooms [aut],
Kirill Müller [cre],
Kirill Müller [aut, cre] (<https://orcid.org/0000-0002-1416-3412>),
RStudio [cph],
R Consortium [cph],
R Consortium [fnd],
Tomoaki Nishiyama [ctb] (Code for encoding vectors into strings derived
from RPostgreSQL),
Kungliga Tekniska Högskolan [ctb] (Source code for timegm)
from RPostgreSQL)
Maintainer: Kirill Müller <krlmlr+r@mailbox.org>
Repository: CRAN
Date/Publication: 2017-12-20 15:50:56 UTC
Date/Publication: 2018-04-06 09:24:36 UTC
66 changes: 35 additions & 31 deletions MD5
@@ -1,81 +1,85 @@
4832eb107246f1c494d8b0a0a12e0426 *DESCRIPTION
feec1bfbc596fa53152300f94a3a7ab7 *NAMESPACE
4f803550504bcf1c80e414b6d4dab64b *NEWS.md
d3949d39c6e0d3ebb30f5f47e69ed7d2 *R/PqConnection.R
03a867755b841450b855879abbf62b30 *R/PqDriver.R
b91897c5beee9b99af6fd55051171a80 *R/PqResult.R
544d29d2a0fbd5c9414866e42321f5ce *DESCRIPTION
998e05675badd0cdcd0d8373ea585460 *NAMESPACE
c40b639382b77be75d84f341b90d54cf *NEWS.md
3976e508105f09c79f16c6df4240f26a *R/PqConnection.R
528f400dd08dc6f21674359e80b67d91 *R/PqDriver.R
67983fd39c5428647b47fdcee308af64 *R/PqResult.R
0b846aae48eacea9831cd61b50eedea2 *R/RPostgres-pkg.R
971e28b404b0401f5b8c38db70e85ff2 *R/RcppExports.R
ff99d2cac7decf472cd0bc8291a78e49 *R/default.R
4ab74e90a8c8573ecb483e069793bb28 *R/quote.R
178feaef07207f895f30fd44b038ace6 *R/tables.R
c5497949eb1f47b24120170f688d4d04 *R/default.R
78a39301621b07479871b0d721c785e6 *R/export.R
ff2c51f565a54d438a9384c8dd8a139b *R/quote.R
202e1587e6cfff21f74390119d7cc4c3 *R/tables.R
bbad0daadf44d8a9a43a0a720bef3803 *R/transactions.R
c3efac6c8ef323cae26e037cce6c0d16 *R/utils.R
f68cbc04ffaf966382f11d77aff0ada5 *README.md
fd1af0835186a29508665ac416772551 *README.md
593b73f88532bd8bca65acc012047767 *configure
d41d8cd98f00b204e9800998ecf8427e *configure.win
254056c489b1f3e7cc8cdc9fe4a14255 *man/Postgres.Rd
fcfcf00fa9190113b6ee073f9fd11e2c *man/PqConnection-class.Rd
26ccd704aecacc6484f3ea5b2e3eaa5f *man/PqDriver-class.Rd
6ebae0927715384b8e90764e3ad2ba87 *man/PqResult-class.Rd
fb4dbf64f44d7e1bdbb2c89f242429e4 *man/RPostgres-package.Rd
3968c41c099acd7c228e85cc99655961 *man/dbConnect-PqDriver-method.Rd
10051d734f12cf564e1e1300a73edc19 *man/RPostgres-package.Rd
83bc1c5516b1b9c1acff5779e70e304d *man/dbConnect-PqDriver-method.Rd
dda833f4b2c036ce15b0555c49add570 *man/dbDataType.Rd
549393f4e48dad8a411932f23b543930 *man/postgres-query.Rd
8e99dd84756b338faa2981ff82a8bfc0 *man/postgres-tables.Rd
5cc66e6dec9a5c9806f76db8f5142fcc *man/postgres-tables.Rd
068c48521487f453e0c5b15bc6605cfe *man/postgres-transactions.Rd
0f380511ba5e72720224904f24e3a42b *man/postgresHasDefault.Rd
c4a8dbefb34cf9b1b599d26fc3ab3612 *man/quote.Rd
7e701610d5c1fb8fa7b3a8fac3cc872f *man/quote.Rd
a567f5b302cec3ac90c52fd40be56c7d *src/DbColumn.cpp
0d0f6283e1aee5ba374ac6c30ce35a57 *src/DbColumn.h
1bead3e4afde4eb4237507be9fd81801 *src/DbColumnDataSource.cpp
146bd8c14b6eb654bf6ef8c4014453b1 *src/DbColumnDataSource.cpp
c1bd654b0f1d00b85c0213fb15266100 *src/DbColumnDataSource.h
b54f1bed5e031730d84ea6ac5678d57c *src/DbColumnDataSourceFactory.cpp
bdb2b7ed1a0c451b46b90f5ba0cae405 *src/DbColumnDataSourceFactory.h
1ba5afa61895d800dbe19155f7d2c492 *src/DbColumnDataType.h
42a9a49f416883265bc88ef5d9b35b9a *src/DbColumnStorage.cpp
00308bd348a82fa234bc3faf490c3bb5 *src/DbColumnStorage.h
b568eeeb2a620abb473f6e96e925dc9e *src/DbConnection.cpp
635e7a8ce8fad8137bb62dac19e44acd *src/DbConnection.cpp
91fd7039d2c543d73abf05c10937928a *src/DbConnection.h
52f74e46125617344b9ef6c064922057 *src/DbDataFrame.cpp
ce8cede04ec884229dfec09a95128ad9 *src/DbDataFrame.h
548a2a51f2beb996158270d790cfb7d2 *src/DbResult.cpp
8fcd22187e896f842ec2a034eeca9844 *src/DbResult.h
aa6b004a18a443064e92833378f109c6 *src/DbDataFrame.h
863c387085575330973494a7ec75f061 *src/DbResult.cpp
1b26b8077ef82ec2a40c598aadccd5b9 *src/DbResult.h
111e1efb50ff675feb507ea42a24b300 *src/Makevars.in
c5a5d51517569b4577b384cbbc412ad5 *src/Makevars.win
16024658adfb1ccb34b929298ac0396e *src/PqColumnDataSource.cpp
96ae4c931ee1599e2f8fd62ddea8c95e *src/Makevars.win
d2da0737c49f3be0e57b1dca3c57f431 *src/PqColumnDataSource.cpp
5b65a687e65c37ef8b4f6b0427313c9b *src/PqColumnDataSource.h
d94f34a4e740f7d2f7b1f46c5bbc9411 *src/PqColumnDataSourceFactory.cpp
7ea23ce015d4e0a8c47581ae646f4f61 *src/PqColumnDataSourceFactory.cpp
5932e6e86bc3c43a31954bfd1dac8117 *src/PqColumnDataSourceFactory.h
8dd8d1fe7af6e996859ef849d6b72993 *src/PqDataFrame.cpp
3fb6f7104460055e29d87402ef538b55 *src/PqDataFrame.h
d73945444948561434167824978e0d2e *src/PqResultImpl.cpp
53c364304523ba77289d3c77c6ff9b33 *src/PqResultImpl.h
ad51c490ab4c9bf3aaba14544108be4c *src/PqDataFrame.cpp
50318e54863d1df1c4dbec190934c5f4 *src/PqDataFrame.h
bcab2e04b35529b4f8a0c8df523ac5a4 *src/PqResultImpl.cpp
5313fb679f2743c3479aacb53b01173b *src/PqResultImpl.h
4601b2b6e925fa6761186d25fa93f9f5 *src/PqResultSource.cpp
e2d8563ac79450e3f2347ebc5259ba0e *src/PqResultSource.h
8dfa99fe35180785119bedf906a81471 *src/PqUtils.cpp
721fb987c03729a6ca2da77db92b4425 *src/PqUtils.h
74630eb1d3dd72f0e20c90f0deac0ba6 *src/RPostgres-init.c
5fd33ab4f8ba8480acb085aa8a5bf94d *src/RPostgres_types.h
57b657eeee6da528d4522e3c31781597 *src/RcppExports.cpp
861292357d8bb45348cbc0a2c3c00d2c *src/connection.cpp
40ca6054ebb1ae2e41a65c4f7d8ee5f3 *src/encode.cpp
2802c3b6e9aaed4521e887934f17b1db *src/encode.cpp
dfb7deb192ff48e8d33f196f1afaa3d6 *src/encode.h
6b44efff9fefa69c04f41a3cbf3b1ce3 *src/encrypt.cpp
9a3d1653a1ced0d8daac4102701ec18a *src/integer64.h
ecf4e945c36fea5564e665ff5012c19d *src/logging.cpp
7291096e5ad632a53bf9483e3020c1ea *src/pch.h
99039714005147435bebbbd0a640d897 *src/result.cpp
e2f57a97ad5e5d484dc0de7d0656faea *src/win32/timegm.c
60dca4ef2333c74e57542dc491fccc40 *src/result.cpp
a9f6581105458f9b9a9bcc0b7bf4971f *src/workarounds/XPtr.h
4111945e05f4e4a31c72f6ef63b1f1e6 *tests/testthat.R
a74d10622304ddd4ebf25b9b2a11b71c *tests/testthat/helper-DBItest.R
ac3971b62e24ae2cc633a12eb1aa0d3d *tests/testthat/helper-astyle.R
60e9b2574eb76a3da502315b6630c2a5 *tests/testthat/helper-astyle.R
5f99bf46169a27c39db6b35611d0da42 *tests/testthat/helper-with_database_connection.R
f251e8d8c1249e774674be514615eeec *tests/testthat/helper-with_table.R
78eff1c41624d5eb4d7e5036b59b7d80 *tests/testthat/helper-without_rownames.R
000f052dbee7a744d411e507f6efbb9e *tests/testthat/test-DBItest.R
29890f7f72946cbf870c714ebeaee604 *tests/testthat/test-bigint.R
d0d355c427d7373ab8e6a85d655a381b *tests/testthat/test-data-type.R
1eb01045fcf55d6094c6d528af1df1af *tests/testthat/test-dbConnect.R
9939d01b8b9c8b6c138e1466a1a74c09 *tests/testthat/test-dbGetQuery.R
be8d2023b9ff4f2659fc383c893c89ac *tests/testthat/test-dbGetQuery.R
dfc643c4d14d440fb7b02648551dca58 *tests/testthat/test-dbWriteTable.R
07ec38d74f52ade1ddc67997730ad1ca *tests/testthat/test-encoding.R
76b610eb3c1116bb15b7f76834e41209 *tests/testthat/test-types.R
5170ffd2f4d60933fe94753bc048c7f2 *tools/winlibs.R
10 changes: 9 additions & 1 deletion NAMESPACE
Expand Up @@ -14,15 +14,20 @@ exportMethods(dbCommit)
exportMethods(dbConnect)
exportMethods(dbDataType)
exportMethods(dbDisconnect)
exportMethods(dbDriver)
exportMethods(dbExecute)
exportMethods(dbExistsTable)
exportMethods(dbFetch)
exportMethods(dbGetInfo)
exportMethods(dbGetQuery)
exportMethods(dbGetRowCount)
exportMethods(dbGetRowsAffected)
exportMethods(dbGetStatement)
exportMethods(dbHasCompleted)
exportMethods(dbIsValid)
exportMethods(dbListFields)
exportMethods(dbListObjects)
exportMethods(dbListResults)
exportMethods(dbListTables)
exportMethods(dbQuoteIdentifier)
exportMethods(dbQuoteLiteral)
Expand All @@ -31,13 +36,16 @@ exportMethods(dbReadTable)
exportMethods(dbRemoveTable)
exportMethods(dbRollback)
exportMethods(dbSendQuery)
exportMethods(dbSendStatement)
exportMethods(dbUnloadDriver)
exportMethods(dbUnquoteIdentifier)
exportMethods(dbWithTransaction)
exportMethods(dbWriteTable)
exportMethods(show)
exportMethods(sqlData)
import(DBI)
import(methods)
importFrom(Rcpp,evalCpp)
importFrom(Rcpp,sourceCpp)
importFrom(bit64,integer64)
importFrom(blob,blob)
importFrom(hms,hms)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
@@ -1,3 +1,15 @@
# RPostgres 1.1.0 (2018-04-04)

- Breaking change: `dbGetException()` is no longer reexported from DBI.
- Make "typname" information available after `dbFetch()` and `dbGetQuery()`. Values of unknown type are returned as character vector of class `"pq_xxx"`, where `"xxx"` is the "typname" returned from PostgreSQL. In particular, `JSON` and `JSONB` values now have class `"pq_json"` and `"pq_jsonb"`, respectively. The return value of `dbColumnInfo()` gains new columns `".oid"` (`integer`), `". known"` (`logical`) and `".typname"` (`character`)(#114, @etiennebr).
- Values of class `"integer64"` are now supported for `dbWriteTable()` and `dbBind()` (#178).
- Schema support, as specified by DBI: `dbListObjects()`, `dbUnquoteIdentifier()` and `Id()`.
- Names in the `x` argument to `dbQuoteIdentifier()` are preserved in the output (r-lib/DBI#173).
- All generics defined in DBI (e.g., `dbGetQuery()`) are now exported, even if the package doesn't provide a custom implementation (#168).
- Replace non-portable `timegm()` with private implementation.
- Correct reference to RPostgreSQL package (#165, @ClaytonJY).


# RPostgres 1.0-4 (2017-12-20)

- Only call `PQcancel()` if the query hasn't completed, fixes transactions on Amazon RedShift (#159, @mmuurr).
Expand Down
23 changes: 13 additions & 10 deletions R/PqConnection.R
Expand Up @@ -7,7 +7,7 @@ NULL
#' @export
setClass("PqConnection",
contains = "DBIConnection",
slots = list(ptr = "externalptr", bigint = "character")
slots = list(ptr = "externalptr", bigint = "character", typnames = "data.frame")
)

# show()
Expand All @@ -32,14 +32,6 @@ setMethod("dbIsValid", "PqConnection", function(dbObj, ...) {
connection_valid(dbObj@ptr)
})

# dbDisconnect()
#' @export
#' @rdname dbConnect-PqDriver-method
setMethod("dbDisconnect", "PqConnection", function(conn, ...) {
connection_release(conn@ptr)
invisible(TRUE)
})

# dbSendQuery()

# dbSendStatement()
Expand All @@ -57,6 +49,7 @@ get_data_type <- function(obj) {
if (inherits(obj, "POSIXt")) return("TIMESTAMPTZ")
if (inherits(obj, "Date")) return("DATE")
if (inherits(obj, "difftime")) return("TIME")
if (inherits(obj, "integer64")) return("BIGINT")
switch(typeof(obj),
integer = "INTEGER",
double = "REAL",
Expand Down Expand Up @@ -155,11 +148,21 @@ setMethod("dbConnect", "PqDriver",
ptr <- connection_create(names(opts), as.vector(opts))
}

con <- new("PqConnection", ptr = ptr, bigint = bigint)
con <- new("PqConnection", ptr = ptr, bigint = bigint, typnames = data.frame())
dbExecute(con, "SET TIMEZONE='UTC'")
con@typnames <- dbGetQuery(con, "SELECT oid, typname FROM pg_type")

con
})

# dbDisconnect() (after dbConnect() to maintain order in documentation)
#' @export
#' @rdname dbConnect-PqDriver-method
setMethod("dbDisconnect", "PqConnection", function(conn, ...) {
connection_release(conn@ptr)
invisible(TRUE)
})


#' Determine database type for R vector.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/PqDriver.R
Expand Up @@ -5,7 +5,7 @@
#'
#' @export
#' @useDynLib RPostgres, .registration = TRUE
#' @importFrom Rcpp evalCpp
#' @importFrom Rcpp sourceCpp
#' @import methods DBI
#' @examples
#' library(DBI)
Expand Down
32 changes: 30 additions & 2 deletions R/PqResult.R
Expand Up @@ -43,7 +43,8 @@ setMethod("dbGetRowsAffected", "PqResult", function(res, ...) {
#' @rdname PqResult-class
#' @export
setMethod("dbColumnInfo", "PqResult", function(res, ...) {
result_column_info(res@ptr)
rci <- result_column_info(res@ptr)
cbind(rci, .typname = type_lookup(rci[[".oid"]], res@conn), stringsAsFactors = FALSE)
})

#' Execute a SQL statement on a database connection
Expand Down Expand Up @@ -116,7 +117,8 @@ setMethod("dbFetch", "PqResult", function(res, n = -1, ..., row.names = FALSE) {
if (is.infinite(n)) n <- -1
if (trunc(n) != n) stopc("n must be a whole number")
ret <- sqlColumnToRownames(result_fetch(res@ptr, n = n), row.names)
convert_bigint(ret, res@bigint)
ret <- convert_bigint(ret, res@bigint)
finalize_types(ret, res@conn)
})

convert_bigint <- function(ret, bigint) {
Expand All @@ -131,6 +133,32 @@ convert_bigint <- function(ret, bigint) {
ret
}

finalize_types <- function(ret, conn) {
known <- attr(ret, "known")
is_unknown <- which(!known)

if (length(is_unknown) > 0) {
oids <- attr(ret, "oids")
typnames <- type_lookup(oids[is_unknown], conn)
typname_classes <- paste0("pq_", typnames)
ret[is_unknown] <- Map(set_class, ret[is_unknown], typname_classes)
}

attr(ret, "oids") <- NULL
attr(ret, "known") <- NULL
ret
}

set_class <- function(x, subclass = NULL) {
class(x) <- c(subclass)
x
}

type_lookup <- function(x, conn) {
typnames <- conn@typnames
typnames$typname[match(x, typnames$oid)]
}

#' @rdname postgres-query
#' @export
setMethod("dbBind", "PqResult", function(res, params, ...) {
Expand Down
1 change: 1 addition & 0 deletions R/default.R
Expand Up @@ -28,6 +28,7 @@ postgresHasDefault <- function(...) {
})
}

#' @description
#' `postgresDefault()` works similarly but returns a connection on success and
#' throws a testthat skip condition on failure, making it suitable for use in
#' tests.
Expand Down

0 comments on commit cbaefde

Please sign in to comment.