Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsA0z-008hE7-22 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 01:36:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsA0x-0078Rl-1F for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 01:36:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsA0w-0078Ra-2i for pgsql-hackers@lists.postgresql.org; Tue, 17 Feb 2026 01:36:35 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vsA0s-00000000yv1-49q1 for pgsql-hackers@postgresql.org; Tue, 17 Feb 2026 01:36:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 61H1aPcs1288024; Mon, 16 Feb 2026 20:36:25 -0500 From: Tom Lane To: Andrew Dunstan cc: Andres Freund , PostgreSQL-development Subject: Re: generating function default settings from pg_proc.dat In-reply-to: <1185287.1771278396@sss.pgh.pa.us> References: <183292bb-4891-4c96-a3ca-e78b5e0e1358@dunslane.net> <1166845.1771269225@sss.pgh.pa.us> <1172935.1771272123@sss.pgh.pa.us> <4bb703bc-833f-4b53-a313-ae0b72afe2a5@dunslane.net> <1185287.1771278396@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 16 Feb 2026 16:46:36 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1288005.1771292176.0@sss.pgh.pa.us> Date: Mon, 16 Feb 2026 20:36:25 -0500 Message-ID: <1288023.1771292185@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1288005.1771292176.1@sss.pgh.pa.us> I wrote: > After a little bit of thought, I propose the following sketch > for what to do in the bootstrap backend: Here is a draft patch along those lines. I've verified that the initial contents of pg_proc are exactly as before, except that json[b]_strip_nulls gain the correct provolatile value, and a few proargdefaults entries no longer involve cast functions. The changes in system_functions.sql and pg_proc.dat are nearly verbatim from your 0002 patch, except that I had to adjust the quoting conventions in some places because array_in does it differently. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="0001-fill-proargdefaults-during-bootstrap.patch"; charset="us-ascii" Content-ID: <1288005.1771292176.2@sss.pgh.pa.us> Content-Description: 0001-fill-proargdefaults-during-bootstrap.patch Content-Transfer-Encoding: quoted-printable diff --git a/doc/src/sgml/bki.sgml b/doc/src/sgml/bki.sgml index 53a982bf60d..0747db98fc0 100644 --- a/doc/src/sgml/bki.sgml +++ b/doc/src/sgml/bki.sgml @@ -271,6 +271,21 @@ = + + + There is a special case for values of the + pg_proc.proargdefaults + field, which is of type pg_node_tree. The real + contents of that type are too complex for hand-written entries, + but what we need for proargdefaults is + typically just a list of Const nodes. Therefore, the bootstrap + backend will interpret a value given for that field according to + text array syntax, and then feed the array element values to the + datatype input routines for the corresponding input parameters' dat= a + types, and finally build Const nodes from the datums. + + + Since hashes are unordered data structures, field order and line @@ -817,8 +832,10 @@ $ perl rewrite_dat_with_prokind.pl pg_proc.dat The following column types are supported directly by bootstrap.c: bool, bytea, char (1 byte), - name, int2, - int4, regproc, regclass, + int2, int4, int8, + float4, float8, + name, + regproc, regclass, regtype, text, oid, tid, xid, cid, int2vector, oidvector, @@ -884,7 +901,7 @@ $ perl rewrite_dat_with_prokind.pl pg_proc.dat = - insert ( oid_value value1 valu= e2 ... ) + insert ( value1 value2 ... ) = @@ -902,6 +919,13 @@ $ perl rewrite_dat_with_prokind.pl pg_proc.dat (To include a single quote in a value, write it twice. Escape-string-style backslash escapes are allowed in the string, to= o.) + + + In most cases a value + string is simply fed to the datatype input routine for the column's + data type, after de-quoting if needed. However there are exception= s + for certain fields, as detailed previously. + = diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/boo= tstrap.c index 7d32cd0e159..36a3a9f774c 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -26,6 +26,7 @@ #include "bootstrap/bootstrap.h" #include "catalog/index.h" #include "catalog/pg_collation.h" +#include "catalog/pg_proc.h" #include "catalog/pg_type.h" #include "common/link-canary.h" #include "miscadmin.h" @@ -45,7 +46,9 @@ = static void CheckerModeMain(void); static void bootstrap_signals(void); +static Oid boot_get_typcollation(Oid typid); static Form_pg_attribute AllocateAttribute(void); +static Datum ConvertOneProargdefaultsValue(char *value); static void populate_typ_list(void); static Oid gettype(char *type); static void cleanup(void); @@ -95,8 +98,12 @@ static const struct typinfo TypInfo[] =3D { F_INT2IN, F_INT2OUT}, {"int4", INT4OID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid= , F_INT4IN, F_INT4OUT}, + {"int8", INT8OID, 0, 8, true, TYPALIGN_DOUBLE, TYPSTORAGE_PLAIN, Invalid= Oid, + F_INT8IN, F_INT8OUT}, {"float4", FLOAT4OID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, Invali= dOid, F_FLOAT4IN, F_FLOAT4OUT}, + {"float8", FLOAT8OID, 0, 8, true, TYPALIGN_DOUBLE, TYPSTORAGE_PLAIN, Inv= alidOid, + F_FLOAT8IN, F_FLOAT8OUT}, {"name", NAMEOID, CHAROID, NAMEDATALEN, false, TYPALIGN_CHAR, TYPSTORAGE= _PLAIN, C_COLLATION_OID, F_NAMEIN, F_NAMEOUT}, {"regclass", REGCLASSOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, In= validOid, @@ -123,6 +130,8 @@ static const struct typinfo TypInfo[] =3D { F_XIDIN, F_XIDOUT}, {"cid", CIDOID, 0, 4, true, TYPALIGN_INT, TYPSTORAGE_PLAIN, InvalidOid, F_CIDIN, F_CIDOUT}, + {"jsonb", JSONBOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, Inv= alidOid, + F_JSONB_IN, F_JSONB_OUT}, {"pg_node_tree", PG_NODE_TREEOID, 0, -1, false, TYPALIGN_INT, TYPSTORAGE= _EXTENDED, DEFAULT_COLLATION_OID, F_PG_NODE_TREE_IN, F_PG_NODE_TREE_OUT}, {"int2vector", INT2VECTOROID, INT2OID, -1, false, TYPALIGN_INT, TYPSTORA= GE_PLAIN, InvalidOid, @@ -673,14 +682,32 @@ InsertOneValue(char *value, int i) = elog(DEBUG4, "inserting column %d value \"%s\"", i, value); = - typoid =3D TupleDescAttr(boot_reldesc->rd_att, i)->atttypid; + typoid =3D TupleDescAttr(RelationGetDescr(boot_reldesc), i)->atttypid; = boot_get_type_io_data(typoid, &typlen, &typbyval, &typalign, &typdelim, &typioparam, &typinput, &typoutput); = - values[i] =3D OidInputFunctionCall(typinput, value, typioparam, -1); + /* + * pg_node_tree values can't be inserted normally (pg_node_tree_in would + * just error out), so provide special cases for such columns that we + * would like to fill during bootstrap. + */ + if (typoid =3D=3D PG_NODE_TREEOID) + { + /* pg_proc.proargdefaults */ + if (RelationGetRelid(boot_reldesc) =3D=3D ProcedureRelationId && + i =3D=3D Anum_pg_proc_proargdefaults - 1) + values[i] =3D ConvertOneProargdefaultsValue(value); + else /* maybe other cases later */ + elog(ERROR, "can't handle pg_node_tree input"); + } + else + { + /* Normal case */ + values[i] =3D OidInputFunctionCall(typinput, value, typioparam, -1); + } = /* * We use ereport not elog here so that parameters aren't evaluated unle= ss @@ -691,6 +718,110 @@ InsertOneValue(char *value, int i) OidOutputFunctionCall(typoutput, values[i])))); } = +/* ---------------- + * ConvertOneProargdefaultsValue + * + * In general, proargdefaults can be a list of any expressions, but + * for bootstrap we only support a list of Const nodes. The input + * has the form of a text array, and we feed non-null elements to the + * typinput functions for the appropriate parameters. + * ---------------- + */ +static Datum +ConvertOneProargdefaultsValue(char *value) +{ + int pronargs; + oidvector *proargtypes; + Datum arrayval; + Datum *array_datums; + bool *array_nulls; + int array_count; + List *proargdefaults; + + /* The pg_proc columns we need to use must have been filled already */ + StaticAssertDecl(Anum_pg_proc_pronargs < Anum_pg_proc_proargdefaults, + "pronargs must come before proargdefaults"); + StaticAssertDecl(Anum_pg_proc_pronargdefaults < Anum_pg_proc_proargdefau= lts, + "pronargdefaults must come before proargdefaults"); + StaticAssertDecl(Anum_pg_proc_proargtypes < Anum_pg_proc_proargdefaults, + "proargtypes must come before proargdefaults"); + if (Nulls[Anum_pg_proc_pronargs - 1]) + elog(ERROR, "pronargs must not be null"); + if (Nulls[Anum_pg_proc_proargtypes - 1]) + elog(ERROR, "proargtypes must not be null"); + pronargs =3D DatumGetInt16(values[Anum_pg_proc_pronargs - 1]); + proargtypes =3D DatumGetPointer(values[Anum_pg_proc_proargtypes - 1]); + Assert(pronargs =3D=3D proargtypes->dim1); + + /* Parse the input string as a text[] value, then deconstruct to Datums = */ + arrayval =3D OidFunctionCall3(F_ARRAY_IN, + CStringGetDatum(value), + ObjectIdGetDatum(TEXTOID), + Int32GetDatum(-1)); + deconstruct_array_builtin(DatumGetArrayTypeP(arrayval), TEXTOID, + &array_datums, &array_nulls, &array_count); + + /* The values should correspond to the last N argtypes */ + if (array_count > pronargs) + elog(ERROR, "too many proargdefaults entries"); + + /* Build the List of Const nodes */ + proargdefaults =3D NIL; + for (int i =3D 0; i < array_count; i++) + { + Oid argtype =3D proargtypes->values[pronargs - array_count + i]; + int16 typlen; + bool typbyval; + char typalign; + char typdelim; + Oid typioparam; + Oid typinput; + Oid typoutput; + Oid typcollation; + Datum defval; + bool defnull; + Const *defConst; + + boot_get_type_io_data(argtype, + &typlen, &typbyval, &typalign, + &typdelim, &typioparam, + &typinput, &typoutput); + typcollation =3D boot_get_typcollation(argtype); + + defnull =3D array_nulls[i]; + if (defnull) + defval =3D (Datum) 0; + else + { + char *defstr =3D text_to_cstring(DatumGetTextPP(array_datums[i])); + + defval =3D OidInputFunctionCall(typinput, defstr, typioparam, -1); + } + + defConst =3D makeConst(argtype, + -1, /* never any typmod */ + typcollation, + typlen, + defval, + defnull, + typbyval); + proargdefaults =3D lappend(proargdefaults, defConst); + } + + /* + * Hack: fill in pronargdefaults with the right value. This is surely + * ugly, but it beats making the programmer do it. + */ + values[Anum_pg_proc_pronargdefaults - 1] =3D Int16GetDatum(array_count); + Nulls[Anum_pg_proc_pronargdefaults - 1] =3D false; + + /* + * Flatten the List to a node-tree string, then convert to a text datum, + * which is the storage representation of pg_node_tree. + */ + return CStringGetTextDatum(nodeToString(proargdefaults)); +} + /* ---------------- * InsertOneNull * ---------------- @@ -907,6 +1038,53 @@ boot_get_type_io_data(Oid typid, } } = +/* ---------------- + * boot_get_typcollation + * + * Obtain type's collation at bootstrap time. This intentionally has + * the same API as lsyscache.c's get_typcollation. + * + * XXX would it be better to add another output to boot_get_type_io_data? + * ---------------- + */ +static Oid +boot_get_typcollation(Oid typid) +{ + if (Typ !=3D NIL) + { + /* We have the boot-time contents of pg_type, so use it */ + struct typmap *ap =3D NULL; + ListCell *lc; + + foreach(lc, Typ) + { + ap =3D lfirst(lc); + if (ap->am_oid =3D=3D typid) + break; + } + + if (!ap || ap->am_oid !=3D typid) + elog(ERROR, "type OID %u not found in Typ list", typid); + + return ap->am_typ.typcollation; + } + else + { + /* We don't have pg_type yet, so use the hard-wired TypInfo array */ + int typeindex; + + for (typeindex =3D 0; typeindex < n_types; typeindex++) + { + if (TypInfo[typeindex].oid =3D=3D typid) + break; + } + if (typeindex >=3D n_types) + elog(ERROR, "type OID %u not found in TypInfo", typid); + + return TypInfo[typeindex].collation; + } +} + /* ---------------- * AllocateAttribute * diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalo= g/system_functions.sql index eb9e31ae1bf..4c20bb380a4 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -7,7 +7,7 @@ * * This file redefines certain built-in functions that are impractical * to fully define in pg_proc.dat. In most cases that's because they use - * SQL-standard function bodies and/or default expressions. The node + * SQL-standard function bodies. The node * tree representations of those are too unreadable, platform-dependent, * and changeable to want to deal with them manually. Hence, we put stub * definitions of such functions into pg_proc.dat and then replace them @@ -66,13 +66,6 @@ CREATE OR REPLACE FUNCTION bit_length(text) IMMUTABLE PARALLEL SAFE STRICT COST 1 RETURN octet_length($1) * 8; = -CREATE OR REPLACE FUNCTION - random_normal(mean float8 DEFAULT 0, stddev float8 DEFAULT 1) - RETURNS float8 - LANGUAGE internal - VOLATILE PARALLEL RESTRICTED STRICT COST 1 -AS 'drandom_normal'; - CREATE OR REPLACE FUNCTION log(numeric) RETURNS numeric LANGUAGE sql @@ -382,281 +375,6 @@ CREATE OR REPLACE FUNCTION ts_debug(document text, BEGIN ATOMIC SELECT * FROM ts_debug(get_current_ts_config(), $1); END; - -CREATE OR REPLACE FUNCTION - pg_backup_start(label text, fast boolean DEFAULT false) - RETURNS pg_lsn STRICT VOLATILE LANGUAGE internal AS 'pg_backup_start' - PARALLEL RESTRICTED; - -CREATE OR REPLACE FUNCTION pg_backup_stop ( - wait_for_archive boolean DEFAULT true, OUT lsn pg_lsn, - OUT labelfile text, OUT spcmapfile text) - RETURNS record STRICT VOLATILE LANGUAGE internal as 'pg_backup_stop' - PARALLEL RESTRICTED; - -CREATE OR REPLACE FUNCTION - pg_promote(wait boolean DEFAULT true, wait_seconds integer DEFAULT 60) - RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_promote' - PARALLEL SAFE; - -CREATE OR REPLACE FUNCTION - pg_terminate_backend(pid integer, timeout int8 DEFAULT 0) - RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_terminate_back= end' - PARALLEL SAFE; - --- legacy definition for compatibility with 9.3 -CREATE OR REPLACE FUNCTION - json_populate_record(base anyelement, from_json json, use_json_as_text = boolean DEFAULT false) - RETURNS anyelement LANGUAGE internal STABLE AS 'json_populate_record' P= ARALLEL SAFE; - --- legacy definition for compatibility with 9.3 -CREATE OR REPLACE FUNCTION - json_populate_recordset(base anyelement, from_json json, use_json_as_te= xt boolean DEFAULT false) - RETURNS SETOF anyelement LANGUAGE internal STABLE ROWS 100 AS 'json_po= pulate_recordset' PARALLEL SAFE; - -CREATE OR REPLACE FUNCTION pg_logical_slot_get_changes( - IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC= options text[] DEFAULT '{}', - OUT lsn pg_lsn, OUT xid xid, OUT data text) -RETURNS SETOF RECORD -LANGUAGE INTERNAL -VOLATILE ROWS 1000 COST 1000 -AS 'pg_logical_slot_get_changes'; - -CREATE OR REPLACE FUNCTION pg_logical_slot_peek_changes( - IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC= options text[] DEFAULT '{}', - OUT lsn pg_lsn, OUT xid xid, OUT data text) -RETURNS SETOF RECORD -LANGUAGE INTERNAL -VOLATILE ROWS 1000 COST 1000 -AS 'pg_logical_slot_peek_changes'; - -CREATE OR REPLACE FUNCTION pg_logical_slot_get_binary_changes( - IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC= options text[] DEFAULT '{}', - OUT lsn pg_lsn, OUT xid xid, OUT data bytea) -RETURNS SETOF RECORD -LANGUAGE INTERNAL -VOLATILE ROWS 1000 COST 1000 -AS 'pg_logical_slot_get_binary_changes'; - -CREATE OR REPLACE FUNCTION pg_logical_slot_peek_binary_changes( - IN slot_name name, IN upto_lsn pg_lsn, IN upto_nchanges int, VARIADIC= options text[] DEFAULT '{}', - OUT lsn pg_lsn, OUT xid xid, OUT data bytea) -RETURNS SETOF RECORD -LANGUAGE INTERNAL -VOLATILE ROWS 1000 COST 1000 -AS 'pg_logical_slot_peek_binary_changes'; - -CREATE OR REPLACE FUNCTION pg_logical_emit_message( - transactional boolean, - prefix text, - message text, - flush boolean DEFAULT false) -RETURNS pg_lsn -LANGUAGE INTERNAL -STRICT VOLATILE -AS 'pg_logical_emit_message_text'; - -CREATE OR REPLACE FUNCTION pg_logical_emit_message( - transactional boolean, - prefix text, - message bytea, - flush boolean DEFAULT false) -RETURNS pg_lsn -LANGUAGE INTERNAL -STRICT VOLATILE -AS 'pg_logical_emit_message_bytea'; - -CREATE OR REPLACE FUNCTION pg_create_physical_replication_slot( - IN slot_name name, IN immediately_reserve boolean DEFAULT false, - IN temporary boolean DEFAULT false, - OUT slot_name name, OUT lsn pg_lsn) -RETURNS RECORD -LANGUAGE INTERNAL -STRICT VOLATILE -AS 'pg_create_physical_replication_slot'; - -CREATE OR REPLACE FUNCTION pg_create_logical_replication_slot( - IN slot_name name, IN plugin name, - IN temporary boolean DEFAULT false, - IN twophase boolean DEFAULT false, - IN failover boolean DEFAULT false, - OUT slot_name name, OUT lsn pg_lsn) -RETURNS RECORD -LANGUAGE INTERNAL -STRICT VOLATILE -AS 'pg_create_logical_replication_slot'; - -CREATE OR REPLACE FUNCTION - make_interval(years int4 DEFAULT 0, months int4 DEFAULT 0, weeks int4 D= EFAULT 0, - days int4 DEFAULT 0, hours int4 DEFAULT 0, mins int4 DEFA= ULT 0, - secs double precision DEFAULT 0.0) -RETURNS interval -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'make_interval'; - -CREATE OR REPLACE FUNCTION - jsonb_set(jsonb_in jsonb, path text[] , replacement jsonb, - create_if_missing boolean DEFAULT true) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_set'; - -CREATE OR REPLACE FUNCTION - jsonb_set_lax(jsonb_in jsonb, path text[] , replacement jsonb, - create_if_missing boolean DEFAULT true, - null_value_treatment text DEFAULT 'use_json_null') -RETURNS jsonb -LANGUAGE INTERNAL -CALLED ON NULL INPUT IMMUTABLE PARALLEL SAFE -AS 'jsonb_set_lax'; - -CREATE OR REPLACE FUNCTION - parse_ident(str text, strict boolean DEFAULT true) -RETURNS text[] -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'parse_ident'; - -CREATE OR REPLACE FUNCTION - jsonb_insert(jsonb_in jsonb, path text[] , replacement jsonb, - insert_after boolean DEFAULT false) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_insert'; - -CREATE OR REPLACE FUNCTION - jsonb_path_exists(target jsonb, path jsonpath, vars jsonb DEFAULT '{}', - silent boolean DEFAULT false) -RETURNS boolean -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_path_exists'; - -CREATE OR REPLACE FUNCTION - jsonb_path_match(target jsonb, path jsonpath, vars jsonb DEFAULT '{}', - silent boolean DEFAULT false) -RETURNS boolean -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_path_match'; - -CREATE OR REPLACE FUNCTION - jsonb_path_query(target jsonb, path jsonpath, vars jsonb DEFAULT '{}', - silent boolean DEFAULT false) -RETURNS SETOF jsonb -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_path_query'; - -CREATE OR REPLACE FUNCTION - jsonb_path_query_array(target jsonb, path jsonpath, vars jsonb DEFAULT = '{}', - silent boolean DEFAULT false) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_path_query_array'; - -CREATE OR REPLACE FUNCTION - jsonb_path_query_first(target jsonb, path jsonpath, vars jsonb DEFAULT = '{}', - silent boolean DEFAULT false) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT IMMUTABLE PARALLEL SAFE -AS 'jsonb_path_query_first'; - -CREATE OR REPLACE FUNCTION - jsonb_path_exists_tz(target jsonb, path jsonpath, vars jsonb DEFAULT '{= }', - silent boolean DEFAULT false) -RETURNS boolean -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'jsonb_path_exists_tz'; - -CREATE OR REPLACE FUNCTION - jsonb_path_match_tz(target jsonb, path jsonpath, vars jsonb DEFAULT '{}= ', - silent boolean DEFAULT false) -RETURNS boolean -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'jsonb_path_match_tz'; - -CREATE OR REPLACE FUNCTION - jsonb_path_query_tz(target jsonb, path jsonpath, vars jsonb DEFAULT '{}= ', - silent boolean DEFAULT false) -RETURNS SETOF jsonb -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'jsonb_path_query_tz'; - -CREATE OR REPLACE FUNCTION - jsonb_path_query_array_tz(target jsonb, path jsonpath, vars jsonb DEFAU= LT '{}', - silent boolean DEFAULT false) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'jsonb_path_query_array_tz'; - -CREATE OR REPLACE FUNCTION - jsonb_path_query_first_tz(target jsonb, path jsonpath, vars jsonb DEFAU= LT '{}', - silent boolean DEFAULT false) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'jsonb_path_query_first_tz'; - -CREATE OR REPLACE FUNCTION - jsonb_strip_nulls(target jsonb, strip_in_arrays boolean DEFAULT false) -RETURNS jsonb -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'jsonb_strip_nulls'; - -CREATE OR REPLACE FUNCTION - json_strip_nulls(target json, strip_in_arrays boolean DEFAULT false) -RETURNS json -LANGUAGE INTERNAL -STRICT STABLE PARALLEL SAFE -AS 'json_strip_nulls'; - --- default normalization form is NFC, per SQL standard -CREATE OR REPLACE FUNCTION - "normalize"(text, text DEFAULT 'NFC') -RETURNS text -LANGUAGE internal -STRICT IMMUTABLE PARALLEL SAFE -AS 'unicode_normalize_func'; - -CREATE OR REPLACE FUNCTION - is_normalized(text, text DEFAULT 'NFC') -RETURNS boolean -LANGUAGE internal -STRICT IMMUTABLE PARALLEL SAFE -AS 'unicode_is_normalized'; - -CREATE OR REPLACE FUNCTION - pg_stat_reset_shared(target text DEFAULT NULL) -RETURNS void -LANGUAGE INTERNAL -CALLED ON NULL INPUT VOLATILE PARALLEL SAFE -AS 'pg_stat_reset_shared'; - -CREATE OR REPLACE FUNCTION - pg_stat_reset_slru(target text DEFAULT NULL) -RETURNS void -LANGUAGE INTERNAL -CALLED ON NULL INPUT VOLATILE PARALLEL SAFE -AS 'pg_stat_reset_slru'; - -CREATE OR REPLACE FUNCTION - pg_replication_origin_session_setup(node_name text, pid integer DEFAULT= 0) -RETURNS void -LANGUAGE INTERNAL -STRICT VOLATILE PARALLEL UNSAFE -AS 'pg_replication_origin_session_setup'; - -- -- The default permissions for functions mean that anyone can execute the= m. -- A number of functions shouldn't be executable by just anyone, but rath= er diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc= .dat index 83f6501df38..dac40992cbc 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -3499,6 +3499,7 @@ { oid =3D> '6212', descr =3D> 'random value from normal distribution', proname =3D> 'random_normal', provolatile =3D> 'v', proparallel =3D> 'r= ', prorettype =3D> 'float8', proargtypes =3D> 'float8 float8', + proargnames =3D> '{mean,stddev}', proargdefaults =3D> '{0,1}', prosrc =3D> 'drandom_normal' }, { oid =3D> '6339', descr =3D> 'random integer in range', proname =3D> 'random', provolatile =3D> 'v', proparallel =3D> 'r', @@ -6174,6 +6175,7 @@ descr =3D> 'statistics: reset collected statistics shared across the cl= uster', proname =3D> 'pg_stat_reset_shared', proisstrict =3D> 'f', provolatile = =3D> 'v', prorettype =3D> 'void', proargtypes =3D> 'text', + proargnames =3D> '{target}', proargdefaults =3D> '{NULL}', prosrc =3D> 'pg_stat_reset_shared' }, { oid =3D> '3776', descr =3D> 'statistics: reset collected statistics for a single table o= r index in the current database or shared across all databases in the clus= ter', @@ -6193,6 +6195,7 @@ descr =3D> 'statistics: reset collected statistics for a single SLRU', proname =3D> 'pg_stat_reset_slru', proisstrict =3D> 'f', provolatile =3D= > 'v', prorettype =3D> 'void', proargtypes =3D> 'text', proargnames =3D> '{tar= get}', + proargdefaults =3D> '{NULL}', prosrc =3D> 'pg_stat_reset_slru' }, { oid =3D> '6170', descr =3D> 'statistics: reset collected statistics for a single replica= tion slot', @@ -6728,20 +6731,24 @@ { oid =3D> '2096', descr =3D> 'terminate a server process', proname =3D> 'pg_terminate_backend', provolatile =3D> 'v', prorettype =3D= > 'bool', proargtypes =3D> 'int4 int8', proargnames =3D> '{pid,timeout}', + proargdefaults =3D> '{0}', prosrc =3D> 'pg_terminate_backend' }, { oid =3D> '2172', descr =3D> 'prepare for taking an online backup', proname =3D> 'pg_backup_start', provolatile =3D> 'v', proparallel =3D> = 'r', prorettype =3D> 'pg_lsn', proargtypes =3D> 'text bool', + proargnames =3D> '{label,fast}', proargdefaults =3D> '{false}', prosrc =3D> 'pg_backup_start' }, { oid =3D> '2739', descr =3D> 'finish taking an online backup', proname =3D> 'pg_backup_stop', provolatile =3D> 'v', proparallel =3D> '= r', prorettype =3D> 'record', proargtypes =3D> 'bool', proallargtypes =3D> '{bool,pg_lsn,text,text}', proargmodes =3D> '{i,o,o= ,o}', proargnames =3D> '{wait_for_archive,lsn,labelfile,spcmapfile}', + proargdefaults =3D> '{true}', prosrc =3D> 'pg_backup_stop' }, { oid =3D> '3436', descr =3D> 'promote standby server', proname =3D> 'pg_promote', provolatile =3D> 'v', prorettype =3D> 'bool'= , proargtypes =3D> 'bool int4', proargnames =3D> '{wait,wait_seconds}', + proargdefaults =3D> '{true,60}', prosrc =3D> 'pg_promote' }, { oid =3D> '2848', descr =3D> 'switch to new wal file', proname =3D> 'pg_switch_wal', provolatile =3D> 'v', prorettype =3D> 'pg= _lsn', @@ -7517,7 +7524,8 @@ { oid =3D> '1268', descr =3D> 'parse qualified identifier to array of identifiers', proname =3D> 'parse_ident', prorettype =3D> '_text', proargtypes =3D> '= text bool', - proargnames =3D> '{str,strict}', prosrc =3D> 'parse_ident' }, + proargnames =3D> '{str,strict}', proargdefaults =3D> '{true}', + prosrc =3D> 'parse_ident' }, = { oid =3D> '2246', descr =3D> '(internal)', proname =3D> 'fmgr_internal_validator', provolatile =3D> 's', @@ -9423,7 +9431,9 @@ proargtypes =3D> 'anyelement', prosrc =3D> 'to_json' }, { oid =3D> '3261', descr =3D> 'remove object fields with null values from= json', proname =3D> 'json_strip_nulls', prorettype =3D> 'json', - proargtypes =3D> 'json bool', prosrc =3D> 'json_strip_nulls' }, + proargtypes =3D> 'json bool', + proargnames =3D> '{target,strip_in_arrays}', proargdefaults =3D> '{fals= e}', + prosrc =3D> 'json_strip_nulls' }, = { oid =3D> '3947', proname =3D> 'json_object_field', prorettype =3D> 'json', @@ -9480,12 +9490,17 @@ { oid =3D> '3960', descr =3D> 'get record fields from a json object', proname =3D> 'json_populate_record', proisstrict =3D> 'f', provolatile = =3D> 's', prorettype =3D> 'anyelement', proargtypes =3D> 'anyelement json bool', + proargnames =3D> '{base,from_json,use_json_as_text}', + proargdefaults =3D> '{false}', prosrc =3D> 'json_populate_record' }, { oid =3D> '3961', descr =3D> 'get set of records with fields from a json array of objects= ', proname =3D> 'json_populate_recordset', prorows =3D> '100', proisstrict= =3D> 'f', proretset =3D> 't', provolatile =3D> 's', prorettype =3D> 'anyelement', - proargtypes =3D> 'anyelement json bool', prosrc =3D> 'json_populate_rec= ordset' }, + proargtypes =3D> 'anyelement json bool', + proargnames =3D> '{base,from_json,use_json_as_text}', + proargdefaults =3D> '{false}', + prosrc =3D> 'json_populate_recordset' }, { oid =3D> '3204', descr =3D> 'get record fields from a json object', proname =3D> 'json_to_record', provolatile =3D> 's', prorettype =3D> 'r= ecord', proargtypes =3D> 'json', prosrc =3D> 'json_to_record' }, @@ -10364,7 +10379,9 @@ prosrc =3D> 'jsonb_build_object_noargs' }, { oid =3D> '3262', descr =3D> 'remove object fields with null values from= jsonb', proname =3D> 'jsonb_strip_nulls', prorettype =3D> 'jsonb', - proargtypes =3D> 'jsonb bool', prosrc =3D> 'jsonb_strip_nulls' }, + proargtypes =3D> 'jsonb bool', + proargnames =3D> '{target,strip_in_arrays}', proargdefaults =3D> '{fals= e}', + prosrc =3D> 'jsonb_strip_nulls' }, = { oid =3D> '3478', proname =3D> 'jsonb_object_field', prorettype =3D> 'jsonb', @@ -10538,16 +10555,25 @@ proargtypes =3D> 'jsonb _text', prosrc =3D> 'jsonb_delete_path' }, { oid =3D> '5054', descr =3D> 'Set part of a jsonb, handle NULL value', proname =3D> 'jsonb_set_lax', proisstrict =3D> 'f', prorettype =3D> 'js= onb', - proargtypes =3D> 'jsonb _text jsonb bool text', prosrc =3D> 'jsonb_set_= lax' }, + proargtypes =3D> 'jsonb _text jsonb bool text', + proargnames =3D> '{jsonb_in,path,replacement,create_if_missing,null_val= ue_treatment}', + proargdefaults =3D> '{true,use_json_null}', + prosrc =3D> 'jsonb_set_lax' }, { oid =3D> '3305', descr =3D> 'Set part of a jsonb', proname =3D> 'jsonb_set', prorettype =3D> 'jsonb', - proargtypes =3D> 'jsonb _text jsonb bool', prosrc =3D> 'jsonb_set' }, + proargtypes =3D> 'jsonb _text jsonb bool', + proargnames =3D> '{jsonb_in,path,replacement,create_if_missing}', + proargdefaults =3D> '{true}', + prosrc =3D> 'jsonb_set' }, { oid =3D> '3306', descr =3D> 'Indented text from jsonb', proname =3D> 'jsonb_pretty', prorettype =3D> 'text', proargtypes =3D> '= jsonb', prosrc =3D> 'jsonb_pretty' }, { oid =3D> '3579', descr =3D> 'Insert value into a jsonb', proname =3D> 'jsonb_insert', prorettype =3D> 'jsonb', - proargtypes =3D> 'jsonb _text jsonb bool', prosrc =3D> 'jsonb_insert' }= , + proargtypes =3D> 'jsonb _text jsonb bool', + proargnames =3D> '{jsonb_in,path,replacement,insert_after}', + proargdefaults =3D> '{false}', + prosrc =3D> 'jsonb_insert' }, = # jsonpath { oid =3D> '4001', descr =3D> 'I/O', @@ -10565,42 +10591,66 @@ = { oid =3D> '4005', descr =3D> 'jsonpath exists test', proname =3D> 'jsonb_path_exists', prorettype =3D> 'bool', - proargtypes =3D> 'jsonb jsonpath jsonb bool', prosrc =3D> 'jsonb_path_e= xists' }, + proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', + prosrc =3D> 'jsonb_path_exists' }, { oid =3D> '4006', descr =3D> 'jsonpath query', proname =3D> 'jsonb_path_query', prorows =3D> '1000', proretset =3D> 't= ', prorettype =3D> 'jsonb', proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', prosrc =3D> 'jsonb_path_query' }, { oid =3D> '4007', descr =3D> 'jsonpath query wrapped into array', proname =3D> 'jsonb_path_query_array', prorettype =3D> 'jsonb', proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', prosrc =3D> 'jsonb_path_query_array' }, { oid =3D> '4008', descr =3D> 'jsonpath query first item', proname =3D> 'jsonb_path_query_first', prorettype =3D> 'jsonb', proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', prosrc =3D> 'jsonb_path_query_first' }, { oid =3D> '4009', descr =3D> 'jsonpath match', proname =3D> 'jsonb_path_match', prorettype =3D> 'bool', - proargtypes =3D> 'jsonb jsonpath jsonb bool', prosrc =3D> 'jsonb_path_m= atch' }, + proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', + prosrc =3D> 'jsonb_path_match' }, = { oid =3D> '1177', descr =3D> 'jsonpath exists test with timezone', proname =3D> 'jsonb_path_exists_tz', provolatile =3D> 's', prorettype =3D= > 'bool', proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', prosrc =3D> 'jsonb_path_exists_tz' }, { oid =3D> '1179', descr =3D> 'jsonpath query with timezone', proname =3D> 'jsonb_path_query_tz', prorows =3D> '1000', proretset =3D>= 't', provolatile =3D> 's', prorettype =3D> 'jsonb', - proargtypes =3D> 'jsonb jsonpath jsonb bool', prosrc =3D> 'jsonb_path_q= uery_tz' }, + proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', + prosrc =3D> 'jsonb_path_query_tz' }, { oid =3D> '1180', descr =3D> 'jsonpath query wrapped into array with tim= ezone', proname =3D> 'jsonb_path_query_array_tz', provolatile =3D> 's', prorettype =3D> 'jsonb', proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', prosrc =3D> 'jsonb_path_query_array_tz' }, { oid =3D> '2023', descr =3D> 'jsonpath query first item with timezone', proname =3D> 'jsonb_path_query_first_tz', provolatile =3D> 's', prorettype =3D> 'jsonb', proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', prosrc =3D> 'jsonb_path_query_first_tz' }, { oid =3D> '2030', descr =3D> 'jsonpath match with timezone', proname =3D> 'jsonb_path_match_tz', provolatile =3D> 's', prorettype =3D= > 'bool', - proargtypes =3D> 'jsonb jsonpath jsonb bool', prosrc =3D> 'jsonb_path_m= atch_tz' }, + proargtypes =3D> 'jsonb jsonpath jsonb bool', + proargnames =3D> '{target,path,vars,silent}', + proargdefaults =3D> '{"{}",false}', + prosrc =3D> 'jsonb_path_match_tz' }, = { oid =3D> '4010', descr =3D> 'implementation of @? operator', proname =3D> 'jsonb_path_exists_opr', prorettype =3D> 'bool', @@ -11411,6 +11461,7 @@ proname =3D> 'make_interval', prorettype =3D> 'interval', proargtypes =3D> 'int4 int4 int4 int4 int4 int4 float8', proargnames =3D> '{years,months,weeks,days,hours,mins,secs}', + proargdefaults =3D> '{0,0,0,0,0,0,0.0}', prosrc =3D> 'make_interval' }, = # spgist opclasses @@ -11511,6 +11562,7 @@ proallargtypes =3D> '{name,bool,bool,name,pg_lsn}', proargmodes =3D> '{i,i,i,o,o}', proargnames =3D> '{slot_name,immediately_reserve,temporary,slot_name,ls= n}', + proargdefaults =3D> '{false,false}', prosrc =3D> 'pg_create_physical_replication_slot' }, { oid =3D> '4220', descr =3D> 'copy a physical replication slot, changing temporality', @@ -11546,6 +11598,7 @@ proallargtypes =3D> '{name,name,bool,bool,bool,name,pg_lsn}', proargmodes =3D> '{i,i,i,i,i,o,o}', proargnames =3D> '{slot_name,plugin,temporary,twophase,failover,slot_na= me,lsn}', + proargdefaults =3D> '{false,false,false}', prosrc =3D> 'pg_create_logical_replication_slot' }, { oid =3D> '4222', descr =3D> 'copy a logical replication slot, changing temporality and p= lugin', @@ -11578,6 +11631,7 @@ proallargtypes =3D> '{name,pg_lsn,int4,_text,pg_lsn,xid,text}', proargmodes =3D> '{i,i,i,v,o,o,o}', proargnames =3D> '{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,dat= a}', + proargdefaults =3D> '{"{}"}', prosrc =3D> 'pg_logical_slot_get_changes' }, { oid =3D> '3783', descr =3D> 'get binary changes from replication slot', proname =3D> 'pg_logical_slot_get_binary_changes', procost =3D> '1000', @@ -11587,6 +11641,7 @@ proallargtypes =3D> '{name,pg_lsn,int4,_text,pg_lsn,xid,bytea}', proargmodes =3D> '{i,i,i,v,o,o,o}', proargnames =3D> '{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,dat= a}', + proargdefaults =3D> '{"{}"}', prosrc =3D> 'pg_logical_slot_get_binary_changes' }, { oid =3D> '3784', descr =3D> 'peek at changes from replication slot', proname =3D> 'pg_logical_slot_peek_changes', procost =3D> '1000', @@ -11596,6 +11651,7 @@ proallargtypes =3D> '{name,pg_lsn,int4,_text,pg_lsn,xid,text}', proargmodes =3D> '{i,i,i,v,o,o,o}', proargnames =3D> '{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,dat= a}', + proargdefaults =3D> '{"{}"}', prosrc =3D> 'pg_logical_slot_peek_changes' }, { oid =3D> '3785', descr =3D> 'peek at binary changes from replication sl= ot', proname =3D> 'pg_logical_slot_peek_binary_changes', procost =3D> '1000'= , @@ -11605,6 +11661,7 @@ proallargtypes =3D> '{name,pg_lsn,int4,_text,pg_lsn,xid,bytea}', proargmodes =3D> '{i,i,i,v,o,o,o}', proargnames =3D> '{slot_name,upto_lsn,upto_nchanges,options,lsn,xid,dat= a}', + proargdefaults =3D> '{"{}"}', prosrc =3D> 'pg_logical_slot_peek_binary_changes' }, { oid =3D> '3878', descr =3D> 'advance logical replication slot', proname =3D> 'pg_replication_slot_advance', provolatile =3D> 'v', @@ -11615,10 +11672,14 @@ { oid =3D> '3577', descr =3D> 'emit a textual logical decoding message', proname =3D> 'pg_logical_emit_message', provolatile =3D> 'v', proparall= el =3D> 'u', prorettype =3D> 'pg_lsn', proargtypes =3D> 'bool text text bool', + proargnames =3D> '{transactional,prefix,message,flush}', + proargdefaults =3D> '{false}', prosrc =3D> 'pg_logical_emit_message_text' }, { oid =3D> '3578', descr =3D> 'emit a binary logical decoding message', proname =3D> 'pg_logical_emit_message', provolatile =3D> 'v', proparall= el =3D> 'u', prorettype =3D> 'pg_lsn', proargtypes =3D> 'bool text bytea bool', + proargnames =3D> '{transactional,prefix,message,flush}', + proargdefaults =3D> '{false}', prosrc =3D> 'pg_logical_emit_message_bytea' }, { oid =3D> '6344', descr =3D> 'sync replication slots from the primary to the standby', @@ -12268,6 +12329,7 @@ descr =3D> 'configure session to maintain replication progress tracking= for the passed in origin', proname =3D> 'pg_replication_origin_session_setup', provolatile =3D> 'v= ', proparallel =3D> 'u', prorettype =3D> 'void', proargtypes =3D> 'text in= t4', + proargnames =3D> '{node_name,pid}', proargdefaults =3D> '{0}', prosrc =3D> 'pg_replication_origin_session_setup' }, = { oid =3D> '6007', descr =3D> 'teardown configured replication progress t= racking', @@ -12518,10 +12580,12 @@ = { oid =3D> '4350', descr =3D> 'Unicode normalization', proname =3D> 'normalize', prorettype =3D> 'text', proargtypes =3D> 'tex= t text', + proargdefaults =3D> '{NFC}', prosrc =3D> 'unicode_normalize_func' }, = { oid =3D> '4351', descr =3D> 'check Unicode normalization', proname =3D> 'is_normalized', prorettype =3D> 'bool', proargtypes =3D> = 'text text', + proargdefaults =3D> '{NFC}', prosrc =3D> 'unicode_is_normalized' }, = { oid =3D> '6198', descr =3D> 'unescape Unicode characters', ------- =_aaaaaaaaaa0--