From c325e9f88ddedae96d648c641f7dc82ee4c5b6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 15 Sep 2021 09:53:09 +0200 Subject: [PATCH 1/5] Remove unused --- src/result.cpp | 1 - src/workarounds/XPtr.h | 43 ------------------------------------------ 2 files changed, 44 deletions(-) delete mode 100644 src/workarounds/XPtr.h diff --git a/src/result.cpp b/src/result.cpp index 7c0c39a5..5c403347 100644 --- a/src/result.cpp +++ b/src/result.cpp @@ -1,5 +1,4 @@ #include "pch.h" -#include "workarounds/XPtr.h" #include "RPostgres_types.h" #include "PqResult.h" diff --git a/src/workarounds/XPtr.h b/src/workarounds/XPtr.h deleted file mode 100644 index 2f651505..00000000 --- a/src/workarounds/XPtr.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef RSQLite_workarounds_XPtr_h -#define RSQLite_workarounds_XPtr_h - - -#ifdef __CLION__ - -namespace Rcpp{ - - template < - typename T> - class XPtr - { - public: - explicit XPtr(SEXP x, SEXP tag = R_NilValue, SEXP prot = R_NilValue); - explicit XPtr(T* p, bool set_delete_finalizer = true, SEXP tag = R_NilValue, SEXP prot = R_NilValue); - XPtr( const XPtr& other ); - XPtr& operator=(const XPtr& other); - - inline T* get() const; - - typedef void (*unspecified_bool_type)(); - static void unspecified_bool_true(); - operator unspecified_bool_type() const; - bool operator!() const; - - inline T* checked_get() const; - - T& operator*() const; - - T* operator->() const; - - void release(); - - inline operator T*(); - - void update(SEXP); - }; - -} // namespace Rcpp - -#endif // #ifdef __CLION__ - -#endif // #ifndef RSQLite_workarounds_XPtr_h From f354a7177ebf2de84f9d94693e795aa86c1fc407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 15 Sep 2021 10:00:56 +0200 Subject: [PATCH 2/5] Set UTC attribute to output time --- src/DbColumnStorage.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/DbColumnStorage.cpp b/src/DbColumnStorage.cpp index 83be75aa..0ccaa808 100644 --- a/src/DbColumnStorage.cpp +++ b/src/DbColumnStorage.cpp @@ -209,6 +209,11 @@ SEXP DbColumnStorage::set_attribs_from_datatype(SEXP x, DATA_TYPE dt) { case DT_TIME: return new_hms(x); + case DT_DATETIME: { + Rcpp::RObject ro = Rcpp::RObject(x); + ro.attr("tzone") = "UTC"; + return ro; + } default: return x; } From 12d8ea98c77b9027a9f734810e8e224e7f376a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 15 Sep 2021 10:01:09 +0200 Subject: [PATCH 3/5] Properly return bigint NA --- src/DbColumnStorage.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/DbColumnStorage.cpp b/src/DbColumnStorage.cpp index 0ccaa808..3ff8a0b2 100644 --- a/src/DbColumnStorage.cpp +++ b/src/DbColumnStorage.cpp @@ -281,11 +281,21 @@ void DbColumnStorage::copy_value(SEXP x, DATA_TYPE dt, const int tgt, const int case DT_INT64: switch (TYPEOF(data)) { case INTSXP: - INTEGER64(x)[tgt] = INTEGER(data)[src]; + if (INTEGER(data)[src] == NA_INTEGER) { + INTEGER64(x)[tgt] = NA_INTEGER64; + } + else { + INTEGER64(x)[tgt] = INTEGER(data)[src]; + } break; case REALSXP: - INTEGER64(x)[tgt] = INTEGER64(data)[src]; + if (R_IsNA(INTEGER64(data)[src])) { + INTEGER64(x)[tgt] = NA_INTEGER64; + } + else { + INTEGER64(x)[tgt] = INTEGER64(data)[src]; + } break; } break; @@ -293,7 +303,12 @@ void DbColumnStorage::copy_value(SEXP x, DATA_TYPE dt, const int tgt, const int case DT_REAL: switch (TYPEOF(data)) { case INTSXP: - REAL(x)[tgt] = INTEGER(data)[src]; + if (INTEGER(data)[src] == NA_INTEGER) { + REAL(x)[tgt] = NA_REAL; + } + else { + REAL(x)[tgt] = INTEGER(data)[src]; + } break; case REALSXP: From 4d29376ee1b6bdf3c73c175d76a783733695a335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 15 Sep 2021 10:01:21 +0200 Subject: [PATCH 4/5] DbResult::close() --- src/DbResult.cpp | 5 +++++ src/DbResult.h | 2 ++ src/PqResultImpl.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/DbResult.cpp b/src/DbResult.cpp index 7278beb6..b6a376fe 100644 --- a/src/DbResult.cpp +++ b/src/DbResult.cpp @@ -65,6 +65,11 @@ List DbResult::get_column_info() { return out; } +void DbResult::close() { + // Called from destructor + if (impl) impl->close(); +} + // Privates /////////////////////////////////////////////////////////////////// void DbResult::validate_params(const List& params) const { diff --git a/src/DbResult.h b/src/DbResult.h index d469f3fe..f6d63717 100644 --- a/src/DbResult.h +++ b/src/DbResult.h @@ -26,6 +26,8 @@ class DbResult : boost::noncopyable { ~DbResult(); public: + void close(); + bool complete() const; bool is_active() const; int n_rows_fetched(); diff --git a/src/PqResultImpl.h b/src/PqResultImpl.h index 007ec4d9..47b0ec39 100644 --- a/src/PqResultImpl.h +++ b/src/PqResultImpl.h @@ -54,6 +54,7 @@ class PqResultImpl : boost::noncopyable, public PqResultSource { void init(bool params_have_rows); public: + void close() {} // FIXME bool complete() const; int n_rows_fetched(); int n_rows_affected(); From 666b23d147c3bfc2d68e45d8dae692063fccf235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Wed, 15 Sep 2021 10:15:27 +0200 Subject: [PATCH 5/5] Listen to R_PLOGR_ENABLE environment variable --- configure | 15 ++++++++++----- src/Makevars.in | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/configure b/configure index e2fa9633..6a02c470 100755 --- a/configure +++ b/configure @@ -94,14 +94,19 @@ elif [ `uname` = "Darwin" ]; then fi fi -# Find compiler -CC=`${R_HOME}/bin/R CMD config CC` -CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` -CPPFLAGS=`${R_HOME}/bin/R CMD config CPPFLAGS` +if [ "$R_PLOGR_ENABLE" ]; then + PKG_PLOGR=-DPLOGR_ENABLE +fi # For debugging echo "Using PKG_CFLAGS=$PKG_CFLAGS" echo "Using PKG_LIBS=$PKG_LIBS" +echo "Using PKG_PLOGR=$PKG_PLOGR" + +# Find compiler +CC=`${R_HOME}/bin/R CMD config CC` +CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` +CPPFLAGS=`${R_HOME}/bin/R CMD config CPPFLAGS` # Test configuration echo "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2> configure.log @@ -130,7 +135,7 @@ fi # Write to Makevars echo "# Generated from Makevars.in, do not edit by hand" > src/Makevars.new -sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in >> src/Makevars.new +sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@plogr@|$PKG_PLOGR|" src/Makevars.in >> src/Makevars.new if [ ! -f src/Makevars ] || (which diff > /dev/null && ! diff -q src/Makevars src/Makevars.new); then cp -f src/Makevars.new src/Makevars fi diff --git a/src/Makevars.in b/src/Makevars.in index 796ff9f6..997f0450 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,4 +1,4 @@ -PKG_CPPFLAGS=@cflags@ -Ivendor -DRCPP_DEFAULT_INCLUDE_CALL=false -DRCPP_USING_UTF8_ERROR_STRING -DBOOST_NO_AUTO_PTR +PKG_CPPFLAGS=@cflags@ -Ivendor -DRCPP_DEFAULT_INCLUDE_CALL=false -DRCPP_USING_UTF8_ERROR_STRING -DBOOST_NO_AUTO_PTR @plogr@ PKG_CFLAGS=$(C_VISIBILITY) PKG_CXXFLAGS=$(CXX_VISIBILITY)