Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Replace Rcpp by cpp11 #419

Merged
merged 37 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
93ae2e8
init cpp11
Antonov548 Jan 22, 2023
ded1f0d
encrypt.cpp fix
Antonov548 Jan 22, 2023
b50174b
connection cpp11::external_pointer
Antonov548 Jan 22, 2023
aa71b44
result cpp11::external_pointer
Antonov548 Jan 22, 2023
3b6b881
encode.cpp cpp11
Antonov548 Jan 22, 2023
88639d1
connection.cpp cpp11
Antonov548 Jan 22, 2023
d44c3fe
DbConnection cpp11
Antonov548 Jan 22, 2023
6f712d4
update external_pointer release to reset
Antonov548 Jan 22, 2023
bfda2ed
Merge branch 'main' into cpp11
krlmlr Jan 23, 2023
6b35f3a
remove error message
Antonov548 Jan 26, 2023
39b48f3
update wait_for_notify
Antonov548 Jan 26, 2023
a720ae6
return empty list instead of NULL
Antonov548 Jan 26, 2023
4c7cf8b
Merge branch 'main' into cpp11
Antonov548 Jan 26, 2023
22398b7
result cpp11::list
Antonov548 Jan 28, 2023
867b5d3
Merge branch 'cpp11' of https://github.com/Antonov548/RPostgres into …
Antonov548 Jan 28, 2023
76ecec5
data frame cpp11
Antonov548 Jan 28, 2023
1dc6bde
column storage
Antonov548 Jan 28, 2023
e20f8ea
remove strings
Antonov548 Jan 28, 2023
ad948f9
warning/stop/package
Antonov548 Jan 28, 2023
4db227f
remove Rcpp
Antonov548 Jan 28, 2023
ae7a9d4
undo DESCRIPTION
Antonov548 Jan 28, 2023
435f97d
fix new line
Antonov548 Jan 28, 2023
e60c573
use cpp11 and cpp11 only
pachadotdev Jan 30, 2023
92c27a5
re roxygenize with newer roxygen installed version (7.2.3)
pachadotdev Jan 30, 2023
a67c4c2
use std::string for warning/stop
Antonov548 Jan 30, 2023
718db2c
Merge pull request #1 from pachadotdev/cpp11
Antonov548 Jan 30, 2023
37bc3fe
remove import Rcpp
Antonov548 Jan 30, 2023
56de452
update DESCRIPTION
Antonov548 Feb 1, 2023
57c7b91
remove cxx11 from Makevars
Antonov548 Feb 1, 2023
4b68109
string for cpp11::warning
Antonov548 Feb 6, 2023
3a8d2e0
Merge branch 'r-dbi:main' into cpp11
Antonov548 Feb 6, 2023
6533d54
Tweak test
krlmlr Feb 8, 2023
ac129e5
Merge branch 'main' into cpp11
krlmlr Feb 8, 2023
44c1918
fix: release connection with result
krlmlr Feb 8, 2023
7ca870b
retrun std::string instead of r_string
Antonov548 Feb 9, 2023
4a1ac62
Revert "fix: release connection with result"
krlmlr Feb 13, 2023
87def43
Early return if connection closed already
krlmlr Feb 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ windows
^\.gitpod\.yml$
^\.gitpod\.Dockerfile$
^CMakeLists\.txt$
^vscode-install\.r$
11 changes: 5 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Imports:
hms (>= 1.0.0),
lubridate,
methods,
Rcpp (>= 1.0.7),
withr
Suggests:
callr,
Expand All @@ -36,8 +35,8 @@ Suggests:
rmarkdown,
testthat (>= 3.0.0)
LinkingTo:
plogr (>= 0.2.0),
Rcpp
cpp11,
plogr (>= 0.2.0)
VignetteBuilder:
knitr
Config/autostyle/scope: line_breaks
Expand All @@ -47,15 +46,15 @@ Encoding: UTF-8
LazyLoad: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
SystemRequirements: libpq >= 9.0: libpq-dev (deb) or postgresql-devel
(rpm)
SystemRequirements:
libpq >= 9.0: libpq-dev (deb) or postgresql-devel (rpm)
Collate:
'PqDriver.R'
'PqConnection.R'
'PqResult.R'
'RPostgres-pkg.R'
'RcppExports.R'
'Redshift.R'
'cpp11.R'
'dbAppendTable_PqConnection.R'
'dbBegin_PqConnection.R'
'dbBind_PqResult.R'
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ exportMethods(show)
exportMethods(sqlData)
import(DBI)
import(methods)
importFrom(Rcpp,sourceCpp)
importFrom(bit64,integer64)
importFrom(blob,blob)
importFrom(hms,hms)
Expand Down
1 change: 0 additions & 1 deletion R/PqDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#'
#' @export
#' @useDynLib RPostgres, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @import methods DBI
Postgres <- function() {
new("PqDriver")
Expand Down
107 changes: 0 additions & 107 deletions R/RcppExports.R

This file was deleted.

105 changes: 105 additions & 0 deletions R/cpp11.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Generated by cpp11: do not edit by hand

client_version <- function() {
.Call(`_RPostgres_client_version`)
}

connection_create <- function(keys, values, check_interrupts) {
.Call(`_RPostgres_connection_create`, keys, values, check_interrupts)
}

connection_valid <- function(con_) {
.Call(`_RPostgres_connection_valid`, con_)
}

connection_release <- function(con_) {
invisible(.Call(`_RPostgres_connection_release`, con_))
}

connection_info <- function(con) {
.Call(`_RPostgres_connection_info`, con)
}

connection_quote_string <- function(con, xs) {
.Call(`_RPostgres_connection_quote_string`, con, xs)
}

connection_quote_identifier <- function(con, xs) {
.Call(`_RPostgres_connection_quote_identifier`, con, xs)
}

connection_is_transacting <- function(con) {
.Call(`_RPostgres_connection_is_transacting`, con)
}

connection_set_transacting <- function(con, transacting) {
invisible(.Call(`_RPostgres_connection_set_transacting`, con, transacting))
}

connection_copy_data <- function(con, sql, df) {
invisible(.Call(`_RPostgres_connection_copy_data`, con, sql, df))
}

connection_wait_for_notify <- function(con, timeout_secs) {
.Call(`_RPostgres_connection_wait_for_notify`, con, timeout_secs)
}

connection_get_temp_schema <- function(con) {
.Call(`_RPostgres_connection_get_temp_schema`, con)
}

connection_set_temp_schema <- function(con, temp_schema) {
invisible(.Call(`_RPostgres_connection_set_temp_schema`, con, temp_schema))
}

encode_vector <- function(x) {
.Call(`_RPostgres_encode_vector`, x)
}

encode_data_frame <- function(x) {
.Call(`_RPostgres_encode_data_frame`, x)
}

encrypt_password <- function(password, user) {
.Call(`_RPostgres_encrypt_password`, password, user)
}

init_logging <- function(log_level) {
invisible(.Call(`_RPostgres_init_logging`, log_level))
}

result_create <- function(con, sql, immediate) {
.Call(`_RPostgres_result_create`, con, sql, immediate)
}

result_release <- function(res) {
invisible(.Call(`_RPostgres_result_release`, res))
}

result_valid <- function(res_) {
.Call(`_RPostgres_result_valid`, res_)
}

result_fetch <- function(res, n) {
.Call(`_RPostgres_result_fetch`, res, n)
}

result_bind <- function(res, params) {
invisible(.Call(`_RPostgres_result_bind`, res, params))
}

result_has_completed <- function(res) {
.Call(`_RPostgres_result_has_completed`, res)
}

result_rows_fetched <- function(res) {
.Call(`_RPostgres_result_rows_fetched`, res)
}

result_rows_affected <- function(res) {
.Call(`_RPostgres_result_rows_affected`, res)
}

result_column_info <- function(res) {
.Call(`_RPostgres_result_column_info`, res)
}
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ add_library(RPostgres
PqUtils.h
RPostgres-init.c
RPostgres_types.h
RcppExports.cpp
cpp11.cpp
connection.cpp
encode.cpp
encode.h
Expand Down
9 changes: 3 additions & 6 deletions src/DbColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void DbColumn::finalize(const int n_) {
n = n_;
}

void DbColumn::warn_type_conflicts(const String& name) const {
void DbColumn::warn_type_conflicts(const cpp11::r_string& name) const {
std::set<DATA_TYPE> my_data_types_seen = data_types_seen;
DATA_TYPE dt = get_last_storage()->get_data_type();

Expand All @@ -52,11 +52,8 @@ void DbColumn::warn_type_conflicts(const String& name) const {

if (my_data_types_seen.size() == 0) return;

String name_utf8 = name;
name_utf8.set_encoding(CE_UTF8);

std::stringstream ss;
ss << "Column `" << name_utf8.get_cstring() << "`: " <<
ss << "Column `" << static_cast<std::string>(name) << "`: " <<
"mixed type, first seen values of type " << format_data_type(dt) << ", " <<
"coercing other values of type ";

Expand All @@ -67,7 +64,7 @@ void DbColumn::warn_type_conflicts(const String& name) const {
ss << format_data_type(*it);
}

warning(ss.str());
cpp11::warning(ss.str());
}

DbColumn::operator SEXP() const {
Expand Down
3 changes: 2 additions & 1 deletion src/DbColumn.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef DB_COLUMN_H
#define DB_COLUMN_H

#include <set>

#include "DbColumnDataType.h"
#include "DbColumnDataSourceFactory.h"
Expand All @@ -25,7 +26,7 @@ class DbColumn {
public:
void set_col_value();
void finalize(const int n_);
void warn_type_conflicts(const String& name) const;
void warn_type_conflicts(const cpp11::r_string& name) const;

operator SEXP() const;
DATA_TYPE get_type() const;
Expand Down
Loading