Skip to content

Commit

Permalink
add function guard
Browse files Browse the repository at this point in the history
  • Loading branch information
dentiny committed Feb 26, 2025
1 parent f8eb069 commit e3a22bb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pgduckdb_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,12 @@ ConvertNumericDatum(const duckdb::Value &value) {

// Special handle duckdb VARINT type.
if (value.type().id() == duckdb::LogicalTypeId::VARINT) {
std::string value_str = value.ToString();
Datum pg_numeric = DirectFunctionCall3(numeric_in, CStringGetDatum(value_str.c_str()),
ObjectIdGetDatum(InvalidOid), Int32GetDatum(-1));
// The performant way to handle the translation is to parse VARINT out, here we leverage string conversion and
// parsing mainly for code simplicity.
const std::string value_str = value.ToString();
const Datum pg_numeric = PostgresFunctionGuard(
DirectFunctionCall3(numeric_in, /*str=*/CStringGetDatum(value_str.c_str()),
/*typelem=*/ObjectIdGetDatum(InvalidOid), /*typmod=*/Int32GetDatum(-1)));
return pg_numeric;
}

Expand Down

0 comments on commit e3a22bb

Please sign in to comment.