diff --git a/src/pgduckdb_types.cpp b/src/pgduckdb_types.cpp index 0576087..14e3e88 100644 --- a/src/pgduckdb_types.cpp +++ b/src/pgduckdb_types.cpp @@ -340,9 +340,11 @@ ConvertNumericDatum(const duckdb::Value &value) { // Special handle duckdb VARINT type. if (value.type().id() == duckdb::LogicalTypeId::VARINT) { + // The performant way to handle the translation is to parse VARINT out, here we leverage string conversion and + // parsing mainly for code simplicity. std::string value_str = value.ToString(); - Datum pg_numeric = DirectFunctionCall3(numeric_in, CStringGetDatum(value_str.c_str()), - ObjectIdGetDatum(InvalidOid), Int32GetDatum(-1)); + Datum pg_numeric = PostgresFunctionGuard(DirectFunctionCall3(numeric_in, CStringGetDatum(value_str.c_str()), + ObjectIdGetDatum(InvalidOid), Int32GetDatum(-1))); return pg_numeric; }