From 1301ed74bd805816c22650a01504260ef6531538 Mon Sep 17 00:00:00 2001 From: Vladimir Rachkin Date: Wed, 27 Nov 2024 15:53:23 +0300 Subject: [PATCH] Add defaults for try_convert --- contrib/try_convert/try_convert.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/try_convert/try_convert.c b/contrib/try_convert/try_convert.c index 4b89aee648..b9fd8cac8f 100644 --- a/contrib/try_convert/try_convert.c +++ b/contrib/try_convert/try_convert.c @@ -97,8 +97,6 @@ try_convert_via_io(Datum value, Oid sourceTypeId, Oid targetTypeId, bool *is_nul } -// NO NULL INPUTS!!!! - Datum try_convert(PG_FUNCTION_ARGS) { @@ -130,7 +128,11 @@ try_convert(PG_FUNCTION_ARGS) is_null = fcinfo->isnull; res = try_convert_via_io(value, sourceTypeId, targetTypeId, &is_null); } - - fcinfo->isnull = is_null; + + if (is_null) { + fcinfo->isnull = fcinfo->argnull[1]; + res = fcinfo->arg[1]; + } + return res; } \ No newline at end of file