I noticed a small gap in our recent addition of default arguments for functions in pg_proc.dat - it chokes if you try to set the default for a VARIADIC "any" argument. But there's no need if the default argument us NULL, as it often is. We don't need the argument's type_io_data etc. in such a case. So this patch just handles NULL without fetching any type info.
cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com
From 9cfc67d8e326be7bc40287a016295ff3d681a348 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan <[email protected]> Date: Fri, 6 Mar 2026 09:53:23 -0500 Subject: [PATCH 1/2] Allow NULL defaults for pseudo-type parameters in pg_proc.dat InsertOneProargdefaultsValue() called boot_get_type_io_data() for every default value entry, including NULLs. This failed for pseudo-types like "any" that have no entry in the bootstrap TypInfo[] array, even though NULL defaults never need a type input function. Move the boot_get_type_io_data() call inside the non-null branch, so that NULL defaults can be specified for any type directly in pg_proc.dat without needing a system_functions.sql wrapper. --- src/backend/bootstrap/bootstrap.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index e7699be55aa..c95b417c63e 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -772,19 +772,29 @@ InsertOneProargdefaultsValue(char *value) bool defnull; Const *defConst; - boot_get_type_io_data(argtype, - &typlen, &typbyval, &typalign, - &typdelim, &typioparam, - &typinput, &typoutput, - &typcollation); - defnull = array_nulls[i]; if (defnull) + { + /* + * For NULL defaults we don't need the type's I/O functions, so + * we can handle types like "any" that aren't in TypInfo[]. + */ defval = (Datum) 0; + typlen = -1; + typbyval = false; + typcollation = InvalidOid; + } else + { + boot_get_type_io_data(argtype, + &typlen, &typbyval, &typalign, + &typdelim, &typioparam, + &typinput, &typoutput, + &typcollation); defval = OidInputFunctionCall(typinput, DatumGetCString(array_datums[i]), typioparam, -1); + } defConst = makeConst(argtype, -1, /* never any typmod */ -- 2.43.0
