Skip to content

Commit

Permalink
fix: Fix rchk errors
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 8, 2024
1 parent d245c35 commit 1ade54e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- Fix installation of extensions (#623).

- Fix rchk errors (#635).
- Fix rchk and UB errors (#635).

- Avoid loading rlang during startup (#601).

Expand Down Expand Up @@ -742,7 +742,7 @@ Major changes:
- #440 Builds on Solaris & OpenBSD


*Note*: This release contains a bug in the Python API that leads to crashes when fetching strings to NumPy/Pandas #447
*Note*: This release contains a bug in the Python API that leads to crashes when fetching strings to NumPy/Pandas #447


# duckdb 0.1.3
Expand All @@ -756,7 +756,7 @@ Major changes:
* #390 Unused Column & Column Lifetime Optimizers
* #402 String and compound keys in indices/primary keys
* #406 Adaptive reordering of filter expressions



# duckdb 0.1.2
Expand Down
10 changes: 7 additions & 3 deletions src/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ static cpp11::list construct_retlist(duckdb::unique_ptr<PreparedStatement> stmt,
stmt->parameters[param_idx] = val;
}

// No protection, assigned immediately
out.push_back(rapi_execute(stmt, arrow, integer64));
// Protection error is flagged by rchk
cpp11::sexp res = rapi_execute(stmt, arrow, integer64);
out.push_back(res);
}

return out;
Expand Down Expand Up @@ -377,7 +378,10 @@ bool FetchArrowChunk(ChunkScanState &scan_state, ClientProperties options, Appen
} else {
D_ASSERT(generic_result->type == QueryResultType::MATERIALIZED_RESULT);
auto result = (MaterializedQueryResult *)generic_result.get();
return duckdb_execute_R_impl(result, integer64);

// Avoid rchk warning, it sees QueryResult::~QueryResult() as an allocating function
cpp11::sexp out = duckdb_execute_R_impl(result, integer64);
return out;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,15 @@ RType RApiTypes::DetectRType(SEXP v, bool integer64) {
if (Rf_inherits(v, "data.frame")) {
child_list_t<RType> child_types;
R_xlen_t ncol = Rf_length(v);
SEXP names = GET_NAMES(v);

cpp11::strings names = GET_NAMES(v);
for (R_xlen_t i = 0; i < ncol; ++i) {
RType child = DetectRType(VECTOR_ELT(v, i), integer64);
if (child == RType::UNKNOWN) {
return (RType::UNKNOWN);
}
child_types.push_back(std::make_pair(CHAR(STRING_ELT(names, i)), child));

child_types.push_back(std::make_pair(CHAR(names[i]), child));
}

return RType::STRUCT(std::move(child_types));
Expand Down

0 comments on commit 1ade54e

Please sign in to comment.