Skip to content

Commit

Permalink
Merge pull request r-dbi#335 from r-dbi/f-src-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Sep 15, 2021
2 parents a31920c + 666b23d commit 421504a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 53 deletions.
15 changes: 10 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 23 additions & 3 deletions src/DbColumnStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -276,19 +281,34 @@ 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;

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:
Expand Down
5 changes: 5 additions & 0 deletions src/DbResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/DbResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class DbResult : boost::noncopyable {
~DbResult();

public:
void close();

bool complete() const;
bool is_active() const;
int n_rows_fetched();
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/PqResultImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/result.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "pch.h"
#include "workarounds/XPtr.h"
#include "RPostgres_types.h"
#include "PqResult.h"

Expand Down
43 changes: 0 additions & 43 deletions src/workarounds/XPtr.h

This file was deleted.

0 comments on commit 421504a

Please sign in to comment.