Skip to content

Commit

Permalink
version 1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored and cran-robot committed Dec 5, 2021
1 parent 51f83e2 commit 4514e84
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 209 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: RPostgres
Title: Rcpp Interface to PostgreSQL
Version: 1.4.1
Date: 2021-09-26
Version: 1.4.2
Date: 2021-12-05
Authors@R:
c(person(given = "Hadley",
family = "Wickham",
Expand Down Expand Up @@ -43,7 +43,7 @@ Collate: 'PqDriver.R' 'PqConnection.R' 'PqResult.R' 'RPostgres-pkg.R'
'RcppExports.R' 'Redshift.R' 'default.R' 'export.R' 'names.R'
'quote.R' 'tables.R' 'transactions.R' 'utils.R'
NeedsCompilation: yes
Packaged: 2021-09-26 22:07:24 UTC; kirill
Packaged: 2021-12-05 11:37:19 UTC; kirill
Author: Hadley Wickham [aut],
Jeroen Ooms [aut],
Kirill Müller [aut, cre] (<https://orcid.org/0000-0002-1416-3412>),
Expand All @@ -53,4 +53,4 @@ Author: Hadley Wickham [aut],
from RPostgreSQL)
Maintainer: Kirill Müller <krlmlr+r@mailbox.org>
Repository: CRAN
Date/Publication: 2021-09-27 10:10:13 UTC
Date/Publication: 2021-12-05 12:10:02 UTC
30 changes: 14 additions & 16 deletions MD5
@@ -1,7 +1,7 @@
0cb1942601096a926df8d6d2e49b0f24 *DESCRIPTION
2f1afdeac2cca33f2acedb6847b91bea *DESCRIPTION
3ba426cf8e5c98bb899cd54a4e592ceb *NAMESPACE
97248d9a46e0ef81945881bf816d009d *NEWS.md
6f363c855773abea4a6ccad4aeeba9ef *R/PqConnection.R
44870f43de857475c0f898794b4bcb2e *NEWS.md
92c772e5705de94a12050a1b2af03744 *R/PqConnection.R
a070b1343f8d8bf4c86fc402e12e9803 *R/PqDriver.R
ef6ee9ea318c7fc3bfdc2e9cdeb0d1c9 *R/PqResult.R
0b846aae48eacea9831cd61b50eedea2 *R/RPostgres-pkg.R
Expand All @@ -10,22 +10,22 @@ c724812b566086217e351b3b98588887 *R/Redshift.R
3ef526448695ba513c048cf20adf99b5 *R/default.R
568aecb1066757bc112c6798174ba377 *R/export.R
55d0f1da7f7a73971d0a58339fb99b6c *R/names.R
d8f238591c150aac2f62f5333c95cbe0 *R/quote.R
cd7715d75c3a24c3ef62bb2ebb83f716 *R/tables.R
3d72444ef0aa2dedb93e9289d77cac10 *R/quote.R
e456ddce6129cb227026fed26a8533bc *R/tables.R
07e7b5ee52c26769c0561985ad22cdf9 *R/transactions.R
5b2835cb80913f7e866393f57030f78b *R/utils.R
f4a55c33173de520e9d07868db9b215b *README.md
c9827f06133bf65a9743acb2c99a5511 *README.md
e9f416244990496500037511798a75d0 *build/vignette.rds
56817d2d8e66f64fbbd677ec277bcf3a *configure
2a4d75e6bfa77ae0c7ba0932407ceb5c *configure
d41d8cd98f00b204e9800998ecf8427e *configure.win
8000b439e478dba7fe70d722dafafb99 *inst/doc/work-queue.R
b87ee293c031dd9146bde6502b9c71d8 *inst/doc/work-queue.Rmd
373ba6bec1ad55d979eaa77986af8040 *inst/doc/work-queue.html
1c3053d1628d28602fbc108e653495a1 *inst/doc/work-queue.html
a235baa1a86ec8f41be910d112165ec9 *man/Postgres.Rd
809eb0aa572aeae0521d78fc27f5854c *man/PqConnection-class.Rd
f0cda4140152c4d9260438779f2baca6 *man/PqDriver-class.Rd
757d0e726b6ce92bc25efc7e65a07dbe *man/PqResult-class.Rd
0bdfa35a34c9725118e86dc6ab7f8d1e *man/RPostgres-package.Rd
82c3b20386f302c739ac8e8350093c32 *man/RPostgres-package.Rd
aea5d46900048339b7fa77e645ac27cb *man/Redshift.Rd
5f8eee318fabf2e8ecb3f4f38340ba40 *man/dbDataType.Rd
cfc9e8f2964660ddff219985f305c180 *man/postgres-query.Rd
Expand All @@ -44,7 +44,7 @@ bdb2b7ed1a0c451b46b90f5ba0cae405 *src/DbColumnDataSourceFactory.h
1ba5afa61895d800dbe19155f7d2c492 *src/DbColumnDataType.h
a767727e50cd53b612b09375d2fbb15f *src/DbColumnStorage.cpp
e24e7165514d9c6d82259d8c0ed4dfe6 *src/DbColumnStorage.h
463d599111f3c8c0bad5b9205ced91e5 *src/DbConnection.cpp
13dd3cd3620bc780854864aac3fe7b22 *src/DbConnection.cpp
84d1d0cc09680c7c640f7a5a3d8a2655 *src/DbConnection.h
e089124da5acaa0c87cc7a22c69c2e52 *src/DbDataFrame.cpp
aa6b004a18a443064e92833378f109c6 *src/DbDataFrame.h
Expand All @@ -63,7 +63,7 @@ dc0c9c1a7018a5dbc69e21a8a81da07c *src/PqColumnDataSource.cpp
e991d1583380c2955033c447eb117afc *src/PqDataFrame.h
79c8fecf150b35d6e4b4f55603b5e5d3 *src/PqResult.cpp
5c30bfc925cbb848ccbcecb8d7ccdf58 *src/PqResult.h
cc8d04ce2fe0a19ad33b9d512489f520 *src/PqResultImpl.cpp
1f3c020bf4e4977119477348fc41ef33 *src/PqResultImpl.cpp
4ad681c3ee9c9581e21cb19e8bec2bcf *src/PqResultImpl.h
4601b2b6e925fa6761186d25fa93f9f5 *src/PqResultSource.cpp
e2d8563ac79450e3f2347ebc5259ba0e *src/PqResultSource.h
Expand Down Expand Up @@ -1709,24 +1709,22 @@ aaf844f158cf0592d537c95457f773a4 *src/vendor/boost/utility/base_from_member.hpp
45c9f078378c203b4a02d4f27f83186b *src/vendor/boost/version.hpp
61108cfe1e8bd3ae15c893600d38907d *src/vendor/boost/visit_each.hpp
4111945e05f4e4a31c72f6ef63b1f1e6 *tests/testthat.R
78dbf5eae9e6e14402f6c61aa8f9af84 *tests/testthat/_snaps/checkInterrupts.md
98f8fab1930e8d1eb8eb546d932bf30d *tests/testthat/_snaps/immediate.md
13e554ad04c6c31b611d1d3946fd0af3 *tests/testthat/helper-DBItest.R
1f9207122aed39a62efce663ad24f66a *tests/testthat/helper-DBItest.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
12d4b2ba46626718ba9e48cfb763b1b8 *tests/testthat/test-DBItest.R
1c856b3eccecaefc738acadd55ae3636 *tests/testthat/test-Redshift.R
29890f7f72946cbf870c714ebeaee604 *tests/testthat/test-bigint.R
b92de13cb4f4d3ddedf0f1675fdf7ecb *tests/testthat/test-checkInterrupts.R
247a748e3f2c7dda0ee9d1955ed6f467 *tests/testthat/test-checkInterrupts.R
a43898d0ffd33f8ad8fff8e6805d74c3 *tests/testthat/test-data-type.R
37c33c1651be76fbf2b2388f3383b616 *tests/testthat/test-dbConnect.R
a81f5dd62df14a99a5c959e5748c0091 *tests/testthat/test-dbGetQuery.R
7373bd9dc8dab391a83ebfbcc52633c3 *tests/testthat/test-dbQuoteIdentifier.R
859f6c8a6bff30f1f72d1def1440e39b *tests/testthat/test-dbWriteTable.R
07ec38d74f52ade1ddc67997730ad1ca *tests/testthat/test-encoding.R
a7ffbca4808607aea94068998f07226b *tests/testthat/test-immediate.R
94967ba5d1e9a12149b7ddd92062579e *tests/testthat/test-immediate.R
a9a9e9542fa0e278504a1b0bce468e45 *tests/testthat/test-timezone.R
6168ca0b8281698c7abd4ffff879cfca *tests/testthat/test-transactions.R
76b610eb3c1116bb15b7f76834e41209 *tests/testthat/test-types.R
Expand Down
26 changes: 23 additions & 3 deletions NEWS.md
@@ -1,5 +1,25 @@
<!-- NEWS.md is maintained by https://cynkra.github.io/fledge, do not edit -->

# RPostgres 1.4.2 (2021-12-05)

## Features

- `dbWriteTable()` uses savepoints for its transactions, even if an external transaction is open. This does not affect Redshift, because savepoints are not supproted there (#342).
- With `dbConnect(check_interrupts = TRUE)`, interrupting a query now gives a dedicated error message. Very short-running queries no longer take one second to complete (#344).

## Bug fixes

- `dbQuoteLiteral()` correctly quotes length-0 values (#355) and generates typed `NULL` expressions for `NA` values (#357).
- The `SET DATESTYLE` query sent after connecting uses quotes for compatibility with CockroachDB (#360).

## Internal

- `dbConnect()` executes initial queries with `immediate = TRUE` (#346).
- Check Postgres starting from version 10 on GitHub Actions (#368).
- Fix build on Ubuntu 16.04 (#352).
- Mention `libssl-dev` in `configure` script (#350).


# RPostgres 1.4.1 (2021-09-26)

## Bug fixes
Expand Down Expand Up @@ -94,7 +114,7 @@
- Document `Postgres()` together with `dbConnect()` (#242).
- Windows: update libpq to 12.2.0.

# RPostgres 1.2.0
# RPostgres 1.2.0 (2019-12-18)

## Communication with the database

Expand Down Expand Up @@ -131,12 +151,12 @@
- Align `DbResult` and other classes with RSQLite and RMariaDB.


# RPostgres 1.1.3
# RPostgres 1.1.3 (2019-12-07)

- Replace `std::mem_fn()` by `boost::mem_fn()` which works for older compilers.


# RPostgres 1.1.2
# RPostgres 1.1.2 (2019-12-03)

- Replace `std::mem_fun_ref()` by `std::mem_fn()`.

Expand Down
8 changes: 4 additions & 4 deletions R/PqConnection.R
Expand Up @@ -204,13 +204,13 @@ setMethod("dbConnect", "PqDriver",
on.exit(dbDisconnect(conn))

# set datestyle workaround - https://github.com/r-dbi/RPostgres/issues/287
dbExecute(conn, "SET datestyle to iso, mdy")
dbExecute(conn, "SET datestyle to 'iso, mdy'", immediate = TRUE)

if (!is.null(timezone)) {
# Side effect: check if time zone valid
dbExecute(conn, paste0("SET TIMEZONE = ", dbQuoteString(conn, timezone)))
dbExecute(conn, paste0("SET TIMEZONE = ", dbQuoteString(conn, timezone)), immediate = TRUE)
} else {
timezone <- dbGetQuery(conn, "SHOW timezone")[[1]]
timezone <- dbGetQuery(conn, "SHOW timezone", immediate = TRUE)[[1]]
}

# Check if this is a valid time zone in R:
Expand All @@ -224,7 +224,7 @@ setMethod("dbConnect", "PqDriver",

conn@timezone <- timezone
conn@timezone_out <- timezone_out
conn@typnames <- dbGetQuery(conn, "SELECT oid, typname FROM pg_type")
conn@typnames <- dbGetQuery(conn, "SELECT oid, typname FROM pg_type", immediate = TRUE)

on.exit(NULL)
conn
Expand Down
30 changes: 17 additions & 13 deletions R/quote.R
Expand Up @@ -27,7 +27,7 @@ setMethod("dbQuoteString", c("PqConnection", "character"), function(conn, x, ...
if (length(x) == 0) return(SQL(character()))
if (is(conn, "RedshiftConnection")) {
out <- paste0("'", gsub("(['\\\\])", "\\1\\1", enc2utf8(x)), "'")
out[is.na(x)] <- "NULL"
out[is.na(x)] <- "NULL::varchar(max)"
} else {
out <- connection_quote_string(conn@ptr, enc2utf8(x))
}
Expand Down Expand Up @@ -114,39 +114,43 @@ as_table <- function(catalog, schema, table) {
#' @importFrom blob blob
#' @rdname quote
setMethod("dbQuoteLiteral", "PqConnection", function(conn, x, ...) {
if (length(x) == 0) {
return(SQL(character()))
}

if (is.factor(x)) {
x <- as.character(x)
}

if (inherits(x, "Date")) {
ret <- paste0("'", as.character(x), "'::date")
ret <- paste0("'", as.character(x), "'")
ret[is.na(x)] <- "NULL"
SQL(ret, names = names(ret))
SQL(paste0(ret, "::date"), names = names(ret))
} else if (inherits(x, "POSIXt")) {
ret <- paste0("'", as.character(lubridate::with_tz(x, conn@timezone)), "'::timestamp")
ret <- paste0("'", as.character(lubridate::with_tz(x, conn@timezone)), "'")
ret[is.na(x)] <- "NULL"
SQL(ret, names = names(ret))
SQL(paste0(ret, "::timestamp"), names = names(ret))
} else if (inherits(x, "difftime")) {
ret <- paste0("'", as.character(hms::as_hms(x)), "'::interval")
ret <- paste0("'", as.character(hms::as_hms(x)), "'")
ret[is.na(x)] <- "NULL"
SQL(ret, names = names(ret))
SQL(paste0(ret, "::interval"), names = names(ret))
} else if (is.logical(x)) {
ret <- as.character(x)
ret[is.na(ret)] <- "NULL"
ret[is.na(ret)] <- "NULL::bool"
SQL(ret, names = names(ret))
} else if (is.integer(x)) {
ret <- paste0(as.character(x), "::int4")
ret <- as.character(x)
ret[is.na(x)] <- "NULL"
SQL(ret, names = names(ret))
SQL(paste0(ret, "::int4"), names = names(ret))
} else if (is.numeric(x)) {
ret <- paste0(as.character(x), "::float8")
ret <- as.character(x)
ret[is.na(x)] <- "NULL"
SQL(ret, names = names(ret))
SQL(paste0(ret, "::float8"), names = names(ret))
} else if (is.list(x) || inherits(x, "blob")) {
blob_data <- vcapply(
x,
function(x) {
if (is.null(x)) "NULL"
if (is.null(x)) "NULL::bytea"
else if (is.raw(x)) paste0("E'\\\\x", paste(format(x), collapse = ""), "'")
else {
stopc("Lists must contain raw vectors or NULL")
Expand Down
23 changes: 20 additions & 3 deletions R/tables.R
Expand Up @@ -88,7 +88,20 @@ setMethod("dbWriteTable", c("PqConnection", "character", "data.frame"),
need_transaction <- !connection_is_transacting(conn@ptr)
if (need_transaction) {
dbBegin(conn)
on.exit(dbRollback(conn))
}

if (!is(conn, "RedshiftConnection")) {
dbBegin(conn, name = "dbWriteTable")
# This is executed first, the `after` argument requires quite recent R
on.exit({
dbRollback(conn, name = "dbWriteTable")
})
}

if (need_transaction) {
on.exit({
dbRollback(conn)
})
}

found <- dbExistsTable(conn, name)
Expand Down Expand Up @@ -127,10 +140,13 @@ setMethod("dbWriteTable", c("PqConnection", "character", "data.frame"),
db_append_table(conn, name, value, copy, warn = FALSE)
}

if (!is(conn, "RedshiftConnection")) {
dbCommit(conn, name = "dbWriteTable")
}
if (need_transaction) {
dbCommit(conn)
on.exit(NULL)
}
on.exit(NULL)

invisible(TRUE)
}
Expand Down Expand Up @@ -396,9 +412,10 @@ setMethod("dbListObjects", c("PqConnection", "ANY"), function(conn, prefix = NUL

if (is.null(prefix)) {
if (is_redshift) {
# On Redshift, UNION ALL with NULL::text fails
null_varchar <- "NULL::varchar(max)"
} else {
null_varchar <- "NULL"
null_varchar <- "NULL::text"
}
query <- paste0(
"SELECT ", null_varchar, " AS schema, table_name AS table FROM INFORMATION_SCHEMA.tables\n",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

<!-- badges: start -->
[![rcc](https://github.com/r-dbi/RPostgres/workflows/rcc/badge.svg)](https://github.com/r-dbi/RPostgres/actions)
[![Codecov test coverage](https://codecov.io/gh/r-dbi/RPostgres/branch/master/graph/badge.svg)](https://codecov.io/gh/r-dbi/RPostgres?branch=master)
[![Codecov test coverage](https://codecov.io/gh/r-dbi/RPostgres/branch/master/graph/badge.svg)](https://app.codecov.io/gh/r-dbi/RPostgres?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/RPostgres)](https://CRAN.R-project.org/package=RPostgres)
<!-- badges: end -->

Expand Down
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -8,7 +8,7 @@

# Library settings
PKG_CONFIG_NAME="libpq"
PKG_DEB_NAME="libpq-dev"
PKG_DEB_NAME="libpq-dev libssl-dev"
PKG_RPM_NAME="postgresql-devel"
PKG_AMZ_RPM_NAMES="postgreql8-devel, psstgresql92-devel, postgresql93-devel, or postgresql94-devel"
PKG_CSW_NAME="postgresql_dev"
Expand Down
12 changes: 6 additions & 6 deletions inst/doc/work-queue.html
Expand Up @@ -301,7 +301,7 @@ <h2>Implementing our worker</h2>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>rs <span class="ot">&lt;-</span> <span class="fu">dbSendQuery</span>(con, <span class="st">&quot;SELECT * FROM sqroot_vignette_example ORDER BY in_val&quot;</span>)</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">dbFetch</span>(rs)</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; in_val out_val</span></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 7 2.645751</span></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 1 7 NA</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 2 8 2.828427</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; 3 9 3.000000</span></span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="fu">dbClearResult</span>(rs) ; rs <span class="ot">&lt;-</span> <span class="cn">NULL</span></span></code></pre></div>
Expand All @@ -317,11 +317,11 @@ <h2>Implementing our worker</h2>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="fu">writeLines</span>(outputs[[<span class="dv">1</span>]])</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Not sqroot-ing as another worker got there first</span></span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="fu">writeLines</span>(outputs[[<span class="dv">2</span>]])</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sqroot-ing 7 ... </span></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sqroot-ing 8 ... </span></span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sqroot-ing 9 ... </span></span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Shutting down.</span></span></code></pre></div>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sqroot-ing 8 ... </span></span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sqroot-ing 9 ... </span></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Shutting down.</span></span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="fu">writeLines</span>(outputs[[<span class="dv">2</span>]])</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; Sqroot-ing 7 ...</span></span></code></pre></div>
<p>Notice that the work has been shared between the 2 workers. If these 2 weren’t enough, we could happily add more to keep the system going.</p>
<pre><code>#&gt; [1] 0</code></pre>
</div>
Expand Down
4 changes: 1 addition & 3 deletions man/RPostgres-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/DbConnection.cpp
Expand Up @@ -233,7 +233,7 @@ SEXP DbConnection::quote_identifier(const String& x) {
}

SEXP DbConnection::get_null_string() {
static RObject null = Rf_mkCharCE("NULL", CE_UTF8);
static RObject null = Rf_mkCharCE("NULL::text", CE_UTF8);
return null;
}

Expand Down

0 comments on commit 4514e84

Please sign in to comment.