Thread

  1. [PATCH v7 4/6] Handle pg_get_constraintdef default args in system_functions.sql

    Mark Wong <markwkm@gmail.com> — 2025-12-09T18:59:41Z

    Modernize pg_get_constraintdef to use proargdefaults to handle the
    optional pretty argument.
    ---
     src/backend/utils/adt/ruleutils.c | 17 -----------------
     src/include/catalog/pg_proc.dat   |  8 +++-----
     2 files changed, 3 insertions(+), 22 deletions(-)
    
    diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
    index 55926ec15e0..2d39bce7fd7 100644
    --- a/src/backend/utils/adt/ruleutils.c
    +++ b/src/backend/utils/adt/ruleutils.c
    @@ -2420,23 +2420,6 @@ pg_get_partconstrdef_string(Oid partitionId, char *aliasname)
      */
     Datum
     pg_get_constraintdef(PG_FUNCTION_ARGS)
    -{
    -	Oid			constraintId = PG_GETARG_OID(0);
    -	int			prettyFlags;
    -	char	   *res;
    -
    -	prettyFlags = PRETTYFLAG_INDENT;
    -
    -	res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true);
    -
    -	if (res == NULL)
    -		PG_RETURN_NULL();
    -
    -	PG_RETURN_TEXT_P(string_to_text(res));
    -}
    -
    -Datum
    -pg_get_constraintdef_ext(PG_FUNCTION_ARGS)
     {
     	Oid			constraintId = PG_GETARG_OID(0);
     	bool		pretty = PG_GETARG_BOOL(1);
    diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
    index dfedf5c2851..39139fd9e3b 100644
    --- a/src/include/catalog/pg_proc.dat
    +++ b/src/include/catalog/pg_proc.dat
    @@ -4006,9 +4006,6 @@
     { oid => '1662', descr => 'trigger description',
       proname => 'pg_get_triggerdef', provolatile => 's', prorettype => 'text',
       proargtypes => 'oid', prosrc => 'pg_get_triggerdef' },
    -{ oid => '1387', descr => 'constraint description',
    -  proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
    -  proargtypes => 'oid', prosrc => 'pg_get_constraintdef' },
     { oid => '1716', descr => 'deparse an encoded expression',
       proname => 'pg_get_expr', provolatile => 's', prorettype => 'text',
       proargtypes => 'pg_node_tree oid', prosrc => 'pg_get_expr' },
    @@ -8604,9 +8601,10 @@
       proname => 'pg_get_indexdef', provolatile => 's', prorettype => 'text',
       proargtypes => 'oid int4 bool', proargnames => '{index,column,pretty}',
       proargdefaults => '{0,false}', prosrc => 'pg_get_indexdef' },
    -{ oid => '2508', descr => 'constraint description with pretty-print option',
    +{ oid => '2508', descr => 'constraint description',
       proname => 'pg_get_constraintdef', provolatile => 's', prorettype => 'text',
    -  proargtypes => 'oid bool', prosrc => 'pg_get_constraintdef_ext' },
    +  proargtypes => 'oid bool', proargnames => '{constraint,pretty}',
    +  proargdefaults => '{false}', prosrc => 'pg_get_constraintdef' },
     { oid => '8760', descr => 'get DDL to recreate a role',
       proname => 'pg_get_role_ddl', provariadic => 'text', proisstrict => 'f',
       provolatile => 's', proretset => 't', prorows => '10', prorettype => 'text',
    -- 
    2.52.0
    
    
    --GzYugJnip6WHHvTk
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: attachment;
    	filename=v7-0005-Handle-pg_get_expr-default-args-in-system_functio.patch