diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index dd7418a4fc1..6790663f04d 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -971,11 +971,21 @@ postquel_sub_params(SQLFunctionCachePtr fcache, * because of possible function inlining during planning.) */ prm->isnull = fcinfo->args[i].isnull; - prm->value = MakeExpandedObjectReadOnly(fcinfo->args[i].value, + if (i >= fcache->pinfo->nargs) + { + prm->value = MakeExpandedObjectReadOnly(fcinfo->args[i].value, + prm->isnull, + get_typlen(0)); + prm->ptype = 0; + } + else + { + prm->value = MakeExpandedObjectReadOnly(fcinfo->args[i].value, prm->isnull, get_typlen(argtypes[i])); + prm->ptype = argtypes[i]; + } prm->pflags = 0; - prm->ptype = argtypes[i]; } } else