From b5799e905b32d98f38feeadf62c5e8c50fb74c1a Mon Sep 17 00:00:00 2001 From: dentiny Date: Wed, 26 Feb 2025 13:12:40 +0000 Subject: [PATCH] add function guard --- src/pgduckdb_types.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pgduckdb_types.cpp b/src/pgduckdb_types.cpp index 0576087..905ece8 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) { - 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; }