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 b5799e9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pgduckdb_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,11 @@ 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, CStringGetDatum(value_str.c_str()), ObjectIdGetDatum(InvalidOid), Int32GetDatum(-1)));
return pg_numeric;
}

Expand Down

0 comments on commit b5799e9

Please sign in to comment.